-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular-ts-decorators.min.js
1 lines (1 loc) · 7.04 KB
/
angular-ts-decorators.min.js
1
function annotate(t){return injector().annotate(t)}function kebabToCamel(t){return t.replace(/(-\w)/g,function(t){return t[1].toUpperCase()})}function getAttributeName(t){return t.substr(1,t.length-2)}function isAttributeSelector(t){return/^[\[].*[\]]$/g.test(t)}function getMetadata(t,e){return Reflect.getMetadata(t,e)}function defineMetadata(t,e,n){Reflect.defineMetadata(t,e,n)}function Component(t){var e=t.selector,n=__rest(t,["selector"]);return function(t){n.controller=t;var a=isAttributeSelector(e),o=getMetadata(metadataKeys.bindings,t);o&&(a?(n.bindToController=o,n.controllerAs=n.controllerAs||"$ctrl"):n.bindings=o),a&&(n.restrict="A"),replaceLifecycleHooks(t);var r=a?getAttributeName(e):e;defineMetadata(metadataKeys.name,kebabToCamel(r),t),defineMetadata(metadataKeys.declaration,a?Declarations.directive:Declarations.component,t),defineMetadata(metadataKeys.options,n,t)}}function registerComponent(t,e){var n=getMetadata(metadataKeys.name,e),a=getMetadata(metadataKeys.options,e),o=getMetadata(metadataKeys.listeners,a.controller);o&&(a.controller=extendWithHostListeners(a.controller,o)),e.$inject=e.$inject||annotate(e),t.component(n,a)}function extendWithHostListeners(t,e){var n=Object.keys(e),a=function(t){function a(e){for(var n=[],a=1;a<arguments.length;a++)n[a-1]=arguments[a];var o=t.apply(this,n)||this;return o.$element=e,o}return __extends(a,t),a.prototype.$postLink=function(){var a=this;t.prototype.$postLink&&t.prototype.$postLink.call(this),n.forEach(function(t){var n=e[t].eventName;a.$element.on(n,a[t].bind(a))})},a.prototype.$onDestroy=function(){var a=this;t.prototype.$onDestroy&&t.prototype.$onDestroy.call(this),n.forEach(function(t){var n=e[t].eventName;a.$element.off(n,a[t])})},a}(t);return a.$inject=["$element"].concat(t.$inject||[]),a}function replaceLifecycleHooks(t){var e=t.prototype;getHooksOnCtrlClass(e).forEach(function(t){var n=ngLifecycleHooksMap[t];e[n]=e[t],delete e[t]})}function getHooksOnCtrlClass(t){return Object.keys(ngLifecycleHooksMap).filter(function(e){return isFunction(t[e])})}function Directive(t){var e=t.selector,n=__rest(t,["selector"]);return function(t){var a=getMetadata(metadataKeys.bindings,t);a&&(n.bindToController=a),n.restrict=n.restrict||"A",n.restrict,n.link||n.compile;var o=isAttributeSelector(e)?getAttributeName(e):e;defineMetadata(metadataKeys.name,kebabToCamel(o),t),defineMetadata(metadataKeys.declaration,Declarations.directive,t),defineMetadata(metadataKeys.options,n,t)}}function registerDirective(t,e){var n,a=getMetadata(metadataKeys.name,e),o=getMetadata(metadataKeys.options,e),r=e.prototype,i=r.compile,s=r.link;if(i&&"function"==typeof i||s&&"function"==typeof s)(n=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var a=t[0].instantiate(e);return i?o.compile=i.bind(a):s&&(o.link=s.bind(a)),o}).$inject=["$injector"].concat(e.$inject||annotate(e));else{e.$inject=e.$inject||annotate(e),replaceLifecycleHooks(e);var c=getMetadata(metadataKeys.listeners,e);o.controller=c?extendWithHostListeners$1(e,c):e,n=function(){return o}}t.directive(a,n)}function extendWithHostListeners$1(t,e){var n=Object.keys(e),a=function(t){function a(e){for(var n=[],a=1;a<arguments.length;a++)n[a-1]=arguments[a];var o=t.apply(this,n)||this;return o.$element=e,o}return __extends(a,t),a.prototype.$postLink=function(){var a=this;t.prototype.$postLink&&t.prototype.$postLink.call(this),n.forEach(function(t){var n=e[t].eventName;a.$element.on(n,a[t].bind(a))})},a.prototype.$onDestroy=function(){var a=this;t.prototype.$onDestroy&&t.prototype.$onDestroy.call(this),n.forEach(function(t){var n=e[t].eventName;a.$element.off(n,a[t])})},a}(t);return a.$inject=["$element"].concat(t.$inject||[]),a}function Injectable(t){return function(e){t||(t=e.name),defineMetadata(metadataKeys.name,t,e)}}function registerProviders(t,e){e.forEach(function(e){if(e.provide){var n=e.provide;e.useClass&&e.useClass instanceof Function?(e.useClass.$inject=e.useClass.$inject||annotate(e.useClass),e.useClass.prototype.$get?t.provider(n,e.useClass):t.service(n,e.useClass)):e.useFactory&&e.useFactory instanceof Function?(e.useFactory.$inject=e.useFactory.$inject||annotate(e.useFactory),t.factory(n,e.useFactory)):e.useValue&&t.constant(n,e.useValue)}else{var a=getMetadata(metadataKeys.name,e);e.$inject=e.$inject||annotate(e),e.prototype.$get?t.provider(a,e):t.service(a,e)}})}function Pipe(t){return function(e){defineMetadata(metadataKeys.name,t.name,e),defineMetadata(metadataKeys.declaration,Declarations.pipe,e)}}function registerPipe(t,e){var n=getMetadata(metadataKeys.name,e),a=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var a=t[0].instantiate(e);return a.transform.bind(a)};a.$inject=["$injector"].concat(e.$inject||annotate(e)),t.filter(n,a)}function Input(t){return function(e,n){return addBindingToMetadata(e,n,"<",t)}}function Output(t){return function(e,n){return addBindingToMetadata(e,n,"&",t)}}function addBindingToMetadata(t,e,n,a){var o=t.constructor,r=getMetadata(metadataKeys.bindings,o)||{};r[e]=a||n,defineMetadata(metadataKeys.bindings,r,o)}function NgModule(t){var e=t.id,n=t.name,a=t.declarations,o=void 0===a?[]:a,r=t.imports,i=void 0===r?[]:r,s=t.providers,c=void 0===s?[]:s;return function(t){var a=i.map(function(t){return"string"==typeof t?t:t.module.name});n&&(e=n),e||(e=t.name);var r=module$1(e,a);o.forEach(function(t){switch(getMetadata(metadataKeys.declaration,t)){case Declarations.component:registerComponent(r,t);break;case Declarations.directive:registerDirective(r,t);break;case Declarations.pipe:registerPipe(r,t)}}),c&®isterProviders(r,c);var s=t.config,u=t.run;s&&(s.$inject=annotate(s),r.config(s)),u&&(u.$inject=annotate(u),r.run(u)),t.module=r}}function HostListener(t,e){return function(n,a,o){var r=o.value;if("function"!=typeof r)throw new Error("@HostListener decorator can only be applied to methods not: "+typeof r);var i=n.constructor,s=getMetadata(metadataKeys.listeners,i)||{};s[a]={eventName:t,args:e},defineMetadata(metadataKeys.listeners,s,i)}}import{bootstrap,element,injector,isFunction,module as module$1}from"angular";import*as angular from"angular";import{__extends,__rest}from"tslib";import*as tslib_1 from"tslib";import"reflect-metadata";var platformBrowserDynamic=function(){return PlatformRef},PlatformRef={bootstrapModule:function(t,e){var n=!0;e&&(n=e.strictDi),element(document).ready(function(){bootstrap(document,[t.module.name],{strictDi:n})})}},Declarations;!function(t){t[t.component=0]="component",t[t.directive=1]="directive",t[t.pipe=2]="pipe"}(Declarations||(Declarations={}));var metadataKeys={declaration:"custom:declaration",name:"custom:name",bindings:"custom:bindings",options:"custom:options",listeners:"custom:listeners"},ngLifecycleHooksMap={ngOnInit:"$onInit",ngOnDestroy:"$onDestroy",ngDoCheck:"$doCheck",ngOnChanges:"$onChanges",ngAfterViewInit:"$postLink"},SimpleChange=function(){function t(t,e,n){this.previousValue=t,this.currentValue=e,this.firstChange=n}return t.prototype.isFirstChange=function(){return this.firstChange},t}();export{platformBrowserDynamic,Component,Directive,Injectable,Pipe,Input,Output,NgModule,NgModule as NgModuleDecorated,HostListener,ngLifecycleHooksMap,SimpleChange};