Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-svg-icon

Package Overview
Dependencies
Maintainers
1
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-svg-icon - npm Package Compare versions

Comparing version 5.1.1 to 6.0.0

2

angular-svg-icon.metadata.json

@@ -1,1 +0,1 @@

{"__symbolic":"module","version":4,"metadata":{"AngularSvgIconModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":7,"character":1},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":9,"character":2}],"declarations":[{"__symbolic":"reference","name":"SvgIconComponent"}],"providers":[{"__symbolic":"reference","name":"SVG_ICON_REGISTRY_PROVIDER"}],"exports":[{"__symbolic":"reference","name":"SvgIconComponent"}]}]}],"members":{}},"SvgIconRegistryService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":14,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/common/http","name":"HttpClient","line":20,"character":26}]}],"loadSvg":[{"__symbolic":"method"}],"unloadSvg":[{"__symbolic":"method"}]}},"SVG_ICON_REGISTRY_PROVIDER_FACTORY":{"__symbolic":"function","parameters":["parentRegistry","http"],"value":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"reference","name":"parentRegistry"},"right":{"__symbolic":"new","expression":{"__symbolic":"reference","name":"SvgIconRegistryService"},"arguments":[{"__symbolic":"reference","name":"http"}]}}},"SVG_ICON_REGISTRY_PROVIDER":{"provide":{"__symbolic":"reference","name":"SvgIconRegistryService"},"deps":[[{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":67,"character":14}},{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"SkipSelf","line":67,"character":30}},{"__symbolic":"reference","name":"SvgIconRegistryService"}],{"__symbolic":"reference","module":"@angular/common/http","name":"HttpClient","line":20,"character":26}],"useFactory":{"__symbolic":"reference","name":"SVG_ICON_REGISTRY_PROVIDER_FACTORY"}},"SvgIconComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":9,"character":1},"arguments":[{"selector":"svg-icon","styles":[":host { display: inline-block; }"],"template":"<ng-content></ng-content>"}]}],"members":{"src":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":16,"character":2}}]}],"stretch":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":17,"character":2}}]}],"svgStyle":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":20,"character":2}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef","line":33,"character":29},{"__symbolic":"reference","module":"@angular/core","name":"KeyValueDiffers","line":34,"character":18},{"__symbolic":"reference","module":"@angular/core","name":"Renderer2","line":35,"character":19},{"__symbolic":"reference","name":"SvgIconRegistryService"}]}],"ngOnInit":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"ngDoCheck":[{"__symbolic":"method"}],"init":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"resetDiffer":[{"__symbolic":"method"}],"setSvg":[{"__symbolic":"method"}],"stylize":[{"__symbolic":"method"}],"applyChanges":[{"__symbolic":"method"}],"setStyle":[{"__symbolic":"method"}]}}},"origins":{"AngularSvgIconModule":"./src/angular-svg-icon.module","SvgIconRegistryService":"./src/svg-icon-registry.service","SVG_ICON_REGISTRY_PROVIDER_FACTORY":"./src/svg-icon-registry.service","SVG_ICON_REGISTRY_PROVIDER":"./src/svg-icon-registry.service","SvgIconComponent":"./src/svg-icon.component"},"importAs":"angular-svg-icon"}
{"__symbolic":"module","version":4,"metadata":{"AngularSvgIconModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":7,"character":1},"arguments":[{"imports":[{"__symbolic":"reference","module":"@angular/common","name":"CommonModule","line":9,"character":2}],"declarations":[{"__symbolic":"reference","name":"SvgIconComponent"}],"providers":[{"__symbolic":"reference","name":"SVG_ICON_REGISTRY_PROVIDER"}],"exports":[{"__symbolic":"reference","name":"SvgIconComponent"}]}]}],"members":{}},"SvgIconRegistryService":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":6,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/common/http","name":"HttpClient","line":12,"character":26}]}],"addSvg":[{"__symbolic":"method"}],"loadSvg":[{"__symbolic":"method"}],"unloadSvg":[{"__symbolic":"method"}]}},"SVG_ICON_REGISTRY_PROVIDER_FACTORY":{"__symbolic":"function","parameters":["parentRegistry","http"],"value":{"__symbolic":"binop","operator":"||","left":{"__symbolic":"reference","name":"parentRegistry"},"right":{"__symbolic":"new","expression":{"__symbolic":"reference","name":"SvgIconRegistryService"},"arguments":[{"__symbolic":"reference","name":"http"}]}}},"SVG_ICON_REGISTRY_PROVIDER":{"provide":{"__symbolic":"reference","name":"SvgIconRegistryService"},"deps":[[{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":67,"character":14}},{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"SkipSelf","line":67,"character":30}},{"__symbolic":"reference","name":"SvgIconRegistryService"}],{"__symbolic":"reference","module":"@angular/common/http","name":"HttpClient","line":12,"character":26}],"useFactory":{"__symbolic":"reference","name":"SVG_ICON_REGISTRY_PROVIDER_FACTORY"}},"SvgIconComponent":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Component","line":9,"character":1},"arguments":[{"selector":"svg-icon","styles":[":host { display: inline-block; }"],"template":"<ng-content></ng-content>"}]}],"members":{"src":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":16,"character":2}}]}],"stretch":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":17,"character":2}}]}],"svgStyle":[{"__symbolic":"property","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Input","line":20,"character":2}}]}],"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/core","name":"ElementRef","line":33,"character":29},{"__symbolic":"reference","module":"@angular/core","name":"KeyValueDiffers","line":34,"character":18},{"__symbolic":"reference","module":"@angular/core","name":"Renderer2","line":35,"character":19},{"__symbolic":"reference","name":"SvgIconRegistryService"}]}],"ngOnInit":[{"__symbolic":"method"}],"ngOnDestroy":[{"__symbolic":"method"}],"ngOnChanges":[{"__symbolic":"method"}],"ngDoCheck":[{"__symbolic":"method"}],"init":[{"__symbolic":"method"}],"destroy":[{"__symbolic":"method"}],"resetDiffer":[{"__symbolic":"method"}],"setSvg":[{"__symbolic":"method"}],"stylize":[{"__symbolic":"method"}],"applyChanges":[{"__symbolic":"method"}],"setStyle":[{"__symbolic":"method"}]}}},"origins":{"AngularSvgIconModule":"./src/angular-svg-icon.module","SvgIconRegistryService":"./src/svg-icon-registry.service","SVG_ICON_REGISTRY_PROVIDER_FACTORY":"./src/svg-icon-registry.service","SVG_ICON_REGISTRY_PROVIDER":"./src/svg-icon-registry.service","SvgIconComponent":"./src/svg-icon.component"},"importAs":"angular-svg-icon"}
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common/http'), require('rxjs/Observable'), require('rxjs/add/observable/of'), require('rxjs/add/operator/catch'), require('rxjs/add/operator/do'), require('rxjs/add/operator/finally'), require('rxjs/add/operator/map'), require('rxjs/add/operator/share'), require('rxjs/add/observable/throw'), require('@angular/common')) :
typeof define === 'function' && define.amd ? define('angular-svg-icon', ['exports', '@angular/core', '@angular/common/http', 'rxjs/Observable', 'rxjs/add/observable/of', 'rxjs/add/operator/catch', 'rxjs/add/operator/do', 'rxjs/add/operator/finally', 'rxjs/add/operator/map', 'rxjs/add/operator/share', 'rxjs/add/observable/throw', '@angular/common'], factory) :
(factory((global['angular-svg-icon'] = {}),global.ng.core,global.ng.common.http,global.Rx,global.Rx.Observable,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable.prototype,global.Rx.Observable,global.ng.common));
}(this, (function (exports,core,http,Observable,of,_catch,_do,_finally,map,share,_throw,common) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common/http'), require('rxjs'), require('rxjs/operators'), require('@angular/common')) :
typeof define === 'function' && define.amd ? define('angular-svg-icon', ['exports', '@angular/core', '@angular/common/http', 'rxjs', 'rxjs/operators', '@angular/common'], factory) :
(factory((global['angular-svg-icon'] = {}),global.ng.core,global.ng.common.http,global.rxjs,global.Rx.Observable.prototype,global.ng.common));
}(this, (function (exports,core,http,rxjs,operators,common) { 'use strict';

@@ -53,6 +53,14 @@ /*! *****************************************************************************

}
SvgIconRegistryService.prototype.addSvg = function (name, data) {
if (!this.iconsByUrl.has(name)) {
var div = document.createElement('DIV');
div.innerHTML = data;
var svg = (div.querySelector('svg'));
this.iconsByUrl.set(name, svg);
}
};
SvgIconRegistryService.prototype.loadSvg = function (url) {
var _this = this;
if (this.iconsByUrl.has(url)) {
return Observable.Observable.of(this.iconsByUrl.get(url));
return rxjs.of(this.iconsByUrl.get(url));
}

@@ -63,19 +71,10 @@ else if (this.iconsLoadingByUrl.has(url)) {

else {
var o = (this.http.get(url, { responseType: 'text' })
.map(function (svg) {
var o = (this.http.get(url, { responseType: 'text' }).pipe(operators.map(function (svg) {
var div = document.createElement('DIV');
div.innerHTML = svg;
return (div.querySelector('svg'));
})
.do(function (svg) {
_this.iconsByUrl.set(url, svg);
})
.catch(function (err) {
}), operators.tap(function (svg) { return _this.iconsByUrl.set(url, svg); }), operators.catchError(function (err) {
console.error(err);
return Observable.Observable.throw(err);
})
.finally(function () {
_this.iconsLoadingByUrl.delete(url);
})
.share());
return rxjs.throwError(err);
}), operators.finalize(function () { return _this.iconsLoadingByUrl.delete(url); }), operators.share()));
this.iconsLoadingByUrl.set(url, o);

@@ -164,6 +163,4 @@ return o;

SvgIconComponent.prototype.resetDiffer = function () {
if (this._svgStyle) {
if (!this.differ) {
this.differ = this.differs.find(this._svgStyle).create();
}
if (this._svgStyle && !this.differ) {
this.differ = this.differs.find(this._svgStyle).create();
}

@@ -170,0 +167,0 @@ };

@@ -1,2 +0,2 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common/http"),require("rxjs/Observable"),require("rxjs/add/observable/of"),require("rxjs/add/operator/catch"),require("rxjs/add/operator/do"),require("rxjs/add/operator/finally"),require("rxjs/add/operator/map"),require("rxjs/add/operator/share"),require("rxjs/add/observable/throw"),require("@angular/common")):"function"==typeof define&&define.amd?define("angular-svg-icon",["exports","@angular/core","@angular/common/http","rxjs/Observable","rxjs/add/observable/of","rxjs/add/operator/catch","rxjs/add/operator/do","rxjs/add/operator/finally","rxjs/add/operator/map","rxjs/add/operator/share","rxjs/add/observable/throw","@angular/common"],t):t(e["angular-svg-icon"]={},e.ng.core,e.ng.common.http,e.Rx,e.Rx.Observable,e.Rx.Observable.prototype,e.Rx.Observable.prototype,e.Rx.Observable.prototype,e.Rx.Observable.prototype,e.Rx.Observable.prototype,e.Rx.Observable,e.ng.common)}(this,function(e,t,r,n,o,i,s,a,c,l,p,u){"use strict";var d=function(){function e(e){this.http=e,this.iconsByUrl=new Map,this.iconsLoadingByUrl=new Map}return e.prototype.loadSvg=function(t){var r=this;if(this.iconsByUrl.has(t))return n.Observable.of(this.iconsByUrl.get(t));if(this.iconsLoadingByUrl.has(t))return this.iconsLoadingByUrl.get(t);var e=this.http.get(t,{responseType:"text"}).map(function(e){var t=document.createElement("DIV");return t.innerHTML=e,t.querySelector("svg")})["do"](function(e){r.iconsByUrl.set(t,e)})["catch"](function(e){return console.error(e),n.Observable["throw"](e)})["finally"](function(){r.iconsLoadingByUrl["delete"](t)}).share();return this.iconsLoadingByUrl.set(t,e),e},e.prototype.unloadSvg=function(e){this.iconsByUrl.has(e)&&this.iconsByUrl["delete"](e)},e}();function f(e,t){return e||new d(t)}d.decorators=[{type:t.Injectable}],d.ctorParameters=function(){return[{type:r.HttpClient}]};var h={provide:d,deps:[[new t.Optional,new t.SkipSelf,d],r.HttpClient],useFactory:f},y=function(){function e(e,t,r,n){this.element=e,this.differs=t,this.renderer=r,this.iconReg=n,this.stretch=!1}return Object.defineProperty(e.prototype,"svgStyle",{set:function(e){this._svgStyle=e,!this.differ&&e&&(this.differ=this.differs.find(e).create())},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){this.init()},e.prototype.ngOnDestroy=function(){this.destroy()},e.prototype.ngOnChanges=function(e){e.src&&(this.svg&&this.destroy(),this.init()),e.stretch&&this.stylize()},e.prototype.ngDoCheck=function(){if(this.svg&&this.differ){var e=this.differ.diff(this._svgStyle);e&&this.applyChanges(e)}},e.prototype.init=function(){var t=this;this.icnSub=this.iconReg.loadSvg(this.src).subscribe(function(e){t.setSvg(e),t.resetDiffer()})},e.prototype.destroy=function(){this.svg=undefined,this.differ=undefined,this.icnSub&&this.icnSub.unsubscribe()},e.prototype.resetDiffer=function(){this._svgStyle&&(this.differ||(this.differ=this.differs.find(this._svgStyle).create()))},e.prototype.setSvg=function(e){if(e){var t=(this.svg=e).cloneNode(!0),r=this.element.nativeElement;r.innerHTML="",this.renderer.appendChild(r,t),this.stylize()}},e.prototype.stylize=function(){if(this.svg){var e=this.element.nativeElement.firstChild;!0===this.stretch?this.renderer.setAttribute(e,"preserveAspectRatio","none"):!1===this.stretch&&this.renderer.removeAttribute(e,"preserveAspectRatio")}},e.prototype.applyChanges=function(e){var t=this;e.forEachRemovedItem(function(e){return t.setStyle(e.key,null)}),e.forEachAddedItem(function(e){return t.setStyle(e.key,e.currentValue)}),e.forEachChangedItem(function(e){return t.setStyle(e.key,e.currentValue)})},e.prototype.setStyle=function(e,t){var r=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,i=r.call(e),s=[];try{for(;(void 0===t||0<t--)&&!(n=i.next()).done;)s.push(n.value)}catch(a){o={error:a}}finally{try{n&&!n.done&&(r=i["return"])&&r.call(i)}finally{if(o)throw o.error}}return s}(e.split("."),2),n=r[0],o=r[1];t=null!==t&&o?""+t+o:t;var i=this.element.nativeElement.firstChild;null!==t?this.renderer.setStyle(i,n,t):this.renderer.removeStyle(i,n)},e}();y.decorators=[{type:t.Component,args:[{selector:"svg-icon",styles:[":host { display: inline-block; }"],template:"<ng-content></ng-content>"}]}],y.ctorParameters=function(){return[{type:t.ElementRef},{type:t.KeyValueDiffers},{type:t.Renderer2},{type:d}]},y.propDecorators={src:[{type:t.Input}],stretch:[{type:t.Input}],svgStyle:[{type:t.Input}]};var v=function(){};v.decorators=[{type:t.NgModule,args:[{imports:[u.CommonModule],declarations:[y],providers:[h],exports:[y]}]}],e.AngularSvgIconModule=v,e.SvgIconRegistryService=d,e.SVG_ICON_REGISTRY_PROVIDER_FACTORY=f,e.SVG_ICON_REGISTRY_PROVIDER=h,e.SvgIconComponent=y,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@angular/common/http"),require("rxjs"),require("rxjs/operators"),require("@angular/common")):"function"==typeof define&&define.amd?define("angular-svg-icon",["exports","@angular/core","@angular/common/http","rxjs","rxjs/operators","@angular/common"],t):t(e["angular-svg-icon"]={},e.ng.core,e.ng.common.http,e.rxjs,e.Rx.Observable.prototype,e.ng.common)}(this,function(e,t,r,n,i,o){"use strict";var s=function(){function e(e){this.http=e,this.iconsByUrl=new Map,this.iconsLoadingByUrl=new Map}return e.prototype.addSvg=function(e,t){if(!this.iconsByUrl.has(e)){var r=document.createElement("DIV");r.innerHTML=t;var n=r.querySelector("svg");this.iconsByUrl.set(e,n)}},e.prototype.loadSvg=function(t){var r=this;if(this.iconsByUrl.has(t))return n.of(this.iconsByUrl.get(t));if(this.iconsLoadingByUrl.has(t))return this.iconsLoadingByUrl.get(t);var e=this.http.get(t,{responseType:"text"}).pipe(i.map(function(e){var t=document.createElement("DIV");return t.innerHTML=e,t.querySelector("svg")}),i.tap(function(e){return r.iconsByUrl.set(t,e)}),i.catchError(function(e){return console.error(e),n.throwError(e)}),i.finalize(function(){return r.iconsLoadingByUrl["delete"](t)}),i.share());return this.iconsLoadingByUrl.set(t,e),e},e.prototype.unloadSvg=function(e){this.iconsByUrl.has(e)&&this.iconsByUrl["delete"](e)},e}();function c(e,t){return e||new s(t)}s.decorators=[{type:t.Injectable}],s.ctorParameters=function(){return[{type:r.HttpClient}]};var a={provide:s,deps:[[new t.Optional,new t.SkipSelf,s],r.HttpClient],useFactory:c},u=function(){function e(e,t,r,n){this.element=e,this.differs=t,this.renderer=r,this.iconReg=n,this.stretch=!1}return Object.defineProperty(e.prototype,"svgStyle",{set:function(e){this._svgStyle=e,!this.differ&&e&&(this.differ=this.differs.find(e).create())},enumerable:!0,configurable:!0}),e.prototype.ngOnInit=function(){this.init()},e.prototype.ngOnDestroy=function(){this.destroy()},e.prototype.ngOnChanges=function(e){e.src&&(this.svg&&this.destroy(),this.init()),e.stretch&&this.stylize()},e.prototype.ngDoCheck=function(){if(this.svg&&this.differ){var e=this.differ.diff(this._svgStyle);e&&this.applyChanges(e)}},e.prototype.init=function(){var t=this;this.icnSub=this.iconReg.loadSvg(this.src).subscribe(function(e){t.setSvg(e),t.resetDiffer()})},e.prototype.destroy=function(){this.svg=undefined,this.differ=undefined,this.icnSub&&this.icnSub.unsubscribe()},e.prototype.resetDiffer=function(){this._svgStyle&&!this.differ&&(this.differ=this.differs.find(this._svgStyle).create())},e.prototype.setSvg=function(e){if(e){var t=(this.svg=e).cloneNode(!0),r=this.element.nativeElement;r.innerHTML="",this.renderer.appendChild(r,t),this.stylize()}},e.prototype.stylize=function(){if(this.svg){var e=this.element.nativeElement.firstChild;!0===this.stretch?this.renderer.setAttribute(e,"preserveAspectRatio","none"):!1===this.stretch&&this.renderer.removeAttribute(e,"preserveAspectRatio")}},e.prototype.applyChanges=function(e){var t=this;e.forEachRemovedItem(function(e){return t.setStyle(e.key,null)}),e.forEachAddedItem(function(e){return t.setStyle(e.key,e.currentValue)}),e.forEachChangedItem(function(e){return t.setStyle(e.key,e.currentValue)})},e.prototype.setStyle=function(e,t){var r=function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,i,o=r.call(e),s=[];try{for(;(void 0===t||0<t--)&&!(n=o.next()).done;)s.push(n.value)}catch(c){i={error:c}}finally{try{n&&!n.done&&(r=o["return"])&&r.call(o)}finally{if(i)throw i.error}}return s}(e.split("."),2),n=r[0],i=r[1];t=null!==t&&i?""+t+i:t;var o=this.element.nativeElement.firstChild;null!==t?this.renderer.setStyle(o,n,t):this.renderer.removeStyle(o,n)},e}();u.decorators=[{type:t.Component,args:[{selector:"svg-icon",styles:[":host { display: inline-block; }"],template:"<ng-content></ng-content>"}]}],u.ctorParameters=function(){return[{type:t.ElementRef},{type:t.KeyValueDiffers},{type:t.Renderer2},{type:s}]},u.propDecorators={src:[{type:t.Input}],stretch:[{type:t.Input}],svgStyle:[{type:t.Input}]};var l=function(){};l.decorators=[{type:t.NgModule,args:[{imports:[o.CommonModule],declarations:[u],providers:[a],exports:[u]}]}],e.AngularSvgIconModule=l,e.SvgIconRegistryService=s,e.SVG_ICON_REGISTRY_PROVIDER_FACTORY=c,e.SVG_ICON_REGISTRY_PROVIDER=a,e.SvgIconComponent=u,Object.defineProperty(e,"__esModule",{value:!0})});
//# sourceMappingURL=angular-svg-icon.umd.min.js.map
import { Injectable, Optional, SkipSelf, Component, ElementRef, Input, KeyValueDiffers, Renderer2, NgModule } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/finally';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/share';
import 'rxjs/add/observable/throw';
import { of, throwError } from 'rxjs';
import { map, tap, catchError, finalize, share } from 'rxjs/operators';
import { CommonModule } from '@angular/common';

@@ -27,2 +21,17 @@

/**
* Add a SVG to the registry by passing a name and the SVG.
* @param {?} name
* @param {?} data
* @return {?}
*/
addSvg(name, data) {
if (!this.iconsByUrl.has(name)) {
const /** @type {?} */ div = document.createElement('DIV');
div.innerHTML = data;
const /** @type {?} */ svg = /** @type {?} */ (div.querySelector('svg'));
this.iconsByUrl.set(name, svg);
}
}
/**
* Load a SVG to the registry from a URL.
* @param {?} url

@@ -33,3 +42,3 @@ * @return {?}

if (this.iconsByUrl.has(url)) {
return Observable.of(this.iconsByUrl.get(url));
return of(this.iconsByUrl.get(url));
}

@@ -40,19 +49,10 @@ else if (this.iconsLoadingByUrl.has(url)) {

else {
const /** @type {?} */ o = /** @type {?} */ (this.http.get(url, { responseType: 'text' })
.map(svg => {
const /** @type {?} */ o = /** @type {?} */ (this.http.get(url, { responseType: 'text' }).pipe(map(svg => {
const /** @type {?} */ div = document.createElement('DIV');
div.innerHTML = svg;
return /** @type {?} */ (div.querySelector('svg'));
})
.do(svg => {
this.iconsByUrl.set(url, svg);
})
.catch(err => {
}), tap(svg => this.iconsByUrl.set(url, svg)), catchError(err => {
console.error(err);
return Observable.throw(err);
})
.finally(() => {
this.iconsLoadingByUrl.delete(url);
})
.share());
return throwError(err);
}), finalize(() => this.iconsLoadingByUrl.delete(url)), share()));
this.iconsLoadingByUrl.set(url, o);

@@ -63,2 +63,3 @@ return o;

/**
* Remove a SVG from the registry by URL (or name).
* @param {?} url

@@ -183,6 +184,4 @@ * @return {?}

resetDiffer() {
if (this._svgStyle) {
if (!this.differ) {
this.differ = this.differs.find(this._svgStyle).create();
}
if (this._svgStyle && !this.differ) {
this.differ = this.differs.find(this._svgStyle).create();
}

@@ -189,0 +188,0 @@ }

import { __read } from 'tslib';
import { Injectable, Optional, SkipSelf, Component, ElementRef, Input, KeyValueDiffers, Renderer2, NgModule } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/finally';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/share';
import 'rxjs/add/observable/throw';
import { of, throwError } from 'rxjs';
import { map, tap, catchError, finalize, share } from 'rxjs/operators';
import { CommonModule } from '@angular/common';

@@ -20,6 +14,14 @@

}
SvgIconRegistryService.prototype.addSvg = function (name, data) {
if (!this.iconsByUrl.has(name)) {
var div = document.createElement('DIV');
div.innerHTML = data;
var svg = (div.querySelector('svg'));
this.iconsByUrl.set(name, svg);
}
};
SvgIconRegistryService.prototype.loadSvg = function (url) {
var _this = this;
if (this.iconsByUrl.has(url)) {
return Observable.of(this.iconsByUrl.get(url));
return of(this.iconsByUrl.get(url));
}

@@ -30,19 +32,10 @@ else if (this.iconsLoadingByUrl.has(url)) {

else {
var o = (this.http.get(url, { responseType: 'text' })
.map(function (svg) {
var o = (this.http.get(url, { responseType: 'text' }).pipe(map(function (svg) {
var div = document.createElement('DIV');
div.innerHTML = svg;
return (div.querySelector('svg'));
})
.do(function (svg) {
_this.iconsByUrl.set(url, svg);
})
.catch(function (err) {
}), tap(function (svg) { return _this.iconsByUrl.set(url, svg); }), catchError(function (err) {
console.error(err);
return Observable.throw(err);
})
.finally(function () {
_this.iconsLoadingByUrl.delete(url);
})
.share());
return throwError(err);
}), finalize(function () { return _this.iconsLoadingByUrl.delete(url); }), share()));
this.iconsLoadingByUrl.set(url, o);

@@ -131,6 +124,4 @@ return o;

SvgIconComponent.prototype.resetDiffer = function () {
if (this._svgStyle) {
if (!this.differ) {
this.differ = this.differs.find(this._svgStyle).create();
}
if (this._svgStyle && !this.differ) {
this.differ = this.differs.find(this._svgStyle).create();
}

@@ -137,0 +128,0 @@ };

{
"$schema": "../../node_modules/ng-packagr/package.schema.json",
"name": "angular-svg-icon",
"description": "Angular 5 component for inlining SVGs allowing them to be easily styled with CSS.",
"version": "5.1.1",
"description": "Angular 6 component for inlining SVGs allowing them to be easily styled with CSS.",
"version": "6.0.0",
"repository": {

@@ -18,5 +18,5 @@ "type": "git",

"peerDependencies": {
"@angular/core": "^4.3.0 || ^5.0.0 || ^6.0.0",
"@angular/common": "^4.3.0 || ^5.0.0 || ^6.0.0",
"rxjs": "^5.5.2"
"@angular/core": "^6.0.0",
"@angular/common": "^6.0.0",
"rxjs": "^6.0.0"
},

@@ -29,4 +29,4 @@ "main": "bundles/angular-svg-icon.umd.js",

"dependencies": {
"tslib": "^1.7.1"
"tslib": "^1.9.0"
}
}

@@ -6,3 +6,3 @@ [![npm version](https://badge.fury.io/js/angular-svg-icon.svg)](https://badge.fury.io/js/angular-svg-icon)

The **angular-svg-icon** is an Angular 4.3+ service and component that provides a
The **angular-svg-icon** is an Angular 6 service and component that provides a
means to inline SVG files to allow for them to be easily styled by CSS and code.

@@ -15,3 +15,3 @@

A [working demo](http://czeckd.github.io/angular-svg-icon/demo/) shows solution in action.
This [demo](http://czeckd.github.io/angular-svg-icon/demo/) shows this module in action.

@@ -22,5 +22,8 @@ ## How to use?

```
(**Note:** For use Angular 2.4 through Angular 4.2, please install angular-svg-icon@4.2.6
and see the module's accompanying README.md for instructions.)
**Note on earlier versions of ngx:**
- For Angular 4.3 through Angular 5.x, use angular-svg-icon@5.1.1
- For Angular 2.4 through Angular 4.2, use angular-svg-icon@4.2.6
See the module's accompanying README.md for instructions.
## Integration

@@ -36,4 +39,4 @@

@NgModule({
imports: [ HttpClientModule, AngularSvgIconModule ],
...
imports: [ HttpClientModule, AngularSvgIconModule ],
...
})

@@ -67,21 +70,27 @@ export class AppModule {}

The registry has two public functions: `loadSvg(string)` and `unloadSvg(string)`.
The registry has three public functions: `loadSvg(string)`, `addSvg(string, string)`, and `unloadSvg(string)`.
To preload a svg file into the registry:
To preload a SVG file from a URL into the registry:
```typescript
{
...
this.iconReg.loadSvg('foo.svg');
...
this.iconReg.loadSvg('foo.svg');
}
```
To unload a svg from the registry.
To add a SVG from a sting:
```typescript
{
...
this.iconReg.unloadSvg('foo.svg');
...
this.iconReg.addSvg('box',
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10"><path d="M1 1 L1 9 L9 9 L9 1 Z"/></svg>'
);
}
```
To unload a SVG from the registry.
```typescript
{
...
this.iconReg.unloadSvg('foo.svg');
}
```

@@ -88,0 +97,0 @@ ## SVG Preparation

import { Optional } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/catch';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/finally';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/share';
import 'rxjs/add/observable/throw';
import { Observable } from 'rxjs';
export declare class SvgIconRegistryService {

@@ -16,3 +9,7 @@ private http;

constructor(http: HttpClient);
/** Add a SVG to the registry by passing a name and the SVG. */
addSvg(name: string, data: string): void;
/** Load a SVG to the registry from a URL. */
loadSvg(url: string): Observable<SVGElement>;
/** Remove a SVG from the registry by URL (or name). */
unloadSvg(url: string): void;

@@ -24,3 +21,3 @@ }

deps: (Optional[] | typeof HttpClient)[];
useFactory: (parentRegistry: SvgIconRegistryService, http: HttpClient) => SvgIconRegistryService;
useFactory: typeof SVG_ICON_REGISTRY_PROVIDER_FACTORY;
};

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc