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

react-helmet-async

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-helmet-async - npm Package Compare versions

Comparing version 0.3.0-beta.0 to 0.3.0-beta.1

lib/index.js.map

282

lib/index.js

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

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "HelmetProvider", {
enumerable: true,
get: function get() {
return _Provider.default;
}
});
exports.default = void 0;
var _react = _interopRequireWildcard(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
var _invariant = _interopRequireDefault(require("invariant"));
var _Provider = _interopRequireWildcard(require("./Provider"));
var _Dispatcher = _interopRequireDefault(require("./Dispatcher"));
var _constants = require("./constants");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance"); }
function _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
/* eslint-disable class-methods-use-this */
var Helmet =
/*#__PURE__*/
function (_Component) {
_inherits(Helmet, _Component);
function Helmet() {
_classCallCheck(this, Helmet);
return _possibleConstructorReturn(this, _getPrototypeOf(Helmet).apply(this, arguments));
}
_createClass(Helmet, [{
key: "shouldComponentUpdate",
/**
* @param {Object} base: {"target": "_blank", "href": "http://mysite.com/"}
* @param {Object} bodyAttributes: {"className": "root"}
* @param {String} defaultTitle: "Default Title"
* @param {Boolean} defer: true
* @param {Boolean} encodeSpecialCharacters: true
* @param {Object} htmlAttributes: {"lang": "en", "amp": undefined}
* @param {Array} link: [{"rel": "canonical", "href": "http://mysite.com/example"}]
* @param {Array} meta: [{"name": "description", "content": "Test description"}]
* @param {Array} noscript: [{"innerHTML": "<img src='http://mysite.com/js/test.js'"}]
* @param {Function} onChangeClientState: "(newState) => console.log(newState)"
* @param {Array} script: [{"type": "text/javascript", "src": "http://mysite.com/js/test.js"}]
* @param {Array} style: [{"type": "text/css", "cssText": "div { display: block; color: blue; }"}]
* @param {String} title: "Title"
* @param {Object} titleAttributes: {"itemprop": "name"}
* @param {String} titleTemplate: "MySite.com - %s"
*/
/* eslint-disable react/prop-types, react/forbid-prop-types, react/require-default-props */
/* eslint-enable react/prop-types, react/forbid-prop-types, react/require-default-props */
value: function shouldComponentUpdate(nextProps) {
return !(0, _reactFastCompare.default)(this.props, nextProps);
}
}, {
key: "mapNestedChildrenToProps",
value: function mapNestedChildrenToProps(child, nestedChildren) {
if (!nestedChildren) {
return null;
}
switch (child.type) {
case _constants.TAG_NAMES.SCRIPT:
case _constants.TAG_NAMES.NOSCRIPT:
return {
innerHTML: nestedChildren
};
case _constants.TAG_NAMES.STYLE:
return {
cssText: nestedChildren
};
default:
throw new Error("<".concat(child.type, " /> elements are self-closing and can not contain children. Refer to our API for more information."));
}
}
}, {
key: "flattenArrayTypeChildren",
value: function flattenArrayTypeChildren(_ref) {
var child = _ref.child,
arrayTypeChildren = _ref.arrayTypeChildren,
newChildProps = _ref.newChildProps,
nestedChildren = _ref.nestedChildren;
return _objectSpread({}, arrayTypeChildren, _defineProperty({}, child.type, [].concat(_toConsumableArray(arrayTypeChildren[child.type] || []), [_objectSpread({}, newChildProps, this.mapNestedChildrenToProps(child, nestedChildren))])));
}
}, {
key: "mapObjectTypeChildren",
value: function mapObjectTypeChildren(_ref2) {
var _objectSpread3;
var child = _ref2.child,
newProps = _ref2.newProps,
newChildProps = _ref2.newChildProps,
nestedChildren = _ref2.nestedChildren;
switch (child.type) {
case _constants.TAG_NAMES.TITLE:
return _objectSpread({}, newProps, (_objectSpread3 = {}, _defineProperty(_objectSpread3, child.type, nestedChildren), _defineProperty(_objectSpread3, "titleAttributes", _objectSpread({}, newChildProps)), _objectSpread3));
case _constants.TAG_NAMES.BODY:
return _objectSpread({}, newProps, {
bodyAttributes: _objectSpread({}, newChildProps)
});
case _constants.TAG_NAMES.HTML:
return _objectSpread({}, newProps, {
htmlAttributes: _objectSpread({}, newChildProps)
});
default:
return _objectSpread({}, newProps, _defineProperty({}, child.type, _objectSpread({}, newChildProps)));
}
}
}, {
key: "mapArrayTypeChildrenToProps",
value: function mapArrayTypeChildrenToProps(arrayTypeChildren, newProps) {
var newFlattenedProps = _objectSpread({}, newProps);
Object.keys(arrayTypeChildren).forEach(function (arrayChildName) {
newFlattenedProps = _objectSpread({}, newFlattenedProps, _defineProperty({}, arrayChildName, arrayTypeChildren[arrayChildName]));
});
return newFlattenedProps;
}
}, {
key: "warnOnInvalidChildren",
value: function warnOnInvalidChildren(child, nestedChildren) {
(0, _invariant.default)(_constants.VALID_TAG_NAMES.some(function (name) {
return child.type === name;
}), typeof child.type === 'function' ? "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 ".concat(_constants.VALID_TAG_NAMES.join(', '), " are allowed. Helmet does not support rendering <").concat(child.type, "> elements. Refer to our API for more information."));
(0, _invariant.default)(!nestedChildren || typeof nestedChildren === 'string' || Array.isArray(nestedChildren) && !nestedChildren.some(function (nestedChild) {
return typeof nestedChild !== 'string';
}), "Helmet expects a string as a child of <".concat(child.type, ">. Did you forget to wrap your children in braces? ( <").concat(child.type, ">{``}</").concat(child.type, "> ) Refer to our API for more information."));
return true;
}
}, {
key: "mapChildrenToProps",
value: function mapChildrenToProps(children, newProps) {
var _this = this;
var arrayTypeChildren = {};
_react.default.Children.forEach(children, function (child) {
if (!child || !child.props) {
return;
}
var _child$props = child.props,
nestedChildren = _child$props.children,
childProps = _objectWithoutProperties(_child$props, ["children"]); // convert React props to HTML attributes
var newChildProps = Object.keys(childProps).reduce(function (obj, key) {
// eslint-disable-next-line no-param-reassign
obj[_constants.HTML_TAG_MAP[key] || key] = childProps[key];
return obj;
}, {});
var type = child.type;
if (_typeof(type) === 'symbol') {
type = type.toString();
} else {
_this.warnOnInvalidChildren(child, nestedChildren);
}
switch (type) {
case _constants.TAG_NAMES.FRAGMENT:
// eslint-disable-next-line no-param-reassign
newProps = _this.mapChildrenToProps(nestedChildren, newProps);
break;
case _constants.TAG_NAMES.LINK:
case _constants.TAG_NAMES.META:
case _constants.TAG_NAMES.NOSCRIPT:
case _constants.TAG_NAMES.SCRIPT:
case _constants.TAG_NAMES.STYLE:
arrayTypeChildren = _this.flattenArrayTypeChildren({
child: child,
arrayTypeChildren: arrayTypeChildren,
newChildProps: newChildProps,
nestedChildren: nestedChildren
});
break;
default:
// eslint-disable-next-line no-param-reassign
newProps = _this.mapObjectTypeChildren({
child: child,
newProps: newProps,
newChildProps: newChildProps,
nestedChildren: nestedChildren
});
break;
}
});
return this.mapArrayTypeChildrenToProps(arrayTypeChildren, newProps);
}
}, {
key: "render",
value: function render() {
var _this$props = this.props,
children = _this$props.children,
props = _objectWithoutProperties(_this$props, ["children"]);
var newProps = _objectSpread({}, props);
if (children) {
newProps = this.mapChildrenToProps(children, newProps);
}
return _react.default.createElement(_Provider.Context.Consumer, null, function (context) {
return _react.default.createElement(_Dispatcher.default, _extends({}, newProps, {
context: context
}));
});
}
}]);
return Helmet;
}(_react.Component);
exports.default = Helmet;
_defineProperty(Helmet, "defaultProps", {
defer: true,
encodeSpecialCharacters: true
});
function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var e=t(require("react-fast-compare")),r=t(require("invariant")),n=t(require("prop-types")),o=require("react"),i=t(o),a=t(require("shallowequal")),s={BASE:"base",BODY:"body",HEAD:"head",HTML:"html",LINK:"link",META:"meta",NOSCRIPT:"noscript",SCRIPT:"script",STYLE:"style",TITLE:"title",FRAGMENT:"Symbol(react.fragment)"},c=Object.keys(s).map(function(t){return s[t]}),u={accesskey:"accessKey",charset:"charSet",class:"className",contenteditable:"contentEditable",contextmenu:"contextMenu","http-equiv":"httpEquiv",itemprop:"itemProp",tabindex:"tabIndex"},l=Object.keys(u).reduce(function(t,e){return t[u[e]]=e,t},{}),p=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},f=function(t){var e=p(t,s.TITLE),r=p(t,"titleTemplate");if(Array.isArray(e)&&(e=e.join("")),r&&e)return r.replace(/%s/g,function(){return e});var n=p(t,"defaultTitle");return e||n||void 0},d=function(t){return p(t,"onChangeClientState")||function(){}},y=function(t,e){return e.filter(function(e){return void 0!==e[t]}).map(function(e){return e[t]}).reduce(function(t,e){return Object.assign({},t,e)},{})},T=function(t,e){return e.filter(function(t){return void 0!==t[s.BASE]}).map(function(t){return t[s.BASE]}).reverse().reduce(function(e,r){if(!e.length)for(var n=Object.keys(r),o=0;o<n.length;o+=1){var i=n[o].toLowerCase();if(-1!==t.indexOf(i)&&r[i])return e.concat(r)}return e},[])},m=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 o={};r.filter(function(t){for(var r,i=Object.keys(t),a=0;a<i.length;a+=1){var s=i[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]={}),o[r]||(o[r]={}),!n[r][u]&&(o[r][u]=!0,!0)}).reverse().forEach(function(e){return t.push(e)});for(var i=Object.keys(o),a=0;a<i.length;a+=1){var s=i[a],c=Object.assign({},n[s],o[s]);n[s]=c}return t},[]).reverse()},b=function(t){return Array.isArray(t)?t.join(""):t},g=[s.NOSCRIPT,s.SCRIPT,s.STYLE],v=function(t,e){return void 0===e&&(e=!0),!1===e?String(t):String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;")},A=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},"")},C=function(t,e){return void 0===e&&(e={}),Object.keys(t).reduce(function(e,r){return e[u[r]||r]=t[r],e},e)},O=function(t,e,r){switch(t){case s.TITLE:return{toComponent:function(){return r=C(e.titleAttributes,{key:t=e.title,"data-rh":!0}),[i.createElement(s.TITLE,r,t)];var t,r},toString:function(){return function(t,r,n,o){var i=A(e.titleAttributes),a=b(r);return i?"<"+t+' data-rh="true" '+i+">"+v(a,o)+"</"+t+">":"<"+t+' data-rh="true">'+v(a,o)+"</"+t+">"}(t,e.title,0,r)}};case"bodyAttributes":case"htmlAttributes":return{toComponent:function(){return C(e)},toString:function(){return A(e)}};default:return{toComponent:function(){return function(t,e){return e.map(function(e,r){var n={key:r,"data-rh":!0};return Object.keys(e).forEach(function(t){var r=u[t]||t;"innerHTML"===r||"cssText"===r?n.dangerouslySetInnerHTML={__html:e.innerHTML||e.cssText}:n[r]=e[t]}),i.createElement(t,n)})}(t,e)},toString:function(){return function(t,e,r){return e.reduce(function(e,n){var o=Object.keys(n).filter(function(t){return!("innerHTML"===t||"cssText"===t)}).reduce(function(t,e){var o=void 0===n[e]?e:e+'="'+v(n[e],r)+'"';return t?t+" "+o:o},""),i=n.innerHTML||n.cssText||"",a=-1===g.indexOf(t);return e+"<"+t+' data-rh="true" '+o+(a?"/>":">"+i+"</"+t+">")},"")}(t,e,r)}}}},j=function(t){var e=t.bodyAttributes,r=t.encode,n=t.htmlAttributes,o=t.linkTags,i=t.metaTags,a=t.noscriptTags,c=t.scriptTags,u=t.styleTags,l=t.title;void 0===l&&(l="");var p=t.titleAttributes;return{base:O(s.BASE,t.baseTag,r),bodyAttributes:O("bodyAttributes",e,r),htmlAttributes:O("htmlAttributes",n,r),link:O(s.LINK,o,r),meta:O(s.META,i,r),noscript:O(s.NOSCRIPT,a,r),script:O(s.SCRIPT,c,r),style:O(s.STYLE,u,r),title:O(s.TITLE,{title:l,titleAttributes:p},r)}},S=i.createContext({}),E=n.shape({setHelmet:n.func,helmetInstances:n.shape({get:n.func,add:n.func,remove:n.func})}),I="undefined"!=typeof document,x=function(t){function e(r){var n=this;t.call(this,r),this.instances=[],this.value={setHelmet:function(t){n.props.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)}}},e.canUseDOM||(r.context.helmet=j({baseTag:[],bodyAttributes:{},encodeSpecialCharacters:!0,htmlAttributes:{},linkTags:[],metaTags:[],noscriptTags:[],scriptTags:[],styleTags:[],title:"",titleAttributes:{}}))}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.render=function(){return h(S.Provider,{value:this.value},this.props.children)},e}(o.Component);x.canUseDOM=I,x.propTypes={context:n.shape({helmet:n.shape()}),children:n.node.isRequired},x.defaultProps={context:{}};var L=function(t,e){var r,n=document.head||document.querySelector(s.HEAD),o=n.querySelectorAll(t+"[data-rh]"),i=[].slice.call(o),a=[];return e&&e.length&&e.forEach(function(e){var n=document.createElement(t);for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&("innerHTML"===o?n.innerHTML=e.innerHTML:"cssText"===o?n.styleSheet?n.styleSheet.cssText=e.cssText:n.appendChild(document.createTextNode(e.cssText)):n.setAttribute(o,void 0===e[o]?"":e[o]));n.setAttribute("data-rh","true"),i.some(function(t,e){return r=e,n.isEqualNode(t)})?i.splice(r,1):a.push(n)}),i.forEach(function(t){return t.parentNode.removeChild(t)}),a.forEach(function(t){return n.appendChild(t)}),{oldTags:i,newTags:a}},P=function(t,e){var r=document.getElementsByTagName(t)[0];if(r){for(var n=r.getAttribute("data-rh"),o=n?n.split(","):[],i=[].concat(o),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===o.indexOf(c)&&o.push(c);var l=i.indexOf(c);-1!==l&&i.splice(l,1)}for(var p=i.length-1;p>=0;p-=1)r.removeAttribute(i[p]);o.length===i.length?r.removeAttribute("data-rh"):r.getAttribute("data-rh")!==a.join(",")&&r.setAttribute("data-rh",a.join(","))}},w=function(t,e){var r=t.baseTag,n=t.htmlAttributes,o=t.linkTags,i=t.metaTags,a=t.noscriptTags,c=t.onChangeClientState,u=t.scriptTags,l=t.styleTags,p=t.title,f=t.titleAttributes;P(s.BODY,t.bodyAttributes),P(s.HTML,n),function(t,e){void 0!==t&&document.title!==t&&(document.title=b(t)),P(s.TITLE,e)}(p,f);var d={baseTag:L(s.BASE,r),linkTags:L(s.LINK,o),metaTags:L(s.META,i),noscriptTags:L(s.NOSCRIPT,a),scriptTags:L(s.SCRIPT,u),styleTags:L(s.STYLE,l)},h={},y={};Object.keys(d).forEach(function(t){var e=d[t],r=e.newTags,n=e.oldTags;r.length&&(h[t]=r),n.length&&(y[t]=d[t].oldTags)}),e&&e(),c(t,h,y)},k=null,M=function(t){function e(){for(var e=[],r=arguments.length;r--;)e[r]=arguments[r];t.apply(this,e),this.rendered=!1}return t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e,e.prototype.shouldComponentUpdate=function(t){return!a(t,this.props)},e.prototype.componentDidUpdate=function(){this.emitChange()},e.prototype.componentWillUnmount=function(){this.props.context.helmetInstances.remove(this),this.emitChange()},e.prototype.emitChange=function(){var t,e,r=this.props.context,n=r.setHelmet,o=null,i=(t=r.helmetInstances.get().map(function(t){var e=Object.assign({},t.props);return delete e.context,e}),{baseTag:T(["href"],t),bodyAttributes:y("bodyAttributes",t),defer:p(t,"defer"),encode:p(t,"encodeSpecialCharacters"),htmlAttributes:y("htmlAttributes",t),linkTags:m(s.LINK,["rel","href"],t),metaTags:m(s.META,["name","charset","http-equiv","property","itemprop"],t),noscriptTags:m(s.NOSCRIPT,["innerHTML"],t),onChangeClientState:d(t),scriptTags:m(s.SCRIPT,["src","innerHTML"],t),styleTags:m(s.STYLE,["cssText"],t),title:f(t),titleAttributes:y("titleAttributes",t)});x.canUseDOM?(e=i,k&&cancelAnimationFrame(k),e.defer?k=requestAnimationFrame(function(){w(e,function(){k=null})}):(w(e),k=null)):j&&(o=j(i)),n(o)},e.prototype.init=function(){this.rendered||(this.rendered=!0,this.props.context.helmetInstances.add(this),this.emitChange())},e.prototype.render=function(){return this.init(),null},e}(o.Component);function H(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&-1===e.indexOf(n)&&(r[n]=t[n]);return r}M.propTypes={context:E.isRequired};var R=function(t){function n(){t.apply(this,arguments)}return t&&(n.__proto__=t),(n.prototype=Object.create(t&&t.prototype)).constructor=n,n.prototype.shouldComponentUpdate=function(t){return!e(this.props,t)},n.prototype.mapNestedChildrenToProps=function(t,e){if(!e)return null;switch(t.type){case s.SCRIPT:case s.NOSCRIPT:return{innerHTML:e};case s.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.")}},n.prototype.flattenArrayTypeChildren=function(t){var e,r=t.child,n=t.arrayTypeChildren;return Object.assign({},n,((e={})[r.type]=(n[r.type]||[]).concat([Object.assign({},t.newChildProps,this.mapNestedChildrenToProps(r,t.nestedChildren))]),e))},n.prototype.mapObjectTypeChildren=function(t){var e,r,n=t.child,o=t.newProps,i=t.newChildProps,a=t.nestedChildren;switch(n.type){case s.TITLE:return Object.assign({},o,((e={})[n.type]=a,e),{titleAttributes:Object.assign({},i)});case s.BODY:return Object.assign({},o,{bodyAttributes:Object.assign({},i)});case s.HTML:return Object.assign({},o,{htmlAttributes:Object.assign({},i)});default:return Object.assign({},o,((r={})[n.type]=Object.assign({},i),r))}},n.prototype.mapArrayTypeChildrenToProps=function(t,e){var r=Object.assign({},e);return Object.keys(t).forEach(function(e){var n;r=Object.assign({},r,((n={})[e]=t[e],n))}),r},n.prototype.warnOnInvalidChildren=function(t,e){return r(c.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 "+c.join(", ")+" are allowed. Helmet does not support rendering <"+t.type+"> elements. Refer to our API for more information."),r(!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},n.prototype.mapChildrenToProps=function(t,e){var r=this,n={};return i.Children.forEach(t,function(t){if(t&&t.props){var o=t.props,i=o.children,a=H(o,["children"]),c=Object.keys(a).reduce(function(t,e){return t[l[e]||e]=a[e],t},{}),u=t.type;switch("symbol"==typeof u?u=u.toString():r.warnOnInvalidChildren(t,i),u){case s.FRAGMENT:e=r.mapChildrenToProps(i,e);break;case s.LINK:case s.META:case s.NOSCRIPT:case s.SCRIPT:case s.STYLE:n=r.flattenArrayTypeChildren({child:t,arrayTypeChildren:n,newChildProps:c,nestedChildren:i});break;default:e=r.mapObjectTypeChildren({child:t,newProps:e,newChildProps:c,nestedChildren:i})}}}),this.mapArrayTypeChildrenToProps(n,e)},n.prototype.render=function(){var t=this.props,e=t.children,r=H(t,["children"]),n=Object.assign({},r);return e&&(n=this.mapChildrenToProps(e,n)),h(S.Consumer,null,function(t){return h(M,Object.assign({},n,{context:t}))})},n}(o.Component);R.propTypes={base:n.object,bodyAttributes:n.object,children:n.oneOfType([n.arrayOf(n.node),n.node]),defaultTitle:n.string,defer:n.bool,encodeSpecialCharacters:n.bool,htmlAttributes:n.object,link:n.arrayOf(n.object),meta:n.arrayOf(n.object),noscript:n.arrayOf(n.object),onChangeClientState:n.func,script:n.arrayOf(n.object),style:n.arrayOf(n.object),title:n.string,titleAttributes:n.object,titleTemplate:n.string},R.defaultProps={defer:!0,encodeSpecialCharacters:!0},exports.default=R,exports.HelmetProvider=x;
//# sourceMappingURL=index.js.map
{
"name": "react-helmet-async",
"version": "0.3.0-beta.0",
"version": "0.3.0-beta.1",
"description": "Thread-safe Helmet for React 16+ and friends",
"main": "lib/index.js",
"umd:main": "lib/index.umd.js",
"module": "lib/index.mjs",
"source": "src/index.js",
"types": "index.d.ts",
"repository": "http://github.com/NYTimes/react-helmet-async",
"author": "Scott Taylor <scott.c.taylor@mac.com>",
"license": "Apache-2.0",
"typings": "index.d.ts",
"files": [
"lib/",
"index.d.ts"
],
"dependencies": {
"@babel/runtime": "7.3.4",
"invariant": "2.2.4",
"prop-types": "15.6.2",
"prop-types": "15.7.2",
"react-fast-compare": "2.0.4",

@@ -18,47 +26,47 @@ "shallowequal": "1.1.0"

"@babel/cli": "7.2.3",
"@babel/core": "7.2.2",
"@babel/plugin-proposal-class-properties": "7.2.3",
"@babel/preset-env": "7.2.3",
"@babel/preset-react": "7.0.0",
"babel-core": "7.0.0-bridge.0",
"@babel/core": "7.3.4",
"@babel/plugin-proposal-class-properties": "7.3.4",
"babel-eslint": "10.0.1",
"babel-jest": "23.6.0",
"babel-plugin-transform-react-remove-prop-types": "0.4.21",
"enzyme": "3.8.0",
"enzyme-adapter-react-16": "1.7.1",
"eslint": "5.10.0",
"babel-preset-kyt-react": "1.0.0-alpha.365f23ad",
"enzyme": "3.9.0",
"enzyme-adapter-react-16": "1.10.0",
"enzyme-to-json": "3.3.5",
"eslint": "5.15.1",
"eslint-config-airbnb": "17.1.0",
"eslint-config-prettier": "3.3.0",
"eslint-plugin-import": "2.14.0",
"eslint-plugin-jest": "22.1.2",
"eslint-plugin-json": "1.3.2",
"eslint-plugin-jsx-a11y": "6.1.2",
"eslint-plugin-prettier": "3.0.0",
"eslint-plugin-react": "7.11.1",
"jest": "23.6.0",
"jsdom": "13.1.0",
"prettier": "1.15.3",
"prettier-eslint": "8.8.2",
"prettier-eslint-cli": "4.7.1",
"eslint-config-kyt": "1.0.0-alpha.365f23ad",
"eslint-config-prettier": "4.1.0",
"eslint-plugin-import": "2.16.0",
"eslint-plugin-jest": "22.3.0",
"eslint-plugin-json": "1.4.0",
"eslint-plugin-jsx-a11y": "6.2.1",
"eslint-plugin-kyt": "1.0.0-alpha.365f23ad",
"eslint-plugin-prettier": "3.0.1",
"eslint-plugin-react": "7.12.4",
"jest": "24.3.1",
"jsdom": "11.12.0",
"microbundle": "^0.11.0",
"prettier": "1.16.4",
"raf": "3.4.1",
"react": "16.7.0",
"react-dom": "16.7.0"
"react": "16.8.4",
"react-dom": "16.8.4",
"rimraf": "^2.6.3"
},
"peerDependencies": {
"react": "^16.7.0",
"react-dom": "^16.7.0"
"react": "^16.6.0",
"react-dom": "^16.6.0"
},
"scripts": {
"clean": "rimraf lib",
"lint": "eslint .",
"lint-fix": "eslint . --fix",
"test": "jest --no-cache",
"test": "KYT_ENV_TYPE=test jest --no-cache",
"test-watch": "npm run test -- --watch",
"test-update": "npm run test -- -u",
"compile": "NODE_ENV=production npm run compile:commonjs && npm run compile:es",
"compile:commonjs": "babel src --out-dir lib",
"compile:es": "babel src --out-dir es",
"compile": "npm run clean && KYT_ENV_TYPE=client NODE_ENV=production microbundle",
"prepare": "npm run compile"
},
"jest": {
"setupTestFrameworkScriptFile": "<rootDir>/jest.setup.js",
"setupFilesAfterEnv": [
"<rootDir>/jest.setup.js"
],
"testEnvironment": "node",

@@ -65,0 +73,0 @@ "testMatch": [

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc