@huntsman-cancer-institute/utils 17.9.3 → 17.9.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"huntsman-cancer-institute-utils.mjs","sources":["../../../projects/utils/src/component-type.decorator.ts","../../../projects/utils/src/injection.ts","../../../projects/utils/src/huntsman-cancer-institute-utils.ts"],"sourcesContent":["/**\r\n * We do a lot of dynamic component creation and use the class name to reference the component. The problem is that\r\n * uglification obfuscates the component name so it no longer matches the component name stored as a string in the typescript\r\n * or database. Use this decorator to auto specify the componentType on that class. This is the standard by which\r\n * our injection util will find the appropriate component.\r\n *\r\n * @param {string} componentType\r\n * @returns {any}\r\n * @constructor\r\n */\r\nexport function ComponentType(componentType: string) {\r\n function decorator(target, n, descriptor) {\r\n target.componentType = componentType;\r\n };\r\n\r\n return <any>decorator;\r\n}\r\n","import {ComponentFactoryResolver, ComponentRef, Type, ViewContainerRef} from \"@angular/core\";\r\n\r\n/**\r\n * Helper classes that will dynamically create a component from a Type or string name.\r\n *\r\n * One important consideration is that types are uglified during production packing. This means that if we search for\r\n * a type with a string, it won't find it because the type name is now obfuscated. To get around this, I introduce a\r\n * new decorator that you must pass in the original type as a string. The decorator then places that as the\r\n * \"componentType\" on the class.\r\n */\r\nexport class ComponentInjector {\r\n\r\n static getComponentRef(resolver: ComponentFactoryResolver, container: ViewContainerRef, type: Type<any> | string): ComponentRef<any> {\r\n let factory = null;\r\n let factories = null;\r\n\r\n try {\r\n if (typeof type === \"string\") {\r\n let factories = Array.from(resolver[\"_factories\"].keys());\r\n let factoryClass = <Type<any>>factories.find((factory: any) => factory.componentType === type);\r\n if (!factoryClass) {\r\n factoryClass = <Type<any>>factories.find((factory: any) => factory.name === type);\r\n }\r\n factory = resolver.resolveComponentFactory(factoryClass);\r\n } else {\r\n factory = resolver.resolveComponentFactory(type);\r\n }\r\n return container.createComponent(factory);\r\n } catch (error) {\r\n console.error(\"getComponentRef: \" + type);\r\n console.error(error);\r\n }\r\n }\r\n\r\n static getComponent(resolver: ComponentFactoryResolver, container: ViewContainerRef, type: Type<any> | string): any {\r\n let factory = null;\r\n if (typeof type === \"string\") {\r\n let factories = Array.from(resolver[\"_factories\"].keys());\r\n let factoryClass = <Type<any>>factories.find((factory: any) => factory.componentType === type);\r\n if (!factoryClass) {\r\n factoryClass = <Type<any>>factories.find((factory: any) => factory.name === type);\r\n }\r\n factory = resolver.resolveComponentFactory(factoryClass);\r\n } else {\r\n factory = resolver.resolveComponentFactory(type);\r\n }\r\n let componentRef = container.createComponent(factory);\r\n return componentRef.instance;\r\n }\r\n\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAAA;;;;;;;;;AASG;AACG,SAAU,aAAa,CAAC,aAAqB,EAAA;AACjD,IAAA,SAAS,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,UAAU,EAAA;AACtC,QAAA,MAAM,CAAC,aAAa,GAAG,aAAa
|
|
1
|
+
{"version":3,"file":"huntsman-cancer-institute-utils.mjs","sources":["../../../projects/utils/src/component-type.decorator.ts","../../../projects/utils/src/injection.ts","../../../projects/utils/src/huntsman-cancer-institute-utils.ts"],"sourcesContent":["/**\r\n * We do a lot of dynamic component creation and use the class name to reference the component. The problem is that\r\n * uglification obfuscates the component name so it no longer matches the component name stored as a string in the typescript\r\n * or database. Use this decorator to auto specify the componentType on that class. This is the standard by which\r\n * our injection util will find the appropriate component.\r\n *\r\n * @param {string} componentType\r\n * @returns {any}\r\n * @constructor\r\n */\r\nexport function ComponentType(componentType: string) {\r\n function decorator(target, n, descriptor) {\r\n target.componentType = componentType;\r\n };\r\n\r\n return <any>decorator;\r\n}\r\n","import {ComponentFactoryResolver, ComponentRef, Type, ViewContainerRef} from \"@angular/core\";\r\n\r\n/**\r\n * Helper classes that will dynamically create a component from a Type or string name.\r\n *\r\n * One important consideration is that types are uglified during production packing. This means that if we search for\r\n * a type with a string, it won't find it because the type name is now obfuscated. To get around this, I introduce a\r\n * new decorator that you must pass in the original type as a string. The decorator then places that as the\r\n * \"componentType\" on the class.\r\n */\r\nexport class ComponentInjector {\r\n\r\n static getComponentRef(resolver: ComponentFactoryResolver, container: ViewContainerRef, type: Type<any> | string): ComponentRef<any> {\r\n let factory = null;\r\n let factories = null;\r\n\r\n try {\r\n if (typeof type === \"string\") {\r\n let factories = Array.from(resolver[\"_factories\"].keys());\r\n let factoryClass = <Type<any>>factories.find((factory: any) => factory.componentType === type);\r\n if (!factoryClass) {\r\n factoryClass = <Type<any>>factories.find((factory: any) => factory.name === type);\r\n }\r\n factory = resolver.resolveComponentFactory(factoryClass);\r\n } else {\r\n factory = resolver.resolveComponentFactory(type);\r\n }\r\n return container.createComponent(factory);\r\n } catch (error) {\r\n console.error(\"getComponentRef: \" + type);\r\n console.error(error);\r\n }\r\n }\r\n\r\n static getComponent(resolver: ComponentFactoryResolver, container: ViewContainerRef, type: Type<any> | string): any {\r\n let factory = null;\r\n if (typeof type === \"string\") {\r\n let factories = Array.from(resolver[\"_factories\"].keys());\r\n let factoryClass = <Type<any>>factories.find((factory: any) => factory.componentType === type);\r\n if (!factoryClass) {\r\n factoryClass = <Type<any>>factories.find((factory: any) => factory.name === type);\r\n }\r\n factory = resolver.resolveComponentFactory(factoryClass);\r\n } else {\r\n factory = resolver.resolveComponentFactory(type);\r\n }\r\n let componentRef = container.createComponent(factory);\r\n return componentRef.instance;\r\n }\r\n\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"AAAA;;;;;;;;;AASG;AACG,SAAU,aAAa,CAAC,aAAqB,EAAA;AACjD,IAAA,SAAS,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,UAAU,EAAA;AACtC,QAAA,MAAM,CAAC,aAAa,GAAG,aAAa;IACtC;IAAC;AAED,IAAA,OAAY,SAAS;AACvB;;ACdA;;;;;;;AAOG;MACU,iB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