ts-ref-kit 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
var sn=Object.create;var Re=Object.defineProperty,un=Object.defineProperties,fn=Object.getOwnPropertyDescriptor,cn=Object.getOwnPropertyDescriptors,ln=Object.getOwnPropertyNames,ft=Object.getOwnPropertySymbols,pn=Object.getPrototypeOf,lt=Object.prototype.hasOwnProperty,yn=Object.prototype.propertyIsEnumerable;var ct=(e,t,n)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,F=(e,t)=>{for(var n in t||(t={}))lt.call(t,n)&&ct(e,n,t[n]);if(ft)for(var n of ft(t))yn.call(t,n)&&ct(e,n,t[n]);return e},je=(e,t)=>un(e,cn(t));var dn=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var mn=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ln(t))!lt.call(e,a)&&a!==n&&Re(e,a,{get:()=>t[a],enumerable:!(r=fn(t,a))||r.enumerable});return e};var pt=(e,t,n)=>(n=e!=null?sn(pn(e)):{},mn(t||!e||!e.__esModule?Re(n,"default",{value:e,enumerable:!0}):n,e));var Ve=dn(()=>{var Mt;(function(e){(function(t){var n=typeof globalThis=="object"?globalThis:typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:g(),r=a(e);typeof n.Reflect!="undefined"&&(r=a(n.Reflect,r)),t(r,n),typeof n.Reflect=="undefined"&&(n.Reflect=e);function a(h,v){return function(C,V){Object.defineProperty(h,C,{configurable:!0,writable:!0,value:V}),v&&v(C,V)}}function y(){try{return Function("return this;")()}catch(h){}}function d(){try{return(0,eval)("(function() { return this; })()")}catch(h){}}function g(){return y()||d()}})(function(t,n){var r=Object.prototype.hasOwnProperty,a=typeof Symbol=="function",y=a&&typeof Symbol.toPrimitive!="undefined"?Symbol.toPrimitive:"@@toPrimitive",d=a&&typeof Symbol.iterator!="undefined"?Symbol.iterator:"@@iterator",g=typeof Object.create=="function",h={__proto__:[]}instanceof Array,v=!g&&!h,C={create:g?function(){return _e(Object.create(null))}:h?function(){return _e({__proto__:null})}:function(){return _e({})},has:v?function(i,o){return r.call(i,o)}:function(i,o){return o in i},get:v?function(i,o){return r.call(i,o)?i[o]:void 0}:function(i,o){return i[o]}},V=Object.getPrototypeOf(Function),B=typeof Map=="function"&&typeof Map.prototype.entries=="function"?Map:tn(),we=typeof Set=="function"&&typeof Set.prototype.entries=="function"?Set:nn(),ve=typeof WeakMap=="function"?WeakMap:rn(),G=a?Symbol.for("@reflect-metadata:registry"):void 0,fe=Xt(),We=Kt(fe);function It(i,o,s,u){if(b(s)){if(!tt(i))throw new TypeError;if(!nt(o))throw new TypeError;return Ut(i,o)}else{if(!tt(i))throw new TypeError;if(!_(o))throw new TypeError;if(!_(u)&&!b(u)&&!W(u))throw new TypeError;return W(u)&&(u=void 0),s=J(s),Gt(i,o,s,u)}}t("decorate",It);function kt(i,o){function s(u,m){if(!_(u))throw new TypeError;if(!b(m)&&!qt(m))throw new TypeError;qe(i,o,u,m)}return s}t("metadata",kt);function Nt(i,o,s,u){if(!_(s))throw new TypeError;return b(u)||(u=J(u)),qe(i,o,s,u)}t("defineMetadata",Nt);function Vt(i,o,s){if(!_(o))throw new TypeError;return b(s)||(s=J(s)),He(i,o,s)}t("hasMetadata",Vt);function Jt(i,o,s){if(!_(o))throw new TypeError;return b(s)||(s=J(s)),Me(i,o,s)}t("hasOwnMetadata",Jt);function Ft(i,o,s){if(!_(o))throw new TypeError;return b(s)||(s=J(s)),Ze(i,o,s)}t("getMetadata",Ft);function $t(i,o,s){if(!_(o))throw new TypeError;return b(s)||(s=J(s)),Ye(i,o,s)}t("getOwnMetadata",$t);function zt(i,o){if(!_(i))throw new TypeError;return b(o)||(o=J(o)),Qe(i,o)}t("getMetadataKeys",zt);function Lt(i,o){if(!_(i))throw new TypeError;return b(o)||(o=J(o)),Xe(i,o)}t("getOwnMetadataKeys",Lt);function Bt(i,o,s){if(!_(o))throw new TypeError;if(b(s)||(s=J(s)),!_(o))throw new TypeError;b(s)||(s=J(s));var u=X(o,s,!1);return b(u)?!1:u.OrdinaryDeleteMetadata(i,o,s)}t("deleteMetadata",Bt);function Ut(i,o){for(var s=i.length-1;s>=0;--s){var u=i[s],m=u(o);if(!b(m)&&!W(m)){if(!nt(m))throw new TypeError;o=m}}return o}function Gt(i,o,s,u){for(var m=i.length-1;m>=0;--m){var R=i[m],x=R(o,s,u);if(!b(x)&&!W(x)){if(!_(x))throw new TypeError;u=x}}return u}function He(i,o,s){var u=Me(i,o,s);if(u)return!0;var m=Ae(o);return W(m)?!1:He(i,m,s)}function Me(i,o,s){var u=X(o,s,!1);return b(u)?!1:et(u.OrdinaryHasOwnMetadata(i,o,s))}function Ze(i,o,s){var u=Me(i,o,s);if(u)return Ye(i,o,s);var m=Ae(o);if(!W(m))return Ze(i,m,s)}function Ye(i,o,s){var u=X(o,s,!1);if(!b(u))return u.OrdinaryGetOwnMetadata(i,o,s)}function qe(i,o,s,u){var m=X(s,u,!0);m.OrdinaryDefineOwnMetadata(i,o,s,u)}function Qe(i,o){var s=Xe(i,o),u=Ae(i);if(u===null)return s;var m=Qe(u,o);if(m.length<=0)return s;if(s.length<=0)return m;for(var R=new we,x=[],T=0,f=s;T<f.length;T++){var c=f[T],l=R.has(c);l||(R.add(c),x.push(c))}for(var p=0,D=m;p<D.length;p++){var c=D[p],l=R.has(c);l||(R.add(c),x.push(c))}return x}function Xe(i,o){var s=X(i,o,!1);return s?s.OrdinaryOwnMetadataKeys(i,o):[]}function Ke(i){if(i===null)return 1;switch(typeof i){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return i===null?1:6;default:return 6}}function b(i){return i===void 0}function W(i){return i===null}function Wt(i){return typeof i=="symbol"}function _(i){return typeof i=="object"?i!==null:typeof i=="function"}function Ht(i,o){switch(Ke(i)){case 0:return i;case 1:return i;case 2:return i;case 3:return i;case 4:return i;case 5:return i}var s=o===3?"string":o===5?"number":"default",u=rt(i,y);if(u!==void 0){var m=u.call(i,s);if(_(m))throw new TypeError;return m}return Zt(i,s==="default"?"number":s)}function Zt(i,o){if(o==="string"){var s=i.toString;if(H(s)){var u=s.call(i);if(!_(u))return u}var m=i.valueOf;if(H(m)){var u=m.call(i);if(!_(u))return u}}else{var m=i.valueOf;if(H(m)){var u=m.call(i);if(!_(u))return u}var R=i.toString;if(H(R)){var u=R.call(i);if(!_(u))return u}}throw new TypeError}function et(i){return!!i}function Yt(i){return""+i}function J(i){var o=Ht(i,3);return Wt(o)?o:Yt(o)}function tt(i){return Array.isArray?Array.isArray(i):i instanceof Object?i instanceof Array:Object.prototype.toString.call(i)==="[object Array]"}function H(i){return typeof i=="function"}function nt(i){return typeof i=="function"}function qt(i){switch(Ke(i)){case 3:return!0;case 4:return!0;default:return!1}}function Oe(i,o){return i===o||i!==i&&o!==o}function rt(i,o){var s=i[o];if(s!=null){if(!H(s))throw new TypeError;return s}}function it(i){var o=rt(i,d);if(!H(o))throw new TypeError;var s=o.call(i);if(!_(s))throw new TypeError;return s}function ot(i){return i.value}function at(i){var o=i.next();return o.done?!1:o}function st(i){var o=i.return;o&&o.call(i)}function Ae(i){var o=Object.getPrototypeOf(i);if(typeof i!="function"||i===V||o!==V)return o;var s=i.prototype,u=s&&Object.getPrototypeOf(s);if(u==null||u===Object.prototype)return o;var m=u.constructor;return typeof m!="function"||m===i?o:m}function Qt(){var i;!b(G)&&typeof n.Reflect!="undefined"&&!(G in n.Reflect)&&typeof n.Reflect.defineMetadata=="function"&&(i=en(n.Reflect));var o,s,u,m=new ve,R={registerProvider:x,getProvider:f,setProvider:l};return R;function x(p){if(!Object.isExtensible(R))throw new Error("Cannot add provider to a frozen registry.");switch(!0){case i===p:break;case b(o):o=p;break;case o===p:break;case b(s):s=p;break;case s===p:break;default:u===void 0&&(u=new we),u.add(p);break}}function T(p,D){if(!b(o)){if(o.isProviderFor(p,D))return o;if(!b(s)){if(s.isProviderFor(p,D))return o;if(!b(u))for(var M=it(u);;){var j=at(M);if(!j)return;var N=ot(j);if(N.isProviderFor(p,D))return st(M),N}}}if(!b(i)&&i.isProviderFor(p,D))return i}function f(p,D){var M=m.get(p),j;return b(M)||(j=M.get(D)),b(j)&&(j=T(p,D),b(j)||(b(M)&&(M=new B,m.set(p,M)),M.set(D,j))),j}function c(p){if(b(p))throw new TypeError;return o===p||s===p||!b(u)&&u.has(p)}function l(p,D,M){if(!c(M))throw new Error("Metadata provider not registered.");var j=f(p,D);if(j!==M){if(!b(j))return!1;var N=m.get(p);b(N)&&(N=new B,m.set(p,N)),N.set(D,M)}return!0}}function Xt(){var i;return!b(G)&&_(n.Reflect)&&Object.isExtensible(n.Reflect)&&(i=n.Reflect[G]),b(i)&&(i=Qt()),!b(G)&&_(n.Reflect)&&Object.isExtensible(n.Reflect)&&Object.defineProperty(n.Reflect,G,{enumerable:!1,configurable:!1,writable:!1,value:i}),i}function Kt(i){var o=new ve,s={isProviderFor:function(c,l){var p=o.get(c);return b(p)?!1:p.has(l)},OrdinaryDefineOwnMetadata:x,OrdinaryHasOwnMetadata:m,OrdinaryGetOwnMetadata:R,OrdinaryOwnMetadataKeys:T,OrdinaryDeleteMetadata:f};return fe.registerProvider(s),s;function u(c,l,p){var D=o.get(c),M=!1;if(b(D)){if(!p)return;D=new B,o.set(c,D),M=!0}var j=D.get(l);if(b(j)){if(!p)return;if(j=new B,D.set(l,j),!i.setProvider(c,l,s))throw D.delete(l),M&&o.delete(c),new Error("Wrong provider for target.")}return j}function m(c,l,p){var D=u(l,p,!1);return b(D)?!1:et(D.has(c))}function R(c,l,p){var D=u(l,p,!1);if(!b(D))return D.get(c)}function x(c,l,p,D){var M=u(p,D,!0);M.set(c,l)}function T(c,l){var p=[],D=u(c,l,!1);if(b(D))return p;for(var M=D.keys(),j=it(M),N=0;;){var ut=at(j);if(!ut)return p.length=N,p;var on=ot(ut);try{p[N]=on}catch(an){try{st(j)}finally{throw an}}N++}}function f(c,l,p){var D=u(l,p,!1);if(b(D)||!D.delete(c))return!1;if(D.size===0){var M=o.get(l);b(M)||(M.delete(p),M.size===0&&o.delete(M))}return!0}}function en(i){var o=i.defineMetadata,s=i.hasOwnMetadata,u=i.getOwnMetadata,m=i.getOwnMetadataKeys,R=i.deleteMetadata,x=new ve,T={isProviderFor:function(f,c){var l=x.get(f);return!b(l)&&l.has(c)?!0:m(f,c).length?(b(l)&&(l=new we,x.set(f,l)),l.add(c),!0):!1},OrdinaryDefineOwnMetadata:o,OrdinaryHasOwnMetadata:s,OrdinaryGetOwnMetadata:u,OrdinaryOwnMetadataKeys:m,OrdinaryDeleteMetadata:R};return T}function X(i,o,s){var u=fe.getProvider(i,o);if(!b(u))return u;if(s){if(fe.setProvider(i,o,We))return We;throw new Error("Illegal state.")}}function tn(){var i={},o=[],s=(function(){function T(f,c,l){this._index=0,this._keys=f,this._values=c,this._selector=l}return T.prototype["@@iterator"]=function(){return this},T.prototype[d]=function(){return this},T.prototype.next=function(){var f=this._index;if(f>=0&&f<this._keys.length){var c=this._selector(this._keys[f],this._values[f]);return f+1>=this._keys.length?(this._index=-1,this._keys=o,this._values=o):this._index++,{value:c,done:!1}}return{value:void 0,done:!0}},T.prototype.throw=function(f){throw this._index>=0&&(this._index=-1,this._keys=o,this._values=o),f},T.prototype.return=function(f){return this._index>=0&&(this._index=-1,this._keys=o,this._values=o),{value:f,done:!0}},T})(),u=(function(){function T(){this._keys=[],this._values=[],this._cacheKey=i,this._cacheIndex=-2}return Object.defineProperty(T.prototype,"size",{get:function(){return this._keys.length},enumerable:!0,configurable:!0}),T.prototype.has=function(f){return this._find(f,!1)>=0},T.prototype.get=function(f){var c=this._find(f,!1);return c>=0?this._values[c]:void 0},T.prototype.set=function(f,c){var l=this._find(f,!0);return this._values[l]=c,this},T.prototype.delete=function(f){var c=this._find(f,!1);if(c>=0){for(var l=this._keys.length,p=c+1;p<l;p++)this._keys[p-1]=this._keys[p],this._values[p-1]=this._values[p];return this._keys.length--,this._values.length--,Oe(f,this._cacheKey)&&(this._cacheKey=i,this._cacheIndex=-2),!0}return!1},T.prototype.clear=function(){this._keys.length=0,this._values.length=0,this._cacheKey=i,this._cacheIndex=-2},T.prototype.keys=function(){return new s(this._keys,this._values,m)},T.prototype.values=function(){return new s(this._keys,this._values,R)},T.prototype.entries=function(){return new s(this._keys,this._values,x)},T.prototype["@@iterator"]=function(){return this.entries()},T.prototype[d]=function(){return this.entries()},T.prototype._find=function(f,c){if(!Oe(this._cacheKey,f)){this._cacheIndex=-1;for(var l=0;l<this._keys.length;l++)if(Oe(this._keys[l],f)){this._cacheIndex=l;break}}return this._cacheIndex<0&&c&&(this._cacheIndex=this._keys.length,this._keys.push(f),this._values.push(void 0)),this._cacheIndex},T})();return u;function m(T,f){return T}function R(T,f){return f}function x(T,f){return[T,f]}}function nn(){var i=(function(){function o(){this._map=new B}return Object.defineProperty(o.prototype,"size",{get:function(){return this._map.size},enumerable:!0,configurable:!0}),o.prototype.has=function(s){return this._map.has(s)},o.prototype.add=function(s){return this._map.set(s,s),this},o.prototype.delete=function(s){return this._map.delete(s)},o.prototype.clear=function(){this._map.clear()},o.prototype.keys=function(){return this._map.keys()},o.prototype.values=function(){return this._map.keys()},o.prototype.entries=function(){return this._map.entries()},o.prototype["@@iterator"]=function(){return this.keys()},o.prototype[d]=function(){return this.keys()},o})();return i}function rn(){var i=16,o=C.create(),s=u();return(function(){function f(){this._key=u()}return f.prototype.has=function(c){var l=m(c,!1);return l!==void 0?C.has(l,this._key):!1},f.prototype.get=function(c){var l=m(c,!1);return l!==void 0?C.get(l,this._key):void 0},f.prototype.set=function(c,l){var p=m(c,!0);return p[this._key]=l,this},f.prototype.delete=function(c){var l=m(c,!1);return l!==void 0?delete l[this._key]:!1},f.prototype.clear=function(){this._key=u()},f})();function u(){var f;do f="@@WeakMap@@"+T();while(C.has(o,f));return o[f]=!0,f}function m(f,c){if(!r.call(f,s)){if(!c)return;Object.defineProperty(f,s,{value:C.create()})}return f[s]}function R(f,c){for(var l=0;l<c;++l)f[l]=Math.random()*255|0;return f}function x(f){if(typeof Uint8Array=="function"){var c=new Uint8Array(f);return typeof crypto!="undefined"?crypto.getRandomValues(c):typeof msCrypto!="undefined"?msCrypto.getRandomValues(c):R(c,f),c}return R(new Array(f),f)}function T(){var f=x(i);f[6]=f[6]&79|64,f[8]=f[8]&191|128;for(var c="",l=0;l<i;++l){var p=f[l];(l===4||l===6||l===8)&&(c+="-"),p<16&&(c+="0"),c+=p.toString(16).toLowerCase()}return c}}function _e(i){return i.__=void 0,delete i.__,i}})})(Mt||(Mt={}))});var bn=["string","number","boolean","bigint","symbol"];function yt(e){return!!(e.name&&["any","void","unknown"].includes(e.name))}function dt(e){return!!(e.name&&bn.includes(e.name))}function K(e){return!!e.arrayElementType}function xe(e){return!!e.literalValue}function Se(e){return!!e.typeLiteralMembers}function Pe(e){return!!e.unionMembers}function Ce(e){return!!e.intersectionMembers}function Ee(e){return!!e.tupleMembers}function Zn(e){return!!e.generics}var ce=new Map,le=new Map,pe=new Map,ye=new Map,gn=new Map,Xn=(e=>{gn.set(e.name,e)}),hn={string:String,number:Number,boolean:Boolean,object:Object},ee={getClassDefinition:Tn,getInterfaceDefinition:Dn,getEnumDefinition:wn,getTypeAliasDefinition:vn},P=Reflect;function te(e){return P.__classDef[e]||globalThis[e]||hn[e]}function Tn(e){var n,r;let t;switch(typeof e){case"function":t=e.name;break;case"string":t=e;break;case"object":t=e.constructor.name;break;default:return}if(!ce.has(t)){let a=(n=P.__classes)==null?void 0:n[t];if(!a)return;let y=(r=P.__classDef)==null?void 0:r[t];ce.set(t,new ne(je(F({},a),{jsClass:y})))}return ce.get(t)}function Dn(e){var t;if(!le.has(e)){let n=(t=P.__interfaces)==null?void 0:t[e];if(!n)return;le.set(e,new re(n))}return le.get(e)}function wn(e){var t;if(!pe.has(e)){let n=(t=P.__enums)==null?void 0:t[e];if(!n)return;pe.set(e,new ie(n))}return pe.get(e)}function vn(e){var t;if(!ye.has(e)){let n=E((t=P.__typeAliases)==null?void 0:t[e]);if(!n)return;ye.set(e,n)}return ye.get(e)}P.initReflectContext=()=>{P.__classes&&Object.entries(P.__classes).map(([e,t])=>{let n=P.__classDef[e];n&&ce.set(e,new ne(je(F({},t),{jsClass:n})))}),P.__interfaces&&Object.entries(P.__interfaces).map(([e,t])=>le.set(e,new re(t))),P.__enums&&Object.entries(P.__enums).map(([e,t])=>pe.set(e,new ie(t))),P.__typeAliases&&Object.entries(P.__typeAliases).map(([e,t])=>{ye.set(e,E(t))}),["__classDef","__classes","__interfaces","__enums","__typeAliases","initReflectContext"].forEach(e=>delete P[e])};var ne=class{constructor(t){var n,r;this.name=t.name,this.superClassName=t.superClassName||"Object",this.superClass=S(this.superClassName),this._implementationNames=t.implementations||[],this.methods=((n=t.methods)==null?void 0:n.map(de))||[],this.properties=((r=t.properties)==null?void 0:r.map(me))||[],this.jsClass=t.jsClass}get allMethods(){let t={};if(this.superClassName!=="Object"){let n=S(this.superClassName);n&&Object.assign(t,F({},n.allMethods))}return Object.assign(t,F({},mt(this.methods,n=>[n.name,n]))),t}get allProperties(){var t;return Object.assign(((t=this.superClass)==null?void 0:t.allProperties)||{},mt(this.properties,n=>[n.name,n]))}get implementations(){return this._implementations?this._implementations:Mn(this._implementationNames,$)}get allImplementations(){var t,n;if(this._allImplementations===void 0){let r=new Set(this.implementations);this.implementations.forEach(a=>{a.allImplementations.forEach(y=>r.add(y))}),(n=(t=this.superClass)==null?void 0:t.allImplementations)==null||n.forEach(a=>r.add(a)),this._allImplementations=Array.from(r)}return this._allImplementations}getProperty(t){return this.properties.find(n=>n.name===t)}get type(){var n,r;let t={};return(r=(n=this.superClass)==null?void 0:n.type.typeLiteralMembers)==null||r.forEach(a=>t[a.name]=a),this.properties.forEach(a=>t[a.name]=a),{name:this.name,typeLiteralMembers:Object.values(t)}}isSubClassOf(t){var n;return this.name===t||(n=this.superClass)!=null&&n.isSubClassOf(t)?!0:this.implementations.map(r=>r.name).includes(t)}isSuperClassOf(t){if(this.name===t)return!0;let n=S(t);return n?n.isSubClassOf(this.name):!1}toString(){return`class ${this.name}`}};function mt(e,t){let n={};return e.forEach(r=>{let[a,y]=t(r);n[a]=y}),n}function Mn(e,t){return(e==null?void 0:e.map(t).filter(n=>n!==void 0))||[]}function Z(e,t,n){e!==void 0&&(e[t]=n)}function Y(e,t){if(e!==void 0)return e[t]}function bt(e,t){return(e==null?void 0:e.map(t).filter(n=>n!==void 0))||[]}function be(e){try{Object.entries(e).forEach(t=>Object.defineProperty(globalThis,t[0],{value:t[1]}))}catch(t){console.log(t)}}var re=class{constructor(t){var n,r;this.name=t.name,this._implementationNames=t.implementations||[],this.methods=((n=t.methods)==null?void 0:n.map(de))||[],this.properties=((r=t.properties)==null?void 0:r.map(me))||[]}get implementations(){return this._implementations||(this._implementations=bt(this._implementationNames,$)),this._implementations}get allImplementations(){if(this._allImplementations===void 0){let t=new Set(this.implementations);this.implementations.forEach(n=>{n.allImplementations.forEach(r=>t.add(r))}),this._allImplementations=Array.from(t)}return this._allImplementations}get type(){let t={};return this.allImplementations.forEach(n=>{let r=n.type.typeLiteralMembers;r==null||r.forEach(a=>t[a.name]=a)}),this.properties.forEach(n=>t[n.name]=n),{name:this.name,typeLiteralMembers:Object.values(t)}}toString(){return`interface ${this.name}`}buildBaseObject(){let t={};return this.properties.forEach(n=>Z(t,n.name,void 0)),this.methods.forEach(n=>Z(t,n.name,()=>{})),t}};var ie=class{constructor(t){this.name=t.name,this.members=new Map,t.members.forEach(n=>{let r=n.initializer===void 0?{name:"number"}:{literalValue:n.initializer};this.members.set(n.name,r)})}get type(){return{name:this.name,unionMembers:Array.from(this.members.values())}}get names(){return Array.from(this.members.keys())}};var Ie=class{constructor(t){var n;this.name=t.name,this.returnType=E(t.returnType),this.args=((n=t.args)==null?void 0:n.map(r=>({name:r.name,type:E(r.type),isOptional:r.isOptional})))||[],this.isPrivate=t.isPrivate||!1,this.isStatic=t.isStatic||!1,this.isAsync=t.isAsync||!1}};function de(e){return new Ie(e)}var ke=class{constructor(t){this.name=t.name,this.isOptional=t.isOptional||!1,this.isPrivate=t.isPrivate||!1,this.isStatic=t.isStatic||!1,this.type=E(t.type),this.accessor=t.accessor&&F({},t.accessor)}};function me(e){return new ke(e)}var k={name:"any"},On={name:"null"};function S(e){return ee.getClassDefinition(e)}function $(e){return ee.getInterfaceDefinition(e)}function q(e){return ee.getEnumDefinition(e)}function ge(e){return ee.getTypeAliasDefinition(e)}function z(e){if(e==="any"||e==="Any"||e==="unknown"||e==="")return k;if(e==="null")return On;let t=S(e)||$(e)||q(e);if(t)return t.type;let n=ge(e);return n||k}function gt(e){var t;return((t=q(e))==null?void 0:t.names)||[]}function ht(e){let t=Object.entries(e)[0];if(!t)return[];let[n,r]=t,a=q(n);return a?a.names.map(y=>r[y]):Array.from(Object.keys(r))}function E(e){switch(typeof e){case"undefined":return k;case"string":return Object.assign({},z(e)||{},{name:e});default:if(e.arrayElementType)Object.assign(e,{arrayElementType:E(e.arrayElementType)});else if(e.unionMembers)Object.assign(e,{unionMembers:e.unionMembers.map(E)});else if(e.intersectionMembers)Object.assign(e,{intersectionMembers:e.intersectionMembers.map(E)});else if(e.tupleMembers)Object.assign(e,{tupleMembers:e.tupleMembers.map(E)});else if(e.generics){let t=E(e.generics[0]);return t.generics=e.generics.slice(1).map(E),t}return e}}be({getClassByName:te,getInterfaceDefinition:$,getEnumDefinition:q,getTypeAliasDefinition:ge,getTypeDefinition:z});var w={success:!0},O=(e,t)=>({success:!1,errorMessage:e,cause:t}),An=[Promise,Date,Map,Set,Error,Function];function I(e,t,n=1){switch(!0){case t.name==="undefined":return e===void 0?w:O(`declared as ${A(t)} but actually not`);case yt(t):return w;case K(t):return _n(e,t,n);case Ee(t):return Rn(e,t,n);case Pe(t):for(let r of t.unionMembers||[])if(I(e,r,n).success)return w;return O(`declared as ${A(t)} but all value not match`);case Ce(t):for(let r of t.intersectionMembers||[]){let a=I(e,r,n);if(!a.success)return O(`declared as ${A(t)} but all value not match`,a)}return w;case xe(t):switch(typeof e){case"string":return e===Cn(t.literalValue)?w:O(`declared as string ${A(t)} but value not match`);case"number":return e===Number(t.literalValue)?w:O(`declared as number ${A(t)} but value not match`);case"bigint":return e===BigInt(t.literalValue)?w:O(`declared as bigint ${A(t)} but value not match`);case"boolean":return e===!!t.literalValue?w:O(`declared as boolean ${A(t)} but value not match`);default:return t.literalValue==="null"&&e===null||e===t.literalValue?w:O(`declared as ${A(t)} but value not match`)}case Se(t):return jn(e,t,n);case t.isFunction:case t.isConstructor:return typeof e=="function"?w:O(`declared as ${A(t)} but actually not`);case dt(t):return typeof e===t.name?w:O(`declared as ${A(t)} but actually ${typeof e}`);default:return xn(e,t,n)}}function _n(e,t,n=1){if(!Array.isArray(e))return O(`declared as ${A(t)} but actually not`);if(n===0)return w;for(let r of e){let a=I(r,t.arrayElementType||k,n-1);if(!a.success)return O(`declared as ${A(t)} but not all values in array match`,a)}return w}function Rn(e,t,n=1){if(!Array.isArray(e))return O(`declared as ${A(t)} but actually not a tuple`);if(n===0)return w;let r=0;for(let a of t.tupleMembers){let y=e[r++];if(a.isOptionalInTuple&&y===void 0)continue;let d=I(e[r],a,n);if(!d.success)return O(`declared as ${A(t)} but not all values in tuple match`,d)}return w}function jn(e,t,n=1){if(e instanceof Object){for(let r of t.typeLiteralMembers||[]){if(r.isStatic||r.name.startsWith("[")&&r.name.endsWith("]")||n===0)return w;let a=r.type||k;r.isOptional&&(a={unionMembers:[a,{name:"undefined"}]});let y=Y(e,r.name),d=I(y,a,n-1);if(!d.success)return O(`declared ${r.name} as ${A(a)}, but not match`,d)}return w}else return O(`declared as ${A(t)} but not an object`)}function xn(e,t,n=1){let r=typeof t=="string"?t:t.name;if(!r)return w;if(e===void 0)return O(`declared as ${A(t)} but actually undefined`);if(e===null)return r==="null"?w:O(`declared as ${A(t)} but actually null`);for(let y of An)if(r===y.name)return e instanceof y?w:O(`declared as ${A(t)} but actually ${e.constructor.name}`);if(e instanceof Object&&!Tt(e,r))return O(`declared as ${A(t)} but actually not instance of it`);if(n==0)return w;let a=I(e,z(r),n);return a.success?w:O(`declared as ${A(t)} but actually not match`,a)}function Q(e,t,n=1){if(t){if(t!=="object"&&!Tt(e,t))return O(`declared as instance of ${t} but actually not`)}else t=e.constructor.name;let r=z(t);return t!=="any"&&r===k?O(`${t} not defined`):I(e,r,n)}function Sn(e,t,n=1){for(let r=0;r<e.length;r++){let a=Q(e[r],t,n);if(!a.success)return O(`declared as instance of ${t}[] but [${r}] actually not`,a)}return w}function Pn(e,t,n=1){let r=Object.entries(e);for(let a=0;a<r.length;a++){let[y,d]=r[a],g=Q(d,t,n);if(!g.success)return O(`declared as instance of Dictionary<${t}> but [${y}] actually not`,g)}return w}function Tt(e,t){if(e===void 0||e.constructor.name===t)return!0;let n=S(t);if(!n)return!0;if(n.jsClass)return e instanceof n.jsClass;let r=S(e);return r?r.isSubClassOf(n.name):!1}function Cn(e){return e.length>=2&&(e[0]==='"'&&e[e.length-1]==='"'||e[0]==="'"&&e[e.length-1]==="'")?e.substring(1,e.length-1):e}function A(e){var t,n,r;return typeof e=="string"?e:K(e)?(((t=e.arrayElementType)==null?void 0:t.name)||"unknown")+"[]":e.isConstructor?"Class":e.isFunction?"Function":Se(e)?"Object":Ee(e)?`(${e.tupleMembers.map(A).join(",")})`:Pe(e)?((n=e.unionMembers)==null?void 0:n.map(A).join(" | "))||"unknown":Ce(e)?((r=e.intersectionMembers)==null?void 0:r.map(A).join(" & "))||"unknown":xe(e)?e.literalValue:e.name||"unknown"}function Dt(e){let t=n=>n.errorMessage?[n.errorMessage,...n.cause?t(n.cause):[]]:[];return t(e).join(`
|
|
2
|
-
-> `)}function xr(e){let{funcName:t,optionsObj:n,value:r,argName:a,type:y,optional:d}=e,g=r||n&&Y(n,a);if(g===void 0){if(d)return;throw Error(`Illegal arguments for ${t}: ${a} is undefined`)}if(["string","number","boolean","bigint"].includes(y)){if(typeof g!==y)throw Error(`Illegal arguments for ${t}: ${a} is not a ${y}`);return}if(typeof g!="object")throw Error(`Illegal arguments for ${t}: ${a} is not an object`);if(g===null)throw Error(`Illegal arguments for ${t}: ${a} is null`);let h=Q(g,y);if(!h.success)throw Error(`Illegal arguments for ${t}: ${h.errorMessage}`)}function Sr(e,t,n){let r=S(e);if(!r){Z(e,t,n);return}let a=r.allProperties[t];if(!a)throw new Error(`Property ${t} is not defined in ${r.name}`);let y=a.type,d=I(n,y);if(!d.success)throw new Error(d.errorMessage);Z(e,t,n)}be({validateInstance:Q,validateArray:Sn,validateDictionary:Pn,getClassDefinition:S,getInterfaceDefinition:$,getEnumDefinition:q,getTypeAliasDefinition:ge,getTypeDefinition:z,getEnumNames:gt,getEnumValues:ht});function oe(e){if(typeof e=="string")return z(e);let t=e;if(t.array)return{arrayElementType:oe(t.array)};let n=e;if(n.union)return{unionMembers:n.union.map(oe)};let r=e;if(r.intersection)return{intersectionMembers:r.intersection.map(oe)};let a=e;if(a.tuple)return{tupleMembers:a.tuple.map(oe)};throw new Error(`unknown type: ${e}`)}function Er(e,t,n=5){let r=I(e,oe(t),n);if(!r.success){console.error(`assert failed with type: ${t}`),console.dir(r);debugger}return e}var wt=Symbol("VALIDATE_WRAPPER"),Vr=(e,t,n)=>En(e,t,n);function En(e,t,n){let r=n.value;if(typeof r!="function"||Y(r,wt))return;let a=()=>{var h,v;return(v=(h=S(e))==null?void 0:h.methods)==null?void 0:v.find(C=>C.name===t)},y=h=>vt(e,a(),h),d=h=>In(e,a(),h),g=function(...h){y(h);let v=r.call(this,...h);return d(v)};g[wt]=r,n.value=g}function vt(e,t,n){var r;(r=t==null?void 0:t.args)==null||r.forEach((a,y)=>{let d=n==null?void 0:n[y];if(d===void 0){if(a.isOptional)return;throw new Error(`Illegal arguments for ${Ne(e.constructor.name,t)}: ${a.name} is not optional`)}let g=I(d,a.type||k,1);if(!g.success)throw console.error("validateResult",g),new Error(`Illegal arguments for ${Ne(e.constructor.name,t)}: ${a.name}: ${a.name} ${g.errorMessage}`)})}function In(e,t,n){var y;if(!t)return n;let r=(d,g)=>{let h=I(d,g,5);if(!h.success){console.error(h);debugger;throw new Error(`result for ${Ne(e.constructor.name,t)} doesn't match type ${g.name}: ${h.errorMessage}`)}return d},a=t.returnType;return a.name==="Promise"&&(a=((y=a.generics)==null?void 0:y[0])||k),n instanceof Promise?n.then(d=>r(d,a||k)):r(n,a||k)}function Ne(e,t){var n;return`${e}.${t.name}(${(n=t.args)==null?void 0:n.map(r=>r.name).join(", ")})`}function Jr(e,t,...n){let r=S(e);if(!r)return;let a=r.allMethods[t];if(a)return vt(e,a,n),Y(e,t).apply(e,n)}var ai=pt(Ve(),1);function Ot(e){return String(e).toLocaleLowerCase()==="false"?!1:!!e}function ae(e){return e==null||Number.isNaN(e)||e instanceof Date&&String(e)==="Invalid Date"?"":typeof e=="symbol"?e.description||"":String(e)}function Je(e){return e?e instanceof Date?e.getDate():Number(e):0}function L(e,t,n){e[t]=n}function he(e,t){return e[t]}function ei(e,t,n){let r=e[t];if(r!==void 0)return r;let a=n();return L(e,t,a),a}function At(e){return typeof e=="object"&&e!==null&&e.constructor===Object}function _t(e){let t=Object.create(e.prototype);return t.constructor=this,t}function Rt(e){return((t,n)=>Reflect.defineMetadata(e,n,t.constructor))}function jt(e,t,...n){let r=xt(e,t);if(r!==void 0&&r instanceof Function)return r.apply(e,n)}function ri(e,t){let n=xt(e,t);return n!==void 0&&n instanceof Function}function kn(e,t){return Reflect.getMetadata(t,e.constructor)}function xt(e,t){let n=kn(e,t);if(n!==void 0)return he(e,n)}var U=function({getter:e,setter:t,fieldSymbol:n}){return(r,a)=>{Object.defineProperty(r,a,{get:function(){return e?e(this,a):U.getField(r,a,n)},set:function(y){t?t(this,y,a):U.setField(r,a,y,n)}})}};L(U,"getField",(e,t,n)=>{var r;return(r=he(e,n))==null?void 0:r[t]});L(U,"setField",(e,t,n,r)=>{let a=he(e,r)||{};a[t]=n,L(e,r,a)});function ii(e){let t=Symbol("lazy");return U({getter:(n,r)=>{let a=U.getField(n,r,t);if(a)return a.value;let y=e(n,r);return U.setField(n,r,{value:y},t),y},setter:()=>{},fieldSymbol:t})}var se=Symbol("JSON_SERIALIZED"),St=Symbol("AFTER_SERIALIZED"),Fe=class{constructor(){this.settingsByName={};this.settingsBySerializedName={};this.ignoredProperties=[];this.defaultIgnored=!1}add(t){this.settingsByName[t.propName]=t,this.settingsBySerializedName[t.serializedName]=t}isPropertyIgnored(t){return this.defaultIgnored&&!this.settingsByName[t]?!0:this.ignoredProperties.indexOf(t)!==-1}},$e=class{constructor(t,n,r){this.target=t;this.propName=n;this.options=r;this.isArray=Reflect.getDesignType(t,n)===Array,this.serializedName=r.name||ae(n),this.class=r.class,this.fromJSON=this.createBuilder(),this.toJSON=r.toJSON||(a=>Ct(a))}createBuilder(){if(this.options.fromJSON)return this.options.fromJSON;if(this.class&&this.class instanceof Function){let t=this.class;return n=>{let r=ue.get(t);return r?r.fromJson(n):Be(n,t)}}else return t=>Fn(this.target,this.propName,t)}};function Pt(e,t){ze(e,n=>{n.defaultIgnored=t})}function Te(e,t,n){let r=e.constructor;ze(r,a=>{a.add(new $e(e,t,n))})}function ze(e,t){let n=Reflect.getMetadata(se,e);n===void 0&&(n=new Fe),t(n),Reflect.defineMetadata(se,n,e)}var pi=Nn();function Nn(e){return e=e||{},(t,n)=>Te(t,ae(n),e)}function yi(e){return(t,n)=>Te(t,ae(n),{name:e})}var di=(e,t)=>ze(e.constructor,n=>n.ignoredProperties.push(t));function mi(e){return JSON.stringify(typeof e=="object"?Le(e):e)}function Ct(e){if(e===void 0)throw new Error("attempt to serialize undefined value");if(e===null)return null;let t=ue.get(e.constructor);return t?t.toJson(e):Le(e)}function Le(e){var y;if(e instanceof Array)return e.map(d=>Le(d));if(At(e)){let d={};return Object.entries(e).forEach(g=>{let[h,v]=g;d[h]=Ct(v)}),d}let t=e.constructor;((y=S(t))==null?void 0:y.isSubClassOf("Mappable"))&&Ge(t);let r=Reflect.getMetadata(se,t);if(r===void 0)return e;let a={};return Object.entries(e).forEach(d=>{let g=d[0];if(r.isPropertyIgnored(g))return;let h=d[1];if(h===void 0||h instanceof Function||typeof h=="symbol")return;let v=r.settingsByName[g],C=(v==null?void 0:v.serializedName)||g;v&&(v.isArray?h=h.map(V=>v.toJSON(V)):h=v.toJSON(h)),a[C]=h}),a}function Be(e,t){var n;if(typeof e=="string"&&(e=JSON.parse(e)),t===null||t===void 0)return e;try{let r=e,a=t instanceof Function?t:t.constructor,y=(n=S(a))==null?void 0:n.isSubClassOf("Mappable");y&&Ge(a);let d=ue.get(a);if(d)return d.fromJson(r);let g=t instanceof Function?_t(t):t;if(Jn(r,g),y){let h=Q(g,a.name);if(!h.success)throw new Error(`JSON deserialize validate failed: ${Dt(h)} `)}return g}catch(r){throw console.error("failed to deserialize"),console.dir(r),r}}function Vn(e,t){let n=typeof e=="string"?JSON.parse(e):e;return n instanceof Array?n.map(r=>Be(r,t)):[]}function Jn(e,t){let n=t.constructor,r=Reflect.getMetadata(se,n);if(r===void 0){Object.assign(t,e);return}Object.keys(e).forEach(a=>{let y=r.settingsBySerializedName[a],d=e[a];if(y===void 0){r.defaultIgnored||L(t,a,d);return}let g=y.propName;if(r.isPropertyIgnored(g))return;let h;d instanceof Array?h=d.map(v=>y.fromJSON(v)):h=y.fromJSON(d),L(t,g,h)}),jt(t,St)}function bi(e){return Reflect.getMetadata(se,e)}function Fn(e,t,n){let r=Reflect.getDesignType(e,t);if(r===void 0)return n;if(r===Array)return Vn(n);let a=ue.get(r);return a?a.fromJson(n):Be(n,r)}var ue=new Map;function De(e,t){ue.set(e,t)}var Ue=e=>e,gi=()=>{};De(String,{fromJson:ae,toJson:Ue});De(Number,{fromJson:Je,toJson:Ue});De(Boolean,{fromJson:Ot,toJson:Ue});De(Date,{fromJson:e=>new Date(Je(e)),toJson:e=>e.getTime()});var hi=Rt(St);var Et=new Map;function Ge(e){if(Et.get(e))return;let t=S(e),n=new Proxy({},{get(a,y){return r(y)},set(a,y,d){return r(y)(d),!0}});function r(a){return(y,d)=>{var v,C,V;let g=(C=(v=Object.values((t==null?void 0:t.allProperties)||{}))==null?void 0:v.find(B=>B.name===a))==null?void 0:C.type,h=(g==null?void 0:g.name)!==void 0?te(g.name):void 0;g&&K(g)&&(h=((V=g.arrayElementType)==null?void 0:V.name)!==void 0?te(g.arrayElementType.name):void 0),typeof a=="string"&&(Te(e.prototype,a,{name:y,class:h,fromJSON:d==null?void 0:d.fromJSON,toJSON:d==null?void 0:d.toJSON}),Pt(e,!0))}}e.prototype.mapping(n),Et.set(e,!0)}function vi(e,t){let n=S(e);n&&n.properties.forEach(r=>t[r.name]())}var Oi=pt(Ve(),1),$n="design:type",zn="design:returntype",Ln="design:paramtypes";function Bn(e,t){return Reflect.getMetadata($n,e,t)}function Un(e,t){return Reflect.getMetadata(zn,e,t)}function Gn(e,t){return Reflect.getMetadata(Ln,e,t)}function Wn(e,t,n,r){let a=(r===void 0?Reflect.getMetadata(e,n):Reflect.getMetadata(e,n,r))||[];a.includes(t)||a.push(t),r===void 0?Reflect.defineMetadata(e,a,n):Reflect.defineMetadata(e,a,n,r)}Object.assign(Reflect,{getDesignType:Bn,getReturnType:Un,getParamTypes:Gn,addMetadataList:Wn});export{hi as AfterSerialized,ne as ClassDefinition,ie as EnumDefinition,di as IgnoreSerialization,re as InterfaceDefinition,ii as Lazy,Ie as MethodDefinition,ke as PropertyDefinition,U as PropertyWrapper,Xn as ReflectClass,ee as ReflectContext,Vr as ReflectValidate,Nn as Serialized,pi as SerializedClass,yi as SerializedName,k as anyType,Ot as asBoolean,Je as asNumber,ae as asString,Er as assertType,jt as callDecoratedMethod,_t as createNewInstance,Rt as defineDecoratedProperty,Be as deserialize,Vn as deserializeArray,Jn as deserializeFrom,gi as done,de as fillMethod,me as fillProperty,E as fillType,he as getAnyValue,te as getClassByName,S as getClassDefinition,kn as getDecoratedProperty,xt as getDecoratedPropertyValue,q as getEnumDefinition,gt as getEnumNames,ht as getEnumValues,Dt as getErrorTraceMessages,$ as getInterfaceDefinition,ei as getOrSetValue,bi as getSerializeSettings,ge as getTypeAliasDefinition,oe as getTypeDef,z as getTypeDefinition,ri as hasDecoratedMethod,Zn as hasGenerics,K as isArrayType,At as isDictionary,yt as isIgnoredType,Ce as isIntersectionType,xe as isLiteralType,dt as isPrimitiveType,Ee as isTupleType,Se as isTypeLiteralType,Pe as isUnionType,Ue as itSelf,vi as mapAllProperties,On as nullType,Ge as registerMappable,Te as registerSerializedProperty,De as registerTransform,Jr as safeCall,Sr as safeSetValue,mi as serialize,Ct as serializeTo,Le as serializeToData,L as setAnyValue,Pt as setDefaultIgnored,Sn as validateArray,Pn as validateDictionary,xr as validateFunctionArgument,Q as validateInstance,I as validateValue};
|
|
1
|
+
var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getOwnPropSymbols=Object.getOwnPropertySymbols;var __getProtoOf=Object.getPrototypeOf;var __hasOwnProp=Object.prototype.hasOwnProperty;var __propIsEnum=Object.prototype.propertyIsEnumerable;var __defNormalProp=(obj,key,value)=>key in obj?__defProp(obj,key,{enumerable:true,configurable:true,writable:true,value}):obj[key]=value;var __spreadValues=(a,b)=>{for(var prop in b||(b={}))if(__hasOwnProp.call(b,prop))__defNormalProp(a,prop,b[prop]);if(__getOwnPropSymbols)for(var prop of __getOwnPropSymbols(b)){if(__propIsEnum.call(b,prop))__defNormalProp(a,prop,b[prop])}return a};var __commonJS=(cb,mod)=>function __require(){return mod||(0,cb[__getOwnPropNames(cb)[0]])((mod={exports:{}}).exports,mod),mod.exports};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:true}):target,mod));var require_Reflect=__commonJS({"node_modules/reflect-metadata/Reflect.js"(){var Reflect2;(function(Reflect3){(function(factory){var root=typeof globalThis==="object"?globalThis:typeof global==="object"?global:typeof self==="object"?self:typeof this==="object"?this:sloppyModeThis();var exporter=makeExporter(Reflect3);if(typeof root.Reflect!=="undefined"){exporter=makeExporter(root.Reflect,exporter)}factory(exporter,root);if(typeof root.Reflect==="undefined"){root.Reflect=Reflect3}function makeExporter(target,previous){return function(key,value){Object.defineProperty(target,key,{configurable:true,writable:true,value});if(previous)previous(key,value)}}function functionThis(){try{return Function("return this;")()}catch(_){}}function indirectEvalThis(){try{return(void 0,eval)("(function() { return this; })()")}catch(_){}}function sloppyModeThis(){return functionThis()||indirectEvalThis()}})(function(exporter,root){var hasOwn=Object.prototype.hasOwnProperty;var supportsSymbol=typeof Symbol==="function";var toPrimitiveSymbol=supportsSymbol&&typeof Symbol.toPrimitive!=="undefined"?Symbol.toPrimitive:"@@toPrimitive";var iteratorSymbol=supportsSymbol&&typeof Symbol.iterator!=="undefined"?Symbol.iterator:"@@iterator";var supportsCreate=typeof Object.create==="function";var supportsProto={__proto__:[]}instanceof Array;var downLevel=!supportsCreate&&!supportsProto;var HashMap={create:supportsCreate?function(){return MakeDictionary(Object.create(null))}:supportsProto?function(){return MakeDictionary({__proto__:null})}:function(){return MakeDictionary({})},has:downLevel?function(map,key){return hasOwn.call(map,key)}:function(map,key){return key in map},get:downLevel?function(map,key){return hasOwn.call(map,key)?map[key]:void 0}:function(map,key){return map[key]}};var functionPrototype=Object.getPrototypeOf(Function);var _Map=typeof Map==="function"&&typeof Map.prototype.entries==="function"?Map:CreateMapPolyfill();var _Set=typeof Set==="function"&&typeof Set.prototype.entries==="function"?Set:CreateSetPolyfill();var _WeakMap=typeof WeakMap==="function"?WeakMap:CreateWeakMapPolyfill();var registrySymbol=supportsSymbol?Symbol.for("@reflect-metadata:registry"):void 0;var metadataRegistry=GetOrCreateMetadataRegistry();var metadataProvider=CreateMetadataProvider(metadataRegistry);function decorate(decorators,target,propertyKey,attributes){if(!IsUndefined(propertyKey)){if(!IsArray(decorators))throw new TypeError;if(!IsObject(target))throw new TypeError;if(!IsObject(attributes)&&!IsUndefined(attributes)&&!IsNull(attributes))throw new TypeError;if(IsNull(attributes))attributes=void 0;propertyKey=ToPropertyKey(propertyKey);return DecorateProperty(decorators,target,propertyKey,attributes)}else{if(!IsArray(decorators))throw new TypeError;if(!IsConstructor(target))throw new TypeError;return DecorateConstructor(decorators,target)}}exporter("decorate",decorate);function metadata(metadataKey,metadataValue){function decorator(target,propertyKey){if(!IsObject(target))throw new TypeError;if(!IsUndefined(propertyKey)&&!IsPropertyKey(propertyKey))throw new TypeError;OrdinaryDefineOwnMetadata(metadataKey,metadataValue,target,propertyKey)}return decorator}exporter("metadata",metadata);function defineMetadata(metadataKey,metadataValue,target,propertyKey){if(!IsObject(target))throw new TypeError;if(!IsUndefined(propertyKey))propertyKey=ToPropertyKey(propertyKey);return OrdinaryDefineOwnMetadata(metadataKey,metadataValue,target,propertyKey)}exporter("defineMetadata",defineMetadata);function hasMetadata(metadataKey,target,propertyKey){if(!IsObject(target))throw new TypeError;if(!IsUndefined(propertyKey))propertyKey=ToPropertyKey(propertyKey);return OrdinaryHasMetadata(metadataKey,target,propertyKey)}exporter("hasMetadata",hasMetadata);function hasOwnMetadata(metadataKey,target,propertyKey){if(!IsObject(target))throw new TypeError;if(!IsUndefined(propertyKey))propertyKey=ToPropertyKey(propertyKey);return OrdinaryHasOwnMetadata(metadataKey,target,propertyKey)}exporter("hasOwnMetadata",hasOwnMetadata);function getMetadata(metadataKey,target,propertyKey){if(!IsObject(target))throw new TypeError;if(!IsUndefined(propertyKey))propertyKey=ToPropertyKey(propertyKey);return OrdinaryGetMetadata(metadataKey,target,propertyKey)}exporter("getMetadata",getMetadata);function getOwnMetadata(metadataKey,target,propertyKey){if(!IsObject(target))throw new TypeError;if(!IsUndefined(propertyKey))propertyKey=ToPropertyKey(propertyKey);return OrdinaryGetOwnMetadata(metadataKey,target,propertyKey)}exporter("getOwnMetadata",getOwnMetadata);function getMetadataKeys(target,propertyKey){if(!IsObject(target))throw new TypeError;if(!IsUndefined(propertyKey))propertyKey=ToPropertyKey(propertyKey);return OrdinaryMetadataKeys(target,propertyKey)}exporter("getMetadataKeys",getMetadataKeys);function getOwnMetadataKeys(target,propertyKey){if(!IsObject(target))throw new TypeError;if(!IsUndefined(propertyKey))propertyKey=ToPropertyKey(propertyKey);return OrdinaryOwnMetadataKeys(target,propertyKey)}exporter("getOwnMetadataKeys",getOwnMetadataKeys);function deleteMetadata(metadataKey,target,propertyKey){if(!IsObject(target))throw new TypeError;if(!IsUndefined(propertyKey))propertyKey=ToPropertyKey(propertyKey);if(!IsObject(target))throw new TypeError;if(!IsUndefined(propertyKey))propertyKey=ToPropertyKey(propertyKey);var provider=GetMetadataProvider(target,propertyKey,false);if(IsUndefined(provider))return false;return provider.OrdinaryDeleteMetadata(metadataKey,target,propertyKey)}exporter("deleteMetadata",deleteMetadata);function DecorateConstructor(decorators,target){for(var i=decorators.length-1;i>=0;--i){var decorator=decorators[i];var decorated=decorator(target);if(!IsUndefined(decorated)&&!IsNull(decorated)){if(!IsConstructor(decorated))throw new TypeError;target=decorated}}return target}function DecorateProperty(decorators,target,propertyKey,descriptor){for(var i=decorators.length-1;i>=0;--i){var decorator=decorators[i];var decorated=decorator(target,propertyKey,descriptor);if(!IsUndefined(decorated)&&!IsNull(decorated)){if(!IsObject(decorated))throw new TypeError;descriptor=decorated}}return descriptor}function OrdinaryHasMetadata(MetadataKey,O,P){var hasOwn2=OrdinaryHasOwnMetadata(MetadataKey,O,P);if(hasOwn2)return true;var parent=OrdinaryGetPrototypeOf(O);if(!IsNull(parent))return OrdinaryHasMetadata(MetadataKey,parent,P);return false}function OrdinaryHasOwnMetadata(MetadataKey,O,P){var provider=GetMetadataProvider(O,P,false);if(IsUndefined(provider))return false;return ToBoolean(provider.OrdinaryHasOwnMetadata(MetadataKey,O,P))}function OrdinaryGetMetadata(MetadataKey,O,P){var hasOwn2=OrdinaryHasOwnMetadata(MetadataKey,O,P);if(hasOwn2)return OrdinaryGetOwnMetadata(MetadataKey,O,P);var parent=OrdinaryGetPrototypeOf(O);if(!IsNull(parent))return OrdinaryGetMetadata(MetadataKey,parent,P);return void 0}function OrdinaryGetOwnMetadata(MetadataKey,O,P){var provider=GetMetadataProvider(O,P,false);if(IsUndefined(provider))return;return provider.OrdinaryGetOwnMetadata(MetadataKey,O,P)}function OrdinaryDefineOwnMetadata(MetadataKey,MetadataValue,O,P){var provider=GetMetadataProvider(O,P,true);provider.OrdinaryDefineOwnMetadata(MetadataKey,MetadataValue,O,P)}function OrdinaryMetadataKeys(O,P){var ownKeys=OrdinaryOwnMetadataKeys(O,P);var parent=OrdinaryGetPrototypeOf(O);if(parent===null)return ownKeys;var parentKeys=OrdinaryMetadataKeys(parent,P);if(parentKeys.length<=0)return ownKeys;if(ownKeys.length<=0)return parentKeys;var set=new _Set;var keys=[];for(var _i=0,ownKeys_1=ownKeys;_i<ownKeys_1.length;_i++){var key=ownKeys_1[_i];var hasKey=set.has(key);if(!hasKey){set.add(key);keys.push(key)}}for(var _a=0,parentKeys_1=parentKeys;_a<parentKeys_1.length;_a++){var key=parentKeys_1[_a];var hasKey=set.has(key);if(!hasKey){set.add(key);keys.push(key)}}return keys}function OrdinaryOwnMetadataKeys(O,P){var provider=GetMetadataProvider(O,P,false);if(!provider){return[]}return provider.OrdinaryOwnMetadataKeys(O,P)}function Type(x){if(x===null)return 1;switch(typeof x){case"undefined":return 0;case"boolean":return 2;case"string":return 3;case"symbol":return 4;case"number":return 5;case"object":return x===null?1:6;default:return 6}}function IsUndefined(x){return x===void 0}function IsNull(x){return x===null}function IsSymbol(x){return typeof x==="symbol"}function IsObject(x){return typeof x==="object"?x!==null:typeof x==="function"}function ToPrimitive(input,PreferredType){switch(Type(input)){case 0:return input;case 1:return input;case 2:return input;case 3:return input;case 4:return input;case 5:return input}var hint=PreferredType===3?"string":PreferredType===5?"number":"default";var exoticToPrim=GetMethod(input,toPrimitiveSymbol);if(exoticToPrim!==void 0){var result=exoticToPrim.call(input,hint);if(IsObject(result))throw new TypeError;return result}return OrdinaryToPrimitive(input,hint==="default"?"number":hint)}function OrdinaryToPrimitive(O,hint){if(hint==="string"){var toString_1=O.toString;if(IsCallable(toString_1)){var result=toString_1.call(O);if(!IsObject(result))return result}var valueOf=O.valueOf;if(IsCallable(valueOf)){var result=valueOf.call(O);if(!IsObject(result))return result}}else{var valueOf=O.valueOf;if(IsCallable(valueOf)){var result=valueOf.call(O);if(!IsObject(result))return result}var toString_2=O.toString;if(IsCallable(toString_2)){var result=toString_2.call(O);if(!IsObject(result))return result}}throw new TypeError}function ToBoolean(argument){return!!argument}function ToString(argument){return""+argument}function ToPropertyKey(argument){var key=ToPrimitive(argument,3);if(IsSymbol(key))return key;return ToString(key)}function IsArray(argument){return Array.isArray?Array.isArray(argument):argument instanceof Object?argument instanceof Array:Object.prototype.toString.call(argument)==="[object Array]"}function IsCallable(argument){return typeof argument==="function"}function IsConstructor(argument){return typeof argument==="function"}function IsPropertyKey(argument){switch(Type(argument)){case 3:return true;case 4:return true;default:return false}}function SameValueZero(x,y){return x===y||x!==x&&y!==y}function GetMethod(V,P){var func=V[P];if(func===void 0||func===null)return void 0;if(!IsCallable(func))throw new TypeError;return func}function GetIterator(obj){var method=GetMethod(obj,iteratorSymbol);if(!IsCallable(method))throw new TypeError;var iterator=method.call(obj);if(!IsObject(iterator))throw new TypeError;return iterator}function IteratorValue(iterResult){return iterResult.value}function IteratorStep(iterator){var result=iterator.next();return result.done?false:result}function IteratorClose(iterator){var f=iterator["return"];if(f)f.call(iterator)}function OrdinaryGetPrototypeOf(O){var proto=Object.getPrototypeOf(O);if(typeof O!=="function"||O===functionPrototype)return proto;if(proto!==functionPrototype)return proto;var prototype=O.prototype;var prototypeProto=prototype&&Object.getPrototypeOf(prototype);if(prototypeProto==null||prototypeProto===Object.prototype)return proto;var constructor=prototypeProto.constructor;if(typeof constructor!=="function")return proto;if(constructor===O)return proto;return constructor}function CreateMetadataRegistry(){var fallback;if(!IsUndefined(registrySymbol)&&typeof root.Reflect!=="undefined"&&!(registrySymbol in root.Reflect)&&typeof root.Reflect.defineMetadata==="function"){fallback=CreateFallbackProvider(root.Reflect)}var first;var second;var rest;var targetProviderMap=new _WeakMap;var registry={registerProvider,getProvider,setProvider};return registry;function registerProvider(provider){if(!Object.isExtensible(registry)){throw new Error("Cannot add provider to a frozen registry.")}switch(true){case fallback===provider:break;case IsUndefined(first):first=provider;break;case first===provider:break;case IsUndefined(second):second=provider;break;case second===provider:break;default:if(rest===void 0)rest=new _Set;rest.add(provider);break}}function getProviderNoCache(O,P){if(!IsUndefined(first)){if(first.isProviderFor(O,P))return first;if(!IsUndefined(second)){if(second.isProviderFor(O,P))return first;if(!IsUndefined(rest)){var iterator=GetIterator(rest);while(true){var next=IteratorStep(iterator);if(!next){return void 0}var provider=IteratorValue(next);if(provider.isProviderFor(O,P)){IteratorClose(iterator);return provider}}}}}if(!IsUndefined(fallback)&&fallback.isProviderFor(O,P)){return fallback}return void 0}function getProvider(O,P){var providerMap=targetProviderMap.get(O);var provider;if(!IsUndefined(providerMap)){provider=providerMap.get(P)}if(!IsUndefined(provider)){return provider}provider=getProviderNoCache(O,P);if(!IsUndefined(provider)){if(IsUndefined(providerMap)){providerMap=new _Map;targetProviderMap.set(O,providerMap)}providerMap.set(P,provider)}return provider}function hasProvider(provider){if(IsUndefined(provider))throw new TypeError;return first===provider||second===provider||!IsUndefined(rest)&&rest.has(provider)}function setProvider(O,P,provider){if(!hasProvider(provider)){throw new Error("Metadata provider not registered.")}var existingProvider=getProvider(O,P);if(existingProvider!==provider){if(!IsUndefined(existingProvider)){return false}var providerMap=targetProviderMap.get(O);if(IsUndefined(providerMap)){providerMap=new _Map;targetProviderMap.set(O,providerMap)}providerMap.set(P,provider)}return true}}function GetOrCreateMetadataRegistry(){var metadataRegistry2;if(!IsUndefined(registrySymbol)&&IsObject(root.Reflect)&&Object.isExtensible(root.Reflect)){metadataRegistry2=root.Reflect[registrySymbol]}if(IsUndefined(metadataRegistry2)){metadataRegistry2=CreateMetadataRegistry()}if(!IsUndefined(registrySymbol)&&IsObject(root.Reflect)&&Object.isExtensible(root.Reflect)){Object.defineProperty(root.Reflect,registrySymbol,{enumerable:false,configurable:false,writable:false,value:metadataRegistry2})}return metadataRegistry2}function CreateMetadataProvider(registry){var metadata2=new _WeakMap;var provider={isProviderFor:function(O,P){var targetMetadata=metadata2.get(O);if(IsUndefined(targetMetadata))return false;return targetMetadata.has(P)},OrdinaryDefineOwnMetadata:OrdinaryDefineOwnMetadata2,OrdinaryHasOwnMetadata:OrdinaryHasOwnMetadata2,OrdinaryGetOwnMetadata:OrdinaryGetOwnMetadata2,OrdinaryOwnMetadataKeys:OrdinaryOwnMetadataKeys2,OrdinaryDeleteMetadata};metadataRegistry.registerProvider(provider);return provider;function GetOrCreateMetadataMap(O,P,Create){var targetMetadata=metadata2.get(O);var createdTargetMetadata=false;if(IsUndefined(targetMetadata)){if(!Create)return void 0;targetMetadata=new _Map;metadata2.set(O,targetMetadata);createdTargetMetadata=true}var metadataMap=targetMetadata.get(P);if(IsUndefined(metadataMap)){if(!Create)return void 0;metadataMap=new _Map;targetMetadata.set(P,metadataMap);if(!registry.setProvider(O,P,provider)){targetMetadata.delete(P);if(createdTargetMetadata){metadata2.delete(O)}throw new Error("Wrong provider for target.")}}return metadataMap}function OrdinaryHasOwnMetadata2(MetadataKey,O,P){var metadataMap=GetOrCreateMetadataMap(O,P,false);if(IsUndefined(metadataMap))return false;return ToBoolean(metadataMap.has(MetadataKey))}function OrdinaryGetOwnMetadata2(MetadataKey,O,P){var metadataMap=GetOrCreateMetadataMap(O,P,false);if(IsUndefined(metadataMap))return void 0;return metadataMap.get(MetadataKey)}function OrdinaryDefineOwnMetadata2(MetadataKey,MetadataValue,O,P){var metadataMap=GetOrCreateMetadataMap(O,P,true);metadataMap.set(MetadataKey,MetadataValue)}function OrdinaryOwnMetadataKeys2(O,P){var keys=[];var metadataMap=GetOrCreateMetadataMap(O,P,false);if(IsUndefined(metadataMap))return keys;var keysObj=metadataMap.keys();var iterator=GetIterator(keysObj);var k=0;while(true){var next=IteratorStep(iterator);if(!next){keys.length=k;return keys}var nextValue=IteratorValue(next);try{keys[k]=nextValue}catch(e){try{IteratorClose(iterator)}finally{throw e}}k++}}function OrdinaryDeleteMetadata(MetadataKey,O,P){var metadataMap=GetOrCreateMetadataMap(O,P,false);if(IsUndefined(metadataMap))return false;if(!metadataMap.delete(MetadataKey))return false;if(metadataMap.size===0){var targetMetadata=metadata2.get(O);if(!IsUndefined(targetMetadata)){targetMetadata.delete(P);if(targetMetadata.size===0){metadata2.delete(targetMetadata)}}}return true}}function CreateFallbackProvider(reflect2){var defineMetadata2=reflect2.defineMetadata,hasOwnMetadata2=reflect2.hasOwnMetadata,getOwnMetadata2=reflect2.getOwnMetadata,getOwnMetadataKeys2=reflect2.getOwnMetadataKeys,deleteMetadata2=reflect2.deleteMetadata;var metadataOwner=new _WeakMap;var provider={isProviderFor:function(O,P){var metadataPropertySet=metadataOwner.get(O);if(!IsUndefined(metadataPropertySet)&&metadataPropertySet.has(P)){return true}if(getOwnMetadataKeys2(O,P).length){if(IsUndefined(metadataPropertySet)){metadataPropertySet=new _Set;metadataOwner.set(O,metadataPropertySet)}metadataPropertySet.add(P);return true}return false},OrdinaryDefineOwnMetadata:defineMetadata2,OrdinaryHasOwnMetadata:hasOwnMetadata2,OrdinaryGetOwnMetadata:getOwnMetadata2,OrdinaryOwnMetadataKeys:getOwnMetadataKeys2,OrdinaryDeleteMetadata:deleteMetadata2};return provider}function GetMetadataProvider(O,P,Create){var registeredProvider=metadataRegistry.getProvider(O,P);if(!IsUndefined(registeredProvider)){return registeredProvider}if(Create){if(metadataRegistry.setProvider(O,P,metadataProvider)){return metadataProvider}throw new Error("Illegal state.")}return void 0}function CreateMapPolyfill(){var cacheSentinel={};var arraySentinel=[];var MapIterator=(function(){function MapIterator2(keys,values,selector){this._index=0;this._keys=keys;this._values=values;this._selector=selector}MapIterator2.prototype["@@iterator"]=function(){return this};MapIterator2.prototype[iteratorSymbol]=function(){return this};MapIterator2.prototype.next=function(){var index=this._index;if(index>=0&&index<this._keys.length){var result=this._selector(this._keys[index],this._values[index]);if(index+1>=this._keys.length){this._index=-1;this._keys=arraySentinel;this._values=arraySentinel}else{this._index++}return{value:result,done:false}}return{value:void 0,done:true}};MapIterator2.prototype.throw=function(error){if(this._index>=0){this._index=-1;this._keys=arraySentinel;this._values=arraySentinel}throw error};MapIterator2.prototype.return=function(value){if(this._index>=0){this._index=-1;this._keys=arraySentinel;this._values=arraySentinel}return{value,done:true}};return MapIterator2})();var Map2=(function(){function Map3(){this._keys=[];this._values=[];this._cacheKey=cacheSentinel;this._cacheIndex=-2}Object.defineProperty(Map3.prototype,"size",{get:function(){return this._keys.length},enumerable:true,configurable:true});Map3.prototype.has=function(key){return this._find(key,false)>=0};Map3.prototype.get=function(key){var index=this._find(key,false);return index>=0?this._values[index]:void 0};Map3.prototype.set=function(key,value){var index=this._find(key,true);this._values[index]=value;return this};Map3.prototype.delete=function(key){var index=this._find(key,false);if(index>=0){var size=this._keys.length;for(var i=index+1;i<size;i++){this._keys[i-1]=this._keys[i];this._values[i-1]=this._values[i]}this._keys.length--;this._values.length--;if(SameValueZero(key,this._cacheKey)){this._cacheKey=cacheSentinel;this._cacheIndex=-2}return true}return false};Map3.prototype.clear=function(){this._keys.length=0;this._values.length=0;this._cacheKey=cacheSentinel;this._cacheIndex=-2};Map3.prototype.keys=function(){return new MapIterator(this._keys,this._values,getKey)};Map3.prototype.values=function(){return new MapIterator(this._keys,this._values,getValue2)};Map3.prototype.entries=function(){return new MapIterator(this._keys,this._values,getEntry)};Map3.prototype["@@iterator"]=function(){return this.entries()};Map3.prototype[iteratorSymbol]=function(){return this.entries()};Map3.prototype._find=function(key,insert){if(!SameValueZero(this._cacheKey,key)){this._cacheIndex=-1;for(var i=0;i<this._keys.length;i++){if(SameValueZero(this._keys[i],key)){this._cacheIndex=i;break}}}if(this._cacheIndex<0&&insert){this._cacheIndex=this._keys.length;this._keys.push(key);this._values.push(void 0)}return this._cacheIndex};return Map3})();return Map2;function getKey(key,_){return key}function getValue2(_,value){return value}function getEntry(key,value){return[key,value]}}function CreateSetPolyfill(){var Set2=(function(){function Set3(){this._map=new _Map}Object.defineProperty(Set3.prototype,"size",{get:function(){return this._map.size},enumerable:true,configurable:true});Set3.prototype.has=function(value){return this._map.has(value)};Set3.prototype.add=function(value){return this._map.set(value,value),this};Set3.prototype.delete=function(value){return this._map.delete(value)};Set3.prototype.clear=function(){this._map.clear()};Set3.prototype.keys=function(){return this._map.keys()};Set3.prototype.values=function(){return this._map.keys()};Set3.prototype.entries=function(){return this._map.entries()};Set3.prototype["@@iterator"]=function(){return this.keys()};Set3.prototype[iteratorSymbol]=function(){return this.keys()};return Set3})();return Set2}function CreateWeakMapPolyfill(){var UUID_SIZE=16;var keys=HashMap.create();var rootKey=CreateUniqueKey();return(function(){function WeakMap2(){this._key=CreateUniqueKey()}WeakMap2.prototype.has=function(target){var table=GetOrCreateWeakMapTable(target,false);return table!==void 0?HashMap.has(table,this._key):false};WeakMap2.prototype.get=function(target){var table=GetOrCreateWeakMapTable(target,false);return table!==void 0?HashMap.get(table,this._key):void 0};WeakMap2.prototype.set=function(target,value){var table=GetOrCreateWeakMapTable(target,true);table[this._key]=value;return this};WeakMap2.prototype.delete=function(target){var table=GetOrCreateWeakMapTable(target,false);return table!==void 0?delete table[this._key]:false};WeakMap2.prototype.clear=function(){this._key=CreateUniqueKey()};return WeakMap2})();function CreateUniqueKey(){var key;do key="@@WeakMap@@"+CreateUUID();while(HashMap.has(keys,key));keys[key]=true;return key}function GetOrCreateWeakMapTable(target,create){if(!hasOwn.call(target,rootKey)){if(!create)return void 0;Object.defineProperty(target,rootKey,{value:HashMap.create()})}return target[rootKey]}function FillRandomBytes(buffer,size){for(var i=0;i<size;++i)buffer[i]=Math.random()*255|0;return buffer}function GenRandomBytes(size){if(typeof Uint8Array==="function"){var array=new Uint8Array(size);if(typeof crypto!=="undefined"){crypto.getRandomValues(array)}else if(typeof msCrypto!=="undefined"){msCrypto.getRandomValues(array)}else{FillRandomBytes(array,size)}return array}return FillRandomBytes(new Array(size),size)}function CreateUUID(){var data=GenRandomBytes(UUID_SIZE);data[6]=data[6]&79|64;data[8]=data[8]&191|128;var result="";for(var offset=0;offset<UUID_SIZE;++offset){var byte=data[offset];if(offset===4||offset===6||offset===8)result+="-";if(byte<16)result+="0";result+=byte.toString(16).toLowerCase()}return result}}function MakeDictionary(obj){obj.__=void 0;delete obj.__;return obj}})})(Reflect2||(Reflect2={}))}});var primitiveTypes=["string","number","boolean","bigint","symbol"];function isIgnoredType(type){return!!(type.name&&["any","void","unknown"].includes(type.name))}function isPrimitiveType(type){return!!(type.name&&primitiveTypes.includes(type.name))}function isArrayType(type){return!!type.arrayElementType}function isLiteralType(type){return!!type.literalValue}function isTypeLiteralType(type){return!!type.typeLiteralMembers}function isUnionType(type){return!!type.unionMembers}function isIntersectionType(type){return!!type.intersectionMembers}function isTupleType(type){return!!type.tupleMembers}function hasGenerics(type){return!!type.generics}var classMap=new Map;var interfaceMap=new Map;var enumMap=new Map;var typeAliasMap=new Map;var classPool=new Map;var ReflectClass=(jsClass=>{classPool.set(jsClass.name,jsClass)});var primitiveMap={string:String,number:Number,boolean:Boolean,object:Object};var ReflectContext={getClassDefinition,getInterfaceDefinition,getEnumDefinition,getTypeAliasDefinition};var reflect=Reflect;function getClassByName(className){return reflect.__classDef[className]||globalThis[className]||primitiveMap[className]}function getClassDefinition(arg){var _a,_b;let className;switch(typeof arg){case"function":className=arg.name;break;case"string":className=arg;break;case"object":className=arg.constructor.name;break;default:return void 0}if(!classMap.has(className)){const rawClassDef=(_a=reflect.__classes)==null?void 0:_a[className];if(!rawClassDef)return void 0;const jsClass=(_b=reflect.__classDef)==null?void 0:_b[className];classMap.set(className,new ClassDefinition(__spreadValues(__spreadValues({},rawClassDef),{jsClass})))}return classMap.get(className)}function getInterfaceDefinition(name){var _a;if(!interfaceMap.has(name)){const interfaceMeta=(_a=reflect.__interfaces)==null?void 0:_a[name];if(!interfaceMeta)return void 0;interfaceMap.set(name,new InterfaceDefinition(interfaceMeta))}return interfaceMap.get(name)}function getEnumDefinition(name){var _a;if(!enumMap.has(name)){const enumMeta=(_a=reflect.__enums)==null?void 0:_a[name];if(!enumMeta)return void 0;enumMap.set(name,new EnumDefinition(enumMeta))}return enumMap.get(name)}function getTypeAliasDefinition(name){var _a;if(!typeAliasMap.has(name)){const typeAliasMeta=fillType((_a=reflect.__typeAliases)==null?void 0:_a[name]);if(!typeAliasMeta)return void 0;typeAliasMap.set(name,typeAliasMeta)}return typeAliasMap.get(name)}reflect.initReflectContext=()=>{reflect.__classes&&Object.entries(reflect.__classes).map(([className,rawClassDef])=>{const jsClass=reflect.__classDef[className];if(!jsClass)return void 0;classMap.set(className,new ClassDefinition(__spreadValues(__spreadValues({},rawClassDef),{jsClass})))});reflect.__interfaces&&Object.entries(reflect.__interfaces).map(([name,interfaceMeta])=>interfaceMap.set(name,new InterfaceDefinition(interfaceMeta)));reflect.__enums&&Object.entries(reflect.__enums).map(([name,enumMeta])=>enumMap.set(name,new EnumDefinition(enumMeta)));reflect.__typeAliases&&Object.entries(reflect.__typeAliases).map(([name,def])=>{typeAliasMap.set(name,fillType(def))});["__classDef","__classes","__interfaces","__enums","__typeAliases","initReflectContext"].forEach(it=>delete reflect[it])};var ClassDefinition=class{constructor(def){var _a,_b;this.name=def.name;this.superClassName=def.superClassName||"Object";this.superClass=getClassDefinition2(this.superClassName);this._implementationNames=def.implementations||[];this.methods=((_a=def.methods)==null?void 0:_a.map(fillMethod))||[];this.properties=((_b=def.properties)==null?void 0:_b.map(fillProperty))||[];this.jsClass=def.jsClass}get allMethods(){const results={};if(this.superClassName!=="Object"){const superClassDef=getClassDefinition2(this.superClassName);if(superClassDef){Object.assign(results,__spreadValues({},superClassDef.allMethods))}}Object.assign(results,__spreadValues({},toDictionary(this.methods,it=>[it.name,it])));return results}get allProperties(){var _a;return Object.assign(((_a=this.superClass)==null?void 0:_a.allProperties)||{},toDictionary(this.properties,it=>[it.name,it]))}get implementations(){if(!this._implementations){return mapNotNull(this._implementationNames,getInterfaceDefinition2)}return this._implementations}get allImplementations(){var _a,_b;if(this._allImplementations===void 0){const result=new Set(this.implementations);this.implementations.forEach(interfaceDef=>{interfaceDef.allImplementations.forEach(it=>result.add(it))});(_b=(_a=this.superClass)==null?void 0:_a.allImplementations)==null?void 0:_b.forEach(it=>result.add(it));this._allImplementations=Array.from(result)}return this._allImplementations}getProperty(propName){return this.properties.find(it=>it.name===propName)}get type(){var _a,_b;const props={};(_b=(_a=this.superClass)==null?void 0:_a.type.typeLiteralMembers)==null?void 0:_b.forEach(prop=>props[prop.name]=prop);this.properties.forEach(prop=>props[prop.name]=prop);return{name:this.name,typeLiteralMembers:Object.values(props)}}isSubClassOf(typeName){var _a;if(this.name===typeName)return true;if((_a=this.superClass)==null?void 0:_a.isSubClassOf(typeName))return true;return this.implementations.map(it=>it.name).includes(typeName)}isSuperClassOf(typeName){if(this.name===typeName)return true;const classDef=getClassDefinition2(typeName);if(!classDef)return false;return classDef.isSubClassOf(this.name)}toString(){return`class ${this.name}`}};function toDictionary(arr,handler){const dict={};arr.forEach(item=>{const[key,value]=handler(item);dict[key]=value});return dict}function mapNotNull(arr,mapper){return(arr==null?void 0:arr.map(mapper).filter(it=>it!==void 0))||[]}function setValue(target,field,value){if(target===void 0)return;target[field]=value}function getValue(target,field){if(target===void 0)return void 0;return target[field]}function mapNotNull2(arr,mapper){return(arr==null?void 0:arr.map(mapper).filter(it=>it!==void 0))||[]}var InterfaceDefinition=class{constructor(def){var _a,_b;this.name=def.name;this._implementationNames=def.implementations||[];this.methods=((_a=def.methods)==null?void 0:_a.map(fillMethod))||[];this.properties=((_b=def.properties)==null?void 0:_b.map(fillProperty))||[]}get implementations(){if(!this._implementations){this._implementations=mapNotNull2(this._implementationNames,getInterfaceDefinition2)}return this._implementations}get allImplementations(){if(this._allImplementations===void 0){const result=new Set(this.implementations);this.implementations.forEach(interfaceDef=>{interfaceDef.allImplementations.forEach(it=>result.add(it))});this._allImplementations=Array.from(result)}return this._allImplementations}get type(){const props={};this.allImplementations.forEach(parentInterface=>{const interfaceProps=parentInterface.type.typeLiteralMembers;interfaceProps==null?void 0:interfaceProps.forEach(prop=>props[prop.name]=prop)});this.properties.forEach(prop=>props[prop.name]=prop);return{name:this.name,typeLiteralMembers:Object.values(props)}}toString(){return`interface ${this.name}`}buildBaseObject(){const result={};this.properties.forEach(it=>setValue(result,it.name,void 0));this.methods.forEach(it=>setValue(result,it.name,()=>void 0));return result}};var EnumDefinition=class{constructor(def){this.name=def.name;this.members=new Map;def.members.forEach(member=>{const value=member.initializer===void 0?{name:"number"}:{literalValue:member.initializer};this.members.set(member.name,value)})}get type(){return{name:this.name,unionMembers:Array.from(this.members.values())}}get names(){return Array.from(this.members.keys())}};var MethodDefinition3=class{constructor(def){var _a;this.name=def.name;this.returnType=fillType(def.returnType);this.args=((_a=def.args)==null?void 0:_a.map(arg=>({name:arg.name,type:fillType(arg.type),isOptional:arg.isOptional})))||[];this.isPrivate=def.isPrivate||false;this.isStatic=def.isStatic||false;this.isAsync=def.isAsync||false}};function fillMethod(rawMethod){return new MethodDefinition3(rawMethod)}var PropertyDefinition3=class{constructor(def){this.name=def.name;this.isOptional=def.isOptional||false;this.isPrivate=def.isPrivate||false;this.isStatic=def.isStatic||false;this.type=fillType(def.type);this.accessor=def.accessor&&__spreadValues({},def.accessor)}};function fillProperty(rawProperty){return new PropertyDefinition3(rawProperty)}var anyType={name:"any"};var nullType={name:"null"};function getClassDefinition2(arg){return ReflectContext.getClassDefinition(arg)}function getInterfaceDefinition2(name){return ReflectContext.getInterfaceDefinition(name)}function getEnumDefinition2(name){return ReflectContext.getEnumDefinition(name)}function getTypeAliasDefinition2(name){return ReflectContext.getTypeAliasDefinition(name)}function getTypeDefinition(typeName){if(typeName==="any"||typeName==="Any"||typeName==="unknown"||typeName==="")return anyType;if(typeName==="null")return nullType;const classDef=getClassDefinition2(typeName)||getInterfaceDefinition2(typeName)||getEnumDefinition2(typeName);if(classDef)return classDef.type;const typeDef=getTypeAliasDefinition2(typeName);if(typeDef)return typeDef;return anyType}function getEnumNames(enumName){var _a;return((_a=getEnumDefinition2(enumName))==null?void 0:_a.names)||[]}function getEnumValues(args){const enumArg=Object.entries(args)[0];if(!enumArg)return[];const[enumName,obj]=enumArg;const enumDef=getEnumDefinition2(enumName);if(!enumDef)return Array.from(Object.keys(obj));return enumDef.names.map(name=>obj[name])}function fillType(rawType){switch(typeof rawType){case"undefined":return anyType;case"string":return Object.assign({},getTypeDefinition(rawType)||{},{name:rawType});default:if(rawType.arrayElementType){Object.assign(rawType,{arrayElementType:fillType(rawType.arrayElementType)})}else if(rawType.unionMembers){Object.assign(rawType,{unionMembers:rawType.unionMembers.map(fillType)})}else if(rawType.intersectionMembers){Object.assign(rawType,{intersectionMembers:rawType.intersectionMembers.map(fillType)})}else if(rawType.tupleMembers){Object.assign(rawType,{tupleMembers:rawType.tupleMembers.map(fillType)})}else if(rawType.generics){const baseType=fillType(rawType.generics[0]);baseType.generics=rawType.generics.slice(1).map(fillType);return baseType}return rawType}}var successResult={success:true};var failedResult=(errorMessage,cause)=>({success:false,errorMessage,cause});var preservedTypes=[Promise,Date,Map,Set,Error,Function];function validateValue(value,type,depth=1){switch(true){case type.name==="undefined":return value===void 0?successResult:failedResult(`declared as ${getTypeDisplayName(type)} but actually not`);case isIgnoredType(type):return successResult;case isArrayType(type):return validateArrayValue(value,type,depth);case isTupleType(type):return validateTupleValue(value,type,depth);case isUnionType(type):for(const unionMember of type.unionMembers||[]){const validateResult=validateValue(value,unionMember,depth);if(validateResult.success)return successResult}return failedResult(`declared as ${getTypeDisplayName(type)} but all value not match`);case isIntersectionType(type):for(const intersectionMember of type.intersectionMembers||[]){const validateResult=validateValue(value,intersectionMember,depth);if(!validateResult.success)return failedResult(`declared as ${getTypeDisplayName(type)} but all value not match`,validateResult)}return successResult;case isLiteralType(type):switch(typeof value){case"string":return value===trimQuotes(type.literalValue)?successResult:failedResult(`declared as string ${getTypeDisplayName(type)} but value not match`);case"number":return value===Number(type.literalValue)?successResult:failedResult(`declared as number ${getTypeDisplayName(type)} but value not match`);case"bigint":return value===BigInt(type.literalValue)?successResult:failedResult(`declared as bigint ${getTypeDisplayName(type)} but value not match`);case"boolean":return value===Boolean(type.literalValue)?successResult:failedResult(`declared as boolean ${getTypeDisplayName(type)} but value not match`);default:if(type.literalValue==="null"&&value===null)return successResult;return value===type.literalValue?successResult:failedResult(`declared as ${getTypeDisplayName(type)} but value not match`)}case isTypeLiteralType(type):return validateProperties(value,type,depth);case type.isFunction:case type.isConstructor:return typeof value==="function"?successResult:failedResult(`declared as ${getTypeDisplayName(type)} but actually not`);case isPrimitiveType(type):return typeof value===type.name?successResult:failedResult(`declared as ${getTypeDisplayName(type)} but actually ${typeof value}`);default:return validateSimpleValue(value,type,depth)}}function validateArrayValue(value,type,depth=1){if(!Array.isArray(value)){return failedResult(`declared as ${getTypeDisplayName(type)} but actually not`)}if(depth===0)return successResult;for(const arrayItem of value){const validateResult=validateValue(arrayItem,type.arrayElementType||anyType,depth-1);if(!validateResult.success){return failedResult(`declared as ${getTypeDisplayName(type)} but not all values in array match`,validateResult)}}return successResult}function validateTupleValue(value,type,depth=1){if(!Array.isArray(value)){return failedResult(`declared as ${getTypeDisplayName(type)} but actually not a tuple`)}if(depth===0)return successResult;let index=0;for(const tupleItem of type.tupleMembers){const tupleValue=value[index++];if(tupleItem.isOptionalInTuple&&tupleValue===void 0)continue;const validateResult=validateValue(value[index],tupleItem,depth);if(!validateResult.success){return failedResult(`declared as ${getTypeDisplayName(type)} but not all values in tuple match`,validateResult)}}return successResult}function validateProperties(value,type,depth=1){if(!(value instanceof Object)){return failedResult(`declared as ${getTypeDisplayName(type)} but not an object`)}else{for(const prop of type.typeLiteralMembers||[]){if(prop.isStatic)return successResult;if(prop.name.startsWith("[")&&prop.name.endsWith("]"))return successResult;if(depth===0)return successResult;let propType=prop.type||anyType;if(prop.isOptional)propType={unionMembers:[propType,{name:"undefined"}]};const propValue=getValue(value,prop.name);const validateResult=validateValue(propValue,propType,depth-1);if(!validateResult.success){return failedResult(`declared ${prop.name} as ${getTypeDisplayName(propType)}, but not match`,validateResult)}}return successResult}}function validateSimpleValue(value,type,depth=1){const typeName=typeof type==="string"?type:type.name;if(!typeName)return successResult;if(value===void 0){return failedResult(`declared as ${getTypeDisplayName(type)} but actually undefined`)}if(value===null){if(typeName==="null")return successResult;else return failedResult(`declared as ${getTypeDisplayName(type)} but actually null`)}for(const preservedType of preservedTypes){if(typeName===preservedType.name){return value instanceof preservedType?successResult:failedResult(`declared as ${getTypeDisplayName(type)} but actually ${value.constructor.name}`)}}if(value instanceof Object&&!valueInstanceOf(value,typeName)){return failedResult(`declared as ${getTypeDisplayName(type)} but actually not instance of it`)}if(depth==0)return successResult;const result=validateValue(value,getTypeDefinition(typeName),depth);return result.success?successResult:failedResult(`declared as ${getTypeDisplayName(type)} but actually not match`,result)}function validateInstance(instance,typeName,depth=1){if(typeName){if(typeName!=="object"&&!valueInstanceOf(instance,typeName)){return failedResult(`declared as instance of ${typeName} but actually not`)}}else{typeName=instance.constructor.name}const typeDef=getTypeDefinition(typeName);if(typeName!=="any"&&typeDef===anyType){return failedResult(`${typeName} not defined`)}return validateValue(instance,typeDef,depth)}function validateArray(array,typeName,depth=1){for(let i=0;i<array.length;i++){const result=validateInstance(array[i],typeName,depth);if(!result.success){return failedResult(`declared as instance of ${typeName}[] but [${i}] actually not`,result)}}return successResult}function validateDictionary(dict,typeName,depth=1){const entries=Object.entries(dict);for(let i=0;i<entries.length;i++){const[key,value]=entries[i];const result=validateInstance(value,typeName,depth);if(!result.success){return failedResult(`declared as instance of Dictionary<${typeName}> but [${key}] actually not`,result)}}return successResult}function valueInstanceOf(value,className){if(value===void 0)return true;if(value.constructor.name===className)return true;const classDef=getClassDefinition2(className);if(!classDef)return true;if(classDef.jsClass)return value instanceof classDef.jsClass;const instanceClassDef=getClassDefinition2(value);if(!instanceClassDef)return false;return instanceClassDef.isSubClassOf(classDef.name)}function trimQuotes(text){if(text.length>=2&&(text[0]==='"'&&text[text.length-1]==='"'||text[0]==="'"&&text[text.length-1]==="'")){return text.substring(1,text.length-1)}return text}function getTypeDisplayName(type){var _a,_b,_c;if(typeof type==="string"){return type}if(isArrayType(type)){return(((_a=type.arrayElementType)==null?void 0:_a.name)||"unknown")+"[]"}if(type.isConstructor){return"Class"}if(type.isFunction){return"Function"}if(isTypeLiteralType(type)){return"Object"}if(isTupleType(type)){return`(${type.tupleMembers.map(getTypeDisplayName).join(",")})`}if(isUnionType(type)){return((_b=type.unionMembers)==null?void 0:_b.map(getTypeDisplayName).join(" | "))||"unknown"}if(isIntersectionType(type)){return((_c=type.intersectionMembers)==null?void 0:_c.map(getTypeDisplayName).join(" & "))||"unknown"}if(isLiteralType(type)){return type.literalValue}return type.name||"unknown"}function getErrorTraceMessages(failureResult){const getAllTraceMessages=failureResult2=>failureResult2.errorMessage?[failureResult2.errorMessage,...failureResult2.cause?getAllTraceMessages(failureResult2.cause):[]]:[];return getAllTraceMessages(failureResult).join("\n-> ")}function validateFunctionArgument(args){const{funcName,optionsObj,value,argName,type,optional}=args;const v=value||optionsObj&&getValue(optionsObj,argName);if(v===void 0){if(!optional)throw Error(`Illegal arguments for ${funcName}: ${argName} is undefined`);else return}if(["string","number","boolean","bigint"].includes(type)){if(typeof v!==type)throw Error(`Illegal arguments for ${funcName}: ${argName} is not a ${type}`);return}if(typeof v!=="object")throw Error(`Illegal arguments for ${funcName}: ${argName} is not an object`);if(v===null)throw Error(`Illegal arguments for ${funcName}: ${argName} is null`);const result=validateInstance(v,type);if(!result.success)throw Error(`Illegal arguments for ${funcName}: ${result.errorMessage}`)}function safeSetValue(target,propName,value){const classDef=getClassDefinition2(target);if(!classDef){setValue(target,propName,value);return}const propDef=classDef.allProperties[propName];if(!propDef){throw new Error(`Property ${propName} is not defined in ${classDef.name}`)}const propType=propDef.type;const validateResult=validateValue(value,propType);if(!validateResult.success){throw new Error(validateResult.errorMessage)}setValue(target,propName,value)}function getTypeDef(type){if(typeof type==="string")return getTypeDefinition(type);if("array"in type)return{arrayElementType:getTypeDef(type.array)};if("union"in type)return{unionMembers:type.union.map(getTypeDef)};if("intersection"in type)return{intersectionMembers:type.intersection.map(getTypeDef)};if("tuple"in type)return{tupleMembers:type.tuple.map(getTypeDef)};else return type}function assertType(data,type,depth=5){const validateResult=validateValue(data,getTypeDef(type),depth);if(!validateResult.success){console.error(`assert failed with type: ${type}`);console.dir(validateResult);debugger}return data}function isNullable(type){return isType(null,type)}function isType(value,type){return validateValue(value,getTypeDef(type),3).success}var VALIDATE_WRAPPER=Symbol("VALIDATE_WRAPPER");var ReflectValidate=(target,propertyKey,descriptor)=>wrapValidateMethod(target,propertyKey,descriptor);function wrapValidateMethod(target,methodName,descriptor){const func=descriptor.value;if(typeof func!=="function")return;if(getValue(func,VALIDATE_WRAPPER))return;const getMethodDef=()=>{var _a,_b;return(_b=(_a=getClassDefinition2(target))==null?void 0:_a.methods)==null?void 0:_b.find(it=>it.name===methodName)};const validateArgs=args=>validateMethodParams(target,getMethodDef(),args);const validateReturn=result=>validateMethodReturnValue(target,getMethodDef(),result);const newFunc=function(...args){validateArgs(args);const result=func.call(this,...args);return validateReturn(result)};newFunc[VALIDATE_WRAPPER]=func;descriptor.value=newFunc}function validateMethodParams(target,methodDef,args){var _a;(_a=methodDef==null?void 0:methodDef.args)==null?void 0:_a.forEach((argDef,index)=>{const arg=args==null?void 0:args[index];if(arg===void 0){if(!argDef.isOptional)throw new Error(`Illegal arguments for ${getMethodDescription(target.constructor.name,methodDef)}: ${argDef.name} is not optional`);else return}const validResult=validateValue(arg,argDef.type||anyType,1);if(!validResult.success){console.error("validateResult",validResult);throw new Error(`Illegal arguments for ${getMethodDescription(target.constructor.name,methodDef)}: ${argDef.name}: ${argDef.name} ${validResult.errorMessage}`)}})}function validateMethodReturnValue(target,methodDef,result){var _a;if(!methodDef)return result;const checkValue=(value,type)=>{const validateResult=validateValue(value,type,5);if(!validateResult.success){console.error(validateResult);debugger;throw new Error(`result for ${getMethodDescription(target.constructor.name,methodDef)} doesn't match type ${type.name}: ${validateResult.errorMessage}`)}return value};let returnType=methodDef.returnType;if(returnType.name==="Promise"){returnType=((_a=returnType.generics)==null?void 0:_a[0])||anyType}if(result instanceof Promise){return result.then(res=>checkValue(res,returnType||anyType))}else{return checkValue(result,returnType||anyType)}}function getMethodDescription(className,methodDef){var _a;return`${className}.${methodDef.name}(${(_a=methodDef.args)==null?void 0:_a.map(it=>it.name).join(", ")})`}function safeCall(target,methodName,...args){const classDef=getClassDefinition2(target);if(!classDef)return;const methodDef=classDef.allMethods[methodName];if(!methodDef)return;validateMethodParams(target,methodDef,args);return getValue(target,methodName).apply(target,args)}var import_reflect_metadata=__toESM(require_Reflect(),1);function asBoolean(value){if(String(value).toLocaleLowerCase()==="false")return false;return!!value}function asString(v){if(v===null||v===void 0||Number.isNaN(v)){return""}if(v instanceof Date&&String(v)==="Invalid Date"){return""}if(typeof v==="symbol"){return v.description||""}return String(v)}function asNumber(v){if(!v)return 0;if(v instanceof Date)return v.getDate();return Number(v)}function setAnyValue(target,field,value){;target[field]=value}function getAnyValue(target,field){return target[field]}function getOrSetValue(target,field,defaultWith){const value=target[field];if(value!==void 0)return value;const defaultValue=defaultWith();setAnyValue(target,field,defaultValue);return defaultValue}function isDictionary(value){return typeof value==="object"&&value!==null&&value.constructor===Object}function createNewInstance(clazz){const result=Object.create(clazz.prototype);result.constructor=this;return result}function defineDecoratedProperty(metaKey){return((self2,propertyKey)=>Reflect.defineMetadata(metaKey,propertyKey,self2.constructor))}function callDecoratedMethod(self2,metaKey,...args){const method=getDecoratedPropertyValue(self2,metaKey);if(method!==void 0&&method instanceof Function){return method.apply(self2,args)}return void 0}function hasDecoratedMethod(self2,metaKey){const method=getDecoratedPropertyValue(self2,metaKey);return method!==void 0&&method instanceof Function}function getDecoratedProperty(target,metaKey){return Reflect.getMetadata(metaKey,target.constructor)}function getDecoratedPropertyValue(target,metaKey){const propName=getDecoratedProperty(target,metaKey);if(propName===void 0)return;return getAnyValue(target,propName)}var PropertyWrapper=function({getter,setter,fieldSymbol}){return(target,propertyKey)=>{Object.defineProperty(target,propertyKey,{get:function(){return getter?getter(this,propertyKey):PropertyWrapper.getField(target,propertyKey,fieldSymbol)},set:function(newValue){setter?setter(this,newValue,propertyKey):PropertyWrapper.setField(target,propertyKey,newValue,fieldSymbol)}})}};setAnyValue(PropertyWrapper,"getField",(owner,property,fieldSymbol)=>{var _a;return(_a=getAnyValue(owner,fieldSymbol))==null?void 0:_a[property]});setAnyValue(PropertyWrapper,"setField",(owner,property,newValue,fieldSymbol)=>{const fields=getAnyValue(owner,fieldSymbol)||{};fields[property]=newValue;setAnyValue(owner,fieldSymbol,fields)});function Lazy(creator){const symbol=Symbol("lazy");return PropertyWrapper({getter:(target,property)=>{const stored=PropertyWrapper.getField(target,property,symbol);if(stored)return stored.value;const value=creator(target,property);PropertyWrapper.setField(target,property,{value},symbol);return value},setter:()=>{},fieldSymbol:symbol})}var JSON_SERIALIZED=Symbol("JSON_SERIALIZED");var AFTER_SERIALIZED=Symbol("AFTER_SERIALIZED");var SerializeSettings=class{constructor(){this.settingsByName={};this.settingsBySerializedName={};this.ignoredProperties=[];this.defaultIgnored=false}add(prop){this.settingsByName[prop.propName]=prop;this.settingsBySerializedName[prop.serializedName]=prop}isPropertyIgnored(propName){if(this.defaultIgnored&&!this.settingsByName[propName]){return true}return this.ignoredProperties.indexOf(propName)!==-1}};var SerializedPropertySetting=class{constructor(target,propName,options){this.target=target;this.propName=propName;this.options=options;this.isArray=Reflect.getDesignType(target,propName)===Array;this.serializedName=options.name||asString(propName);this.class=options.class;this.fromJSON=this.createBuilder();this.toJSON=options.toJSON||(value=>serializeTo(value))}createBuilder(){if(this.options.fromJSON){return this.options.fromJSON}else if(this.class&&this.class instanceof Function){const clazz=this.class;return data=>{const transformer=jsonTransformers.get(clazz);return transformer?transformer.fromJson(data):deserialize(data,clazz)}}else{return data=>getValueByReflectType(this.target,this.propName,data)}}};function setDefaultIgnored(clazz,defaultIgnored){updateSerializeSettings(clazz,settings=>{settings.defaultIgnored=defaultIgnored})}function registerSerializedProperty(target,propName,options){const clazz=target.constructor;updateSerializeSettings(clazz,settings=>{settings.add(new SerializedPropertySetting(target,propName,options))})}function updateSerializeSettings(clazz,update){let settings=Reflect.getMetadata(JSON_SERIALIZED,clazz);if(settings===void 0){settings=new SerializeSettings}update(settings);Reflect.defineMetadata(JSON_SERIALIZED,settings,clazz)}var SerializedClass=Serialized();function Serialized(options){options=options||{};return(target,propName)=>registerSerializedProperty(target,asString(propName),options)}function SerializedName(serializedName){return(target,propName)=>registerSerializedProperty(target,asString(propName),{name:serializedName})}var IgnoreSerialization=(target,propName)=>updateSerializeSettings(target.constructor,settings=>settings.ignoredProperties.push(propName));function serialize(value){if(typeof value==="object")return JSON.stringify(serializeToData(value));return JSON.stringify(value)}function serializeTo(value){if(value===void 0)throw new Error("attempt to serialize undefined value");if(value===null)return null;const transformer=jsonTransformers.get(value.constructor);return transformer?transformer.toJson(value):serializeToData(value)}function serializeToData(object){var _a;if(object instanceof Array){return object.map(it=>serializeToData(it))}if(isDictionary(object)){const result={};Object.entries(object).forEach(it=>{const[prop,value]=it;result[prop]=serializeTo(value)});return result}const clazz=object.constructor;const reflectEnabled=(_a=getClassDefinition2(clazz))==null?void 0:_a.isSubClassOf("Mappable");if(reflectEnabled)registerMappable(clazz);const settings=Reflect.getMetadata(JSON_SERIALIZED,clazz);if(settings===void 0){return object}const jsonMappingObject={};Object.entries(object).forEach(entry=>{const propName=entry[0];if(settings.isPropertyIgnored(propName))return;let value=entry[1];if(value===void 0||value instanceof Function||typeof value==="symbol")return;const propSetting=settings.settingsByName[propName];const serializedName=(propSetting==null?void 0:propSetting.serializedName)||propName;if(propSetting){if(propSetting.isArray){value=value.map(it=>propSetting.toJSON(it))}else{value=propSetting.toJSON(value)}}jsonMappingObject[serializedName]=value});return jsonMappingObject}function deserialize(json,constructorOrTarget){var _a;if(typeof json==="string"){json=JSON.parse(json)}if(constructorOrTarget===null)return json;if(constructorOrTarget===void 0)return json;try{const data=json;const clazz=constructorOrTarget instanceof Function?constructorOrTarget:constructorOrTarget.constructor;const reflectEnabled=(_a=getClassDefinition2(clazz))==null?void 0:_a.isSubClassOf("Mappable");if(reflectEnabled)registerMappable(clazz);const transformer=jsonTransformers.get(clazz);if(transformer)return transformer.fromJson(data);const target=constructorOrTarget instanceof Function?createNewInstance(constructorOrTarget):constructorOrTarget;deserializeFrom(data,target);if(reflectEnabled){const validateResult=validateInstance(target,clazz.name);if(!validateResult.success){throw new Error(`JSON deserialize validate failed: ${getErrorTraceMessages(validateResult)} `)}}return target}catch(e){console.error("failed to deserialize");console.dir(e);throw e}}function deserializeArray(json,clazz){const data=typeof json==="string"?JSON.parse(json):json;if(!(data instanceof Array)){return[]}return data.map(item=>deserialize(item,clazz))}function deserializeFrom(data,target){const clazz=target.constructor;const settings=Reflect.getMetadata(JSON_SERIALIZED,clazz);if(settings===void 0){Object.assign(target,data);return}Object.keys(data).forEach(serializedName=>{const propDef=settings.settingsBySerializedName[serializedName];const jsonValue=data[serializedName];if(propDef===void 0){if(!settings.defaultIgnored){setAnyValue(target,serializedName,jsonValue)}return}const propName=propDef.propName;if(settings.isPropertyIgnored(propName)){return}let value;if(jsonValue instanceof Array){value=jsonValue.map(it=>propDef.fromJSON(it))}else{value=propDef.fromJSON(jsonValue)}setAnyValue(target,propName,value)});callDecoratedMethod(target,AFTER_SERIALIZED)}function getSerializeSettings(clazz){return Reflect.getMetadata(JSON_SERIALIZED,clazz)}function getValueByReflectType(target,propName,value){const reflectType=Reflect.getDesignType(target,propName);if(reflectType===void 0)return value;if(reflectType===Array)return deserializeArray(value);const transformer=jsonTransformers.get(reflectType);return transformer?transformer.fromJson(value):deserialize(value,reflectType)}var jsonTransformers=new Map;function registerTransform(clazz,transform){jsonTransformers.set(clazz,transform)}var itSelf=some=>some;var done=()=>void 0;registerTransform(String,{fromJson:asString,toJson:itSelf});registerTransform(Number,{fromJson:asNumber,toJson:itSelf});registerTransform(Boolean,{fromJson:asBoolean,toJson:itSelf});registerTransform(Date,{fromJson:anyValue=>new Date(asNumber(anyValue)),toJson:date=>date.getTime()});var AfterSerialized=defineDecoratedProperty(AFTER_SERIALIZED);var mapStatus=new Map;function registerMappable(mappableClass){if(mapStatus.get(mappableClass))return;const classDef=getClassDefinition2(mappableClass);const mapping=new Proxy({},{get(target,p){return doMap(p)},set(target,p,newValue){doMap(p)(newValue);return true}});function doMap(propName){return(fieldName,transform)=>{var _a,_b,_c;const propType=(_b=(_a=Object.values((classDef==null?void 0:classDef.allProperties)||{}))==null?void 0:_a.find(it=>it.name===propName))==null?void 0:_b.type;let propClass=(propType==null?void 0:propType.name)!==void 0?getClassByName(propType.name):void 0;if(propType&&isArrayType(propType)){propClass=((_c=propType.arrayElementType)==null?void 0:_c.name)!==void 0?getClassByName(propType.arrayElementType.name):void 0}if(typeof propName!=="string")return;registerSerializedProperty(mappableClass.prototype,propName,{name:fieldName,class:propClass,fromJSON:transform==null?void 0:transform.fromJSON,toJSON:transform==null?void 0:transform.toJSON});setDefaultIgnored(mappableClass,true)}}mappableClass.prototype.mapping(mapping);mapStatus.set(mappableClass,true)}function mapAllProperties(target,map){const classDef=getClassDefinition2(target);if(!classDef)return;classDef.properties.forEach(prop=>map[prop.name]())}var import_reflect_metadata2=__toESM(require_Reflect(),1);var DESIGN_TYPE="design:type";var DESIGN_RETURNTYPE="design:returntype";var DESIGN_PARAMTYPES="design:paramtypes";function getDesignType(target,property){return Reflect.getMetadata(DESIGN_TYPE,target,property)}function getReturnType(target,property){return Reflect.getMetadata(DESIGN_RETURNTYPE,target,property)}function getParamTypes(target,property){return Reflect.getMetadata(DESIGN_PARAMTYPES,target,property)}function addMetadataList(key,value,target,propertyKey){const list=(propertyKey===void 0?Reflect.getMetadata(key,target):Reflect.getMetadata(key,target,propertyKey))||[];if(!list.includes(value))list.push(value);propertyKey===void 0?Reflect.defineMetadata(key,list,target):Reflect.defineMetadata(key,list,target,propertyKey)}Object.assign(Reflect,{getDesignType,getReturnType,getParamTypes,addMetadataList});export{AfterSerialized,ClassDefinition,EnumDefinition,IgnoreSerialization,InterfaceDefinition,Lazy,MethodDefinition3 as MethodDefinition,PropertyDefinition3 as PropertyDefinition,PropertyWrapper,ReflectClass,ReflectContext,ReflectValidate,Serialized,SerializedClass,SerializedName,anyType,asBoolean,asNumber,asString,assertType,callDecoratedMethod,createNewInstance,defineDecoratedProperty,deserialize,deserializeArray,deserializeFrom,done,fillMethod,fillProperty,fillType,getAnyValue,getClassByName,getClassDefinition2 as getClassDefinition,getDecoratedProperty,getDecoratedPropertyValue,getEnumDefinition2 as getEnumDefinition,getEnumNames,getEnumValues,getErrorTraceMessages,getInterfaceDefinition2 as getInterfaceDefinition,getOrSetValue,getSerializeSettings,getTypeAliasDefinition2 as getTypeAliasDefinition,getTypeDef,getTypeDefinition,hasDecoratedMethod,hasGenerics,isArrayType,isDictionary,isIgnoredType,isIntersectionType,isLiteralType,isNullable,isPrimitiveType,isTupleType,isType,isTypeLiteralType,isUnionType,itSelf,mapAllProperties,nullType,registerMappable,registerSerializedProperty,registerTransform,safeCall,safeSetValue,serialize,serializeTo,serializeToData,setAnyValue,setDefaultIgnored,validateArray,validateDictionary,validateFunctionArgument,validateInstance,validateValue};
|
|
3
2
|
/*! Bundled license information:
|
|
4
3
|
|
|
5
4
|
reflect-metadata/Reflect.js:
|
package/dist/parser/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var L=(e,n,t)=>new Promise((s,f)=>{var r=m=>{try{w(t.next(m))}catch(D){f(D)}},l=m=>{try{w(t.throw(m))}catch(D){f(D)}},w=m=>m.done?s(m.value):Promise.resolve(m.value).then(r,l);w((t=t.apply(e,n)).next())});import J from"typescript";import i from"typescript";import*as E from"fs";import*as C from"process";import*as x from"path";var fe=!0,O=new Map,K=new Map,j=new Map,A=new Map,q=new Map,v=new Set,B={[i.SyntaxKind.BooleanKeyword]:"boolean",[i.SyntaxKind.StringKeyword]:"string",[i.SyntaxKind.BigIntKeyword]:"bigint",[i.SyntaxKind.NumberKeyword]:"number",[i.SyntaxKind.SymbolKeyword]:"symbol",[i.SyntaxKind.VoidKeyword]:"void",[i.SyntaxKind.UndefinedKeyword]:"undefined",[i.SyntaxKind.UnknownKeyword]:"unknown",[i.SyntaxKind.AnyKeyword]:"any",[i.SyntaxKind.ObjectKeyword]:"object"},P="any",H=["string","number","boolean","bigint","symbol"],X=["any","Promise","Date","Error","undefined","unknown","object","Map","Set"],Y=["Mappable","EnableReflect"];[...H,...X,...Y].forEach(ie);Y.forEach(e=>K.set(e,{name:e}));var k,G=!1,R=Reflect;function be(s,f){return L(this,arguments,function*(e,n,t=C.cwd()){if(t=x.resolve(t),R.__classes===void 0){e=ae(e),U(e,n),R.__classes={};for(let[r,l]of O)R.__classes[r]=l;R.__interfaces={};for(let[r,l]of K)R.__interfaces[r]=l;R.__typeAliases={};for(let[r,l]of A)R.__typeAliases[r]=l;R.__constTypes={};for(let[r,l]of q)R.__constTypes[r]=l;yield Promise.all(e.map(r=>Z(r,t)))}})}function Z(e,n){return L(this,null,function*(){if(!E.existsSync(e))return;if(E.statSync(e).isDirectory()){E.readdirSync(e).forEach(r=>{Z(x.join(e,r),n)});return}let s=yield import(x.join(n,e).replace(/\.ts$/,".js"));R.__classDef={},Object.values(s).forEach(f=>{typeof f=="function"&&(R.__classDef[f.name]=f)})})}function U(e,n){if(e||(e=[C.cwd()]),e=ae(e),!G){let t=ee(e,n),s=i.createProgram(t,{});k=s.getTypeChecker(),t=t.map(r=>Q(r)),s.getSourceFiles().filter(r=>t.includes(Q(r.fileName))).forEach(r=>{b(`parse file: ${r.fileName}`),ne(r)});for(let r of v.keys())!O.has(r)&&!K.has(r)&&!j.has(r)&&!A.has(r)&&!H.includes(r)&&!X.includes(r)&&(b(`remove unknown typeName: ${r}`),v.delete(r));Array.from(O.values()).forEach(ge),Array.from(K.values()).forEach(Te),[O,K,A].forEach(De),G=!0}return{classDefinitions:O,interfaceDefinitions:K,enumDefinitions:j,typeAliasDefinitions:A,constTypeDefinitions:q}}function ee(e,n){let t=[];return e.forEach(s=>{if(s=x.resolve(s),we(s,n)){b(`ignore excluded ${s}`);return}if(!E.existsSync(s)){console.error(`Path ${s} does not exist.`);return}if(E.statSync(s).isFile()){t.push(s);return}E.readdirSync(s).forEach(l=>t.push(...ee([x.join(s,l)],n)))}),t}function ne(e){i.isClassDeclaration(e)?ce(e):i.isInterfaceDeclaration(e)?le(e):i.isEnumDeclaration(e)?pe(e):i.isTypeAliasDeclaration(e)?ue(e):i.isConstTypeReference(e)?me(e):e.forEachChild(ne)}function ce(e){var w,m,D,S,u,T,M,$,y,a,d,h;let n=o(e.name);if(!n)return;let t=o((D=(m=(w=e.heritageClauses)==null?void 0:w.find(c=>c.token===i.SyntaxKind.ExtendsKeyword))==null?void 0:m.types)==null?void 0:D[0].expression),s=(u=(S=e.heritageClauses)==null?void 0:S.find(c=>c.token===i.SyntaxKind.ImplementsKeyword))==null?void 0:u.types.map(c=>o(c.expression)),f=[],r=[];for(let c of e.members)if(i.isPropertyDeclaration(c))f.push({name:o(c.name),isOptional:c.questionToken!==void 0,type:g(c),isPrivate:(T=c.modifiers)==null?void 0:T.some(p=>p.kind===i.SyntaxKind.PrivateKeyword),isStatic:(M=c.modifiers)==null?void 0:M.some(p=>p.kind===i.SyntaxKind.StaticKeyword)});else if(i.isMethodDeclaration(c))r.push({name:o(c.name),returnType:g(c),isPrivate:($=c.modifiers)==null?void 0:$.some(p=>p.kind===i.SyntaxKind.PrivateKeyword),isStatic:(y=c.modifiers)==null?void 0:y.some(p=>p.kind===i.SyntaxKind.StaticKeyword),isAsync:(a=c.modifiers)==null?void 0:a.some(p=>p.kind===i.SyntaxKind.AsyncKeyword),args:c.parameters.map(p=>({name:o(p.name),type:g(p),isOptional:p.questionToken!==void 0}))});else if(i.isGetAccessorDeclaration(c)){let p=f.find(N=>N.name===o(c.name));p||(p={name:o(c.name),isOptional:c.questionToken===void 0,type:g(c)},f.push(p)),p.accessor=p.accessor||{},p.accessor.getter={isPrivate:((d=c.modifiers)==null?void 0:d.some(N=>N.kind===i.SyntaxKind.PrivateKeyword))||!1},p.isPrivate=p.accessor.getter.isPrivate}else if(i.isSetAccessorDeclaration(c)){let p=f.find(N=>N.name===o(c.name));p||(p={name:o(c.name),isOptional:c.questionToken===void 0,type:g(c)},f.push(p)),p.accessor=p.accessor||{},p.accessor.setter={isPrivate:((h=c.modifiers)==null?void 0:h.some(N=>N.kind===i.SyntaxKind.PrivateKeyword))||!1}}let l={name:n,superClassName:t,implementations:s,properties:f,methods:r};b(`Define class: ${o(e.name)}`),O.set(n,l)}function le(e){var w,m,D,S;let n=o(e.name);if(!n)return;let t=((m=(w=e.heritageClauses)==null?void 0:w.find(u=>u.token===i.SyntaxKind.ExtendsKeyword))==null?void 0:m.types.map(u=>o(u.expression)))||[],s=[],f=[],r;for(let u of e.members)i.isPropertySignature(u)?s.push({name:o(u.name),isOptional:u.questionToken!==void 0,type:g(u),isPrivate:((D=u.modifiers)==null?void 0:D.some(T=>T.kind===i.SyntaxKind.PrivateKeyword))||!1}):i.isMethodSignature(u)?f.push({name:u.name.text,returnType:g(u),isPrivate:((S=u.modifiers)==null?void 0:S.some(T=>T.kind===i.SyntaxKind.PrivateKeyword))||!1,args:u.parameters.map(T=>({name:o(T.name),type:g(T),isOptional:T.questionToken!==void 0}))}):i.isIndexSignatureDeclaration(u)&&(r=g(u));let l=K.get(n);l?(l.implementations=I(l.implementations||[],t),l.methods=I(l.methods||[],f,(u,T)=>u.name===T.name),l.properties=I(l.properties||[],s,(u,T)=>u.name===T.name),l.indexElementType=r,b(`Merge interface ${o(e.name)}`)):(l={name:n,implementations:t,methods:f,properties:s,indexElementType:r},K.set(n,l),b(`Define interface ${o(e.name)}`))}function pe(e){let n=o(e.name);n&&(j.set(n,{name:n,members:e.members.map(t=>({name:o(t.name),initializer:o(t.initializer)}))}),b(`Define enum: ${o(e.name)}`))}function ue(e){b(`Define typeAlias: ${o(e.name)}`),A.set(o(e.name),g(e))}function me(e){let n=e.parent.parent;i.isVariableDeclaration(n)&&n.initializer&&i.isAsExpression(n.initializer)&&q.set(o(n.name),te(n.initializer.expression))}function te(e){return i.isArrayLiteralExpression(e)?ye(e):i.isObjectLiteralExpression(e)?de(e):i.isNumericLiteral(e)?"number":i.isStringLiteral(e)?"string":i.isBigIntLiteral(e)?"bigint":[i.SyntaxKind.TrueKeyword,i.SyntaxKind.FalseKeyword].includes(e.kind)?"boolean":P}function ye(e){let n=[];return e.elements.forEach(t=>{if(i.isStringLiteral(t))return n.push(o(t))}),n.length===0?P:n.length===1?n[0]:{unionMembers:n}}function de(e){let n=[];return e.properties.map(t=>{i.isPropertyAssignment(t)?n.push({name:o(t.name),type:te(t.initializer)}):b(`unsupported property: ${t.name}`)}),{typeLiteralMembers:n}}function ie(e){v.add(e)}function g(e,n=!1){if(e.type&&!n)return _(e.type);if(!k)return console.error("TypeChecker not initialized!"),P;let t=k.getTypeAtLocation(e),s=k.typeToTypeNode(t,void 0,void 0);return s?_("type"in s?s.type:s):P}function _(e){let n={};if(e===void 0)return P;if(i.isUnionTypeNode(e))n.unionMembers=e.types.map(_);else if(i.isIntersectionTypeNode(e))n.intersectionMembers=e.types.map(_);else if(i.isLiteralTypeNode(e))n.literalValue=o(e.literal);else if(i.isTypeLiteralNode(e)){let t=[];e.members.forEach(s=>{i.isPropertySignature(s)?t.push({name:o(s.name),isOptional:s.questionToken!==void 0,type:g(s)}):i.isIndexSignatureDeclaration(s)?n.indexElementType=g(s):t.push({name:o(s.name)||"",isOptional:s.questionToken!==void 0,type:_()})}),n.typeLiteralMembers=t}else if(i.isArrayTypeNode(e))n.arrayElementType=_(e.elementType);else if(i.isFunctionTypeNode(e))n.isFunction=!0;else if(i.isTypeReferenceNode(e))if(ie(o(e.typeName)),e.typeArguments)n.generics=[o(e.typeName),...e.typeArguments.map(t=>_(t))];else return o(e.typeName);else{if(i.isIndexedAccessTypeNode(e))return g(e,!0);if(i.isThisTypeNode(e))return g(e);if(i.isParenthesizedTypeNode(e))return g(e);if(i.isConditionalTypeNode(e))return g(e);if(i.isTypeQueryNode(e))return g(e);if(i.isConstructorTypeNode(e))n.isConstructor=!0;else if(i.isTupleTypeNode(e))n.tupleMembers=e.elements.map(_);else{if(Object.keys(B).includes(String(e.kind)))return B[e.kind]||P;if(i.isOptionalTypeNode(e))Object.assign(n,g(e)),n.isOptionalInTuple=!0;else if(i.isNamedTupleMember(e))Object.assign(n,g(e));else return i.isTypeOperatorNode(e)&&e.operator===i.SyntaxKind.KeyOfKeyword,g(e,!0)}}return n}var I=(e,n,t)=>[...(e==null?void 0:e.filter(s=>!(n!=null&&n.some(f=>(t||(()=>f===s))(f,s)))))||[],...n||[]];function F(e){if(e!==void 0&&e!==P)return typeof e=="string"?v.has(e)?e:void 0:e}function ge(e){var n,t;(n=e.methods)==null||n.forEach(re),(t=e.properties)==null||t.forEach(se)}function Te(e){var n,t;(n=e.methods)==null||n.forEach(re),(t=e.properties)==null||t.forEach(se)}function se(e){e.type=F(e.type)}function re(e){var n;(n=e.args)==null||n.forEach(t=>t.type=F(t.type)),e.returnType=F(e.returnType)}function o(e){if(!e)return e;if(e.end<0)return e.text;try{return i.isQualifiedName(e)?o(e.right):e.getText()}catch(n){return e.text}}function z(e){e&&Object.entries(e).forEach(n=>{let[t,s]=n;s instanceof Array&&s.length===0||s===!1||s===void 0?delete e[t]:s.constructor===Array?s.forEach(z):s.constructor===Object&&z(s)})}function De(e){for(let n of e.values())z(n)}function we(e,n){return n?(n=n instanceof Array?n:[n],n.some(t=>(t instanceof RegExp||(t=new RegExp(t.replace(/\./g,"\\.").replace(/\*/g,".*"))),e.match(t)))):!1}function Q(e,n=C.cwd()){return W(e).replace(W(n)+"/","")}function W(e){let n=x.sep;return e.split(n).join("/")}function ae(e){return e instanceof Array?e:[e]}function b(e){fe&&console.log(e)}function V(e,n){let t=f=>{let r=e.replace(/\\/g,"/"),l=f.replace(/\\/g,"/");l=l.replace(/\*\*/g,"<<double_star>>");let m=l.replace(/([.+^${}()|[\]\\])/g,"\\$1").replace(/<<double_star>>/g,".*").replace(/\*/g,"[^/]*");return!f.startsWith("/")&&!f.startsWith("*")&&(m=".*"+m),m="^"+m+"$",new RegExp(m).test(r)};return(n instanceof Array?n:[n]).some(t)}function oe(e){let{sourcePaths:n,exclude:t,forEnabledClassOnly:s}=e;if(!n)throw new Error("need provide source paths for reflect loader");let{classDefinitions:f,interfaceDefinitions:r,enumDefinitions:l,typeAliasDefinitions:w}=U(n,t),m=[],D=[];function S(y){let a=f.get(y),d=[];return a?(a.superClassName&&d.push(a.superClassName),d.push(...a.implementations||[])):(a=r.get(y),a?d.push(...a.implementations||[]):(a=w.get(y),a&&d.push(...a.implementations||[]))),d.flatMap(h=>[h,...S(h)])||[]}function u(y,a){return S(y.name).includes(a)}function T(y){if(J.isClassDeclaration(y)&&y.name!==void 0){let a=y.name.text,d=f.get(a);if(!a||!d||s&&!u(d,"EnableReflect"))return;D.push(`Reflect.__classDef = Object.assign(Reflect.__classDef || {}, { ${a} })`);return}y.forEachChild(T)}function M(){let y=[];return f.forEach((a,d)=>{s&&!u(a,"EnableReflect")||y.push(`Reflect.__classes = Object.assign(Reflect.__classes || {}, { ${d}: ${JSON.stringify(a)} })`)}),r.forEach((a,d)=>{s&&!u(a,"EnableReflect")||y.push(`Reflect.__interfaces = Object.assign(Reflect.__interfaces || {}, { ${d}: ${JSON.stringify(a)} })`)}),l.forEach((a,d)=>{y.push(`Reflect.__enums = Object.assign(Reflect.__enums || {}, { ${d}: ${JSON.stringify(a)} })`)}),w.forEach((a,d)=>{y.push(`Reflect.__typeAliases = Object.assign(Reflect.__typeAliases || {}, { ${d}: ${JSON.stringify(a)} })`)}),y.join(`
|
|
2
|
-
`)}return{outputAllMetas:M,transform:(y,
|
|
3
|
-
${t}`:n.transform(t,s))}}export{U as parseSource,
|
|
1
|
+
var $=(e,n,t)=>new Promise((s,l)=>{var r=m=>{try{w(t.next(m))}catch(D){l(D)}},c=m=>{try{w(t.throw(m))}catch(D){l(D)}},w=m=>m.done?s(m.value):Promise.resolve(m.value).then(r,c);w((t=t.apply(e,n)).next())});import B from"typescript";import i from"typescript";import*as E from"fs";import*as v from"process";import*as x from"path";var U={OUTPUT_LOG:!1},P=new Map,_=new Map,j=new Map,A=new Map,q=new Map,C=new Set,J={[i.SyntaxKind.BooleanKeyword]:"boolean",[i.SyntaxKind.StringKeyword]:"string",[i.SyntaxKind.BigIntKeyword]:"bigint",[i.SyntaxKind.NumberKeyword]:"number",[i.SyntaxKind.SymbolKeyword]:"symbol",[i.SyntaxKind.VoidKeyword]:"void",[i.SyntaxKind.UndefinedKeyword]:"undefined",[i.SyntaxKind.UnknownKeyword]:"unknown",[i.SyntaxKind.AnyKeyword]:"any",[i.SyntaxKind.ObjectKeyword]:"object"},O="any",X=["string","number","boolean","bigint","symbol"],Y=["any","Promise","Date","Error","undefined","unknown","object","Map","Set"],Z=["Mappable","EnableReflect"];[...X,...Y,...Z].forEach(se);Z.forEach(e=>_.set(e,{name:e}));var k,Q=!1,h=Reflect;function be(s,l){return $(this,arguments,function*(e,n,t=v.cwd()){if(t=x.resolve(t),h.__classes===void 0){e=oe(e),G(e,n),h.__classes={};for(let[r,c]of P)h.__classes[r]=c;h.__interfaces={};for(let[r,c]of _)h.__interfaces[r]=c;h.__typeAliases={};for(let[r,c]of A)h.__typeAliases[r]=c;h.__constTypes={};for(let[r,c]of q)h.__constTypes[r]=c;yield Promise.all(e.map(r=>ee(r,t)))}})}function ee(e,n){return $(this,null,function*(){if(!E.existsSync(e))return;if(E.statSync(e).isDirectory()){E.readdirSync(e).forEach(r=>{ee(x.join(e,r),n)});return}let s=yield import(x.join(n,e).replace(/\.ts$/,".js"));h.__classDef={},Object.values(s).forEach(l=>{typeof l=="function"&&(h.__classDef[l.name]=l)})})}function G(e,n){if(e||(e=[v.cwd()]),e=oe(e),!Q){let t=ne(e,n),s=i.createProgram(t,{});k=s.getTypeChecker(),t=t.map(r=>W(r)),s.getSourceFiles().filter(r=>t.includes(W(r.fileName))).forEach(r=>{b(`parse file: ${r.fileName}`),te(r)});for(let r of C.keys())!P.has(r)&&!_.has(r)&&!j.has(r)&&!A.has(r)&&!X.includes(r)&&!Y.includes(r)&&(b(`remove unknown typeName: ${r}`),C.delete(r));Array.from(P.values()).forEach(ge),Array.from(_.values()).forEach(Te),[P,_,A].forEach(De),Q=!0}return{classDefinitions:P,interfaceDefinitions:_,enumDefinitions:j,typeAliasDefinitions:A,constTypeDefinitions:q}}function ne(e,n){let t=[];return e.forEach(s=>{if(s=x.resolve(s),we(s,n)){b(`ignore excluded ${s}`);return}if(!E.existsSync(s)){console.error(`Path ${s} does not exist.`);return}if(E.statSync(s).isFile()){t.push(s);return}E.readdirSync(s).forEach(c=>t.push(...ne([x.join(s,c)],n)))}),t}function te(e){i.isClassDeclaration(e)?ce(e):i.isInterfaceDeclaration(e)?le(e):i.isEnumDeclaration(e)?pe(e):i.isTypeAliasDeclaration(e)?ue(e):i.isConstTypeReference(e)?me(e):e.forEachChild(te)}function ce(e){var w,m,D,R,u,T,K,M,L,y,o,d;let n=f(e.name);if(!n)return;let t=f((D=(m=(w=e.heritageClauses)==null?void 0:w.find(a=>a.token===i.SyntaxKind.ExtendsKeyword))==null?void 0:m.types)==null?void 0:D[0].expression),s=(u=(R=e.heritageClauses)==null?void 0:R.find(a=>a.token===i.SyntaxKind.ImplementsKeyword))==null?void 0:u.types.map(a=>f(a.expression)),l=[],r=[];for(let a of e.members)if(i.isPropertyDeclaration(a))l.push({name:f(a.name),isOptional:a.questionToken!==void 0,type:g(a),isPrivate:(T=a.modifiers)==null?void 0:T.some(p=>p.kind===i.SyntaxKind.PrivateKeyword),isStatic:(K=a.modifiers)==null?void 0:K.some(p=>p.kind===i.SyntaxKind.StaticKeyword)});else if(i.isMethodDeclaration(a))r.push({name:f(a.name),returnType:g(a),isPrivate:(M=a.modifiers)==null?void 0:M.some(p=>p.kind===i.SyntaxKind.PrivateKeyword),isStatic:(L=a.modifiers)==null?void 0:L.some(p=>p.kind===i.SyntaxKind.StaticKeyword),isAsync:(y=a.modifiers)==null?void 0:y.some(p=>p.kind===i.SyntaxKind.AsyncKeyword),args:a.parameters.map(p=>({name:f(p.name),type:g(p),isOptional:p.questionToken!==void 0}))});else if(i.isGetAccessorDeclaration(a)){let p=l.find(N=>N.name===f(a.name));p||(p={name:f(a.name),isOptional:a.questionToken===void 0,type:g(a)},l.push(p)),p.accessor=p.accessor||{},p.accessor.getter={isPrivate:((o=a.modifiers)==null?void 0:o.some(N=>N.kind===i.SyntaxKind.PrivateKeyword))||!1},p.isPrivate=p.accessor.getter.isPrivate}else if(i.isSetAccessorDeclaration(a)){let p=l.find(N=>N.name===f(a.name));p||(p={name:f(a.name),isOptional:a.questionToken===void 0,type:g(a)},l.push(p)),p.accessor=p.accessor||{},p.accessor.setter={isPrivate:((d=a.modifiers)==null?void 0:d.some(N=>N.kind===i.SyntaxKind.PrivateKeyword))||!1}}let c={name:n,superClassName:t,implementations:s,properties:l,methods:r};b(`Define class: ${f(e.name)}`),P.set(n,c)}function le(e){var w,m,D,R;let n=f(e.name);if(!n)return;let t=((m=(w=e.heritageClauses)==null?void 0:w.find(u=>u.token===i.SyntaxKind.ExtendsKeyword))==null?void 0:m.types.map(u=>f(u.expression)))||[],s=[],l=[],r;for(let u of e.members)i.isPropertySignature(u)?s.push({name:f(u.name),isOptional:u.questionToken!==void 0,type:g(u),isPrivate:((D=u.modifiers)==null?void 0:D.some(T=>T.kind===i.SyntaxKind.PrivateKeyword))||!1}):i.isMethodSignature(u)?l.push({name:u.name.text,returnType:g(u),isPrivate:((R=u.modifiers)==null?void 0:R.some(T=>T.kind===i.SyntaxKind.PrivateKeyword))||!1,args:u.parameters.map(T=>({name:f(T.name),type:g(T),isOptional:T.questionToken!==void 0}))}):i.isIndexSignatureDeclaration(u)&&(r=g(u));let c=_.get(n);c?(c.implementations=I(c.implementations||[],t),c.methods=I(c.methods||[],l,(u,T)=>u.name===T.name),c.properties=I(c.properties||[],s,(u,T)=>u.name===T.name),c.indexElementType=r,b(`Merge interface ${f(e.name)}`)):(c={name:n,implementations:t,methods:l,properties:s,indexElementType:r},_.set(n,c),b(`Define interface ${f(e.name)}`))}function pe(e){let n=f(e.name);n&&(j.set(n,{name:n,members:e.members.map(t=>({name:f(t.name),initializer:f(t.initializer)}))}),b(`Define enum: ${f(e.name)}`))}function ue(e){b(`Define typeAlias: ${f(e.name)}`),A.set(f(e.name),g(e))}function me(e){let n=e.parent.parent;i.isVariableDeclaration(n)&&n.initializer&&i.isAsExpression(n.initializer)&&q.set(f(n.name),ie(n.initializer.expression))}function ie(e){return i.isArrayLiteralExpression(e)?ye(e):i.isObjectLiteralExpression(e)?de(e):i.isNumericLiteral(e)?"number":i.isStringLiteral(e)?"string":i.isBigIntLiteral(e)?"bigint":[i.SyntaxKind.TrueKeyword,i.SyntaxKind.FalseKeyword].includes(e.kind)?"boolean":O}function ye(e){let n=[];return e.elements.forEach(t=>{if(i.isStringLiteral(t))return n.push(f(t))}),n.length===0?O:n.length===1?n[0]:{unionMembers:n}}function de(e){let n=[];return e.properties.map(t=>{i.isPropertyAssignment(t)?n.push({name:f(t.name),type:ie(t.initializer)}):b(`unsupported property: ${t.name}`)}),{typeLiteralMembers:n}}function se(e){C.add(e)}function g(e,n=!1){if(e.type&&!n)return S(e.type);if(!k)return console.error("TypeChecker not initialized!"),O;let t=k.getTypeAtLocation(e),s=k.typeToTypeNode(t,void 0,void 0);return s?S("type"in s?s.type:s):O}function S(e){let n={};if(e===void 0)return O;if(i.isUnionTypeNode(e))n.unionMembers=e.types.map(S);else if(i.isIntersectionTypeNode(e))n.intersectionMembers=e.types.map(S);else if(i.isLiteralTypeNode(e))n.literalValue=f(e.literal);else if(i.isTypeLiteralNode(e)){let t=[];e.members.forEach(s=>{i.isPropertySignature(s)?t.push({name:f(s.name),isOptional:s.questionToken!==void 0,type:g(s)}):i.isIndexSignatureDeclaration(s)?n.indexElementType=g(s):t.push({name:f(s.name)||"",isOptional:s.questionToken!==void 0,type:S()})}),n.typeLiteralMembers=t}else if(i.isArrayTypeNode(e))n.arrayElementType=S(e.elementType);else if(i.isFunctionTypeNode(e))n.isFunction=!0;else if(i.isTypeReferenceNode(e))if(se(f(e.typeName)),e.typeArguments)n.generics=[f(e.typeName),...e.typeArguments.map(t=>S(t))];else return f(e.typeName);else{if(i.isIndexedAccessTypeNode(e))return g(e,!0);if(i.isThisTypeNode(e))return g(e);if(i.isParenthesizedTypeNode(e))return g(e);if(i.isConditionalTypeNode(e))return g(e);if(i.isTypeQueryNode(e))return g(e);if(i.isConstructorTypeNode(e))n.isConstructor=!0;else if(i.isTupleTypeNode(e))n.tupleMembers=e.elements.map(S);else{if(Object.keys(J).includes(String(e.kind)))return J[e.kind]||O;if(i.isOptionalTypeNode(e))Object.assign(n,g(e)),n.isOptionalInTuple=!0;else if(i.isNamedTupleMember(e))Object.assign(n,g(e));else return i.isTypeOperatorNode(e)&&e.operator===i.SyntaxKind.KeyOfKeyword,g(e,!0)}}return n}var I=(e,n,t)=>[...(e==null?void 0:e.filter(s=>!(n!=null&&n.some(l=>(t||(()=>l===s))(l,s)))))||[],...n||[]];function F(e){if(e!==void 0&&e!==O)return typeof e=="string"?C.has(e)?e:void 0:e}function ge(e){var n,t;(n=e.methods)==null||n.forEach(ae),(t=e.properties)==null||t.forEach(re)}function Te(e){var n,t;(n=e.methods)==null||n.forEach(ae),(t=e.properties)==null||t.forEach(re)}function re(e){e.type=F(e.type)}function ae(e){var n;(n=e.args)==null||n.forEach(t=>t.type=F(t.type)),e.returnType=F(e.returnType)}function f(e){if(!e)return e;if(e.end<0)return e.text;try{return i.isQualifiedName(e)?f(e.right):e.getText()}catch(n){return e.text}}function z(e){e&&Object.entries(e).forEach(n=>{let[t,s]=n;s instanceof Array&&s.length===0||s===!1||s===void 0?delete e[t]:s.constructor===Array?s.forEach(z):s.constructor===Object&&z(s)})}function De(e){for(let n of e.values())z(n)}function we(e,n){return n?(n=n instanceof Array?n:[n],n.some(t=>(t instanceof RegExp||(t=new RegExp(t.replace(/\./g,"\\.").replace(/\*/g,".*"))),e.match(t)))):!1}function W(e,n=v.cwd()){return H(e).replace(H(n)+"/","")}function H(e){let n=x.sep;return e.split(n).join("/")}function oe(e){return e instanceof Array?e:[e]}function b(e){U.OUTPUT_LOG&&console.log(e)}function V(e,n){let t=l=>{let r=e.replace(/\\/g,"/"),c=l.replace(/\\/g,"/");c=c.replace(/\*\*/g,"<<double_star>>");let m=c.replace(/([.+^${}()|[\]\\])/g,"\\$1").replace(/<<double_star>>/g,".*").replace(/\*/g,"[^/]*");return!l.startsWith("/")&&!l.startsWith("*")&&(m=".*"+m),m="^"+m+"$",new RegExp(m).test(r)};return(n instanceof Array?n:[n]).some(t)}function fe(e){let{sourcePaths:n,exclude:t,forEnabledClassOnly:s,outputLog:l}=e;if(l&&(U.OUTPUT_LOG=!0),!n)throw new Error("need provide source paths for reflect loader");let{classDefinitions:r,interfaceDefinitions:c,enumDefinitions:w,typeAliasDefinitions:m}=G(n,t),D=[],R=[];function u(y){let o=r.get(y),d=[];return o?(o.superClassName&&d.push(o.superClassName),d.push(...o.implementations||[])):(o=c.get(y),o?d.push(...o.implementations||[]):(o=m.get(y),o&&d.push(...o.implementations||[]))),d.flatMap(a=>[a,...u(a)])||[]}function T(y,o){return u(y.name).includes(o)}function K(y){if(B.isClassDeclaration(y)&&y.name!==void 0){let o=y.name.text,d=r.get(o);if(!o||!d||s&&!T(d,"EnableReflect"))return;R.push(`Reflect.__classDef = Object.assign(Reflect.__classDef || {}, { ${o} })`);return}y.forEachChild(K)}function M(){let y=[];return r.forEach((o,d)=>{s&&!T(o,"EnableReflect")||y.push(`Reflect.__classes = Object.assign(Reflect.__classes || {}, { ${d}: ${JSON.stringify(o)} })`)}),c.forEach((o,d)=>{s&&!T(o,"EnableReflect")||y.push(`Reflect.__interfaces = Object.assign(Reflect.__interfaces || {}, { ${d}: ${JSON.stringify(o)} })`)}),w.forEach((o,d)=>{y.push(`Reflect.__enums = Object.assign(Reflect.__enums || {}, { ${d}: ${JSON.stringify(o)} })`)}),m.forEach((o,d)=>{y.push(`Reflect.__typeAliases = Object.assign(Reflect.__typeAliases || {}, { ${d}: ${JSON.stringify(o)} })`)}),y.join(`
|
|
2
|
+
`)}return{outputAllMetas:M,transform:(y,o)=>{let d=(typeof n=="string"?[n]:n).map(a=>a+"/**.ts");if(V(o,d))try{let a=B.createSourceFile(o,y,B.ScriptTarget.Latest,!1);return D.length=0,R.length=0,K(a),`${D.join(";")};${y};${R.join(";")}`}catch(a){return console.error(`[reflect-parser-plugin] Error processing ${o}:`,a),null}}}}var he=process.cwd().replace(/\\/g,"/")+"/";function Le(e){let n=fe(e);return{name:"reflect-parser-plugin",enforce:"pre",transform:(t,s)=>(s=s.replace(he,""),s===e.entry?`${n.outputAllMetas()}
|
|
3
|
+
${t}`:n.transform(t,s))}}export{U as DEBUG_CONFIG,G as parseSource,fe as reflectLoader,Le as reflectParserPlugin,be as setupReflectTypes,ee as updateReflectModules};
|
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ export interface ReflectLoaderOptions {
|
|
|
2
2
|
sourcePaths: string | string[];
|
|
3
3
|
exclude?: string | RegExp | (string | RegExp)[];
|
|
4
4
|
forEnabledClassOnly?: boolean;
|
|
5
|
+
outputLog?: boolean;
|
|
5
6
|
}
|
|
6
7
|
export declare function reflectLoader(options: ReflectLoaderOptions): {
|
|
7
8
|
outputAllMetas: () => string;
|
|
@@ -8,5 +8,7 @@ export type Type = string | {
|
|
|
8
8
|
} | {
|
|
9
9
|
tuple: Type[];
|
|
10
10
|
};
|
|
11
|
-
export declare function getTypeDef(type: Type): TypeDefinition;
|
|
11
|
+
export declare function getTypeDef(type: Type | TypeDefinition): TypeDefinition;
|
|
12
12
|
export declare function assertType<T>(data: T, type: Type, depth?: number): T;
|
|
13
|
+
export declare function isNullable(type: Type | TypeDefinition): boolean;
|
|
14
|
+
export declare function isType(value: unknown, type: Type | TypeDefinition): boolean;
|
|
@@ -7,7 +7,4 @@ export type AnyFunction = (...args: Any[]) => Any;
|
|
|
7
7
|
export declare function setValue<T>(target: unknown, field: string | symbol, value: T): void;
|
|
8
8
|
export declare function getValue<T>(target: unknown, field: string | symbol): T | undefined;
|
|
9
9
|
export declare function mapNotNull<T, U>(arr: T[] | undefined, mapper: (item: T) => U | undefined): U[];
|
|
10
|
-
export declare function spy(variables: {
|
|
11
|
-
[prop: string]: unknown;
|
|
12
|
-
}): void;
|
|
13
10
|
export {};
|