react-helmet-async
Advanced tools
Comparing version 0.3.0-beta.3 to 1.0.0-beta.0
@@ -1,2 +0,2 @@ | ||
function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("react-fast-compare")),r=e(require("invariant")),n=e(require("prop-types")),o=require("react"),i=e(o),a=e(require("shallowequal")),s={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},c=Object.keys(s).map(function(e){return s[e]}),u={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},l=Object.keys(u).reduce(function(e,t){return e[u[t]]=t,e},{}),p=function(e,t){for(var r=e.length-1;r>=0;r-=1){var n=e[r];if(Object.prototype.hasOwnProperty.call(n,t))return n[t]}return null},f=function(e){var t=p(e,s.TITLE),r=p(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,function(){return t});var n=p(e,"defaultTitle");return t||n||void 0},d=function(e){return p(e,"onChangeClientState")||function(){}},h=function(e,t){return t.filter(function(t){return void 0!==t[e]}).map(function(t){return t[e]}).reduce(function(e,t){return Object.assign({},e,t)},{})},y=function(e,t){return t.filter(function(e){return void 0!==e[s.BASE]}).map(function(e){return e[s.BASE]}).reverse().reduce(function(t,r){if(!t.length)for(var n=Object.keys(r),o=0;o<n.length;o+=1){var i=n[o].toLowerCase();if(-1!==e.indexOf(i)&&r[i])return t.concat(r)}return t},[])},m=function(e,t,r){var n={};return r.filter(function(t){return!!Array.isArray(t[e])||(void 0!==t[e]&&console&&"function"==typeof console.warn&&console.warn("Helmet: "+e+' should be of type "Array". Instead found type "'+typeof t[e]+'"'),!1)}).map(function(t){return t[e]}).reverse().reduce(function(e,r){var o={};r.filter(function(e){for(var r,i=Object.keys(e),a=0;a<i.length;a+=1){var s=i[a],c=s.toLowerCase();-1===t.indexOf(c)||"rel"===r&&"canonical"===e[r].toLowerCase()||"rel"===c&&"stylesheet"===e[c].toLowerCase()||(r=c),-1===t.indexOf(s)||"innerHTML"!==s&&"cssText"!==s&&"itemprop"!==s||(r=s)}if(!r||!e[r])return!1;var u=e[r].toLowerCase();return n[r]||(n[r]={}),o[r]||(o[r]={}),!n[r][u]&&(o[r][u]=!0,!0)}).reverse().forEach(function(t){return e.push(t)});for(var i=Object.keys(o),a=0;a<i.length;a+=1){var s=i[a],c=Object.assign({},n[s],o[s]);n[s]=c}return e},[]).reverse()},T=function(e){return Array.isArray(e)?e.join(""):e},b=[s.NOSCRIPT,s.SCRIPT,s.STYLE],g=function(e,t){return void 0===t&&(t=!0),!1===t?String(e):String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},v=function(e){return Object.keys(e).reduce(function(t,r){var n=void 0!==e[r]?r+'="'+e[r]+'"':""+r;return t?t+" "+n:n},"")},A=function(e,t){return void 0===t&&(t={}),Object.keys(e).reduce(function(t,r){return t[u[r]||r]=e[r],t},t)},C=function(e,t,r){switch(e){case s.TITLE:return{toComponent:function(){return r=A(t.titleAttributes,{key:e=t.title,"data-rh":!0}),[i.createElement(s.TITLE,r,e)];var e,r},toString:function(){return function(e,r,n,o){var i=v(t.titleAttributes),a=T(r);return i?"<"+e+' data-rh="true" '+i+">"+g(a,o)+"</"+e+">":"<"+e+' data-rh="true">'+g(a,o)+"</"+e+">"}(e,t.title,0,r)}};case"bodyAttributes":case"htmlAttributes":return{toComponent:function(){return A(t)},toString:function(){return v(t)}};default:return{toComponent:function(){return function(e,t){return t.map(function(t,r){var n={key:r,"data-rh":!0};return Object.keys(t).forEach(function(e){var r=u[e]||e;"innerHTML"===r||"cssText"===r?n.dangerouslySetInnerHTML={__html:t.innerHTML||t.cssText}:n[r]=t[e]}),i.createElement(e,n)})}(e,t)},toString:function(){return function(e,t,r){return t.reduce(function(t,n){var o=Object.keys(n).filter(function(e){return!("innerHTML"===e||"cssText"===e)}).reduce(function(e,t){var o=void 0===n[t]?t:t+'="'+g(n[t],r)+'"';return e?e+" "+o:o},""),i=n.innerHTML||n.cssText||"",a=-1===b.indexOf(e);return t+"<"+e+' data-rh="true" '+o+(a?"/>":">"+i+"</"+e+">")},"")}(e,t,r)}}}},O=function(e){var t=e.bodyAttributes,r=e.encode,n=e.htmlAttributes,o=e.linkTags,i=e.metaTags,a=e.noscriptTags,c=e.scriptTags,u=e.styleTags,l=e.title;void 0===l&&(l="");var p=e.titleAttributes;return{base:C(s.BASE,e.baseTag,r),bodyAttributes:C("bodyAttributes",t,r),htmlAttributes:C("htmlAttributes",n,r),link:C(s.LINK,o,r),meta:C(s.META,i,r),noscript:C(s.NOSCRIPT,a,r),script:C(s.SCRIPT,c,r),style:C(s.STYLE,u,r),title:C(s.TITLE,{title:l,titleAttributes:p},r)}},j=i.createContext({}),E=n.shape({setHelmet:n.func,helmetInstances:n.shape({get:n.func,add:n.func,remove:n.func})}),S="undefined"!=typeof document,I=function(e){function t(r){var n=this;e.call(this,r),this.instances=[],this.value={setHelmet:function(e){n.props.context.helmet=e},helmetInstances:{get:function(){return n.instances},add:function(e){n.instances.push(e)},remove:function(e){var t=n.instances.indexOf(e);n.instances.splice(t,1)}}},t.canUseDOM||(r.context.helmet=O({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.render=function(){return i.createElement(j.Provider,{value:this.value},this.props.children)},t}(o.Component);I.canUseDOM=S,I.propTypes={context:n.shape({helmet:n.shape()}),children:n.node.isRequired},I.defaultProps={context:{}},I.displayName="HelmetProvider";var P=function(e,t){var r,n=document.head||document.querySelector(s.HEAD),o=n.querySelectorAll(e+"[data-rh]"),i=[].slice.call(o),a=[];return t&&t.length&&t.forEach(function(t){var n=document.createElement(e);for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&("innerHTML"===o?n.innerHTML=t.innerHTML:"cssText"===o?n.styleSheet?n.styleSheet.cssText=t.cssText:n.appendChild(document.createTextNode(t.cssText)):n.setAttribute(o,void 0===t[o]?"":t[o]));n.setAttribute("data-rh","true"),i.some(function(e,t){return r=t,n.isEqualNode(e)})?i.splice(r,1):a.push(n)}),i.forEach(function(e){return e.parentNode.removeChild(e)}),a.forEach(function(e){return n.appendChild(e)}),{oldTags:i,newTags:a}},x=function(e,t){var r=document.getElementsByTagName(e)[0];if(r){for(var n=r.getAttribute("data-rh"),o=n?n.split(","):[],i=[].concat(o),a=Object.keys(t),s=0;s<a.length;s+=1){var c=a[s],u=t[c]||"";r.getAttribute(c)!==u&&r.setAttribute(c,u),-1===o.indexOf(c)&&o.push(c);var l=i.indexOf(c);-1!==l&&i.splice(l,1)}for(var p=i.length-1;p>=0;p-=1)r.removeAttribute(i[p]);o.length===i.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==a.join(",")&&r.setAttribute("data-rh",a.join(","))}},L=function(e,t){var r=e.baseTag,n=e.htmlAttributes,o=e.linkTags,i=e.metaTags,a=e.noscriptTags,c=e.onChangeClientState,u=e.scriptTags,l=e.styleTags,p=e.title,f=e.titleAttributes;x(s.BODY,e.bodyAttributes),x(s.HTML,n),function(e,t){void 0!==e&&document.title!==e&&(document.title=T(e)),x(s.TITLE,t)}(p,f);var d={baseTag:P(s.BASE,r),linkTags:P(s.LINK,o),metaTags:P(s.META,i),noscriptTags:P(s.NOSCRIPT,a),scriptTags:P(s.SCRIPT,u),styleTags:P(s.STYLE,l)},h={},y={};Object.keys(d).forEach(function(e){var t=d[e],r=t.newTags,n=t.oldTags;r.length&&(h[e]=r),n.length&&(y[e]=d[e].oldTags)}),t&&t(),c(e,h,y)},w=null,H=function(e){function t(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];e.apply(this,t),this.rendered=!1}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.shouldComponentUpdate=function(e){return!a(e,this.props)},t.prototype.componentDidUpdate=function(){this.emitChange()},t.prototype.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},t.prototype.emitChange=function(){var e,t,r=this.props.context,n=r.setHelmet,o=null,i=(e=r.helmetInstances.get().map(function(e){var t=Object.assign({},e.props);return delete t.context,t}),{baseTag:y(["href"],e),bodyAttributes:h("bodyAttributes",e),defer:p(e,"defer"),encode:p(e,"encodeSpecialCharacters"),htmlAttributes:h("htmlAttributes",e),linkTags:m(s.LINK,["rel","href"],e),metaTags:m(s.META,["name","charset","http-equiv","property","itemprop"],e),noscriptTags:m(s.NOSCRIPT,["innerHTML"],e),onChangeClientState:d(e),scriptTags:m(s.SCRIPT,["src","innerHTML"],e),styleTags:m(s.STYLE,["cssText"],e),title:f(e),titleAttributes:h("titleAttributes",e)});I.canUseDOM?(t=i,w&&cancelAnimationFrame(w),t.defer?w=requestAnimationFrame(function(){L(t,function(){w=null})}):(L(t),w=null)):O&&(o=O(i)),n(o)},t.prototype.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},t.prototype.render=function(){return this.init(),null},t}(o.Component);function k(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&-1===t.indexOf(n)&&(r[n]=e[n]);return r}H.propTypes={context:E.isRequired};var M=function(e){function n(){e.apply(this,arguments)}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.shouldComponentUpdate=function(e){return!t(this.props,e)},n.prototype.mapNestedChildrenToProps=function(e,t){if(!t)return null;switch(e.type){case s.SCRIPT:case s.NOSCRIPT:return{innerHTML:t};case s.STYLE:return{cssText:t};default:throw new Error("<"+e.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")}},n.prototype.flattenArrayTypeChildren=function(e){var t,r=e.child,n=e.arrayTypeChildren;return Object.assign({},n,((t={})[r.type]=(n[r.type]||[]).concat([Object.assign({},e.newChildProps,this.mapNestedChildrenToProps(r,e.nestedChildren))]),t))},n.prototype.mapObjectTypeChildren=function(e){var t,r,n=e.child,o=e.newProps,i=e.newChildProps,a=e.nestedChildren;switch(n.type){case s.TITLE:return Object.assign({},o,((t={})[n.type]=a,t),{titleAttributes:Object.assign({},i)});case s.BODY:return Object.assign({},o,{bodyAttributes:Object.assign({},i)});case s.HTML:return Object.assign({},o,{htmlAttributes:Object.assign({},i)});default:return Object.assign({},o,((r={})[n.type]=Object.assign({},i),r))}},n.prototype.mapArrayTypeChildrenToProps=function(e,t){var r=Object.assign({},t);return Object.keys(e).forEach(function(t){var n;r=Object.assign({},r,((n={})[t]=e[t],n))}),r},n.prototype.warnOnInvalidChildren=function(e,t){return r(c.some(function(t){return e.type===t}),"function"==typeof e.type?"You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.":"Only elements types "+c.join(", ")+" are allowed. Helmet does not support rendering <"+e.type+"> elements. Refer to our API for more information."),r(!t||"string"==typeof t||Array.isArray(t)&&!t.some(function(e){return"string"!=typeof e}),"Helmet expects a string as a child of <"+e.type+">. Did you forget to wrap your children in braces? ( <"+e.type+">{``}</"+e.type+"> ) Refer to our API for more information."),!0},n.prototype.mapChildrenToProps=function(e,t){var r=this,n={};return i.Children.forEach(e,function(e){if(e&&e.props){var o=e.props,i=o.children,a=k(o,["children"]),c=Object.keys(a).reduce(function(e,t){return e[l[t]||t]=a[t],e},{}),u=e.type;switch("symbol"==typeof u?u=u.toString():r.warnOnInvalidChildren(e,i),u){case s.FRAGMENT:t=r.mapChildrenToProps(i,t);break;case s.LINK:case s.META:case s.NOSCRIPT:case s.SCRIPT:case s.STYLE:n=r.flattenArrayTypeChildren({child:e,arrayTypeChildren:n,newChildProps:c,nestedChildren:i});break;default:t=r.mapObjectTypeChildren({child:e,newProps:t,newChildProps:c,nestedChildren:i})}}}),this.mapArrayTypeChildrenToProps(n,t)},n.prototype.render=function(){var e=this.props,t=e.children,r=k(e,["children"]),n=Object.assign({},r);return t&&(n=this.mapChildrenToProps(t,n)),i.createElement(j.Consumer,null,function(e){return i.createElement(H,Object.assign({},n,{context:e}))})},n}(o.Component);M.propTypes={base:n.object,bodyAttributes:n.object,children:n.oneOfType([n.arrayOf(n.node),n.node]),defaultTitle:n.string,defer:n.bool,encodeSpecialCharacters:n.bool,htmlAttributes:n.object,link:n.arrayOf(n.object),meta:n.arrayOf(n.object),noscript:n.arrayOf(n.object),onChangeClientState:n.func,script:n.arrayOf(n.object),style:n.arrayOf(n.object),title:n.string,titleAttributes:n.object,titleTemplate:n.string},M.defaultProps={defer:!0,encodeSpecialCharacters:!0},M.displayName="Helmet",exports.default=M,exports.HelmetProvider=I; | ||
function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var t=e(require("react-fast-compare")),r=e(require("invariant")),n=e(require("prop-types")),o=require("react"),i=e(o),a=e(require("shallowequal")),s={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},c=Object.keys(s).map(function(e){return s[e]}),u={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},l=Object.keys(u).reduce(function(e,t){return e[u[t]]=t,e},{}),p=function(e,t){for(var r=e.length-1;r>=0;r-=1){var n=e[r];if(Object.prototype.hasOwnProperty.call(n,t))return n[t]}return null},f=function(e){var t=p(e,s.TITLE),r=p(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,function(){return t});var n=p(e,"defaultTitle");return t||n||void 0},d=function(e){return p(e,"onChangeClientState")||function(){}},h=function(e,t){return t.filter(function(t){return void 0!==t[e]}).map(function(t){return t[e]}).reduce(function(e,t){return Object.assign({},e,t)},{})},y=function(e,t){return t.filter(function(e){return void 0!==e[s.BASE]}).map(function(e){return e[s.BASE]}).reverse().reduce(function(t,r){if(!t.length)for(var n=Object.keys(r),o=0;o<n.length;o+=1){var i=n[o].toLowerCase();if(-1!==e.indexOf(i)&&r[i])return t.concat(r)}return t},[])},m=function(e,t,r){var n={};return r.filter(function(t){return!!Array.isArray(t[e])||(void 0!==t[e]&&console&&"function"==typeof console.warn&&console.warn("Helmet: "+e+' should be of type "Array". Instead found type "'+typeof t[e]+'"'),!1)}).map(function(t){return t[e]}).reverse().reduce(function(e,r){var o={};r.filter(function(e){for(var r,i=Object.keys(e),a=0;a<i.length;a+=1){var s=i[a],c=s.toLowerCase();-1===t.indexOf(c)||"rel"===r&&"canonical"===e[r].toLowerCase()||"rel"===c&&"stylesheet"===e[c].toLowerCase()||(r=c),-1===t.indexOf(s)||"innerHTML"!==s&&"cssText"!==s&&"itemprop"!==s||(r=s)}if(!r||!e[r])return!1;var u=e[r].toLowerCase();return n[r]||(n[r]={}),o[r]||(o[r]={}),!n[r][u]&&(o[r][u]=!0,!0)}).reverse().forEach(function(t){return e.push(t)});for(var i=Object.keys(o),a=0;a<i.length;a+=1){var s=i[a],c=Object.assign({},n[s],o[s]);n[s]=c}return e},[]).reverse()},T=function(e){return Array.isArray(e)?e.join(""):e},b=[s.NOSCRIPT,s.SCRIPT,s.STYLE],g=function(e,t){return void 0===t&&(t=!0),!1===t?String(e):String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},v=function(e){return Object.keys(e).reduce(function(t,r){var n=void 0!==e[r]?r+'="'+e[r]+'"':""+r;return t?t+" "+n:n},"")},A=function(e,t){return void 0===t&&(t={}),Object.keys(e).reduce(function(t,r){return t[u[r]||r]=e[r],t},t)},C=function(e,t,r){switch(e){case s.TITLE:return{toComponent:function(){return r=A(t.titleAttributes,{key:e=t.title,"data-rh":!0}),[i.createElement(s.TITLE,r,e)];var e,r},toString:function(){return function(e,r,n,o){var i=v(t.titleAttributes),a=T(r);return i?"<"+e+' data-rh="true" '+i+">"+g(a,o)+"</"+e+">":"<"+e+' data-rh="true">'+g(a,o)+"</"+e+">"}(e,t.title,0,r)}};case"bodyAttributes":case"htmlAttributes":return{toComponent:function(){return A(t)},toString:function(){return v(t)}};default:return{toComponent:function(){return function(e,t){return t.map(function(t,r){var n={key:r,"data-rh":!0};return Object.keys(t).forEach(function(e){var r=u[e]||e;"innerHTML"===r||"cssText"===r?n.dangerouslySetInnerHTML={__html:t.innerHTML||t.cssText}:n[r]=t[e]}),i.createElement(e,n)})}(e,t)},toString:function(){return function(e,t,r){return t.reduce(function(t,n){var o=Object.keys(n).filter(function(e){return!("innerHTML"===e||"cssText"===e)}).reduce(function(e,t){var o=void 0===n[t]?t:t+'="'+g(n[t],r)+'"';return e?e+" "+o:o},""),i=n.innerHTML||n.cssText||"",a=-1===b.indexOf(e);return t+"<"+e+' data-rh="true" '+o+(a?"/>":">"+i+"</"+e+">")},"")}(e,t,r)}}}},O=function(e){var t=e.bodyAttributes,r=e.encode,n=e.htmlAttributes,o=e.linkTags,i=e.metaTags,a=e.noscriptTags,c=e.scriptTags,u=e.styleTags,l=e.title;void 0===l&&(l="");var p=e.titleAttributes;return{base:C(s.BASE,e.baseTag,r),bodyAttributes:C("bodyAttributes",t,r),htmlAttributes:C("htmlAttributes",n,r),link:C(s.LINK,o,r),meta:C(s.META,i,r),noscript:C(s.NOSCRIPT,a,r),script:C(s.SCRIPT,c,r),style:C(s.STYLE,u,r),title:C(s.TITLE,{title:l,titleAttributes:p},r)}},j=i.createContext({}),E=n.shape({setHelmet:n.func,helmetInstances:n.shape({get:n.func,add:n.func,remove:n.func})}),S="undefined"!=typeof document,I=function(e){function t(r){var n=this;e.call(this,r),this.instances=[],this.value={setHelmet:function(e){n.props.context.helmet=e},helmetInstances:{get:function(){return n.instances},add:function(e){n.instances.push(e)},remove:function(e){var t=n.instances.indexOf(e);n.instances.splice(t,1)}}},t.canUseDOM||(r.context.helmet=O({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.render=function(){return i.createElement(j.Provider,{value:this.value},this.props.children)},t}(o.Component);I.canUseDOM=S,I.propTypes={context:n.shape({helmet:n.shape()}),children:n.node.isRequired},I.defaultProps={context:{}},I.displayName="HelmetProvider";var P=function(e,t){var r,n=document.head||document.querySelector(s.HEAD),o=n.querySelectorAll(e+"[data-rh]"),i=[].slice.call(o),a=[];return t&&t.length&&t.forEach(function(t){var n=document.createElement(e);for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&("innerHTML"===o?n.innerHTML=t.innerHTML:"cssText"===o?n.styleSheet?n.styleSheet.cssText=t.cssText:n.appendChild(document.createTextNode(t.cssText)):n.setAttribute(o,void 0===t[o]?"":t[o]));n.setAttribute("data-rh","true"),i.some(function(e,t){return r=t,n.isEqualNode(e)})?i.splice(r,1):a.push(n)}),i.forEach(function(e){return e.parentNode.removeChild(e)}),a.forEach(function(e){return n.appendChild(e)}),{oldTags:i,newTags:a}},x=function(e,t){var r=document.getElementsByTagName(e)[0];if(r){for(var n=r.getAttribute("data-rh"),o=n?n.split(","):[],i=[].concat(o),a=Object.keys(t),s=0;s<a.length;s+=1){var c=a[s],u=t[c]||"";r.getAttribute(c)!==u&&r.setAttribute(c,u),-1===o.indexOf(c)&&o.push(c);var l=i.indexOf(c);-1!==l&&i.splice(l,1)}for(var p=i.length-1;p>=0;p-=1)r.removeAttribute(i[p]);o.length===i.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==a.join(",")&&r.setAttribute("data-rh",a.join(","))}},L=function(e,t){var r=e.baseTag,n=e.htmlAttributes,o=e.linkTags,i=e.metaTags,a=e.noscriptTags,c=e.onChangeClientState,u=e.scriptTags,l=e.styleTags,p=e.title,f=e.titleAttributes;x(s.BODY,e.bodyAttributes),x(s.HTML,n),function(e,t){void 0!==e&&document.title!==e&&(document.title=T(e)),x(s.TITLE,t)}(p,f);var d={baseTag:P(s.BASE,r),linkTags:P(s.LINK,o),metaTags:P(s.META,i),noscriptTags:P(s.NOSCRIPT,a),scriptTags:P(s.SCRIPT,u),styleTags:P(s.STYLE,l)},h={},y={};Object.keys(d).forEach(function(e){var t=d[e],r=t.newTags,n=t.oldTags;r.length&&(h[e]=r),n.length&&(y[e]=d[e].oldTags)}),t&&t(),c(e,h,y)},w=null,H=function(e){function t(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];e.apply(this,t),this.rendered=!1}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.shouldComponentUpdate=function(e){return!a(e,this.props)},t.prototype.componentDidUpdate=function(){this.emitChange()},t.prototype.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},t.prototype.emitChange=function(){var e,t,r=this.props.context,n=r.setHelmet,o=null,i=(e=r.helmetInstances.get().map(function(e){var t=Object.assign({},e.props);return delete t.context,t}),{baseTag:y(["href"],e),bodyAttributes:h("bodyAttributes",e),defer:p(e,"defer"),encode:p(e,"encodeSpecialCharacters"),htmlAttributes:h("htmlAttributes",e),linkTags:m(s.LINK,["rel","href"],e),metaTags:m(s.META,["name","charset","http-equiv","property","itemprop"],e),noscriptTags:m(s.NOSCRIPT,["innerHTML"],e),onChangeClientState:d(e),scriptTags:m(s.SCRIPT,["src","innerHTML"],e),styleTags:m(s.STYLE,["cssText"],e),title:f(e),titleAttributes:h("titleAttributes",e)});I.canUseDOM?(t=i,w&&cancelAnimationFrame(w),t.defer?w=requestAnimationFrame(function(){L(t,function(){w=null})}):(L(t),w=null)):O&&(o=O(i)),n(o)},t.prototype.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},t.prototype.render=function(){return this.init(),null},t}(o.Component);function k(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&-1===t.indexOf(n)&&(r[n]=e[n]);return r}H.propTypes={context:E.isRequired};var M=function(e){function n(){e.apply(this,arguments)}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.shouldComponentUpdate=function(e){return!t(this.props,e)},n.prototype.mapNestedChildrenToProps=function(e,t){if(!t)return null;switch(e.type){case s.SCRIPT:case s.NOSCRIPT:return{innerHTML:t};case s.STYLE:return{cssText:t};default:throw new Error("<"+e.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")}},n.prototype.flattenArrayTypeChildren=function(e){var t,r=e.child,n=e.arrayTypeChildren;return Object.assign({},n,((t={})[r.type]=(n[r.type]||[]).concat([Object.assign({},e.newChildProps,this.mapNestedChildrenToProps(r,e.nestedChildren))]),t))},n.prototype.mapObjectTypeChildren=function(e){var t,r,n=e.child,o=e.newProps,i=e.newChildProps,a=e.nestedChildren;switch(n.type){case s.TITLE:return Object.assign({},o,((t={})[n.type]=a,t),{titleAttributes:Object.assign({},i)});case s.BODY:return Object.assign({},o,{bodyAttributes:Object.assign({},i)});case s.HTML:return Object.assign({},o,{htmlAttributes:Object.assign({},i)});default:return Object.assign({},o,((r={})[n.type]=Object.assign({},i),r))}},n.prototype.mapArrayTypeChildrenToProps=function(e,t){var r=Object.assign({},t);return Object.keys(e).forEach(function(t){var n;r=Object.assign({},r,((n={})[t]=e[t],n))}),r},n.prototype.warnOnInvalidChildren=function(e,t){return r(c.some(function(t){return e.type===t}),"function"==typeof e.type?"You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.":"Only elements types "+c.join(", ")+" are allowed. Helmet does not support rendering <"+e.type+"> elements. Refer to our API for more information."),r(!t||"string"==typeof t||Array.isArray(t)&&!t.some(function(e){return"string"!=typeof e}),"Helmet expects a string as a child of <"+e.type+">. Did you forget to wrap your children in braces? ( <"+e.type+">{``}</"+e.type+"> ) Refer to our API for more information."),!0},n.prototype.mapChildrenToProps=function(e,t){var r=this,n={};return i.Children.forEach(e,function(e){if(e&&e.props){var o=e.props,i=o.children,a=k(o,["children"]),c=Object.keys(a).reduce(function(e,t){return e[l[t]||t]=a[t],e},{}),u=e.type;switch("symbol"==typeof u?u=u.toString():r.warnOnInvalidChildren(e,i),u){case s.FRAGMENT:t=r.mapChildrenToProps(i,t);break;case s.LINK:case s.META:case s.NOSCRIPT:case s.SCRIPT:case s.STYLE:n=r.flattenArrayTypeChildren({child:e,arrayTypeChildren:n,newChildProps:c,nestedChildren:i});break;default:t=r.mapObjectTypeChildren({child:e,newProps:t,newChildProps:c,nestedChildren:i})}}}),this.mapArrayTypeChildrenToProps(n,t)},n.prototype.render=function(){var e=this.props,t=e.children,r=k(e,["children"]),n=Object.assign({},r);return t&&(n=this.mapChildrenToProps(t,n)),i.createElement(j.Consumer,null,function(e){return i.createElement(H,Object.assign({},n,{context:e}))})},n}(o.Component);M.propTypes={base:n.object,bodyAttributes:n.object,children:n.oneOfType([n.arrayOf(n.node),n.node]),defaultTitle:n.string,defer:n.bool,encodeSpecialCharacters:n.bool,htmlAttributes:n.object,link:n.arrayOf(n.object),meta:n.arrayOf(n.object),noscript:n.arrayOf(n.object),onChangeClientState:n.func,script:n.arrayOf(n.object),style:n.arrayOf(n.object),title:n.string,titleAttributes:n.object,titleTemplate:n.string},M.defaultProps={defer:!0,encodeSpecialCharacters:!0},M.displayName="Helmet",exports.Helmet=M,exports.HelmetProvider=I; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react-fast-compare"),require("invariant"),require("prop-types"),require("react"),require("shallowequal")):"function"==typeof define&&define.amd?define(["exports","react-fast-compare","invariant","prop-types","react","shallowequal"],t):t(e.reactHelmetAsync={},e.fastCompare,e.invariant,e.PropTypes,e.react,e.shallowequal)}(this,function(e,t,r,n,o,i){t=t&&t.hasOwnProperty("default")?t.default:t,r=r&&r.hasOwnProperty("default")?r.default:r,n=n&&n.hasOwnProperty("default")?n.default:n;var a="default"in o?o.default:o;i=i&&i.hasOwnProperty("default")?i.default:i;var s={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},c=Object.keys(s).map(function(e){return s[e]}),u={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},l=Object.keys(u).reduce(function(e,t){return e[u[t]]=t,e},{}),p=function(e,t){for(var r=e.length-1;r>=0;r-=1){var n=e[r];if(Object.prototype.hasOwnProperty.call(n,t))return n[t]}return null},f=function(e){var t=p(e,s.TITLE),r=p(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,function(){return t});var n=p(e,"defaultTitle");return t||n||void 0},d=function(e){return p(e,"onChangeClientState")||function(){}},h=function(e,t){return t.filter(function(t){return void 0!==t[e]}).map(function(t){return t[e]}).reduce(function(e,t){return Object.assign({},e,t)},{})},y=function(e,t){return t.filter(function(e){return void 0!==e[s.BASE]}).map(function(e){return e[s.BASE]}).reverse().reduce(function(t,r){if(!t.length)for(var n=Object.keys(r),o=0;o<n.length;o+=1){var i=n[o].toLowerCase();if(-1!==e.indexOf(i)&&r[i])return t.concat(r)}return t},[])},m=function(e,t,r){var n={};return r.filter(function(t){return!!Array.isArray(t[e])||(void 0!==t[e]&&console&&"function"==typeof console.warn&&console.warn("Helmet: "+e+' should be of type "Array". Instead found type "'+typeof t[e]+'"'),!1)}).map(function(t){return t[e]}).reverse().reduce(function(e,r){var o={};r.filter(function(e){for(var r,i=Object.keys(e),a=0;a<i.length;a+=1){var s=i[a],c=s.toLowerCase();-1===t.indexOf(c)||"rel"===r&&"canonical"===e[r].toLowerCase()||"rel"===c&&"stylesheet"===e[c].toLowerCase()||(r=c),-1===t.indexOf(s)||"innerHTML"!==s&&"cssText"!==s&&"itemprop"!==s||(r=s)}if(!r||!e[r])return!1;var u=e[r].toLowerCase();return n[r]||(n[r]={}),o[r]||(o[r]={}),!n[r][u]&&(o[r][u]=!0,!0)}).reverse().forEach(function(t){return e.push(t)});for(var i=Object.keys(o),a=0;a<i.length;a+=1){var s=i[a],c=Object.assign({},n[s],o[s]);n[s]=c}return e},[]).reverse()},T=function(e){return Array.isArray(e)?e.join(""):e},b=[s.NOSCRIPT,s.SCRIPT,s.STYLE],g=function(e,t){return void 0===t&&(t=!0),!1===t?String(e):String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},v=function(e){return Object.keys(e).reduce(function(t,r){var n=void 0!==e[r]?r+'="'+e[r]+'"':""+r;return t?t+" "+n:n},"")},O=function(e,t){return void 0===t&&(t={}),Object.keys(e).reduce(function(t,r){return t[u[r]||r]=e[r],t},t)},A=function(e,t,r){switch(e){case s.TITLE:return{toComponent:function(){return r=O(t.titleAttributes,{key:e=t.title,"data-rh":!0}),[a.createElement(s.TITLE,r,e)];var e,r},toString:function(){return function(e,r,n,o){var i=v(t.titleAttributes),a=T(r);return i?"<"+e+' data-rh="true" '+i+">"+g(a,o)+"</"+e+">":"<"+e+' data-rh="true">'+g(a,o)+"</"+e+">"}(e,t.title,0,r)}};case"bodyAttributes":case"htmlAttributes":return{toComponent:function(){return O(t)},toString:function(){return v(t)}};default:return{toComponent:function(){return function(e,t){return t.map(function(t,r){var n={key:r,"data-rh":!0};return Object.keys(t).forEach(function(e){var r=u[e]||e;"innerHTML"===r||"cssText"===r?n.dangerouslySetInnerHTML={__html:t.innerHTML||t.cssText}:n[r]=t[e]}),a.createElement(e,n)})}(e,t)},toString:function(){return function(e,t,r){return t.reduce(function(t,n){var o=Object.keys(n).filter(function(e){return!("innerHTML"===e||"cssText"===e)}).reduce(function(e,t){var o=void 0===n[t]?t:t+'="'+g(n[t],r)+'"';return e?e+" "+o:o},""),i=n.innerHTML||n.cssText||"",a=-1===b.indexOf(e);return t+"<"+e+' data-rh="true" '+o+(a?"/>":">"+i+"</"+e+">")},"")}(e,t,r)}}}},C=function(e){var t=e.bodyAttributes,r=e.encode,n=e.htmlAttributes,o=e.linkTags,i=e.metaTags,a=e.noscriptTags,c=e.scriptTags,u=e.styleTags,l=e.title;void 0===l&&(l="");var p=e.titleAttributes;return{base:A(s.BASE,e.baseTag,r),bodyAttributes:A("bodyAttributes",t,r),htmlAttributes:A("htmlAttributes",n,r),link:A(s.LINK,o,r),meta:A(s.META,i,r),noscript:A(s.NOSCRIPT,a,r),script:A(s.SCRIPT,c,r),style:A(s.STYLE,u,r),title:A(s.TITLE,{title:l,titleAttributes:p},r)}},j=a.createContext({}),E=n.shape({setHelmet:n.func,helmetInstances:n.shape({get:n.func,add:n.func,remove:n.func})}),S="undefined"!=typeof document,P=function(e){function t(r){var n=this;e.call(this,r),this.instances=[],this.value={setHelmet:function(e){n.props.context.helmet=e},helmetInstances:{get:function(){return n.instances},add:function(e){n.instances.push(e)},remove:function(e){var t=n.instances.indexOf(e);n.instances.splice(t,1)}}},t.canUseDOM||(r.context.helmet=C({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.render=function(){return a.createElement(j.Provider,{value:this.value},this.props.children)},t}(o.Component);P.canUseDOM=S,P.propTypes={context:n.shape({helmet:n.shape()}),children:n.node.isRequired},P.defaultProps={context:{}},P.displayName="HelmetProvider";var x=function(e,t){var r,n=document.head||document.querySelector(s.HEAD),o=n.querySelectorAll(e+"[data-rh]"),i=[].slice.call(o),a=[];return t&&t.length&&t.forEach(function(t){var n=document.createElement(e);for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&("innerHTML"===o?n.innerHTML=t.innerHTML:"cssText"===o?n.styleSheet?n.styleSheet.cssText=t.cssText:n.appendChild(document.createTextNode(t.cssText)):n.setAttribute(o,void 0===t[o]?"":t[o]));n.setAttribute("data-rh","true"),i.some(function(e,t){return r=t,n.isEqualNode(e)})?i.splice(r,1):a.push(n)}),i.forEach(function(e){return e.parentNode.removeChild(e)}),a.forEach(function(e){return n.appendChild(e)}),{oldTags:i,newTags:a}},I=function(e,t){var r=document.getElementsByTagName(e)[0];if(r){for(var n=r.getAttribute("data-rh"),o=n?n.split(","):[],i=[].concat(o),a=Object.keys(t),s=0;s<a.length;s+=1){var c=a[s],u=t[c]||"";r.getAttribute(c)!==u&&r.setAttribute(c,u),-1===o.indexOf(c)&&o.push(c);var l=i.indexOf(c);-1!==l&&i.splice(l,1)}for(var p=i.length-1;p>=0;p-=1)r.removeAttribute(i[p]);o.length===i.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==a.join(",")&&r.setAttribute("data-rh",a.join(","))}},L=function(e,t){var r=e.baseTag,n=e.htmlAttributes,o=e.linkTags,i=e.metaTags,a=e.noscriptTags,c=e.onChangeClientState,u=e.scriptTags,l=e.styleTags,p=e.title,f=e.titleAttributes;I(s.BODY,e.bodyAttributes),I(s.HTML,n),function(e,t){void 0!==e&&document.title!==e&&(document.title=T(e)),I(s.TITLE,t)}(p,f);var d={baseTag:x(s.BASE,r),linkTags:x(s.LINK,o),metaTags:x(s.META,i),noscriptTags:x(s.NOSCRIPT,a),scriptTags:x(s.SCRIPT,u),styleTags:x(s.STYLE,l)},h={},y={};Object.keys(d).forEach(function(e){var t=d[e],r=t.newTags,n=t.oldTags;r.length&&(h[e]=r),n.length&&(y[e]=d[e].oldTags)}),t&&t(),c(e,h,y)},w=null,H=function(e){function t(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];e.apply(this,t),this.rendered=!1}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.shouldComponentUpdate=function(e){return!i(e,this.props)},t.prototype.componentDidUpdate=function(){this.emitChange()},t.prototype.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},t.prototype.emitChange=function(){var e,t,r=this.props.context,n=r.setHelmet,o=null,i=(e=r.helmetInstances.get().map(function(e){var t=Object.assign({},e.props);return delete t.context,t}),{baseTag:y(["href"],e),bodyAttributes:h("bodyAttributes",e),defer:p(e,"defer"),encode:p(e,"encodeSpecialCharacters"),htmlAttributes:h("htmlAttributes",e),linkTags:m(s.LINK,["rel","href"],e),metaTags:m(s.META,["name","charset","http-equiv","property","itemprop"],e),noscriptTags:m(s.NOSCRIPT,["innerHTML"],e),onChangeClientState:d(e),scriptTags:m(s.SCRIPT,["src","innerHTML"],e),styleTags:m(s.STYLE,["cssText"],e),title:f(e),titleAttributes:h("titleAttributes",e)});P.canUseDOM?(t=i,w&&cancelAnimationFrame(w),t.defer?w=requestAnimationFrame(function(){L(t,function(){w=null})}):(L(t),w=null)):C&&(o=C(i)),n(o)},t.prototype.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},t.prototype.render=function(){return this.init(),null},t}(o.Component);function k(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&-1===t.indexOf(n)&&(r[n]=e[n]);return r}H.propTypes={context:E.isRequired};var M=function(e){function n(){e.apply(this,arguments)}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.shouldComponentUpdate=function(e){return!t(this.props,e)},n.prototype.mapNestedChildrenToProps=function(e,t){if(!t)return null;switch(e.type){case s.SCRIPT:case s.NOSCRIPT:return{innerHTML:t};case s.STYLE:return{cssText:t};default:throw new Error("<"+e.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")}},n.prototype.flattenArrayTypeChildren=function(e){var t,r=e.child,n=e.arrayTypeChildren;return Object.assign({},n,((t={})[r.type]=(n[r.type]||[]).concat([Object.assign({},e.newChildProps,this.mapNestedChildrenToProps(r,e.nestedChildren))]),t))},n.prototype.mapObjectTypeChildren=function(e){var t,r,n=e.child,o=e.newProps,i=e.newChildProps,a=e.nestedChildren;switch(n.type){case s.TITLE:return Object.assign({},o,((t={})[n.type]=a,t),{titleAttributes:Object.assign({},i)});case s.BODY:return Object.assign({},o,{bodyAttributes:Object.assign({},i)});case s.HTML:return Object.assign({},o,{htmlAttributes:Object.assign({},i)});default:return Object.assign({},o,((r={})[n.type]=Object.assign({},i),r))}},n.prototype.mapArrayTypeChildrenToProps=function(e,t){var r=Object.assign({},t);return Object.keys(e).forEach(function(t){var n;r=Object.assign({},r,((n={})[t]=e[t],n))}),r},n.prototype.warnOnInvalidChildren=function(e,t){return r(c.some(function(t){return e.type===t}),"function"==typeof e.type?"You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.":"Only elements types "+c.join(", ")+" are allowed. Helmet does not support rendering <"+e.type+"> elements. Refer to our API for more information."),r(!t||"string"==typeof t||Array.isArray(t)&&!t.some(function(e){return"string"!=typeof e}),"Helmet expects a string as a child of <"+e.type+">. Did you forget to wrap your children in braces? ( <"+e.type+">{``}</"+e.type+"> ) Refer to our API for more information."),!0},n.prototype.mapChildrenToProps=function(e,t){var r=this,n={};return a.Children.forEach(e,function(e){if(e&&e.props){var o=e.props,i=o.children,a=k(o,["children"]),c=Object.keys(a).reduce(function(e,t){return e[l[t]||t]=a[t],e},{}),u=e.type;switch("symbol"==typeof u?u=u.toString():r.warnOnInvalidChildren(e,i),u){case s.FRAGMENT:t=r.mapChildrenToProps(i,t);break;case s.LINK:case s.META:case s.NOSCRIPT:case s.SCRIPT:case s.STYLE:n=r.flattenArrayTypeChildren({child:e,arrayTypeChildren:n,newChildProps:c,nestedChildren:i});break;default:t=r.mapObjectTypeChildren({child:e,newProps:t,newChildProps:c,nestedChildren:i})}}}),this.mapArrayTypeChildrenToProps(n,t)},n.prototype.render=function(){var e=this.props,t=e.children,r=k(e,["children"]),n=Object.assign({},r);return t&&(n=this.mapChildrenToProps(t,n)),a.createElement(j.Consumer,null,function(e){return a.createElement(H,Object.assign({},n,{context:e}))})},n}(o.Component);M.propTypes={base:n.object,bodyAttributes:n.object,children:n.oneOfType([n.arrayOf(n.node),n.node]),defaultTitle:n.string,defer:n.bool,encodeSpecialCharacters:n.bool,htmlAttributes:n.object,link:n.arrayOf(n.object),meta:n.arrayOf(n.object),noscript:n.arrayOf(n.object),onChangeClientState:n.func,script:n.arrayOf(n.object),style:n.arrayOf(n.object),title:n.string,titleAttributes:n.object,titleTemplate:n.string},M.defaultProps={defer:!0,encodeSpecialCharacters:!0},M.displayName="Helmet",e.default=M,e.HelmetProvider=P}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react-fast-compare"),require("invariant"),require("prop-types"),require("react"),require("shallowequal")):"function"==typeof define&&define.amd?define(["exports","react-fast-compare","invariant","prop-types","react","shallowequal"],t):t(e.reactHelmetAsync={},e.fastCompare,e.invariant,e.PropTypes,e.react,e.shallowequal)}(this,function(e,t,r,n,o,i){t=t&&t.hasOwnProperty("default")?t.default:t,r=r&&r.hasOwnProperty("default")?r.default:r,n=n&&n.hasOwnProperty("default")?n.default:n;var a="default"in o?o.default:o;i=i&&i.hasOwnProperty("default")?i.default:i;var s={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},c=Object.keys(s).map(function(e){return s[e]}),u={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},l=Object.keys(u).reduce(function(e,t){return e[u[t]]=t,e},{}),p=function(e,t){for(var r=e.length-1;r>=0;r-=1){var n=e[r];if(Object.prototype.hasOwnProperty.call(n,t))return n[t]}return null},f=function(e){var t=p(e,s.TITLE),r=p(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,function(){return t});var n=p(e,"defaultTitle");return t||n||void 0},d=function(e){return p(e,"onChangeClientState")||function(){}},h=function(e,t){return t.filter(function(t){return void 0!==t[e]}).map(function(t){return t[e]}).reduce(function(e,t){return Object.assign({},e,t)},{})},y=function(e,t){return t.filter(function(e){return void 0!==e[s.BASE]}).map(function(e){return e[s.BASE]}).reverse().reduce(function(t,r){if(!t.length)for(var n=Object.keys(r),o=0;o<n.length;o+=1){var i=n[o].toLowerCase();if(-1!==e.indexOf(i)&&r[i])return t.concat(r)}return t},[])},m=function(e,t,r){var n={};return r.filter(function(t){return!!Array.isArray(t[e])||(void 0!==t[e]&&console&&"function"==typeof console.warn&&console.warn("Helmet: "+e+' should be of type "Array". Instead found type "'+typeof t[e]+'"'),!1)}).map(function(t){return t[e]}).reverse().reduce(function(e,r){var o={};r.filter(function(e){for(var r,i=Object.keys(e),a=0;a<i.length;a+=1){var s=i[a],c=s.toLowerCase();-1===t.indexOf(c)||"rel"===r&&"canonical"===e[r].toLowerCase()||"rel"===c&&"stylesheet"===e[c].toLowerCase()||(r=c),-1===t.indexOf(s)||"innerHTML"!==s&&"cssText"!==s&&"itemprop"!==s||(r=s)}if(!r||!e[r])return!1;var u=e[r].toLowerCase();return n[r]||(n[r]={}),o[r]||(o[r]={}),!n[r][u]&&(o[r][u]=!0,!0)}).reverse().forEach(function(t){return e.push(t)});for(var i=Object.keys(o),a=0;a<i.length;a+=1){var s=i[a],c=Object.assign({},n[s],o[s]);n[s]=c}return e},[]).reverse()},T=function(e){return Array.isArray(e)?e.join(""):e},b=[s.NOSCRIPT,s.SCRIPT,s.STYLE],g=function(e,t){return void 0===t&&(t=!0),!1===t?String(e):String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},v=function(e){return Object.keys(e).reduce(function(t,r){var n=void 0!==e[r]?r+'="'+e[r]+'"':""+r;return t?t+" "+n:n},"")},O=function(e,t){return void 0===t&&(t={}),Object.keys(e).reduce(function(t,r){return t[u[r]||r]=e[r],t},t)},A=function(e,t,r){switch(e){case s.TITLE:return{toComponent:function(){return r=O(t.titleAttributes,{key:e=t.title,"data-rh":!0}),[a.createElement(s.TITLE,r,e)];var e,r},toString:function(){return function(e,r,n,o){var i=v(t.titleAttributes),a=T(r);return i?"<"+e+' data-rh="true" '+i+">"+g(a,o)+"</"+e+">":"<"+e+' data-rh="true">'+g(a,o)+"</"+e+">"}(e,t.title,0,r)}};case"bodyAttributes":case"htmlAttributes":return{toComponent:function(){return O(t)},toString:function(){return v(t)}};default:return{toComponent:function(){return function(e,t){return t.map(function(t,r){var n={key:r,"data-rh":!0};return Object.keys(t).forEach(function(e){var r=u[e]||e;"innerHTML"===r||"cssText"===r?n.dangerouslySetInnerHTML={__html:t.innerHTML||t.cssText}:n[r]=t[e]}),a.createElement(e,n)})}(e,t)},toString:function(){return function(e,t,r){return t.reduce(function(t,n){var o=Object.keys(n).filter(function(e){return!("innerHTML"===e||"cssText"===e)}).reduce(function(e,t){var o=void 0===n[t]?t:t+'="'+g(n[t],r)+'"';return e?e+" "+o:o},""),i=n.innerHTML||n.cssText||"",a=-1===b.indexOf(e);return t+"<"+e+' data-rh="true" '+o+(a?"/>":">"+i+"</"+e+">")},"")}(e,t,r)}}}},C=function(e){var t=e.bodyAttributes,r=e.encode,n=e.htmlAttributes,o=e.linkTags,i=e.metaTags,a=e.noscriptTags,c=e.scriptTags,u=e.styleTags,l=e.title;void 0===l&&(l="");var p=e.titleAttributes;return{base:A(s.BASE,e.baseTag,r),bodyAttributes:A("bodyAttributes",t,r),htmlAttributes:A("htmlAttributes",n,r),link:A(s.LINK,o,r),meta:A(s.META,i,r),noscript:A(s.NOSCRIPT,a,r),script:A(s.SCRIPT,c,r),style:A(s.STYLE,u,r),title:A(s.TITLE,{title:l,titleAttributes:p},r)}},j=a.createContext({}),E=n.shape({setHelmet:n.func,helmetInstances:n.shape({get:n.func,add:n.func,remove:n.func})}),S="undefined"!=typeof document,P=function(e){function t(r){var n=this;e.call(this,r),this.instances=[],this.value={setHelmet:function(e){n.props.context.helmet=e},helmetInstances:{get:function(){return n.instances},add:function(e){n.instances.push(e)},remove:function(e){var t=n.instances.indexOf(e);n.instances.splice(t,1)}}},t.canUseDOM||(r.context.helmet=C({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.render=function(){return a.createElement(j.Provider,{value:this.value},this.props.children)},t}(o.Component);P.canUseDOM=S,P.propTypes={context:n.shape({helmet:n.shape()}),children:n.node.isRequired},P.defaultProps={context:{}},P.displayName="HelmetProvider";var x=function(e,t){var r,n=document.head||document.querySelector(s.HEAD),o=n.querySelectorAll(e+"[data-rh]"),i=[].slice.call(o),a=[];return t&&t.length&&t.forEach(function(t){var n=document.createElement(e);for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&("innerHTML"===o?n.innerHTML=t.innerHTML:"cssText"===o?n.styleSheet?n.styleSheet.cssText=t.cssText:n.appendChild(document.createTextNode(t.cssText)):n.setAttribute(o,void 0===t[o]?"":t[o]));n.setAttribute("data-rh","true"),i.some(function(e,t){return r=t,n.isEqualNode(e)})?i.splice(r,1):a.push(n)}),i.forEach(function(e){return e.parentNode.removeChild(e)}),a.forEach(function(e){return n.appendChild(e)}),{oldTags:i,newTags:a}},I=function(e,t){var r=document.getElementsByTagName(e)[0];if(r){for(var n=r.getAttribute("data-rh"),o=n?n.split(","):[],i=[].concat(o),a=Object.keys(t),s=0;s<a.length;s+=1){var c=a[s],u=t[c]||"";r.getAttribute(c)!==u&&r.setAttribute(c,u),-1===o.indexOf(c)&&o.push(c);var l=i.indexOf(c);-1!==l&&i.splice(l,1)}for(var p=i.length-1;p>=0;p-=1)r.removeAttribute(i[p]);o.length===i.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==a.join(",")&&r.setAttribute("data-rh",a.join(","))}},L=function(e,t){var r=e.baseTag,n=e.htmlAttributes,o=e.linkTags,i=e.metaTags,a=e.noscriptTags,c=e.onChangeClientState,u=e.scriptTags,l=e.styleTags,p=e.title,f=e.titleAttributes;I(s.BODY,e.bodyAttributes),I(s.HTML,n),function(e,t){void 0!==e&&document.title!==e&&(document.title=T(e)),I(s.TITLE,t)}(p,f);var d={baseTag:x(s.BASE,r),linkTags:x(s.LINK,o),metaTags:x(s.META,i),noscriptTags:x(s.NOSCRIPT,a),scriptTags:x(s.SCRIPT,u),styleTags:x(s.STYLE,l)},h={},y={};Object.keys(d).forEach(function(e){var t=d[e],r=t.newTags,n=t.oldTags;r.length&&(h[e]=r),n.length&&(y[e]=d[e].oldTags)}),t&&t(),c(e,h,y)},w=null,H=function(e){function t(){for(var t=[],r=arguments.length;r--;)t[r]=arguments[r];e.apply(this,t),this.rendered=!1}return e&&(t.__proto__=e),(t.prototype=Object.create(e&&e.prototype)).constructor=t,t.prototype.shouldComponentUpdate=function(e){return!i(e,this.props)},t.prototype.componentDidUpdate=function(){this.emitChange()},t.prototype.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},t.prototype.emitChange=function(){var e,t,r=this.props.context,n=r.setHelmet,o=null,i=(e=r.helmetInstances.get().map(function(e){var t=Object.assign({},e.props);return delete t.context,t}),{baseTag:y(["href"],e),bodyAttributes:h("bodyAttributes",e),defer:p(e,"defer"),encode:p(e,"encodeSpecialCharacters"),htmlAttributes:h("htmlAttributes",e),linkTags:m(s.LINK,["rel","href"],e),metaTags:m(s.META,["name","charset","http-equiv","property","itemprop"],e),noscriptTags:m(s.NOSCRIPT,["innerHTML"],e),onChangeClientState:d(e),scriptTags:m(s.SCRIPT,["src","innerHTML"],e),styleTags:m(s.STYLE,["cssText"],e),title:f(e),titleAttributes:h("titleAttributes",e)});P.canUseDOM?(t=i,w&&cancelAnimationFrame(w),t.defer?w=requestAnimationFrame(function(){L(t,function(){w=null})}):(L(t),w=null)):C&&(o=C(i)),n(o)},t.prototype.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},t.prototype.render=function(){return this.init(),null},t}(o.Component);function k(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&-1===t.indexOf(n)&&(r[n]=e[n]);return r}H.propTypes={context:E.isRequired};var M=function(e){function n(){e.apply(this,arguments)}return e&&(n.__proto__=e),(n.prototype=Object.create(e&&e.prototype)).constructor=n,n.prototype.shouldComponentUpdate=function(e){return!t(this.props,e)},n.prototype.mapNestedChildrenToProps=function(e,t){if(!t)return null;switch(e.type){case s.SCRIPT:case s.NOSCRIPT:return{innerHTML:t};case s.STYLE:return{cssText:t};default:throw new Error("<"+e.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")}},n.prototype.flattenArrayTypeChildren=function(e){var t,r=e.child,n=e.arrayTypeChildren;return Object.assign({},n,((t={})[r.type]=(n[r.type]||[]).concat([Object.assign({},e.newChildProps,this.mapNestedChildrenToProps(r,e.nestedChildren))]),t))},n.prototype.mapObjectTypeChildren=function(e){var t,r,n=e.child,o=e.newProps,i=e.newChildProps,a=e.nestedChildren;switch(n.type){case s.TITLE:return Object.assign({},o,((t={})[n.type]=a,t),{titleAttributes:Object.assign({},i)});case s.BODY:return Object.assign({},o,{bodyAttributes:Object.assign({},i)});case s.HTML:return Object.assign({},o,{htmlAttributes:Object.assign({},i)});default:return Object.assign({},o,((r={})[n.type]=Object.assign({},i),r))}},n.prototype.mapArrayTypeChildrenToProps=function(e,t){var r=Object.assign({},t);return Object.keys(e).forEach(function(t){var n;r=Object.assign({},r,((n={})[t]=e[t],n))}),r},n.prototype.warnOnInvalidChildren=function(e,t){return r(c.some(function(t){return e.type===t}),"function"==typeof e.type?"You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.":"Only elements types "+c.join(", ")+" are allowed. Helmet does not support rendering <"+e.type+"> elements. Refer to our API for more information."),r(!t||"string"==typeof t||Array.isArray(t)&&!t.some(function(e){return"string"!=typeof e}),"Helmet expects a string as a child of <"+e.type+">. Did you forget to wrap your children in braces? ( <"+e.type+">{``}</"+e.type+"> ) Refer to our API for more information."),!0},n.prototype.mapChildrenToProps=function(e,t){var r=this,n={};return a.Children.forEach(e,function(e){if(e&&e.props){var o=e.props,i=o.children,a=k(o,["children"]),c=Object.keys(a).reduce(function(e,t){return e[l[t]||t]=a[t],e},{}),u=e.type;switch("symbol"==typeof u?u=u.toString():r.warnOnInvalidChildren(e,i),u){case s.FRAGMENT:t=r.mapChildrenToProps(i,t);break;case s.LINK:case s.META:case s.NOSCRIPT:case s.SCRIPT:case s.STYLE:n=r.flattenArrayTypeChildren({child:e,arrayTypeChildren:n,newChildProps:c,nestedChildren:i});break;default:t=r.mapObjectTypeChildren({child:e,newProps:t,newChildProps:c,nestedChildren:i})}}}),this.mapArrayTypeChildrenToProps(n,t)},n.prototype.render=function(){var e=this.props,t=e.children,r=k(e,["children"]),n=Object.assign({},r);return t&&(n=this.mapChildrenToProps(t,n)),a.createElement(j.Consumer,null,function(e){return a.createElement(H,Object.assign({},n,{context:e}))})},n}(o.Component);M.propTypes={base:n.object,bodyAttributes:n.object,children:n.oneOfType([n.arrayOf(n.node),n.node]),defaultTitle:n.string,defer:n.bool,encodeSpecialCharacters:n.bool,htmlAttributes:n.object,link:n.arrayOf(n.object),meta:n.arrayOf(n.object),noscript:n.arrayOf(n.object),onChangeClientState:n.func,script:n.arrayOf(n.object),style:n.arrayOf(n.object),title:n.string,titleAttributes:n.object,titleTemplate:n.string},M.defaultProps={defer:!0,encodeSpecialCharacters:!0},M.displayName="Helmet",e.Helmet=M,e.HelmetProvider=P}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "react-helmet-async", | ||
"version": "0.3.0-beta.3", | ||
"version": "1.0.0-beta.0", | ||
"description": "Thread-safe Helmet for React 16+ and friends", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -14,2 +14,4 @@ # react-helmet-async | ||
**New is 1.0.0:** No more default export! `import { Helmet } from 'react-helmet-async'` | ||
The main way that this package differs from `react-helmet` is that it requires using a Provider to encapsulate Helmet state for your React tree. If you use libraries like Redux or Apollo, you are already familiar with this paradigm: | ||
@@ -20,3 +22,3 @@ | ||
import ReactDOM from 'react-dom'; | ||
import Helmet, { HelmetProvider } from 'react-helmet-async'; | ||
import { Helmet, HelmetProvider } from 'react-helmet-async'; | ||
@@ -48,3 +50,3 @@ const app = ( | ||
import { renderToString } from 'react-dom/server'; | ||
import Helmet, { HelmetProvider } from 'react-helmet-async'; | ||
import { Helmet, HelmetProvider } from 'react-helmet-async'; | ||
@@ -81,3 +83,3 @@ const helmetContext = {}; | ||
import { getDataFromTree } from 'react-apollo'; | ||
import Helmet, { HelmetProvider } from 'react-helmet-async'; | ||
import { Helmet, HelmetProvider } from 'react-helmet-async'; | ||
import template from 'server/template'; | ||
@@ -84,0 +86,0 @@ |
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
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
187040
123