node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

321
server/node_modules/react-helmet/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,321 @@
<a name="6.1.0"></a>
# [6.1.0](https://github.com/nfl/react-helmet/compare/6.0.0...6.1.0) (2020-06-08)
### Features
- Re-add Helmet as a default export [(#547)](https://github.com/nfl/react-helmet/pull/547)
- Note: You may now choose `import Helmet` or `import {Helmet}`
- Updates react-fast-compare to get support for Preact [(#559)](https://github.com/nfl/react-helmet/pull/559)
<a name="6.0.0"></a>
# [6.0.0](https://github.com/nfl/react-helmet/compare/5.2.0...6.0.0) (2020-04-09)
### Features
- Bundle with Rollup instead of Webpack - As a result, the default export was removed and Helmet must now be imported as a named component - `import {Helmet} from "react-helmet"` [(#395)](https://github.com/nfl/react-helmet/pull/395)
- Replace deepEqual with isEqual [(#402)](https://github.com/nfl/react-helmet/pull/402)
<a name="6.0.0-beta.2"></a>
# [6.0.0-beta.2](https://github.com/nfl/react-helmet/compare/6.0.0-beta...6.0.0-beta.2) (2020-01-27)
<a name="6.0.0-beta"></a>
# [6.0.0-beta](https://github.com/nfl/react-helmet/compare/5.2.0...6.0.0-beta) (2018-12-07)
<a name="5.2.0"></a>
# [5.2.0](https://github.com/nfl/react-helmet/compare/5.1.3...5.2.0) (2017-08-29)
### Features
- Adds support for synchronously updated tags
([#297](https://github.com/nfl/react-helmet/pull/297))
([6a3d3bf](https://github.com/nfl/react-helmet/commit/6a3d3bf)), closes [#291](https://github.com/nfl/react-helmet/issues/291)
### Bug Fixes
- Remove unexpected comma in server-rendered title ([#289](https://github.com/nfl/react-helmet/pull/289)) ([66b8212](https://github.com/nfl/react-helmet/commit/66b8212)), closes [#286](https://github.com/nfl/react-helmet/issues/286)
- Replace requestIdleCallback with requestAnimationFrame for a more consistent DOM write cycle. ([#307](https://github.com/nfl/react-helmet/issues/307)) ([a2323ad](https://github.com/nfl/react-helmet/commit/a2323ad))
<a name="5.1.3"></a>
## [5.1.3](https://github.com/nfl/react-helmet/compare/5.0.3...5.1.3) (2017-05-18)
### Bug Fixes
- Add support for renderable Arrays of strings ([#275](https://github.com/nfl/react-helmet/issues/275)) ([aad5457](https://github.com/nfl/react-helmet/commit/aad5457)), closes [#272](https://github.com/nfl/react-helmet/issues/272)
<a name="5.0.3"></a>
## [5.0.3](https://github.com/nfl/react-helmet/compare/5.0.2...5.0.3) (2017-04-10)
### Bug Fixes
- React.propTypes -> PropTypes ([#265](https://github.com/nfl/react-helmet/issues/265)) ([68ece0c](https://github.com/nfl/react-helmet/commit/68ece0c))
<a name="5.0.2"></a>
## [5.0.2](https://github.com/nfl/react-helmet/compare/5.0.1...5.0.2) (2017-03-28)
### Bug Fixes
- prevent clearing existing title ([#259](https://github.com/nfl/react-helmet/issues/259)) ([549b603](https://github.com/nfl/react-helmet/commit/549b603))
<a name="5.0.1"></a>
## [5.0.1](https://github.com/nfl/react-helmet/compare/5.0.0...5.0.1) (2017-03-24)
### Bug Fixes
- handle falsy children values ([#256](https://github.com/nfl/react-helmet/issues/256)) ([4a60765](https://github.com/nfl/react-helmet/commit/4a60765))
<a name="5.0.0"></a>
# [5.0.0](https://github.com/nfl/react-helmet/compare/4.0.0...5.0.0) (2017-03-21)
### Features
- New Simplified API (fully backward-compatible) - Helmet now takes plain HTML tags for the majority of the API with just a few remaining props for Helmet - retaining `titleTemplate`, `defaultTitle`, `onChangeClientState`, and one new - `encodeSpecialCharacters` - refer to README for details. Directly passing Helmet props will be deprecated in the future. [(#246)](https://github.com/nfl/react-helmet/pull/246)
- `requestIdleCallback` utilized to consolidate DOM changes and makes these non-blocking for things like animations. Fixes first client-side render not matching server-side render. Maintains one DOM change between route changes on the client-side as well. [(#248)](https://github.com/nfl/react-helmet/pull/248)
- On server-side, `Helmet.renderStatic()` aliased to `Helmet.rewind()` for more clarity. `rewind` will be deprecated in the future.
- Yarn support
# 4.0.0
### Features
- Replacing PlainComponent with stateless functional component `NullComponent`, with a hard requirement to use React 15 or higher.
# 3.3.2
### Bugfixes
- Removed stateless functional component `NullComponent` because of it's incompatibility with React 14 and reverted back to PlainComponent.
# 3.3.1 [BROKEN]
### Bugfixes
- README updates - npm badge and helmet image
- Bump react-side-effect to 1.1.0
- Removing PlainComponent, replaced with NullComponent defined within Helmet.js
- Refactored code - cut lines of code and used `reduce` to simplify functions
- Replaced PlainComponent with NullComponent (now within Helmet.js)
# 3.3.0
### Features
- `itemprop` available in meta tags
- New API - `titleAttributes` to add attributes to the title tag
- `class` support for html tag
# 3.2.3
### Bugfixes
- applied previous fix (undefined value for primary attribute key) to base tag
- fix htmlAttributes fallback value when calling rewind() on blank Helmet
- Removed unneeded dependencies - shallowequal, warning
- babel configuration moved into .babelrc
- eslint configuration moved into .eslintrc
# 3.2.2
### Bugfixes
- Removed breaking changes `jsnext:main` and `module` from package.json. `es` version required special babel configuration for end users and needs to be re-thought for major release.
- Reverted `canUseDOM` setter in `Helmet.js`, as this was a breaking change for some users.
- [fix] runtime error when providing undefined value for primary attribute key (applies to meta, link, script, noscript, style)
# 3.2.1 [BROKEN]
### Bugfixes
- Removing "engines" field in package.json.
# 3.2.0 [BROKEN]
### Features
- `<noscript>` support
### Bugfixes
- Prevent stripping dollar signs from title when titleTemplate is present
- Offering jsnext:main build
- Removed Gulp Dependency
- Bump Dependencies
- IE8 Support
# 3.1.0
### Features
- Add support for `<style>` elements.
# 3.0.2
### Bugfixes
- Avoids rendering "undefined" if it's passed in as a value of an attribute, but instead renders just the attribute name.
- When htmlAttributes gets cleared, or is blank, the helmet attribute on the html tag, used for tracking, is cleaned up.
- Upgrading devDependency of React to 15.
# 3.0.1
### Bugfixes
- The htmlAttributes feature will no longer remove existing attributes on the HTML tag
# 3.0.0
### Features
- innerHTML for scripts. Originally added to support the use of JSON-LD (https://developers.google.com/schemas/formats/json-ld?hl=en), but this can be used for any inline scripts you would like in your document head.
- New htmlAttributes prop which allows users to add attributes to their html tag.
- New defaultTitle prop which allows users to have a fallback title in the scenario where a Helmet wants to define a titleTemplate for it's nested routes, but not for itself (for example, at the root component level). See README for use cases.
### Bugfixes
- Removed all polyfills from Helmet. Due to reported conflicts, to remove bloat, and to encourage users to polyfill at the application level. Please double-check that you weren't relying solely on Helmet for polyfilling certain features.
# 2.3.1
### Bugfixes
- Fallback values for rewind on the server threw a `tags.map` error in Node. Changing the tag default values to `[]` fixes it.
# 2.3.0
### Bugfixes
- FOUC fix - existing tags that persist between route changes, will not be removed and re-added to the DOM. They will remain unchanged. This will avoid, in particular, stylesheets being removed and re-added causing an unstyled flash when the new Helmet is rendered.
- onChangeClientState enhanced to also return the html tags that were added and removed.
- provide fallback object for rewind() result - If no Helmets are rendered, rewind() will still return head.base, head.title, etc.
- Tag attributes ordering does not matter. It no longer looks at the first valid attribute to identify the tag. All attributes of the tag will be searched for names that can be found in HelmetConstants.js. When rel="canonical" is included, it will take priority over href.
- Bump dependencies
# 2.2.0
### Features
- New prop `onChangeClientState` to set a callback function that is called in the event the DOM is changed by Helmet. When set on a Helmet, it will apply to all subsequent Helmet instances downstream (similar to titleTemplate).
### Bugfixes
- Fix for double encoding when returning state to the server as React components.
- dist -> lib
- Added CLA url to CONTRIBUTING.
- Added .babelrc to .npmignore (fix for now, as the settings were not compatible with Babel 6)
- Bump dependencies (except Babel 6 as a dev dependency - coming soon)
# 2.1.1
### Bugfixes
- Remove npm he dependency
- HTML entitiy encode only special characters instead of all characters that have HTML entity equivalents
# 2.1.0
### Features
- All head attributes (title / base / meta / link / script) returned with `.toComponent()` and `.toString()` methods to use in any scenario when calling rewind on the server.
- Helmet using React 14 for unit testing.
### Bugfixes
- Bump dependencies
# 2.0.0
### Features
- Base tag support.
- Script tag support.
- All head attributes (title / base / meta / link / script) returned as React components on the server with toString() support
- Removed ability to nest children in Helmet.
- Decorated component from react-side-effect, now wrapped by Helmet in order to enforce deep equal check on shouldComponentUpdate. This will limit unnecessary DOM changes and rendering.
### Bugfixes
- Bump dependencies
# 1.1.5
### Bugfixes
- Adding webpack under devDependencies, as it's no longer automatically installed as a peer dependency
- Bump dependencies
# 1.1.4
### Bugfixes
- Bumping to react-side-effect 1.0.2
- Updating peer dependences for react 0.14.0-rc1
- Bump dependencies
# 1.1.3
### Bugfixes
- Externalize react-side-effect
- shouldComponentUpdate compares props with deep equal
- handleClientStateChange compares DOM changes with deep equal to prevent unnecessary DOM changes
- Warning users to not nest children in their Helmet components. We found that when Helmet contains children, those children are part of the props that are compared in shouldComponentUpdate. And this causes unnecessary renders as the props are always different, even with the same Helmet title/meta/link props.
- Adding react-helmet-example to README
- Bumping to react-side-effect 1.0.1
- Bump dependencies.
# 1.1.2
### Bugfixes
- Use named exports in HelmetConstants
- Allow all React 0.14 betas in peer dependencies
- Bump dependencies.
- Fixed invariant check in CreateSideEffect
# 1.1.1
### Bugfixes
- Externalizing of React helpers - exenv, invariant, shallowequal
- Using ES6 collections to manage tags
- Bumping peer dependency for use in React 0.14.0-beta.
- Title encoded when being rendered on the server
- Import a smaller subset of core-js modules instead of the whole shim.
# 1.1.0
### Features
- titleTemplate attribute to help format `document.title`
### Bugfixes
- Bump dependencies.
- Title will never be overwritten with blank title. Lifts constraint where every component with Helmet needed to define a title.
- Re-organization of unit tests.
# 1.0.1
### Bugfixes
- Bump dependencies
- rewind() saves title/meta/link values before disposing
- Typo in README - use Helmet.rewind()
- "he" package added to dependencies
- Added Travis CI integration
- npm requirement removed - removed reference in README (System Requirements) and in package.json (engines)
# 1.0.0
### Features
- Initial release

76
server/node_modules/react-helmet/CODE_OF_CONDUCT.md generated vendored Normal file
View File

@@ -0,0 +1,76 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at engineers@nfl.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq

16
server/node_modules/react-helmet/ISSUE_TEMPLATE.md generated vendored Normal file
View File

@@ -0,0 +1,16 @@
**Do you want to request a *feature* or report a *bug*?**
**What is the current behavior?**
**If the current behavior is a bug,
please provide the steps to reproduce and if
possible a minimal demo of the problem.
Your bug will get fixed much faster if we can run your
code and it doesn't have dependencies other than React and react-helmet.
Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or
CodeSandbox (https://codesandbox.io/s/new) example below:**
**What is the expected behavior?**
**Which versions of React and react-helmet, and which browser / OS are affected by this issue?
Did this work in previous versions of React and/or react-helmet?**

19
server/node_modules/react-helmet/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (c) 2015 NFL
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

269
server/node_modules/react-helmet/README.md generated vendored Normal file
View File

@@ -0,0 +1,269 @@
<img align="right" width="200" src="http://static.nfl.com/static/content/public/static/img/logos/react-helmet.jpg" />
# React Helmet
[![npm Version](https://img.shields.io/npm/v/react-helmet.svg?style=flat-square)](https://www.npmjs.org/package/react-helmet)
[![codecov.io](https://img.shields.io/codecov/c/github/nfl/react-helmet.svg?branch=master&style=flat-square)](https://codecov.io/github/nfl/react-helmet?branch=master)
[![Build Status](https://img.shields.io/travis/nfl/react-helmet/master.svg?style=flat-square)](https://travis-ci.org/nfl/react-helmet)
[![Dependency Status](https://img.shields.io/david/nfl/react-helmet.svg?style=flat-square)](https://david-dm.org/nfl/react-helmet)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](CONTRIBUTING.md#pull-requests)
This reusable React component will manage all of your changes to the document head.
Helmet _takes_ plain HTML tags and _outputs_ plain HTML tags. It's dead simple, and React beginner friendly.
## [6.0.0 Breaking Changes](https://github.com/nfl/react-helmet/releases/tag/6.0.0)
## Example
```javascript
import React from "react";
import {Helmet} from "react-helmet";
class Application extends React.Component {
render () {
return (
<div className="application">
<Helmet>
<meta charSet="utf-8" />
<title>My Title</title>
<link rel="canonical" href="http://mysite.com/example" />
</Helmet>
...
</div>
);
}
};
```
Nested or latter components will override duplicate changes:
```javascript
<Parent>
<Helmet>
<title>My Title</title>
<meta name="description" content="Helmet application" />
</Helmet>
<Child>
<Helmet>
<title>Nested Title</title>
<meta name="description" content="Nested component" />
</Helmet>
</Child>
</Parent>
```
outputs:
```html
<head>
<title>Nested Title</title>
<meta name="description" content="Nested component">
</head>
```
See below for a full reference guide.
## Features
- Supports all valid head tags: `title`, `base`, `meta`, `link`, `script`, `noscript`, and `style` tags.
- Supports attributes for `body`, `html` and `title` tags.
- Supports server-side rendering.
- Nested components override duplicate head changes.
- Duplicate head changes are preserved when specified in the same component (support for tags like "apple-touch-icon").
- Callback for tracking DOM changes.
## Compatibility
Helmet 5 is fully backward-compatible with previous Helmet releases, so you can upgrade at any time without fear of breaking changes. We encourage you to update your code to our more semantic API, but please feel free to do so at your own pace.
## Installation
Yarn:
```bash
yarn add react-helmet
```
npm:
```bash
npm install --save react-helmet
```
## Server Usage
To use on the server, call `Helmet.renderStatic()` after `ReactDOMServer.renderToString` or `ReactDOMServer.renderToStaticMarkup` to get the head data for use in your prerender.
Because this component keeps track of mounted instances, **you have to make sure to call `renderStatic` on server**, or you'll get a memory leak.
```javascript
ReactDOMServer.renderToString(<Handler />);
const helmet = Helmet.renderStatic();
```
This `helmet` instance contains the following properties:
- `base`
- `bodyAttributes`
- `htmlAttributes`
- `link`
- `meta`
- `noscript`
- `script`
- `style`
- `title`
Each property contains `toComponent()` and `toString()` methods. Use whichever is appropriate for your environment. For attributes, use the JSX spread operator on the object returned by `toComponent()`. E.g:
### As string output
```javascript
const html = `
<!doctype html>
<html ${helmet.htmlAttributes.toString()}>
<head>
${helmet.title.toString()}
${helmet.meta.toString()}
${helmet.link.toString()}
</head>
<body ${helmet.bodyAttributes.toString()}>
<div id="content">
// React stuff here
</div>
</body>
</html>
`;
```
### As React components
```javascript
function HTML () {
const htmlAttrs = helmet.htmlAttributes.toComponent();
const bodyAttrs = helmet.bodyAttributes.toComponent();
return (
<html {...htmlAttrs}>
<head>
{helmet.title.toComponent()}
{helmet.meta.toComponent()}
{helmet.link.toComponent()}
</head>
<body {...bodyAttrs}>
<div id="content">
// React stuff here
</div>
</body>
</html>
);
}
```
### Note: Use the same instance
If you are using a prebuilt compilation of your app with webpack in the server be sure to include this in the `webpack file` so that the same instance of `react-helmet` is used.
```
externals: ["react-helmet"],
```
Or to import the *react-helmet* instance from the app on the server.
### Reference Guide
```javascript
<Helmet
{/* (optional) set to false to disable string encoding (server-only) */}
encodeSpecialCharacters={true}
{/*
(optional) Useful when you want titles to inherit from a template:
<Helmet
titleTemplate="%s | MyAwesomeWebsite.com"
>
<title>Nested Title</title>
</Helmet>
outputs:
<head>
<title>Nested Title | MyAwesomeWebsite.com</title>
</head>
*/}
titleTemplate="MySite.com - %s"
{/*
(optional) used as a fallback when a template exists but a title is not defined
<Helmet
defaultTitle="My Site"
titleTemplate="My Site - %s"
/>
outputs:
<head>
<title>My Site</title>
</head>
*/}
defaultTitle="My Default Title"
{/* (optional) callback that tracks DOM changes */}
onChangeClientState={(newState, addedTags, removedTags) => console.log(newState, addedTags, removedTags)}
>
{/* html attributes */}
<html lang="en" amp />
{/* body attributes */}
<body className="root" />
{/* title attributes and value */}
<title itemProp="name" lang="en">My Plain Title or {`dynamic`} title</title>
{/* base element */}
<base target="_blank" href="http://mysite.com/" />
{/* multiple meta elements */}
<meta name="description" content="Helmet application" />
<meta property="og:type" content="article" />
{/* multiple link elements */}
<link rel="canonical" href="http://mysite.com/example" />
<link rel="apple-touch-icon" href="http://mysite.com/img/apple-touch-icon-57x57.png" />
<link rel="apple-touch-icon" sizes="72x72" href="http://mysite.com/img/apple-touch-icon-72x72.png" />
{locales.map((locale) => {
<link rel="alternate" href="http://example.com/{locale}" hrefLang={locale} key={locale}/>
})}
{/* multiple script elements */}
<script src="http://include.com/pathtojs.js" type="text/javascript" />
{/* inline script elements */}
<script type="application/ld+json">{`
{
"@context": "http://schema.org"
}
`}</script>
{/* noscript elements */}
<noscript>{`
<link rel="stylesheet" type="text/css" href="foo.css" />
`}</noscript>
{/* inline style elements */}
<style type="text/css">{`
body {
background-color: blue;
}
p {
font-size: 12px;
}
`}</style>
</Helmet>
```
## Contributing to this project
Please take a moment to review the [guidelines for contributing](CONTRIBUTING.md).
* [Pull requests](CONTRIBUTING.md#pull-requests)
* [Development Process](CONTRIBUTING.md#development)
## License
MIT
<img align="left" height="200" src="http://static.nfl.com/static/content/public/static/img/logos/ENG_SigilLockup_4C_POS_RGB.png" />

915
server/node_modules/react-helmet/es/Helmet.js generated vendored Normal file
View File

@@ -0,0 +1,915 @@
import PropTypes from 'prop-types';
import withSideEffect from 'react-side-effect';
import isEqual from 'react-fast-compare';
import React from 'react';
import objectAssign from 'object-assign';
var ATTRIBUTE_NAMES = {
BODY: "bodyAttributes",
HTML: "htmlAttributes",
TITLE: "titleAttributes"
};
var TAG_NAMES = {
BASE: "base",
BODY: "body",
HEAD: "head",
HTML: "html",
LINK: "link",
META: "meta",
NOSCRIPT: "noscript",
SCRIPT: "script",
STYLE: "style",
TITLE: "title"
};
var VALID_TAG_NAMES = Object.keys(TAG_NAMES).map(function (name) {
return TAG_NAMES[name];
});
var TAG_PROPERTIES = {
CHARSET: "charset",
CSS_TEXT: "cssText",
HREF: "href",
HTTPEQUIV: "http-equiv",
INNER_HTML: "innerHTML",
ITEM_PROP: "itemprop",
NAME: "name",
PROPERTY: "property",
REL: "rel",
SRC: "src",
TARGET: "target"
};
var REACT_TAG_MAP = {
accesskey: "accessKey",
charset: "charSet",
class: "className",
contenteditable: "contentEditable",
contextmenu: "contextMenu",
"http-equiv": "httpEquiv",
itemprop: "itemProp",
tabindex: "tabIndex"
};
var HELMET_PROPS = {
DEFAULT_TITLE: "defaultTitle",
DEFER: "defer",
ENCODE_SPECIAL_CHARACTERS: "encodeSpecialCharacters",
ON_CHANGE_CLIENT_STATE: "onChangeClientState",
TITLE_TEMPLATE: "titleTemplate"
};
var HTML_TAG_MAP = Object.keys(REACT_TAG_MAP).reduce(function (obj, key) {
obj[REACT_TAG_MAP[key]] = key;
return obj;
}, {});
var SELF_CLOSING_TAGS = [TAG_NAMES.NOSCRIPT, TAG_NAMES.SCRIPT, TAG_NAMES.STYLE];
var HELMET_ATTRIBUTE = "data-react-helmet";
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = 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);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var _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;
};
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
var objectWithoutProperties = function (obj, keys) {
var target = {};
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
}
return target;
};
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
var encodeSpecialCharacters = function encodeSpecialCharacters(str) {
var encode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
if (encode === false) {
return String(str);
}
return String(str).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;");
};
var getTitleFromPropsList = function getTitleFromPropsList(propsList) {
var innermostTitle = getInnermostProperty(propsList, TAG_NAMES.TITLE);
var innermostTemplate = getInnermostProperty(propsList, HELMET_PROPS.TITLE_TEMPLATE);
if (innermostTemplate && innermostTitle) {
// use function arg to avoid need to escape $ characters
return innermostTemplate.replace(/%s/g, function () {
return Array.isArray(innermostTitle) ? innermostTitle.join("") : innermostTitle;
});
}
var innermostDefaultTitle = getInnermostProperty(propsList, HELMET_PROPS.DEFAULT_TITLE);
return innermostTitle || innermostDefaultTitle || undefined;
};
var getOnChangeClientState = function getOnChangeClientState(propsList) {
return getInnermostProperty(propsList, HELMET_PROPS.ON_CHANGE_CLIENT_STATE) || function () {};
};
var getAttributesFromPropsList = function getAttributesFromPropsList(tagType, propsList) {
return propsList.filter(function (props) {
return typeof props[tagType] !== "undefined";
}).map(function (props) {
return props[tagType];
}).reduce(function (tagAttrs, current) {
return _extends({}, tagAttrs, current);
}, {});
};
var getBaseTagFromPropsList = function getBaseTagFromPropsList(primaryAttributes, propsList) {
return propsList.filter(function (props) {
return typeof props[TAG_NAMES.BASE] !== "undefined";
}).map(function (props) {
return props[TAG_NAMES.BASE];
}).reverse().reduce(function (innermostBaseTag, tag) {
if (!innermostBaseTag.length) {
var keys = Object.keys(tag);
for (var i = 0; i < keys.length; i++) {
var attributeKey = keys[i];
var lowerCaseAttributeKey = attributeKey.toLowerCase();
if (primaryAttributes.indexOf(lowerCaseAttributeKey) !== -1 && tag[lowerCaseAttributeKey]) {
return innermostBaseTag.concat(tag);
}
}
}
return innermostBaseTag;
}, []);
};
var getTagsFromPropsList = function getTagsFromPropsList(tagName, primaryAttributes, propsList) {
// Calculate list of tags, giving priority innermost component (end of the propslist)
var approvedSeenTags = {};
return propsList.filter(function (props) {
if (Array.isArray(props[tagName])) {
return true;
}
if (typeof props[tagName] !== "undefined") {
warn("Helmet: " + tagName + " should be of type \"Array\". Instead found type \"" + _typeof(props[tagName]) + "\"");
}
return false;
}).map(function (props) {
return props[tagName];
}).reverse().reduce(function (approvedTags, instanceTags) {
var instanceSeenTags = {};
instanceTags.filter(function (tag) {
var primaryAttributeKey = void 0;
var keys = Object.keys(tag);
for (var i = 0; i < keys.length; i++) {
var attributeKey = keys[i];
var lowerCaseAttributeKey = attributeKey.toLowerCase();
// Special rule with link tags, since rel and href are both primary tags, rel takes priority
if (primaryAttributes.indexOf(lowerCaseAttributeKey) !== -1 && !(primaryAttributeKey === TAG_PROPERTIES.REL && tag[primaryAttributeKey].toLowerCase() === "canonical") && !(lowerCaseAttributeKey === TAG_PROPERTIES.REL && tag[lowerCaseAttributeKey].toLowerCase() === "stylesheet")) {
primaryAttributeKey = lowerCaseAttributeKey;
}
// Special case for innerHTML which doesn't work lowercased
if (primaryAttributes.indexOf(attributeKey) !== -1 && (attributeKey === TAG_PROPERTIES.INNER_HTML || attributeKey === TAG_PROPERTIES.CSS_TEXT || attributeKey === TAG_PROPERTIES.ITEM_PROP)) {
primaryAttributeKey = attributeKey;
}
}
if (!primaryAttributeKey || !tag[primaryAttributeKey]) {
return false;
}
var value = tag[primaryAttributeKey].toLowerCase();
if (!approvedSeenTags[primaryAttributeKey]) {
approvedSeenTags[primaryAttributeKey] = {};
}
if (!instanceSeenTags[primaryAttributeKey]) {
instanceSeenTags[primaryAttributeKey] = {};
}
if (!approvedSeenTags[primaryAttributeKey][value]) {
instanceSeenTags[primaryAttributeKey][value] = true;
return true;
}
return false;
}).reverse().forEach(function (tag) {
return approvedTags.push(tag);
});
// Update seen tags with tags from this instance
var keys = Object.keys(instanceSeenTags);
for (var i = 0; i < keys.length; i++) {
var attributeKey = keys[i];
var tagUnion = objectAssign({}, approvedSeenTags[attributeKey], instanceSeenTags[attributeKey]);
approvedSeenTags[attributeKey] = tagUnion;
}
return approvedTags;
}, []).reverse();
};
var getInnermostProperty = function getInnermostProperty(propsList, property) {
for (var i = propsList.length - 1; i >= 0; i--) {
var props = propsList[i];
if (props.hasOwnProperty(property)) {
return props[property];
}
}
return null;
};
var reducePropsToState = function reducePropsToState(propsList) {
return {
baseTag: getBaseTagFromPropsList([TAG_PROPERTIES.HREF, TAG_PROPERTIES.TARGET], propsList),
bodyAttributes: getAttributesFromPropsList(ATTRIBUTE_NAMES.BODY, propsList),
defer: getInnermostProperty(propsList, HELMET_PROPS.DEFER),
encode: getInnermostProperty(propsList, HELMET_PROPS.ENCODE_SPECIAL_CHARACTERS),
htmlAttributes: getAttributesFromPropsList(ATTRIBUTE_NAMES.HTML, propsList),
linkTags: getTagsFromPropsList(TAG_NAMES.LINK, [TAG_PROPERTIES.REL, TAG_PROPERTIES.HREF], propsList),
metaTags: getTagsFromPropsList(TAG_NAMES.META, [TAG_PROPERTIES.NAME, TAG_PROPERTIES.CHARSET, TAG_PROPERTIES.HTTPEQUIV, TAG_PROPERTIES.PROPERTY, TAG_PROPERTIES.ITEM_PROP], propsList),
noscriptTags: getTagsFromPropsList(TAG_NAMES.NOSCRIPT, [TAG_PROPERTIES.INNER_HTML], propsList),
onChangeClientState: getOnChangeClientState(propsList),
scriptTags: getTagsFromPropsList(TAG_NAMES.SCRIPT, [TAG_PROPERTIES.SRC, TAG_PROPERTIES.INNER_HTML], propsList),
styleTags: getTagsFromPropsList(TAG_NAMES.STYLE, [TAG_PROPERTIES.CSS_TEXT], propsList),
title: getTitleFromPropsList(propsList),
titleAttributes: getAttributesFromPropsList(ATTRIBUTE_NAMES.TITLE, propsList)
};
};
var rafPolyfill = function () {
var clock = Date.now();
return function (callback) {
var currentTime = Date.now();
if (currentTime - clock > 16) {
clock = currentTime;
callback(currentTime);
} else {
setTimeout(function () {
rafPolyfill(callback);
}, 0);
}
};
}();
var cafPolyfill = function cafPolyfill(id) {
return clearTimeout(id);
};
var requestAnimationFrame = typeof window !== "undefined" ? window.requestAnimationFrame && window.requestAnimationFrame.bind(window) || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || rafPolyfill : global.requestAnimationFrame || rafPolyfill;
var cancelAnimationFrame = typeof window !== "undefined" ? window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || cafPolyfill : global.cancelAnimationFrame || cafPolyfill;
var warn = function warn(msg) {
return console && typeof console.warn === "function" && console.warn(msg);
};
var _helmetCallback = null;
var handleClientStateChange = function handleClientStateChange(newState) {
if (_helmetCallback) {
cancelAnimationFrame(_helmetCallback);
}
if (newState.defer) {
_helmetCallback = requestAnimationFrame(function () {
commitTagChanges(newState, function () {
_helmetCallback = null;
});
});
} else {
commitTagChanges(newState);
_helmetCallback = null;
}
};
var commitTagChanges = function commitTagChanges(newState, cb) {
var baseTag = newState.baseTag,
bodyAttributes = newState.bodyAttributes,
htmlAttributes = newState.htmlAttributes,
linkTags = newState.linkTags,
metaTags = newState.metaTags,
noscriptTags = newState.noscriptTags,
onChangeClientState = newState.onChangeClientState,
scriptTags = newState.scriptTags,
styleTags = newState.styleTags,
title = newState.title,
titleAttributes = newState.titleAttributes;
updateAttributes(TAG_NAMES.BODY, bodyAttributes);
updateAttributes(TAG_NAMES.HTML, htmlAttributes);
updateTitle(title, titleAttributes);
var tagUpdates = {
baseTag: updateTags(TAG_NAMES.BASE, baseTag),
linkTags: updateTags(TAG_NAMES.LINK, linkTags),
metaTags: updateTags(TAG_NAMES.META, metaTags),
noscriptTags: updateTags(TAG_NAMES.NOSCRIPT, noscriptTags),
scriptTags: updateTags(TAG_NAMES.SCRIPT, scriptTags),
styleTags: updateTags(TAG_NAMES.STYLE, styleTags)
};
var addedTags = {};
var removedTags = {};
Object.keys(tagUpdates).forEach(function (tagType) {
var _tagUpdates$tagType = tagUpdates[tagType],
newTags = _tagUpdates$tagType.newTags,
oldTags = _tagUpdates$tagType.oldTags;
if (newTags.length) {
addedTags[tagType] = newTags;
}
if (oldTags.length) {
removedTags[tagType] = tagUpdates[tagType].oldTags;
}
});
cb && cb();
onChangeClientState(newState, addedTags, removedTags);
};
var flattenArray = function flattenArray(possibleArray) {
return Array.isArray(possibleArray) ? possibleArray.join("") : possibleArray;
};
var updateTitle = function updateTitle(title, attributes) {
if (typeof title !== "undefined" && document.title !== title) {
document.title = flattenArray(title);
}
updateAttributes(TAG_NAMES.TITLE, attributes);
};
var updateAttributes = function updateAttributes(tagName, attributes) {
var elementTag = document.getElementsByTagName(tagName)[0];
if (!elementTag) {
return;
}
var helmetAttributeString = elementTag.getAttribute(HELMET_ATTRIBUTE);
var helmetAttributes = helmetAttributeString ? helmetAttributeString.split(",") : [];
var attributesToRemove = [].concat(helmetAttributes);
var attributeKeys = Object.keys(attributes);
for (var i = 0; i < attributeKeys.length; i++) {
var attribute = attributeKeys[i];
var value = attributes[attribute] || "";
if (elementTag.getAttribute(attribute) !== value) {
elementTag.setAttribute(attribute, value);
}
if (helmetAttributes.indexOf(attribute) === -1) {
helmetAttributes.push(attribute);
}
var indexToSave = attributesToRemove.indexOf(attribute);
if (indexToSave !== -1) {
attributesToRemove.splice(indexToSave, 1);
}
}
for (var _i = attributesToRemove.length - 1; _i >= 0; _i--) {
elementTag.removeAttribute(attributesToRemove[_i]);
}
if (helmetAttributes.length === attributesToRemove.length) {
elementTag.removeAttribute(HELMET_ATTRIBUTE);
} else if (elementTag.getAttribute(HELMET_ATTRIBUTE) !== attributeKeys.join(",")) {
elementTag.setAttribute(HELMET_ATTRIBUTE, attributeKeys.join(","));
}
};
var updateTags = function updateTags(type, tags) {
var headElement = document.head || document.querySelector(TAG_NAMES.HEAD);
var tagNodes = headElement.querySelectorAll(type + "[" + HELMET_ATTRIBUTE + "]");
var oldTags = Array.prototype.slice.call(tagNodes);
var newTags = [];
var indexToDelete = void 0;
if (tags && tags.length) {
tags.forEach(function (tag) {
var newElement = document.createElement(type);
for (var attribute in tag) {
if (tag.hasOwnProperty(attribute)) {
if (attribute === TAG_PROPERTIES.INNER_HTML) {
newElement.innerHTML = tag.innerHTML;
} else if (attribute === TAG_PROPERTIES.CSS_TEXT) {
if (newElement.styleSheet) {
newElement.styleSheet.cssText = tag.cssText;
} else {
newElement.appendChild(document.createTextNode(tag.cssText));
}
} else {
var value = typeof tag[attribute] === "undefined" ? "" : tag[attribute];
newElement.setAttribute(attribute, value);
}
}
}
newElement.setAttribute(HELMET_ATTRIBUTE, "true");
// Remove a duplicate tag from domTagstoRemove, so it isn't cleared.
if (oldTags.some(function (existingTag, index) {
indexToDelete = index;
return newElement.isEqualNode(existingTag);
})) {
oldTags.splice(indexToDelete, 1);
} else {
newTags.push(newElement);
}
});
}
oldTags.forEach(function (tag) {
return tag.parentNode.removeChild(tag);
});
newTags.forEach(function (tag) {
return headElement.appendChild(tag);
});
return {
oldTags: oldTags,
newTags: newTags
};
};
var generateElementAttributesAsString = function generateElementAttributesAsString(attributes) {
return Object.keys(attributes).reduce(function (str, key) {
var attr = typeof attributes[key] !== "undefined" ? key + "=\"" + attributes[key] + "\"" : "" + key;
return str ? str + " " + attr : attr;
}, "");
};
var generateTitleAsString = function generateTitleAsString(type, title, attributes, encode) {
var attributeString = generateElementAttributesAsString(attributes);
var flattenedTitle = flattenArray(title);
return attributeString ? "<" + type + " " + HELMET_ATTRIBUTE + "=\"true\" " + attributeString + ">" + encodeSpecialCharacters(flattenedTitle, encode) + "</" + type + ">" : "<" + type + " " + HELMET_ATTRIBUTE + "=\"true\">" + encodeSpecialCharacters(flattenedTitle, encode) + "</" + type + ">";
};
var generateTagsAsString = function generateTagsAsString(type, tags, encode) {
return tags.reduce(function (str, tag) {
var attributeHtml = Object.keys(tag).filter(function (attribute) {
return !(attribute === TAG_PROPERTIES.INNER_HTML || attribute === TAG_PROPERTIES.CSS_TEXT);
}).reduce(function (string, attribute) {
var attr = typeof tag[attribute] === "undefined" ? attribute : attribute + "=\"" + encodeSpecialCharacters(tag[attribute], encode) + "\"";
return string ? string + " " + attr : attr;
}, "");
var tagContent = tag.innerHTML || tag.cssText || "";
var isSelfClosing = SELF_CLOSING_TAGS.indexOf(type) === -1;
return str + "<" + type + " " + HELMET_ATTRIBUTE + "=\"true\" " + attributeHtml + (isSelfClosing ? "/>" : ">" + tagContent + "</" + type + ">");
}, "");
};
var convertElementAttributestoReactProps = function convertElementAttributestoReactProps(attributes) {
var initProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return Object.keys(attributes).reduce(function (obj, key) {
obj[REACT_TAG_MAP[key] || key] = attributes[key];
return obj;
}, initProps);
};
var convertReactPropstoHtmlAttributes = function convertReactPropstoHtmlAttributes(props) {
var initAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return Object.keys(props).reduce(function (obj, key) {
obj[HTML_TAG_MAP[key] || key] = props[key];
return obj;
}, initAttributes);
};
var generateTitleAsReactComponent = function generateTitleAsReactComponent(type, title, attributes) {
var _initProps;
// assigning into an array to define toString function on it
var initProps = (_initProps = {
key: title
}, _initProps[HELMET_ATTRIBUTE] = true, _initProps);
var props = convertElementAttributestoReactProps(attributes, initProps);
return [React.createElement(TAG_NAMES.TITLE, props, title)];
};
var generateTagsAsReactComponent = function generateTagsAsReactComponent(type, tags) {
return tags.map(function (tag, i) {
var _mappedTag;
var mappedTag = (_mappedTag = {
key: i
}, _mappedTag[HELMET_ATTRIBUTE] = true, _mappedTag);
Object.keys(tag).forEach(function (attribute) {
var mappedAttribute = REACT_TAG_MAP[attribute] || attribute;
if (mappedAttribute === TAG_PROPERTIES.INNER_HTML || mappedAttribute === TAG_PROPERTIES.CSS_TEXT) {
var content = tag.innerHTML || tag.cssText;
mappedTag.dangerouslySetInnerHTML = { __html: content };
} else {
mappedTag[mappedAttribute] = tag[attribute];
}
});
return React.createElement(type, mappedTag);
});
};
var getMethodsForTag = function getMethodsForTag(type, tags, encode) {
switch (type) {
case TAG_NAMES.TITLE:
return {
toComponent: function toComponent() {
return generateTitleAsReactComponent(type, tags.title, tags.titleAttributes, encode);
},
toString: function toString() {
return generateTitleAsString(type, tags.title, tags.titleAttributes, encode);
}
};
case ATTRIBUTE_NAMES.BODY:
case ATTRIBUTE_NAMES.HTML:
return {
toComponent: function toComponent() {
return convertElementAttributestoReactProps(tags);
},
toString: function toString() {
return generateElementAttributesAsString(tags);
}
};
default:
return {
toComponent: function toComponent() {
return generateTagsAsReactComponent(type, tags);
},
toString: function toString() {
return generateTagsAsString(type, tags, encode);
}
};
}
};
var mapStateOnServer = function mapStateOnServer(_ref) {
var baseTag = _ref.baseTag,
bodyAttributes = _ref.bodyAttributes,
encode = _ref.encode,
htmlAttributes = _ref.htmlAttributes,
linkTags = _ref.linkTags,
metaTags = _ref.metaTags,
noscriptTags = _ref.noscriptTags,
scriptTags = _ref.scriptTags,
styleTags = _ref.styleTags,
_ref$title = _ref.title,
title = _ref$title === undefined ? "" : _ref$title,
titleAttributes = _ref.titleAttributes;
return {
base: getMethodsForTag(TAG_NAMES.BASE, baseTag, encode),
bodyAttributes: getMethodsForTag(ATTRIBUTE_NAMES.BODY, bodyAttributes, encode),
htmlAttributes: getMethodsForTag(ATTRIBUTE_NAMES.HTML, htmlAttributes, encode),
link: getMethodsForTag(TAG_NAMES.LINK, linkTags, encode),
meta: getMethodsForTag(TAG_NAMES.META, metaTags, encode),
noscript: getMethodsForTag(TAG_NAMES.NOSCRIPT, noscriptTags, encode),
script: getMethodsForTag(TAG_NAMES.SCRIPT, scriptTags, encode),
style: getMethodsForTag(TAG_NAMES.STYLE, styleTags, encode),
title: getMethodsForTag(TAG_NAMES.TITLE, { title: title, titleAttributes: titleAttributes }, encode)
};
};
var Helmet = function Helmet(Component) {
var _class, _temp;
return _temp = _class = function (_React$Component) {
inherits(HelmetWrapper, _React$Component);
function HelmetWrapper() {
classCallCheck(this, HelmetWrapper);
return possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
HelmetWrapper.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
return !isEqual(this.props, nextProps);
};
HelmetWrapper.prototype.mapNestedChildrenToProps = function mapNestedChildrenToProps(child, nestedChildren) {
if (!nestedChildren) {
return null;
}
switch (child.type) {
case TAG_NAMES.SCRIPT:
case TAG_NAMES.NOSCRIPT:
return {
innerHTML: nestedChildren
};
case TAG_NAMES.STYLE:
return {
cssText: nestedChildren
};
}
throw new Error("<" + child.type + " /> elements are self-closing and can not contain children. Refer to our API for more information.");
};
HelmetWrapper.prototype.flattenArrayTypeChildren = function flattenArrayTypeChildren(_ref) {
var _babelHelpers$extends;
var child = _ref.child,
arrayTypeChildren = _ref.arrayTypeChildren,
newChildProps = _ref.newChildProps,
nestedChildren = _ref.nestedChildren;
return _extends({}, arrayTypeChildren, (_babelHelpers$extends = {}, _babelHelpers$extends[child.type] = [].concat(arrayTypeChildren[child.type] || [], [_extends({}, newChildProps, this.mapNestedChildrenToProps(child, nestedChildren))]), _babelHelpers$extends));
};
HelmetWrapper.prototype.mapObjectTypeChildren = function mapObjectTypeChildren(_ref2) {
var _babelHelpers$extends2, _babelHelpers$extends3;
var child = _ref2.child,
newProps = _ref2.newProps,
newChildProps = _ref2.newChildProps,
nestedChildren = _ref2.nestedChildren;
switch (child.type) {
case TAG_NAMES.TITLE:
return _extends({}, newProps, (_babelHelpers$extends2 = {}, _babelHelpers$extends2[child.type] = nestedChildren, _babelHelpers$extends2.titleAttributes = _extends({}, newChildProps), _babelHelpers$extends2));
case TAG_NAMES.BODY:
return _extends({}, newProps, {
bodyAttributes: _extends({}, newChildProps)
});
case TAG_NAMES.HTML:
return _extends({}, newProps, {
htmlAttributes: _extends({}, newChildProps)
});
}
return _extends({}, newProps, (_babelHelpers$extends3 = {}, _babelHelpers$extends3[child.type] = _extends({}, newChildProps), _babelHelpers$extends3));
};
HelmetWrapper.prototype.mapArrayTypeChildrenToProps = function mapArrayTypeChildrenToProps(arrayTypeChildren, newProps) {
var newFlattenedProps = _extends({}, newProps);
Object.keys(arrayTypeChildren).forEach(function (arrayChildName) {
var _babelHelpers$extends4;
newFlattenedProps = _extends({}, newFlattenedProps, (_babelHelpers$extends4 = {}, _babelHelpers$extends4[arrayChildName] = arrayTypeChildren[arrayChildName], _babelHelpers$extends4));
});
return newFlattenedProps;
};
HelmetWrapper.prototype.warnOnInvalidChildren = function warnOnInvalidChildren(child, nestedChildren) {
if (process.env.NODE_ENV !== "production") {
if (!VALID_TAG_NAMES.some(function (name) {
return child.type === name;
})) {
if (typeof child.type === "function") {
return warn("You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.");
}
return warn("Only elements types " + VALID_TAG_NAMES.join(", ") + " are allowed. Helmet does not support rendering <" + child.type + "> elements. Refer to our API for more information.");
}
if (nestedChildren && typeof nestedChildren !== "string" && (!Array.isArray(nestedChildren) || nestedChildren.some(function (nestedChild) {
return typeof nestedChild !== "string";
}))) {
throw new Error("Helmet expects a string as a child of <" + child.type + ">. Did you forget to wrap your children in braces? ( <" + child.type + ">{``}</" + child.type + "> ) Refer to our API for more information.");
}
}
return true;
};
HelmetWrapper.prototype.mapChildrenToProps = function mapChildrenToProps(children, newProps) {
var _this2 = this;
var arrayTypeChildren = {};
React.Children.forEach(children, function (child) {
if (!child || !child.props) {
return;
}
var _child$props = child.props,
nestedChildren = _child$props.children,
childProps = objectWithoutProperties(_child$props, ["children"]);
var newChildProps = convertReactPropstoHtmlAttributes(childProps);
_this2.warnOnInvalidChildren(child, nestedChildren);
switch (child.type) {
case TAG_NAMES.LINK:
case TAG_NAMES.META:
case TAG_NAMES.NOSCRIPT:
case TAG_NAMES.SCRIPT:
case TAG_NAMES.STYLE:
arrayTypeChildren = _this2.flattenArrayTypeChildren({
child: child,
arrayTypeChildren: arrayTypeChildren,
newChildProps: newChildProps,
nestedChildren: nestedChildren
});
break;
default:
newProps = _this2.mapObjectTypeChildren({
child: child,
newProps: newProps,
newChildProps: newChildProps,
nestedChildren: nestedChildren
});
break;
}
});
newProps = this.mapArrayTypeChildrenToProps(arrayTypeChildren, newProps);
return newProps;
};
HelmetWrapper.prototype.render = function render() {
var _props = this.props,
children = _props.children,
props = objectWithoutProperties(_props, ["children"]);
var newProps = _extends({}, props);
if (children) {
newProps = this.mapChildrenToProps(children, newProps);
}
return React.createElement(Component, newProps);
};
createClass(HelmetWrapper, null, [{
key: "canUseDOM",
// Component.peek comes from react-side-effect:
// For testing, you may use a static peek() method available on the returned component.
// It lets you get the current state without resetting the mounted instance stack.
// Dont use it for anything other than testing.
/**
* @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"
*/
set: function set$$1(canUseDOM) {
Component.canUseDOM = canUseDOM;
}
}]);
return HelmetWrapper;
}(React.Component), _class.propTypes = {
base: PropTypes.object,
bodyAttributes: PropTypes.object,
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
defaultTitle: PropTypes.string,
defer: PropTypes.bool,
encodeSpecialCharacters: PropTypes.bool,
htmlAttributes: PropTypes.object,
link: PropTypes.arrayOf(PropTypes.object),
meta: PropTypes.arrayOf(PropTypes.object),
noscript: PropTypes.arrayOf(PropTypes.object),
onChangeClientState: PropTypes.func,
script: PropTypes.arrayOf(PropTypes.object),
style: PropTypes.arrayOf(PropTypes.object),
title: PropTypes.string,
titleAttributes: PropTypes.object,
titleTemplate: PropTypes.string
}, _class.defaultProps = {
defer: true,
encodeSpecialCharacters: true
}, _class.peek = Component.peek, _class.rewind = function () {
var mappedState = Component.rewind();
if (!mappedState) {
// provide fallback if mappedState is undefined
mappedState = mapStateOnServer({
baseTag: [],
bodyAttributes: {},
encodeSpecialCharacters: true,
htmlAttributes: {},
linkTags: [],
metaTags: [],
noscriptTags: [],
scriptTags: [],
styleTags: [],
title: "",
titleAttributes: {}
});
}
return mappedState;
}, _temp;
};
var NullComponent = function NullComponent() {
return null;
};
var HelmetSideEffects = withSideEffect(reducePropsToState, handleClientStateChange, mapStateOnServer)(NullComponent);
var HelmetExport = Helmet(HelmetSideEffects);
HelmetExport.renderStatic = HelmetExport.rewind;
export default HelmetExport;
export { HelmetExport as Helmet };

921
server/node_modules/react-helmet/lib/Helmet.js generated vendored Normal file
View File

@@ -0,0 +1,921 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var PropTypes = _interopDefault(require('prop-types'));
var withSideEffect = _interopDefault(require('react-side-effect'));
var isEqual = _interopDefault(require('react-fast-compare'));
var React = _interopDefault(require('react'));
var objectAssign = _interopDefault(require('object-assign'));
var ATTRIBUTE_NAMES = {
BODY: "bodyAttributes",
HTML: "htmlAttributes",
TITLE: "titleAttributes"
};
var TAG_NAMES = {
BASE: "base",
BODY: "body",
HEAD: "head",
HTML: "html",
LINK: "link",
META: "meta",
NOSCRIPT: "noscript",
SCRIPT: "script",
STYLE: "style",
TITLE: "title"
};
var VALID_TAG_NAMES = Object.keys(TAG_NAMES).map(function (name) {
return TAG_NAMES[name];
});
var TAG_PROPERTIES = {
CHARSET: "charset",
CSS_TEXT: "cssText",
HREF: "href",
HTTPEQUIV: "http-equiv",
INNER_HTML: "innerHTML",
ITEM_PROP: "itemprop",
NAME: "name",
PROPERTY: "property",
REL: "rel",
SRC: "src",
TARGET: "target"
};
var REACT_TAG_MAP = {
accesskey: "accessKey",
charset: "charSet",
class: "className",
contenteditable: "contentEditable",
contextmenu: "contextMenu",
"http-equiv": "httpEquiv",
itemprop: "itemProp",
tabindex: "tabIndex"
};
var HELMET_PROPS = {
DEFAULT_TITLE: "defaultTitle",
DEFER: "defer",
ENCODE_SPECIAL_CHARACTERS: "encodeSpecialCharacters",
ON_CHANGE_CLIENT_STATE: "onChangeClientState",
TITLE_TEMPLATE: "titleTemplate"
};
var HTML_TAG_MAP = Object.keys(REACT_TAG_MAP).reduce(function (obj, key) {
obj[REACT_TAG_MAP[key]] = key;
return obj;
}, {});
var SELF_CLOSING_TAGS = [TAG_NAMES.NOSCRIPT, TAG_NAMES.SCRIPT, TAG_NAMES.STYLE];
var HELMET_ATTRIBUTE = "data-react-helmet";
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
var createClass = 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);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
var _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;
};
var inherits = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
};
var objectWithoutProperties = function (obj, keys) {
var target = {};
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
}
return target;
};
var possibleConstructorReturn = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && (typeof call === "object" || typeof call === "function") ? call : self;
};
var encodeSpecialCharacters = function encodeSpecialCharacters(str) {
var encode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
if (encode === false) {
return String(str);
}
return String(str).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#x27;");
};
var getTitleFromPropsList = function getTitleFromPropsList(propsList) {
var innermostTitle = getInnermostProperty(propsList, TAG_NAMES.TITLE);
var innermostTemplate = getInnermostProperty(propsList, HELMET_PROPS.TITLE_TEMPLATE);
if (innermostTemplate && innermostTitle) {
// use function arg to avoid need to escape $ characters
return innermostTemplate.replace(/%s/g, function () {
return Array.isArray(innermostTitle) ? innermostTitle.join("") : innermostTitle;
});
}
var innermostDefaultTitle = getInnermostProperty(propsList, HELMET_PROPS.DEFAULT_TITLE);
return innermostTitle || innermostDefaultTitle || undefined;
};
var getOnChangeClientState = function getOnChangeClientState(propsList) {
return getInnermostProperty(propsList, HELMET_PROPS.ON_CHANGE_CLIENT_STATE) || function () {};
};
var getAttributesFromPropsList = function getAttributesFromPropsList(tagType, propsList) {
return propsList.filter(function (props) {
return typeof props[tagType] !== "undefined";
}).map(function (props) {
return props[tagType];
}).reduce(function (tagAttrs, current) {
return _extends({}, tagAttrs, current);
}, {});
};
var getBaseTagFromPropsList = function getBaseTagFromPropsList(primaryAttributes, propsList) {
return propsList.filter(function (props) {
return typeof props[TAG_NAMES.BASE] !== "undefined";
}).map(function (props) {
return props[TAG_NAMES.BASE];
}).reverse().reduce(function (innermostBaseTag, tag) {
if (!innermostBaseTag.length) {
var keys = Object.keys(tag);
for (var i = 0; i < keys.length; i++) {
var attributeKey = keys[i];
var lowerCaseAttributeKey = attributeKey.toLowerCase();
if (primaryAttributes.indexOf(lowerCaseAttributeKey) !== -1 && tag[lowerCaseAttributeKey]) {
return innermostBaseTag.concat(tag);
}
}
}
return innermostBaseTag;
}, []);
};
var getTagsFromPropsList = function getTagsFromPropsList(tagName, primaryAttributes, propsList) {
// Calculate list of tags, giving priority innermost component (end of the propslist)
var approvedSeenTags = {};
return propsList.filter(function (props) {
if (Array.isArray(props[tagName])) {
return true;
}
if (typeof props[tagName] !== "undefined") {
warn("Helmet: " + tagName + " should be of type \"Array\". Instead found type \"" + _typeof(props[tagName]) + "\"");
}
return false;
}).map(function (props) {
return props[tagName];
}).reverse().reduce(function (approvedTags, instanceTags) {
var instanceSeenTags = {};
instanceTags.filter(function (tag) {
var primaryAttributeKey = void 0;
var keys = Object.keys(tag);
for (var i = 0; i < keys.length; i++) {
var attributeKey = keys[i];
var lowerCaseAttributeKey = attributeKey.toLowerCase();
// Special rule with link tags, since rel and href are both primary tags, rel takes priority
if (primaryAttributes.indexOf(lowerCaseAttributeKey) !== -1 && !(primaryAttributeKey === TAG_PROPERTIES.REL && tag[primaryAttributeKey].toLowerCase() === "canonical") && !(lowerCaseAttributeKey === TAG_PROPERTIES.REL && tag[lowerCaseAttributeKey].toLowerCase() === "stylesheet")) {
primaryAttributeKey = lowerCaseAttributeKey;
}
// Special case for innerHTML which doesn't work lowercased
if (primaryAttributes.indexOf(attributeKey) !== -1 && (attributeKey === TAG_PROPERTIES.INNER_HTML || attributeKey === TAG_PROPERTIES.CSS_TEXT || attributeKey === TAG_PROPERTIES.ITEM_PROP)) {
primaryAttributeKey = attributeKey;
}
}
if (!primaryAttributeKey || !tag[primaryAttributeKey]) {
return false;
}
var value = tag[primaryAttributeKey].toLowerCase();
if (!approvedSeenTags[primaryAttributeKey]) {
approvedSeenTags[primaryAttributeKey] = {};
}
if (!instanceSeenTags[primaryAttributeKey]) {
instanceSeenTags[primaryAttributeKey] = {};
}
if (!approvedSeenTags[primaryAttributeKey][value]) {
instanceSeenTags[primaryAttributeKey][value] = true;
return true;
}
return false;
}).reverse().forEach(function (tag) {
return approvedTags.push(tag);
});
// Update seen tags with tags from this instance
var keys = Object.keys(instanceSeenTags);
for (var i = 0; i < keys.length; i++) {
var attributeKey = keys[i];
var tagUnion = objectAssign({}, approvedSeenTags[attributeKey], instanceSeenTags[attributeKey]);
approvedSeenTags[attributeKey] = tagUnion;
}
return approvedTags;
}, []).reverse();
};
var getInnermostProperty = function getInnermostProperty(propsList, property) {
for (var i = propsList.length - 1; i >= 0; i--) {
var props = propsList[i];
if (props.hasOwnProperty(property)) {
return props[property];
}
}
return null;
};
var reducePropsToState = function reducePropsToState(propsList) {
return {
baseTag: getBaseTagFromPropsList([TAG_PROPERTIES.HREF, TAG_PROPERTIES.TARGET], propsList),
bodyAttributes: getAttributesFromPropsList(ATTRIBUTE_NAMES.BODY, propsList),
defer: getInnermostProperty(propsList, HELMET_PROPS.DEFER),
encode: getInnermostProperty(propsList, HELMET_PROPS.ENCODE_SPECIAL_CHARACTERS),
htmlAttributes: getAttributesFromPropsList(ATTRIBUTE_NAMES.HTML, propsList),
linkTags: getTagsFromPropsList(TAG_NAMES.LINK, [TAG_PROPERTIES.REL, TAG_PROPERTIES.HREF], propsList),
metaTags: getTagsFromPropsList(TAG_NAMES.META, [TAG_PROPERTIES.NAME, TAG_PROPERTIES.CHARSET, TAG_PROPERTIES.HTTPEQUIV, TAG_PROPERTIES.PROPERTY, TAG_PROPERTIES.ITEM_PROP], propsList),
noscriptTags: getTagsFromPropsList(TAG_NAMES.NOSCRIPT, [TAG_PROPERTIES.INNER_HTML], propsList),
onChangeClientState: getOnChangeClientState(propsList),
scriptTags: getTagsFromPropsList(TAG_NAMES.SCRIPT, [TAG_PROPERTIES.SRC, TAG_PROPERTIES.INNER_HTML], propsList),
styleTags: getTagsFromPropsList(TAG_NAMES.STYLE, [TAG_PROPERTIES.CSS_TEXT], propsList),
title: getTitleFromPropsList(propsList),
titleAttributes: getAttributesFromPropsList(ATTRIBUTE_NAMES.TITLE, propsList)
};
};
var rafPolyfill = function () {
var clock = Date.now();
return function (callback) {
var currentTime = Date.now();
if (currentTime - clock > 16) {
clock = currentTime;
callback(currentTime);
} else {
setTimeout(function () {
rafPolyfill(callback);
}, 0);
}
};
}();
var cafPolyfill = function cafPolyfill(id) {
return clearTimeout(id);
};
var requestAnimationFrame = typeof window !== "undefined" ? window.requestAnimationFrame && window.requestAnimationFrame.bind(window) || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || rafPolyfill : global.requestAnimationFrame || rafPolyfill;
var cancelAnimationFrame = typeof window !== "undefined" ? window.cancelAnimationFrame || window.webkitCancelAnimationFrame || window.mozCancelAnimationFrame || cafPolyfill : global.cancelAnimationFrame || cafPolyfill;
var warn = function warn(msg) {
return console && typeof console.warn === "function" && console.warn(msg);
};
var _helmetCallback = null;
var handleClientStateChange = function handleClientStateChange(newState) {
if (_helmetCallback) {
cancelAnimationFrame(_helmetCallback);
}
if (newState.defer) {
_helmetCallback = requestAnimationFrame(function () {
commitTagChanges(newState, function () {
_helmetCallback = null;
});
});
} else {
commitTagChanges(newState);
_helmetCallback = null;
}
};
var commitTagChanges = function commitTagChanges(newState, cb) {
var baseTag = newState.baseTag,
bodyAttributes = newState.bodyAttributes,
htmlAttributes = newState.htmlAttributes,
linkTags = newState.linkTags,
metaTags = newState.metaTags,
noscriptTags = newState.noscriptTags,
onChangeClientState = newState.onChangeClientState,
scriptTags = newState.scriptTags,
styleTags = newState.styleTags,
title = newState.title,
titleAttributes = newState.titleAttributes;
updateAttributes(TAG_NAMES.BODY, bodyAttributes);
updateAttributes(TAG_NAMES.HTML, htmlAttributes);
updateTitle(title, titleAttributes);
var tagUpdates = {
baseTag: updateTags(TAG_NAMES.BASE, baseTag),
linkTags: updateTags(TAG_NAMES.LINK, linkTags),
metaTags: updateTags(TAG_NAMES.META, metaTags),
noscriptTags: updateTags(TAG_NAMES.NOSCRIPT, noscriptTags),
scriptTags: updateTags(TAG_NAMES.SCRIPT, scriptTags),
styleTags: updateTags(TAG_NAMES.STYLE, styleTags)
};
var addedTags = {};
var removedTags = {};
Object.keys(tagUpdates).forEach(function (tagType) {
var _tagUpdates$tagType = tagUpdates[tagType],
newTags = _tagUpdates$tagType.newTags,
oldTags = _tagUpdates$tagType.oldTags;
if (newTags.length) {
addedTags[tagType] = newTags;
}
if (oldTags.length) {
removedTags[tagType] = tagUpdates[tagType].oldTags;
}
});
cb && cb();
onChangeClientState(newState, addedTags, removedTags);
};
var flattenArray = function flattenArray(possibleArray) {
return Array.isArray(possibleArray) ? possibleArray.join("") : possibleArray;
};
var updateTitle = function updateTitle(title, attributes) {
if (typeof title !== "undefined" && document.title !== title) {
document.title = flattenArray(title);
}
updateAttributes(TAG_NAMES.TITLE, attributes);
};
var updateAttributes = function updateAttributes(tagName, attributes) {
var elementTag = document.getElementsByTagName(tagName)[0];
if (!elementTag) {
return;
}
var helmetAttributeString = elementTag.getAttribute(HELMET_ATTRIBUTE);
var helmetAttributes = helmetAttributeString ? helmetAttributeString.split(",") : [];
var attributesToRemove = [].concat(helmetAttributes);
var attributeKeys = Object.keys(attributes);
for (var i = 0; i < attributeKeys.length; i++) {
var attribute = attributeKeys[i];
var value = attributes[attribute] || "";
if (elementTag.getAttribute(attribute) !== value) {
elementTag.setAttribute(attribute, value);
}
if (helmetAttributes.indexOf(attribute) === -1) {
helmetAttributes.push(attribute);
}
var indexToSave = attributesToRemove.indexOf(attribute);
if (indexToSave !== -1) {
attributesToRemove.splice(indexToSave, 1);
}
}
for (var _i = attributesToRemove.length - 1; _i >= 0; _i--) {
elementTag.removeAttribute(attributesToRemove[_i]);
}
if (helmetAttributes.length === attributesToRemove.length) {
elementTag.removeAttribute(HELMET_ATTRIBUTE);
} else if (elementTag.getAttribute(HELMET_ATTRIBUTE) !== attributeKeys.join(",")) {
elementTag.setAttribute(HELMET_ATTRIBUTE, attributeKeys.join(","));
}
};
var updateTags = function updateTags(type, tags) {
var headElement = document.head || document.querySelector(TAG_NAMES.HEAD);
var tagNodes = headElement.querySelectorAll(type + "[" + HELMET_ATTRIBUTE + "]");
var oldTags = Array.prototype.slice.call(tagNodes);
var newTags = [];
var indexToDelete = void 0;
if (tags && tags.length) {
tags.forEach(function (tag) {
var newElement = document.createElement(type);
for (var attribute in tag) {
if (tag.hasOwnProperty(attribute)) {
if (attribute === TAG_PROPERTIES.INNER_HTML) {
newElement.innerHTML = tag.innerHTML;
} else if (attribute === TAG_PROPERTIES.CSS_TEXT) {
if (newElement.styleSheet) {
newElement.styleSheet.cssText = tag.cssText;
} else {
newElement.appendChild(document.createTextNode(tag.cssText));
}
} else {
var value = typeof tag[attribute] === "undefined" ? "" : tag[attribute];
newElement.setAttribute(attribute, value);
}
}
}
newElement.setAttribute(HELMET_ATTRIBUTE, "true");
// Remove a duplicate tag from domTagstoRemove, so it isn't cleared.
if (oldTags.some(function (existingTag, index) {
indexToDelete = index;
return newElement.isEqualNode(existingTag);
})) {
oldTags.splice(indexToDelete, 1);
} else {
newTags.push(newElement);
}
});
}
oldTags.forEach(function (tag) {
return tag.parentNode.removeChild(tag);
});
newTags.forEach(function (tag) {
return headElement.appendChild(tag);
});
return {
oldTags: oldTags,
newTags: newTags
};
};
var generateElementAttributesAsString = function generateElementAttributesAsString(attributes) {
return Object.keys(attributes).reduce(function (str, key) {
var attr = typeof attributes[key] !== "undefined" ? key + "=\"" + attributes[key] + "\"" : "" + key;
return str ? str + " " + attr : attr;
}, "");
};
var generateTitleAsString = function generateTitleAsString(type, title, attributes, encode) {
var attributeString = generateElementAttributesAsString(attributes);
var flattenedTitle = flattenArray(title);
return attributeString ? "<" + type + " " + HELMET_ATTRIBUTE + "=\"true\" " + attributeString + ">" + encodeSpecialCharacters(flattenedTitle, encode) + "</" + type + ">" : "<" + type + " " + HELMET_ATTRIBUTE + "=\"true\">" + encodeSpecialCharacters(flattenedTitle, encode) + "</" + type + ">";
};
var generateTagsAsString = function generateTagsAsString(type, tags, encode) {
return tags.reduce(function (str, tag) {
var attributeHtml = Object.keys(tag).filter(function (attribute) {
return !(attribute === TAG_PROPERTIES.INNER_HTML || attribute === TAG_PROPERTIES.CSS_TEXT);
}).reduce(function (string, attribute) {
var attr = typeof tag[attribute] === "undefined" ? attribute : attribute + "=\"" + encodeSpecialCharacters(tag[attribute], encode) + "\"";
return string ? string + " " + attr : attr;
}, "");
var tagContent = tag.innerHTML || tag.cssText || "";
var isSelfClosing = SELF_CLOSING_TAGS.indexOf(type) === -1;
return str + "<" + type + " " + HELMET_ATTRIBUTE + "=\"true\" " + attributeHtml + (isSelfClosing ? "/>" : ">" + tagContent + "</" + type + ">");
}, "");
};
var convertElementAttributestoReactProps = function convertElementAttributestoReactProps(attributes) {
var initProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return Object.keys(attributes).reduce(function (obj, key) {
obj[REACT_TAG_MAP[key] || key] = attributes[key];
return obj;
}, initProps);
};
var convertReactPropstoHtmlAttributes = function convertReactPropstoHtmlAttributes(props) {
var initAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
return Object.keys(props).reduce(function (obj, key) {
obj[HTML_TAG_MAP[key] || key] = props[key];
return obj;
}, initAttributes);
};
var generateTitleAsReactComponent = function generateTitleAsReactComponent(type, title, attributes) {
var _initProps;
// assigning into an array to define toString function on it
var initProps = (_initProps = {
key: title
}, _initProps[HELMET_ATTRIBUTE] = true, _initProps);
var props = convertElementAttributestoReactProps(attributes, initProps);
return [React.createElement(TAG_NAMES.TITLE, props, title)];
};
var generateTagsAsReactComponent = function generateTagsAsReactComponent(type, tags) {
return tags.map(function (tag, i) {
var _mappedTag;
var mappedTag = (_mappedTag = {
key: i
}, _mappedTag[HELMET_ATTRIBUTE] = true, _mappedTag);
Object.keys(tag).forEach(function (attribute) {
var mappedAttribute = REACT_TAG_MAP[attribute] || attribute;
if (mappedAttribute === TAG_PROPERTIES.INNER_HTML || mappedAttribute === TAG_PROPERTIES.CSS_TEXT) {
var content = tag.innerHTML || tag.cssText;
mappedTag.dangerouslySetInnerHTML = { __html: content };
} else {
mappedTag[mappedAttribute] = tag[attribute];
}
});
return React.createElement(type, mappedTag);
});
};
var getMethodsForTag = function getMethodsForTag(type, tags, encode) {
switch (type) {
case TAG_NAMES.TITLE:
return {
toComponent: function toComponent() {
return generateTitleAsReactComponent(type, tags.title, tags.titleAttributes, encode);
},
toString: function toString() {
return generateTitleAsString(type, tags.title, tags.titleAttributes, encode);
}
};
case ATTRIBUTE_NAMES.BODY:
case ATTRIBUTE_NAMES.HTML:
return {
toComponent: function toComponent() {
return convertElementAttributestoReactProps(tags);
},
toString: function toString() {
return generateElementAttributesAsString(tags);
}
};
default:
return {
toComponent: function toComponent() {
return generateTagsAsReactComponent(type, tags);
},
toString: function toString() {
return generateTagsAsString(type, tags, encode);
}
};
}
};
var mapStateOnServer = function mapStateOnServer(_ref) {
var baseTag = _ref.baseTag,
bodyAttributes = _ref.bodyAttributes,
encode = _ref.encode,
htmlAttributes = _ref.htmlAttributes,
linkTags = _ref.linkTags,
metaTags = _ref.metaTags,
noscriptTags = _ref.noscriptTags,
scriptTags = _ref.scriptTags,
styleTags = _ref.styleTags,
_ref$title = _ref.title,
title = _ref$title === undefined ? "" : _ref$title,
titleAttributes = _ref.titleAttributes;
return {
base: getMethodsForTag(TAG_NAMES.BASE, baseTag, encode),
bodyAttributes: getMethodsForTag(ATTRIBUTE_NAMES.BODY, bodyAttributes, encode),
htmlAttributes: getMethodsForTag(ATTRIBUTE_NAMES.HTML, htmlAttributes, encode),
link: getMethodsForTag(TAG_NAMES.LINK, linkTags, encode),
meta: getMethodsForTag(TAG_NAMES.META, metaTags, encode),
noscript: getMethodsForTag(TAG_NAMES.NOSCRIPT, noscriptTags, encode),
script: getMethodsForTag(TAG_NAMES.SCRIPT, scriptTags, encode),
style: getMethodsForTag(TAG_NAMES.STYLE, styleTags, encode),
title: getMethodsForTag(TAG_NAMES.TITLE, { title: title, titleAttributes: titleAttributes }, encode)
};
};
var Helmet = function Helmet(Component) {
var _class, _temp;
return _temp = _class = function (_React$Component) {
inherits(HelmetWrapper, _React$Component);
function HelmetWrapper() {
classCallCheck(this, HelmetWrapper);
return possibleConstructorReturn(this, _React$Component.apply(this, arguments));
}
HelmetWrapper.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
return !isEqual(this.props, nextProps);
};
HelmetWrapper.prototype.mapNestedChildrenToProps = function mapNestedChildrenToProps(child, nestedChildren) {
if (!nestedChildren) {
return null;
}
switch (child.type) {
case TAG_NAMES.SCRIPT:
case TAG_NAMES.NOSCRIPT:
return {
innerHTML: nestedChildren
};
case TAG_NAMES.STYLE:
return {
cssText: nestedChildren
};
}
throw new Error("<" + child.type + " /> elements are self-closing and can not contain children. Refer to our API for more information.");
};
HelmetWrapper.prototype.flattenArrayTypeChildren = function flattenArrayTypeChildren(_ref) {
var _babelHelpers$extends;
var child = _ref.child,
arrayTypeChildren = _ref.arrayTypeChildren,
newChildProps = _ref.newChildProps,
nestedChildren = _ref.nestedChildren;
return _extends({}, arrayTypeChildren, (_babelHelpers$extends = {}, _babelHelpers$extends[child.type] = [].concat(arrayTypeChildren[child.type] || [], [_extends({}, newChildProps, this.mapNestedChildrenToProps(child, nestedChildren))]), _babelHelpers$extends));
};
HelmetWrapper.prototype.mapObjectTypeChildren = function mapObjectTypeChildren(_ref2) {
var _babelHelpers$extends2, _babelHelpers$extends3;
var child = _ref2.child,
newProps = _ref2.newProps,
newChildProps = _ref2.newChildProps,
nestedChildren = _ref2.nestedChildren;
switch (child.type) {
case TAG_NAMES.TITLE:
return _extends({}, newProps, (_babelHelpers$extends2 = {}, _babelHelpers$extends2[child.type] = nestedChildren, _babelHelpers$extends2.titleAttributes = _extends({}, newChildProps), _babelHelpers$extends2));
case TAG_NAMES.BODY:
return _extends({}, newProps, {
bodyAttributes: _extends({}, newChildProps)
});
case TAG_NAMES.HTML:
return _extends({}, newProps, {
htmlAttributes: _extends({}, newChildProps)
});
}
return _extends({}, newProps, (_babelHelpers$extends3 = {}, _babelHelpers$extends3[child.type] = _extends({}, newChildProps), _babelHelpers$extends3));
};
HelmetWrapper.prototype.mapArrayTypeChildrenToProps = function mapArrayTypeChildrenToProps(arrayTypeChildren, newProps) {
var newFlattenedProps = _extends({}, newProps);
Object.keys(arrayTypeChildren).forEach(function (arrayChildName) {
var _babelHelpers$extends4;
newFlattenedProps = _extends({}, newFlattenedProps, (_babelHelpers$extends4 = {}, _babelHelpers$extends4[arrayChildName] = arrayTypeChildren[arrayChildName], _babelHelpers$extends4));
});
return newFlattenedProps;
};
HelmetWrapper.prototype.warnOnInvalidChildren = function warnOnInvalidChildren(child, nestedChildren) {
if (process.env.NODE_ENV !== "production") {
if (!VALID_TAG_NAMES.some(function (name) {
return child.type === name;
})) {
if (typeof child.type === "function") {
return warn("You may be attempting to nest <Helmet> components within each other, which is not allowed. Refer to our API for more information.");
}
return warn("Only elements types " + VALID_TAG_NAMES.join(", ") + " are allowed. Helmet does not support rendering <" + child.type + "> elements. Refer to our API for more information.");
}
if (nestedChildren && typeof nestedChildren !== "string" && (!Array.isArray(nestedChildren) || nestedChildren.some(function (nestedChild) {
return typeof nestedChild !== "string";
}))) {
throw new Error("Helmet expects a string as a child of <" + child.type + ">. Did you forget to wrap your children in braces? ( <" + child.type + ">{``}</" + child.type + "> ) Refer to our API for more information.");
}
}
return true;
};
HelmetWrapper.prototype.mapChildrenToProps = function mapChildrenToProps(children, newProps) {
var _this2 = this;
var arrayTypeChildren = {};
React.Children.forEach(children, function (child) {
if (!child || !child.props) {
return;
}
var _child$props = child.props,
nestedChildren = _child$props.children,
childProps = objectWithoutProperties(_child$props, ["children"]);
var newChildProps = convertReactPropstoHtmlAttributes(childProps);
_this2.warnOnInvalidChildren(child, nestedChildren);
switch (child.type) {
case TAG_NAMES.LINK:
case TAG_NAMES.META:
case TAG_NAMES.NOSCRIPT:
case TAG_NAMES.SCRIPT:
case TAG_NAMES.STYLE:
arrayTypeChildren = _this2.flattenArrayTypeChildren({
child: child,
arrayTypeChildren: arrayTypeChildren,
newChildProps: newChildProps,
nestedChildren: nestedChildren
});
break;
default:
newProps = _this2.mapObjectTypeChildren({
child: child,
newProps: newProps,
newChildProps: newChildProps,
nestedChildren: nestedChildren
});
break;
}
});
newProps = this.mapArrayTypeChildrenToProps(arrayTypeChildren, newProps);
return newProps;
};
HelmetWrapper.prototype.render = function render() {
var _props = this.props,
children = _props.children,
props = objectWithoutProperties(_props, ["children"]);
var newProps = _extends({}, props);
if (children) {
newProps = this.mapChildrenToProps(children, newProps);
}
return React.createElement(Component, newProps);
};
createClass(HelmetWrapper, null, [{
key: "canUseDOM",
// Component.peek comes from react-side-effect:
// For testing, you may use a static peek() method available on the returned component.
// It lets you get the current state without resetting the mounted instance stack.
// Dont use it for anything other than testing.
/**
* @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"
*/
set: function set$$1(canUseDOM) {
Component.canUseDOM = canUseDOM;
}
}]);
return HelmetWrapper;
}(React.Component), _class.propTypes = {
base: PropTypes.object,
bodyAttributes: PropTypes.object,
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),
defaultTitle: PropTypes.string,
defer: PropTypes.bool,
encodeSpecialCharacters: PropTypes.bool,
htmlAttributes: PropTypes.object,
link: PropTypes.arrayOf(PropTypes.object),
meta: PropTypes.arrayOf(PropTypes.object),
noscript: PropTypes.arrayOf(PropTypes.object),
onChangeClientState: PropTypes.func,
script: PropTypes.arrayOf(PropTypes.object),
style: PropTypes.arrayOf(PropTypes.object),
title: PropTypes.string,
titleAttributes: PropTypes.object,
titleTemplate: PropTypes.string
}, _class.defaultProps = {
defer: true,
encodeSpecialCharacters: true
}, _class.peek = Component.peek, _class.rewind = function () {
var mappedState = Component.rewind();
if (!mappedState) {
// provide fallback if mappedState is undefined
mappedState = mapStateOnServer({
baseTag: [],
bodyAttributes: {},
encodeSpecialCharacters: true,
htmlAttributes: {},
linkTags: [],
metaTags: [],
noscriptTags: [],
scriptTags: [],
styleTags: [],
title: "",
titleAttributes: {}
});
}
return mappedState;
}, _temp;
};
var NullComponent = function NullComponent() {
return null;
};
var HelmetSideEffects = withSideEffect(reducePropsToState, handleClientStateChange, mapStateOnServer)(NullComponent);
var HelmetExport = Helmet(HelmetSideEffects);
HelmetExport.renderStatic = HelmetExport.rewind;
exports.Helmet = HelmetExport;
exports.default = HelmetExport;

View File

@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2018 Formidable Labs
Copyright (c) 2017 Evgeny Poberezkin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,165 @@
[![React Fast Compare — Formidable, We build the modern web](https://raw.githubusercontent.com/FormidableLabs/react-fast-compare/master/react-fast-compare-Hero.png)](https://formidable.com/open-source/)
[![Downloads][downloads_img]][npm_site]
[![Bundle Size][bundle_img]](#bundle-size)
[![GH Actions Status][actions_img]][actions_site]
[![Coverage Status][cov_img]][cov_site]
[![npm version][npm_img]][npm_site]
[![Maintenance Status][maintenance_img]](#maintenance-status)
The fastest deep equal comparison for React. Very quick general-purpose deep
comparison, too. Great for `React.memo` and `shouldComponentUpdate`.
This is a fork of the brilliant
[fast-deep-equal](https://github.com/epoberezkin/fast-deep-equal) with some
extra handling for React.
![benchmark chart](https://raw.githubusercontent.com/FormidableLabs/react-fast-compare/master/assets/benchmarking.png "benchmarking chart")
(Check out the [benchmarking details](#benchmarking-this-library).)
## Install
```sh
$ yarn add react-fast-compare
# or
$ npm install react-fast-compare
```
## Highlights
- ES5 compatible; works in node.js (0.10+) and browsers (IE9+)
- deeply compares any value (besides objects with circular references)
- handles React-specific circular references, like elements
- checks equality Date and RegExp objects
- should as fast as [fast-deep-equal](https://github.com/epoberezkin/fast-deep-equal) via a single unified library, and with added guardrails for circular references.
- small: under 660 bytes minified+gzipped
## Usage
```jsx
const isEqual = require("react-fast-compare");
// general usage
console.log(isEqual({ foo: "bar" }, { foo: "bar" })); // true
// React.memo
// only re-render ExpensiveComponent when the props have deeply changed
const DeepMemoComponent = React.memo(ExpensiveComponent, isEqual);
// React.Component shouldComponentUpdate
// only re-render AnotherExpensiveComponent when the props have deeply changed
class AnotherExpensiveComponent extends React.Component {
shouldComponentUpdate(nextProps) {
return !isEqual(this.props, nextProps);
}
render() {
// ...
}
}
```
## Do I Need `React.memo` (or `shouldComponentUpdate`)?
> What's faster than a really fast deep comparison? No deep comparison at all.
—This Readme
Deep checks in `React.memo` or a `shouldComponentUpdate` should not be used blindly.
First, see if the default
[React.memo](https://reactjs.org/docs/react-api.html#reactmemo) or
[PureComponent](https://reactjs.org/docs/react-api.html#reactpurecomponent)
will work for you. If it won't (if you need deep checks), it's wise to make
sure you've correctly indentified the bottleneck in your application by
[profiling the performance](https://reactjs.org/docs/optimizing-performance.html#profiling-components-with-the-chrome-performance-tab).
After you've determined that you _do_ need deep equality checks and you've
identified the minimum number of places to apply them, then this library may
be for you!
## Benchmarking this Library
The absolute values are much less important than the relative differences
between packages.
Benchmarking source can be found
[here](https://github.com/FormidableLabs/react-fast-compare/blob/master/benchmark/index.js).
Each "operation" consists of running all relevant tests. The React benchmark
uses both the generic tests and the react tests; these runs will be slower
simply because there are more tests in each operation.
The results below are from a local test on a laptop _(stats last updated 6/2/2020)_:
### Generic Data
```
react-fast-compare x 177,600 ops/sec ±1.73% (92 runs sampled)
fast-deep-equal x 184,211 ops/sec ±0.65% (87 runs sampled)
lodash.isEqual x 39,826 ops/sec ±1.32% (86 runs sampled)
nano-equal x 176,023 ops/sec ±0.89% (92 runs sampled)
shallow-equal-fuzzy x 146,355 ops/sec ±0.64% (89 runs sampled)
fastest: fast-deep-equal
```
`react-fast-compare` and `fast-deep-equal` should be the same speed for these
tests; any difference is just noise. `react-fast-compare` won't be faster than
`fast-deep-equal`, because it's based on it.
### React and Generic Data
```
react-fast-compare x 86,392 ops/sec ±0.70% (93 runs sampled)
fast-deep-equal x 85,567 ops/sec ±0.95% (92 runs sampled)
lodash.isEqual x 7,369 ops/sec ±1.78% (84 runs sampled)
fastest: react-fast-compare,fast-deep-equal
```
Two of these packages cannot handle comparing React elements, because they
contain circular reference: `nano-equal` and `shallow-equal-fuzzy`.
### Running Benchmarks
```sh
$ yarn install
$ yarn run benchmark
```
## Differences between this library and `fast-deep-equal`
`react-fast-compare` is based on `fast-deep-equal`, with some additions:
- `react-fast-compare` has `try`/`catch` guardrails for stack overflows from undetected (non-React) circular references.
- `react-fast-compare` has a _single_ unified entry point for all uses. No matter what your target application is, `import equal from 'react-fast-compare'` just works. `fast-deep-equal` has multiple entry points for different use cases.
This version of `react-fast-compare` tracks `fast-deep-equal@3.1.1`.
## Bundle Size
There are a variety of ways to calculate bundle size for JavaScript code.
You can see our size test code in the `compress` script in
[`package.json`](https://github.com/FormidableLabs/react-fast-compare/blob/master/package.json).
[Bundlephobia's calculation](https://bundlephobia.com/result?p=react-fast-compare) is slightly higher,
as they [do not mangle during minification](https://github.com/pastelsky/package-build-stats/blob/v6.1.1/src/getDependencySizeTree.js#L139).
## License
[MIT](https://github.com/FormidableLabs/react-fast-compare/blob/readme/LICENSE)
## Contributing
Please see our [contributions guide](./CONTRIBUTING.md).
## Maintenance Status
**Active:** Formidable is actively working on this project, and we expect to continue for work for the foreseeable future. Bug reports, feature requests and pull requests are welcome.
[actions_img]: https://github.com/FormidableLabs/react-fast-compare/actions/workflows/ci.yml/badge.svg
[actions_site]: https://github.com/formidablelabs/react-fast-compare/actions/workflows/ci.yml
[cov_img]: https://codecov.io/gh/FormidableLabs/react-fast-compare/branch/master/graph/badge.svg
[cov_site]: https://codecov.io/gh/FormidableLabs/react-fast-compare
[npm_img]: https://badge.fury.io/js/react-fast-compare.svg
[npm_site]: http://badge.fury.io/js/react-fast-compare
[appveyor_img]: https://ci.appveyor.com/api/projects/status/github/formidablelabs/react-fast-compare?branch=master&svg=true
[appveyor_site]: https://ci.appveyor.com/project/FormidableLabs/react-fast-compare
[bundle_img]: https://img.shields.io/badge/minzipped%20size-656%20B-flatgreen.svg
[downloads_img]: https://img.shields.io/npm/dm/react-fast-compare.svg
[maintenance_img]: https://img.shields.io/badge/maintenance-active-flatgreen.svg

View File

@@ -0,0 +1,2 @@
declare function isEqual<A = any, B = any>(a: A, b: B): boolean;
export = isEqual;

View File

@@ -0,0 +1,139 @@
/* global Map:readonly, Set:readonly, ArrayBuffer:readonly */
var hasElementType = typeof Element !== 'undefined';
var hasMap = typeof Map === 'function';
var hasSet = typeof Set === 'function';
var hasArrayBuffer = typeof ArrayBuffer === 'function' && !!ArrayBuffer.isView;
// Note: We **don't** need `envHasBigInt64Array` in fde es6/index.js
function equal(a, b) {
// START: fast-deep-equal es6/index.js 3.1.3
if (a === b) return true;
if (a && b && typeof a == 'object' && typeof b == 'object') {
if (a.constructor !== b.constructor) return false;
var length, i, keys;
if (Array.isArray(a)) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;)
if (!equal(a[i], b[i])) return false;
return true;
}
// START: Modifications:
// 1. Extra `has<Type> &&` helpers in initial condition allow es6 code
// to co-exist with es5.
// 2. Replace `for of` with es5 compliant iteration using `for`.
// Basically, take:
//
// ```js
// for (i of a.entries())
// if (!b.has(i[0])) return false;
// ```
//
// ... and convert to:
//
// ```js
// it = a.entries();
// while (!(i = it.next()).done)
// if (!b.has(i.value[0])) return false;
// ```
//
// **Note**: `i` access switches to `i.value`.
var it;
if (hasMap && (a instanceof Map) && (b instanceof Map)) {
if (a.size !== b.size) return false;
it = a.entries();
while (!(i = it.next()).done)
if (!b.has(i.value[0])) return false;
it = a.entries();
while (!(i = it.next()).done)
if (!equal(i.value[1], b.get(i.value[0]))) return false;
return true;
}
if (hasSet && (a instanceof Set) && (b instanceof Set)) {
if (a.size !== b.size) return false;
it = a.entries();
while (!(i = it.next()).done)
if (!b.has(i.value[0])) return false;
return true;
}
// END: Modifications
if (hasArrayBuffer && ArrayBuffer.isView(a) && ArrayBuffer.isView(b)) {
length = a.length;
if (length != b.length) return false;
for (i = length; i-- !== 0;)
if (a[i] !== b[i]) return false;
return true;
}
if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
// START: Modifications:
// Apply guards for `Object.create(null)` handling. See:
// - https://github.com/FormidableLabs/react-fast-compare/issues/64
// - https://github.com/epoberezkin/fast-deep-equal/issues/49
if (a.valueOf !== Object.prototype.valueOf && typeof a.valueOf === 'function' && typeof b.valueOf === 'function') return a.valueOf() === b.valueOf();
if (a.toString !== Object.prototype.toString && typeof a.toString === 'function' && typeof b.toString === 'function') return a.toString() === b.toString();
// END: Modifications
keys = Object.keys(a);
length = keys.length;
if (length !== Object.keys(b).length) return false;
for (i = length; i-- !== 0;)
if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
// END: fast-deep-equal
// START: react-fast-compare
// custom handling for DOM elements
if (hasElementType && a instanceof Element) return false;
// custom handling for React/Preact
for (i = length; i-- !== 0;) {
if ((keys[i] === '_owner' || keys[i] === '__v' || keys[i] === '__o') && a.$$typeof) {
// React-specific: avoid traversing React elements' _owner
// Preact-specific: avoid traversing Preact elements' __v and __o
// __v = $_original / $_vnode
// __o = $_owner
// These properties contain circular references and are not needed when
// comparing the actual elements (and not their owners)
// .$$typeof and ._store on just reasonable markers of elements
continue;
}
// all other properties should be traversed as usual
if (!equal(a[keys[i]], b[keys[i]])) return false;
}
// END: react-fast-compare
// START: fast-deep-equal
return true;
}
return a !== a && b !== b;
}
// end fast-deep-equal
module.exports = function isEqual(a, b) {
try {
return equal(a, b);
} catch (error) {
if (((error.message || '').match(/stack|recursion/i))) {
// warn on circular references, don't crash
// browsers give this different errors name and messages:
// chrome/safari: "RangeError", "Maximum call stack size exceeded"
// firefox: "InternalError", too much recursion"
// edge: "Error", "Out of stack space"
console.warn('react-fast-compare cannot handle circular refs');
return false;
}
// some other error. we should definitely know about these
throw error;
}
};

View File

@@ -0,0 +1,105 @@
{
"name": "react-fast-compare",
"version": "3.2.2",
"description": "Fastest deep equal comparison for React. Great for React.memo & shouldComponentUpdate. Also really fast general-purpose deep comparison.",
"main": "index.js",
"typings": "index.d.ts",
"scripts": {
"preversion": "yarn test",
"benchmark": "node benchmark",
"eslint": "eslint \"*.js\" benchmark test",
"tslint": "eslint test/typescript/*.tsx",
"test-browser": "karma start test/browser/karma.conf.js",
"test-node": "mocha \"test/node/*.spec.js\"",
"test-node-cov": "nyc mocha \"test/node/*.spec.js\"",
"test-ts-usage": "tsc --esModuleInterop --jsx react --noEmit test/typescript/sample-react-redux-usage.tsx test/typescript/sample-usage.tsx",
"test-ts-defs": "tsc --target ES5 index.d.ts",
"test": "builder concurrent --buffer eslint tslint test-ts-usage test-ts-defs test-node-cov test-browser",
"compress": "terser --compress --mangle=\"toplevel:true\" -- index.js",
"size-min-gz": "yarn -s compress | gzip -9 | wc -c"
},
"repository": {
"type": "git",
"url": "https://github.com/FormidableLabs/react-fast-compare"
},
"keywords": [
"fast",
"equal",
"react",
"compare",
"shouldComponentUpdate",
"deep-equal"
],
"author": "Chris Bolin",
"license": "MIT",
"bugs": {
"url": "https://github.com/FormidableLabs/react-fast-compare/issues"
},
"homepage": "https://github.com/FormidableLabs/react-fast-compare",
"devDependencies": {
"@babel/core": "^7.21.0",
"@babel/preset-env": "^7.20.2",
"@changesets/cli": "^2.26.1",
"@svitejs/changesets-changelog-github-compact": "^0.1.1",
"@testing-library/dom": "^9.0.1",
"@testing-library/preact": "^3.2.3",
"@types/node": "^18.15.0",
"@types/react": "^16.9.35",
"@types/react-dom": "^16.9.8",
"@types/react-redux": "^7.1.25",
"@typescript-eslint/parser": "^5.54.1",
"assert": "^2.0.0",
"babel-loader": "^9.1.2",
"benchmark": "^2.1.4",
"builder": "^5.0.0",
"codecov": "^3.8.3",
"core-js": "^3.29.0",
"eslint": "^8.35.0",
"eslint-plugin-react": "^7.32.2",
"fast-deep-equal": "3.1.3",
"fast-deep-equal-git": "epoberezkin/fast-deep-equal#v3.1.3",
"jsdom": "^21.1.0",
"jsdom-global": "^3.0.2",
"karma": "^6.4.1",
"karma-chrome-launcher": "^3.1.1",
"karma-firefox-launcher": "^2.1.2",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"karma-safari-launcher": "^1.0.0",
"karma-webpack": "^5.0.0",
"lodash": "^4.17.10",
"mocha": "^10.2.0",
"nano-equal": "^2.0.2",
"nyc": "^15.1.0",
"preact": "^10.13.1",
"process": "^0.11.10",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.5",
"react-test-renderer": "^18.2.0",
"redux": "^4.2.1",
"shallow-equal-fuzzy": "0.0.2",
"sinon": "^15.0.1",
"terser": "^5.16.6",
"typescript": "^4.9.5",
"webpack": "^5.76.0"
},
"publishConfig": {
"provenance": true
},
"nyc": {
"exclude": [
"**/test/**",
"node_modules"
],
"reporter": [
"lcov",
"text-summary"
]
},
"files": [
"index.js",
"index.d.ts"
],
"types": "index.d.ts"
}

103
server/node_modules/react-helmet/package.json generated vendored Normal file
View File

@@ -0,0 +1,103 @@
{
"name": "react-helmet",
"description": "A document head manager for React",
"version": "6.1.0",
"main": "./lib/Helmet.js",
"module": "./es/Helmet.js",
"author": "NFL <engineers@nfl.com>",
"contributors": [
"Chris Welch <chris.welch@nfl.com>",
"Robert dela Victoria <robert.delavictoria@nfl.com>"
],
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/nfl/react-helmet"
},
"keywords": [
"react-helmet",
"nfl",
"react",
"document",
"head",
"title",
"meta",
"link",
"script",
"base",
"noscript",
"style"
],
"peerDependencies": {
"react": ">=16.3.0"
},
"dependencies": {
"object-assign": "^4.1.1",
"prop-types": "^15.7.2",
"react-fast-compare": "^3.1.1",
"react-side-effect": "^2.1.0"
},
"devDependencies": {
"babel-core": "^6.24.0",
"babel-eslint": "^9.0.0",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-istanbul": "^4.0.0",
"babel-plugin-transform-class-properties": "^6.23.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-env": "^1.2.2",
"babel-preset-react": "^6.23.0",
"chai": "^3.5.0",
"codecov": "^3.6.5",
"conventional-changelog-cli": "^1.3.1",
"cz-conventional-changelog": "^2.0.0",
"eslint": "^3.18.0",
"eslint-config-nfl": "^11.1.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-mocha": "^4.9.0",
"eslint-plugin-prettier": "^2.1.2",
"eslint-plugin-react": "^6.10.2",
"istanbul": "^0.4.5",
"karma": "^1.5.0",
"karma-chai": "^0.1.0",
"karma-chai-sinon": "^0.1.5",
"karma-chrome-launcher": "^3.1.0",
"karma-coverage": "^1.1.1",
"karma-firefox-launcher": "^1.0.1",
"karma-html-reporter": "^0.2.7",
"karma-mocha": "^2.0.1",
"karma-rollup-preprocessor": "^6.1.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "^0.0.32",
"karma-tap-reporter": "^0.0.6",
"mocha": "^7.2.0",
"prettier": "^1.4.4",
"react": "16.13.1",
"react-dom": "16.13.1",
"rimraf": "^3.0.2",
"rollup": "^0.67.0",
"rollup-plugin-babel": "^3.0.7",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-replace": "^2.1.0",
"sinon": "^2.1.0",
"sinon-chai": "^2.8.0"
},
"scripts": {
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"clean": "rimraf lib coverage es",
"lint": "eslint --ignore-path .gitignore --fix -- .",
"test": "karma start karma.config.js",
"posttest": "istanbul report lcov text",
"pretest": "npm run clean && npm run lint",
"commit": "git-cz",
"build": "rollup -c",
"prepublish": "npm run build"
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}