react-svg
Advanced tools
Comparing version 16.1.34 to 16.2.0
@@ -27,42 +27,30 @@ (function (global, factory) { | ||
function _objectWithoutPropertiesLoose(source, excluded) { | ||
if (source == null) return {}; | ||
var target = {}; | ||
var sourceKeys = Object.keys(source); | ||
var key, i; | ||
for (i = 0; i < sourceKeys.length; i++) { | ||
key = sourceKeys[i]; | ||
if (excluded.indexOf(key) >= 0) continue; | ||
target[key] = source[key]; | ||
function _objectWithoutPropertiesLoose(r, e) { | ||
if (null == r) return {}; | ||
var t = {}; | ||
for (var n in r) if ({}.hasOwnProperty.call(r, n)) { | ||
if (e.includes(n)) continue; | ||
t[n] = r[n]; | ||
} | ||
return target; | ||
return t; | ||
} | ||
function _extends() { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
return _extends = Object.assign ? Object.assign.bind() : function (n) { | ||
for (var e = 1; e < arguments.length; e++) { | ||
var t = arguments[e]; | ||
for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
return n; | ||
}, _extends.apply(null, arguments); | ||
} | ||
function _setPrototypeOf(o, p) { | ||
_setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { | ||
o.__proto__ = p; | ||
return o; | ||
}; | ||
return _setPrototypeOf(o, p); | ||
function _setPrototypeOf(t, e) { | ||
return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { | ||
return t.__proto__ = e, t; | ||
}, _setPrototypeOf(t, e); | ||
} | ||
function _inheritsLoose(subClass, superClass) { | ||
subClass.prototype = Object.create(superClass.prototype); | ||
subClass.prototype.constructor = subClass; | ||
_setPrototypeOf(subClass, superClass); | ||
function _inheritsLoose(t, o) { | ||
t.prototype = Object.create(o.prototype), t.prototype.constructor = t, _setPrototypeOf(t, o); | ||
} | ||
@@ -102,2 +90,4 @@ | ||
var contentType = {}; | ||
/*! | ||
@@ -109,142 +99,230 @@ * content-type | ||
/** | ||
* RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1 | ||
* | ||
* parameter = token "=" ( token / quoted-string ) | ||
* token = 1*tchar | ||
* tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" | ||
* / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" | ||
* / DIGIT / ALPHA | ||
* ; any VCHAR, except delimiters | ||
* quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE | ||
* qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text | ||
* obs-text = %x80-FF | ||
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) | ||
*/ | ||
var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g; // eslint-disable-line no-control-regex | ||
var hasRequiredContentType; | ||
/** | ||
* RegExp to match quoted-pair in RFC 7230 sec 3.2.6 | ||
* | ||
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) | ||
* obs-text = %x80-FF | ||
*/ | ||
var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g; // eslint-disable-line no-control-regex | ||
function requireContentType () { | ||
if (hasRequiredContentType) return contentType; | ||
hasRequiredContentType = 1; | ||
/** | ||
* RegExp to match type in RFC 7231 sec 3.1.1.1 | ||
* | ||
* media-type = type "/" subtype | ||
* type = token | ||
* subtype = token | ||
*/ | ||
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
var parse_1 = parse; | ||
/** | ||
* RegExp to match *( ";" parameter ) in RFC 7231 sec 3.1.1.1 | ||
* | ||
* parameter = token "=" ( token / quoted-string ) | ||
* token = 1*tchar | ||
* tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" | ||
* / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~" | ||
* / DIGIT / ALPHA | ||
* ; any VCHAR, except delimiters | ||
* quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE | ||
* qdtext = HTAB / SP / %x21 / %x23-5B / %x5D-7E / obs-text | ||
* obs-text = %x80-FF | ||
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) | ||
*/ | ||
var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g; // eslint-disable-line no-control-regex | ||
var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/; // eslint-disable-line no-control-regex | ||
var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
/** | ||
* Parse media type to object. | ||
* | ||
* @param {string|object} string | ||
* @return {Object} | ||
* @public | ||
*/ | ||
/** | ||
* RegExp to match quoted-pair in RFC 7230 sec 3.2.6 | ||
* | ||
* quoted-pair = "\" ( HTAB / SP / VCHAR / obs-text ) | ||
* obs-text = %x80-FF | ||
*/ | ||
var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g; // eslint-disable-line no-control-regex | ||
function parse (string) { | ||
if (!string) { | ||
throw new TypeError('argument string is required') | ||
} | ||
/** | ||
* RegExp to match chars that must be quoted-pair in RFC 7230 sec 3.2.6 | ||
*/ | ||
var QUOTE_REGEXP = /([\\"])/g; | ||
// support req/res-like objects as argument | ||
var header = typeof string === 'object' | ||
? getcontenttype(string) | ||
: string; | ||
/** | ||
* RegExp to match type in RFC 7231 sec 3.1.1.1 | ||
* | ||
* media-type = type "/" subtype | ||
* type = token | ||
* subtype = token | ||
*/ | ||
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/; | ||
if (typeof header !== 'string') { | ||
throw new TypeError('argument string is required to be a string') | ||
} | ||
/** | ||
* Module exports. | ||
* @public | ||
*/ | ||
var index = header.indexOf(';'); | ||
var type = index !== -1 | ||
? header.slice(0, index).trim() | ||
: header.trim(); | ||
contentType.format = format; | ||
contentType.parse = parse; | ||
if (!TYPE_REGEXP.test(type)) { | ||
throw new TypeError('invalid media type') | ||
} | ||
/** | ||
* Format object to media type. | ||
* | ||
* @param {object} obj | ||
* @return {string} | ||
* @public | ||
*/ | ||
var obj = new ContentType(type.toLowerCase()); | ||
function format (obj) { | ||
if (!obj || typeof obj !== 'object') { | ||
throw new TypeError('argument obj is required') | ||
} | ||
// parse parameters | ||
if (index !== -1) { | ||
var key; | ||
var match; | ||
var value; | ||
var parameters = obj.parameters; | ||
var type = obj.type; | ||
PARAM_REGEXP.lastIndex = index; | ||
if (!type || !TYPE_REGEXP.test(type)) { | ||
throw new TypeError('invalid type') | ||
} | ||
while ((match = PARAM_REGEXP.exec(header))) { | ||
if (match.index !== index) { | ||
throw new TypeError('invalid parameter format') | ||
} | ||
var string = type; | ||
index += match[0].length; | ||
key = match[1].toLowerCase(); | ||
value = match[2]; | ||
// append parameters | ||
if (parameters && typeof parameters === 'object') { | ||
var param; | ||
var params = Object.keys(parameters).sort(); | ||
if (value.charCodeAt(0) === 0x22 /* " */) { | ||
// remove quotes | ||
value = value.slice(1, -1); | ||
for (var i = 0; i < params.length; i++) { | ||
param = params[i]; | ||
// remove escapes | ||
if (value.indexOf('\\') !== -1) { | ||
value = value.replace(QESC_REGEXP, '$1'); | ||
} | ||
} | ||
if (!TOKEN_REGEXP.test(param)) { | ||
throw new TypeError('invalid parameter name') | ||
} | ||
obj.parameters[key] = value; | ||
} | ||
string += '; ' + param + '=' + qstring(parameters[param]); | ||
} | ||
} | ||
if (index !== header.length) { | ||
throw new TypeError('invalid parameter format') | ||
} | ||
} | ||
return string | ||
} | ||
return obj | ||
} | ||
/** | ||
* Parse media type to object. | ||
* | ||
* @param {string|object} string | ||
* @return {Object} | ||
* @public | ||
*/ | ||
/** | ||
* Get content-type from req/res objects. | ||
* | ||
* @param {object} | ||
* @return {Object} | ||
* @private | ||
*/ | ||
function parse (string) { | ||
if (!string) { | ||
throw new TypeError('argument string is required') | ||
} | ||
function getcontenttype (obj) { | ||
var header; | ||
// support req/res-like objects as argument | ||
var header = typeof string === 'object' | ||
? getcontenttype(string) | ||
: string; | ||
if (typeof obj.getHeader === 'function') { | ||
// res-like | ||
header = obj.getHeader('content-type'); | ||
} else if (typeof obj.headers === 'object') { | ||
// req-like | ||
header = obj.headers && obj.headers['content-type']; | ||
} | ||
if (typeof header !== 'string') { | ||
throw new TypeError('argument string is required to be a string') | ||
} | ||
if (typeof header !== 'string') { | ||
throw new TypeError('content-type header is missing from object') | ||
} | ||
var index = header.indexOf(';'); | ||
var type = index !== -1 | ||
? header.slice(0, index).trim() | ||
: header.trim(); | ||
return header | ||
} | ||
if (!TYPE_REGEXP.test(type)) { | ||
throw new TypeError('invalid media type') | ||
} | ||
/** | ||
* Class to represent a content type. | ||
* @private | ||
*/ | ||
function ContentType (type) { | ||
this.parameters = Object.create(null); | ||
this.type = type; | ||
var obj = new ContentType(type.toLowerCase()); | ||
// parse parameters | ||
if (index !== -1) { | ||
var key; | ||
var match; | ||
var value; | ||
PARAM_REGEXP.lastIndex = index; | ||
while ((match = PARAM_REGEXP.exec(header))) { | ||
if (match.index !== index) { | ||
throw new TypeError('invalid parameter format') | ||
} | ||
index += match[0].length; | ||
key = match[1].toLowerCase(); | ||
value = match[2]; | ||
if (value.charCodeAt(0) === 0x22 /* " */) { | ||
// remove quotes | ||
value = value.slice(1, -1); | ||
// remove escapes | ||
if (value.indexOf('\\') !== -1) { | ||
value = value.replace(QESC_REGEXP, '$1'); | ||
} | ||
} | ||
obj.parameters[key] = value; | ||
} | ||
if (index !== header.length) { | ||
throw new TypeError('invalid parameter format') | ||
} | ||
} | ||
return obj | ||
} | ||
/** | ||
* Get content-type from req/res objects. | ||
* | ||
* @param {object} | ||
* @return {Object} | ||
* @private | ||
*/ | ||
function getcontenttype (obj) { | ||
var header; | ||
if (typeof obj.getHeader === 'function') { | ||
// res-like | ||
header = obj.getHeader('content-type'); | ||
} else if (typeof obj.headers === 'object') { | ||
// req-like | ||
header = obj.headers && obj.headers['content-type']; | ||
} | ||
if (typeof header !== 'string') { | ||
throw new TypeError('content-type header is missing from object') | ||
} | ||
return header | ||
} | ||
/** | ||
* Quote a string if necessary. | ||
* | ||
* @param {string} val | ||
* @return {string} | ||
* @private | ||
*/ | ||
function qstring (val) { | ||
var str = String(val); | ||
// no need to quote tokens | ||
if (TOKEN_REGEXP.test(str)) { | ||
return str | ||
} | ||
if (str.length > 0 && !TEXT_REGEXP.test(str)) { | ||
throw new TypeError('invalid parameter value') | ||
} | ||
return '"' + str.replace(QUOTE_REGEXP, '\\$1') + '"' | ||
} | ||
/** | ||
* Class to represent a content type. | ||
* @private | ||
*/ | ||
function ContentType (type) { | ||
this.parameters = Object.create(null); | ||
this.type = type; | ||
} | ||
return contentType; | ||
} | ||
var contentTypeExports = requireContentType(); | ||
var cache = new Map(); | ||
@@ -269,3 +347,3 @@ | ||
} | ||
var type = parse_1(contentType).type; | ||
var type = contentTypeExports.parse(contentType).type; | ||
if (!(type === 'image/svg+xml' || type === 'text/plain')) { | ||
@@ -272,0 +350,0 @@ throw new Error("Invalid content type: ".concat(type)); |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactSVG={},e.React)}(this,(function(e,t){"use strict";function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=r(t);function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},i.apply(this,arguments)}function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}function a(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var s=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,l=/\\([\u000b\u0020-\u00ff])/g,c=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,u=function(e){if(!e)throw new TypeError("argument string is required");var t="object"==typeof e?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(e):e;if("string"!=typeof t)throw new TypeError("argument string is required to be a string");var r=t.indexOf(";"),n=-1!==r?t.slice(0,r).trim():t.trim();if(!c.test(n))throw new TypeError("invalid media type");var i=new f(n.toLowerCase());if(-1!==r){var o,a,u;for(s.lastIndex=r;a=s.exec(t);){if(a.index!==r)throw new TypeError("invalid parameter format");r+=a[0].length,o=a[1].toLowerCase(),34===(u=a[2]).charCodeAt(0)&&-1!==(u=u.slice(1,-1)).indexOf("\\")&&(u=u.replace(l,"$1")),i.parameters[o]=u}if(r!==t.length)throw new TypeError("invalid parameter format")}return i};function f(e){this.parameters=Object.create(null),this.type=e}var p=new Map,d=function(e){return e.cloneNode(!0)},h=function(){return"file:"===window.location.protocol},v=function(e,t,r){var n=new XMLHttpRequest;n.onreadystatechange=function(){try{if(!/\.svg/i.test(e)&&2===n.readyState){var t=n.getResponseHeader("Content-Type");if(!t)throw new Error("Content type not found");var i=u(t).type;if("image/svg+xml"!==i&&"text/plain"!==i)throw new Error("Invalid content type: ".concat(i))}if(4===n.readyState){if(404===n.status||null===n.responseXML)throw new Error(h()?"Note: SVG injection ajax calls do not work locally without adjusting security settings in your browser. Or consider using a local webserver.":"Unable to load SVG file: "+e);if(!(200===n.status||h()&&0===n.status))throw new Error("There was a problem injecting the SVG: "+n.status+" "+n.statusText);r(null,n)}}catch(e){if(n.abort(),!(e instanceof Error))throw e;r(e,n)}},n.open("GET",e),n.withCredentials=t,n.overrideMimeType&&n.overrideMimeType("text/xml"),n.send()},m={},g=function(e,t){m[e]=m[e]||[],m[e].push(t)},y=function(e,t,r){if(p.has(e)){var n=p.get(e);if(void 0===n)return void g(e,r);if(n instanceof SVGSVGElement)return void r(null,d(n))}p.set(e,void 0),g(e,r),v(e,t,(function(t,r){var n;t?p.set(e,t):(null===(n=r.responseXML)||void 0===n?void 0:n.documentElement)instanceof SVGSVGElement&&p.set(e,r.responseXML.documentElement),function(e){for(var t=function(t,r){setTimeout((function(){if(Array.isArray(m[e])){var r=p.get(e),n=m[e][t];r instanceof SVGSVGElement&&n(null,d(r)),r instanceof Error&&n(r),t===m[e].length-1&&delete m[e]}}),0)},r=0,n=m[e].length;r<n;r++)t(r)}(e)}))},b=function(e,t,r){v(e,t,(function(e,t){var n;e?r(e):(null===(n=t.responseXML)||void 0===n?void 0:n.documentElement)instanceof SVGSVGElement&&r(null,t.responseXML.documentElement)}))},w=0,E=[],A={},S="http://www.w3.org/1999/xlink",x=function(e,t,r,n,i,o,s){var l=e.getAttribute("data-src")||e.getAttribute("src");if(l){if(-1!==E.indexOf(e))return E.splice(E.indexOf(e),1),void(e=null);E.push(e),e.setAttribute("src",""),(n?y:b)(l,i,(function(n,i){if(!i)return E.splice(E.indexOf(e),1),e=null,void s(n);var c=e.getAttribute("id");c&&i.setAttribute("id",c);var u=e.getAttribute("title");u&&i.setAttribute("title",u);var f=e.getAttribute("width");f&&i.setAttribute("width",f);var p=e.getAttribute("height");p&&i.setAttribute("height",p);var d=Array.from(new Set(a(a(a([],(i.getAttribute("class")||"").split(" "),!0),["injected-svg"],!1),(e.getAttribute("class")||"").split(" "),!0))).join(" ").trim();i.setAttribute("class",d);var h=e.getAttribute("style");h&&i.setAttribute("style",h),i.setAttribute("data-src",l);var v=[].filter.call(e.attributes,(function(e){return/^data-\w[\w-]*$/.test(e.name)}));if(Array.prototype.forEach.call(v,(function(e){e.name&&e.value&&i.setAttribute(e.name,e.value)})),r){var m,g,y,b,x={clipPath:["clip-path"],"color-profile":["color-profile"],cursor:["cursor"],filter:["filter"],linearGradient:["fill","stroke"],marker:["marker","marker-start","marker-mid","marker-end"],mask:["mask"],path:[],pattern:["fill","stroke"],radialGradient:["fill","stroke"]};Object.keys(x).forEach((function(e){g=x[e];for(var t=function(e,t){var r;b=(y=m[e].id)+"-"+ ++w,Array.prototype.forEach.call(g,(function(e){for(var t=0,n=(r=i.querySelectorAll("["+e+'*="'+y+'"]')).length;t<n;t++){var o=r[t].getAttribute(e);o&&!o.match(new RegExp('url\\("?#'+y+'"?\\)'))||r[t].setAttribute(e,"url(#"+b+")")}}));for(var n=i.querySelectorAll("[*|href]"),o=[],a=0,s=n.length;a<s;a++){var l=n[a].getAttributeNS(S,"href");l&&l.toString()==="#"+m[e].id&&o.push(n[a])}for(var c=0,u=o.length;c<u;c++)o[c].setAttributeNS(S,"href","#"+b);m[e].id=b},r=0,n=(m=i.querySelectorAll(e+"[id]")).length;r<n;r++)t(r)}))}i.removeAttribute("xmlns:a");for(var j,O,R=i.querySelectorAll("script"),C=[],k=0,G=R.length;k<G;k++)(O=R[k].getAttribute("type"))&&"application/ecmascript"!==O&&"application/javascript"!==O&&"text/javascript"!==O||((j=R[k].innerText||R[k].textContent)&&C.push(j),i.removeChild(R[k]));if(C.length>0&&("always"===t||"once"===t&&!A[l])){for(var q=0,V=C.length;q<V;q++)new Function(C[q])(window);A[l]=!0}var I=i.querySelectorAll("style");if(Array.prototype.forEach.call(I,(function(e){e.textContent+=""})),i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("xmlns:xlink",S),o(i),!e.parentNode)return E.splice(E.indexOf(e),1),e=null,void s(new Error("Parent node is null"));e.parentNode.replaceChild(i,e),E.splice(E.indexOf(e),1),e=null,s(null,i)}))}else s(new Error("Invalid data-src or src attribute"))},j=["afterInjection","beforeInjection","desc","evalScripts","fallback","httpRequestWithCredentials","loading","renumerateIRIElements","src","title","useRequestCache","wrapper"],O="http://www.w3.org/2000/svg",R="http://www.w3.org/1999/xlink",C=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).initialState={hasError:!1,isLoading:!0},t.state=t.initialState,t._isMounted=!1,t.reactWrapper=void 0,t.nonReactWrapper=void 0,t.refCallback=function(e){t.reactWrapper=e},t}var r,a;a=e,(r=t).prototype=Object.create(a.prototype),r.prototype.constructor=r,o(r,a);var s=t.prototype;return s.renderSVG=function(){var e,t=this;if(this.reactWrapper instanceof(e=this.reactWrapper,((null==e?void 0:e.ownerDocument)||document).defaultView||window).Node){var r,n,i=this.props,o=i.desc,a=i.evalScripts,s=i.httpRequestWithCredentials,l=i.renumerateIRIElements,c=i.src,u=i.title,f=i.useRequestCache,p=this.props.onError,d=this.props.beforeInjection,h=this.props.afterInjection,v=this.props.wrapper;"svg"===v?((r=document.createElementNS(O,v)).setAttribute("xmlns",O),r.setAttribute("xmlns:xlink",R),n=document.createElementNS(O,v)):(r=document.createElement(v),n=document.createElement(v)),r.appendChild(n),n.dataset.src=c,this.nonReactWrapper=this.reactWrapper.appendChild(r);var m=function(e){t.removeSVG(),t._isMounted?t.setState((function(){return{hasError:!0,isLoading:!1}}),(function(){p(e)})):p(e)};!function(e,t){var r=void 0===t?{}:t,n=r.afterAll,i=void 0===n?function(){}:n,o=r.afterEach,a=void 0===o?function(){}:o,s=r.beforeEach,l=void 0===s?function(){}:s,c=r.cacheRequests,u=void 0===c||c,f=r.evalScripts,p=void 0===f?"never":f,d=r.httpRequestWithCredentials,h=void 0!==d&&d,v=r.renumerateIRIElements,m=void 0===v||v;if(e&&"length"in e)for(var g=0,y=0,b=e.length;y<b;y++)x(e[y],p,m,u,h,l,(function(t,r){a(t,r),e&&"length"in e&&e.length===++g&&i(g)}));else e?x(e,p,m,u,h,l,(function(t,r){a(t,r),i(1),e=null})):i(0)}(n,{afterEach:function(e,r){e?m(e):t._isMounted&&t.setState((function(){return{isLoading:!1}}),(function(){try{h(r)}catch(e){m(e)}}))},beforeEach:function(e){if(e.setAttribute("role","img"),o){var t=e.querySelector(":scope > desc");t&&e.removeChild(t);var r=document.createElement("desc");r.innerHTML=o,e.prepend(r)}if(u){var n=e.querySelector(":scope > title");n&&e.removeChild(n);var i=document.createElement("title");i.innerHTML=u,e.prepend(i)}try{d(e)}catch(e){m(e)}},cacheRequests:f,evalScripts:a,httpRequestWithCredentials:s,renumerateIRIElements:l})}},s.removeSVG=function(){var e;null!=(e=this.nonReactWrapper)&&e.parentNode&&(this.nonReactWrapper.parentNode.removeChild(this.nonReactWrapper),this.nonReactWrapper=null)},s.componentDidMount=function(){this._isMounted=!0,this.renderSVG()},s.componentDidUpdate=function(e){var t=this;(function(e,t){for(var r in e)if(!(r in t))return!0;for(var n in t)if(e[n]!==t[n])return!0;return!1})(i({},e),this.props)&&this.setState((function(){return t.initialState}),(function(){t.removeSVG(),t.renderSVG()}))},s.componentWillUnmount=function(){this._isMounted=!1,this.removeSVG()},s.render=function(){var e=this.props,t=e.fallback,r=e.loading,o=e.wrapper,a=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(i[r]=e[r]);return i}(e,j);return n.createElement(o,i({},a,{ref:this.refCallback},"svg"===o?{xmlns:O,xmlnsXlink:R}:{}),this.state.isLoading&&r&&n.createElement(r,null),this.state.hasError&&t&&n.createElement(t,null))},t}(n.Component);C.defaultProps={afterInjection:function(){},beforeInjection:function(){},desc:"",evalScripts:"never",fallback:null,httpRequestWithCredentials:!1,loading:null,onError:function(){},renumerateIRIElements:!0,title:"",useRequestCache:!0,wrapper:"div"},e.ReactSVG=C})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactSVG={},e.React)}(this,(function(e,t){"use strict";function r(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var n=r(t);function i(){return i=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},i.apply(null,arguments)}function o(e,t){return o=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},o(e,t)}function a(e,t,r){if(r||2===arguments.length)for(var n,i=0,o=t.length;i<o;i++)!n&&i in t||(n||(n=Array.prototype.slice.call(t,0,i)),n[i]=t[i]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var s,l={};var c=function(){if(s)return l;s=1;var e=/; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g,t=/^[\u000b\u0020-\u007e\u0080-\u00ff]+$/,r=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/,n=/\\([\u000b\u0020-\u00ff])/g,i=/([\\"])/g,o=/^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;function a(e){var n=String(e);if(r.test(n))return n;if(n.length>0&&!t.test(n))throw new TypeError("invalid parameter value");return'"'+n.replace(i,"\\$1")+'"'}function c(e){this.parameters=Object.create(null),this.type=e}return l.format=function(e){if(!e||"object"!=typeof e)throw new TypeError("argument obj is required");var t=e.parameters,n=e.type;if(!n||!o.test(n))throw new TypeError("invalid type");var i=n;if(t&&"object"==typeof t)for(var s,l=Object.keys(t).sort(),c=0;c<l.length;c++){if(!r.test(s=l[c]))throw new TypeError("invalid parameter name");i+="; "+s+"="+a(t[s])}return i},l.parse=function(t){if(!t)throw new TypeError("argument string is required");var r="object"==typeof t?function(e){var t;"function"==typeof e.getHeader?t=e.getHeader("content-type"):"object"==typeof e.headers&&(t=e.headers&&e.headers["content-type"]);if("string"!=typeof t)throw new TypeError("content-type header is missing from object");return t}(t):t;if("string"!=typeof r)throw new TypeError("argument string is required to be a string");var i=r.indexOf(";"),a=-1!==i?r.slice(0,i).trim():r.trim();if(!o.test(a))throw new TypeError("invalid media type");var s=new c(a.toLowerCase());if(-1!==i){var l,u,f;for(e.lastIndex=i;u=e.exec(r);){if(u.index!==i)throw new TypeError("invalid parameter format");i+=u[0].length,l=u[1].toLowerCase(),34===(f=u[2]).charCodeAt(0)&&-1!==(f=f.slice(1,-1)).indexOf("\\")&&(f=f.replace(n,"$1")),s.parameters[l]=f}if(i!==r.length)throw new TypeError("invalid parameter format")}return s},l}(),u=new Map,f=function(e){return e.cloneNode(!0)},p=function(){return"file:"===window.location.protocol},d=function(e,t,r){var n=new XMLHttpRequest;n.onreadystatechange=function(){try{if(!/\.svg/i.test(e)&&2===n.readyState){var t=n.getResponseHeader("Content-Type");if(!t)throw new Error("Content type not found");var i=c.parse(t).type;if("image/svg+xml"!==i&&"text/plain"!==i)throw new Error("Invalid content type: ".concat(i))}if(4===n.readyState){if(404===n.status||null===n.responseXML)throw new Error(p()?"Note: SVG injection ajax calls do not work locally without adjusting security settings in your browser. Or consider using a local webserver.":"Unable to load SVG file: "+e);if(!(200===n.status||p()&&0===n.status))throw new Error("There was a problem injecting the SVG: "+n.status+" "+n.statusText);r(null,n)}}catch(e){if(n.abort(),!(e instanceof Error))throw e;r(e,n)}},n.open("GET",e),n.withCredentials=t,n.overrideMimeType&&n.overrideMimeType("text/xml"),n.send()},h={},v=function(e,t){h[e]=h[e]||[],h[e].push(t)},m=function(e,t,r){if(u.has(e)){var n=u.get(e);if(void 0===n)return void v(e,r);if(n instanceof SVGSVGElement)return void r(null,f(n))}u.set(e,void 0),v(e,r),d(e,t,(function(t,r){var n;t?u.set(e,t):(null===(n=r.responseXML)||void 0===n?void 0:n.documentElement)instanceof SVGSVGElement&&u.set(e,r.responseXML.documentElement),function(e){for(var t=function(t,r){setTimeout((function(){if(Array.isArray(h[e])){var r=u.get(e),n=h[e][t];r instanceof SVGSVGElement&&n(null,f(r)),r instanceof Error&&n(r),t===h[e].length-1&&delete h[e]}}),0)},r=0,n=h[e].length;r<n;r++)t(r)}(e)}))},g=function(e,t,r){d(e,t,(function(e,t){var n;e?r(e):(null===(n=t.responseXML)||void 0===n?void 0:n.documentElement)instanceof SVGSVGElement&&r(null,t.responseXML.documentElement)}))},y=0,w=[],b={},E="http://www.w3.org/1999/xlink",A=function(e,t,r,n,i,o,s){var l=e.getAttribute("data-src")||e.getAttribute("src");if(l){if(-1!==w.indexOf(e))return w.splice(w.indexOf(e),1),void(e=null);w.push(e),e.setAttribute("src",""),(n?m:g)(l,i,(function(n,i){if(!i)return w.splice(w.indexOf(e),1),e=null,void s(n);var c=e.getAttribute("id");c&&i.setAttribute("id",c);var u=e.getAttribute("title");u&&i.setAttribute("title",u);var f=e.getAttribute("width");f&&i.setAttribute("width",f);var p=e.getAttribute("height");p&&i.setAttribute("height",p);var d=Array.from(new Set(a(a(a([],(i.getAttribute("class")||"").split(" "),!0),["injected-svg"],!1),(e.getAttribute("class")||"").split(" "),!0))).join(" ").trim();i.setAttribute("class",d);var h=e.getAttribute("style");h&&i.setAttribute("style",h),i.setAttribute("data-src",l);var v=[].filter.call(e.attributes,(function(e){return/^data-\w[\w-]*$/.test(e.name)}));if(Array.prototype.forEach.call(v,(function(e){e.name&&e.value&&i.setAttribute(e.name,e.value)})),r){var m,g,A,S,x={clipPath:["clip-path"],"color-profile":["color-profile"],cursor:["cursor"],filter:["filter"],linearGradient:["fill","stroke"],marker:["marker","marker-start","marker-mid","marker-end"],mask:["mask"],path:[],pattern:["fill","stroke"],radialGradient:["fill","stroke"]};Object.keys(x).forEach((function(e){g=x[e];for(var t=function(e,t){var r;S=(A=m[e].id)+"-"+ ++y,Array.prototype.forEach.call(g,(function(e){for(var t=0,n=(r=i.querySelectorAll("["+e+'*="'+A+'"]')).length;t<n;t++){var o=r[t].getAttribute(e);o&&!o.match(new RegExp('url\\("?#'+A+'"?\\)'))||r[t].setAttribute(e,"url(#"+S+")")}}));for(var n=i.querySelectorAll("[*|href]"),o=[],a=0,s=n.length;a<s;a++){var l=n[a].getAttributeNS(E,"href");l&&l.toString()==="#"+m[e].id&&o.push(n[a])}for(var c=0,u=o.length;c<u;c++)o[c].setAttributeNS(E,"href","#"+S);m[e].id=S},r=0,n=(m=i.querySelectorAll(e+"[id]")).length;r<n;r++)t(r)}))}i.removeAttribute("xmlns:a");for(var j,R,C=i.querySelectorAll("script"),O=[],k=0,G=C.length;k<G;k++)(R=C[k].getAttribute("type"))&&"application/ecmascript"!==R&&"application/javascript"!==R&&"text/javascript"!==R||((j=C[k].innerText||C[k].textContent)&&O.push(j),i.removeChild(C[k]));if(O.length>0&&("always"===t||"once"===t&&!b[l])){for(var q=0,T=O.length;q<T;q++)new Function(O[q])(window);b[l]=!0}var V=i.querySelectorAll("style");if(Array.prototype.forEach.call(V,(function(e){e.textContent+=""})),i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("xmlns:xlink",E),o(i),!e.parentNode)return w.splice(w.indexOf(e),1),e=null,void s(new Error("Parent node is null"));e.parentNode.replaceChild(i,e),w.splice(w.indexOf(e),1),e=null,s(null,i)}))}else s(new Error("Invalid data-src or src attribute"))},S=["afterInjection","beforeInjection","desc","evalScripts","fallback","httpRequestWithCredentials","loading","renumerateIRIElements","src","title","useRequestCache","wrapper"],x="http://www.w3.org/2000/svg",j="http://www.w3.org/1999/xlink",R=function(e){function t(){for(var t,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return(t=e.call.apply(e,[this].concat(n))||this).initialState={hasError:!1,isLoading:!0},t.state=t.initialState,t._isMounted=!1,t.reactWrapper=void 0,t.nonReactWrapper=void 0,t.refCallback=function(e){t.reactWrapper=e},t}var r,a;a=e,(r=t).prototype=Object.create(a.prototype),r.prototype.constructor=r,o(r,a);var s=t.prototype;return s.renderSVG=function(){var e,t=this;if(this.reactWrapper instanceof(e=this.reactWrapper,((null==e?void 0:e.ownerDocument)||document).defaultView||window).Node){var r,n,i=this.props,o=i.desc,a=i.evalScripts,s=i.httpRequestWithCredentials,l=i.renumerateIRIElements,c=i.src,u=i.title,f=i.useRequestCache,p=this.props.onError,d=this.props.beforeInjection,h=this.props.afterInjection,v=this.props.wrapper;"svg"===v?((r=document.createElementNS(x,v)).setAttribute("xmlns",x),r.setAttribute("xmlns:xlink",j),n=document.createElementNS(x,v)):(r=document.createElement(v),n=document.createElement(v)),r.appendChild(n),n.dataset.src=c,this.nonReactWrapper=this.reactWrapper.appendChild(r);var m=function(e){t.removeSVG(),t._isMounted?t.setState((function(){return{hasError:!0,isLoading:!1}}),(function(){p(e)})):p(e)};!function(e,t){var r=void 0===t?{}:t,n=r.afterAll,i=void 0===n?function(){}:n,o=r.afterEach,a=void 0===o?function(){}:o,s=r.beforeEach,l=void 0===s?function(){}:s,c=r.cacheRequests,u=void 0===c||c,f=r.evalScripts,p=void 0===f?"never":f,d=r.httpRequestWithCredentials,h=void 0!==d&&d,v=r.renumerateIRIElements,m=void 0===v||v;if(e&&"length"in e)for(var g=0,y=0,w=e.length;y<w;y++)A(e[y],p,m,u,h,l,(function(t,r){a(t,r),e&&"length"in e&&e.length===++g&&i(g)}));else e?A(e,p,m,u,h,l,(function(t,r){a(t,r),i(1),e=null})):i(0)}(n,{afterEach:function(e,r){e?m(e):t._isMounted&&t.setState((function(){return{isLoading:!1}}),(function(){try{h(r)}catch(e){m(e)}}))},beforeEach:function(e){if(e.setAttribute("role","img"),o){var t=e.querySelector(":scope > desc");t&&e.removeChild(t);var r=document.createElement("desc");r.innerHTML=o,e.prepend(r)}if(u){var n=e.querySelector(":scope > title");n&&e.removeChild(n);var i=document.createElement("title");i.innerHTML=u,e.prepend(i)}try{d(e)}catch(e){m(e)}},cacheRequests:f,evalScripts:a,httpRequestWithCredentials:s,renumerateIRIElements:l})}},s.removeSVG=function(){var e;null!=(e=this.nonReactWrapper)&&e.parentNode&&(this.nonReactWrapper.parentNode.removeChild(this.nonReactWrapper),this.nonReactWrapper=null)},s.componentDidMount=function(){this._isMounted=!0,this.renderSVG()},s.componentDidUpdate=function(e){var t=this;(function(e,t){for(var r in e)if(!(r in t))return!0;for(var n in t)if(e[n]!==t[n])return!0;return!1})(i({},e),this.props)&&this.setState((function(){return t.initialState}),(function(){t.removeSVG(),t.renderSVG()}))},s.componentWillUnmount=function(){this._isMounted=!1,this.removeSVG()},s.render=function(){var e=this.props,t=e.fallback,r=e.loading,o=e.wrapper,a=function(e,t){if(null==e)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.includes(n))continue;r[n]=e[n]}return r}(e,S);return n.createElement(o,i({},a,{ref:this.refCallback},"svg"===o?{xmlns:x,xmlnsXlink:j}:{}),this.state.isLoading&&r&&n.createElement(r,null),this.state.hasError&&t&&n.createElement(t,null))},t}(n.Component);R.defaultProps={afterInjection:function(){},beforeInjection:function(){},desc:"",evalScripts:"never",fallback:null,httpRequestWithCredentials:!1,loading:null,onError:function(){},renumerateIRIElements:!0,title:"",useRequestCache:!0,wrapper:"div"},e.ReactSVG=R})); | ||
//# sourceMappingURL=react-svg.umd.production.js.map |
{ | ||
"name": "react-svg", | ||
"version": "16.1.34", | ||
"version": "16.2.0", | ||
"description": "A React component that injects SVG into the DOM.", | ||
@@ -58,51 +58,54 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@babel/runtime": "^7.24.1", | ||
"@babel/runtime": "^7.26.0", | ||
"@tanem/svg-injector": "^10.1.68", | ||
"@types/prop-types": "^15.7.12", | ||
"@types/prop-types": "^15.7.13", | ||
"prop-types": "^15.8.1" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.24.3", | ||
"@babel/plugin-transform-runtime": "7.24.3", | ||
"@babel/preset-env": "7.24.3", | ||
"@babel/preset-react": "7.24.1", | ||
"@babel/core": "7.26.0", | ||
"@babel/plugin-transform-runtime": "7.25.9", | ||
"@babel/preset-env": "7.26.0", | ||
"@babel/preset-react": "7.25.9", | ||
"@eslint/compat": "1.2.3", | ||
"@eslint/eslintrc": "3.2.0", | ||
"@eslint/js": "9.15.0", | ||
"@rollup/plugin-babel": "6.0.4", | ||
"@rollup/plugin-commonjs": "25.0.7", | ||
"@rollup/plugin-node-resolve": "15.2.3", | ||
"@rollup/plugin-replace": "5.0.5", | ||
"@rollup/plugin-commonjs": "28.0.1", | ||
"@rollup/plugin-node-resolve": "15.3.0", | ||
"@rollup/plugin-replace": "6.0.1", | ||
"@rollup/plugin-terser": "0.4.4", | ||
"@testing-library/react": "14.2.2", | ||
"@testing-library/react": "16.0.1", | ||
"@types/faker": "5.5.9", | ||
"@types/jest": "29.5.12", | ||
"@types/jsdom": "21.1.6", | ||
"@types/react": "18.2.69", | ||
"@types/react-dom": "18.2.22", | ||
"@types/jest": "29.5.14", | ||
"@types/jsdom": "21.1.7", | ||
"@types/node": "22.9.0", | ||
"@types/react": "18.3.12", | ||
"@types/react-dom": "18.3.1", | ||
"@types/shelljs": "0.8.15", | ||
"@typescript-eslint/eslint-plugin": "7.3.1", | ||
"@typescript-eslint/parser": "7.3.1", | ||
"@typescript-eslint/eslint-plugin": "8.15.0", | ||
"@typescript-eslint/parser": "8.15.0", | ||
"babel-core": "6.26.3", | ||
"babel-plugin-transform-react-remove-prop-types": "0.4.24", | ||
"eslint": "8.57.0", | ||
"eslint": "9.15.0", | ||
"eslint-config-prettier": "9.1.0", | ||
"eslint-plugin-react": "7.34.1", | ||
"eslint-plugin-react-hooks": "4.6.0", | ||
"eslint-plugin-simple-import-sort": "12.0.0", | ||
"eslint-plugin-react": "7.37.2", | ||
"eslint-plugin-react-hooks": "5.0.0", | ||
"eslint-plugin-simple-import-sort": "12.1.1", | ||
"faker": "5.5.3", | ||
"jest": "29.7.0", | ||
"jest-environment-jsdom": "29.7.0", | ||
"jest-prettyhtml-matchers": "1.17.13", | ||
"nock": "13.5.4", | ||
"npm-run-all2": "6.1.2", | ||
"prettier": "3.2.5", | ||
"react": "18.2.0", | ||
"react-dom": "18.2.0", | ||
"rollup": "4.13.0", | ||
"rollup-plugin-sourcemaps": "0.6.3", | ||
"jest-prettyhtml-matchers": "1.17.14", | ||
"nock": "13.5.6", | ||
"npm-run-all2": "7.0.1", | ||
"prettier": "3.3.3", | ||
"react": "18.3.1", | ||
"react-dom": "18.3.1", | ||
"rollup": "4.27.2", | ||
"shelljs": "0.8.5", | ||
"shx": "0.3.4", | ||
"tanem-scripts": "7.0.26", | ||
"ts-jest": "29.1.2", | ||
"tanem-scripts": "7.0.27", | ||
"ts-jest": "29.2.5", | ||
"ts-node": "10.9.2", | ||
"typescript": "5.4.3" | ||
"typescript": "5.6.3" | ||
} | ||
} |
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
Sorry, the diff of this file is not supported yet
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
1468
260366
45
Updated@babel/runtime@^7.26.0
Updated@types/prop-types@^15.7.13