@angular-extensions/elements
Advanced tools
Comparing version 0.3.7 to 6.1.0
@@ -5,3 +5,5 @@ /** | ||
export * from './public-api'; | ||
export { LazyElementDirective as ɵa } from './lib/lazy-elements/lazy-element/lazy-element.directive'; | ||
export { LazyElementsLoaderService as ɵb } from './lib/lazy-elements/lazy-elements-loader.service'; | ||
export { LazyElementDynamicDirective as ɵg } from './lib/lazy-elements/lazy-element-dynamic/lazy-element-dynamic.directive'; | ||
export { LazyElementDirective as ɵd } from './lib/lazy-elements/lazy-element/lazy-element.directive'; | ||
export { ElementConfig as ɵe, LazyElementsLoaderService as ɵf } from './lib/lazy-elements/lazy-elements-loader.service'; | ||
export { LAZY_ELEMENT_CONFIGS as ɵa, LAZY_ELEMENT_ROOT_GUARD as ɵc, LAZY_ELEMENT_ROOT_OPTIONS as ɵb } from './lib/lazy-elements/lazy-elements.tokens'; |
@@ -1,1 +0,1 @@ | ||
{"__symbolic":"module","version":4,"metadata":{"LazyElementsModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":5,"character":1},"arguments":[{"declarations":[{"__symbolic":"reference","name":"ɵa"}],"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":7,"character":12}],"exports":[{"__symbolic":"reference","name":"ɵa"}]}]}],"members":{}},"ɵa":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":4,"character":1},"arguments":[{"selector":"[axLazyElement]"}]}],"members":{"url":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":8,"character":3},"arguments":["axLazyElement"]}]}],"loadingTemplateRef":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":9,"character":3},"arguments":["axLazyElementLoading"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ViewContainerRef","line":12,"character":17},{"__symbolic":"reference","name":"TemplateRef","module":"@angular/core","arguments":[{"__symbolic":"reference","name":"any"}]},{"__symbolic":"reference","name":"ɵb"}]}],"ngOnInit":[{"__symbolic":"method"}]}},"ɵb":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":4,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor"}],"loadElement":[{"__symbolic":"method"}],"addElement":[{"__symbolic":"method"}],"hasElement":[{"__symbolic":"method"}],"stripUrlProtocol":[{"__symbolic":"method"}]},"statics":{"ngInjectableDef":{}}}},"origins":{"LazyElementsModule":"./lib/lazy-elements/lazy-elements.module","ɵa":"./lib/lazy-elements/lazy-element/lazy-element.directive","ɵb":"./lib/lazy-elements/lazy-elements-loader.service"},"importAs":"@angular-extensions/elements"} | ||
{"__symbolic":"module","version":4,"metadata":{"ɵa":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":5,"character":40},"arguments":["LAZY_ELEMENT_CONFIGS"]},"ɵb":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":9,"character":45},"arguments":["LAZY_ELEMENT_ROOT_OPTIONS"]},"ɵc":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":13,"character":43},"arguments":["LAZY_ELEMENT_ROOT_GUARD"]},"LAZY_ELEMENTS_REGISTRY":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":17,"character":42},"arguments":["Lazu elements registry",{"__symbolic":"error","message":"Lambda not supported","line":21,"character":13,"module":"./lib/lazy-elements/lazy-elements.tokens"}]},"LazyElementsRegistry":{"__symbolic":"interface"},"createLazyElementRootGuard":{"__symbolic":"function"},"LazyElementsModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":36,"character":1},"arguments":[{"declarations":[{"__symbolic":"reference","name":"ɵd"},{"__symbolic":"reference","name":"ɵg"}],"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":38,"character":12}],"exports":[{"__symbolic":"reference","name":"ɵd"},{"__symbolic":"reference","name":"ɵg"}],"providers":[]}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":92,"character":5}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":93,"character":5},"arguments":[{"__symbolic":"reference","name":"ɵa"}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":95,"character":5}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":96,"character":5},"arguments":[{"__symbolic":"reference","name":"ɵc"}]}]],"parameters":[{"__symbolic":"reference","name":"ɵf"},{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","name":"Array","arguments":[{"__symbolic":"reference","name":"ɵe"}]}]},{"__symbolic":"reference","name":"any"}]}]},"statics":{"forRoot":{"__symbolic":"function","parameters":["options"],"value":{"ngModule":{"__symbolic":"reference","name":"LazyElementsModule"},"providers":[{"provide":{"__symbolic":"reference","name":"ɵa"},"useValue":{"__symbolic":"if","condition":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"reference","name":"options"},"right":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"options"},"member":"elementConfigs"}},"thenExpression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"options"},"member":"elementConfigs"},"elseExpression":[]},"multi":true},{"provide":{"__symbolic":"reference","name":"ɵb"},"useValue":{"__symbolic":"if","condition":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"options"},"member":"rootOptions"},"thenExpression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"options"},"member":"rootOptions"},"elseExpression":{}}},{"provide":{"__symbolic":"reference","module":"@angular/core","name":"ANALYZE_FOR_ENTRY_COMPONENTS","line":58,"character":19},"useValue":{"__symbolic":"reference","name":"options"},"multi":true},{"provide":{"__symbolic":"reference","name":"ɵc"},"useFactory":{"__symbolic":"reference","name":"createLazyElementRootGuard"},"deps":[[{"__symbolic":"reference","name":"ɵa"},{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":65,"character":44}},{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"SkipSelf","line":65,"character":60}}]]}]}},"forFeature":{"__symbolic":"function","parameters":["options"],"value":{"ngModule":{"__symbolic":"reference","name":"LazyElementsModule"},"providers":[{"provide":{"__symbolic":"reference","name":"ɵa"},"useValue":{"__symbolic":"if","condition":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"reference","name":"options"},"right":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"options"},"member":"elementConfigs"}},"thenExpression":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"options"},"member":"elementConfigs"},"elseExpression":[]},"multi":true},{"provide":{"__symbolic":"reference","module":"@angular/core","name":"ANALYZE_FOR_ENTRY_COMPONENTS","line":82,"character":19},"useValue":{"__symbolic":"binop","operator":"&&","left":{"__symbolic":"reference","name":"options"},"right":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"options"},"member":"elementConfigs"}},"multi":true}]}}}},"LazyElementModuleOptions":{"__symbolic":"interface"},"LazyElementModuleRootOptions":{"__symbolic":"interface"},"LazyElementRootOptions":{"__symbolic":"interface"},"ɵd":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":17,"character":1},"arguments":[{"selector":"[axLazyElement]"}]}],"members":{"url":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":21,"character":3},"arguments":["axLazyElement"]}]}],"loadingTemplateRef":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":22,"character":3},"arguments":["axLazyElementLoadingTemplate"]}]}],"errorTemplateRef":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":23,"character":3},"arguments":["axLazyElementErrorTemplate"]}]}],"isModule":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":24,"character":3},"arguments":["axLazyElementModule"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ViewContainerRef","line":27,"character":17},{"__symbolic":"reference","name":"TemplateRef","module":"@angular/core","arguments":[{"__symbolic":"reference","name":"any"}]},{"__symbolic":"reference","name":"ɵf"},{"__symbolic":"reference","module":"@angular/core","name":"ComponentFactoryResolver","line":30,"character":17},{"__symbolic":"reference","module":"@angular/core","name":"ChangeDetectorRef","line":31,"character":17}]}],"ngOnInit":[{"__symbolic":"method"}]}},"ɵe":{"__symbolic":"interface"},"ɵf":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":20,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":27,"character":5},"arguments":[{"__symbolic":"reference","name":"LAZY_ELEMENTS_REGISTRY"}]}],[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":28,"character":5}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":29,"character":5},"arguments":[{"__symbolic":"reference","name":"ɵb"}]}]],"parameters":[{"__symbolic":"reference","name":"LazyElementsRegistry"},{"__symbolic":"reference","name":"LazyElementRootOptions"}]}],"addConfigs":[{"__symbolic":"method"}],"getElementConfig":[{"__symbolic":"method"}],"preload":[{"__symbolic":"method"}],"loadElement":[{"__symbolic":"method"}],"addElement":[{"__symbolic":"method"}],"hasElement":[{"__symbolic":"method"}],"stripUrlProtocol":[{"__symbolic":"method"}]},"statics":{"ngInjectableDef":{}}},"ɵg":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Directive","line":17,"character":1},"arguments":[{"selector":"[axLazyElementDynamic]"}]}],"members":{"tag":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":21,"character":3},"arguments":["axLazyElementDynamic"]}]}],"url":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":22,"character":3},"arguments":["axLazyElementDynamicUrl"]}]}],"loadingTemplateRef":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":23,"character":3},"arguments":["axLazyElementDynamicLoadingTemplate"]}]}],"errorTemplateRef":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":26,"character":3},"arguments":["axLazyElementDynamicErrorTemplate"]}]}],"isModule":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":29,"character":3},"arguments":["axLazyElementDynamicModule"]}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ViewContainerRef","line":32,"character":17},{"__symbolic":"reference","name":"TemplateRef","module":"@angular/core","arguments":[{"__symbolic":"reference","name":"any"}]},{"__symbolic":"reference","name":"ɵf"},{"__symbolic":"reference","module":"@angular/core","name":"ComponentFactoryResolver","line":35,"character":17},{"__symbolic":"reference","module":"@angular/core","name":"ChangeDetectorRef","line":36,"character":17}]}],"ngOnInit":[{"__symbolic":"method"}]}}},"origins":{"ɵa":"./lib/lazy-elements/lazy-elements.tokens","ɵb":"./lib/lazy-elements/lazy-elements.tokens","ɵc":"./lib/lazy-elements/lazy-elements.tokens","LAZY_ELEMENTS_REGISTRY":"./lib/lazy-elements/lazy-elements.tokens","LazyElementsRegistry":"./lib/lazy-elements/lazy-elements.tokens","createLazyElementRootGuard":"./lib/lazy-elements/lazy-elements.module","LazyElementsModule":"./lib/lazy-elements/lazy-elements.module","LazyElementModuleOptions":"./lib/lazy-elements/lazy-elements.module","LazyElementModuleRootOptions":"./lib/lazy-elements/lazy-elements.module","LazyElementRootOptions":"./lib/lazy-elements/lazy-elements.module","ɵd":"./lib/lazy-elements/lazy-element/lazy-element.directive","ɵe":"./lib/lazy-elements/lazy-elements-loader.service","ɵf":"./lib/lazy-elements/lazy-elements-loader.service","ɵg":"./lib/lazy-elements/lazy-element-dynamic/lazy-element-dynamic.directive"},"importAs":"@angular-extensions/elements"} |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common')) : | ||
typeof define === 'function' && define.amd ? define('@angular-extensions/elements', ['exports', '@angular/core', '@angular/common'], factory) : | ||
(global = global || self, factory((global['angular-extensions'] = global['angular-extensions'] || {}, global['angular-extensions'].elements = {}), global.ng.core, global.ng.common)); | ||
}(this, function (exports, core, common) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/common'), require('@angular/core')) : | ||
typeof define === 'function' && define.amd ? define('@angular-extensions/elements', ['exports', '@angular/common', '@angular/core'], factory) : | ||
(factory((global['angular-extensions'] = global['angular-extensions'] || {}, global['angular-extensions'].elements = {}),global.ng.common,global.ng.core)); | ||
}(this, (function (exports,common,i0) { 'use strict'; | ||
@@ -12,10 +12,104 @@ /** | ||
/** @type {?} */ | ||
var LAZY_ELEMENT_CONFIGS = new i0.InjectionToken('LAZY_ELEMENT_CONFIGS'); | ||
/** @type {?} */ | ||
var LAZY_ELEMENT_ROOT_OPTIONS = new i0.InjectionToken('LAZY_ELEMENT_ROOT_OPTIONS'); | ||
/** @type {?} */ | ||
var LAZY_ELEMENT_ROOT_GUARD = new i0.InjectionToken('LAZY_ELEMENT_ROOT_GUARD'); | ||
/** @type {?} */ | ||
var LAZY_ELEMENTS_REGISTRY = new i0.InjectionToken('Lazu elements registry', { | ||
providedIn: 'root', | ||
factory: ( /** | ||
* @return {?} | ||
*/function () { return new Map(); }) | ||
}); | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** @type {?} */ | ||
var LOG_PREFIX = '@angular-extensions/elements'; | ||
var LazyElementsLoaderService = /** @class */ (function () { | ||
function LazyElementsLoaderService() { | ||
this.registry = new Map(); | ||
function LazyElementsLoaderService(registry, options) { | ||
this.registry = registry; | ||
this.options = options; | ||
this.configs = []; | ||
if (!options) { | ||
this.options = {}; | ||
} | ||
} | ||
/** | ||
* @param {?} newConfigs | ||
* @return {?} | ||
*/ | ||
LazyElementsLoaderService.prototype.addConfigs = /** | ||
* @param {?} newConfigs | ||
* @return {?} | ||
*/ | ||
function (newConfigs) { | ||
var _this = this; | ||
newConfigs.forEach(( /** | ||
* @param {?} newConfig | ||
* @return {?} | ||
*/function (newConfig) { | ||
/** @type {?} */ | ||
var existingConfig = _this.getElementConfig(newConfig.tag); | ||
if (existingConfig) { | ||
console.warn(LOG_PREFIX + " - ElementConfig for tag '" + newConfig.tag + "' was previously added, it will not be added multiple times, continue..."); | ||
} | ||
else { | ||
_this.configs.push(newConfig); | ||
/** @type {?} */ | ||
var shouldPreload = newConfig.preload !== undefined | ||
? newConfig.preload | ||
: _this.options.preload; | ||
if (shouldPreload) { | ||
_this.loadElement(newConfig.url, newConfig.tag, newConfig.isModule); | ||
} | ||
} | ||
})); | ||
}; | ||
/** | ||
* @param {?} tag | ||
* @return {?} | ||
*/ | ||
LazyElementsLoaderService.prototype.getElementConfig = /** | ||
* @param {?} tag | ||
* @return {?} | ||
*/ | ||
function (tag) { | ||
return this.configs.find(( /** | ||
* @param {?} config | ||
* @return {?} | ||
*/function (config) { return config.tag === tag; })); | ||
}; | ||
/** | ||
* @param {?=} tags | ||
* @return {?} | ||
*/ | ||
LazyElementsLoaderService.prototype.preload = /** | ||
* @param {?=} tags | ||
* @return {?} | ||
*/ | ||
function (tags) { | ||
var _this = this; | ||
/** @type {?} */ | ||
var configs = this.configs; | ||
if (tags) { | ||
configs = this.configs.filter(( /** | ||
* @param {?} config | ||
* @return {?} | ||
*/function (config) { return tags.includes(config.tag); })); | ||
} | ||
configs.forEach(( /** | ||
* @param {?} config | ||
* @return {?} | ||
*/function (config) { | ||
return _this.loadElement(config.url, config.tag, config.isModule); | ||
})); | ||
}; | ||
/** | ||
* @param {?} url | ||
* @param {?} tag | ||
* @param {?=} isModule | ||
* @return {?} | ||
@@ -26,22 +120,38 @@ */ | ||
* @param {?} tag | ||
* @param {?=} isModule | ||
* @return {?} | ||
*/ | ||
function (url, tag) { | ||
if (!url) { | ||
throw new Error(LOG_PREFIX + " - url for <" + tag + "> not found"); | ||
} | ||
if (!tag) { | ||
throw new Error(LOG_PREFIX + " - tag for '" + url + "' not found, the *axLazyElement has to be used on HTML element"); | ||
} | ||
if (!this.hasElement(url)) { | ||
function (url, tag, isModule) { | ||
/** @type {?} */ | ||
var notifier = this.addElement(url); | ||
/** @type {?} */ | ||
var script = (/** @type {?} */ (document.createElement('script'))); | ||
script.src = url; | ||
script.onload = notifier; | ||
document.body.appendChild(script); | ||
} | ||
return this.registry.get(this.stripUrlProtocol(url)); | ||
}; | ||
var config = this.getElementConfig(tag); | ||
if (!url) { | ||
if (!config) { | ||
throw new Error(LOG_PREFIX + " - url for <" + tag + "> not found"); | ||
} | ||
url = config.url; | ||
} | ||
if (isModule === undefined) { | ||
isModule = | ||
config && config.isModule !== undefined | ||
? config.isModule | ||
: this.options.isModule; | ||
} | ||
if (!tag) { | ||
throw new Error(LOG_PREFIX + " - tag for '" + url + "' not found, the *axLazyElement has to be used on HTML element"); | ||
} | ||
if (!this.hasElement(url)) { | ||
/** @type {?} */ | ||
var notifier = this.addElement(url); | ||
/** @type {?} */ | ||
var script = ( /** @type {?} */(document.createElement('script'))); | ||
if (isModule) { | ||
script.type = 'module'; | ||
} | ||
script.src = url; | ||
script.onload = notifier.resolve; | ||
script.onerror = notifier.reject; | ||
document.body.appendChild(script); | ||
} | ||
return this.registry.get(this.stripUrlProtocol(url)); | ||
}; | ||
/** | ||
@@ -57,12 +167,12 @@ * @private | ||
*/ | ||
function (url) { | ||
/** @type {?} */ | ||
var notifier; | ||
this.registry.set(this.stripUrlProtocol(url), new Promise((/** | ||
* @param {?} resolve | ||
* @return {?} | ||
*/ | ||
function (resolve) { return (notifier = resolve); }))); | ||
return notifier; | ||
}; | ||
function (url) { | ||
/** @type {?} */ | ||
var notifier; | ||
this.registry.set(this.stripUrlProtocol(url), new Promise(( /** | ||
* @param {?} resolve | ||
* @param {?} reject | ||
* @return {?} | ||
*/function (resolve, reject) { return (notifier = { resolve: resolve, reject: reject }); }))); | ||
return notifier; | ||
}; | ||
/** | ||
@@ -78,5 +188,5 @@ * @private | ||
*/ | ||
function (url) { | ||
return this.registry.has(this.stripUrlProtocol(url)); | ||
}; | ||
function (url) { | ||
return this.registry.has(this.stripUrlProtocol(url)); | ||
}; | ||
/** | ||
@@ -92,13 +202,17 @@ * @private | ||
*/ | ||
function (url) { | ||
return url.replace(/https?:\/\//, ''); | ||
}; | ||
function (url) { | ||
return url.replace(/https?:\/\//, ''); | ||
}; | ||
LazyElementsLoaderService.decorators = [ | ||
{ type: core.Injectable, args: [{ | ||
{ type: i0.Injectable, args: [{ | ||
providedIn: 'root' | ||
},] } | ||
]; | ||
/** @nocollapse */ | ||
LazyElementsLoaderService.ctorParameters = function () { return []; }; | ||
/** @nocollapse */ LazyElementsLoaderService.ngInjectableDef = core.ɵɵdefineInjectable({ factory: function LazyElementsLoaderService_Factory() { return new LazyElementsLoaderService(); }, token: LazyElementsLoaderService, providedIn: "root" }); | ||
LazyElementsLoaderService.ctorParameters = function () { | ||
return [ | ||
{ type: undefined, decorators: [{ type: i0.Inject, args: [LAZY_ELEMENTS_REGISTRY,] }] }, | ||
{ type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [LAZY_ELEMENT_ROOT_OPTIONS,] }] } | ||
]; | ||
}; | ||
/** @nocollapse */ LazyElementsLoaderService.ngInjectableDef = i0.defineInjectable({ factory: function LazyElementsLoaderService_Factory() { return new LazyElementsLoaderService(i0.inject(LAZY_ELEMENTS_REGISTRY), i0.inject(LAZY_ELEMENT_ROOT_OPTIONS, 8)); }, token: LazyElementsLoaderService, providedIn: "root" }); | ||
return LazyElementsLoaderService; | ||
@@ -111,7 +225,11 @@ }()); | ||
*/ | ||
/** @type {?} */ | ||
var LOG_PREFIX$1 = '@angular-extensions/elements'; | ||
var LazyElementDirective = /** @class */ (function () { | ||
function LazyElementDirective(vcr, template, elementsLoaderService) { | ||
function LazyElementDirective(vcr, template, elementsLoaderService, cfr, cdr) { | ||
this.vcr = vcr; | ||
this.template = template; | ||
this.elementsLoaderService = elementsLoaderService; | ||
this.cfr = cfr; | ||
this.cdr = cdr; | ||
} | ||
@@ -124,31 +242,74 @@ /** | ||
*/ | ||
function () { | ||
var _this = this; | ||
/** @type {?} */ | ||
var elementTag = ((/** @type {?} */ (this.template)))._def.element.template.nodes[0].element.name; | ||
if (this.loadingTemplateRef) { | ||
this.vcr.createEmbeddedView(this.loadingTemplateRef); | ||
} | ||
this.elementsLoaderService.loadElement(this.url, elementTag).then((/** | ||
function () { | ||
var _this = this; | ||
/** @type {?} */ | ||
var tpl = ( /** @type {?} */(this.template)); | ||
/** @type {?} */ | ||
var elementTag = tpl._declarationTContainer | ||
? tpl._declarationTContainer.tagName | ||
: tpl._def.element.template.nodes[0].element.name; | ||
/** @type {?} */ | ||
var elementConfig = this.elementsLoaderService.getElementConfig(elementTag) || | ||
(( /** @type {?} */({}))); | ||
/** @type {?} */ | ||
var options = this.elementsLoaderService.options; | ||
/** @type {?} */ | ||
var loadingComponent = elementConfig.loadingComponent || options.loadingComponent; | ||
if (this.loadingTemplateRef) { | ||
this.vcr.createEmbeddedView(this.loadingTemplateRef); | ||
} | ||
else if (loadingComponent) { | ||
/** @type {?} */ | ||
var factory = this.cfr.resolveComponentFactory(loadingComponent); | ||
this.vcr.createComponent(factory); | ||
} | ||
this.elementsLoaderService | ||
.loadElement(this.url, elementTag, this.isModule) | ||
.then(( /** | ||
* @return {?} | ||
*/ | ||
function () { | ||
_this.vcr.clear(); | ||
_this.vcr.createEmbeddedView(_this.template); | ||
})); | ||
}; | ||
*/function () { | ||
_this.vcr.clear(); | ||
_this.vcr.createEmbeddedView(_this.template); | ||
_this.cdr.markForCheck(); | ||
})) | ||
.catch(( /** | ||
* @return {?} | ||
*/function () { | ||
_this.vcr.clear(); | ||
/** @type {?} */ | ||
var errorComponent = elementConfig.errorComponent || options.errorComponent; | ||
if (_this.errorTemplateRef) { | ||
_this.vcr.createEmbeddedView(_this.errorTemplateRef); | ||
_this.cdr.markForCheck(); | ||
} | ||
else if (errorComponent) { | ||
/** @type {?} */ | ||
var factory = _this.cfr.resolveComponentFactory(errorComponent); | ||
_this.vcr.createComponent(factory); | ||
_this.cdr.markForCheck(); | ||
} | ||
else { | ||
console.error(LOG_PREFIX$1 + " - Loading of element <" + elementTag + "> failed, please provide <ng-template #error>Loading failed...</ng-template> and reference it in *axLazyElement=\"errorTemplate: error\" to display customized error message in place of element"); | ||
} | ||
})); | ||
}; | ||
LazyElementDirective.decorators = [ | ||
{ type: core.Directive, args: [{ | ||
{ type: i0.Directive, args: [{ | ||
selector: '[axLazyElement]' | ||
},] } | ||
]; | ||
/** @nocollapse */ | ||
LazyElementDirective.ctorParameters = function () { return [ | ||
{ type: core.ViewContainerRef }, | ||
{ type: core.TemplateRef }, | ||
{ type: LazyElementsLoaderService } | ||
]; }; | ||
LazyElementDirective.ctorParameters = function () { | ||
return [ | ||
{ type: i0.ViewContainerRef }, | ||
{ type: i0.TemplateRef }, | ||
{ type: LazyElementsLoaderService }, | ||
{ type: i0.ComponentFactoryResolver }, | ||
{ type: i0.ChangeDetectorRef } | ||
]; | ||
}; | ||
LazyElementDirective.propDecorators = { | ||
url: [{ type: core.Input, args: ['axLazyElement',] }], | ||
loadingTemplateRef: [{ type: core.Input, args: ['axLazyElementLoading',] }] | ||
url: [{ type: i0.Input, args: ['axLazyElement',] }], | ||
loadingTemplateRef: [{ type: i0.Input, args: ['axLazyElementLoadingTemplate',] }], | ||
errorTemplateRef: [{ type: i0.Input, args: ['axLazyElementErrorTemplate',] }], | ||
isModule: [{ type: i0.Input, args: ['axLazyElementModule',] }] | ||
}; | ||
@@ -162,22 +323,224 @@ return LazyElementDirective; | ||
*/ | ||
/** @type {?} */ | ||
var LOG_PREFIX$2 = '@angular-extensions/elements'; | ||
var LazyElementDynamicDirective = /** @class */ (function () { | ||
function LazyElementDynamicDirective(vcr, template, elementsLoaderService, cfr, cdr) { | ||
this.vcr = vcr; | ||
this.template = template; | ||
this.elementsLoaderService = elementsLoaderService; | ||
this.cfr = cfr; | ||
this.cdr = cdr; | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
LazyElementDynamicDirective.prototype.ngOnInit = /** | ||
* @return {?} | ||
*/ | ||
function () { | ||
var _this = this; | ||
if (!this.tag || this.tag.length === 0 || !this.tag.includes('-')) { | ||
throw new Error(LOG_PREFIX$2 + " - Valid tag has to be specified when using *axLazyElementDynamic directive (use *axLazyElementDynamic=\"'some-tag'\"), got: \"" + this.tag + "\""); | ||
} | ||
/** @type {?} */ | ||
var elementConfig = this.elementsLoaderService.getElementConfig(this.tag) || | ||
(( /** @type {?} */({}))); | ||
/** @type {?} */ | ||
var options = this.elementsLoaderService.options; | ||
/** @type {?} */ | ||
var loadingComponent = elementConfig.loadingComponent || options.loadingComponent; | ||
if (this.loadingTemplateRef) { | ||
this.vcr.createEmbeddedView(this.loadingTemplateRef); | ||
} | ||
else if (loadingComponent) { | ||
/** @type {?} */ | ||
var factory = this.cfr.resolveComponentFactory(loadingComponent); | ||
this.vcr.createComponent(factory); | ||
} | ||
this.elementsLoaderService | ||
.loadElement(this.url, this.tag, this.isModule) | ||
.then(( /** | ||
* @return {?} | ||
*/function () { | ||
if ((( /** @type {?} */(_this.template)))._declarationTContainer) { | ||
// (this.template as any)._declarationTContainer.tagName = this.tag; | ||
throw new Error('The *axLazyElementDynamic directive is currently does NOT support Angular Ivy, please use standard *axLazyElement directive instead!'); | ||
} | ||
else { | ||
(( /** @type {?} */(_this | ||
.template)))._def.element.template.nodes[0].element.name = _this.tag; | ||
} | ||
_this.vcr.clear(); | ||
_this.vcr.createEmbeddedView(_this.template); | ||
_this.cdr.markForCheck(); | ||
})) | ||
.catch(( /** | ||
* @param {?} error | ||
* @return {?} | ||
*/function (error) { | ||
/** @type {?} */ | ||
var errorComponent = elementConfig.errorComponent || options.errorComponent; | ||
_this.vcr.clear(); | ||
if (_this.errorTemplateRef) { | ||
_this.vcr.createEmbeddedView(_this.errorTemplateRef); | ||
_this.cdr.markForCheck(); | ||
} | ||
else if (errorComponent) { | ||
/** @type {?} */ | ||
var factory = _this.cfr.resolveComponentFactory(errorComponent); | ||
_this.vcr.createComponent(factory); | ||
_this.cdr.markForCheck(); | ||
} | ||
else { | ||
console.error(LOG_PREFIX$2 + " - Loading of element <" + _this.tag + "> failed, please provide <ng-template #error>Loading failed...</ng-template> and reference it in *axLazyElementDynamic=\"errorTemplate: error\" to display customized error message in place of element\n\n", error); | ||
} | ||
})); | ||
}; | ||
LazyElementDynamicDirective.decorators = [ | ||
{ type: i0.Directive, args: [{ | ||
selector: '[axLazyElementDynamic]' | ||
},] } | ||
]; | ||
LazyElementDynamicDirective.ctorParameters = function () { | ||
return [ | ||
{ type: i0.ViewContainerRef }, | ||
{ type: i0.TemplateRef }, | ||
{ type: LazyElementsLoaderService }, | ||
{ type: i0.ComponentFactoryResolver }, | ||
{ type: i0.ChangeDetectorRef } | ||
]; | ||
}; | ||
LazyElementDynamicDirective.propDecorators = { | ||
tag: [{ type: i0.Input, args: ['axLazyElementDynamic',] }], | ||
url: [{ type: i0.Input, args: ['axLazyElementDynamicUrl',] }], | ||
loadingTemplateRef: [{ type: i0.Input, args: ['axLazyElementDynamicLoadingTemplate',] }], | ||
errorTemplateRef: [{ type: i0.Input, args: ['axLazyElementDynamicErrorTemplate',] }], | ||
isModule: [{ type: i0.Input, args: ['axLazyElementDynamicModule',] }] | ||
}; | ||
return LazyElementDynamicDirective; | ||
}()); | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
function createLazyElementRootGuard(options) { | ||
if (options) { | ||
throw new TypeError("LazyElementsModule.forRoot() called twice. Feature modules should use LazyElementsModule.forFeature() instead."); | ||
} | ||
return 'guarded'; | ||
} | ||
var LazyElementsModule = /** @class */ (function () { | ||
function LazyElementsModule() { | ||
function LazyElementsModule(lazyElementsLoaderService, elementConfigsMultiProvider, guard) { | ||
if (elementConfigsMultiProvider && elementConfigsMultiProvider.length) { | ||
/** @type {?} */ | ||
var lastAddedConfigs = elementConfigsMultiProvider[elementConfigsMultiProvider.length - 1]; | ||
lazyElementsLoaderService.addConfigs(lastAddedConfigs); | ||
} | ||
} | ||
/** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
LazyElementsModule.forRoot = /** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
function (options) { | ||
return { | ||
ngModule: LazyElementsModule, | ||
providers: [ | ||
{ | ||
provide: LAZY_ELEMENT_CONFIGS, | ||
useValue: options && options.elementConfigs ? options.elementConfigs : [], | ||
multi: true | ||
}, | ||
{ | ||
provide: LAZY_ELEMENT_ROOT_OPTIONS, | ||
useValue: options.rootOptions ? options.rootOptions : {} | ||
}, | ||
{ | ||
provide: i0.ANALYZE_FOR_ENTRY_COMPONENTS, | ||
useValue: options, | ||
multi: true | ||
}, | ||
{ | ||
provide: LAZY_ELEMENT_ROOT_GUARD, | ||
useFactory: createLazyElementRootGuard, | ||
deps: [[LAZY_ELEMENT_CONFIGS, new i0.Optional(), new i0.SkipSelf()]] | ||
} | ||
] | ||
}; | ||
}; | ||
/** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
LazyElementsModule.forFeature = /** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
function (options) { | ||
return { | ||
ngModule: LazyElementsModule, | ||
providers: [ | ||
{ | ||
provide: LAZY_ELEMENT_CONFIGS, | ||
useValue: options && options.elementConfigs ? options.elementConfigs : [], | ||
multi: true | ||
}, | ||
{ | ||
provide: i0.ANALYZE_FOR_ENTRY_COMPONENTS, | ||
useValue: options && options.elementConfigs, | ||
multi: true | ||
} | ||
] | ||
}; | ||
}; | ||
LazyElementsModule.decorators = [ | ||
{ type: core.NgModule, args: [{ | ||
declarations: [LazyElementDirective], | ||
{ type: i0.NgModule, args: [{ | ||
declarations: [LazyElementDirective, LazyElementDynamicDirective], | ||
imports: [common.CommonModule], | ||
exports: [LazyElementDirective] | ||
exports: [LazyElementDirective, LazyElementDynamicDirective], | ||
providers: [] | ||
},] } | ||
]; | ||
LazyElementsModule.ctorParameters = function () { | ||
return [ | ||
{ type: LazyElementsLoaderService }, | ||
{ type: Array, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [LAZY_ELEMENT_CONFIGS,] }] }, | ||
{ type: undefined, decorators: [{ type: i0.Optional }, { type: i0.Inject, args: [LAZY_ELEMENT_ROOT_GUARD,] }] } | ||
]; | ||
}; | ||
return LazyElementsModule; | ||
}()); | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
exports.LAZY_ELEMENTS_REGISTRY = LAZY_ELEMENTS_REGISTRY; | ||
exports.createLazyElementRootGuard = createLazyElementRootGuard; | ||
exports.LazyElementsModule = LazyElementsModule; | ||
exports.ɵa = LazyElementDirective; | ||
exports.ɵb = LazyElementsLoaderService; | ||
exports.ɵg = LazyElementDynamicDirective; | ||
exports.ɵd = LazyElementDirective; | ||
exports.ɵf = LazyElementsLoaderService; | ||
exports.ɵa = LAZY_ELEMENT_CONFIGS; | ||
exports.ɵc = LAZY_ELEMENT_ROOT_GUARD; | ||
exports.ɵb = LAZY_ELEMENT_ROOT_OPTIONS; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
})); | ||
//# sourceMappingURL=angular-extensions-elements.umd.js.map | ||
}))); | ||
//# sourceMappingURL=angular-extensions-elements.umd.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common")):"function"==typeof define&&define.amd?define("@angular-extensions/elements",["exports","@angular/core","@angular/common"],t):t(((e=e||self)["angular-extensions"]=e["angular-extensions"]||{},e["angular-extensions"].elements={}),e.ng.core,e.ng.common)}(this,function(e,t,n){"use strict";var r=function(){function e(){this.registry=new Map}return e.prototype.loadElement=function(e,t){if(!e)throw new Error("@angular-extensions/elements - url for <"+t+"> not found");if(!t)throw new Error("@angular-extensions/elements - tag for '"+e+"' not found, the *axLazyElement has to be used on HTML element");if(!this.hasElement(e)){var n=this.addElement(e),r=document.createElement("script");r.src=e,r.onload=n,document.body.appendChild(r)}return this.registry.get(this.stripUrlProtocol(e))},e.prototype.addElement=function(e){var t;return this.registry.set(this.stripUrlProtocol(e),new Promise(function(e){return t=e})),t},e.prototype.hasElement=function(e){return this.registry.has(this.stripUrlProtocol(e))},e.prototype.stripUrlProtocol=function(e){return e.replace(/https?:\/\//,"")},e.decorators=[{type:t.Injectable,args:[{providedIn:"root"}]}],e.ctorParameters=function(){return[]},e.ngInjectableDef=t.ɵɵdefineInjectable({factory:function(){return new e},token:e,providedIn:"root"}),e}(),o=function(){function e(e,t,n){this.vcr=e,this.template=t,this.elementsLoaderService=n}return e.prototype.ngOnInit=function(){var e=this,t=this.template._def.element.template.nodes[0].element.name;this.loadingTemplateRef&&this.vcr.createEmbeddedView(this.loadingTemplateRef),this.elementsLoaderService.loadElement(this.url,t).then(function(){e.vcr.clear(),e.vcr.createEmbeddedView(e.template)})},e.decorators=[{type:t.Directive,args:[{selector:"[axLazyElement]"}]}],e.ctorParameters=function(){return[{type:t.ViewContainerRef},{type:t.TemplateRef},{type:r}]},e.propDecorators={url:[{type:t.Input,args:["axLazyElement"]}],loadingTemplateRef:[{type:t.Input,args:["axLazyElementLoading"]}]},e}(),a=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{declarations:[o],imports:[n.CommonModule],exports:[o]}]}],e}();e.LazyElementsModule=a,e.ɵa=o,e.ɵb=r,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/common"),require("@angular/core")):"function"==typeof define&&define.amd?define("@angular-extensions/elements",["exports","@angular/common","@angular/core"],t):t((e["angular-extensions"]=e["angular-extensions"]||{},e["angular-extensions"].elements={}),e.ng.common,e.ng.core)}(this,function(e,t,r){"use strict";var n=new r.InjectionToken("LAZY_ELEMENT_CONFIGS"),o=new r.InjectionToken("LAZY_ELEMENT_ROOT_OPTIONS"),a=new r.InjectionToken("LAZY_ELEMENT_ROOT_GUARD"),i=new r.InjectionToken("Lazu elements registry",{providedIn:"root",factory:function(){return new Map}}),l="@angular-extensions/elements",s=(c.prototype.addConfigs=function(e){var t=this;e.forEach(function(e){t.getElementConfig(e.tag)?console.warn(l+" - ElementConfig for tag '"+e.tag+"' was previously added, it will not be added multiple times, continue..."):(t.configs.push(e),(e.preload!==undefined?e.preload:t.options.preload)&&t.loadElement(e.url,e.tag,e.isModule))})},c.prototype.getElementConfig=function(t){return this.configs.find(function(e){return e.tag===t})},c.prototype.preload=function(t){var r=this,e=this.configs;t&&(e=this.configs.filter(function(e){return t.includes(e.tag)})),e.forEach(function(e){return r.loadElement(e.url,e.tag,e.isModule)})},c.prototype.loadElement=function(e,t,r){var n=this.getElementConfig(t);if(!e){if(!n)throw new Error(l+" - url for <"+t+"> not found");e=n.url}if(r===undefined&&(r=n&&n.isModule!==undefined?n.isModule:this.options.isModule),!t)throw new Error(l+" - tag for '"+e+"' not found, the *axLazyElement has to be used on HTML element");if(!this.hasElement(e)){var o=this.addElement(e),a=document.createElement("script");r&&(a.type="module"),a.src=e,a.onload=o.resolve,a.onerror=o.reject,document.body.appendChild(a)}return this.registry.get(this.stripUrlProtocol(e))},c.prototype.addElement=function(e){var r;return this.registry.set(this.stripUrlProtocol(e),new Promise(function(e,t){return r={resolve:e,reject:t}})),r},c.prototype.hasElement=function(e){return this.registry.has(this.stripUrlProtocol(e))},c.prototype.stripUrlProtocol=function(e){return e.replace(/https?:\/\//,"")},c.decorators=[{type:r.Injectable,args:[{providedIn:"root"}]}],c.ctorParameters=function(){return[{type:undefined,decorators:[{type:r.Inject,args:[i]}]},{type:undefined,decorators:[{type:r.Optional},{type:r.Inject,args:[o]}]}]},c.ngInjectableDef=r.defineInjectable({factory:function(){return new c(r.inject(i),r.inject(o,8))},token:c,providedIn:"root"}),c);function c(e,t){this.registry=e,this.options=t,this.configs=[],t||(this.options={})}var d=(p.prototype.ngOnInit=function(){var r=this,e=this.template,n=e._declarationTContainer?e._declarationTContainer.tagName:e._def.element.template.nodes[0].element.name,o=this.elementsLoaderService.getElementConfig(n)||{},a=this.elementsLoaderService.options,t=o.loadingComponent||a.loadingComponent;if(this.loadingTemplateRef)this.vcr.createEmbeddedView(this.loadingTemplateRef);else if(t){var i=this.cfr.resolveComponentFactory(t);this.vcr.createComponent(i)}this.elementsLoaderService.loadElement(this.url,n,this.isModule).then(function(){r.vcr.clear(),r.vcr.createEmbeddedView(r.template),r.cdr.markForCheck()})["catch"](function(){r.vcr.clear();var e=o.errorComponent||a.errorComponent;if(r.errorTemplateRef)r.vcr.createEmbeddedView(r.errorTemplateRef),r.cdr.markForCheck();else if(e){var t=r.cfr.resolveComponentFactory(e);r.vcr.createComponent(t),r.cdr.markForCheck()}else console.error("@angular-extensions/elements - Loading of element <"+n+'> failed, please provide <ng-template #error>Loading failed...</ng-template> and reference it in *axLazyElement="errorTemplate: error" to display customized error message in place of element')})},p.decorators=[{type:r.Directive,args:[{selector:"[axLazyElement]"}]}],p.ctorParameters=function(){return[{type:r.ViewContainerRef},{type:r.TemplateRef},{type:s},{type:r.ComponentFactoryResolver},{type:r.ChangeDetectorRef}]},p.propDecorators={url:[{type:r.Input,args:["axLazyElement"]}],loadingTemplateRef:[{type:r.Input,args:["axLazyElementLoadingTemplate"]}],errorTemplateRef:[{type:r.Input,args:["axLazyElementErrorTemplate"]}],isModule:[{type:r.Input,args:["axLazyElementModule"]}]},p);function p(e,t,r,n,o){this.vcr=e,this.template=t,this.elementsLoaderService=r,this.cfr=n,this.cdr=o}var m="@angular-extensions/elements",u=(f.prototype.ngOnInit=function(){var n=this;if(!this.tag||0===this.tag.length||!this.tag.includes("-"))throw new Error(m+' - Valid tag has to be specified when using *axLazyElementDynamic directive (use *axLazyElementDynamic="\'some-tag\'"), got: "'+this.tag+'"');var o=this.elementsLoaderService.getElementConfig(this.tag)||{},a=this.elementsLoaderService.options,e=o.loadingComponent||a.loadingComponent;if(this.loadingTemplateRef)this.vcr.createEmbeddedView(this.loadingTemplateRef);else if(e){var t=this.cfr.resolveComponentFactory(e);this.vcr.createComponent(t)}this.elementsLoaderService.loadElement(this.url,this.tag,this.isModule).then(function(){if(n.template._declarationTContainer)throw new Error("The *axLazyElementDynamic directive is currently does NOT support Angular Ivy, please use standard *axLazyElement directive instead!");n.template._def.element.template.nodes[0].element.name=n.tag,n.vcr.clear(),n.vcr.createEmbeddedView(n.template),n.cdr.markForCheck()})["catch"](function(e){var t=o.errorComponent||a.errorComponent;if(n.vcr.clear(),n.errorTemplateRef)n.vcr.createEmbeddedView(n.errorTemplateRef),n.cdr.markForCheck();else if(t){var r=n.cfr.resolveComponentFactory(t);n.vcr.createComponent(r),n.cdr.markForCheck()}else console.error(m+" - Loading of element <"+n.tag+'> failed, please provide <ng-template #error>Loading failed...</ng-template> and reference it in *axLazyElementDynamic="errorTemplate: error" to display customized error message in place of element\n\n',e)})},f.decorators=[{type:r.Directive,args:[{selector:"[axLazyElementDynamic]"}]}],f.ctorParameters=function(){return[{type:r.ViewContainerRef},{type:r.TemplateRef},{type:s},{type:r.ComponentFactoryResolver},{type:r.ChangeDetectorRef}]},f.propDecorators={tag:[{type:r.Input,args:["axLazyElementDynamic"]}],url:[{type:r.Input,args:["axLazyElementDynamicUrl"]}],loadingTemplateRef:[{type:r.Input,args:["axLazyElementDynamicLoadingTemplate"]}],errorTemplateRef:[{type:r.Input,args:["axLazyElementDynamicErrorTemplate"]}],isModule:[{type:r.Input,args:["axLazyElementDynamicModule"]}]},f);function f(e,t,r,n,o){this.vcr=e,this.template=t,this.elementsLoaderService=r,this.cfr=n,this.cdr=o}function g(e){if(e)throw new TypeError("LazyElementsModule.forRoot() called twice. Feature modules should use LazyElementsModule.forFeature() instead.");return"guarded"}var y=(h.forRoot=function(e){return{ngModule:h,providers:[{provide:n,useValue:e&&e.elementConfigs?e.elementConfigs:[],multi:!0},{provide:o,useValue:e.rootOptions?e.rootOptions:{}},{provide:r.ANALYZE_FOR_ENTRY_COMPONENTS,useValue:e,multi:!0},{provide:a,useFactory:g,deps:[[n,new r.Optional,new r.SkipSelf]]}]}},h.forFeature=function(e){return{ngModule:h,providers:[{provide:n,useValue:e&&e.elementConfigs?e.elementConfigs:[],multi:!0},{provide:r.ANALYZE_FOR_ENTRY_COMPONENTS,useValue:e&&e.elementConfigs,multi:!0}]}},h.decorators=[{type:r.NgModule,args:[{declarations:[d,u],imports:[t.CommonModule],exports:[d,u],providers:[]}]}],h.ctorParameters=function(){return[{type:s},{type:Array,decorators:[{type:r.Optional},{type:r.Inject,args:[n]}]},{type:undefined,decorators:[{type:r.Optional},{type:r.Inject,args:[a]}]}]},h);function h(e,t,r){if(t&&t.length){var n=t[t.length-1];e.addConfigs(n)}}e.LAZY_ELEMENTS_REGISTRY=i,e.createLazyElementRootGuard=g,e.LazyElementsModule=y,e.ɵg=u,e.ɵd=d,e.ɵf=s,e.ɵa=n,e.ɵc=a,e.ɵb=o,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=angular-extensions-elements.umd.min.js.map |
@@ -8,5 +8,7 @@ /** | ||
*/ | ||
export { LazyElementsModule } from './public-api'; | ||
export { LazyElementDirective as ɵa } from './lib/lazy-elements/lazy-element/lazy-element.directive'; | ||
export { LazyElementsLoaderService as ɵb } from './lib/lazy-elements/lazy-elements-loader.service'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5ndWxhci1leHRlbnNpb25zLWVsZW1lbnRzLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQGFuZ3VsYXItZXh0ZW5zaW9ucy9lbGVtZW50cy8iLCJzb3VyY2VzIjpbImFuZ3VsYXItZXh0ZW5zaW9ucy1lbGVtZW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsbUNBQWMsY0FBYyxDQUFDO0FBRTdCLE9BQU8sRUFBQyxvQkFBb0IsSUFBSSxFQUFFLEVBQUMsTUFBTSx5REFBeUQsQ0FBQztBQUNuRyxPQUFPLEVBQUMseUJBQXlCLElBQUksRUFBRSxFQUFDLE1BQU0sa0RBQWtELENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vcHVibGljLWFwaSc7XG5cbmV4cG9ydCB7TGF6eUVsZW1lbnREaXJlY3RpdmUgYXMgybVhfSBmcm9tICcuL2xpYi9sYXp5LWVsZW1lbnRzL2xhenktZWxlbWVudC9sYXp5LWVsZW1lbnQuZGlyZWN0aXZlJztcbmV4cG9ydCB7TGF6eUVsZW1lbnRzTG9hZGVyU2VydmljZSBhcyDJtWJ9IGZyb20gJy4vbGliL2xhenktZWxlbWVudHMvbGF6eS1lbGVtZW50cy1sb2FkZXIuc2VydmljZSc7Il19 | ||
export { LAZY_ELEMENTS_REGISTRY, createLazyElementRootGuard, LazyElementsModule } from './public-api'; | ||
export { LazyElementDynamicDirective as ɵg } from './lib/lazy-elements/lazy-element-dynamic/lazy-element-dynamic.directive'; | ||
export { LazyElementDirective as ɵd } from './lib/lazy-elements/lazy-element/lazy-element.directive'; | ||
export { LazyElementsLoaderService as ɵf } from './lib/lazy-elements/lazy-elements-loader.service'; | ||
export { LAZY_ELEMENT_CONFIGS as ɵa, LAZY_ELEMENT_ROOT_GUARD as ɵc, LAZY_ELEMENT_ROOT_OPTIONS as ɵb } from './lib/lazy-elements/lazy-elements.tokens'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5ndWxhci1leHRlbnNpb25zLWVsZW1lbnRzLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQGFuZ3VsYXItZXh0ZW5zaW9ucy9lbGVtZW50cy8iLCJzb3VyY2VzIjpbImFuZ3VsYXItZXh0ZW5zaW9ucy1lbGVtZW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsdUZBQWMsY0FBYyxDQUFDO0FBRTdCLE9BQU8sRUFBQywyQkFBMkIsSUFBSSxFQUFFLEVBQUMsTUFBTSx5RUFBeUUsQ0FBQztBQUMxSCxPQUFPLEVBQUMsb0JBQW9CLElBQUksRUFBRSxFQUFDLE1BQU0seURBQXlELENBQUM7QUFDbkcsT0FBTyxFQUFxQix5QkFBeUIsSUFBSSxFQUFFLEVBQUMsTUFBTSxrREFBa0QsQ0FBQztBQUNySCxPQUFPLEVBQUMsb0JBQW9CLElBQUksRUFBRSxFQUFDLHVCQUF1QixJQUFJLEVBQUUsRUFBQyx5QkFBeUIsSUFBSSxFQUFFLEVBQUMsTUFBTSwwQ0FBMEMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWMtYXBpJztcblxuZXhwb3J0IHtMYXp5RWxlbWVudER5bmFtaWNEaXJlY3RpdmUgYXMgybVnfSBmcm9tICcuL2xpYi9sYXp5LWVsZW1lbnRzL2xhenktZWxlbWVudC1keW5hbWljL2xhenktZWxlbWVudC1keW5hbWljLmRpcmVjdGl2ZSc7XG5leHBvcnQge0xhenlFbGVtZW50RGlyZWN0aXZlIGFzIMm1ZH0gZnJvbSAnLi9saWIvbGF6eS1lbGVtZW50cy9sYXp5LWVsZW1lbnQvbGF6eS1lbGVtZW50LmRpcmVjdGl2ZSc7XG5leHBvcnQge0VsZW1lbnRDb25maWcgYXMgybVlLExhenlFbGVtZW50c0xvYWRlclNlcnZpY2UgYXMgybVmfSBmcm9tICcuL2xpYi9sYXp5LWVsZW1lbnRzL2xhenktZWxlbWVudHMtbG9hZGVyLnNlcnZpY2UnO1xuZXhwb3J0IHtMQVpZX0VMRU1FTlRfQ09ORklHUyBhcyDJtWEsTEFaWV9FTEVNRU5UX1JPT1RfR1VBUkQgYXMgybVjLExBWllfRUxFTUVOVF9ST09UX09QVElPTlMgYXMgybVifSBmcm9tICcuL2xpYi9sYXp5LWVsZW1lbnRzL2xhenktZWxlbWVudHMudG9rZW5zJzsiXX0= |
@@ -5,4 +5,6 @@ /** | ||
*/ | ||
import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core'; | ||
import { Directive, Input, TemplateRef, ViewContainerRef, ComponentFactoryResolver, ChangeDetectorRef } from '@angular/core'; | ||
import { LazyElementsLoaderService } from '../lazy-elements-loader.service'; | ||
/** @type {?} */ | ||
const LOG_PREFIX = '@angular-extensions/elements'; | ||
export class LazyElementDirective { | ||
@@ -14,7 +16,11 @@ // tslint:disable-line:no-input-rename | ||
* @param {?} elementsLoaderService | ||
* @param {?} cfr | ||
* @param {?} cdr | ||
*/ | ||
constructor(vcr, template, elementsLoaderService) { | ||
constructor(vcr, template, elementsLoaderService, cfr, cdr) { | ||
this.vcr = vcr; | ||
this.template = template; | ||
this.elementsLoaderService = elementsLoaderService; | ||
this.cfr = cfr; | ||
this.cdr = cdr; | ||
} | ||
@@ -26,7 +32,25 @@ /** | ||
/** @type {?} */ | ||
const elementTag = ((/** @type {?} */ (this.template)))._def.element.template.nodes[0].element.name; | ||
const tpl = (/** @type {?} */ (this.template)); | ||
/** @type {?} */ | ||
const elementTag = tpl._declarationTContainer | ||
? tpl._declarationTContainer.tagName | ||
: tpl._def.element.template.nodes[0].element.name; | ||
/** @type {?} */ | ||
const elementConfig = this.elementsLoaderService.getElementConfig(elementTag) || | ||
((/** @type {?} */ ({}))); | ||
/** @type {?} */ | ||
const options = this.elementsLoaderService.options; | ||
/** @type {?} */ | ||
const loadingComponent = elementConfig.loadingComponent || options.loadingComponent; | ||
if (this.loadingTemplateRef) { | ||
this.vcr.createEmbeddedView(this.loadingTemplateRef); | ||
} | ||
this.elementsLoaderService.loadElement(this.url, elementTag).then((/** | ||
else if (loadingComponent) { | ||
/** @type {?} */ | ||
const factory = this.cfr.resolveComponentFactory(loadingComponent); | ||
this.vcr.createComponent(factory); | ||
} | ||
this.elementsLoaderService | ||
.loadElement(this.url, elementTag, this.isModule) | ||
.then((/** | ||
* @return {?} | ||
@@ -37,2 +61,24 @@ */ | ||
this.vcr.createEmbeddedView(this.template); | ||
this.cdr.markForCheck(); | ||
})) | ||
.catch((/** | ||
* @return {?} | ||
*/ | ||
() => { | ||
this.vcr.clear(); | ||
/** @type {?} */ | ||
const errorComponent = elementConfig.errorComponent || options.errorComponent; | ||
if (this.errorTemplateRef) { | ||
this.vcr.createEmbeddedView(this.errorTemplateRef); | ||
this.cdr.markForCheck(); | ||
} | ||
else if (errorComponent) { | ||
/** @type {?} */ | ||
const factory = this.cfr.resolveComponentFactory(errorComponent); | ||
this.vcr.createComponent(factory); | ||
this.cdr.markForCheck(); | ||
} | ||
else { | ||
console.error(`${LOG_PREFIX} - Loading of element <${elementTag}> failed, please provide <ng-template #error>Loading failed...</ng-template> and reference it in *axLazyElement="errorTemplate: error" to display customized error message in place of element`); | ||
} | ||
})); | ||
@@ -46,11 +92,14 @@ } | ||
]; | ||
/** @nocollapse */ | ||
LazyElementDirective.ctorParameters = () => [ | ||
{ type: ViewContainerRef }, | ||
{ type: TemplateRef }, | ||
{ type: LazyElementsLoaderService } | ||
{ type: LazyElementsLoaderService }, | ||
{ type: ComponentFactoryResolver }, | ||
{ type: ChangeDetectorRef } | ||
]; | ||
LazyElementDirective.propDecorators = { | ||
url: [{ type: Input, args: ['axLazyElement',] }], | ||
loadingTemplateRef: [{ type: Input, args: ['axLazyElementLoading',] }] | ||
loadingTemplateRef: [{ type: Input, args: ['axLazyElementLoadingTemplate',] }], | ||
errorTemplateRef: [{ type: Input, args: ['axLazyElementErrorTemplate',] }], | ||
isModule: [{ type: Input, args: ['axLazyElementModule',] }] | ||
}; | ||
@@ -62,2 +111,6 @@ if (false) { | ||
LazyElementDirective.prototype.loadingTemplateRef; | ||
/** @type {?} */ | ||
LazyElementDirective.prototype.errorTemplateRef; | ||
/** @type {?} */ | ||
LazyElementDirective.prototype.isModule; | ||
/** | ||
@@ -78,3 +131,13 @@ * @type {?} | ||
LazyElementDirective.prototype.elementsLoaderService; | ||
/** | ||
* @type {?} | ||
* @private | ||
*/ | ||
LazyElementDirective.prototype.cfr; | ||
/** | ||
* @type {?} | ||
* @private | ||
*/ | ||
LazyElementDirective.prototype.cdr; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS1lbGVtZW50LmRpcmVjdGl2ZS5qcyIsInNvdXJjZVJvb3QiOiJu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AgICAgICAgdGhpcy52Y3IuY3JlYXRlQ29tcG9uZW50KGZhY3RvcnkpO1xyXG4gICAgICAgICAgdGhpcy5jZHIubWFya0ZvckNoZWNrKCk7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgIGNvbnNvbGUuZXJyb3IoXHJcbiAgICAgICAgICAgIGAke0xPR19QUkVGSVh9IC0gTG9hZGluZyBvZiBlbGVtZW50IDwke2VsZW1lbnRUYWd9PiBmYWlsZWQsIHBsZWFzZSBwcm92aWRlIDxuZy10ZW1wbGF0ZSAjZXJyb3I+TG9hZGluZyBmYWlsZWQuLi48L25nLXRlbXBsYXRlPiBhbmQgcmVmZXJlbmNlIGl0IGluICpheExhenlFbGVtZW50PVwiZXJyb3JUZW1wbGF0ZTogZXJyb3JcIiB0byBkaXNwbGF5IGN1c3RvbWl6ZWQgZXJyb3IgbWVzc2FnZSBpbiBwbGFjZSBvZiBlbGVtZW50YFxyXG4gICAgICAgICAgKTtcclxuICAgICAgICB9XHJcbiAgICAgIH0pO1xyXG4gIH1cclxufVxyXG4iXX0= |
@@ -5,19 +5,118 @@ /** | ||
*/ | ||
import { Injectable } from '@angular/core'; | ||
import { Injectable, Optional, Inject } from '@angular/core'; | ||
import { LAZY_ELEMENT_ROOT_OPTIONS, LAZY_ELEMENTS_REGISTRY } from './lazy-elements.tokens'; | ||
import * as i0 from "@angular/core"; | ||
import * as i1 from "./lazy-elements.tokens"; | ||
/** @type {?} */ | ||
const LOG_PREFIX = '@angular-extensions/elements'; | ||
/** | ||
* @record | ||
*/ | ||
export function ElementConfig() { } | ||
if (false) { | ||
/** @type {?} */ | ||
ElementConfig.prototype.tag; | ||
/** @type {?} */ | ||
ElementConfig.prototype.url; | ||
/** @type {?|undefined} */ | ||
ElementConfig.prototype.isModule; | ||
/** @type {?|undefined} */ | ||
ElementConfig.prototype.loadingComponent; | ||
/** @type {?|undefined} */ | ||
ElementConfig.prototype.errorComponent; | ||
/** @type {?|undefined} */ | ||
ElementConfig.prototype.preload; | ||
} | ||
export class LazyElementsLoaderService { | ||
constructor() { | ||
this.registry = new Map(); | ||
/** | ||
* @param {?} registry | ||
* @param {?} options | ||
*/ | ||
constructor(registry, options) { | ||
this.registry = registry; | ||
this.options = options; | ||
this.configs = []; | ||
if (!options) { | ||
this.options = {}; | ||
} | ||
} | ||
/** | ||
* @param {?} newConfigs | ||
* @return {?} | ||
*/ | ||
addConfigs(newConfigs) { | ||
newConfigs.forEach((/** | ||
* @param {?} newConfig | ||
* @return {?} | ||
*/ | ||
newConfig => { | ||
/** @type {?} */ | ||
const existingConfig = this.getElementConfig(newConfig.tag); | ||
if (existingConfig) { | ||
console.warn(`${LOG_PREFIX} - ElementConfig for tag '${newConfig.tag}' was previously added, it will not be added multiple times, continue...`); | ||
} | ||
else { | ||
this.configs.push(newConfig); | ||
/** @type {?} */ | ||
const shouldPreload = newConfig.preload !== undefined | ||
? newConfig.preload | ||
: this.options.preload; | ||
if (shouldPreload) { | ||
this.loadElement(newConfig.url, newConfig.tag, newConfig.isModule); | ||
} | ||
} | ||
})); | ||
} | ||
/** | ||
* @param {?} tag | ||
* @return {?} | ||
*/ | ||
getElementConfig(tag) { | ||
return this.configs.find((/** | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
config => config.tag === tag)); | ||
} | ||
/** | ||
* @param {?=} tags | ||
* @return {?} | ||
*/ | ||
preload(tags) { | ||
/** @type {?} */ | ||
let configs = this.configs; | ||
if (tags) { | ||
configs = this.configs.filter((/** | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
config => tags.includes(config.tag))); | ||
} | ||
configs.forEach((/** | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
config => this.loadElement(config.url, config.tag, config.isModule))); | ||
} | ||
/** | ||
* @param {?} url | ||
* @param {?} tag | ||
* @param {?=} isModule | ||
* @return {?} | ||
*/ | ||
loadElement(url, tag) { | ||
loadElement(url, tag, isModule) { | ||
/** @type {?} */ | ||
const config = this.getElementConfig(tag); | ||
if (!url) { | ||
throw new Error(`${LOG_PREFIX} - url for <${tag}> not found`); | ||
if (!config) { | ||
throw new Error(`${LOG_PREFIX} - url for <${tag}> not found`); | ||
} | ||
url = config.url; | ||
} | ||
if (isModule === undefined) { | ||
isModule = | ||
config && config.isModule !== undefined | ||
? config.isModule | ||
: this.options.isModule; | ||
} | ||
if (!tag) { | ||
@@ -31,4 +130,8 @@ throw new Error(`${LOG_PREFIX} - tag for '${url}' not found, the *axLazyElement has to be used on HTML element`); | ||
const script = (/** @type {?} */ (document.createElement('script'))); | ||
if (isModule) { | ||
script.type = 'module'; | ||
} | ||
script.src = url; | ||
script.onload = notifier; | ||
script.onload = notifier.resolve; | ||
script.onerror = notifier.reject; | ||
document.body.appendChild(script); | ||
@@ -48,5 +151,6 @@ } | ||
* @param {?} resolve | ||
* @param {?} reject | ||
* @return {?} | ||
*/ | ||
resolve => (notifier = resolve)))); | ||
(resolve, reject) => (notifier = { resolve, reject })))); | ||
return notifier; | ||
@@ -76,9 +180,28 @@ } | ||
]; | ||
/** @nocollapse */ | ||
LazyElementsLoaderService.ctorParameters = () => []; | ||
/** @nocollapse */ LazyElementsLoaderService.ngInjectableDef = i0.ɵɵdefineInjectable({ factory: function LazyElementsLoaderService_Factory() { return new LazyElementsLoaderService(); }, token: LazyElementsLoaderService, providedIn: "root" }); | ||
LazyElementsLoaderService.ctorParameters = () => [ | ||
{ type: undefined, decorators: [{ type: Inject, args: [LAZY_ELEMENTS_REGISTRY,] }] }, | ||
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [LAZY_ELEMENT_ROOT_OPTIONS,] }] } | ||
]; | ||
/** @nocollapse */ LazyElementsLoaderService.ngInjectableDef = i0.defineInjectable({ factory: function LazyElementsLoaderService_Factory() { return new LazyElementsLoaderService(i0.inject(i1.LAZY_ELEMENTS_REGISTRY), i0.inject(i1.LAZY_ELEMENT_ROOT_OPTIONS, 8)); }, token: LazyElementsLoaderService, providedIn: "root" }); | ||
if (false) { | ||
/** @type {?} */ | ||
LazyElementsLoaderService.prototype.configs; | ||
/** | ||
* @type {?} | ||
* @private | ||
*/ | ||
LazyElementsLoaderService.prototype.registry; | ||
/** @type {?} */ | ||
LazyElementsLoaderService.prototype.options; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS1lbGVtZW50cy1sb2FkZXIuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0Bhbmd1bGFyLWV4dGVuc2lvbnMvZWxlbWVudHMvIiwic291cmNlcyI6WyJsaWIvbGF6eS1lbGVtZW50cy9sYXp5LWVsZW1lbnRzLWxvYWRlci5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7QUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sZUFBZSxDQUFDOzs7TUFFckMsVUFBVSxHQUFHLDhCQUE4QjtBQUtqRCxNQUFNLE9BQU8seUJBQXlCO0lBR3BDO1FBRkEsYUFBUSxHQUErQixJQUFJLEdBQUcsRUFBeUIsQ0FBQztJQUV6RCxDQUFDOzs7Ozs7SUFFaEIsV0FBVyxDQUFDLEdBQVcsRUFBRSxHQUFXO1FBQ2xDLElBQUksQ0FBQyxHQUFHLEVBQUU7WUFDUixNQUFNLElBQUksS0FBSyxDQUFDLEdBQUcsVUFBVSxlQUFlLEdBQUcsYUFBYSxDQUFDLENBQUM7U0FDL0Q7UUFFRCxJQUFJLENBQUMsR0FBRyxFQUFFO1lBQ1IsTUFBTSxJQUFJLEtBQUssQ0FBQyxHQUFHLFVBQVUsZUFBZSxHQUFHLGdFQUFnRSxDQUFDLENBQUM7U0FDbEg7UUFFRCxJQUFJLENBQUMsSUFBSSxDQUFDLFVBQVUsQ0FBQyxHQUFHLENBQUMsRUFBRTs7a0JBQ25CLFFBQVEsR0FBRyxJQUFJLENBQUMsVUFBVSxDQUFDLEdBQUcsQ0FBQzs7a0JBQy9CLE1BQU0sR0FBRy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cHBlbmRDaGlsZChzY3JpcHQpO1xuICAgIH1cblxuICAgIHJldHVybiB0aGlzLnJlZ2lzdHJ5LmdldCh0aGlzLnN0cmlwVXJsUHJvdG9jb2wodXJsKSk7XG4gIH1cblxuICBwcml2YXRlIGFkZEVsZW1lbnQodXJsOiBzdHJpbmcpOiAoKSA9PiB2b2lkIHtcbiAgICBsZXQgbm90aWZpZXI7XG4gICAgdGhpcy5yZWdpc3RyeS5zZXQodGhpcy5zdHJpcFVybFByb3RvY29sKHVybCksIG5ldyBQcm9taXNlPHZvaWQ+KHJlc29sdmUgPT4gKG5vdGlmaWVyID0gcmVzb2x2ZSkpKTtcbiAgICByZXR1cm4gbm90aWZpZXI7XG4gIH1cblxuICBwcml2YXRlIGhhc0VsZW1lbnQodXJsOiBzdHJpbmcpOiBib29sZWFuIHtcbiAgICByZXR1cm4gdGhpcy5yZWdpc3RyeS5oYXModGhpcy5zdHJpcFVybFByb3RvY29sKHVybCkpO1xuICB9XG5cbiAgcHJpdmF0ZSBzdHJpcFVybFByb3RvY29sKHVybDogc3RyaW5nKTogc3RyaW5nIHtcbiAgICByZXR1cm4gdXJsLnJlcGxhY2UoL2h0dHBzPzpcXC9cXC8vLCAnJyk7XG4gIH1cbn1cbiJdfQ== | ||
/** | ||
* @record | ||
*/ | ||
function Notifier() { } | ||
if (false) { | ||
/** @type {?} */ | ||
Notifier.prototype.resolve; | ||
/** @type {?} */ | ||
Notifier.prototype.reject; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS1lbGVtZW50cy1sb2FkZXIuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0Bhbmd1bGFyLWV4dGVuc2lvbnMvZWxlbWVudHMvIiwic291cmNlcyI6WyJsaWIvbGF6eS1lbGVtZW50cy9sYXp5LWVsZW1lbnRzLWxvYWRlci5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7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FkRWxlbWVudChuZXdDb25maWcudXJsLCBuZXdDb25maWcudGFnLCBuZXdDb25maWcuaXNNb2R1bGUpO1xyXG4gICAgICAgIH1cclxuICAgICAgfVxyXG4gICAgfSk7XHJcbiAgfVxyXG5cclxuICBnZXRFbGVtZW50Q29uZmlnKHRhZzogc3RyaW5nKTogRWxlbWVudENvbmZpZyB7XHJcbiAgICByZXR1cm4gdGhpcy5jb25maWdzLmZpbmQoY29uZmlnID0+IGNvbmZpZy50YWcgPT09IHRhZyk7XHJcbiAgfVxyXG5cclxuICBwcmVsb2FkKHRhZ3M/OiBzdHJpbmdbXSkge1xyXG4gICAgbGV0IGNvbmZpZ3MgPSB0aGlzLmNvbmZpZ3M7XHJcbiAgICBpZiAodGFncykge1xyXG4gICAgICBjb25maWdzID0gdGhpcy5jb25maWdzLmZpbHRlcihjb25maWcgPT4gdGFncy5pbmNsdWRlcyhjb25maWcudGFnKSk7XHJcbiAgICB9XHJcbiAgICBjb25maWdzLmZvckVhY2goY29uZmlnID0+XHJcbiAgICAgIHRoaXMubG9hZEVsZW1lbnQoY29uZmlnLnVybCwgY29uZmlnLnRhZywgY29uZmlnLmlzTW9kdWxlKVxyXG4gICAgKTtcclxuICB9XHJcblxyXG4gIGxvYWRFbGVtZW50KHVybDogc3RyaW5nLCB0YWc6IHN0cmluZywgaXNNb2R1bGU/OiBib29sZWFuKTogUHJvbWlzZTx2b2lkPiB7XHJcbiAgICBjb25zdCBjb25maWcgPSB0aGlzLmdldEVsZW1lbnRDb25maWcodGFnKTtcclxuXHJcbiAgICBpZiAoIXVybCkge1xyXG4gICAgICBpZiAoIWNvbmZpZykge1xyXG4gICAgICAgIHRocm93IG5ldyBFcnJvcihgJHtMT0dfUFJFRklYfSAtIHVybCBmb3IgPCR7dGFnfT4gbm90IGZvdW5kYCk7XHJcbiAgICAgIH1cclxuICAgICAgdXJsID0gY29uZmlnLnVybDtcclxuICAgIH1cclxuXHJcbiAgICBpZiAoaXNNb2R1bGUgPT09IHVu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GRFbGVtZW50KHVybDogc3RyaW5nKTogTm90aWZpZXIge1xyXG4gICAgbGV0IG5vdGlmaWVyOiBOb3RpZmllcjtcclxuICAgIHRoaXMucmVnaXN0cnkuc2V0KFxyXG4gICAgICB0aGlzLnN0cmlwVXJsUHJvdG9jb2wodXJsKSxcclxuICAgICAgbmV3IFByb21pc2U8dm9pZD4oKHJlc29sdmUsIHJlamVjdCkgPT4gKG5vdGlmaWVyID0geyByZXNvbHZlLCByZWplY3QgfSkpXHJcbiAgICApO1xyXG4gICAgcmV0dXJuIG5vdGlmaWVyO1xyXG4gIH1cclxuXHJcbiAgcHJpdmF0ZSBoYXNFbGVtZW50KHVybDogc3RyaW5nKTogYm9vbGVhbiB7XHJcbiAgICByZXR1cm4gdGhpcy5yZWdpc3RyeS5oYXModGhpcy5zdHJpcFVybFByb3RvY29sKHVybCkpO1xyXG4gIH1cclxuXHJcbiAgcHJpdmF0ZSBzdHJpcFVybFByb3RvY29sKHVybDogc3RyaW5nKTogc3RyaW5nIHtcclxuICAgIHJldHVybiB1cmwucmVwbGFjZSgvaHR0cHM/OlxcL1xcLy8sICcnKTtcclxuICB9XHJcbn1cclxuXHJcbmludGVyZmFjZSBOb3RpZmllciB7XHJcbiAgcmVzb2x2ZTogKCkgPT4gdm9pZDtcclxuICByZWplY3Q6IChlcnJvcjogYW55KSA9PiB2b2lkO1xyXG59XHJcbiJdfQ== |
@@ -5,14 +5,129 @@ /** | ||
*/ | ||
import { NgModule } from '@angular/core'; | ||
import { NgModule, Optional, Inject, ANALYZE_FOR_ENTRY_COMPONENTS, SkipSelf } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { LazyElementDirective } from './lazy-element/lazy-element.directive'; | ||
import { LazyElementDynamicDirective } from './lazy-element-dynamic/lazy-element-dynamic.directive'; | ||
import { LazyElementsLoaderService } from './lazy-elements-loader.service'; | ||
import { LAZY_ELEMENT_ROOT_OPTIONS, LAZY_ELEMENT_CONFIGS, LAZY_ELEMENT_ROOT_GUARD, LAZY_ELEMENTS_REGISTRY } from './lazy-elements.tokens'; | ||
export { LAZY_ELEMENTS_REGISTRY }; | ||
/** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
export function createLazyElementRootGuard(options) { | ||
if (options) { | ||
throw new TypeError(`LazyElementsModule.forRoot() called twice. Feature modules should use LazyElementsModule.forFeature() instead.`); | ||
} | ||
return 'guarded'; | ||
} | ||
export class LazyElementsModule { | ||
/** | ||
* @param {?} lazyElementsLoaderService | ||
* @param {?} elementConfigsMultiProvider | ||
* @param {?} guard | ||
*/ | ||
constructor(lazyElementsLoaderService, elementConfigsMultiProvider, guard) { | ||
if (elementConfigsMultiProvider && elementConfigsMultiProvider.length) { | ||
/** @type {?} */ | ||
const lastAddedConfigs = elementConfigsMultiProvider[elementConfigsMultiProvider.length - 1]; | ||
lazyElementsLoaderService.addConfigs(lastAddedConfigs); | ||
} | ||
} | ||
/** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
static forRoot(options) { | ||
return { | ||
ngModule: LazyElementsModule, | ||
providers: [ | ||
{ | ||
provide: LAZY_ELEMENT_CONFIGS, | ||
useValue: options && options.elementConfigs ? options.elementConfigs : [], | ||
multi: true | ||
}, | ||
{ | ||
provide: LAZY_ELEMENT_ROOT_OPTIONS, | ||
useValue: options.rootOptions ? options.rootOptions : {} | ||
}, | ||
{ | ||
provide: ANALYZE_FOR_ENTRY_COMPONENTS, | ||
useValue: options, | ||
multi: true | ||
}, | ||
{ | ||
provide: LAZY_ELEMENT_ROOT_GUARD, | ||
useFactory: createLazyElementRootGuard, | ||
deps: [[LAZY_ELEMENT_CONFIGS, new Optional(), new SkipSelf()]] | ||
} | ||
] | ||
}; | ||
} | ||
/** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
static forFeature(options) { | ||
return { | ||
ngModule: LazyElementsModule, | ||
providers: [ | ||
{ | ||
provide: LAZY_ELEMENT_CONFIGS, | ||
useValue: options && options.elementConfigs ? options.elementConfigs : [], | ||
multi: true | ||
}, | ||
{ | ||
provide: ANALYZE_FOR_ENTRY_COMPONENTS, | ||
useValue: options && options.elementConfigs, | ||
multi: true | ||
} | ||
] | ||
}; | ||
} | ||
} | ||
LazyElementsModule.decorators = [ | ||
{ type: NgModule, args: [{ | ||
declarations: [LazyElementDirective], | ||
declarations: [LazyElementDirective, LazyElementDynamicDirective], | ||
imports: [CommonModule], | ||
exports: [LazyElementDirective] | ||
exports: [LazyElementDirective, LazyElementDynamicDirective], | ||
providers: [] | ||
},] } | ||
]; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS1lbGVtZW50cy5tb2R1bGUuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AYW5ndWxhci1leHRlbnNpb25zL2VsZW1lbnRzLyIsInNvdXJjZXMiOlsibGliL2xhenktZWxlbWVudHMvbGF6eS1lbGVtZW50cy5tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDekMsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBRS9DLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHVDQUF1QyxDQUFDO0FBTzdFLE1BQU0sT0FBTyxrQkFBa0I7OztZQUw5QixRQUFRLFNBQUM7Z0JBQ1IsWUFBWSxFQUFFLENBQUMsb0JBQW9CLENBQUM7Z0JBQ3BDLE9BQU8sRUFBRSxDQUFDLFlBQVksQ0FBQztnQkFDdkIsT0FBTyxFQUFFLENBQUMsb0JBQW9CLENBQUM7YUFDaEMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgeyBOZ01vZHVsZSB9IGZyb20gJ0Bhbmd1bGFyL2NvcmUnO1xuaW1wb3J0IHsgQ29tbW9uTW9kdWxlIH0gZnJvbSAnQGFuZ3VsYXIvY29tbW9uJztcblxuaW1wb3J0IHsgTGF6eUVsZW1lbnREaXJlY3RpdmUgfSBmcm9tICcuL2xhenktZWxlbWVudC9sYXp5LWVsZW1lbnQuZGlyZWN0aXZlJztcblxuQE5nTW9kdWxlKHtcbiAgZGVjbGFyYXRpb25zOiBbTGF6eUVsZW1lbnREaXJlY3RpdmVdLFxuICBpbXBvcnRzOiBbQ29tbW9uTW9kdWxlXSxcbiAgZXhwb3J0czogW0xhenlFbGVtZW50RGlyZWN0aXZlXVxufSlcbmV4cG9ydCBjbGFzcyBMYXp5RWxlbWVudHNNb2R1bGUge31cbiJdfQ== | ||
LazyElementsModule.ctorParameters = () => [ | ||
{ type: LazyElementsLoaderService }, | ||
{ type: Array, decorators: [{ type: Optional }, { type: Inject, args: [LAZY_ELEMENT_CONFIGS,] }] }, | ||
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [LAZY_ELEMENT_ROOT_GUARD,] }] } | ||
]; | ||
/** | ||
* @record | ||
*/ | ||
export function LazyElementModuleOptions() { } | ||
if (false) { | ||
/** @type {?|undefined} */ | ||
LazyElementModuleOptions.prototype.elementConfigs; | ||
} | ||
/** | ||
* @record | ||
*/ | ||
export function LazyElementModuleRootOptions() { } | ||
if (false) { | ||
/** @type {?|undefined} */ | ||
LazyElementModuleRootOptions.prototype.elementConfigs; | ||
/** @type {?|undefined} */ | ||
LazyElementModuleRootOptions.prototype.rootOptions; | ||
} | ||
/** | ||
* @record | ||
*/ | ||
export function LazyElementRootOptions() { } | ||
if (false) { | ||
/** @type {?|undefined} */ | ||
LazyElementRootOptions.prototype.loadingComponent; | ||
/** @type {?|undefined} */ | ||
LazyElementRootOptions.prototype.errorComponent; | ||
/** @type {?|undefined} */ | ||
LazyElementRootOptions.prototype.isModule; | ||
/** @type {?|undefined} */ | ||
LazyElementRootOptions.prototype.preload; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS1lbGVtZW50cy5tb2R1bGUuanMi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ICAgICAgdXNlVmFsdWU6IG9wdGlvbnMucm9vdE9wdGlvbnMgPyBvcHRpb25zLnJvb3RPcHRpb25zIDoge31cclxuICAgICAgICB9LFxyXG4gICAgICAgIHtcclxuICAgICAgICAgIHByb3ZpZGU6IEFOQUxZWkVfRk9SX0VOVFJZX0NPTVBPTkVOVFMsXHJcbiAgICAgICAgICB1c2VWYWx1ZTogb3B0aW9ucyxcclxuICAgICAgICAgIG11bHRpOiB0cnVlXHJcbiAgICAgICAgfSxcclxuICAgICAgICB7XHJcbiAgICAgICAgICBwcm92aWRlOiBMQVpZX0VMRU1FTlRfUk9PVF9HVUFSRCxcclxuICAgICAgICAgIHVzZUZhY3Rvcnk6IGNyZWF0ZUxhenlFbGVtZW50Um9vdEd1YXJkLFxyXG4gICAgICAgICAgZGVwczogW1tMQVpZX0VMRU1FTlRfQ09ORklHUywgbmV3IE9wdGlvbmFsKCksIG5ldyBTa2lwU2VsZigpXV1cclxuICAgICAgICB9XHJcbiAgICAgIF1cclxuICAgIH07XHJcbiAgfVxyXG5cclxuICBzdGF0aWMgZm9yRmVhdHVyZShvcHRpb25zOiBMYXp5RWxlbWVudE1vZHVsZU9wdGlvbnMpOiBNb2R1bGVXaXRoUHJvdmlkZXJzIHtcclxuICAgIHJldHVybiB7XHJcbiAgICAgIG5nTW9kdWxlOiBMYXp5RWxlbWVudHNNb2R1bGUsXHJcbiAgICAgIHByb3ZpZGVyczogW1xyXG4gICAgICAgIHtcclxuICAgICAgICAgIHByb3ZpZGU6IExBWllfRUxFTUVOVF9DT05GSUdTLFxyXG4gICAgICAgICAgdXNlVmFsdWU6XHJcbiAgICAgICAgICAgIG9wdGlvbnMgJiYgb3B0aW9ucy5lbGVtZW50Q29uZmlncyA/IG9wdGlvbnMuZWxlbWVudENvbmZpZ3MgOiBbXSxcclxuICAgICAgICAgIG11bHRpOiB0cnVlXHJcbiAgICAgICAgfSxcclxuICAgICAgICB7XHJcbiAgICAgICAgICBwcm92aWRlOiBBTkFMWVp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FbGVtZW50TW9kdWxlUm9vdE9wdGlvbnMge1xyXG4gIGVsZW1lbnRDb25maWdzPzogRWxlbWVudENvbmZpZ1tdO1xyXG4gIHJvb3RPcHRpb25zPzogTGF6eUVsZW1lbnRSb290T3B0aW9ucztcclxufVxyXG5cclxuZXhwb3J0IGludGVyZmFjZSBMYXp5RWxlbWVudFJvb3RPcHRpb25zIHtcclxuICBsb2FkaW5nQ29tcG9uZW50PzogVHlwZTxhbnk+O1xyXG4gIGVycm9yQ29tcG9uZW50PzogVHlwZTxhbnk+O1xyXG4gIGlzTW9kdWxlPzogYm9vbGVhbjtcclxuICBwcmVsb2FkPzogYm9vbGVhbjtcclxufVxyXG4iXX0= |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
export { LazyElementsModule } from './lib/lazy-elements/lazy-elements.module'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0Bhbmd1bGFyLWV4dGVuc2lvbnMvZWxlbWVudHMvIiwic291cmNlcyI6WyJwdWJsaWMtYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSxtQ0FBYywwQ0FBMEMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2YgZWxlbWVudHNcbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL2xpYi9sYXp5LWVsZW1lbnRzL2xhenktZWxlbWVudHMubW9kdWxlJztcbiJdfQ== | ||
export { LAZY_ELEMENTS_REGISTRY, createLazyElementRootGuard, LazyElementsModule } from './lib/lazy-elements/lazy-elements.module'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0Bhbmd1bGFyLWV4dGVuc2lvbnMvZWxlbWVudHMvIiwic291cmNlcyI6WyJwdWJsaWMtYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSx1RkFBYywwQ0FBMEMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXHJcbiAqIFB1YmxpYyBBUEkgU3VyZmFjZSBvZiBlbGVtZW50c1xyXG4gKi9cclxuXHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL2xhenktZWxlbWVudHMvbGF6eS1lbGVtZW50cy5tb2R1bGUnO1xyXG4iXX0= |
@@ -8,5 +8,7 @@ /** | ||
*/ | ||
export { LazyElementsModule } from './public-api'; | ||
export { LazyElementDirective as ɵa } from './lib/lazy-elements/lazy-element/lazy-element.directive'; | ||
export { LazyElementsLoaderService as ɵb } from './lib/lazy-elements/lazy-elements-loader.service'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5ndWxhci1leHRlbnNpb25zLWVsZW1lbnRzLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQGFuZ3VsYXItZXh0ZW5zaW9ucy9lbGVtZW50cy8iLCJzb3VyY2VzIjpbImFuZ3VsYXItZXh0ZW5zaW9ucy1lbGVtZW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsbUNBQWMsY0FBYyxDQUFDO0FBRTdCLE9BQU8sRUFBQyxvQkFBb0IsSUFBSSxFQUFFLEVBQUMsTUFBTSx5REFBeUQsQ0FBQztBQUNuRyxPQUFPLEVBQUMseUJBQXlCLElBQUksRUFBRSxFQUFDLE1BQU0sa0RBQWtELENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEdlbmVyYXRlZCBidW5kbGUgaW5kZXguIERvIG5vdCBlZGl0LlxuICovXG5cbmV4cG9ydCAqIGZyb20gJy4vcHVibGljLWFwaSc7XG5cbmV4cG9ydCB7TGF6eUVsZW1lbnREaXJlY3RpdmUgYXMgybVhfSBmcm9tICcuL2xpYi9sYXp5LWVsZW1lbnRzL2xhenktZWxlbWVudC9sYXp5LWVsZW1lbnQuZGlyZWN0aXZlJztcbmV4cG9ydCB7TGF6eUVsZW1lbnRzTG9hZGVyU2VydmljZSBhcyDJtWJ9IGZyb20gJy4vbGliL2xhenktZWxlbWVudHMvbGF6eS1lbGVtZW50cy1sb2FkZXIuc2VydmljZSc7Il19 | ||
export { LAZY_ELEMENTS_REGISTRY, createLazyElementRootGuard, LazyElementsModule } from './public-api'; | ||
export { LazyElementDynamicDirective as ɵg } from './lib/lazy-elements/lazy-element-dynamic/lazy-element-dynamic.directive'; | ||
export { LazyElementDirective as ɵd } from './lib/lazy-elements/lazy-element/lazy-element.directive'; | ||
export { LazyElementsLoaderService as ɵf } from './lib/lazy-elements/lazy-elements-loader.service'; | ||
export { LAZY_ELEMENT_CONFIGS as ɵa, LAZY_ELEMENT_ROOT_GUARD as ɵc, LAZY_ELEMENT_ROOT_OPTIONS as ɵb } from './lib/lazy-elements/lazy-elements.tokens'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYW5ndWxhci1leHRlbnNpb25zLWVsZW1lbnRzLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQGFuZ3VsYXItZXh0ZW5zaW9ucy9lbGVtZW50cy8iLCJzb3VyY2VzIjpbImFuZ3VsYXItZXh0ZW5zaW9ucy1lbGVtZW50cy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7O0FBSUEsdUZBQWMsY0FBYyxDQUFDO0FBRTdCLE9BQU8sRUFBQywyQkFBMkIsSUFBSSxFQUFFLEVBQUMsTUFBTSx5RUFBeUUsQ0FBQztBQUMxSCxPQUFPLEVBQUMsb0JBQW9CLElBQUksRUFBRSxFQUFDLE1BQU0seURBQXlELENBQUM7QUFDbkcsT0FBTyxFQUFxQix5QkFBeUIsSUFBSSxFQUFFLEVBQUMsTUFBTSxrREFBa0QsQ0FBQztBQUNySCxPQUFPLEVBQUMsb0JBQW9CLElBQUksRUFBRSxFQUFDLHVCQUF1QixJQUFJLEVBQUUsRUFBQyx5QkFBeUIsSUFBSSxFQUFFLEVBQUMsTUFBTSwwQ0FBMEMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogR2VuZXJhdGVkIGJ1bmRsZSBpbmRleC4gRG8gbm90IGVkaXQuXG4gKi9cblxuZXhwb3J0ICogZnJvbSAnLi9wdWJsaWMtYXBpJztcblxuZXhwb3J0IHtMYXp5RWxlbWVudER5bmFtaWNEaXJlY3RpdmUgYXMgybVnfSBmcm9tICcuL2xpYi9sYXp5LWVsZW1lbnRzL2xhenktZWxlbWVudC1keW5hbWljL2xhenktZWxlbWVudC1keW5hbWljLmRpcmVjdGl2ZSc7XG5leHBvcnQge0xhenlFbGVtZW50RGlyZWN0aXZlIGFzIMm1ZH0gZnJvbSAnLi9saWIvbGF6eS1lbGVtZW50cy9sYXp5LWVsZW1lbnQvbGF6eS1lbGVtZW50LmRpcmVjdGl2ZSc7XG5leHBvcnQge0VsZW1lbnRDb25maWcgYXMgybVlLExhenlFbGVtZW50c0xvYWRlclNlcnZpY2UgYXMgybVmfSBmcm9tICcuL2xpYi9sYXp5LWVsZW1lbnRzL2xhenktZWxlbWVudHMtbG9hZGVyLnNlcnZpY2UnO1xuZXhwb3J0IHtMQVpZX0VMRU1FTlRfQ09ORklHUyBhcyDJtWEsTEFaWV9FTEVNRU5UX1JPT1RfR1VBUkQgYXMgybVjLExBWllfRUxFTUVOVF9ST09UX09QVElPTlMgYXMgybVifSBmcm9tICcuL2xpYi9sYXp5LWVsZW1lbnRzL2xhenktZWxlbWVudHMudG9rZW5zJzsiXX0= |
@@ -5,9 +5,13 @@ /** | ||
*/ | ||
import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core'; | ||
import { Directive, Input, TemplateRef, ViewContainerRef, ComponentFactoryResolver, ChangeDetectorRef } from '@angular/core'; | ||
import { LazyElementsLoaderService } from '../lazy-elements-loader.service'; | ||
/** @type {?} */ | ||
var LOG_PREFIX = '@angular-extensions/elements'; | ||
var LazyElementDirective = /** @class */ (function () { | ||
function LazyElementDirective(vcr, template, elementsLoaderService) { | ||
function LazyElementDirective(vcr, template, elementsLoaderService, cfr, cdr) { | ||
this.vcr = vcr; | ||
this.template = template; | ||
this.elementsLoaderService = elementsLoaderService; | ||
this.cfr = cfr; | ||
this.cdr = cdr; | ||
} | ||
@@ -23,7 +27,25 @@ /** | ||
/** @type {?} */ | ||
var elementTag = ((/** @type {?} */ (this.template)))._def.element.template.nodes[0].element.name; | ||
var tpl = (/** @type {?} */ (this.template)); | ||
/** @type {?} */ | ||
var elementTag = tpl._declarationTContainer | ||
? tpl._declarationTContainer.tagName | ||
: tpl._def.element.template.nodes[0].element.name; | ||
/** @type {?} */ | ||
var elementConfig = this.elementsLoaderService.getElementConfig(elementTag) || | ||
((/** @type {?} */ ({}))); | ||
/** @type {?} */ | ||
var options = this.elementsLoaderService.options; | ||
/** @type {?} */ | ||
var loadingComponent = elementConfig.loadingComponent || options.loadingComponent; | ||
if (this.loadingTemplateRef) { | ||
this.vcr.createEmbeddedView(this.loadingTemplateRef); | ||
} | ||
this.elementsLoaderService.loadElement(this.url, elementTag).then((/** | ||
else if (loadingComponent) { | ||
/** @type {?} */ | ||
var factory = this.cfr.resolveComponentFactory(loadingComponent); | ||
this.vcr.createComponent(factory); | ||
} | ||
this.elementsLoaderService | ||
.loadElement(this.url, elementTag, this.isModule) | ||
.then((/** | ||
* @return {?} | ||
@@ -34,2 +56,24 @@ */ | ||
_this.vcr.createEmbeddedView(_this.template); | ||
_this.cdr.markForCheck(); | ||
})) | ||
.catch((/** | ||
* @return {?} | ||
*/ | ||
function () { | ||
_this.vcr.clear(); | ||
/** @type {?} */ | ||
var errorComponent = elementConfig.errorComponent || options.errorComponent; | ||
if (_this.errorTemplateRef) { | ||
_this.vcr.createEmbeddedView(_this.errorTemplateRef); | ||
_this.cdr.markForCheck(); | ||
} | ||
else if (errorComponent) { | ||
/** @type {?} */ | ||
var factory = _this.cfr.resolveComponentFactory(errorComponent); | ||
_this.vcr.createComponent(factory); | ||
_this.cdr.markForCheck(); | ||
} | ||
else { | ||
console.error(LOG_PREFIX + " - Loading of element <" + elementTag + "> failed, please provide <ng-template #error>Loading failed...</ng-template> and reference it in *axLazyElement=\"errorTemplate: error\" to display customized error message in place of element"); | ||
} | ||
})); | ||
@@ -42,11 +86,14 @@ }; | ||
]; | ||
/** @nocollapse */ | ||
LazyElementDirective.ctorParameters = function () { return [ | ||
{ type: ViewContainerRef }, | ||
{ type: TemplateRef }, | ||
{ type: LazyElementsLoaderService } | ||
{ type: LazyElementsLoaderService }, | ||
{ type: ComponentFactoryResolver }, | ||
{ type: ChangeDetectorRef } | ||
]; }; | ||
LazyElementDirective.propDecorators = { | ||
url: [{ type: Input, args: ['axLazyElement',] }], | ||
loadingTemplateRef: [{ type: Input, args: ['axLazyElementLoading',] }] | ||
loadingTemplateRef: [{ type: Input, args: ['axLazyElementLoadingTemplate',] }], | ||
errorTemplateRef: [{ type: Input, args: ['axLazyElementErrorTemplate',] }], | ||
isModule: [{ type: Input, args: ['axLazyElementModule',] }] | ||
}; | ||
@@ -61,2 +108,6 @@ return LazyElementDirective; | ||
LazyElementDirective.prototype.loadingTemplateRef; | ||
/** @type {?} */ | ||
LazyElementDirective.prototype.errorTemplateRef; | ||
/** @type {?} */ | ||
LazyElementDirective.prototype.isModule; | ||
/** | ||
@@ -77,3 +128,13 @@ * @type {?} | ||
LazyElementDirective.prototype.elementsLoaderService; | ||
/** | ||
* @type {?} | ||
* @private | ||
*/ | ||
LazyElementDirective.prototype.cfr; | ||
/** | ||
* @type {?} | ||
* @private | ||
*/ | ||
LazyElementDirective.prototype.cdr; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS1lbGVtZW50LmRpcmVjdGl2ZS5qcyIsInNvdXJjZ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cbiAgICAgICAgICBjb25zdCBmYWN0b3J5ID0gdGhpcy5jZnIucmVzb2x2ZUNvbXBvbmVudEZhY3RvcnkoZXJyb3JDb21wb25lbnQpO1xyXG4gICAgICAgICAgdGhpcy52Y3IuY3JlYXRlQ29tcG9uZW50KGZhY3RvcnkpO1xyXG4gICAgICAgICAgdGhpcy5jZHIubWFya0ZvckNoZWNrKCk7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgIGNvbnNvbGUuZXJyb3IoXHJcbiAgICAgICAgICAgIGAke0xPR19QUkVGSVh9IC0gTG9hZGluZyBvZiBlbGVtZW50IDwke2VsZW1lbnRUYWd9PiBmYWlsZWQsIHBsZWFzZSBwcm92aWRlIDxuZy10ZW1wbGF0ZSAjZXJyb3I+TG9hZGluZyBmYWlsZWQuLi48L25nLXRlbXBsYXRlPiBhbmQgcmVmZXJlbmNlIGl0IGluICpheExhenlFbGVtZW50PVwiZXJyb3JUZW1wbGF0ZTogZXJyb3JcIiB0byBkaXNwbGF5IGN1c3RvbWl6ZWQgZXJyb3IgbWVzc2FnZSBpbiBwbGFjZSBvZiBlbGVtZW50YFxyXG4gICAgICAgICAgKTtcclxuICAgICAgICB9XHJcbiAgICAgIH0pO1xyXG4gIH1cclxufVxyXG4iXX0= |
@@ -5,13 +5,113 @@ /** | ||
*/ | ||
import { Injectable } from '@angular/core'; | ||
import { Injectable, Optional, Inject } from '@angular/core'; | ||
import { LAZY_ELEMENT_ROOT_OPTIONS, LAZY_ELEMENTS_REGISTRY } from './lazy-elements.tokens'; | ||
import * as i0 from "@angular/core"; | ||
import * as i1 from "./lazy-elements.tokens"; | ||
/** @type {?} */ | ||
var LOG_PREFIX = '@angular-extensions/elements'; | ||
/** | ||
* @record | ||
*/ | ||
export function ElementConfig() { } | ||
if (false) { | ||
/** @type {?} */ | ||
ElementConfig.prototype.tag; | ||
/** @type {?} */ | ||
ElementConfig.prototype.url; | ||
/** @type {?|undefined} */ | ||
ElementConfig.prototype.isModule; | ||
/** @type {?|undefined} */ | ||
ElementConfig.prototype.loadingComponent; | ||
/** @type {?|undefined} */ | ||
ElementConfig.prototype.errorComponent; | ||
/** @type {?|undefined} */ | ||
ElementConfig.prototype.preload; | ||
} | ||
var LazyElementsLoaderService = /** @class */ (function () { | ||
function LazyElementsLoaderService() { | ||
this.registry = new Map(); | ||
function LazyElementsLoaderService(registry, options) { | ||
this.registry = registry; | ||
this.options = options; | ||
this.configs = []; | ||
if (!options) { | ||
this.options = {}; | ||
} | ||
} | ||
/** | ||
* @param {?} newConfigs | ||
* @return {?} | ||
*/ | ||
LazyElementsLoaderService.prototype.addConfigs = /** | ||
* @param {?} newConfigs | ||
* @return {?} | ||
*/ | ||
function (newConfigs) { | ||
var _this = this; | ||
newConfigs.forEach((/** | ||
* @param {?} newConfig | ||
* @return {?} | ||
*/ | ||
function (newConfig) { | ||
/** @type {?} */ | ||
var existingConfig = _this.getElementConfig(newConfig.tag); | ||
if (existingConfig) { | ||
console.warn(LOG_PREFIX + " - ElementConfig for tag '" + newConfig.tag + "' was previously added, it will not be added multiple times, continue..."); | ||
} | ||
else { | ||
_this.configs.push(newConfig); | ||
/** @type {?} */ | ||
var shouldPreload = newConfig.preload !== undefined | ||
? newConfig.preload | ||
: _this.options.preload; | ||
if (shouldPreload) { | ||
_this.loadElement(newConfig.url, newConfig.tag, newConfig.isModule); | ||
} | ||
} | ||
})); | ||
}; | ||
/** | ||
* @param {?} tag | ||
* @return {?} | ||
*/ | ||
LazyElementsLoaderService.prototype.getElementConfig = /** | ||
* @param {?} tag | ||
* @return {?} | ||
*/ | ||
function (tag) { | ||
return this.configs.find((/** | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
function (config) { return config.tag === tag; })); | ||
}; | ||
/** | ||
* @param {?=} tags | ||
* @return {?} | ||
*/ | ||
LazyElementsLoaderService.prototype.preload = /** | ||
* @param {?=} tags | ||
* @return {?} | ||
*/ | ||
function (tags) { | ||
var _this = this; | ||
/** @type {?} */ | ||
var configs = this.configs; | ||
if (tags) { | ||
configs = this.configs.filter((/** | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
function (config) { return tags.includes(config.tag); })); | ||
} | ||
configs.forEach((/** | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
function (config) { | ||
return _this.loadElement(config.url, config.tag, config.isModule); | ||
})); | ||
}; | ||
/** | ||
* @param {?} url | ||
* @param {?} tag | ||
* @param {?=} isModule | ||
* @return {?} | ||
@@ -22,8 +122,20 @@ */ | ||
* @param {?} tag | ||
* @param {?=} isModule | ||
* @return {?} | ||
*/ | ||
function (url, tag) { | ||
function (url, tag, isModule) { | ||
/** @type {?} */ | ||
var config = this.getElementConfig(tag); | ||
if (!url) { | ||
throw new Error(LOG_PREFIX + " - url for <" + tag + "> not found"); | ||
if (!config) { | ||
throw new Error(LOG_PREFIX + " - url for <" + tag + "> not found"); | ||
} | ||
url = config.url; | ||
} | ||
if (isModule === undefined) { | ||
isModule = | ||
config && config.isModule !== undefined | ||
? config.isModule | ||
: this.options.isModule; | ||
} | ||
if (!tag) { | ||
@@ -37,4 +149,8 @@ throw new Error(LOG_PREFIX + " - tag for '" + url + "' not found, the *axLazyElement has to be used on HTML element"); | ||
var script = (/** @type {?} */ (document.createElement('script'))); | ||
if (isModule) { | ||
script.type = 'module'; | ||
} | ||
script.src = url; | ||
script.onload = notifier; | ||
script.onload = notifier.resolve; | ||
script.onerror = notifier.reject; | ||
document.body.appendChild(script); | ||
@@ -59,5 +175,6 @@ } | ||
* @param {?} resolve | ||
* @param {?} reject | ||
* @return {?} | ||
*/ | ||
function (resolve) { return (notifier = resolve); }))); | ||
function (resolve, reject) { return (notifier = { resolve: resolve, reject: reject }); }))); | ||
return notifier; | ||
@@ -96,5 +213,7 @@ }; | ||
]; | ||
/** @nocollapse */ | ||
LazyElementsLoaderService.ctorParameters = function () { return []; }; | ||
/** @nocollapse */ LazyElementsLoaderService.ngInjectableDef = i0.ɵɵdefineInjectable({ factory: function LazyElementsLoaderService_Factory() { return new LazyElementsLoaderService(); }, token: LazyElementsLoaderService, providedIn: "root" }); | ||
LazyElementsLoaderService.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: Inject, args: [LAZY_ELEMENTS_REGISTRY,] }] }, | ||
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [LAZY_ELEMENT_ROOT_OPTIONS,] }] } | ||
]; }; | ||
/** @nocollapse */ LazyElementsLoaderService.ngInjectableDef = i0.defineInjectable({ factory: function LazyElementsLoaderService_Factory() { return new LazyElementsLoaderService(i0.inject(i1.LAZY_ELEMENTS_REGISTRY), i0.inject(i1.LAZY_ELEMENT_ROOT_OPTIONS, 8)); }, token: LazyElementsLoaderService, providedIn: "root" }); | ||
return LazyElementsLoaderService; | ||
@@ -105,4 +224,21 @@ }()); | ||
/** @type {?} */ | ||
LazyElementsLoaderService.prototype.configs; | ||
/** | ||
* @type {?} | ||
* @private | ||
*/ | ||
LazyElementsLoaderService.prototype.registry; | ||
/** @type {?} */ | ||
LazyElementsLoaderService.prototype.options; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS1lbGVtZW50cy1sb2FkZXIuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0Bhbmd1bGFyLWV4dGVuc2lvbnMvZWxlbWVudHMvIiwic291cmNlcyI6WyJsaWIvbGF6eS1lbGVtZW50cy9sYXp5LWVsZW1lbnRzLWxvYWRlci5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7QUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sZUFBZSxDQUFDOzs7SUFFckMsVUFBVSxHQUFHLDhCQUE4QjtBQUVqRDtJQU1FO1FBRkEsYUFBUSxHQUErQixJQUFJLEdBQUcsRUFBeUIsQ0FBQztJQUV6RCxDQUFDOzs7Ozs7SUFFaEIsK0NBQVc7Ozs7O0lBQVgsVUFBWSxHQ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9jb2wodXJsKSk7XG4gIH1cblxuICBwcml2YXRlIHN0cmlwVXJsUHJvdG9jb2wodXJsOiBzdHJpbmcpOiBzdHJpbmcge1xuICAgIHJldHVybiB1cmwucmVwbGFjZSgvaHR0cHM/OlxcL1xcLy8sICcnKTtcbiAgfVxufVxuIl19 | ||
/** | ||
* @record | ||
*/ | ||
function Notifier() { } | ||
if (false) { | ||
/** @type {?} */ | ||
Notifier.prototype.resolve; | ||
/** @type {?} */ | ||
Notifier.prototype.reject; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS1lbGVtZW50cy1sb2FkZXIuc2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0Bhbmd1bGFyLWV4dGVuc2lvbnMvZWxlbWVudHMvIiwic291cmNlcyI6WyJsaWIvbGF6eS1lbGVtZW50cy9sYXp5LWVsZW1lbnRzLWxvYWRlci5zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7QUFBQSxPQUFPLEVBQUUsVUFBVSxFQUFRLFFBQVEsRUFBRSxNQUFNLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFHbkUsT0FBTyxFQUNMLHlCQUF5QixFQUN6QixzQkFBc0IsRUFFdkIsTUFBTSx3QkFBd0IsQ0FBQzs7OztJQUUxQixVQUFVLEdBQUcsOEJBQThCOzs7O0FBRWpELG1DQU9DOzs7SUFOQyw0QkFBWTs7SUFDWiw0QkFBWTs7SUFDWixpQ0FBbUI7O0lBQ25CLHlDQUE2Qjs7SUFDN0IsdUNBQTJCOztJQUMzQixnQ0FBa0I7O0FBR3BCO0lBTUUsbUNBQzBDLFFBQThCLEVBRy9ELE9BQStCO1FBSEUsYUFBUSxHQUFSLFFBQVEsQ0FBc0I7UUFHL0QsWUFBTyxHQUFQLE9BQU8sQ0FBd0I7UUFOeEMsWUFBTyxHQUFvQixFQUFFLENBQUM7UUFRNUIsSUFBSSxDQU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cmVqZWN0IH0pKVxyXG4gICAgKTtcclxuICAgIHJldHVybiBub3RpZmllcjtcclxuICB9XHJcblxyXG4gIHByaXZhdGUgaGFzRWxlbWVudCh1cmw6IHN0cmluZyk6IGJvb2xlYW4ge1xyXG4gICAgcmV0dXJuIHRoaXMucmVnaXN0cnkuaGFzKHRoaXMuc3RyaXBVcmxQcm90b2NvbCh1cmwpKTtcclxuICB9XHJcblxyXG4gIHByaXZhdGUgc3RyaXBVcmxQcm90b2NvbCh1cmw6IHN0cmluZyk6IHN0cmluZyB7XHJcbiAgICByZXR1cm4gdXJsLnJlcGxhY2UoL2h0dHBzPzpcXC9cXC8vLCAnJyk7XHJcbiAgfVxyXG59XHJcblxyXG5pbnRlcmZhY2UgTm90aWZpZXIge1xyXG4gIHJlc29sdmU6ICgpID0+IHZvaWQ7XHJcbiAgcmVqZWN0OiAoZXJyb3I6IGFueSkgPT4gdm9pZDtcclxufVxyXG4iXX0= |
@@ -5,18 +5,134 @@ /** | ||
*/ | ||
import { NgModule } from '@angular/core'; | ||
import { NgModule, Optional, Inject, ANALYZE_FOR_ENTRY_COMPONENTS, SkipSelf } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { LazyElementDirective } from './lazy-element/lazy-element.directive'; | ||
import { LazyElementDynamicDirective } from './lazy-element-dynamic/lazy-element-dynamic.directive'; | ||
import { LazyElementsLoaderService } from './lazy-elements-loader.service'; | ||
import { LAZY_ELEMENT_ROOT_OPTIONS, LAZY_ELEMENT_CONFIGS, LAZY_ELEMENT_ROOT_GUARD, LAZY_ELEMENTS_REGISTRY } from './lazy-elements.tokens'; | ||
export { LAZY_ELEMENTS_REGISTRY }; | ||
/** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
export function createLazyElementRootGuard(options) { | ||
if (options) { | ||
throw new TypeError("LazyElementsModule.forRoot() called twice. Feature modules should use LazyElementsModule.forFeature() instead."); | ||
} | ||
return 'guarded'; | ||
} | ||
var LazyElementsModule = /** @class */ (function () { | ||
function LazyElementsModule() { | ||
function LazyElementsModule(lazyElementsLoaderService, elementConfigsMultiProvider, guard) { | ||
if (elementConfigsMultiProvider && elementConfigsMultiProvider.length) { | ||
/** @type {?} */ | ||
var lastAddedConfigs = elementConfigsMultiProvider[elementConfigsMultiProvider.length - 1]; | ||
lazyElementsLoaderService.addConfigs(lastAddedConfigs); | ||
} | ||
} | ||
/** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
LazyElementsModule.forRoot = /** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
function (options) { | ||
return { | ||
ngModule: LazyElementsModule, | ||
providers: [ | ||
{ | ||
provide: LAZY_ELEMENT_CONFIGS, | ||
useValue: options && options.elementConfigs ? options.elementConfigs : [], | ||
multi: true | ||
}, | ||
{ | ||
provide: LAZY_ELEMENT_ROOT_OPTIONS, | ||
useValue: options.rootOptions ? options.rootOptions : {} | ||
}, | ||
{ | ||
provide: ANALYZE_FOR_ENTRY_COMPONENTS, | ||
useValue: options, | ||
multi: true | ||
}, | ||
{ | ||
provide: LAZY_ELEMENT_ROOT_GUARD, | ||
useFactory: createLazyElementRootGuard, | ||
deps: [[LAZY_ELEMENT_CONFIGS, new Optional(), new SkipSelf()]] | ||
} | ||
] | ||
}; | ||
}; | ||
/** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
LazyElementsModule.forFeature = /** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
function (options) { | ||
return { | ||
ngModule: LazyElementsModule, | ||
providers: [ | ||
{ | ||
provide: LAZY_ELEMENT_CONFIGS, | ||
useValue: options && options.elementConfigs ? options.elementConfigs : [], | ||
multi: true | ||
}, | ||
{ | ||
provide: ANALYZE_FOR_ENTRY_COMPONENTS, | ||
useValue: options && options.elementConfigs, | ||
multi: true | ||
} | ||
] | ||
}; | ||
}; | ||
LazyElementsModule.decorators = [ | ||
{ type: NgModule, args: [{ | ||
declarations: [LazyElementDirective], | ||
declarations: [LazyElementDirective, LazyElementDynamicDirective], | ||
imports: [CommonModule], | ||
exports: [LazyElementDirective] | ||
exports: [LazyElementDirective, LazyElementDynamicDirective], | ||
providers: [] | ||
},] } | ||
]; | ||
LazyElementsModule.ctorParameters = function () { return [ | ||
{ type: LazyElementsLoaderService }, | ||
{ type: Array, decorators: [{ type: Optional }, { type: Inject, args: [LAZY_ELEMENT_CONFIGS,] }] }, | ||
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [LAZY_ELEMENT_ROOT_GUARD,] }] } | ||
]; }; | ||
return LazyElementsModule; | ||
}()); | ||
export { LazyElementsModule }; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS1lbGVtZW50cy5tb2R1bGUuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AYW5ndWxhci1leHRlbnNpb25zL2VsZW1lbnRzLyIsInNvdXJjZXMiOlsibGliL2xhenktZWxlbWVudHMvbGF6eS1lbGVtZW50cy5tb2R1bGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLE9BQU8sRUFBRSxRQUFRLEVBQUUsTUFBTSxlQUFlLENBQUM7QUFDekMsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLGlCQUFpQixDQUFDO0FBRS9DLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHVDQUF1QyxDQUFDO0FBRTdFO0lBQUE7SUFLaUMsQ0FBQzs7Z0JBTGpDLFFBQVEsU0FBQztvQkFDUixZQUFZLEVBQUUsQ0FBQyxvQkFBb0IsQ0FBQztvQkFDcEMsT0FBTyxFQUFFLENBQUMsWUFBWSxDQUFDO29CQUN2QixPQUFPLEVBQUUsQ0FBQyxvQkFBb0IsQ0FBQztpQkFDaEM7O0lBQ2dDLHlCQUFDO0NBQUEsQUFMbEMsSUFLa0M7U0FBckIsa0JBQWtCIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgTmdNb2R1bGUgfSBmcm9tICdAYW5ndWxhci9jb3JlJztcbmltcG9ydCB7IENvbW1vbk1vZHVsZSB9IGZyb20gJ0Bhbmd1bGFyL2NvbW1vbic7XG5cbmltcG9ydCB7IExhenlFbGVtZW50RGlyZWN0aXZlIH0gZnJvbSAnLi9sYXp5LWVsZW1lbnQvbGF6eS1lbGVtZW50LmRpcmVjdGl2ZSc7XG5cbkBOZ01vZHVsZSh7XG4gIGRlY2xhcmF0aW9uczogW0xhenlFbGVtZW50RGlyZWN0aXZlXSxcbiAgaW1wb3J0czogW0NvbW1vbk1vZHVsZV0sXG4gIGV4cG9ydHM6IFtMYXp5RWxlbWVudERpcmVjdGl2ZV1cbn0pXG5leHBvcnQgY2xhc3MgTGF6eUVsZW1lbnRzTW9kdWxlIHt9XG4iXX0= | ||
/** | ||
* @record | ||
*/ | ||
export function LazyElementModuleOptions() { } | ||
if (false) { | ||
/** @type {?|undefined} */ | ||
LazyElementModuleOptions.prototype.elementConfigs; | ||
} | ||
/** | ||
* @record | ||
*/ | ||
export function LazyElementModuleRootOptions() { } | ||
if (false) { | ||
/** @type {?|undefined} */ | ||
LazyElementModuleRootOptions.prototype.elementConfigs; | ||
/** @type {?|undefined} */ | ||
LazyElementModuleRootOptions.prototype.rootOptions; | ||
} | ||
/** | ||
* @record | ||
*/ | ||
export function LazyElementRootOptions() { } | ||
if (false) { | ||
/** @type {?|undefined} */ | ||
LazyElementRootOptions.prototype.loadingComponent; | ||
/** @type {?|undefined} */ | ||
LazyElementRootOptions.prototype.errorComponent; | ||
/** @type {?|undefined} */ | ||
LazyElementRootOptions.prototype.isModule; | ||
/** @type {?|undefined} */ | ||
LazyElementRootOptions.prototype.preload; | ||
} | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibGF6eS1lbGVtZW50cy5tb2R1bGUuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AYW5ndWxhci1leHRlbnNpb25zL2VsZW1lbnRzLyIsInNvdXJjZXMiOlsibGliL2xhenktZ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yXG4gIGVsZW1lbnRDb25maWdzPzogRWxlbWVudENvbmZpZ1tdO1xyXG4gIHJvb3RPcHRpb25zPzogTGF6eUVsZW1lbnRSb290T3B0aW9ucztcclxufVxyXG5cclxuZXhwb3J0IGludGVyZmFjZSBMYXp5RWxlbWVudFJvb3RPcHRpb25zIHtcclxuICBsb2FkaW5nQ29tcG9uZW50PzogVHlwZTxhbnk+O1xyXG4gIGVycm9yQ29tcG9uZW50PzogVHlwZTxhbnk+O1xyXG4gIGlzTW9kdWxlPzogYm9vbGVhbjtcclxuICBwcmVsb2FkPzogYm9vbGVhbjtcclxufVxyXG4iXX0= |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
export { LazyElementsModule } from './lib/lazy-elements/lazy-elements.module'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0Bhbmd1bGFyLWV4dGVuc2lvbnMvZWxlbWVudHMvIiwic291cmNlcyI6WyJwdWJsaWMtYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSxtQ0FBYywwQ0FBMEMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXG4gKiBQdWJsaWMgQVBJIFN1cmZhY2Ugb2YgZWxlbWVudHNcbiAqL1xuXG5leHBvcnQgKiBmcm9tICcuL2xpYi9sYXp5LWVsZW1lbnRzL2xhenktZWxlbWVudHMubW9kdWxlJztcbiJdfQ== | ||
export { LAZY_ELEMENTS_REGISTRY, createLazyElementRootGuard, LazyElementsModule } from './lib/lazy-elements/lazy-elements.module'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHVibGljLWFwaS5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0Bhbmd1bGFyLWV4dGVuc2lvbnMvZWxlbWVudHMvIiwic291cmNlcyI6WyJwdWJsaWMtYXBpLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7QUFJQSx1RkFBYywwQ0FBMEMsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8qXHJcbiAqIFB1YmxpYyBBUEkgU3VyZmFjZSBvZiBlbGVtZW50c1xyXG4gKi9cclxuXHJcbmV4cG9ydCAqIGZyb20gJy4vbGliL2xhenktZWxlbWVudHMvbGF6eS1lbGVtZW50cy5tb2R1bGUnO1xyXG4iXX0= |
@@ -1,3 +0,3 @@ | ||
import { Injectable, ɵɵdefineInjectable, Directive, ViewContainerRef, TemplateRef, Input, NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { InjectionToken, Injectable, Optional, Inject, Directive, Input, TemplateRef, ViewContainerRef, ComponentFactoryResolver, ChangeDetectorRef, NgModule, ANALYZE_FOR_ENTRY_COMPONENTS, SkipSelf, defineInjectable, inject } from '@angular/core'; | ||
@@ -9,16 +9,114 @@ /** | ||
/** @type {?} */ | ||
const LAZY_ELEMENT_CONFIGS = new InjectionToken('LAZY_ELEMENT_CONFIGS'); | ||
/** @type {?} */ | ||
const LAZY_ELEMENT_ROOT_OPTIONS = new InjectionToken('LAZY_ELEMENT_ROOT_OPTIONS'); | ||
/** @type {?} */ | ||
const LAZY_ELEMENT_ROOT_GUARD = new InjectionToken('LAZY_ELEMENT_ROOT_GUARD'); | ||
/** @type {?} */ | ||
const LAZY_ELEMENTS_REGISTRY = new InjectionToken('Lazu elements registry', { | ||
providedIn: 'root', | ||
factory: (/** | ||
* @return {?} | ||
*/ | ||
() => new Map()) | ||
}); | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** @type {?} */ | ||
const LOG_PREFIX = '@angular-extensions/elements'; | ||
class LazyElementsLoaderService { | ||
constructor() { | ||
this.registry = new Map(); | ||
/** | ||
* @param {?} registry | ||
* @param {?} options | ||
*/ | ||
constructor(registry, options) { | ||
this.registry = registry; | ||
this.options = options; | ||
this.configs = []; | ||
if (!options) { | ||
this.options = {}; | ||
} | ||
} | ||
/** | ||
* @param {?} newConfigs | ||
* @return {?} | ||
*/ | ||
addConfigs(newConfigs) { | ||
newConfigs.forEach((/** | ||
* @param {?} newConfig | ||
* @return {?} | ||
*/ | ||
newConfig => { | ||
/** @type {?} */ | ||
const existingConfig = this.getElementConfig(newConfig.tag); | ||
if (existingConfig) { | ||
console.warn(`${LOG_PREFIX} - ElementConfig for tag '${newConfig.tag}' was previously added, it will not be added multiple times, continue...`); | ||
} | ||
else { | ||
this.configs.push(newConfig); | ||
/** @type {?} */ | ||
const shouldPreload = newConfig.preload !== undefined | ||
? newConfig.preload | ||
: this.options.preload; | ||
if (shouldPreload) { | ||
this.loadElement(newConfig.url, newConfig.tag, newConfig.isModule); | ||
} | ||
} | ||
})); | ||
} | ||
/** | ||
* @param {?} tag | ||
* @return {?} | ||
*/ | ||
getElementConfig(tag) { | ||
return this.configs.find((/** | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
config => config.tag === tag)); | ||
} | ||
/** | ||
* @param {?=} tags | ||
* @return {?} | ||
*/ | ||
preload(tags) { | ||
/** @type {?} */ | ||
let configs = this.configs; | ||
if (tags) { | ||
configs = this.configs.filter((/** | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
config => tags.includes(config.tag))); | ||
} | ||
configs.forEach((/** | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
config => this.loadElement(config.url, config.tag, config.isModule))); | ||
} | ||
/** | ||
* @param {?} url | ||
* @param {?} tag | ||
* @param {?=} isModule | ||
* @return {?} | ||
*/ | ||
loadElement(url, tag) { | ||
loadElement(url, tag, isModule) { | ||
/** @type {?} */ | ||
const config = this.getElementConfig(tag); | ||
if (!url) { | ||
throw new Error(`${LOG_PREFIX} - url for <${tag}> not found`); | ||
if (!config) { | ||
throw new Error(`${LOG_PREFIX} - url for <${tag}> not found`); | ||
} | ||
url = config.url; | ||
} | ||
if (isModule === undefined) { | ||
isModule = | ||
config && config.isModule !== undefined | ||
? config.isModule | ||
: this.options.isModule; | ||
} | ||
if (!tag) { | ||
@@ -32,4 +130,8 @@ throw new Error(`${LOG_PREFIX} - tag for '${url}' not found, the *axLazyElement has to be used on HTML element`); | ||
const script = (/** @type {?} */ (document.createElement('script'))); | ||
if (isModule) { | ||
script.type = 'module'; | ||
} | ||
script.src = url; | ||
script.onload = notifier; | ||
script.onload = notifier.resolve; | ||
script.onerror = notifier.reject; | ||
document.body.appendChild(script); | ||
@@ -49,5 +151,6 @@ } | ||
* @param {?} resolve | ||
* @param {?} reject | ||
* @return {?} | ||
*/ | ||
resolve => (notifier = resolve)))); | ||
(resolve, reject) => (notifier = { resolve, reject })))); | ||
return notifier; | ||
@@ -77,5 +180,7 @@ } | ||
]; | ||
/** @nocollapse */ | ||
LazyElementsLoaderService.ctorParameters = () => []; | ||
/** @nocollapse */ LazyElementsLoaderService.ngInjectableDef = ɵɵdefineInjectable({ factory: function LazyElementsLoaderService_Factory() { return new LazyElementsLoaderService(); }, token: LazyElementsLoaderService, providedIn: "root" }); | ||
LazyElementsLoaderService.ctorParameters = () => [ | ||
{ type: undefined, decorators: [{ type: Inject, args: [LAZY_ELEMENTS_REGISTRY,] }] }, | ||
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [LAZY_ELEMENT_ROOT_OPTIONS,] }] } | ||
]; | ||
/** @nocollapse */ LazyElementsLoaderService.ngInjectableDef = defineInjectable({ factory: function LazyElementsLoaderService_Factory() { return new LazyElementsLoaderService(inject(LAZY_ELEMENTS_REGISTRY), inject(LAZY_ELEMENT_ROOT_OPTIONS, 8)); }, token: LazyElementsLoaderService, providedIn: "root" }); | ||
@@ -86,2 +191,4 @@ /** | ||
*/ | ||
/** @type {?} */ | ||
const LOG_PREFIX$1 = '@angular-extensions/elements'; | ||
class LazyElementDirective { | ||
@@ -93,7 +200,11 @@ // tslint:disable-line:no-input-rename | ||
* @param {?} elementsLoaderService | ||
* @param {?} cfr | ||
* @param {?} cdr | ||
*/ | ||
constructor(vcr, template, elementsLoaderService) { | ||
constructor(vcr, template, elementsLoaderService, cfr, cdr) { | ||
this.vcr = vcr; | ||
this.template = template; | ||
this.elementsLoaderService = elementsLoaderService; | ||
this.cfr = cfr; | ||
this.cdr = cdr; | ||
} | ||
@@ -105,7 +216,25 @@ /** | ||
/** @type {?} */ | ||
const elementTag = ((/** @type {?} */ (this.template)))._def.element.template.nodes[0].element.name; | ||
const tpl = (/** @type {?} */ (this.template)); | ||
/** @type {?} */ | ||
const elementTag = tpl._declarationTContainer | ||
? tpl._declarationTContainer.tagName | ||
: tpl._def.element.template.nodes[0].element.name; | ||
/** @type {?} */ | ||
const elementConfig = this.elementsLoaderService.getElementConfig(elementTag) || | ||
((/** @type {?} */ ({}))); | ||
/** @type {?} */ | ||
const options = this.elementsLoaderService.options; | ||
/** @type {?} */ | ||
const loadingComponent = elementConfig.loadingComponent || options.loadingComponent; | ||
if (this.loadingTemplateRef) { | ||
this.vcr.createEmbeddedView(this.loadingTemplateRef); | ||
} | ||
this.elementsLoaderService.loadElement(this.url, elementTag).then((/** | ||
else if (loadingComponent) { | ||
/** @type {?} */ | ||
const factory = this.cfr.resolveComponentFactory(loadingComponent); | ||
this.vcr.createComponent(factory); | ||
} | ||
this.elementsLoaderService | ||
.loadElement(this.url, elementTag, this.isModule) | ||
.then((/** | ||
* @return {?} | ||
@@ -116,2 +245,24 @@ */ | ||
this.vcr.createEmbeddedView(this.template); | ||
this.cdr.markForCheck(); | ||
})) | ||
.catch((/** | ||
* @return {?} | ||
*/ | ||
() => { | ||
this.vcr.clear(); | ||
/** @type {?} */ | ||
const errorComponent = elementConfig.errorComponent || options.errorComponent; | ||
if (this.errorTemplateRef) { | ||
this.vcr.createEmbeddedView(this.errorTemplateRef); | ||
this.cdr.markForCheck(); | ||
} | ||
else if (errorComponent) { | ||
/** @type {?} */ | ||
const factory = this.cfr.resolveComponentFactory(errorComponent); | ||
this.vcr.createComponent(factory); | ||
this.cdr.markForCheck(); | ||
} | ||
else { | ||
console.error(`${LOG_PREFIX$1} - Loading of element <${elementTag}> failed, please provide <ng-template #error>Loading failed...</ng-template> and reference it in *axLazyElement="errorTemplate: error" to display customized error message in place of element`); | ||
} | ||
})); | ||
@@ -125,11 +276,14 @@ } | ||
]; | ||
/** @nocollapse */ | ||
LazyElementDirective.ctorParameters = () => [ | ||
{ type: ViewContainerRef }, | ||
{ type: TemplateRef }, | ||
{ type: LazyElementsLoaderService } | ||
{ type: LazyElementsLoaderService }, | ||
{ type: ComponentFactoryResolver }, | ||
{ type: ChangeDetectorRef } | ||
]; | ||
LazyElementDirective.propDecorators = { | ||
url: [{ type: Input, args: ['axLazyElement',] }], | ||
loadingTemplateRef: [{ type: Input, args: ['axLazyElementLoading',] }] | ||
loadingTemplateRef: [{ type: Input, args: ['axLazyElementLoadingTemplate',] }], | ||
errorTemplateRef: [{ type: Input, args: ['axLazyElementErrorTemplate',] }], | ||
isModule: [{ type: Input, args: ['axLazyElementModule',] }] | ||
}; | ||
@@ -141,13 +295,209 @@ | ||
*/ | ||
/** @type {?} */ | ||
const LOG_PREFIX$2 = '@angular-extensions/elements'; | ||
class LazyElementDynamicDirective { | ||
// tslint:disable-line:no-input-rename | ||
/** | ||
* @param {?} vcr | ||
* @param {?} template | ||
* @param {?} elementsLoaderService | ||
* @param {?} cfr | ||
* @param {?} cdr | ||
*/ | ||
constructor(vcr, template, elementsLoaderService, cfr, cdr) { | ||
this.vcr = vcr; | ||
this.template = template; | ||
this.elementsLoaderService = elementsLoaderService; | ||
this.cfr = cfr; | ||
this.cdr = cdr; | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
ngOnInit() { | ||
if (!this.tag || this.tag.length === 0 || !this.tag.includes('-')) { | ||
throw new Error(`${LOG_PREFIX$2} - Valid tag has to be specified when using *axLazyElementDynamic directive (use *axLazyElementDynamic="'some-tag'"), got: "${this.tag}"`); | ||
} | ||
/** @type {?} */ | ||
const elementConfig = this.elementsLoaderService.getElementConfig(this.tag) || | ||
((/** @type {?} */ ({}))); | ||
/** @type {?} */ | ||
const options = this.elementsLoaderService.options; | ||
/** @type {?} */ | ||
const loadingComponent = elementConfig.loadingComponent || options.loadingComponent; | ||
if (this.loadingTemplateRef) { | ||
this.vcr.createEmbeddedView(this.loadingTemplateRef); | ||
} | ||
else if (loadingComponent) { | ||
/** @type {?} */ | ||
const factory = this.cfr.resolveComponentFactory(loadingComponent); | ||
this.vcr.createComponent(factory); | ||
} | ||
this.elementsLoaderService | ||
.loadElement(this.url, this.tag, this.isModule) | ||
.then((/** | ||
* @return {?} | ||
*/ | ||
() => { | ||
if (((/** @type {?} */ (this.template)))._declarationTContainer) { | ||
// (this.template as any)._declarationTContainer.tagName = this.tag; | ||
throw new Error('The *axLazyElementDynamic directive is currently does NOT support Angular Ivy, please use standard *axLazyElement directive instead!'); | ||
} | ||
else { | ||
((/** @type {?} */ (this | ||
.template)))._def.element.template.nodes[0].element.name = this.tag; | ||
} | ||
this.vcr.clear(); | ||
this.vcr.createEmbeddedView(this.template); | ||
this.cdr.markForCheck(); | ||
})) | ||
.catch((/** | ||
* @param {?} error | ||
* @return {?} | ||
*/ | ||
error => { | ||
/** @type {?} */ | ||
const errorComponent = elementConfig.errorComponent || options.errorComponent; | ||
this.vcr.clear(); | ||
if (this.errorTemplateRef) { | ||
this.vcr.createEmbeddedView(this.errorTemplateRef); | ||
this.cdr.markForCheck(); | ||
} | ||
else if (errorComponent) { | ||
/** @type {?} */ | ||
const factory = this.cfr.resolveComponentFactory(errorComponent); | ||
this.vcr.createComponent(factory); | ||
this.cdr.markForCheck(); | ||
} | ||
else { | ||
console.error(`${LOG_PREFIX$2} - Loading of element <${this.tag}> failed, please provide <ng-template #error>Loading failed...</ng-template> and reference it in *axLazyElementDynamic="errorTemplate: error" to display customized error message in place of element\n\n`, error); | ||
} | ||
})); | ||
} | ||
} | ||
LazyElementDynamicDirective.decorators = [ | ||
{ type: Directive, args: [{ | ||
selector: '[axLazyElementDynamic]' | ||
},] } | ||
]; | ||
LazyElementDynamicDirective.ctorParameters = () => [ | ||
{ type: ViewContainerRef }, | ||
{ type: TemplateRef }, | ||
{ type: LazyElementsLoaderService }, | ||
{ type: ComponentFactoryResolver }, | ||
{ type: ChangeDetectorRef } | ||
]; | ||
LazyElementDynamicDirective.propDecorators = { | ||
tag: [{ type: Input, args: ['axLazyElementDynamic',] }], | ||
url: [{ type: Input, args: ['axLazyElementDynamicUrl',] }], | ||
loadingTemplateRef: [{ type: Input, args: ['axLazyElementDynamicLoadingTemplate',] }], | ||
errorTemplateRef: [{ type: Input, args: ['axLazyElementDynamicErrorTemplate',] }], | ||
isModule: [{ type: Input, args: ['axLazyElementDynamicModule',] }] | ||
}; | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
function createLazyElementRootGuard(options) { | ||
if (options) { | ||
throw new TypeError(`LazyElementsModule.forRoot() called twice. Feature modules should use LazyElementsModule.forFeature() instead.`); | ||
} | ||
return 'guarded'; | ||
} | ||
class LazyElementsModule { | ||
/** | ||
* @param {?} lazyElementsLoaderService | ||
* @param {?} elementConfigsMultiProvider | ||
* @param {?} guard | ||
*/ | ||
constructor(lazyElementsLoaderService, elementConfigsMultiProvider, guard) { | ||
if (elementConfigsMultiProvider && elementConfigsMultiProvider.length) { | ||
/** @type {?} */ | ||
const lastAddedConfigs = elementConfigsMultiProvider[elementConfigsMultiProvider.length - 1]; | ||
lazyElementsLoaderService.addConfigs(lastAddedConfigs); | ||
} | ||
} | ||
/** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
static forRoot(options) { | ||
return { | ||
ngModule: LazyElementsModule, | ||
providers: [ | ||
{ | ||
provide: LAZY_ELEMENT_CONFIGS, | ||
useValue: options && options.elementConfigs ? options.elementConfigs : [], | ||
multi: true | ||
}, | ||
{ | ||
provide: LAZY_ELEMENT_ROOT_OPTIONS, | ||
useValue: options.rootOptions ? options.rootOptions : {} | ||
}, | ||
{ | ||
provide: ANALYZE_FOR_ENTRY_COMPONENTS, | ||
useValue: options, | ||
multi: true | ||
}, | ||
{ | ||
provide: LAZY_ELEMENT_ROOT_GUARD, | ||
useFactory: createLazyElementRootGuard, | ||
deps: [[LAZY_ELEMENT_CONFIGS, new Optional(), new SkipSelf()]] | ||
} | ||
] | ||
}; | ||
} | ||
/** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
static forFeature(options) { | ||
return { | ||
ngModule: LazyElementsModule, | ||
providers: [ | ||
{ | ||
provide: LAZY_ELEMENT_CONFIGS, | ||
useValue: options && options.elementConfigs ? options.elementConfigs : [], | ||
multi: true | ||
}, | ||
{ | ||
provide: ANALYZE_FOR_ENTRY_COMPONENTS, | ||
useValue: options && options.elementConfigs, | ||
multi: true | ||
} | ||
] | ||
}; | ||
} | ||
} | ||
LazyElementsModule.decorators = [ | ||
{ type: NgModule, args: [{ | ||
declarations: [LazyElementDirective], | ||
declarations: [LazyElementDirective, LazyElementDynamicDirective], | ||
imports: [CommonModule], | ||
exports: [LazyElementDirective] | ||
exports: [LazyElementDirective, LazyElementDynamicDirective], | ||
providers: [] | ||
},] } | ||
]; | ||
LazyElementsModule.ctorParameters = () => [ | ||
{ type: LazyElementsLoaderService }, | ||
{ type: Array, decorators: [{ type: Optional }, { type: Inject, args: [LAZY_ELEMENT_CONFIGS,] }] }, | ||
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [LAZY_ELEMENT_ROOT_GUARD,] }] } | ||
]; | ||
export { LazyElementsModule, LazyElementDirective as ɵa, LazyElementsLoaderService as ɵb }; | ||
//# sourceMappingURL=angular-extensions-elements.js.map | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
export { LAZY_ELEMENTS_REGISTRY, createLazyElementRootGuard, LazyElementsModule, LazyElementDynamicDirective as ɵg, LazyElementDirective as ɵd, LazyElementsLoaderService as ɵf, LAZY_ELEMENT_CONFIGS as ɵa, LAZY_ELEMENT_ROOT_GUARD as ɵc, LAZY_ELEMENT_ROOT_OPTIONS as ɵb }; | ||
//# sourceMappingURL=angular-extensions-elements.js.map |
@@ -1,3 +0,3 @@ | ||
import { Injectable, ɵɵdefineInjectable, Directive, ViewContainerRef, TemplateRef, Input, NgModule } from '@angular/core'; | ||
import { CommonModule } from '@angular/common'; | ||
import { InjectionToken, Injectable, Optional, Inject, Directive, Input, TemplateRef, ViewContainerRef, ComponentFactoryResolver, ChangeDetectorRef, NgModule, ANALYZE_FOR_ENTRY_COMPONENTS, SkipSelf, defineInjectable, inject } from '@angular/core'; | ||
@@ -9,10 +9,109 @@ /** | ||
/** @type {?} */ | ||
var LAZY_ELEMENT_CONFIGS = new InjectionToken('LAZY_ELEMENT_CONFIGS'); | ||
/** @type {?} */ | ||
var LAZY_ELEMENT_ROOT_OPTIONS = new InjectionToken('LAZY_ELEMENT_ROOT_OPTIONS'); | ||
/** @type {?} */ | ||
var LAZY_ELEMENT_ROOT_GUARD = new InjectionToken('LAZY_ELEMENT_ROOT_GUARD'); | ||
/** @type {?} */ | ||
var LAZY_ELEMENTS_REGISTRY = new InjectionToken('Lazu elements registry', { | ||
providedIn: 'root', | ||
factory: (/** | ||
* @return {?} | ||
*/ | ||
function () { return new Map(); }) | ||
}); | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** @type {?} */ | ||
var LOG_PREFIX = '@angular-extensions/elements'; | ||
var LazyElementsLoaderService = /** @class */ (function () { | ||
function LazyElementsLoaderService() { | ||
this.registry = new Map(); | ||
function LazyElementsLoaderService(registry, options) { | ||
this.registry = registry; | ||
this.options = options; | ||
this.configs = []; | ||
if (!options) { | ||
this.options = {}; | ||
} | ||
} | ||
/** | ||
* @param {?} newConfigs | ||
* @return {?} | ||
*/ | ||
LazyElementsLoaderService.prototype.addConfigs = /** | ||
* @param {?} newConfigs | ||
* @return {?} | ||
*/ | ||
function (newConfigs) { | ||
var _this = this; | ||
newConfigs.forEach((/** | ||
* @param {?} newConfig | ||
* @return {?} | ||
*/ | ||
function (newConfig) { | ||
/** @type {?} */ | ||
var existingConfig = _this.getElementConfig(newConfig.tag); | ||
if (existingConfig) { | ||
console.warn(LOG_PREFIX + " - ElementConfig for tag '" + newConfig.tag + "' was previously added, it will not be added multiple times, continue..."); | ||
} | ||
else { | ||
_this.configs.push(newConfig); | ||
/** @type {?} */ | ||
var shouldPreload = newConfig.preload !== undefined | ||
? newConfig.preload | ||
: _this.options.preload; | ||
if (shouldPreload) { | ||
_this.loadElement(newConfig.url, newConfig.tag, newConfig.isModule); | ||
} | ||
} | ||
})); | ||
}; | ||
/** | ||
* @param {?} tag | ||
* @return {?} | ||
*/ | ||
LazyElementsLoaderService.prototype.getElementConfig = /** | ||
* @param {?} tag | ||
* @return {?} | ||
*/ | ||
function (tag) { | ||
return this.configs.find((/** | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
function (config) { return config.tag === tag; })); | ||
}; | ||
/** | ||
* @param {?=} tags | ||
* @return {?} | ||
*/ | ||
LazyElementsLoaderService.prototype.preload = /** | ||
* @param {?=} tags | ||
* @return {?} | ||
*/ | ||
function (tags) { | ||
var _this = this; | ||
/** @type {?} */ | ||
var configs = this.configs; | ||
if (tags) { | ||
configs = this.configs.filter((/** | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
function (config) { return tags.includes(config.tag); })); | ||
} | ||
configs.forEach((/** | ||
* @param {?} config | ||
* @return {?} | ||
*/ | ||
function (config) { | ||
return _this.loadElement(config.url, config.tag, config.isModule); | ||
})); | ||
}; | ||
/** | ||
* @param {?} url | ||
* @param {?} tag | ||
* @param {?=} isModule | ||
* @return {?} | ||
@@ -23,8 +122,20 @@ */ | ||
* @param {?} tag | ||
* @param {?=} isModule | ||
* @return {?} | ||
*/ | ||
function (url, tag) { | ||
function (url, tag, isModule) { | ||
/** @type {?} */ | ||
var config = this.getElementConfig(tag); | ||
if (!url) { | ||
throw new Error(LOG_PREFIX + " - url for <" + tag + "> not found"); | ||
if (!config) { | ||
throw new Error(LOG_PREFIX + " - url for <" + tag + "> not found"); | ||
} | ||
url = config.url; | ||
} | ||
if (isModule === undefined) { | ||
isModule = | ||
config && config.isModule !== undefined | ||
? config.isModule | ||
: this.options.isModule; | ||
} | ||
if (!tag) { | ||
@@ -38,4 +149,8 @@ throw new Error(LOG_PREFIX + " - tag for '" + url + "' not found, the *axLazyElement has to be used on HTML element"); | ||
var script = (/** @type {?} */ (document.createElement('script'))); | ||
if (isModule) { | ||
script.type = 'module'; | ||
} | ||
script.src = url; | ||
script.onload = notifier; | ||
script.onload = notifier.resolve; | ||
script.onerror = notifier.reject; | ||
document.body.appendChild(script); | ||
@@ -60,5 +175,6 @@ } | ||
* @param {?} resolve | ||
* @param {?} reject | ||
* @return {?} | ||
*/ | ||
function (resolve) { return (notifier = resolve); }))); | ||
function (resolve, reject) { return (notifier = { resolve: resolve, reject: reject }); }))); | ||
return notifier; | ||
@@ -97,5 +213,7 @@ }; | ||
]; | ||
/** @nocollapse */ | ||
LazyElementsLoaderService.ctorParameters = function () { return []; }; | ||
/** @nocollapse */ LazyElementsLoaderService.ngInjectableDef = ɵɵdefineInjectable({ factory: function LazyElementsLoaderService_Factory() { return new LazyElementsLoaderService(); }, token: LazyElementsLoaderService, providedIn: "root" }); | ||
LazyElementsLoaderService.ctorParameters = function () { return [ | ||
{ type: undefined, decorators: [{ type: Inject, args: [LAZY_ELEMENTS_REGISTRY,] }] }, | ||
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [LAZY_ELEMENT_ROOT_OPTIONS,] }] } | ||
]; }; | ||
/** @nocollapse */ LazyElementsLoaderService.ngInjectableDef = defineInjectable({ factory: function LazyElementsLoaderService_Factory() { return new LazyElementsLoaderService(inject(LAZY_ELEMENTS_REGISTRY), inject(LAZY_ELEMENT_ROOT_OPTIONS, 8)); }, token: LazyElementsLoaderService, providedIn: "root" }); | ||
return LazyElementsLoaderService; | ||
@@ -108,7 +226,11 @@ }()); | ||
*/ | ||
/** @type {?} */ | ||
var LOG_PREFIX$1 = '@angular-extensions/elements'; | ||
var LazyElementDirective = /** @class */ (function () { | ||
function LazyElementDirective(vcr, template, elementsLoaderService) { | ||
function LazyElementDirective(vcr, template, elementsLoaderService, cfr, cdr) { | ||
this.vcr = vcr; | ||
this.template = template; | ||
this.elementsLoaderService = elementsLoaderService; | ||
this.cfr = cfr; | ||
this.cdr = cdr; | ||
} | ||
@@ -124,7 +246,25 @@ /** | ||
/** @type {?} */ | ||
var elementTag = ((/** @type {?} */ (this.template)))._def.element.template.nodes[0].element.name; | ||
var tpl = (/** @type {?} */ (this.template)); | ||
/** @type {?} */ | ||
var elementTag = tpl._declarationTContainer | ||
? tpl._declarationTContainer.tagName | ||
: tpl._def.element.template.nodes[0].element.name; | ||
/** @type {?} */ | ||
var elementConfig = this.elementsLoaderService.getElementConfig(elementTag) || | ||
((/** @type {?} */ ({}))); | ||
/** @type {?} */ | ||
var options = this.elementsLoaderService.options; | ||
/** @type {?} */ | ||
var loadingComponent = elementConfig.loadingComponent || options.loadingComponent; | ||
if (this.loadingTemplateRef) { | ||
this.vcr.createEmbeddedView(this.loadingTemplateRef); | ||
} | ||
this.elementsLoaderService.loadElement(this.url, elementTag).then((/** | ||
else if (loadingComponent) { | ||
/** @type {?} */ | ||
var factory = this.cfr.resolveComponentFactory(loadingComponent); | ||
this.vcr.createComponent(factory); | ||
} | ||
this.elementsLoaderService | ||
.loadElement(this.url, elementTag, this.isModule) | ||
.then((/** | ||
* @return {?} | ||
@@ -135,2 +275,24 @@ */ | ||
_this.vcr.createEmbeddedView(_this.template); | ||
_this.cdr.markForCheck(); | ||
})) | ||
.catch((/** | ||
* @return {?} | ||
*/ | ||
function () { | ||
_this.vcr.clear(); | ||
/** @type {?} */ | ||
var errorComponent = elementConfig.errorComponent || options.errorComponent; | ||
if (_this.errorTemplateRef) { | ||
_this.vcr.createEmbeddedView(_this.errorTemplateRef); | ||
_this.cdr.markForCheck(); | ||
} | ||
else if (errorComponent) { | ||
/** @type {?} */ | ||
var factory = _this.cfr.resolveComponentFactory(errorComponent); | ||
_this.vcr.createComponent(factory); | ||
_this.cdr.markForCheck(); | ||
} | ||
else { | ||
console.error(LOG_PREFIX$1 + " - Loading of element <" + elementTag + "> failed, please provide <ng-template #error>Loading failed...</ng-template> and reference it in *axLazyElement=\"errorTemplate: error\" to display customized error message in place of element"); | ||
} | ||
})); | ||
@@ -143,11 +305,14 @@ }; | ||
]; | ||
/** @nocollapse */ | ||
LazyElementDirective.ctorParameters = function () { return [ | ||
{ type: ViewContainerRef }, | ||
{ type: TemplateRef }, | ||
{ type: LazyElementsLoaderService } | ||
{ type: LazyElementsLoaderService }, | ||
{ type: ComponentFactoryResolver }, | ||
{ type: ChangeDetectorRef } | ||
]; }; | ||
LazyElementDirective.propDecorators = { | ||
url: [{ type: Input, args: ['axLazyElement',] }], | ||
loadingTemplateRef: [{ type: Input, args: ['axLazyElementLoading',] }] | ||
loadingTemplateRef: [{ type: Input, args: ['axLazyElementLoadingTemplate',] }], | ||
errorTemplateRef: [{ type: Input, args: ['axLazyElementErrorTemplate',] }], | ||
isModule: [{ type: Input, args: ['axLazyElementModule',] }] | ||
}; | ||
@@ -161,16 +326,210 @@ return LazyElementDirective; | ||
*/ | ||
/** @type {?} */ | ||
var LOG_PREFIX$2 = '@angular-extensions/elements'; | ||
var LazyElementDynamicDirective = /** @class */ (function () { | ||
function LazyElementDynamicDirective(vcr, template, elementsLoaderService, cfr, cdr) { | ||
this.vcr = vcr; | ||
this.template = template; | ||
this.elementsLoaderService = elementsLoaderService; | ||
this.cfr = cfr; | ||
this.cdr = cdr; | ||
} | ||
/** | ||
* @return {?} | ||
*/ | ||
LazyElementDynamicDirective.prototype.ngOnInit = /** | ||
* @return {?} | ||
*/ | ||
function () { | ||
var _this = this; | ||
if (!this.tag || this.tag.length === 0 || !this.tag.includes('-')) { | ||
throw new Error(LOG_PREFIX$2 + " - Valid tag has to be specified when using *axLazyElementDynamic directive (use *axLazyElementDynamic=\"'some-tag'\"), got: \"" + this.tag + "\""); | ||
} | ||
/** @type {?} */ | ||
var elementConfig = this.elementsLoaderService.getElementConfig(this.tag) || | ||
((/** @type {?} */ ({}))); | ||
/** @type {?} */ | ||
var options = this.elementsLoaderService.options; | ||
/** @type {?} */ | ||
var loadingComponent = elementConfig.loadingComponent || options.loadingComponent; | ||
if (this.loadingTemplateRef) { | ||
this.vcr.createEmbeddedView(this.loadingTemplateRef); | ||
} | ||
else if (loadingComponent) { | ||
/** @type {?} */ | ||
var factory = this.cfr.resolveComponentFactory(loadingComponent); | ||
this.vcr.createComponent(factory); | ||
} | ||
this.elementsLoaderService | ||
.loadElement(this.url, this.tag, this.isModule) | ||
.then((/** | ||
* @return {?} | ||
*/ | ||
function () { | ||
if (((/** @type {?} */ (_this.template)))._declarationTContainer) { | ||
// (this.template as any)._declarationTContainer.tagName = this.tag; | ||
throw new Error('The *axLazyElementDynamic directive is currently does NOT support Angular Ivy, please use standard *axLazyElement directive instead!'); | ||
} | ||
else { | ||
((/** @type {?} */ (_this | ||
.template)))._def.element.template.nodes[0].element.name = _this.tag; | ||
} | ||
_this.vcr.clear(); | ||
_this.vcr.createEmbeddedView(_this.template); | ||
_this.cdr.markForCheck(); | ||
})) | ||
.catch((/** | ||
* @param {?} error | ||
* @return {?} | ||
*/ | ||
function (error) { | ||
/** @type {?} */ | ||
var errorComponent = elementConfig.errorComponent || options.errorComponent; | ||
_this.vcr.clear(); | ||
if (_this.errorTemplateRef) { | ||
_this.vcr.createEmbeddedView(_this.errorTemplateRef); | ||
_this.cdr.markForCheck(); | ||
} | ||
else if (errorComponent) { | ||
/** @type {?} */ | ||
var factory = _this.cfr.resolveComponentFactory(errorComponent); | ||
_this.vcr.createComponent(factory); | ||
_this.cdr.markForCheck(); | ||
} | ||
else { | ||
console.error(LOG_PREFIX$2 + " - Loading of element <" + _this.tag + "> failed, please provide <ng-template #error>Loading failed...</ng-template> and reference it in *axLazyElementDynamic=\"errorTemplate: error\" to display customized error message in place of element\n\n", error); | ||
} | ||
})); | ||
}; | ||
LazyElementDynamicDirective.decorators = [ | ||
{ type: Directive, args: [{ | ||
selector: '[axLazyElementDynamic]' | ||
},] } | ||
]; | ||
LazyElementDynamicDirective.ctorParameters = function () { return [ | ||
{ type: ViewContainerRef }, | ||
{ type: TemplateRef }, | ||
{ type: LazyElementsLoaderService }, | ||
{ type: ComponentFactoryResolver }, | ||
{ type: ChangeDetectorRef } | ||
]; }; | ||
LazyElementDynamicDirective.propDecorators = { | ||
tag: [{ type: Input, args: ['axLazyElementDynamic',] }], | ||
url: [{ type: Input, args: ['axLazyElementDynamicUrl',] }], | ||
loadingTemplateRef: [{ type: Input, args: ['axLazyElementDynamicLoadingTemplate',] }], | ||
errorTemplateRef: [{ type: Input, args: ['axLazyElementDynamicErrorTemplate',] }], | ||
isModule: [{ type: Input, args: ['axLazyElementDynamicModule',] }] | ||
}; | ||
return LazyElementDynamicDirective; | ||
}()); | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
function createLazyElementRootGuard(options) { | ||
if (options) { | ||
throw new TypeError("LazyElementsModule.forRoot() called twice. Feature modules should use LazyElementsModule.forFeature() instead."); | ||
} | ||
return 'guarded'; | ||
} | ||
var LazyElementsModule = /** @class */ (function () { | ||
function LazyElementsModule() { | ||
function LazyElementsModule(lazyElementsLoaderService, elementConfigsMultiProvider, guard) { | ||
if (elementConfigsMultiProvider && elementConfigsMultiProvider.length) { | ||
/** @type {?} */ | ||
var lastAddedConfigs = elementConfigsMultiProvider[elementConfigsMultiProvider.length - 1]; | ||
lazyElementsLoaderService.addConfigs(lastAddedConfigs); | ||
} | ||
} | ||
/** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
LazyElementsModule.forRoot = /** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
function (options) { | ||
return { | ||
ngModule: LazyElementsModule, | ||
providers: [ | ||
{ | ||
provide: LAZY_ELEMENT_CONFIGS, | ||
useValue: options && options.elementConfigs ? options.elementConfigs : [], | ||
multi: true | ||
}, | ||
{ | ||
provide: LAZY_ELEMENT_ROOT_OPTIONS, | ||
useValue: options.rootOptions ? options.rootOptions : {} | ||
}, | ||
{ | ||
provide: ANALYZE_FOR_ENTRY_COMPONENTS, | ||
useValue: options, | ||
multi: true | ||
}, | ||
{ | ||
provide: LAZY_ELEMENT_ROOT_GUARD, | ||
useFactory: createLazyElementRootGuard, | ||
deps: [[LAZY_ELEMENT_CONFIGS, new Optional(), new SkipSelf()]] | ||
} | ||
] | ||
}; | ||
}; | ||
/** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
LazyElementsModule.forFeature = /** | ||
* @param {?} options | ||
* @return {?} | ||
*/ | ||
function (options) { | ||
return { | ||
ngModule: LazyElementsModule, | ||
providers: [ | ||
{ | ||
provide: LAZY_ELEMENT_CONFIGS, | ||
useValue: options && options.elementConfigs ? options.elementConfigs : [], | ||
multi: true | ||
}, | ||
{ | ||
provide: ANALYZE_FOR_ENTRY_COMPONENTS, | ||
useValue: options && options.elementConfigs, | ||
multi: true | ||
} | ||
] | ||
}; | ||
}; | ||
LazyElementsModule.decorators = [ | ||
{ type: NgModule, args: [{ | ||
declarations: [LazyElementDirective], | ||
declarations: [LazyElementDirective, LazyElementDynamicDirective], | ||
imports: [CommonModule], | ||
exports: [LazyElementDirective] | ||
exports: [LazyElementDirective, LazyElementDynamicDirective], | ||
providers: [] | ||
},] } | ||
]; | ||
LazyElementsModule.ctorParameters = function () { return [ | ||
{ type: LazyElementsLoaderService }, | ||
{ type: Array, decorators: [{ type: Optional }, { type: Inject, args: [LAZY_ELEMENT_CONFIGS,] }] }, | ||
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [LAZY_ELEMENT_ROOT_GUARD,] }] } | ||
]; }; | ||
return LazyElementsModule; | ||
}()); | ||
export { LazyElementsModule, LazyElementDirective as ɵa, LazyElementsLoaderService as ɵb }; | ||
//# sourceMappingURL=angular-extensions-elements.js.map | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
/** | ||
* @fileoverview added by tsickle | ||
* @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc | ||
*/ | ||
export { LAZY_ELEMENTS_REGISTRY, createLazyElementRootGuard, LazyElementsModule, LazyElementDynamicDirective as ɵg, LazyElementDirective as ɵd, LazyElementsLoaderService as ɵf, LAZY_ELEMENT_CONFIGS as ɵa, LAZY_ELEMENT_ROOT_GUARD as ɵc, LAZY_ELEMENT_ROOT_OPTIONS as ɵb }; | ||
//# sourceMappingURL=angular-extensions-elements.js.map |
@@ -1,2 +0,2 @@ | ||
import { OnInit, TemplateRef, ViewContainerRef } from '@angular/core'; | ||
import { OnInit, TemplateRef, ViewContainerRef, ComponentFactoryResolver, ChangeDetectorRef } from '@angular/core'; | ||
import { LazyElementsLoaderService } from '../lazy-elements-loader.service'; | ||
@@ -7,6 +7,10 @@ export declare class LazyElementDirective implements OnInit { | ||
private elementsLoaderService; | ||
private cfr; | ||
private cdr; | ||
url: string; | ||
loadingTemplateRef: TemplateRef<any>; | ||
constructor(vcr: ViewContainerRef, template: TemplateRef<any>, elementsLoaderService: LazyElementsLoaderService); | ||
errorTemplateRef: TemplateRef<any>; | ||
isModule: boolean | undefined; | ||
constructor(vcr: ViewContainerRef, template: TemplateRef<any>, elementsLoaderService: LazyElementsLoaderService, cfr: ComponentFactoryResolver, cdr: ChangeDetectorRef); | ||
ngOnInit(): void; | ||
} |
@@ -0,8 +1,24 @@ | ||
import { Type } from '@angular/core'; | ||
import { LazyElementRootOptions } from './lazy-elements.module'; | ||
import { LazyElementsRegistry } from './lazy-elements.tokens'; | ||
export interface ElementConfig { | ||
tag: string; | ||
url: string; | ||
isModule?: boolean; | ||
loadingComponent?: Type<any>; | ||
errorComponent?: Type<any>; | ||
preload?: boolean; | ||
} | ||
export declare class LazyElementsLoaderService { | ||
registry: Map<string, Promise<void>>; | ||
constructor(); | ||
loadElement(url: string, tag: string): Promise<void>; | ||
private addElement; | ||
private hasElement; | ||
private stripUrlProtocol; | ||
private registry; | ||
options: LazyElementRootOptions; | ||
configs: ElementConfig[]; | ||
constructor(registry: LazyElementsRegistry, options: LazyElementRootOptions); | ||
addConfigs(newConfigs: ElementConfig[]): void; | ||
getElementConfig(tag: string): ElementConfig; | ||
preload(tags?: string[]): void; | ||
loadElement(url: string, tag: string, isModule?: boolean): Promise<void>; | ||
private addElement(url); | ||
private hasElement(url); | ||
private stripUrlProtocol(url); | ||
} |
@@ -0,2 +1,23 @@ | ||
import { ModuleWithProviders, Type } from '@angular/core'; | ||
import { ElementConfig, LazyElementsLoaderService } from './lazy-elements-loader.service'; | ||
import { LAZY_ELEMENTS_REGISTRY, LazyElementsRegistry } from './lazy-elements.tokens'; | ||
export { LAZY_ELEMENTS_REGISTRY, LazyElementsRegistry }; | ||
export declare function createLazyElementRootGuard(options: LazyElementModuleOptions): string; | ||
export declare class LazyElementsModule { | ||
static forRoot(options: LazyElementModuleRootOptions): ModuleWithProviders; | ||
static forFeature(options: LazyElementModuleOptions): ModuleWithProviders; | ||
constructor(lazyElementsLoaderService: LazyElementsLoaderService, elementConfigsMultiProvider: ElementConfig[][], guard: any); | ||
} | ||
export interface LazyElementModuleOptions { | ||
elementConfigs?: ElementConfig[]; | ||
} | ||
export interface LazyElementModuleRootOptions { | ||
elementConfigs?: ElementConfig[]; | ||
rootOptions?: LazyElementRootOptions; | ||
} | ||
export interface LazyElementRootOptions { | ||
loadingComponent?: Type<any>; | ||
errorComponent?: Type<any>; | ||
isModule?: boolean; | ||
preload?: boolean; | ||
} |
{ | ||
"name": "@angular-extensions/elements", | ||
"version": "0.3.7", | ||
"version": "6.1.0", | ||
"peerDependencies": { | ||
"@angular/common": ">6.0.0", | ||
"@angular/core": ">6.0.0" | ||
"@angular/common": "^8.0.0", | ||
"@angular/core": "^8.0.0" | ||
}, | ||
@@ -11,2 +11,22 @@ "publishConfig": { | ||
}, | ||
"keywords": [ | ||
"angular", | ||
"elements", | ||
"web componentst", | ||
"custom elements", | ||
"lazy loading", | ||
"microfrontends", | ||
"components", | ||
"web component" | ||
], | ||
"author": "Tomas Trajan <@tomastrajan>", | ||
"license": "MIT", | ||
"homepage": "https://github.com/angular-extensions/elements#readme", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/angular-extensions/elements.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/angular-extensions/elements/issues" | ||
}, | ||
"main": "bundles/angular-extensions-elements.umd.js", | ||
@@ -13,0 +33,0 @@ "module": "fesm5/angular-extensions-elements.js", |
export * from './lib/lazy-elements/lazy-elements.module'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
309269
31
0
3020
0
1
0
1
0
1