react-helmet-async
Advanced tools
Comparing version 1.0.7 to 1.0.8
@@ -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";const i={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},a=Object.keys(i).map(e=>i[e]),c={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},l=Object.keys(c).reduce((e,t)=>(e[c[t]]=t,e),{}),p=(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},d=e=>{let t=p(e,i.TITLE);const r=p(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,()=>t);const n=p(e,"defaultTitle");return t||n||void 0},h=e=>p(e,"onChangeClientState")||(()=>{}),u=(e,t)=>t.filter(t=>void 0!==t[e]).map(t=>t[e]).reduce((e,t)=>({...e,...t}),{}),m=(e,t)=>t.filter(e=>void 0!==e[i.BASE]).map(e=>e[i.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},[]),T=(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={...n[t],...s[t]};n[t]=r}return e},[]).reverse()},y=e=>Array.isArray(e)?e.join(""):e,f=[i.NOSCRIPT,i.SCRIPT,i.STYLE],b=(e,t=!0)=>!1===t?String(e):String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),g=e=>Object.keys(e).reduce((t,r)=>{const n=void 0!==e[r]?`${r}="${e[r]}"`:""+r;return t?`${t} ${n}`:n},""),A=(e,t={})=>Object.keys(e).reduce((t,r)=>(t[c[r]||r]=e[r],t),t),C=(t,r,n)=>{switch(t){case i.TITLE:return{toComponent:()=>((t,r,n)=>{const s=A(n,{key:r,"data-rh":!0});return[e.createElement(i.TITLE,s,r)]})(0,r.title,r.titleAttributes),toString:()=>((e,t,r,n)=>{const s=g(r),o=y(t);return s?`<${e} data-rh="true" ${s}>${b(o,n)}</${e}>`:`<${e} data-rh="true">${b(o,n)}</${e}>`})(t,r.title,r.titleAttributes,n)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>A(r),toString:()=>g(r)};default:return{toComponent:()=>((t,r)=>r.map((r,n)=>{const s={key:n,"data-rh":!0};return Object.keys(r).forEach(e=>{const t=c[e]||e;"innerHTML"===t||"cssText"===t?s.dangerouslySetInnerHTML={__html:r.innerHTML||r.cssText}:s[t]=r[e]}),e.createElement(t,s)}))(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}="${b(n[t],r)}"`;return e?`${e} ${s}`:s},""),o=n.innerHTML||n.cssText||"",i=-1===f.indexOf(e);return`${t}<${e} data-rh="true" ${s}${i?"/>":`>${o}</${e}>`}`},""))(t,r,n)}}},O=({baseTag:e,bodyAttributes:t,encode:r,htmlAttributes:n,linkTags:s,metaTags:o,noscriptTags:a,scriptTags:c,styleTags:l,title:p="",titleAttributes:d})=>({base:C(i.BASE,e,r),bodyAttributes:C("bodyAttributes",t,r),htmlAttributes:C("htmlAttributes",n,r),link:C(i.LINK,s,r),meta:C(i.META,o,r),noscript:C(i.NOSCRIPT,a,r),script:C(i.SCRIPT,c,r),style:C(i.STYLE,l,r),title:C(i.TITLE,{title:p,titleAttributes:d},r)}),E=e.createContext({}),S=r.shape({setHelmet:r.func,helmetInstances:r.shape({get:r.func,add:r.func,remove:r.func})}),x="undefined"!=typeof document;class I extends t{constructor(e){super(e),this.instances=[],this.value={setHelmet:e=>{this.props.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)}}},I.canUseDOM||(e.context.helmet=O({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}render(){return e.createElement(E.Provider,{value:this.value},this.props.children)}}I.canUseDOM=x,I.propTypes={context:r.shape({helmet:r.shape()}),children:r.node.isRequired},I.defaultProps={context:{}},I.displayName="HelmetProvider";const L=(e,t)=>{const r=document.head||document.querySelector(i.HEAD),n=r.querySelectorAll(e+"[data-rh]"),s=[].slice.call(n),o=[];let a;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)=>(a=t,r.isEqualNode(e)))?s.splice(a,1):o.push(r)}),s.forEach(e=>e.parentNode.removeChild(e)),o.forEach(e=>r.appendChild(e)),{oldTags:s,newTags:o}},P=(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 c=o.indexOf(n);-1!==c&&o.splice(c,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(","))},j=(e,t)=>{const{baseTag:r,bodyAttributes:n,htmlAttributes:s,linkTags:o,metaTags:a,noscriptTags:c,onChangeClientState:l,scriptTags:p,styleTags:d,title:h,titleAttributes:u}=e;P(i.BODY,n),P(i.HTML,s),((e,t)=>{void 0!==e&&document.title!==e&&(document.title=y(e)),P(i.TITLE,t)})(h,u);const m={baseTag:L(i.BASE,r),linkTags:L(i.LINK,o),metaTags:L(i.META,a),noscriptTags:L(i.NOSCRIPT,c),scriptTags:L(i.SCRIPT,p),styleTags:L(i.STYLE,d)},T={},f={};Object.keys(m).forEach(e=>{const{newTags:t,oldTags:r}=m[e];t.length&&(T[e]=t),r.length&&(f[e]=m[e].oldTags)}),t&&t(),l(e,T,f)};let v=null;class w 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={...e.props};return delete t.context,t}),{baseTag:m(["href"],s),bodyAttributes:u("bodyAttributes",s),defer:p(s,"defer"),encode:p(s,"encodeSpecialCharacters"),htmlAttributes:u("htmlAttributes",s),linkTags:T(i.LINK,["rel","href"],s),metaTags:T(i.META,["name","charset","http-equiv","property","itemprop"],s),noscriptTags:T(i.NOSCRIPT,["innerHTML"],s),onChangeClientState:h(s),scriptTags:T(i.SCRIPT,["src","innerHTML"],s),styleTags:T(i.STYLE,["cssText"],s),title:d(s),titleAttributes:u("titleAttributes",s)});var s,o;I.canUseDOM?(o=n,v&&cancelAnimationFrame(v),o.defer?v=requestAnimationFrame(()=>{j(o,()=>{v=null})}):(j(o),v=null)):O&&(r=O(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}}w.propTypes={context:S.isRequired},w.displayName="HelmetDispatcher";class $ extends t{shouldComponentUpdate(e){return!n(this.props,e)}mapNestedChildrenToProps(e,t){if(!t)return null;switch(e.type){case i.SCRIPT:case i.NOSCRIPT:return{innerHTML:t};case i.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{...t,[e.type]:[...t[e.type]||[],{...r,...this.mapNestedChildrenToProps(e,n)}]}}mapObjectTypeChildren({child:e,newProps:t,newChildProps:r,nestedChildren:n}){switch(e.type){case i.TITLE:return{...t,[e.type]:n,titleAttributes:{...r}};case i.BODY:return{...t,bodyAttributes:{...r}};case i.HTML:return{...t,htmlAttributes:{...r}};default:return{...t,[e.type]:{...r}}}}mapArrayTypeChildrenToProps(e,t){let r={...t};return Object.keys(e).forEach(t=>{r={...r,[t]:e[t]}}),r}warnOnInvalidChildren(e,t){return s(a.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 ${a.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{children:t,...s}=e.props,o=Object.keys(s).reduce((e,t)=>(e[l[t]||t]=s[t],e),{});let{type:a}=e;switch("symbol"==typeof a?a=a.toString():this.warnOnInvalidChildren(e,t),a){case i.FRAGMENT:r=this.mapChildrenToProps(t,r);break;case i.LINK:case i.META:case i.NOSCRIPT:case i.SCRIPT:case i.STYLE:n=this.flattenArrayTypeChildren({child:e,arrayTypeChildren:n,newChildProps:o,nestedChildren:t});break;default:r=this.mapObjectTypeChildren({child:e,newProps:r,newChildProps:o,nestedChildren:t})}}),this.mapArrayTypeChildrenToProps(n,r)}render(){const{children:t,...r}=this.props;let n={...r};return t&&(n=this.mapChildrenToProps(t,n)),e.createElement(E.Consumer,null,t=>e.createElement(w,Object.assign({},n,{context:t})))}}$.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},$.defaultProps={defer:!0,encodeSpecialCharacters:!0},$.displayName="Helmet";export{$ as Helmet,I 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 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=Object.keys(l).map(e=>l[e]),p={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},d=Object.keys(p).reduce((e,t)=>(e[p[t]]=t,e),{}),h=(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},u=e=>{let t=h(e,l.TITLE);const r=h(e,"titleTemplate");if(Array.isArray(t)&&(t=t.join("")),r&&t)return r.replace(/%s/g,()=>t);const n=h(e,"defaultTitle");return t||n||void 0},m=e=>h(e,"onChangeClientState")||(()=>{}),T=(e,t)=>t.filter(t=>void 0!==t[e]).map(t=>t[e]).reduce((e,t)=>i({},e,t),{}),y=(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},[]),f=(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()},b=e=>Array.isArray(e)?e.join(""):e,g=[l.NOSCRIPT,l.SCRIPT,l.STYLE],A=(e,t=!0)=>!1===t?String(e):String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'"),C=e=>Object.keys(e).reduce((t,r)=>{const n=void 0!==e[r]?`${r}="${e[r]}"`:""+r;return t?`${t} ${n}`:n},""),O=(e,t={})=>Object.keys(e).reduce((t,r)=>(t[p[r]||r]=e[r],t),t),E=(t,r,n)=>{switch(t){case l.TITLE:return{toComponent:()=>((t,r,n)=>{const s=O(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=C(r),o=b(t);return s?`<${e} data-rh="true" ${s}>${A(o,n)}</${e}>`:`<${e} data-rh="true">${A(o,n)}</${e}>`})(t,r.title,r.titleAttributes,n)};case"bodyAttributes":case"htmlAttributes":return{toComponent:()=>O(r),toString:()=>C(r)};default:return{toComponent:()=>((t,r)=>r.map((r,n)=>{const s={key:n,"data-rh":!0};return Object.keys(r).forEach(e=>{const t=p[e]||e;"innerHTML"===t||"cssText"===t?s.dangerouslySetInnerHTML={__html:r.innerHTML||r.cssText}:s[t]=r[e]}),e.createElement(t,s)}))(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}="${A(n[t],r)}"`;return e?`${e} ${s}`:s},""),o=n.innerHTML||n.cssText||"",i=-1===g.indexOf(e);return`${t}<${e} data-rh="true" ${s}${i?"/>":`>${o}</${e}>`}`},""))(t,r,n)}}},S=({baseTag:e,bodyAttributes:t,encode:r,htmlAttributes:n,linkTags:s,metaTags:o,noscriptTags:i,scriptTags:a,styleTags:c,title:p="",titleAttributes:d})=>({base:E(l.BASE,e,r),bodyAttributes:E("bodyAttributes",t,r),htmlAttributes:E("htmlAttributes",n,r),link:E(l.LINK,s,r),meta:E(l.META,o,r),noscript:E(l.NOSCRIPT,i,r),script:E(l.SCRIPT,a,r),style:E(l.STYLE,c,r),title:E(l.TITLE,{title:p,titleAttributes:d},r)}),x=e.createContext({}),I=r.shape({setHelmet:r.func,helmetInstances:r.shape({get:r.func,add:r.func,remove:r.func})}),P="undefined"!=typeof document;class L extends t{constructor(e){super(e),this.instances=[],this.value={setHelmet:e=>{this.props.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)}}},L.canUseDOM||(e.context.helmet=S({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}render(){return e.createElement(x.Provider,{value:this.value},this.props.children)}}L.canUseDOM=P,L.propTypes={context:r.shape({helmet:r.shape()}),children:r.node.isRequired},L.defaultProps={context:{}},L.displayName="HelmetProvider";const v=(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}},j=(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(","))},w=(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;j(l.BODY,n),j(l.HTML,s),((e,t)=>{void 0!==e&&document.title!==e&&(document.title=b(e)),j(l.TITLE,t)})(h,u);const m={baseTag:v(l.BASE,r),linkTags:v(l.LINK,o),metaTags:v(l.META,i),noscriptTags:v(l.NOSCRIPT,a),scriptTags:v(l.SCRIPT,p),styleTags:v(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 $=null;class H 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:y(["href"],s),bodyAttributes:T("bodyAttributes",s),defer:h(s,"defer"),encode:h(s,"encodeSpecialCharacters"),htmlAttributes:T("htmlAttributes",s),linkTags:f(l.LINK,["rel","href"],s),metaTags:f(l.META,["name","charset","http-equiv","property","itemprop"],s),noscriptTags:f(l.NOSCRIPT,["innerHTML"],s),onChangeClientState:m(s),scriptTags:f(l.SCRIPT,["src","innerHTML"],s),styleTags:f(l.STYLE,["cssText"],s),title:u(s),titleAttributes:T("titleAttributes",s)});var s,o;L.canUseDOM?(o=n,$&&cancelAnimationFrame($),o.defer?$=requestAnimationFrame(()=>{w(o,()=>{$=null})}):(w(o),$=null)):S&&(r=S(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}}H.propTypes={context:I.isRequired},H.displayName="HelmetDispatcher";class k 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(c.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 ${c.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,["children"]),i=Object.keys(o).reduce((e,t)=>(e[d[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}=t;let n=i({},a(t,["children"]));return r&&(n=this.mapChildrenToProps(r,n)),e.createElement(x.Consumer,null,t=>e.createElement(H,i({},n,{context:t})))}}k.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},k.defaultProps={defer:!0,encodeSpecialCharacters:!0},k.displayName="Helmet";export{k as Helmet,L as HelmetProvider}; | ||
//# sourceMappingURL=index.modern.js.map |
{ | ||
"name": "react-helmet-async", | ||
"version": "1.0.7", | ||
"version": "1.0.8", | ||
"description": "Thread-safe Helmet for React 16+ and friends", | ||
@@ -19,3 +19,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@babel/runtime": "^7.11.2", | ||
"@babel/runtime": "^7.12.5", | ||
"invariant": "^2.2.4", | ||
@@ -27,35 +27,37 @@ "prop-types": "^15.7.2", | ||
"devDependencies": { | ||
"@babel/cli": "7.11.6", | ||
"@babel/core": "7.11.6", | ||
"@babel/cli": "7.12.1", | ||
"@babel/core": "7.12.3", | ||
"@babel/eslint-parser": "7.12.1", | ||
"@babel/eslint-plugin": "7.12.1", | ||
"@commitlint/cli": "11.0.0", | ||
"@commitlint/config-conventional": "11.0.0", | ||
"babel-eslint": "10.1.0", | ||
"babel-preset-kyt-react": "1.0.5", | ||
"babel-preset-kyt-react": "1.1.3", | ||
"enzyme": "3.11.0", | ||
"enzyme-adapter-react-16": "1.15.4", | ||
"enzyme-to-json": "3.5.0", | ||
"eslint": "7.9.0", | ||
"eslint-config-airbnb": "18.2.0", | ||
"eslint-config-kyt": "1.0.8", | ||
"eslint-config-prettier": "6.11.0", | ||
"eslint-plugin-import": "2.22.0", | ||
"eslint-plugin-jest": "24.0.1", | ||
"enzyme-adapter-react-16": "1.15.5", | ||
"enzyme-to-json": "3.6.1", | ||
"eslint": "7.13.0", | ||
"eslint-config-airbnb": "18.2.1", | ||
"eslint-config-kyt": "1.3.5", | ||
"eslint-config-prettier": "6.15.0", | ||
"eslint-plugin-import": "2.22.1", | ||
"eslint-plugin-jest": "24.1.3", | ||
"eslint-plugin-jest-formatting": "2.0.0", | ||
"eslint-plugin-json": "2.1.2", | ||
"eslint-plugin-jsx-a11y": "6.3.1", | ||
"eslint-plugin-jsx-a11y": "6.4.1", | ||
"eslint-plugin-prettier": "3.1.4", | ||
"eslint-plugin-react": "7.20.6", | ||
"eslint-plugin-react-hooks": "4.1.2", | ||
"eslint-plugin-react": "7.21.5", | ||
"eslint-plugin-react-hooks": "4.2.0", | ||
"husky": "4.3.0", | ||
"jest": "26.4.2", | ||
"jest": "26.6.3", | ||
"jsdom": "16.4.0", | ||
"microbundle": "0.12.3", | ||
"prettier": "2.1.1", | ||
"microbundle": "0.12.4", | ||
"prettier": "2.1.2", | ||
"raf": "3.4.1", | ||
"react": "16.13.1", | ||
"react-dom": "16.13.1", | ||
"react": "16.14.0", | ||
"react-dom": "16.14.0", | ||
"rimraf": "3.0.2" | ||
}, | ||
"peerDependencies": { | ||
"react": "^16.6.0", | ||
"react": "^16.6.0 || ^17", | ||
"react-dom": "^16.6.0" | ||
@@ -62,0 +64,0 @@ }, |
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
277571
1096
32
+ Addedreact@17.0.2(transitive)
Updated@babel/runtime@^7.12.5