UNPKG

@resk/core

Version:

An innovative TypeScript framework that empowers developers to build applications with a fully decorator-based architecture for efficient resource management. By combining the power of decorators with a resource-oriented design, DecorRes enhances code cla

1 lines 4.9 kB
'use strict';require('reflect-metadata');function T(e){return !e||typeof e!="object"?false:e instanceof Date?true:typeof e.getTime!="function"?false:!(Object.prototype.toString.call(e)!=="[object Date]"||isNaN(e.getTime()))}function d(e){return typeof window!="object"||!window||typeof document=="undefined"||typeof HTMLElement=="undefined"?false:e===document?true:"HTMLElement"in window?!!e&&e instanceof HTMLElement:!!e&&typeof e=="object"&&e.nodeType===1&&!!e.nodeName}function g(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function O(e){if(e instanceof RegExp)return true;if(!e||typeof e!="object"||!Object.prototype.toString.call(e).includes("RegExp"))return false;try{return new RegExp(e),!0}catch(t){return false}}function c(e){if(e===null||typeof e!="object"||d(e)||T(e)||O(e)||g(e))return false;let t=Object.getPrototypeOf(e);if(t===null)return true;let n=t.constructor;if(typeof n!="function")return false;if(n===Object)return true;let r=n.prototype;return typeof r!="object"?false:r===Object.prototype?true:typeof t.hasOwnProperty=="function"&&t.hasOwnProperty("isPrototypeOf")&&typeof t.isPrototypeOf=="function"}function R(e){if(Array.isArray(e)){let r=[];for(var t=0;t<e.length;t++)r[t]=R(e[t]);return r}else if(c(e)&&e){let r={};for(var n in e)e.hasOwnProperty(n)&&(r[n]=R(e[n]));return r}else return e}Object.getSize=function(e,t=false){if(!e||typeof e!="object")return 0;if(Array.isArray(e))return e.length;typeof t!="boolean"&&(t=false);let n=0;for(let r in e)if(e.hasOwnProperty(r)&&(n++,t===true))return n;return n};function l(e,...t){let n=Array.isArray(e),r=c(e);(e==null||!n&&!r)&&(e={});for(let i=0;i<t.length;i++){let a=t[i];if(a==null)continue;let o=c(a),y=Array.isArray(a);if(!(!o&&!y)){if(n){y&&A(e,a);continue}else if(y)continue;for(let u in a){let s=a[u];if(s==null)continue;if(s===a){e[u]=e;continue}let p=e[u],b=Array.isArray(p),m=Array.isArray(s);if(b){m?A(e[u],s):e[u]=s;continue}else if(!c(p)){e[u]=s;continue}if(m||!c(s)){e[u]=s;continue}e[u]=l({},p,s);}}}return e}var A=(e,t)=>{let n=t.length,r=0;for(let i=0;i<e.length;i++){let a=e[i],o=t[i];if(i<n){let y=Array.isArray(a),u=Array.isArray(o),s=c(a),p=c(o);y&&u||s&&p?(e[r]=l(y?[]:{},a,o),r++):o!=null?(e[r]=o,r++):a!=null&&(e[r]=a,r++);}}for(let i=e.length;i<n;i++)t[i]!==void 0&&t[i]!==null&&e.push(t[i]);return e};function S(e,t){return f(e,"",{},t)}function f(e,t="",n={},r){if(n=c(n)?n:{},g(e)||T(e)||O(e)||Array.isArray(e)&&(r!=null&&r.skipArrays))return t&&(n[t]=e),n;if(typeof e=="function"||typeof e=="object"&&!c(e)&&!E(e))return n;if(e instanceof Map||e instanceof WeakMap)return Array.from(e.entries()).forEach(([i,a])=>{let o=t?`${t}[${String(i)}]`:String(i);f(a,o,n,r);}),n;if(Array.isArray(e)||e instanceof Set||e instanceof WeakSet)return (Array.isArray(e)?e:Array.from(e)).forEach((a,o)=>{let y=t?`${t}[${o}]`:String(o);f(a,y,n,r);}),n;if(c(e))for(let i in e){if(!Object.prototype.hasOwnProperty.call(e,i))continue;let a=e[i],o=t?t.endsWith("]")?`${t}.${i}`:`${t}.${i}`:i;f(a,o,n,r);}return n}function E(e){return Array.isArray(e)||e instanceof Set||e instanceof Map||e instanceof WeakMap||e instanceof WeakSet}function P(e){return Object.entries(e)}Object.typedEntries=P;Object.flatten=S;Object.clone=R;function I(e){return !!(e&&typeof e=="string")}function h(...e){for(var t in e){let n=e[t];if(typeof n=="string"&&I(n))return n}return ""}function Q(e,t){return (n,r)=>{let i=n==null?void 0:n.constructor,a=Object.assign({},Reflect.getMetadata(e,i)),o=a[r],y=typeof t=="function"?t(o,a,n,r):t;a[r]=y,Reflect.defineMetadata(e,a,i),Reflect.defineMetadata(e,t,n,r);}}function D(e,t){return l({},Reflect.getMetadata(t,e),Reflect.getMetadata(t,e.prototype))}function U(e,t,n){return D(e,t)[n]}var k="typeRegistry",w="componentRegistry",M=class e{static getMetadataKey(t,n){return `${k}-${n}:${t}`.trim()}static register(t,n,r){!t||typeof t!="string"||!n||typeof n!="string"||Reflect.defineMetadata(this.getMetadataKey(t,n),r,e);}static getRenderer(t,n){return Reflect.getMetadata(this.getMetadataKey(t,n),e)}static hasRenderer(t,n){return !!this.getRenderer(t,n)}static render(t,n,r,i){let a=e.getRenderer(t,r);return a?a(n):i}};function X(e){return t=>function(n){M.register(t,e,n);}}var x=class e{static getMetadataKey(t){return t=h(t,"undefined-component-name"),`${w}:${t}`.trim()}static register(t,n){!t||typeof t!="string"||Reflect.defineMetadata(this.getMetadataKey(t),n,e);}static getRenderer(t){return Reflect.getMetadata(this.getMetadataKey(t),e)}static hasRenderer(t){return !!this.getRenderer(t)}static render(t,n,r){let i=this.getRenderer(n);return i?i(t):r}};function _(e){return function(t){x.register(e,t);}}exports.ComponentRegistry=x;exports.TypeRegistry=M;exports.buildPropertyDecorator=Q;exports.createComponentRegistryDecorator=_;exports.createTypeRegistryDecorator=X;exports.getDecoratedProperties=D;exports.getDecoratedProperty=U;