UNPKG

@web-atoms/core

Version:
89 lines (88 loc) 2.82 kB
System.register(["./TypeKey"], function (_export, _context) { "use strict"; var TypeKey, InjectedTypes; function Inject(target, name, index) { if (index !== undefined) { const key = TypeKey.get(target); const plist = Reflect.getMetadata("design:paramtypes", target, name); if (typeof index === "number") { const pSavedList = InjectedTypes.paramList[key] || (InjectedTypes.paramList[key] = []); pSavedList[index] = plist[index]; } else { throw new Error("Inject can only be applied on constructor" + "parameter or a property without get/set methods"); } } else { const key = TypeKey.get(target.constructor); const plist = Reflect.getMetadata("design:type", target, name); const p = InjectedTypes.propertyList[key] || (InjectedTypes.propertyList[key] = {}); p[name] = plist; let base = target.constructor; while (true) { base = Object.getPrototypeOf(base); if (!base) { break; } const baseKey = TypeKey.get(base); const bp = InjectedTypes.propertyList[baseKey]; if (bp) { for (const pKey in bp) { if (bp.hasOwnProperty(pKey)) { const element = bp[pKey]; if (!p[pKey]) { p[pKey] = element; } } } } } } } _export({ InjectedTypes: void 0, Inject: Inject }); return { setters: [function (_TypeKey) { TypeKey = _TypeKey.TypeKey; }], execute: function () { _export("InjectedTypes", InjectedTypes = class InjectedTypes { static getParamList(key, typeKey1) { let plist = InjectedTypes.paramList[typeKey1]; let type = key; while (plist === undefined) { type = Object.getPrototypeOf(type); if (!type) { break; } const typeKey = TypeKey.get(type); plist = InjectedTypes.paramList[typeKey]; if (!plist) { InjectedTypes.paramList[typeKey] = plist; } } return plist; } static getPropertyList(key, typeKey1) { let plist = InjectedTypes.propertyList[typeKey1]; let type = key; while (plist === undefined) { type = Object.getPrototypeOf(type); if (!type) { break; } const typeKey = TypeKey.get(type); plist = InjectedTypes.propertyList[typeKey]; if (!plist) { InjectedTypes.propertyList[typeKey] = plist; } } return plist; } }); InjectedTypes.paramList = {}; InjectedTypes.propertyList = {}; } }; }); //# sourceMappingURL=Inject.js.map