react-helmet-async
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -83,2 +83,6 @@ declare module 'react-helmet-async' { | ||
export class HelmetData { | ||
constructor(context: any, instances?: Array<any>) | ||
} | ||
export class HelmetProvider extends React.Component<ProviderProps> { | ||
@@ -85,0 +89,0 @@ static canUseDOM: boolean; |
@@ -1,2 +0,2 @@ | ||
var t=require("react"),e=require("prop-types"),r=require("react-fast-compare"),n=require("invariant"),i=require("shallowequal");function a(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=a(t),u=a(e),s=a(r),c=a(n),l=a(i);function f(){return(f=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function d(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,p(t,e)}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function h(t,e){if(null==t)return{};var r,n,i={},a=Object.keys(t);for(n=0;n<a.length;n++)e.indexOf(r=a[n])>=0||(i[r]=t[r]);return i}var m={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},y={rel:["amphtml","canonical","alternate"]},T={type:["application/ld+json"]},g={charset:"",name:["robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},b=Object.keys(m).map(function(t){return m[t]}),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},A=Object.keys(v).reduce(function(t,e){return t[v[e]]=e,t},{}),C=function(t,e){for(var r=t.length-1;r>=0;r-=1){var n=t[r];if(Object.prototype.hasOwnProperty.call(n,e))return n[e]}return null},O=function(t){var e=C(t,m.TITLE),r=C(t,"titleTemplate");if(Array.isArray(e)&&(e=e.join("")),r&&e)return r.replace(/%s/g,function(){return e});var n=C(t,"defaultTitle");return e||n||void 0},S=function(t){return C(t,"onChangeClientState")||function(){}},E=function(t,e){return e.filter(function(e){return void 0!==e[t]}).map(function(e){return e[t]}).reduce(function(t,e){return f({},t,e)},{})},I=function(t,e){return e.filter(function(t){return void 0!==t[m.BASE]}).map(function(t){return t[m.BASE]}).reverse().reduce(function(e,r){if(!e.length)for(var n=Object.keys(r),i=0;i<n.length;i+=1){var a=n[i].toLowerCase();if(-1!==t.indexOf(a)&&r[a])return e.concat(r)}return e},[])},P=function(t,e,r){var n={};return r.filter(function(e){return!!Array.isArray(e[t])||(void 0!==e[t]&&console&&"function"==typeof console.warn&&console.warn("Helmet: "+t+' should be of type "Array". Instead found type "'+typeof e[t]+'"'),!1)}).map(function(e){return e[t]}).reverse().reduce(function(t,r){var i={};r.filter(function(t){for(var r,a=Object.keys(t),o=0;o<a.length;o+=1){var u=a[o],s=u.toLowerCase();-1===e.indexOf(s)||"rel"===r&&"canonical"===t[r].toLowerCase()||"rel"===s&&"stylesheet"===t[s].toLowerCase()||(r=s),-1===e.indexOf(u)||"innerHTML"!==u&&"cssText"!==u&&"itemprop"!==u||(r=u)}if(!r||!t[r])return!1;var c=t[r].toLowerCase();return n[r]||(n[r]={}),i[r]||(i[r]={}),!n[r][c]&&(i[r][c]=!0,!0)}).reverse().forEach(function(e){return t.push(e)});for(var a=Object.keys(i),o=0;o<a.length;o+=1){var u=a[o],s=f({},n[u],i[u]);n[u]=s}return t},[]).reverse()},x=function(t,e){if(Array.isArray(t)&&t.length)for(var r=0;r<t.length;r+=1)if(t[r][e])return!0;return!1},w=function(t){return Array.isArray(t)?t.join(""):t},L=function(t,e){return Array.isArray(t)?t.reduce(function(t,r){return function(t,e){for(var r=Object.keys(t),n=0;n<r.length;n+=1)if(e[r[n]]&&e[r[n]].includes(t[r[n]]))return!0;return!1}(r,e)?t.priority.push(r):t.default.push(r),t},{priority:[],default:[]}):{default:t}},j=[m.NOSCRIPT,m.SCRIPT,m.STYLE],k=function(t,e){return void 0===e&&(e=!0),!1===e?String(t):String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},H=function(t){return Object.keys(t).reduce(function(e,r){var n=void 0!==t[r]?r+'="'+t[r]+'"':""+r;return e?e+" "+n:n},"")},M=function(t,e){return void 0===e&&(e={}),Object.keys(t).reduce(function(e,r){return e[v[r]||r]=t[r],e},e)},N=function(t,e){return e.map(function(e,r){var n,i=((n={key:r})["data-rh"]=!0,n);return Object.keys(e).forEach(function(t){var r=v[t]||t;"innerHTML"===r||"cssText"===r?i.dangerouslySetInnerHTML={__html:e.innerHTML||e.cssText}:i[r]=e[t]}),o.default.createElement(t,i)})},R=function(t,e,r){switch(t){case m.TITLE:return{toComponent:function(){return r=e.titleAttributes,(n={key:t=e.title})["data-rh"]=!0,i=M(r,n),[o.default.createElement(m.TITLE,i,t)];var t,r,n,i},toString:function(){return function(t,e,r,n){var i=H(r),a=w(e);return i?"<"+t+' data-rh="true" '+i+">"+k(a,n)+"</"+t+">":"<"+t+' data-rh="true">'+k(a,n)+"</"+t+">"}(t,e.title,e.titleAttributes,r)}};case"bodyAttributes":case"htmlAttributes":return{toComponent:function(){return M(e)},toString:function(){return H(e)}};default:return{toComponent:function(){return N(t,e)},toString:function(){return function(t,e,r){return e.reduce(function(e,n){var i=Object.keys(n).filter(function(t){return!("innerHTML"===t||"cssText"===t)}).reduce(function(t,e){var i=void 0===n[e]?e:e+'="'+k(n[e],r)+'"';return t?t+" "+i:i},""),a=n.innerHTML||n.cssText||"",o=-1===j.indexOf(t);return e+"<"+t+' data-rh="true" '+i+(o?"/>":">"+a+"</"+t+">")},"")}(t,e,r)}}}},D=function(t){var e=t.baseTag,r=t.bodyAttributes,n=t.encode,i=t.htmlAttributes,a=t.noscriptTags,o=t.styleTags,u=t.title,s=void 0===u?"":u,c=t.titleAttributes,l=t.linkTags,f=t.metaTags,d=t.scriptTags,p={toComponent:function(){},toString:function(){return""}};if(t.prioritizeSeoTags){var h=function(t){var e=t.linkTags,r=t.scriptTags,n=t.encode,i=L(t.metaTags,g),a=L(e,y),o=L(r,T);return{priorityMethods:{toComponent:function(){return[].concat(N(m.META,i.priority),N(m.LINK,a.priority),N(m.SCRIPT,o.priority))},toString:function(){return R(m.META,i.priority,n)+" "+R(m.LINK,a.priority,n)+" "+R(m.SCRIPT,o.priority,n)}},metaTags:i.default,linkTags:a.default,scriptTags:o.default}}(t);p=h.priorityMethods,l=h.linkTags,f=h.metaTags,d=h.scriptTags}return{priority:p,base:R(m.BASE,e,n),bodyAttributes:R("bodyAttributes",r,n),htmlAttributes:R("htmlAttributes",i,n),link:R(m.LINK,l,n),meta:R(m.META,f,n),noscript:R(m.NOSCRIPT,a,n),script:R(m.SCRIPT,d,n),style:R(m.STYLE,o,n),title:R(m.TITLE,{title:s,titleAttributes:c},n)}},q=function t(e){var r=this;this.instances=[],this.value={setHelmet:function(t){r.context.helmet=t},helmetInstances:{get:function(){return r.instances},add:function(t){r.instances.push(t)},remove:function(t){var e=r.instances.indexOf(t);r.instances.splice(e,1)}}},this.context=e,t.canUseDOM||(e.helmet=D({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))},Y=o.default.createContext({}),B=u.default.shape({setHelmet:u.default.func,helmetInstances:u.default.shape({get:u.default.func,add:u.default.func,remove:u.default.func})}),K="undefined"!=typeof document,U=function(t){function e(e){var r;return(r=t.call(this,e)||this).helmetData=new q(r.props.context),r}return d(e,t),e.prototype.render=function(){return o.default.createElement(Y.Provider,{value:this.helmetData.value},this.props.children)},e}(t.Component);U.canUseDOM=K,U.propTypes={context:u.default.shape({helmet:u.default.shape()}),children:u.default.node.isRequired},U.defaultProps={context:{}},U.displayName="HelmetProvider";var _=function(t,e){var r,n=document.head||document.querySelector(m.HEAD),i=n.querySelectorAll(t+"[data-rh]"),a=[].slice.call(i),o=[];return e&&e.length&&e.forEach(function(e){var n=document.createElement(t);for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&("innerHTML"===i?n.innerHTML=e.innerHTML:"cssText"===i?n.styleSheet?n.styleSheet.cssText=e.cssText:n.appendChild(document.createTextNode(e.cssText)):n.setAttribute(i,void 0===e[i]?"":e[i]));n.setAttribute("data-rh","true"),a.some(function(t,e){return r=e,n.isEqualNode(t)})?a.splice(r,1):o.push(n)}),a.forEach(function(t){return t.parentNode.removeChild(t)}),o.forEach(function(t){return n.appendChild(t)}),{oldTags:a,newTags:o}},z=function(t,e){var r=document.getElementsByTagName(t)[0];if(r){for(var n=r.getAttribute("data-rh"),i=n?n.split(","):[],a=[].concat(i),o=Object.keys(e),u=0;u<o.length;u+=1){var s=o[u],c=e[s]||"";r.getAttribute(s)!==c&&r.setAttribute(s,c),-1===i.indexOf(s)&&i.push(s);var l=a.indexOf(s);-1!==l&&a.splice(l,1)}for(var f=a.length-1;f>=0;f-=1)r.removeAttribute(a[f]);i.length===a.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==o.join(",")&&r.setAttribute("data-rh",o.join(","))}},F=function(t,e){var r=t.baseTag,n=t.htmlAttributes,i=t.linkTags,a=t.metaTags,o=t.noscriptTags,u=t.onChangeClientState,s=t.scriptTags,c=t.styleTags,l=t.title,f=t.titleAttributes;z(m.BODY,t.bodyAttributes),z(m.HTML,n),function(t,e){void 0!==t&&document.title!==t&&(document.title=w(t)),z(m.TITLE,e)}(l,f);var d={baseTag:_(m.BASE,r),linkTags:_(m.LINK,i),metaTags:_(m.META,a),noscriptTags:_(m.NOSCRIPT,o),scriptTags:_(m.SCRIPT,s),styleTags:_(m.STYLE,c)},p={},h={};Object.keys(d).forEach(function(t){var e=d[t],r=e.newTags,n=e.oldTags;r.length&&(p[t]=r),n.length&&(h[t]=d[t].oldTags)}),e&&e(),u(t,p,h)},G=null,W=function(t){function e(){for(var e,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return(e=t.call.apply(t,[this].concat(n))||this).rendered=!1,e}d(e,t);var r=e.prototype;return r.shouldComponentUpdate=function(t){return!l.default(t,this.props)},r.componentDidUpdate=function(){this.emitChange()},r.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},r.emitChange=function(){var t,e,r=this.props.context,n=r.setHelmet,i=null,a=(t=r.helmetInstances.get().map(function(t){var e=f({},t.props);return delete e.context,e}),{baseTag:I(["href"],t),bodyAttributes:E("bodyAttributes",t),defer:C(t,"defer"),encode:C(t,"encodeSpecialCharacters"),htmlAttributes:E("htmlAttributes",t),linkTags:P(m.LINK,["rel","href"],t),metaTags:P(m.META,["name","charset","http-equiv","property","itemprop"],t),noscriptTags:P(m.NOSCRIPT,["innerHTML"],t),onChangeClientState:S(t),scriptTags:P(m.SCRIPT,["src","innerHTML"],t),styleTags:P(m.STYLE,["cssText"],t),title:O(t),titleAttributes:E("titleAttributes",t),prioritizeSeoTags:x(t,"prioritizeSeoTags")});U.canUseDOM?(e=a,G&&cancelAnimationFrame(G),e.defer?G=requestAnimationFrame(function(){F(e,function(){G=null})}):(F(e),G=null)):D&&(i=D(a)),n(i)},r.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},r.render=function(){return this.init(),null},e}(t.Component);W.propTypes={context:B.isRequired},W.displayName="HelmetDispatcher";var J=["children"],Q=["children","helmetData"],V=function(t){function e(){return t.apply(this,arguments)||this}d(e,t);var r=e.prototype;return r.shouldComponentUpdate=function(t){return!s.default(this.props,t)},r.mapNestedChildrenToProps=function(t,e){if(!e)return null;switch(t.type){case m.SCRIPT:case m.NOSCRIPT:return{innerHTML:e};case m.STYLE:return{cssText:e};default:throw new Error("<"+t.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")}},r.flattenArrayTypeChildren=function(t){var e,r=t.child,n=t.arrayTypeChildren;return f({},n,((e={})[r.type]=[].concat(n[r.type]||[],[f({},t.newChildProps,this.mapNestedChildrenToProps(r,t.nestedChildren))]),e))},r.mapObjectTypeChildren=function(t){var e,r,n=t.child,i=t.newProps,a=t.newChildProps,o=t.nestedChildren;switch(n.type){case m.TITLE:return f({},i,((e={})[n.type]=o,e.titleAttributes=f({},a),e));case m.BODY:return f({},i,{bodyAttributes:f({},a)});case m.HTML:return f({},i,{htmlAttributes:f({},a)});default:return f({},i,((r={})[n.type]=f({},a),r))}},r.mapArrayTypeChildrenToProps=function(t,e){var r=f({},e);return Object.keys(t).forEach(function(e){var n;r=f({},r,((n={})[e]=t[e],n))}),r},r.warnOnInvalidChildren=function(t,e){return c.default(b.some(function(e){return t.type===e}),"function"==typeof t.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 "+b.join(", ")+" are allowed. Helmet does not support rendering <"+t.type+"> elements. Refer to our API for more information."),c.default(!e||"string"==typeof e||Array.isArray(e)&&!e.some(function(t){return"string"!=typeof t}),"Helmet expects a string as a child of <"+t.type+">. Did you forget to wrap your children in braces? ( <"+t.type+">{``}</"+t.type+"> ) Refer to our API for more information."),!0},r.mapChildrenToProps=function(t,e){var r=this,n={};return o.default.Children.forEach(t,function(t){if(t&&t.props){var i=t.props,a=i.children,o=h(i,J),u=Object.keys(o).reduce(function(t,e){return t[A[e]||e]=o[e],t},{}),s=t.type;switch("symbol"==typeof s?s=s.toString():r.warnOnInvalidChildren(t,a),s){case m.FRAGMENT:e=r.mapChildrenToProps(a,e);break;case m.LINK:case m.META:case m.NOSCRIPT:case m.SCRIPT:case m.STYLE:n=r.flattenArrayTypeChildren({child:t,arrayTypeChildren:n,newChildProps:u,nestedChildren:a});break;default:e=r.mapObjectTypeChildren({child:t,newProps:e,newChildProps:u,nestedChildren:a})}}}),this.mapArrayTypeChildrenToProps(n,e)},r.render=function(){var t=this.props,e=t.children,r=t.helmetData,n=f({},h(t,Q));return e&&(n=this.mapChildrenToProps(e,n)),r?o.default.createElement(W,f({},n,{context:r.value})):o.default.createElement(Y.Consumer,null,function(t){return o.default.createElement(W,f({},n,{context:t}))})},e}(t.Component);V.propTypes={base:u.default.object,bodyAttributes:u.default.object,children:u.default.oneOfType([u.default.arrayOf(u.default.node),u.default.node]),defaultTitle:u.default.string,defer:u.default.bool,encodeSpecialCharacters:u.default.bool,htmlAttributes:u.default.object,link:u.default.arrayOf(u.default.object),meta:u.default.arrayOf(u.default.object),noscript:u.default.arrayOf(u.default.object),onChangeClientState:u.default.func,script:u.default.arrayOf(u.default.object),style:u.default.arrayOf(u.default.object),title:u.default.string,titleAttributes:u.default.object,titleTemplate:u.default.string,prioritizeSeoTags:u.default.bool,helmetData:u.default.object},V.defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1},V.displayName="Helmet",exports.Helmet=V,exports.HelmetData=q,exports.HelmetProvider=U; | ||
var t=require("react"),e=require("prop-types"),r=require("react-fast-compare"),n=require("invariant"),i=require("shallowequal");function a(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}var o=a(t),u=a(e),s=a(r),c=a(n),l=a(i);function f(){return(f=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function d(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,p(t,e)}function p(t,e){return(p=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function h(t,e){if(null==t)return{};var r,n,i={},a=Object.keys(t);for(n=0;n<a.length;n++)e.indexOf(r=a[n])>=0||(i[r]=t[r]);return i}var m={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},y={rel:["amphtml","canonical","alternate"]},T={type:["application/ld+json"]},g={charset:"",name:["robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},b=Object.keys(m).map(function(t){return m[t]}),v={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},A=Object.keys(v).reduce(function(t,e){return t[v[e]]=e,t},{}),C=function(t,e){for(var r=t.length-1;r>=0;r-=1){var n=t[r];if(Object.prototype.hasOwnProperty.call(n,e))return n[e]}return null},O=function(t){var e=C(t,m.TITLE),r=C(t,"titleTemplate");if(Array.isArray(e)&&(e=e.join("")),r&&e)return r.replace(/%s/g,function(){return e});var n=C(t,"defaultTitle");return e||n||void 0},S=function(t){return C(t,"onChangeClientState")||function(){}},E=function(t,e){return e.filter(function(e){return void 0!==e[t]}).map(function(e){return e[t]}).reduce(function(t,e){return f({},t,e)},{})},I=function(t,e){return e.filter(function(t){return void 0!==t[m.BASE]}).map(function(t){return t[m.BASE]}).reverse().reduce(function(e,r){if(!e.length)for(var n=Object.keys(r),i=0;i<n.length;i+=1){var a=n[i].toLowerCase();if(-1!==t.indexOf(a)&&r[a])return e.concat(r)}return e},[])},x=function(t,e,r){var n={};return r.filter(function(e){return!!Array.isArray(e[t])||(void 0!==e[t]&&console&&"function"==typeof console.warn&&console.warn("Helmet: "+t+' should be of type "Array". Instead found type "'+typeof e[t]+'"'),!1)}).map(function(e){return e[t]}).reverse().reduce(function(t,r){var i={};r.filter(function(t){for(var r,a=Object.keys(t),o=0;o<a.length;o+=1){var u=a[o],s=u.toLowerCase();-1===e.indexOf(s)||"rel"===r&&"canonical"===t[r].toLowerCase()||"rel"===s&&"stylesheet"===t[s].toLowerCase()||(r=s),-1===e.indexOf(u)||"innerHTML"!==u&&"cssText"!==u&&"itemprop"!==u||(r=u)}if(!r||!t[r])return!1;var c=t[r].toLowerCase();return n[r]||(n[r]={}),i[r]||(i[r]={}),!n[r][c]&&(i[r][c]=!0,!0)}).reverse().forEach(function(e){return t.push(e)});for(var a=Object.keys(i),o=0;o<a.length;o+=1){var u=a[o],s=f({},n[u],i[u]);n[u]=s}return t},[]).reverse()},P=function(t,e){if(Array.isArray(t)&&t.length)for(var r=0;r<t.length;r+=1)if(t[r][e])return!0;return!1},w=function(t){return Array.isArray(t)?t.join(""):t},L=function(t,e){return Array.isArray(t)?t.reduce(function(t,r){return function(t,e){for(var r=Object.keys(t),n=0;n<r.length;n+=1)if(e[r[n]]&&e[r[n]].includes(t[r[n]]))return!0;return!1}(r,e)?t.priority.push(r):t.default.push(r),t},{priority:[],default:[]}):{default:t}},j=[m.NOSCRIPT,m.SCRIPT,m.STYLE],k=function(t,e){return void 0===e&&(e=!0),!1===e?String(t):String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},H=function(t){return Object.keys(t).reduce(function(e,r){var n=void 0!==t[r]?r+'="'+t[r]+'"':""+r;return e?e+" "+n:n},"")},M=function(t,e){return void 0===e&&(e={}),Object.keys(t).reduce(function(e,r){return e[v[r]||r]=t[r],e},e)},N=function(t,e){return e.map(function(e,r){var n,i=((n={key:r})["data-rh"]=!0,n);return Object.keys(e).forEach(function(t){var r=v[t]||t;"innerHTML"===r||"cssText"===r?i.dangerouslySetInnerHTML={__html:e.innerHTML||e.cssText}:i[r]=e[t]}),o.default.createElement(t,i)})},R=function(t,e,r){switch(t){case m.TITLE:return{toComponent:function(){return r=e.titleAttributes,(n={key:t=e.title})["data-rh"]=!0,i=M(r,n),[o.default.createElement(m.TITLE,i,t)];var t,r,n,i},toString:function(){return function(t,e,r,n){var i=H(r),a=w(e);return i?"<"+t+' data-rh="true" '+i+">"+k(a,n)+"</"+t+">":"<"+t+' data-rh="true">'+k(a,n)+"</"+t+">"}(t,e.title,e.titleAttributes,r)}};case"bodyAttributes":case"htmlAttributes":return{toComponent:function(){return M(e)},toString:function(){return H(e)}};default:return{toComponent:function(){return N(t,e)},toString:function(){return function(t,e,r){return e.reduce(function(e,n){var i=Object.keys(n).filter(function(t){return!("innerHTML"===t||"cssText"===t)}).reduce(function(t,e){var i=void 0===n[e]?e:e+'="'+k(n[e],r)+'"';return t?t+" "+i:i},""),a=n.innerHTML||n.cssText||"",o=-1===j.indexOf(t);return e+"<"+t+' data-rh="true" '+i+(o?"/>":">"+a+"</"+t+">")},"")}(t,e,r)}}}},q=function(t){var e=t.baseTag,r=t.bodyAttributes,n=t.encode,i=t.htmlAttributes,a=t.noscriptTags,o=t.styleTags,u=t.title,s=void 0===u?"":u,c=t.titleAttributes,l=t.linkTags,f=t.metaTags,d=t.scriptTags,p={toComponent:function(){},toString:function(){return""}};if(t.prioritizeSeoTags){var h=function(t){var e=t.linkTags,r=t.scriptTags,n=t.encode,i=L(t.metaTags,g),a=L(e,y),o=L(r,T);return{priorityMethods:{toComponent:function(){return[].concat(N(m.META,i.priority),N(m.LINK,a.priority),N(m.SCRIPT,o.priority))},toString:function(){return R(m.META,i.priority,n)+" "+R(m.LINK,a.priority,n)+" "+R(m.SCRIPT,o.priority,n)}},metaTags:i.default,linkTags:a.default,scriptTags:o.default}}(t);p=h.priorityMethods,l=h.linkTags,f=h.metaTags,d=h.scriptTags}return{priority:p,base:R(m.BASE,e,n),bodyAttributes:R("bodyAttributes",r,n),htmlAttributes:R("htmlAttributes",i,n),link:R(m.LINK,l,n),meta:R(m.META,f,n),noscript:R(m.NOSCRIPT,a,n),script:R(m.SCRIPT,d,n),style:R(m.STYLE,o,n),title:R(m.TITLE,{title:s,titleAttributes:c},n)}},D=function t(e,r){var n=this;this.instances=[],this.value={setHelmet:function(t){n.context.helmet=t},helmetInstances:{get:function(){return n.instances},add:function(t){n.instances.push(t)},remove:function(t){var e=n.instances.indexOf(t);n.instances.splice(e,1)}}},this.context=e,r&&(this.instances=r),t.canUseDOM||(e.helmet=q({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))},Y=o.default.createContext({}),B=u.default.shape({setHelmet:u.default.func,helmetInstances:u.default.shape({get:u.default.func,add:u.default.func,remove:u.default.func})}),K="undefined"!=typeof document,U=function(t){function e(e){var r;return(r=t.call(this,e)||this).helmetData=new D(r.props.context),r}return d(e,t),e.prototype.render=function(){return o.default.createElement(Y.Provider,{value:this.helmetData.value},this.props.children)},e}(t.Component);U.canUseDOM=K,U.propTypes={context:u.default.shape({helmet:u.default.shape()}),children:u.default.node.isRequired},U.defaultProps={context:{}},U.displayName="HelmetProvider";var _=function(t,e){var r,n=document.head||document.querySelector(m.HEAD),i=n.querySelectorAll(t+"[data-rh]"),a=[].slice.call(i),o=[];return e&&e.length&&e.forEach(function(e){var n=document.createElement(t);for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&("innerHTML"===i?n.innerHTML=e.innerHTML:"cssText"===i?n.styleSheet?n.styleSheet.cssText=e.cssText:n.appendChild(document.createTextNode(e.cssText)):n.setAttribute(i,void 0===e[i]?"":e[i]));n.setAttribute("data-rh","true"),a.some(function(t,e){return r=e,n.isEqualNode(t)})?a.splice(r,1):o.push(n)}),a.forEach(function(t){return t.parentNode.removeChild(t)}),o.forEach(function(t){return n.appendChild(t)}),{oldTags:a,newTags:o}},z=function(t,e){var r=document.getElementsByTagName(t)[0];if(r){for(var n=r.getAttribute("data-rh"),i=n?n.split(","):[],a=[].concat(i),o=Object.keys(e),u=0;u<o.length;u+=1){var s=o[u],c=e[s]||"";r.getAttribute(s)!==c&&r.setAttribute(s,c),-1===i.indexOf(s)&&i.push(s);var l=a.indexOf(s);-1!==l&&a.splice(l,1)}for(var f=a.length-1;f>=0;f-=1)r.removeAttribute(a[f]);i.length===a.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==o.join(",")&&r.setAttribute("data-rh",o.join(","))}},F=function(t,e){var r=t.baseTag,n=t.htmlAttributes,i=t.linkTags,a=t.metaTags,o=t.noscriptTags,u=t.onChangeClientState,s=t.scriptTags,c=t.styleTags,l=t.title,f=t.titleAttributes;z(m.BODY,t.bodyAttributes),z(m.HTML,n),function(t,e){void 0!==t&&document.title!==t&&(document.title=w(t)),z(m.TITLE,e)}(l,f);var d={baseTag:_(m.BASE,r),linkTags:_(m.LINK,i),metaTags:_(m.META,a),noscriptTags:_(m.NOSCRIPT,o),scriptTags:_(m.SCRIPT,s),styleTags:_(m.STYLE,c)},p={},h={};Object.keys(d).forEach(function(t){var e=d[t],r=e.newTags,n=e.oldTags;r.length&&(p[t]=r),n.length&&(h[t]=d[t].oldTags)}),e&&e(),u(t,p,h)},G=null,W=function(t){function e(){for(var e,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return(e=t.call.apply(t,[this].concat(n))||this).rendered=!1,e}d(e,t);var r=e.prototype;return r.shouldComponentUpdate=function(t){return!l.default(t,this.props)},r.componentDidUpdate=function(){this.emitChange()},r.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},r.emitChange=function(){var t,e,r=this.props.context,n=r.setHelmet,i=null,a=(t=r.helmetInstances.get().map(function(t){var e=f({},t.props);return delete e.context,e}),{baseTag:I(["href"],t),bodyAttributes:E("bodyAttributes",t),defer:C(t,"defer"),encode:C(t,"encodeSpecialCharacters"),htmlAttributes:E("htmlAttributes",t),linkTags:x(m.LINK,["rel","href"],t),metaTags:x(m.META,["name","charset","http-equiv","property","itemprop"],t),noscriptTags:x(m.NOSCRIPT,["innerHTML"],t),onChangeClientState:S(t),scriptTags:x(m.SCRIPT,["src","innerHTML"],t),styleTags:x(m.STYLE,["cssText"],t),title:O(t),titleAttributes:E("titleAttributes",t),prioritizeSeoTags:P(t,"prioritizeSeoTags")});U.canUseDOM?(e=a,G&&cancelAnimationFrame(G),e.defer?G=requestAnimationFrame(function(){F(e,function(){G=null})}):(F(e),G=null)):q&&(i=q(a)),n(i)},r.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},r.render=function(){return this.init(),null},e}(t.Component);W.propTypes={context:B.isRequired},W.displayName="HelmetDispatcher";var J=["children"],Q=["children"],V=function(t){function e(){return t.apply(this,arguments)||this}d(e,t);var r=e.prototype;return r.shouldComponentUpdate=function(t){return!s.default(this.props,t)},r.mapNestedChildrenToProps=function(t,e){if(!e)return null;switch(t.type){case m.SCRIPT:case m.NOSCRIPT:return{innerHTML:e};case m.STYLE:return{cssText:e};default:throw new Error("<"+t.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")}},r.flattenArrayTypeChildren=function(t){var e,r=t.child,n=t.arrayTypeChildren;return f({},n,((e={})[r.type]=[].concat(n[r.type]||[],[f({},t.newChildProps,this.mapNestedChildrenToProps(r,t.nestedChildren))]),e))},r.mapObjectTypeChildren=function(t){var e,r,n=t.child,i=t.newProps,a=t.newChildProps,o=t.nestedChildren;switch(n.type){case m.TITLE:return f({},i,((e={})[n.type]=o,e.titleAttributes=f({},a),e));case m.BODY:return f({},i,{bodyAttributes:f({},a)});case m.HTML:return f({},i,{htmlAttributes:f({},a)});default:return f({},i,((r={})[n.type]=f({},a),r))}},r.mapArrayTypeChildrenToProps=function(t,e){var r=f({},e);return Object.keys(t).forEach(function(e){var n;r=f({},r,((n={})[e]=t[e],n))}),r},r.warnOnInvalidChildren=function(t,e){return c.default(b.some(function(e){return t.type===e}),"function"==typeof t.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 "+b.join(", ")+" are allowed. Helmet does not support rendering <"+t.type+"> elements. Refer to our API for more information."),c.default(!e||"string"==typeof e||Array.isArray(e)&&!e.some(function(t){return"string"!=typeof t}),"Helmet expects a string as a child of <"+t.type+">. Did you forget to wrap your children in braces? ( <"+t.type+">{``}</"+t.type+"> ) Refer to our API for more information."),!0},r.mapChildrenToProps=function(t,e){var r=this,n={};return o.default.Children.forEach(t,function(t){if(t&&t.props){var i=t.props,a=i.children,o=h(i,J),u=Object.keys(o).reduce(function(t,e){return t[A[e]||e]=o[e],t},{}),s=t.type;switch("symbol"==typeof s?s=s.toString():r.warnOnInvalidChildren(t,a),s){case m.FRAGMENT:e=r.mapChildrenToProps(a,e);break;case m.LINK:case m.META:case m.NOSCRIPT:case m.SCRIPT:case m.STYLE:n=r.flattenArrayTypeChildren({child:t,arrayTypeChildren:n,newChildProps:u,nestedChildren:a});break;default:e=r.mapObjectTypeChildren({child:t,newProps:e,newChildProps:u,nestedChildren:a})}}}),this.mapArrayTypeChildrenToProps(n,e)},r.render=function(){var t=this.props,e=t.children,r=h(t,Q),n=f({},r),i=r.helmetData;return e&&(n=this.mapChildrenToProps(e,n)),!i||i instanceof D||(i=new D(i.context,i.instances)),i?o.default.createElement(W,f({},n,{context:i.value})):o.default.createElement(Y.Consumer,null,function(t){return o.default.createElement(W,f({},n,{context:t}))})},e}(t.Component);V.propTypes={base:u.default.object,bodyAttributes:u.default.object,children:u.default.oneOfType([u.default.arrayOf(u.default.node),u.default.node]),defaultTitle:u.default.string,defer:u.default.bool,encodeSpecialCharacters:u.default.bool,htmlAttributes:u.default.object,link:u.default.arrayOf(u.default.object),meta:u.default.arrayOf(u.default.object),noscript:u.default.arrayOf(u.default.object),onChangeClientState:u.default.func,script:u.default.arrayOf(u.default.object),style:u.default.arrayOf(u.default.object),title:u.default.string,titleAttributes:u.default.object,titleTemplate:u.default.string,prioritizeSeoTags:u.default.bool,helmetData:u.default.object},V.defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1},V.displayName="Helmet",exports.Helmet=V,exports.HelmetData=D,exports.HelmetProvider=U; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import e,{Component as t}from"react";import r from"prop-types";import n from"react-fast-compare";import s from"invariant";import o from"shallowequal";function i(){return(i=Object.assign||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}).apply(this,arguments)}function a(e,t){if(null==e)return{};var r,n,s={},o=Object.keys(e);for(n=0;n<o.length;n++)t.indexOf(r=o[n])>=0||(s[r]=e[r]);return s}const l={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={rel:["amphtml","canonical","alternate"]},p={type:["application/ld+json"]},d={charset:"",name:["robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},h=Object.keys(l).map(e=>l[e]),u={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},m=Object.keys(u).reduce((e,t)=>(e[u[t]]=t,e),{}),T=(e,t)=>{for(let r=e.length-1;r>=0;r-=1){const n=e[r];if(Object.prototype.hasOwnProperty.call(n,t))return n[t]}return null},y=e=>{let t=T(e,l.TITLE);const r=T(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,()=>t);const n=T(e,"defaultTitle");return t||n||void 0},g=e=>T(e,"onChangeClientState")||(()=>{}),f=(e,t)=>t.filter(t=>void 0!==t[e]).map(t=>t[e]).reduce((e,t)=>i({},e,t),{}),b=(e,t)=>t.filter(e=>void 0!==e[l.BASE]).map(e=>e[l.BASE]).reverse().reduce((t,r)=>{if(!t.length){const n=Object.keys(r);for(let s=0;s<n.length;s+=1){const o=n[s].toLowerCase();if(-1!==e.indexOf(o)&&r[o])return t.concat(r)}}return t},[]),A=(e,t,r)=>{const n={};return r.filter(t=>{return!!Array.isArray(t[e])||(void 0!==t[e]&&(r=`Helmet: ${e} should be of type "Array". Instead found type "${typeof t[e]}"`,console&&"function"==typeof console.warn&&console.warn(r)),!1);var r}).map(t=>t[e]).reverse().reduce((e,r)=>{const s={};r.filter(e=>{let r;const o=Object.keys(e);for(let n=0;n<o.length;n+=1){const s=o[n],i=s.toLowerCase();-1===t.indexOf(i)||"rel"===r&&"canonical"===e[r].toLowerCase()||"rel"===i&&"stylesheet"===e[i].toLowerCase()||(r=i),-1===t.indexOf(s)||"innerHTML"!==s&&"cssText"!==s&&"itemprop"!==s||(r=s)}if(!r||!e[r])return!1;const i=e[r].toLowerCase();return n[r]||(n[r]={}),s[r]||(s[r]={}),!n[r][i]&&(s[r][i]=!0,!0)}).reverse().forEach(t=>e.push(t));const o=Object.keys(s);for(let e=0;e<o.length;e+=1){const t=o[e],r=i({},n[t],s[t]);n[t]=r}return e},[]).reverse()},C=(e,t)=>{if(Array.isArray(e)&&e.length)for(let r=0;r<e.length;r+=1)if(e[r][t])return!0;return!1},S=e=>Array.isArray(e)?e.join(""):e,O=(e,t)=>Array.isArray(e)?e.reduce((e,r)=>(((e,t)=>{const r=Object.keys(e);for(let n=0;n<r.length;n+=1)if(t[r[n]]&&t[r[n]].includes(e[r[n]]))return!0;return!1})(r,t)?e.priority.push(r):e.default.push(r),e),{priority:[],default:[]}):{default:e},E=[l.NOSCRIPT,l.SCRIPT,l.STYLE],I=(e,t=!0)=>!1===t?String(e):String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),x=e=>Object.keys(e).reduce((t,r)=>{const n=void 0!==e[r]?`${r}="${e[r]}"`:`${r}`;return t?`${t} ${n}`:n},""),P=(e,t={})=>Object.keys(e).reduce((t,r)=>(t[u[r]||r]=e[r],t),t),L=(t,r)=>r.map((r,n)=>{const s={key:n,"data-rh":!0};return Object.keys(r).forEach(e=>{const t=u[e]||e;"innerHTML"===t||"cssText"===t?s.dangerouslySetInnerHTML={__html:r.innerHTML||r.cssText}:s[t]=r[e]}),e.createElement(t,s)}),w=(t,r,n)=>{switch(t){case l.TITLE:return{toComponent:()=>((t,r,n)=>{const s=P(n,{key:r,"data-rh":!0});return[e.createElement(l.TITLE,s,r)]})(0,r.title,r.titleAttributes),toString:()=>((e,t,r,n)=>{const s=x(r),o=S(t);return s?`<${e} data-rh="true" ${s}>${I(o,n)}</${e}>`:`<${e} data-rh="true">${I(o,n)}</${e}>`})(t,r.title,r.titleAttributes,n)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>P(r),toString:()=>x(r)};default:return{toComponent:()=>L(t,r),toString:()=>((e,t,r)=>t.reduce((t,n)=>{const s=Object.keys(n).filter(e=>!("innerHTML"===e||"cssText"===e)).reduce((e,t)=>{const s=void 0===n[t]?t:`${t}="${I(n[t],r)}"`;return e?`${e} ${s}`:s},""),o=n.innerHTML||n.cssText||"",i=-1===E.indexOf(e);return`${t}<${e} data-rh="true" ${s}${i?"/>":`>${o}</${e}>`}`},""))(t,r,n)}}},j=e=>{const{baseTag:t,bodyAttributes:r,encode:n,htmlAttributes:s,noscriptTags:o,styleTags:i,title:a="",titleAttributes:h,prioritizeSeoTags:u}=e;let{linkTags:m,metaTags:T,scriptTags:y}=e,g={toComponent:()=>{},toString:()=>""};return u&&({priorityMethods:g,linkTags:m,metaTags:T,scriptTags:y}=(({metaTags:e,linkTags:t,scriptTags:r,encode:n})=>{const s=O(e,d),o=O(t,c),i=O(r,p);return{priorityMethods:{toComponent:()=>[...L(l.META,s.priority),...L(l.LINK,o.priority),...L(l.SCRIPT,i.priority)],toString:()=>`${w(l.META,s.priority,n)} ${w(l.LINK,o.priority,n)} ${w(l.SCRIPT,i.priority,n)}`},metaTags:s.default,linkTags:o.default,scriptTags:i.default}})(e)),{priority:g,base:w(l.BASE,t,n),bodyAttributes:w("bodyAttributes",r,n),htmlAttributes:w("htmlAttributes",s,n),link:w(l.LINK,m,n),meta:w(l.META,T,n),noscript:w(l.NOSCRIPT,o,n),script:w(l.SCRIPT,y,n),style:w(l.STYLE,i,n),title:w(l.TITLE,{title:a,titleAttributes:h},n)}};class v{constructor(e){this.instances=[],this.value={setHelmet:e=>{this.context.helmet=e},helmetInstances:{get:()=>this.instances,add:e=>{this.instances.push(e)},remove:e=>{const t=this.instances.indexOf(e);this.instances.splice(t,1)}}},this.context=e,v.canUseDOM||(e.helmet=j({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}}const $=e.createContext({}),k=r.shape({setHelmet:r.func,helmetInstances:r.shape({get:r.func,add:r.func,remove:r.func})}),M="undefined"!=typeof document;class H extends t{constructor(e){super(e),this.helmetData=new v(this.props.context)}render(){return e.createElement($.Provider,{value:this.helmetData.value},this.props.children)}}H.canUseDOM=M,H.propTypes={context:r.shape({helmet:r.shape()}),children:r.node.isRequired},H.defaultProps={context:{}},H.displayName="HelmetProvider";const N=(e,t)=>{const r=document.head||document.querySelector(l.HEAD),n=r.querySelectorAll(`${e}[data-rh]`),s=[].slice.call(n),o=[];let i;return t&&t.length&&t.forEach(t=>{const r=document.createElement(e);for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&("innerHTML"===e?r.innerHTML=t.innerHTML:"cssText"===e?r.styleSheet?r.styleSheet.cssText=t.cssText:r.appendChild(document.createTextNode(t.cssText)):r.setAttribute(e,void 0===t[e]?"":t[e]));r.setAttribute("data-rh","true"),s.some((e,t)=>(i=t,r.isEqualNode(e)))?s.splice(i,1):o.push(r)}),s.forEach(e=>e.parentNode.removeChild(e)),o.forEach(e=>r.appendChild(e)),{oldTags:s,newTags:o}},R=(e,t)=>{const r=document.getElementsByTagName(e)[0];if(!r)return;const n=r.getAttribute("data-rh"),s=n?n.split(","):[],o=[].concat(s),i=Object.keys(t);for(let e=0;e<i.length;e+=1){const n=i[e],a=t[n]||"";r.getAttribute(n)!==a&&r.setAttribute(n,a),-1===s.indexOf(n)&&s.push(n);const l=o.indexOf(n);-1!==l&&o.splice(l,1)}for(let e=o.length-1;e>=0;e-=1)r.removeAttribute(o[e]);s.length===o.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==i.join(",")&&r.setAttribute("data-rh",i.join(","))},D=(e,t)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:s,linkTags:o,metaTags:i,noscriptTags:a,onChangeClientState:c,scriptTags:p,styleTags:d,title:h,titleAttributes:u}=e;R(l.BODY,n),R(l.HTML,s),((e,t)=>{void 0!==e&&document.title!==e&&(document.title=S(e)),R(l.TITLE,t)})(h,u);const m={baseTag:N(l.BASE,r),linkTags:N(l.LINK,o),metaTags:N(l.META,i),noscriptTags:N(l.NOSCRIPT,a),scriptTags:N(l.SCRIPT,p),styleTags:N(l.STYLE,d)},T={},y={};Object.keys(m).forEach(e=>{const{newTags:t,oldTags:r}=m[e];t.length&&(T[e]=t),r.length&&(y[e]=m[e].oldTags)}),t&&t(),c(e,T,y)};let q=null;class Y extends t{constructor(...e){super(...e),this.rendered=!1}shouldComponentUpdate(e){return!o(e,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:e}=this.props.context;e.remove(this),this.emitChange()}emitChange(){const{helmetInstances:e,setHelmet:t}=this.props.context;let r=null;const n=(s=e.get().map(e=>{const t=i({},e.props);return delete t.context,t}),{baseTag:b(["href"],s),bodyAttributes:f("bodyAttributes",s),defer:T(s,"defer"),encode:T(s,"encodeSpecialCharacters"),htmlAttributes:f("htmlAttributes",s),linkTags:A(l.LINK,["rel","href"],s),metaTags:A(l.META,["name","charset","http-equiv","property","itemprop"],s),noscriptTags:A(l.NOSCRIPT,["innerHTML"],s),onChangeClientState:g(s),scriptTags:A(l.SCRIPT,["src","innerHTML"],s),styleTags:A(l.STYLE,["cssText"],s),title:y(s),titleAttributes:f("titleAttributes",s),prioritizeSeoTags:C(s,"prioritizeSeoTags")});var s,o;H.canUseDOM?(o=n,q&&cancelAnimationFrame(q),o.defer?q=requestAnimationFrame(()=>{D(o,()=>{q=null})}):(D(o),q=null)):j&&(r=j(n)),t(r)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:e}=this.props.context;e.add(this),this.emitChange()}render(){return this.init(),null}}Y.propTypes={context:k.isRequired},Y.displayName="HelmetDispatcher";const B=["children"],K=["children","helmetData"];class U extends t{shouldComponentUpdate(e){return!n(this.props,e)}mapNestedChildrenToProps(e,t){if(!t)return null;switch(e.type){case l.SCRIPT:case l.NOSCRIPT:return{innerHTML:t};case l.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.`)}}flattenArrayTypeChildren({child:e,arrayTypeChildren:t,newChildProps:r,nestedChildren:n}){return i({},t,{[e.type]:[...t[e.type]||[],i({},r,this.mapNestedChildrenToProps(e,n))]})}mapObjectTypeChildren({child:e,newProps:t,newChildProps:r,nestedChildren:n}){switch(e.type){case l.TITLE:return i({},t,{[e.type]:n,titleAttributes:i({},r)});case l.BODY:return i({},t,{bodyAttributes:i({},r)});case l.HTML:return i({},t,{htmlAttributes:i({},r)});default:return i({},t,{[e.type]:i({},r)})}}mapArrayTypeChildrenToProps(e,t){let r=i({},t);return Object.keys(e).forEach(t=>{r=i({},r,{[t]:e[t]})}),r}warnOnInvalidChildren(e,t){return s(h.some(t=>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 ${h.join(", ")} are allowed. Helmet does not support rendering <${e.type}> elements. Refer to our API for more information.`),s(!t||"string"==typeof t||Array.isArray(t)&&!t.some(e=>"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}mapChildrenToProps(t,r){let n={};return e.Children.forEach(t,e=>{if(!e||!e.props)return;const t=e.props,{children:s}=t,o=a(t,B),i=Object.keys(o).reduce((e,t)=>(e[m[t]||t]=o[t],e),{});let{type:c}=e;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(e,s),c){case l.FRAGMENT:r=this.mapChildrenToProps(s,r);break;case l.LINK:case l.META:case l.NOSCRIPT:case l.SCRIPT:case l.STYLE:n=this.flattenArrayTypeChildren({child:e,arrayTypeChildren:n,newChildProps:i,nestedChildren:s});break;default:r=this.mapObjectTypeChildren({child:e,newProps:r,newChildProps:i,nestedChildren:s})}}),this.mapArrayTypeChildrenToProps(n,r)}render(){const t=this.props,{children:r,helmetData:n}=t;let s=i({},a(t,K));return r&&(s=this.mapChildrenToProps(r,s)),n?e.createElement(Y,i({},s,{context:n.value})):e.createElement($.Consumer,null,t=>e.createElement(Y,i({},s,{context:t})))}}U.propTypes={base:r.object,bodyAttributes:r.object,children:r.oneOfType([r.arrayOf(r.node),r.node]),defaultTitle:r.string,defer:r.bool,encodeSpecialCharacters:r.bool,htmlAttributes:r.object,link:r.arrayOf(r.object),meta:r.arrayOf(r.object),noscript:r.arrayOf(r.object),onChangeClientState:r.func,script:r.arrayOf(r.object),style:r.arrayOf(r.object),title:r.string,titleAttributes:r.object,titleTemplate:r.string,prioritizeSeoTags:r.bool,helmetData:r.object},U.defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1},U.displayName="Helmet";export{U as Helmet,v as HelmetData,H as HelmetProvider}; | ||
import e,{Component as t}from"react";import r from"prop-types";import n from"react-fast-compare";import s from"invariant";import i from"shallowequal";function o(){return(o=Object.assign||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}).apply(this,arguments)}function a(e,t){if(null==e)return{};var r,n,s={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(s[r]=e[r]);return s}const l={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={rel:["amphtml","canonical","alternate"]},p={type:["application/ld+json"]},d={charset:"",name:["robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},h=Object.keys(l).map(e=>l[e]),u={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},m=Object.keys(u).reduce((e,t)=>(e[u[t]]=t,e),{}),T=(e,t)=>{for(let r=e.length-1;r>=0;r-=1){const n=e[r];if(Object.prototype.hasOwnProperty.call(n,t))return n[t]}return null},y=e=>{let t=T(e,l.TITLE);const r=T(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,()=>t);const n=T(e,"defaultTitle");return t||n||void 0},g=e=>T(e,"onChangeClientState")||(()=>{}),f=(e,t)=>t.filter(t=>void 0!==t[e]).map(t=>t[e]).reduce((e,t)=>o({},e,t),{}),b=(e,t)=>t.filter(e=>void 0!==e[l.BASE]).map(e=>e[l.BASE]).reverse().reduce((t,r)=>{if(!t.length){const n=Object.keys(r);for(let s=0;s<n.length;s+=1){const i=n[s].toLowerCase();if(-1!==e.indexOf(i)&&r[i])return t.concat(r)}}return t},[]),A=(e,t,r)=>{const n={};return r.filter(t=>{return!!Array.isArray(t[e])||(void 0!==t[e]&&(r=`Helmet: ${e} should be of type "Array". Instead found type "${typeof t[e]}"`,console&&"function"==typeof console.warn&&console.warn(r)),!1);var r}).map(t=>t[e]).reverse().reduce((e,r)=>{const s={};r.filter(e=>{let r;const i=Object.keys(e);for(let n=0;n<i.length;n+=1){const s=i[n],o=s.toLowerCase();-1===t.indexOf(o)||"rel"===r&&"canonical"===e[r].toLowerCase()||"rel"===o&&"stylesheet"===e[o].toLowerCase()||(r=o),-1===t.indexOf(s)||"innerHTML"!==s&&"cssText"!==s&&"itemprop"!==s||(r=s)}if(!r||!e[r])return!1;const o=e[r].toLowerCase();return n[r]||(n[r]={}),s[r]||(s[r]={}),!n[r][o]&&(s[r][o]=!0,!0)}).reverse().forEach(t=>e.push(t));const i=Object.keys(s);for(let e=0;e<i.length;e+=1){const t=i[e],r=o({},n[t],s[t]);n[t]=r}return e},[]).reverse()},C=(e,t)=>{if(Array.isArray(e)&&e.length)for(let r=0;r<e.length;r+=1)if(e[r][t])return!0;return!1},S=e=>Array.isArray(e)?e.join(""):e,O=(e,t)=>Array.isArray(e)?e.reduce((e,r)=>(((e,t)=>{const r=Object.keys(e);for(let n=0;n<r.length;n+=1)if(t[r[n]]&&t[r[n]].includes(e[r[n]]))return!0;return!1})(r,t)?e.priority.push(r):e.default.push(r),e),{priority:[],default:[]}):{default:e},E=[l.NOSCRIPT,l.SCRIPT,l.STYLE],x=(e,t=!0)=>!1===t?String(e):String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),I=e=>Object.keys(e).reduce((t,r)=>{const n=void 0!==e[r]?`${r}="${e[r]}"`:`${r}`;return t?`${t} ${n}`:n},""),P=(e,t={})=>Object.keys(e).reduce((t,r)=>(t[u[r]||r]=e[r],t),t),w=(t,r)=>r.map((r,n)=>{const s={key:n,"data-rh":!0};return Object.keys(r).forEach(e=>{const t=u[e]||e;"innerHTML"===t||"cssText"===t?s.dangerouslySetInnerHTML={__html:r.innerHTML||r.cssText}:s[t]=r[e]}),e.createElement(t,s)}),L=(t,r,n)=>{switch(t){case l.TITLE:return{toComponent:()=>((t,r,n)=>{const s=P(n,{key:r,"data-rh":!0});return[e.createElement(l.TITLE,s,r)]})(0,r.title,r.titleAttributes),toString:()=>((e,t,r,n)=>{const s=I(r),i=S(t);return s?`<${e} data-rh="true" ${s}>${x(i,n)}</${e}>`:`<${e} data-rh="true">${x(i,n)}</${e}>`})(t,r.title,r.titleAttributes,n)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>P(r),toString:()=>I(r)};default:return{toComponent:()=>w(t,r),toString:()=>((e,t,r)=>t.reduce((t,n)=>{const s=Object.keys(n).filter(e=>!("innerHTML"===e||"cssText"===e)).reduce((e,t)=>{const s=void 0===n[t]?t:`${t}="${x(n[t],r)}"`;return e?`${e} ${s}`:s},""),i=n.innerHTML||n.cssText||"",o=-1===E.indexOf(e);return`${t}<${e} data-rh="true" ${s}${o?"/>":`>${i}</${e}>`}`},""))(t,r,n)}}},j=e=>{const{baseTag:t,bodyAttributes:r,encode:n,htmlAttributes:s,noscriptTags:i,styleTags:o,title:a="",titleAttributes:h,prioritizeSeoTags:u}=e;let{linkTags:m,metaTags:T,scriptTags:y}=e,g={toComponent:()=>{},toString:()=>""};return u&&({priorityMethods:g,linkTags:m,metaTags:T,scriptTags:y}=(({metaTags:e,linkTags:t,scriptTags:r,encode:n})=>{const s=O(e,d),i=O(t,c),o=O(r,p);return{priorityMethods:{toComponent:()=>[...w(l.META,s.priority),...w(l.LINK,i.priority),...w(l.SCRIPT,o.priority)],toString:()=>`${L(l.META,s.priority,n)} ${L(l.LINK,i.priority,n)} ${L(l.SCRIPT,o.priority,n)}`},metaTags:s.default,linkTags:i.default,scriptTags:o.default}})(e)),{priority:g,base:L(l.BASE,t,n),bodyAttributes:L("bodyAttributes",r,n),htmlAttributes:L("htmlAttributes",s,n),link:L(l.LINK,m,n),meta:L(l.META,T,n),noscript:L(l.NOSCRIPT,i,n),script:L(l.SCRIPT,y,n),style:L(l.STYLE,o,n),title:L(l.TITLE,{title:a,titleAttributes:h},n)}};class v{constructor(e,t){this.instances=[],this.value={setHelmet:e=>{this.context.helmet=e},helmetInstances:{get:()=>this.instances,add:e=>{this.instances.push(e)},remove:e=>{const t=this.instances.indexOf(e);this.instances.splice(t,1)}}},this.context=e,t&&(this.instances=t),v.canUseDOM||(e.helmet=j({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}}const $=e.createContext({}),k=r.shape({setHelmet:r.func,helmetInstances:r.shape({get:r.func,add:r.func,remove:r.func})}),M="undefined"!=typeof document;class H extends t{constructor(e){super(e),this.helmetData=new v(this.props.context)}render(){return e.createElement($.Provider,{value:this.helmetData.value},this.props.children)}}H.canUseDOM=M,H.propTypes={context:r.shape({helmet:r.shape()}),children:r.node.isRequired},H.defaultProps={context:{}},H.displayName="HelmetProvider";const N=(e,t)=>{const r=document.head||document.querySelector(l.HEAD),n=r.querySelectorAll(`${e}[data-rh]`),s=[].slice.call(n),i=[];let o;return t&&t.length&&t.forEach(t=>{const r=document.createElement(e);for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&("innerHTML"===e?r.innerHTML=t.innerHTML:"cssText"===e?r.styleSheet?r.styleSheet.cssText=t.cssText:r.appendChild(document.createTextNode(t.cssText)):r.setAttribute(e,void 0===t[e]?"":t[e]));r.setAttribute("data-rh","true"),s.some((e,t)=>(o=t,r.isEqualNode(e)))?s.splice(o,1):i.push(r)}),s.forEach(e=>e.parentNode.removeChild(e)),i.forEach(e=>r.appendChild(e)),{oldTags:s,newTags:i}},R=(e,t)=>{const r=document.getElementsByTagName(e)[0];if(!r)return;const n=r.getAttribute("data-rh"),s=n?n.split(","):[],i=[].concat(s),o=Object.keys(t);for(let e=0;e<o.length;e+=1){const n=o[e],a=t[n]||"";r.getAttribute(n)!==a&&r.setAttribute(n,a),-1===s.indexOf(n)&&s.push(n);const l=i.indexOf(n);-1!==l&&i.splice(l,1)}for(let e=i.length-1;e>=0;e-=1)r.removeAttribute(i[e]);s.length===i.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==o.join(",")&&r.setAttribute("data-rh",o.join(","))},D=(e,t)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:s,linkTags:i,metaTags:o,noscriptTags:a,onChangeClientState:c,scriptTags:p,styleTags:d,title:h,titleAttributes:u}=e;R(l.BODY,n),R(l.HTML,s),((e,t)=>{void 0!==e&&document.title!==e&&(document.title=S(e)),R(l.TITLE,t)})(h,u);const m={baseTag:N(l.BASE,r),linkTags:N(l.LINK,i),metaTags:N(l.META,o),noscriptTags:N(l.NOSCRIPT,a),scriptTags:N(l.SCRIPT,p),styleTags:N(l.STYLE,d)},T={},y={};Object.keys(m).forEach(e=>{const{newTags:t,oldTags:r}=m[e];t.length&&(T[e]=t),r.length&&(y[e]=m[e].oldTags)}),t&&t(),c(e,T,y)};let q=null;class Y extends t{constructor(...e){super(...e),this.rendered=!1}shouldComponentUpdate(e){return!i(e,this.props)}componentDidUpdate(){this.emitChange()}componentWillUnmount(){const{helmetInstances:e}=this.props.context;e.remove(this),this.emitChange()}emitChange(){const{helmetInstances:e,setHelmet:t}=this.props.context;let r=null;const n=(s=e.get().map(e=>{const t=o({},e.props);return delete t.context,t}),{baseTag:b(["href"],s),bodyAttributes:f("bodyAttributes",s),defer:T(s,"defer"),encode:T(s,"encodeSpecialCharacters"),htmlAttributes:f("htmlAttributes",s),linkTags:A(l.LINK,["rel","href"],s),metaTags:A(l.META,["name","charset","http-equiv","property","itemprop"],s),noscriptTags:A(l.NOSCRIPT,["innerHTML"],s),onChangeClientState:g(s),scriptTags:A(l.SCRIPT,["src","innerHTML"],s),styleTags:A(l.STYLE,["cssText"],s),title:y(s),titleAttributes:f("titleAttributes",s),prioritizeSeoTags:C(s,"prioritizeSeoTags")});var s,i;H.canUseDOM?(i=n,q&&cancelAnimationFrame(q),i.defer?q=requestAnimationFrame(()=>{D(i,()=>{q=null})}):(D(i),q=null)):j&&(r=j(n)),t(r)}init(){if(this.rendered)return;this.rendered=!0;const{helmetInstances:e}=this.props.context;e.add(this),this.emitChange()}render(){return this.init(),null}}Y.propTypes={context:k.isRequired},Y.displayName="HelmetDispatcher";const B=["children"],K=["children"];class U extends t{shouldComponentUpdate(e){return!n(this.props,e)}mapNestedChildrenToProps(e,t){if(!t)return null;switch(e.type){case l.SCRIPT:case l.NOSCRIPT:return{innerHTML:t};case l.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.`)}}flattenArrayTypeChildren({child:e,arrayTypeChildren:t,newChildProps:r,nestedChildren:n}){return o({},t,{[e.type]:[...t[e.type]||[],o({},r,this.mapNestedChildrenToProps(e,n))]})}mapObjectTypeChildren({child:e,newProps:t,newChildProps:r,nestedChildren:n}){switch(e.type){case l.TITLE:return o({},t,{[e.type]:n,titleAttributes:o({},r)});case l.BODY:return o({},t,{bodyAttributes:o({},r)});case l.HTML:return o({},t,{htmlAttributes:o({},r)});default:return o({},t,{[e.type]:o({},r)})}}mapArrayTypeChildrenToProps(e,t){let r=o({},t);return Object.keys(e).forEach(t=>{r=o({},r,{[t]:e[t]})}),r}warnOnInvalidChildren(e,t){return s(h.some(t=>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 ${h.join(", ")} are allowed. Helmet does not support rendering <${e.type}> elements. Refer to our API for more information.`),s(!t||"string"==typeof t||Array.isArray(t)&&!t.some(e=>"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}mapChildrenToProps(t,r){let n={};return e.Children.forEach(t,e=>{if(!e||!e.props)return;const t=e.props,{children:s}=t,i=a(t,B),o=Object.keys(i).reduce((e,t)=>(e[m[t]||t]=i[t],e),{});let{type:c}=e;switch("symbol"==typeof c?c=c.toString():this.warnOnInvalidChildren(e,s),c){case l.FRAGMENT:r=this.mapChildrenToProps(s,r);break;case l.LINK:case l.META:case l.NOSCRIPT:case l.SCRIPT:case l.STYLE:n=this.flattenArrayTypeChildren({child:e,arrayTypeChildren:n,newChildProps:o,nestedChildren:s});break;default:r=this.mapObjectTypeChildren({child:e,newProps:r,newChildProps:o,nestedChildren:s})}}),this.mapArrayTypeChildrenToProps(n,r)}render(){const t=this.props,{children:r}=t,n=a(t,K);let s=o({},n),{helmetData:i}=n;return r&&(s=this.mapChildrenToProps(r,s)),!i||i instanceof v||(i=new v(i.context,i.instances)),i?e.createElement(Y,o({},s,{context:i.value})):e.createElement($.Consumer,null,t=>e.createElement(Y,o({},s,{context:t})))}}U.propTypes={base:r.object,bodyAttributes:r.object,children:r.oneOfType([r.arrayOf(r.node),r.node]),defaultTitle:r.string,defer:r.bool,encodeSpecialCharacters:r.bool,htmlAttributes:r.object,link:r.arrayOf(r.object),meta:r.arrayOf(r.object),noscript:r.arrayOf(r.object),onChangeClientState:r.func,script:r.arrayOf(r.object),style:r.arrayOf(r.object),title:r.string,titleAttributes:r.object,titleTemplate:r.string,prioritizeSeoTags:r.bool,helmetData:r.object},U.defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1},U.displayName="Helmet";export{U as Helmet,v as HelmetData,H as HelmetProvider}; | ||
//# sourceMappingURL=index.modern.js.map |
@@ -1,2 +0,2 @@ | ||
import t,{Component as e}from"react";import r from"prop-types";import n from"react-fast-compare";import i from"invariant";import o from"shallowequal";function a(){return(a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function s(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,c(t,e)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t,e){if(null==t)return{};var r,n,i={},o=Object.keys(t);for(n=0;n<o.length;n++)e.indexOf(r=o[n])>=0||(i[r]=t[r]);return i}var l={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},p={rel:["amphtml","canonical","alternate"]},f={type:["application/ld+json"]},d={charset:"",name:["robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},h=Object.keys(l).map(function(t){return l[t]}),m={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},y=Object.keys(m).reduce(function(t,e){return t[m[e]]=e,t},{}),T=function(t,e){for(var r=t.length-1;r>=0;r-=1){var n=t[r];if(Object.prototype.hasOwnProperty.call(n,e))return n[e]}return null},g=function(t){var e=T(t,l.TITLE),r=T(t,"titleTemplate");if(Array.isArray(e)&&(e=e.join("")),r&&e)return r.replace(/%s/g,function(){return e});var n=T(t,"defaultTitle");return e||n||void 0},b=function(t){return T(t,"onChangeClientState")||function(){}},v=function(t,e){return e.filter(function(e){return void 0!==e[t]}).map(function(e){return e[t]}).reduce(function(t,e){return a({},t,e)},{})},A=function(t,e){return e.filter(function(t){return void 0!==t[l.BASE]}).map(function(t){return t[l.BASE]}).reverse().reduce(function(e,r){if(!e.length)for(var n=Object.keys(r),i=0;i<n.length;i+=1){var o=n[i].toLowerCase();if(-1!==t.indexOf(o)&&r[o])return e.concat(r)}return e},[])},C=function(t,e,r){var n={};return r.filter(function(e){return!!Array.isArray(e[t])||(void 0!==e[t]&&console&&"function"==typeof console.warn&&console.warn("Helmet: "+t+' should be of type "Array". Instead found type "'+typeof e[t]+'"'),!1)}).map(function(e){return e[t]}).reverse().reduce(function(t,r){var i={};r.filter(function(t){for(var r,o=Object.keys(t),a=0;a<o.length;a+=1){var s=o[a],c=s.toLowerCase();-1===e.indexOf(c)||"rel"===r&&"canonical"===t[r].toLowerCase()||"rel"===c&&"stylesheet"===t[c].toLowerCase()||(r=c),-1===e.indexOf(s)||"innerHTML"!==s&&"cssText"!==s&&"itemprop"!==s||(r=s)}if(!r||!t[r])return!1;var u=t[r].toLowerCase();return n[r]||(n[r]={}),i[r]||(i[r]={}),!n[r][u]&&(i[r][u]=!0,!0)}).reverse().forEach(function(e){return t.push(e)});for(var o=Object.keys(i),s=0;s<o.length;s+=1){var c=o[s],u=a({},n[c],i[c]);n[c]=u}return t},[]).reverse()},O=function(t,e){if(Array.isArray(t)&&t.length)for(var r=0;r<t.length;r+=1)if(t[r][e])return!0;return!1},S=function(t){return Array.isArray(t)?t.join(""):t},E=function(t,e){return Array.isArray(t)?t.reduce(function(t,r){return function(t,e){for(var r=Object.keys(t),n=0;n<r.length;n+=1)if(e[r[n]]&&e[r[n]].includes(t[r[n]]))return!0;return!1}(r,e)?t.priority.push(r):t.default.push(r),t},{priority:[],default:[]}):{default:t}},I=[l.NOSCRIPT,l.SCRIPT,l.STYLE],P=function(t,e){return void 0===e&&(e=!0),!1===e?String(t):String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},w=function(t){return Object.keys(t).reduce(function(e,r){var n=void 0!==t[r]?r+'="'+t[r]+'"':""+r;return e?e+" "+n:n},"")},L=function(t,e){return void 0===e&&(e={}),Object.keys(t).reduce(function(e,r){return e[m[r]||r]=t[r],e},e)},x=function(e,r){return r.map(function(r,n){var i,o=((i={key:n})["data-rh"]=!0,i);return Object.keys(r).forEach(function(t){var e=m[t]||t;"innerHTML"===e||"cssText"===e?o.dangerouslySetInnerHTML={__html:r.innerHTML||r.cssText}:o[e]=r[t]}),t.createElement(e,o)})},j=function(e,r,n){switch(e){case l.TITLE:return{toComponent:function(){return n=r.titleAttributes,(i={key:e=r.title})["data-rh"]=!0,o=L(n,i),[t.createElement(l.TITLE,o,e)];var e,n,i,o},toString:function(){return function(t,e,r,n){var i=w(r),o=S(e);return i?"<"+t+' data-rh="true" '+i+">"+P(o,n)+"</"+t+">":"<"+t+' data-rh="true">'+P(o,n)+"</"+t+">"}(e,r.title,r.titleAttributes,n)}};case"bodyAttributes":case"htmlAttributes":return{toComponent:function(){return L(r)},toString:function(){return w(r)}};default:return{toComponent:function(){return x(e,r)},toString:function(){return function(t,e,r){return e.reduce(function(e,n){var i=Object.keys(n).filter(function(t){return!("innerHTML"===t||"cssText"===t)}).reduce(function(t,e){var i=void 0===n[e]?e:e+'="'+P(n[e],r)+'"';return t?t+" "+i:i},""),o=n.innerHTML||n.cssText||"",a=-1===I.indexOf(t);return e+"<"+t+' data-rh="true" '+i+(a?"/>":">"+o+"</"+t+">")},"")}(e,r,n)}}}},k=function(t){var e=t.baseTag,r=t.bodyAttributes,n=t.encode,i=t.htmlAttributes,o=t.noscriptTags,a=t.styleTags,s=t.title,c=void 0===s?"":s,u=t.titleAttributes,h=t.linkTags,m=t.metaTags,y=t.scriptTags,T={toComponent:function(){},toString:function(){return""}};if(t.prioritizeSeoTags){var g=function(t){var e=t.linkTags,r=t.scriptTags,n=t.encode,i=E(t.metaTags,d),o=E(e,p),a=E(r,f);return{priorityMethods:{toComponent:function(){return[].concat(x(l.META,i.priority),x(l.LINK,o.priority),x(l.SCRIPT,a.priority))},toString:function(){return j(l.META,i.priority,n)+" "+j(l.LINK,o.priority,n)+" "+j(l.SCRIPT,a.priority,n)}},metaTags:i.default,linkTags:o.default,scriptTags:a.default}}(t);T=g.priorityMethods,h=g.linkTags,m=g.metaTags,y=g.scriptTags}return{priority:T,base:j(l.BASE,e,n),bodyAttributes:j("bodyAttributes",r,n),htmlAttributes:j("htmlAttributes",i,n),link:j(l.LINK,h,n),meta:j(l.META,m,n),noscript:j(l.NOSCRIPT,o,n),script:j(l.SCRIPT,y,n),style:j(l.STYLE,a,n),title:j(l.TITLE,{title:c,titleAttributes:u},n)}},M=function t(e){var r=this;this.instances=[],this.value={setHelmet:function(t){r.context.helmet=t},helmetInstances:{get:function(){return r.instances},add:function(t){r.instances.push(t)},remove:function(t){var e=r.instances.indexOf(t);r.instances.splice(e,1)}}},this.context=e,t.canUseDOM||(e.helmet=k({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))},H=t.createContext({}),N=r.shape({setHelmet:r.func,helmetInstances:r.shape({get:r.func,add:r.func,remove:r.func})}),R="undefined"!=typeof document,D=function(e){function r(t){var r;return(r=e.call(this,t)||this).helmetData=new M(r.props.context),r}return s(r,e),r.prototype.render=function(){return t.createElement(H.Provider,{value:this.helmetData.value},this.props.children)},r}(e);D.canUseDOM=R,D.propTypes={context:r.shape({helmet:r.shape()}),children:r.node.isRequired},D.defaultProps={context:{}},D.displayName="HelmetProvider";var q=function(t,e){var r,n=document.head||document.querySelector(l.HEAD),i=n.querySelectorAll(t+"[data-rh]"),o=[].slice.call(i),a=[];return e&&e.length&&e.forEach(function(e){var n=document.createElement(t);for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&("innerHTML"===i?n.innerHTML=e.innerHTML:"cssText"===i?n.styleSheet?n.styleSheet.cssText=e.cssText:n.appendChild(document.createTextNode(e.cssText)):n.setAttribute(i,void 0===e[i]?"":e[i]));n.setAttribute("data-rh","true"),o.some(function(t,e){return r=e,n.isEqualNode(t)})?o.splice(r,1):a.push(n)}),o.forEach(function(t){return t.parentNode.removeChild(t)}),a.forEach(function(t){return n.appendChild(t)}),{oldTags:o,newTags:a}},Y=function(t,e){var r=document.getElementsByTagName(t)[0];if(r){for(var n=r.getAttribute("data-rh"),i=n?n.split(","):[],o=[].concat(i),a=Object.keys(e),s=0;s<a.length;s+=1){var c=a[s],u=e[c]||"";r.getAttribute(c)!==u&&r.setAttribute(c,u),-1===i.indexOf(c)&&i.push(c);var l=o.indexOf(c);-1!==l&&o.splice(l,1)}for(var p=o.length-1;p>=0;p-=1)r.removeAttribute(o[p]);i.length===o.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==a.join(",")&&r.setAttribute("data-rh",a.join(","))}},B=function(t,e){var r=t.baseTag,n=t.htmlAttributes,i=t.linkTags,o=t.metaTags,a=t.noscriptTags,s=t.onChangeClientState,c=t.scriptTags,u=t.styleTags,p=t.title,f=t.titleAttributes;Y(l.BODY,t.bodyAttributes),Y(l.HTML,n),function(t,e){void 0!==t&&document.title!==t&&(document.title=S(t)),Y(l.TITLE,e)}(p,f);var d={baseTag:q(l.BASE,r),linkTags:q(l.LINK,i),metaTags:q(l.META,o),noscriptTags:q(l.NOSCRIPT,a),scriptTags:q(l.SCRIPT,c),styleTags:q(l.STYLE,u)},h={},m={};Object.keys(d).forEach(function(t){var e=d[t],r=e.newTags,n=e.oldTags;r.length&&(h[t]=r),n.length&&(m[t]=d[t].oldTags)}),e&&e(),s(t,h,m)},K=null,U=function(t){function e(){for(var e,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return(e=t.call.apply(t,[this].concat(n))||this).rendered=!1,e}s(e,t);var r=e.prototype;return r.shouldComponentUpdate=function(t){return!o(t,this.props)},r.componentDidUpdate=function(){this.emitChange()},r.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},r.emitChange=function(){var t,e,r=this.props.context,n=r.setHelmet,i=null,o=(t=r.helmetInstances.get().map(function(t){var e=a({},t.props);return delete e.context,e}),{baseTag:A(["href"],t),bodyAttributes:v("bodyAttributes",t),defer:T(t,"defer"),encode:T(t,"encodeSpecialCharacters"),htmlAttributes:v("htmlAttributes",t),linkTags:C(l.LINK,["rel","href"],t),metaTags:C(l.META,["name","charset","http-equiv","property","itemprop"],t),noscriptTags:C(l.NOSCRIPT,["innerHTML"],t),onChangeClientState:b(t),scriptTags:C(l.SCRIPT,["src","innerHTML"],t),styleTags:C(l.STYLE,["cssText"],t),title:g(t),titleAttributes:v("titleAttributes",t),prioritizeSeoTags:O(t,"prioritizeSeoTags")});D.canUseDOM?(e=o,K&&cancelAnimationFrame(K),e.defer?K=requestAnimationFrame(function(){B(e,function(){K=null})}):(B(e),K=null)):k&&(i=k(o)),n(i)},r.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},r.render=function(){return this.init(),null},e}(e);U.propTypes={context:N.isRequired},U.displayName="HelmetDispatcher";var _=["children"],z=["children","helmetData"],F=function(e){function r(){return e.apply(this,arguments)||this}s(r,e);var o=r.prototype;return o.shouldComponentUpdate=function(t){return!n(this.props,t)},o.mapNestedChildrenToProps=function(t,e){if(!e)return null;switch(t.type){case l.SCRIPT:case l.NOSCRIPT:return{innerHTML:e};case l.STYLE:return{cssText:e};default:throw new Error("<"+t.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")}},o.flattenArrayTypeChildren=function(t){var e,r=t.child,n=t.arrayTypeChildren;return a({},n,((e={})[r.type]=[].concat(n[r.type]||[],[a({},t.newChildProps,this.mapNestedChildrenToProps(r,t.nestedChildren))]),e))},o.mapObjectTypeChildren=function(t){var e,r,n=t.child,i=t.newProps,o=t.newChildProps,s=t.nestedChildren;switch(n.type){case l.TITLE:return a({},i,((e={})[n.type]=s,e.titleAttributes=a({},o),e));case l.BODY:return a({},i,{bodyAttributes:a({},o)});case l.HTML:return a({},i,{htmlAttributes:a({},o)});default:return a({},i,((r={})[n.type]=a({},o),r))}},o.mapArrayTypeChildrenToProps=function(t,e){var r=a({},e);return Object.keys(t).forEach(function(e){var n;r=a({},r,((n={})[e]=t[e],n))}),r},o.warnOnInvalidChildren=function(t,e){return i(h.some(function(e){return t.type===e}),"function"==typeof t.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 "+h.join(", ")+" are allowed. Helmet does not support rendering <"+t.type+"> elements. Refer to our API for more information."),i(!e||"string"==typeof e||Array.isArray(e)&&!e.some(function(t){return"string"!=typeof t}),"Helmet expects a string as a child of <"+t.type+">. Did you forget to wrap your children in braces? ( <"+t.type+">{``}</"+t.type+"> ) Refer to our API for more information."),!0},o.mapChildrenToProps=function(e,r){var n=this,i={};return t.Children.forEach(e,function(t){if(t&&t.props){var e=t.props,o=e.children,a=u(e,_),s=Object.keys(a).reduce(function(t,e){return t[y[e]||e]=a[e],t},{}),c=t.type;switch("symbol"==typeof c?c=c.toString():n.warnOnInvalidChildren(t,o),c){case l.FRAGMENT:r=n.mapChildrenToProps(o,r);break;case l.LINK:case l.META:case l.NOSCRIPT:case l.SCRIPT:case l.STYLE:i=n.flattenArrayTypeChildren({child:t,arrayTypeChildren:i,newChildProps:s,nestedChildren:o});break;default:r=n.mapObjectTypeChildren({child:t,newProps:r,newChildProps:s,nestedChildren:o})}}}),this.mapArrayTypeChildrenToProps(i,r)},o.render=function(){var e=this.props,r=e.children,n=e.helmetData,i=a({},u(e,z));return r&&(i=this.mapChildrenToProps(r,i)),n?t.createElement(U,a({},i,{context:n.value})):t.createElement(H.Consumer,null,function(e){return t.createElement(U,a({},i,{context:e}))})},r}(e);F.propTypes={base:r.object,bodyAttributes:r.object,children:r.oneOfType([r.arrayOf(r.node),r.node]),defaultTitle:r.string,defer:r.bool,encodeSpecialCharacters:r.bool,htmlAttributes:r.object,link:r.arrayOf(r.object),meta:r.arrayOf(r.object),noscript:r.arrayOf(r.object),onChangeClientState:r.func,script:r.arrayOf(r.object),style:r.arrayOf(r.object),title:r.string,titleAttributes:r.object,titleTemplate:r.string,prioritizeSeoTags:r.bool,helmetData:r.object},F.defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1},F.displayName="Helmet";export{F as Helmet,M as HelmetData,D as HelmetProvider}; | ||
import t,{Component as e}from"react";import r from"prop-types";import n from"react-fast-compare";import i from"invariant";import o from"shallowequal";function a(){return(a=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function s(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,c(t,e)}function c(t,e){return(c=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t,e){if(null==t)return{};var r,n,i={},o=Object.keys(t);for(n=0;n<o.length;n++)e.indexOf(r=o[n])>=0||(i[r]=t[r]);return i}var l={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},p={rel:["amphtml","canonical","alternate"]},f={type:["application/ld+json"]},d={charset:"",name:["robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},h=Object.keys(l).map(function(t){return l[t]}),m={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},y=Object.keys(m).reduce(function(t,e){return t[m[e]]=e,t},{}),T=function(t,e){for(var r=t.length-1;r>=0;r-=1){var n=t[r];if(Object.prototype.hasOwnProperty.call(n,e))return n[e]}return null},g=function(t){var e=T(t,l.TITLE),r=T(t,"titleTemplate");if(Array.isArray(e)&&(e=e.join("")),r&&e)return r.replace(/%s/g,function(){return e});var n=T(t,"defaultTitle");return e||n||void 0},b=function(t){return T(t,"onChangeClientState")||function(){}},v=function(t,e){return e.filter(function(e){return void 0!==e[t]}).map(function(e){return e[t]}).reduce(function(t,e){return a({},t,e)},{})},A=function(t,e){return e.filter(function(t){return void 0!==t[l.BASE]}).map(function(t){return t[l.BASE]}).reverse().reduce(function(e,r){if(!e.length)for(var n=Object.keys(r),i=0;i<n.length;i+=1){var o=n[i].toLowerCase();if(-1!==t.indexOf(o)&&r[o])return e.concat(r)}return e},[])},C=function(t,e,r){var n={};return r.filter(function(e){return!!Array.isArray(e[t])||(void 0!==e[t]&&console&&"function"==typeof console.warn&&console.warn("Helmet: "+t+' should be of type "Array". Instead found type "'+typeof e[t]+'"'),!1)}).map(function(e){return e[t]}).reverse().reduce(function(t,r){var i={};r.filter(function(t){for(var r,o=Object.keys(t),a=0;a<o.length;a+=1){var s=o[a],c=s.toLowerCase();-1===e.indexOf(c)||"rel"===r&&"canonical"===t[r].toLowerCase()||"rel"===c&&"stylesheet"===t[c].toLowerCase()||(r=c),-1===e.indexOf(s)||"innerHTML"!==s&&"cssText"!==s&&"itemprop"!==s||(r=s)}if(!r||!t[r])return!1;var u=t[r].toLowerCase();return n[r]||(n[r]={}),i[r]||(i[r]={}),!n[r][u]&&(i[r][u]=!0,!0)}).reverse().forEach(function(e){return t.push(e)});for(var o=Object.keys(i),s=0;s<o.length;s+=1){var c=o[s],u=a({},n[c],i[c]);n[c]=u}return t},[]).reverse()},O=function(t,e){if(Array.isArray(t)&&t.length)for(var r=0;r<t.length;r+=1)if(t[r][e])return!0;return!1},S=function(t){return Array.isArray(t)?t.join(""):t},E=function(t,e){return Array.isArray(t)?t.reduce(function(t,r){return function(t,e){for(var r=Object.keys(t),n=0;n<r.length;n+=1)if(e[r[n]]&&e[r[n]].includes(t[r[n]]))return!0;return!1}(r,e)?t.priority.push(r):t.default.push(r),t},{priority:[],default:[]}):{default:t}},I=[l.NOSCRIPT,l.SCRIPT,l.STYLE],P=function(t,e){return void 0===e&&(e=!0),!1===e?String(t):String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")},w=function(t){return Object.keys(t).reduce(function(e,r){var n=void 0!==t[r]?r+'="'+t[r]+'"':""+r;return e?e+" "+n:n},"")},x=function(t,e){return void 0===e&&(e={}),Object.keys(t).reduce(function(e,r){return e[m[r]||r]=t[r],e},e)},L=function(e,r){return r.map(function(r,n){var i,o=((i={key:n})["data-rh"]=!0,i);return Object.keys(r).forEach(function(t){var e=m[t]||t;"innerHTML"===e||"cssText"===e?o.dangerouslySetInnerHTML={__html:r.innerHTML||r.cssText}:o[e]=r[t]}),t.createElement(e,o)})},j=function(e,r,n){switch(e){case l.TITLE:return{toComponent:function(){return n=r.titleAttributes,(i={key:e=r.title})["data-rh"]=!0,o=x(n,i),[t.createElement(l.TITLE,o,e)];var e,n,i,o},toString:function(){return function(t,e,r,n){var i=w(r),o=S(e);return i?"<"+t+' data-rh="true" '+i+">"+P(o,n)+"</"+t+">":"<"+t+' data-rh="true">'+P(o,n)+"</"+t+">"}(e,r.title,r.titleAttributes,n)}};case"bodyAttributes":case"htmlAttributes":return{toComponent:function(){return x(r)},toString:function(){return w(r)}};default:return{toComponent:function(){return L(e,r)},toString:function(){return function(t,e,r){return e.reduce(function(e,n){var i=Object.keys(n).filter(function(t){return!("innerHTML"===t||"cssText"===t)}).reduce(function(t,e){var i=void 0===n[e]?e:e+'="'+P(n[e],r)+'"';return t?t+" "+i:i},""),o=n.innerHTML||n.cssText||"",a=-1===I.indexOf(t);return e+"<"+t+' data-rh="true" '+i+(a?"/>":">"+o+"</"+t+">")},"")}(e,r,n)}}}},k=function(t){var e=t.baseTag,r=t.bodyAttributes,n=t.encode,i=t.htmlAttributes,o=t.noscriptTags,a=t.styleTags,s=t.title,c=void 0===s?"":s,u=t.titleAttributes,h=t.linkTags,m=t.metaTags,y=t.scriptTags,T={toComponent:function(){},toString:function(){return""}};if(t.prioritizeSeoTags){var g=function(t){var e=t.linkTags,r=t.scriptTags,n=t.encode,i=E(t.metaTags,d),o=E(e,p),a=E(r,f);return{priorityMethods:{toComponent:function(){return[].concat(L(l.META,i.priority),L(l.LINK,o.priority),L(l.SCRIPT,a.priority))},toString:function(){return j(l.META,i.priority,n)+" "+j(l.LINK,o.priority,n)+" "+j(l.SCRIPT,a.priority,n)}},metaTags:i.default,linkTags:o.default,scriptTags:a.default}}(t);T=g.priorityMethods,h=g.linkTags,m=g.metaTags,y=g.scriptTags}return{priority:T,base:j(l.BASE,e,n),bodyAttributes:j("bodyAttributes",r,n),htmlAttributes:j("htmlAttributes",i,n),link:j(l.LINK,h,n),meta:j(l.META,m,n),noscript:j(l.NOSCRIPT,o,n),script:j(l.SCRIPT,y,n),style:j(l.STYLE,a,n),title:j(l.TITLE,{title:c,titleAttributes:u},n)}},M=function t(e,r){var n=this;this.instances=[],this.value={setHelmet:function(t){n.context.helmet=t},helmetInstances:{get:function(){return n.instances},add:function(t){n.instances.push(t)},remove:function(t){var e=n.instances.indexOf(t);n.instances.splice(e,1)}}},this.context=e,r&&(this.instances=r),t.canUseDOM||(e.helmet=k({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))},H=t.createContext({}),N=r.shape({setHelmet:r.func,helmetInstances:r.shape({get:r.func,add:r.func,remove:r.func})}),R="undefined"!=typeof document,D=function(e){function r(t){var r;return(r=e.call(this,t)||this).helmetData=new M(r.props.context),r}return s(r,e),r.prototype.render=function(){return t.createElement(H.Provider,{value:this.helmetData.value},this.props.children)},r}(e);D.canUseDOM=R,D.propTypes={context:r.shape({helmet:r.shape()}),children:r.node.isRequired},D.defaultProps={context:{}},D.displayName="HelmetProvider";var q=function(t,e){var r,n=document.head||document.querySelector(l.HEAD),i=n.querySelectorAll(t+"[data-rh]"),o=[].slice.call(i),a=[];return e&&e.length&&e.forEach(function(e){var n=document.createElement(t);for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&("innerHTML"===i?n.innerHTML=e.innerHTML:"cssText"===i?n.styleSheet?n.styleSheet.cssText=e.cssText:n.appendChild(document.createTextNode(e.cssText)):n.setAttribute(i,void 0===e[i]?"":e[i]));n.setAttribute("data-rh","true"),o.some(function(t,e){return r=e,n.isEqualNode(t)})?o.splice(r,1):a.push(n)}),o.forEach(function(t){return t.parentNode.removeChild(t)}),a.forEach(function(t){return n.appendChild(t)}),{oldTags:o,newTags:a}},Y=function(t,e){var r=document.getElementsByTagName(t)[0];if(r){for(var n=r.getAttribute("data-rh"),i=n?n.split(","):[],o=[].concat(i),a=Object.keys(e),s=0;s<a.length;s+=1){var c=a[s],u=e[c]||"";r.getAttribute(c)!==u&&r.setAttribute(c,u),-1===i.indexOf(c)&&i.push(c);var l=o.indexOf(c);-1!==l&&o.splice(l,1)}for(var p=o.length-1;p>=0;p-=1)r.removeAttribute(o[p]);i.length===o.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==a.join(",")&&r.setAttribute("data-rh",a.join(","))}},B=function(t,e){var r=t.baseTag,n=t.htmlAttributes,i=t.linkTags,o=t.metaTags,a=t.noscriptTags,s=t.onChangeClientState,c=t.scriptTags,u=t.styleTags,p=t.title,f=t.titleAttributes;Y(l.BODY,t.bodyAttributes),Y(l.HTML,n),function(t,e){void 0!==t&&document.title!==t&&(document.title=S(t)),Y(l.TITLE,e)}(p,f);var d={baseTag:q(l.BASE,r),linkTags:q(l.LINK,i),metaTags:q(l.META,o),noscriptTags:q(l.NOSCRIPT,a),scriptTags:q(l.SCRIPT,c),styleTags:q(l.STYLE,u)},h={},m={};Object.keys(d).forEach(function(t){var e=d[t],r=e.newTags,n=e.oldTags;r.length&&(h[t]=r),n.length&&(m[t]=d[t].oldTags)}),e&&e(),s(t,h,m)},K=null,U=function(t){function e(){for(var e,r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return(e=t.call.apply(t,[this].concat(n))||this).rendered=!1,e}s(e,t);var r=e.prototype;return r.shouldComponentUpdate=function(t){return!o(t,this.props)},r.componentDidUpdate=function(){this.emitChange()},r.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},r.emitChange=function(){var t,e,r=this.props.context,n=r.setHelmet,i=null,o=(t=r.helmetInstances.get().map(function(t){var e=a({},t.props);return delete e.context,e}),{baseTag:A(["href"],t),bodyAttributes:v("bodyAttributes",t),defer:T(t,"defer"),encode:T(t,"encodeSpecialCharacters"),htmlAttributes:v("htmlAttributes",t),linkTags:C(l.LINK,["rel","href"],t),metaTags:C(l.META,["name","charset","http-equiv","property","itemprop"],t),noscriptTags:C(l.NOSCRIPT,["innerHTML"],t),onChangeClientState:b(t),scriptTags:C(l.SCRIPT,["src","innerHTML"],t),styleTags:C(l.STYLE,["cssText"],t),title:g(t),titleAttributes:v("titleAttributes",t),prioritizeSeoTags:O(t,"prioritizeSeoTags")});D.canUseDOM?(e=o,K&&cancelAnimationFrame(K),e.defer?K=requestAnimationFrame(function(){B(e,function(){K=null})}):(B(e),K=null)):k&&(i=k(o)),n(i)},r.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},r.render=function(){return this.init(),null},e}(e);U.propTypes={context:N.isRequired},U.displayName="HelmetDispatcher";var _=["children"],z=["children"],F=function(e){function r(){return e.apply(this,arguments)||this}s(r,e);var o=r.prototype;return o.shouldComponentUpdate=function(t){return!n(this.props,t)},o.mapNestedChildrenToProps=function(t,e){if(!e)return null;switch(t.type){case l.SCRIPT:case l.NOSCRIPT:return{innerHTML:e};case l.STYLE:return{cssText:e};default:throw new Error("<"+t.type+" /> elements are self-closing and can not contain children. Refer to our API for more information.")}},o.flattenArrayTypeChildren=function(t){var e,r=t.child,n=t.arrayTypeChildren;return a({},n,((e={})[r.type]=[].concat(n[r.type]||[],[a({},t.newChildProps,this.mapNestedChildrenToProps(r,t.nestedChildren))]),e))},o.mapObjectTypeChildren=function(t){var e,r,n=t.child,i=t.newProps,o=t.newChildProps,s=t.nestedChildren;switch(n.type){case l.TITLE:return a({},i,((e={})[n.type]=s,e.titleAttributes=a({},o),e));case l.BODY:return a({},i,{bodyAttributes:a({},o)});case l.HTML:return a({},i,{htmlAttributes:a({},o)});default:return a({},i,((r={})[n.type]=a({},o),r))}},o.mapArrayTypeChildrenToProps=function(t,e){var r=a({},e);return Object.keys(t).forEach(function(e){var n;r=a({},r,((n={})[e]=t[e],n))}),r},o.warnOnInvalidChildren=function(t,e){return i(h.some(function(e){return t.type===e}),"function"==typeof t.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 "+h.join(", ")+" are allowed. Helmet does not support rendering <"+t.type+"> elements. Refer to our API for more information."),i(!e||"string"==typeof e||Array.isArray(e)&&!e.some(function(t){return"string"!=typeof t}),"Helmet expects a string as a child of <"+t.type+">. Did you forget to wrap your children in braces? ( <"+t.type+">{``}</"+t.type+"> ) Refer to our API for more information."),!0},o.mapChildrenToProps=function(e,r){var n=this,i={};return t.Children.forEach(e,function(t){if(t&&t.props){var e=t.props,o=e.children,a=u(e,_),s=Object.keys(a).reduce(function(t,e){return t[y[e]||e]=a[e],t},{}),c=t.type;switch("symbol"==typeof c?c=c.toString():n.warnOnInvalidChildren(t,o),c){case l.FRAGMENT:r=n.mapChildrenToProps(o,r);break;case l.LINK:case l.META:case l.NOSCRIPT:case l.SCRIPT:case l.STYLE:i=n.flattenArrayTypeChildren({child:t,arrayTypeChildren:i,newChildProps:s,nestedChildren:o});break;default:r=n.mapObjectTypeChildren({child:t,newProps:r,newChildProps:s,nestedChildren:o})}}}),this.mapArrayTypeChildrenToProps(i,r)},o.render=function(){var e=this.props,r=e.children,n=u(e,z),i=a({},n),o=n.helmetData;return r&&(i=this.mapChildrenToProps(r,i)),!o||o instanceof M||(o=new M(o.context,o.instances)),o?t.createElement(U,a({},i,{context:o.value})):t.createElement(H.Consumer,null,function(e){return t.createElement(U,a({},i,{context:e}))})},r}(e);F.propTypes={base:r.object,bodyAttributes:r.object,children:r.oneOfType([r.arrayOf(r.node),r.node]),defaultTitle:r.string,defer:r.bool,encodeSpecialCharacters:r.bool,htmlAttributes:r.object,link:r.arrayOf(r.object),meta:r.arrayOf(r.object),noscript:r.arrayOf(r.object),onChangeClientState:r.func,script:r.arrayOf(r.object),style:r.arrayOf(r.object),title:r.string,titleAttributes:r.object,titleTemplate:r.string,prioritizeSeoTags:r.bool,helmetData:r.object},F.defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1},F.displayName="Helmet";export{F as Helmet,M as HelmetData,D as HelmetProvider}; | ||
//# sourceMappingURL=index.module.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("react-fast-compare"),require("invariant"),require("shallowequal")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","react-fast-compare","invariant","shallowequal"],t):t((e||self).reactHelmetAsync={},e.react,e.propTypes,e.reactFastCompare,e.invariant,e.shallowequal)}(this,function(e,t,r,n,i,a){function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=o(t),s=o(r),c=o(n),l=o(i),f=o(a);function p(){return(p=Object.assign||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}).apply(this,arguments)}function d(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,h(e,t)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n<a.length;n++)t.indexOf(r=a[n])>=0||(i[r]=e[r]);return i}var m="cssText",T="href",g="innerHTML",b="itemprop",v="rel",A="bodyAttributes",C="htmlAttributes",O={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},S={rel:["amphtml","canonical","alternate"]},E={type:["application/ld+json"]},I={charset:"",name:["robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},w=Object.keys(O).map(function(e){return O[e]}),P={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},j=Object.keys(P).reduce(function(e,t){return e[P[t]]=t,e},{}),x="data-rh",L=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},k=function(e){var t=L(e,O.TITLE),r=L(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,function(){return t});var n=L(e,"defaultTitle");return t||n||void 0},H=function(e){return L(e,"onChangeClientState")||function(){}},N=function(e,t){return t.filter(function(t){return void 0!==t[e]}).map(function(t){return t[e]}).reduce(function(e,t){return p({},e,t)},{})},M=function(e,t){return t.filter(function(e){return void 0!==e[O.BASE]}).map(function(e){return e[O.BASE]}).reverse().reduce(function(t,r){if(!t.length)for(var n=Object.keys(r),i=0;i<n.length;i+=1){var a=n[i].toLowerCase();if(-1!==e.indexOf(a)&&r[a])return t.concat(r)}return t},[])},R=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 i={};r.filter(function(e){for(var r,a=Object.keys(e),o=0;o<a.length;o+=1){var u=a[o],s=u.toLowerCase();-1===t.indexOf(s)||r===v&&"canonical"===e[r].toLowerCase()||s===v&&"stylesheet"===e[s].toLowerCase()||(r=s),-1===t.indexOf(u)||u!==g&&u!==m&&u!==b||(r=u)}if(!r||!e[r])return!1;var c=e[r].toLowerCase();return n[r]||(n[r]={}),i[r]||(i[r]={}),!n[r][c]&&(i[r][c]=!0,!0)}).reverse().forEach(function(t){return e.push(t)});for(var a=Object.keys(i),o=0;o<a.length;o+=1){var u=a[o],s=p({},n[u],i[u]);n[u]=s}return e},[]).reverse()},q=function(e,t){if(Array.isArray(e)&&e.length)for(var r=0;r<e.length;r+=1)if(e[r][t])return!0;return!1},D=function(e){return Array.isArray(e)?e.join(""):e},Y=function(e,t){return Array.isArray(e)?e.reduce(function(e,r){return function(e,t){for(var r=Object.keys(e),n=0;n<r.length;n+=1)if(t[r[n]]&&t[r[n]].includes(e[r[n]]))return!0;return!1}(r,t)?e.priority.push(r):e.default.push(r),e},{priority:[],default:[]}):{default:e}},B=[O.NOSCRIPT,O.SCRIPT,O.STYLE],K=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,"'")},U=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},"")},_=function(e,t){return void 0===t&&(t={}),Object.keys(e).reduce(function(t,r){return t[P[r]||r]=e[r],t},t)},z=function(e,t){return t.map(function(t,r){var n,i=((n={key:r})["data-rh"]=!0,n);return Object.keys(t).forEach(function(e){var r=P[e]||e;r===g||r===m?i.dangerouslySetInnerHTML={__html:t.innerHTML||t.cssText}:i[r]=t[e]}),u.default.createElement(e,i)})},F=function(e,t,r){switch(e){case O.TITLE:return{toComponent:function(){return r=t.titleAttributes,(n={key:e=t.title})["data-rh"]=!0,i=_(r,n),[u.default.createElement(O.TITLE,i,e)];var e,r,n,i},toString:function(){return function(e,t,r,n){var i=U(r),a=D(t);return i?"<"+e+' data-rh="true" '+i+">"+K(a,n)+"</"+e+">":"<"+e+' data-rh="true">'+K(a,n)+"</"+e+">"}(e,t.title,t.titleAttributes,r)}};case A:case C:return{toComponent:function(){return _(t)},toString:function(){return U(t)}};default:return{toComponent:function(){return z(e,t)},toString:function(){return function(e,t,r){return t.reduce(function(t,n){var i=Object.keys(n).filter(function(e){return!(e===g||e===m)}).reduce(function(e,t){var i=void 0===n[t]?t:t+'="'+K(n[t],r)+'"';return e?e+" "+i:i},""),a=n.innerHTML||n.cssText||"",o=-1===B.indexOf(e);return t+"<"+e+' data-rh="true" '+i+(o?"/>":">"+a+"</"+e+">")},"")}(e,t,r)}}}},G=function(e){var t=e.baseTag,r=e.bodyAttributes,n=e.encode,i=e.htmlAttributes,a=e.noscriptTags,o=e.styleTags,u=e.title,s=void 0===u?"":u,c=e.titleAttributes,l=e.linkTags,f=e.metaTags,p=e.scriptTags,d={toComponent:function(){},toString:function(){return""}};if(e.prioritizeSeoTags){var h=function(e){var t=e.linkTags,r=e.scriptTags,n=e.encode,i=Y(e.metaTags,I),a=Y(t,S),o=Y(r,E);return{priorityMethods:{toComponent:function(){return[].concat(z(O.META,i.priority),z(O.LINK,a.priority),z(O.SCRIPT,o.priority))},toString:function(){return F(O.META,i.priority,n)+" "+F(O.LINK,a.priority,n)+" "+F(O.SCRIPT,o.priority,n)}},metaTags:i.default,linkTags:a.default,scriptTags:o.default}}(e);d=h.priorityMethods,l=h.linkTags,f=h.metaTags,p=h.scriptTags}return{priority:d,base:F(O.BASE,t,n),bodyAttributes:F(A,r,n),htmlAttributes:F(C,i,n),link:F(O.LINK,l,n),meta:F(O.META,f,n),noscript:F(O.NOSCRIPT,a,n),script:F(O.SCRIPT,p,n),style:F(O.STYLE,o,n),title:F(O.TITLE,{title:s,titleAttributes:c},n)}},W=function e(t){var r=this;this.instances=[],this.value={setHelmet:function(e){r.context.helmet=e},helmetInstances:{get:function(){return r.instances},add:function(e){r.instances.push(e)},remove:function(e){var t=r.instances.indexOf(e);r.instances.splice(t,1)}}},this.context=t,e.canUseDOM||(t.helmet=G({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))},J=u.default.createContext({}),Q=s.default.shape({setHelmet:s.default.func,helmetInstances:s.default.shape({get:s.default.func,add:s.default.func,remove:s.default.func})}),V="undefined"!=typeof document,X=function(e){function t(t){var r;return(r=e.call(this,t)||this).helmetData=new W(r.props.context),r}return d(t,e),t.prototype.render=function(){return u.default.createElement(J.Provider,{value:this.helmetData.value},this.props.children)},t}(t.Component);X.canUseDOM=V,X.propTypes={context:s.default.shape({helmet:s.default.shape()}),children:s.default.node.isRequired},X.defaultProps={context:{}},X.displayName="HelmetProvider";var Z=function(e,t){var r,n=document.head||document.querySelector(O.HEAD),i=n.querySelectorAll(e+"[data-rh]"),a=[].slice.call(i),o=[];return t&&t.length&&t.forEach(function(t){var n=document.createElement(e);for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(i===g?n.innerHTML=t.innerHTML:i===m?n.styleSheet?n.styleSheet.cssText=t.cssText:n.appendChild(document.createTextNode(t.cssText)):n.setAttribute(i,void 0===t[i]?"":t[i]));n.setAttribute(x,"true"),a.some(function(e,t){return r=t,n.isEqualNode(e)})?a.splice(r,1):o.push(n)}),a.forEach(function(e){return e.parentNode.removeChild(e)}),o.forEach(function(e){return n.appendChild(e)}),{oldTags:a,newTags:o}},$=function(e,t){var r=document.getElementsByTagName(e)[0];if(r){for(var n=r.getAttribute(x),i=n?n.split(","):[],a=[].concat(i),o=Object.keys(t),u=0;u<o.length;u+=1){var s=o[u],c=t[s]||"";r.getAttribute(s)!==c&&r.setAttribute(s,c),-1===i.indexOf(s)&&i.push(s);var l=a.indexOf(s);-1!==l&&a.splice(l,1)}for(var f=a.length-1;f>=0;f-=1)r.removeAttribute(a[f]);i.length===a.length?r.removeAttribute(x):r.getAttribute(x)!==o.join(",")&&r.setAttribute(x,o.join(","))}},ee=function(e,t){var r=e.baseTag,n=e.htmlAttributes,i=e.linkTags,a=e.metaTags,o=e.noscriptTags,u=e.onChangeClientState,s=e.scriptTags,c=e.styleTags,l=e.title,f=e.titleAttributes;$(O.BODY,e.bodyAttributes),$(O.HTML,n),function(e,t){void 0!==e&&document.title!==e&&(document.title=D(e)),$(O.TITLE,t)}(l,f);var p={baseTag:Z(O.BASE,r),linkTags:Z(O.LINK,i),metaTags:Z(O.META,a),noscriptTags:Z(O.NOSCRIPT,o),scriptTags:Z(O.SCRIPT,s),styleTags:Z(O.STYLE,c)},d={},h={};Object.keys(p).forEach(function(e){var t=p[e],r=t.newTags,n=t.oldTags;r.length&&(d[e]=r),n.length&&(h[e]=p[e].oldTags)}),t&&t(),u(e,d,h)},te=null,re=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).rendered=!1,t}d(t,e);var r=t.prototype;return r.shouldComponentUpdate=function(e){return!f.default(e,this.props)},r.componentDidUpdate=function(){this.emitChange()},r.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},r.emitChange=function(){var e,t,r=this.props.context,n=r.setHelmet,i=null,a=(e=r.helmetInstances.get().map(function(e){var t=p({},e.props);return delete t.context,t}),{baseTag:M([T],e),bodyAttributes:N(A,e),defer:L(e,"defer"),encode:L(e,"encodeSpecialCharacters"),htmlAttributes:N(C,e),linkTags:R(O.LINK,[v,T],e),metaTags:R(O.META,["name","charset","http-equiv","property",b],e),noscriptTags:R(O.NOSCRIPT,[g],e),onChangeClientState:H(e),scriptTags:R(O.SCRIPT,["src",g],e),styleTags:R(O.STYLE,[m],e),title:k(e),titleAttributes:N("titleAttributes",e),prioritizeSeoTags:q(e,"prioritizeSeoTags")});X.canUseDOM?(t=a,te&&cancelAnimationFrame(te),t.defer?te=requestAnimationFrame(function(){ee(t,function(){te=null})}):(ee(t),te=null)):G&&(i=G(a)),n(i)},r.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},r.render=function(){return this.init(),null},t}(t.Component);re.propTypes={context:Q.isRequired},re.displayName="HelmetDispatcher";var ne=["children"],ie=["children","helmetData"],ae=function(e){function t(){return e.apply(this,arguments)||this}d(t,e);var r=t.prototype;return r.shouldComponentUpdate=function(e){return!c.default(this.props,e)},r.mapNestedChildrenToProps=function(e,t){if(!t)return null;switch(e.type){case O.SCRIPT:case O.NOSCRIPT:return{innerHTML:t};case O.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.")}},r.flattenArrayTypeChildren=function(e){var t,r=e.child,n=e.arrayTypeChildren;return p({},n,((t={})[r.type]=[].concat(n[r.type]||[],[p({},e.newChildProps,this.mapNestedChildrenToProps(r,e.nestedChildren))]),t))},r.mapObjectTypeChildren=function(e){var t,r,n=e.child,i=e.newProps,a=e.newChildProps,o=e.nestedChildren;switch(n.type){case O.TITLE:return p({},i,((t={})[n.type]=o,t.titleAttributes=p({},a),t));case O.BODY:return p({},i,{bodyAttributes:p({},a)});case O.HTML:return p({},i,{htmlAttributes:p({},a)});default:return p({},i,((r={})[n.type]=p({},a),r))}},r.mapArrayTypeChildrenToProps=function(e,t){var r=p({},t);return Object.keys(e).forEach(function(t){var n;r=p({},r,((n={})[t]=e[t],n))}),r},r.warnOnInvalidChildren=function(e,t){return l.default(w.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 "+w.join(", ")+" are allowed. Helmet does not support rendering <"+e.type+"> elements. Refer to our API for more information."),l.default(!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},r.mapChildrenToProps=function(e,t){var r=this,n={};return u.default.Children.forEach(e,function(e){if(e&&e.props){var i=e.props,a=i.children,o=y(i,ne),u=Object.keys(o).reduce(function(e,t){return e[j[t]||t]=o[t],e},{}),s=e.type;switch("symbol"==typeof s?s=s.toString():r.warnOnInvalidChildren(e,a),s){case O.FRAGMENT:t=r.mapChildrenToProps(a,t);break;case O.LINK:case O.META:case O.NOSCRIPT:case O.SCRIPT:case O.STYLE:n=r.flattenArrayTypeChildren({child:e,arrayTypeChildren:n,newChildProps:u,nestedChildren:a});break;default:t=r.mapObjectTypeChildren({child:e,newProps:t,newChildProps:u,nestedChildren:a})}}}),this.mapArrayTypeChildrenToProps(n,t)},r.render=function(){var e=this.props,t=e.children,r=e.helmetData,n=p({},y(e,ie));return t&&(n=this.mapChildrenToProps(t,n)),r?u.default.createElement(re,p({},n,{context:r.value})):u.default.createElement(J.Consumer,null,function(e){return u.default.createElement(re,p({},n,{context:e}))})},t}(t.Component);ae.propTypes={base:s.default.object,bodyAttributes:s.default.object,children:s.default.oneOfType([s.default.arrayOf(s.default.node),s.default.node]),defaultTitle:s.default.string,defer:s.default.bool,encodeSpecialCharacters:s.default.bool,htmlAttributes:s.default.object,link:s.default.arrayOf(s.default.object),meta:s.default.arrayOf(s.default.object),noscript:s.default.arrayOf(s.default.object),onChangeClientState:s.default.func,script:s.default.arrayOf(s.default.object),style:s.default.arrayOf(s.default.object),title:s.default.string,titleAttributes:s.default.object,titleTemplate:s.default.string,prioritizeSeoTags:s.default.bool,helmetData:s.default.object},ae.defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1},ae.displayName="Helmet",e.Helmet=ae,e.HelmetData=W,e.HelmetProvider=X}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("prop-types"),require("react-fast-compare"),require("invariant"),require("shallowequal")):"function"==typeof define&&define.amd?define(["exports","react","prop-types","react-fast-compare","invariant","shallowequal"],t):t((e||self).reactHelmetAsync={},e.react,e.propTypes,e.reactFastCompare,e.invariant,e.shallowequal)}(this,function(e,t,r,n,i,a){function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=o(t),s=o(r),c=o(n),l=o(i),f=o(a);function p(){return(p=Object.assign||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}).apply(this,arguments)}function d(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,h(e,t)}function h(e,t){return(h=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n<a.length;n++)t.indexOf(r=a[n])>=0||(i[r]=e[r]);return i}var m="cssText",T="href",g="innerHTML",b="itemprop",v="rel",A="bodyAttributes",C="htmlAttributes",O={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},S={rel:["amphtml","canonical","alternate"]},E={type:["application/ld+json"]},w={charset:"",name:["robots","description"],property:["og:type","og:title","og:url","og:image","og:image:alt","og:description","twitter:url","twitter:title","twitter:description","twitter:image","twitter:image:alt","twitter:card","twitter:site"]},I=Object.keys(O).map(function(e){return O[e]}),P={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},j=Object.keys(P).reduce(function(e,t){return e[P[t]]=t,e},{}),x="data-rh",L=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},k=function(e){var t=L(e,O.TITLE),r=L(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,function(){return t});var n=L(e,"defaultTitle");return t||n||void 0},H=function(e){return L(e,"onChangeClientState")||function(){}},N=function(e,t){return t.filter(function(t){return void 0!==t[e]}).map(function(t){return t[e]}).reduce(function(e,t){return p({},e,t)},{})},M=function(e,t){return t.filter(function(e){return void 0!==e[O.BASE]}).map(function(e){return e[O.BASE]}).reverse().reduce(function(t,r){if(!t.length)for(var n=Object.keys(r),i=0;i<n.length;i+=1){var a=n[i].toLowerCase();if(-1!==e.indexOf(a)&&r[a])return t.concat(r)}return t},[])},R=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 i={};r.filter(function(e){for(var r,a=Object.keys(e),o=0;o<a.length;o+=1){var u=a[o],s=u.toLowerCase();-1===t.indexOf(s)||r===v&&"canonical"===e[r].toLowerCase()||s===v&&"stylesheet"===e[s].toLowerCase()||(r=s),-1===t.indexOf(u)||u!==g&&u!==m&&u!==b||(r=u)}if(!r||!e[r])return!1;var c=e[r].toLowerCase();return n[r]||(n[r]={}),i[r]||(i[r]={}),!n[r][c]&&(i[r][c]=!0,!0)}).reverse().forEach(function(t){return e.push(t)});for(var a=Object.keys(i),o=0;o<a.length;o+=1){var u=a[o],s=p({},n[u],i[u]);n[u]=s}return e},[]).reverse()},q=function(e,t){if(Array.isArray(e)&&e.length)for(var r=0;r<e.length;r+=1)if(e[r][t])return!0;return!1},D=function(e){return Array.isArray(e)?e.join(""):e},Y=function(e,t){return Array.isArray(e)?e.reduce(function(e,r){return function(e,t){for(var r=Object.keys(e),n=0;n<r.length;n+=1)if(t[r[n]]&&t[r[n]].includes(e[r[n]]))return!0;return!1}(r,t)?e.priority.push(r):e.default.push(r),e},{priority:[],default:[]}):{default:e}},B=[O.NOSCRIPT,O.SCRIPT,O.STYLE],K=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,"'")},U=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},"")},_=function(e,t){return void 0===t&&(t={}),Object.keys(e).reduce(function(t,r){return t[P[r]||r]=e[r],t},t)},z=function(e,t){return t.map(function(t,r){var n,i=((n={key:r})["data-rh"]=!0,n);return Object.keys(t).forEach(function(e){var r=P[e]||e;r===g||r===m?i.dangerouslySetInnerHTML={__html:t.innerHTML||t.cssText}:i[r]=t[e]}),u.default.createElement(e,i)})},F=function(e,t,r){switch(e){case O.TITLE:return{toComponent:function(){return r=t.titleAttributes,(n={key:e=t.title})["data-rh"]=!0,i=_(r,n),[u.default.createElement(O.TITLE,i,e)];var e,r,n,i},toString:function(){return function(e,t,r,n){var i=U(r),a=D(t);return i?"<"+e+' data-rh="true" '+i+">"+K(a,n)+"</"+e+">":"<"+e+' data-rh="true">'+K(a,n)+"</"+e+">"}(e,t.title,t.titleAttributes,r)}};case A:case C:return{toComponent:function(){return _(t)},toString:function(){return U(t)}};default:return{toComponent:function(){return z(e,t)},toString:function(){return function(e,t,r){return t.reduce(function(t,n){var i=Object.keys(n).filter(function(e){return!(e===g||e===m)}).reduce(function(e,t){var i=void 0===n[t]?t:t+'="'+K(n[t],r)+'"';return e?e+" "+i:i},""),a=n.innerHTML||n.cssText||"",o=-1===B.indexOf(e);return t+"<"+e+' data-rh="true" '+i+(o?"/>":">"+a+"</"+e+">")},"")}(e,t,r)}}}},G=function(e){var t=e.baseTag,r=e.bodyAttributes,n=e.encode,i=e.htmlAttributes,a=e.noscriptTags,o=e.styleTags,u=e.title,s=void 0===u?"":u,c=e.titleAttributes,l=e.linkTags,f=e.metaTags,p=e.scriptTags,d={toComponent:function(){},toString:function(){return""}};if(e.prioritizeSeoTags){var h=function(e){var t=e.linkTags,r=e.scriptTags,n=e.encode,i=Y(e.metaTags,w),a=Y(t,S),o=Y(r,E);return{priorityMethods:{toComponent:function(){return[].concat(z(O.META,i.priority),z(O.LINK,a.priority),z(O.SCRIPT,o.priority))},toString:function(){return F(O.META,i.priority,n)+" "+F(O.LINK,a.priority,n)+" "+F(O.SCRIPT,o.priority,n)}},metaTags:i.default,linkTags:a.default,scriptTags:o.default}}(e);d=h.priorityMethods,l=h.linkTags,f=h.metaTags,p=h.scriptTags}return{priority:d,base:F(O.BASE,t,n),bodyAttributes:F(A,r,n),htmlAttributes:F(C,i,n),link:F(O.LINK,l,n),meta:F(O.META,f,n),noscript:F(O.NOSCRIPT,a,n),script:F(O.SCRIPT,p,n),style:F(O.STYLE,o,n),title:F(O.TITLE,{title:s,titleAttributes:c},n)}},W=function e(t,r){var n=this;this.instances=[],this.value={setHelmet:function(e){n.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)}}},this.context=t,r&&(this.instances=r),e.canUseDOM||(t.helmet=G({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))},J=u.default.createContext({}),Q=s.default.shape({setHelmet:s.default.func,helmetInstances:s.default.shape({get:s.default.func,add:s.default.func,remove:s.default.func})}),V="undefined"!=typeof document,X=function(e){function t(t){var r;return(r=e.call(this,t)||this).helmetData=new W(r.props.context),r}return d(t,e),t.prototype.render=function(){return u.default.createElement(J.Provider,{value:this.helmetData.value},this.props.children)},t}(t.Component);X.canUseDOM=V,X.propTypes={context:s.default.shape({helmet:s.default.shape()}),children:s.default.node.isRequired},X.defaultProps={context:{}},X.displayName="HelmetProvider";var Z=function(e,t){var r,n=document.head||document.querySelector(O.HEAD),i=n.querySelectorAll(e+"[data-rh]"),a=[].slice.call(i),o=[];return t&&t.length&&t.forEach(function(t){var n=document.createElement(e);for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(i===g?n.innerHTML=t.innerHTML:i===m?n.styleSheet?n.styleSheet.cssText=t.cssText:n.appendChild(document.createTextNode(t.cssText)):n.setAttribute(i,void 0===t[i]?"":t[i]));n.setAttribute(x,"true"),a.some(function(e,t){return r=t,n.isEqualNode(e)})?a.splice(r,1):o.push(n)}),a.forEach(function(e){return e.parentNode.removeChild(e)}),o.forEach(function(e){return n.appendChild(e)}),{oldTags:a,newTags:o}},$=function(e,t){var r=document.getElementsByTagName(e)[0];if(r){for(var n=r.getAttribute(x),i=n?n.split(","):[],a=[].concat(i),o=Object.keys(t),u=0;u<o.length;u+=1){var s=o[u],c=t[s]||"";r.getAttribute(s)!==c&&r.setAttribute(s,c),-1===i.indexOf(s)&&i.push(s);var l=a.indexOf(s);-1!==l&&a.splice(l,1)}for(var f=a.length-1;f>=0;f-=1)r.removeAttribute(a[f]);i.length===a.length?r.removeAttribute(x):r.getAttribute(x)!==o.join(",")&&r.setAttribute(x,o.join(","))}},ee=function(e,t){var r=e.baseTag,n=e.htmlAttributes,i=e.linkTags,a=e.metaTags,o=e.noscriptTags,u=e.onChangeClientState,s=e.scriptTags,c=e.styleTags,l=e.title,f=e.titleAttributes;$(O.BODY,e.bodyAttributes),$(O.HTML,n),function(e,t){void 0!==e&&document.title!==e&&(document.title=D(e)),$(O.TITLE,t)}(l,f);var p={baseTag:Z(O.BASE,r),linkTags:Z(O.LINK,i),metaTags:Z(O.META,a),noscriptTags:Z(O.NOSCRIPT,o),scriptTags:Z(O.SCRIPT,s),styleTags:Z(O.STYLE,c)},d={},h={};Object.keys(p).forEach(function(e){var t=p[e],r=t.newTags,n=t.oldTags;r.length&&(d[e]=r),n.length&&(h[e]=p[e].oldTags)}),t&&t(),u(e,d,h)},te=null,re=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).rendered=!1,t}d(t,e);var r=t.prototype;return r.shouldComponentUpdate=function(e){return!f.default(e,this.props)},r.componentDidUpdate=function(){this.emitChange()},r.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},r.emitChange=function(){var e,t,r=this.props.context,n=r.setHelmet,i=null,a=(e=r.helmetInstances.get().map(function(e){var t=p({},e.props);return delete t.context,t}),{baseTag:M([T],e),bodyAttributes:N(A,e),defer:L(e,"defer"),encode:L(e,"encodeSpecialCharacters"),htmlAttributes:N(C,e),linkTags:R(O.LINK,[v,T],e),metaTags:R(O.META,["name","charset","http-equiv","property",b],e),noscriptTags:R(O.NOSCRIPT,[g],e),onChangeClientState:H(e),scriptTags:R(O.SCRIPT,["src",g],e),styleTags:R(O.STYLE,[m],e),title:k(e),titleAttributes:N("titleAttributes",e),prioritizeSeoTags:q(e,"prioritizeSeoTags")});X.canUseDOM?(t=a,te&&cancelAnimationFrame(te),t.defer?te=requestAnimationFrame(function(){ee(t,function(){te=null})}):(ee(t),te=null)):G&&(i=G(a)),n(i)},r.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},r.render=function(){return this.init(),null},t}(t.Component);re.propTypes={context:Q.isRequired},re.displayName="HelmetDispatcher";var ne=["children"],ie=["children"],ae=function(e){function t(){return e.apply(this,arguments)||this}d(t,e);var r=t.prototype;return r.shouldComponentUpdate=function(e){return!c.default(this.props,e)},r.mapNestedChildrenToProps=function(e,t){if(!t)return null;switch(e.type){case O.SCRIPT:case O.NOSCRIPT:return{innerHTML:t};case O.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.")}},r.flattenArrayTypeChildren=function(e){var t,r=e.child,n=e.arrayTypeChildren;return p({},n,((t={})[r.type]=[].concat(n[r.type]||[],[p({},e.newChildProps,this.mapNestedChildrenToProps(r,e.nestedChildren))]),t))},r.mapObjectTypeChildren=function(e){var t,r,n=e.child,i=e.newProps,a=e.newChildProps,o=e.nestedChildren;switch(n.type){case O.TITLE:return p({},i,((t={})[n.type]=o,t.titleAttributes=p({},a),t));case O.BODY:return p({},i,{bodyAttributes:p({},a)});case O.HTML:return p({},i,{htmlAttributes:p({},a)});default:return p({},i,((r={})[n.type]=p({},a),r))}},r.mapArrayTypeChildrenToProps=function(e,t){var r=p({},t);return Object.keys(e).forEach(function(t){var n;r=p({},r,((n={})[t]=e[t],n))}),r},r.warnOnInvalidChildren=function(e,t){return l.default(I.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 "+I.join(", ")+" are allowed. Helmet does not support rendering <"+e.type+"> elements. Refer to our API for more information."),l.default(!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},r.mapChildrenToProps=function(e,t){var r=this,n={};return u.default.Children.forEach(e,function(e){if(e&&e.props){var i=e.props,a=i.children,o=y(i,ne),u=Object.keys(o).reduce(function(e,t){return e[j[t]||t]=o[t],e},{}),s=e.type;switch("symbol"==typeof s?s=s.toString():r.warnOnInvalidChildren(e,a),s){case O.FRAGMENT:t=r.mapChildrenToProps(a,t);break;case O.LINK:case O.META:case O.NOSCRIPT:case O.SCRIPT:case O.STYLE:n=r.flattenArrayTypeChildren({child:e,arrayTypeChildren:n,newChildProps:u,nestedChildren:a});break;default:t=r.mapObjectTypeChildren({child:e,newProps:t,newChildProps:u,nestedChildren:a})}}}),this.mapArrayTypeChildrenToProps(n,t)},r.render=function(){var e=this.props,t=e.children,r=y(e,ie),n=p({},r),i=r.helmetData;return t&&(n=this.mapChildrenToProps(t,n)),!i||i instanceof W||(i=new W(i.context,i.instances)),i?u.default.createElement(re,p({},n,{context:i.value})):u.default.createElement(J.Consumer,null,function(e){return u.default.createElement(re,p({},n,{context:e}))})},t}(t.Component);ae.propTypes={base:s.default.object,bodyAttributes:s.default.object,children:s.default.oneOfType([s.default.arrayOf(s.default.node),s.default.node]),defaultTitle:s.default.string,defer:s.default.bool,encodeSpecialCharacters:s.default.bool,htmlAttributes:s.default.object,link:s.default.arrayOf(s.default.object),meta:s.default.arrayOf(s.default.object),noscript:s.default.arrayOf(s.default.object),onChangeClientState:s.default.func,script:s.default.arrayOf(s.default.object),style:s.default.arrayOf(s.default.object),title:s.default.string,titleAttributes:s.default.object,titleTemplate:s.default.string,prioritizeSeoTags:s.default.bool,helmetData:s.default.object},ae.defaultProps={defer:!0,encodeSpecialCharacters:!0,prioritizeSeoTags:!1},ae.displayName="Helmet",e.Helmet=ae,e.HelmetData=W,e.HelmetProvider=X}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "react-helmet-async", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Thread-safe Helmet for React 16+ and friends", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -22,5 +22,9 @@ import mapStateOnServer from './server'; | ||
constructor(context) { | ||
constructor(context, instances) { | ||
this.context = context; | ||
if (instances) { | ||
this.instances = instances; | ||
} | ||
if (!HelmetData.canUseDOM) { | ||
@@ -27,0 +31,0 @@ context.helmet = mapStateOnServer({ |
@@ -6,2 +6,3 @@ import React, { Component } from 'react'; | ||
import { Context } from './Provider'; | ||
import HelmetData from './HelmetData'; | ||
import Dispatcher from './Dispatcher'; | ||
@@ -224,4 +225,5 @@ import { TAG_NAMES, VALID_TAG_NAMES, HTML_TAG_MAP } from './constants'; | ||
render() { | ||
const { children, helmetData, ...props } = this.props; | ||
const { children, ...props } = this.props; | ||
let newProps = { ...props }; | ||
let { helmetData } = props; | ||
@@ -232,2 +234,6 @@ if (children) { | ||
if (helmetData && !(helmetData instanceof HelmetData)) { | ||
helmetData = new HelmetData(helmetData.context, helmetData.instances); | ||
} | ||
return helmetData ? ( | ||
@@ -234,0 +240,0 @@ // eslint-disable-next-line react/jsx-props-no-spreading |
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
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
315774
1248