mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 21:52:19 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
48
web/node_modules/react-lifecycles-compat/CHANGELOG.md
generated
vendored
Normal file
48
web/node_modules/react-lifecycles-compat/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
## [Unreleased]
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
Changes that have landed in master but are not yet released.
|
||||
Click to see more.
|
||||
</summary>
|
||||
</details>
|
||||
|
||||
## 3.0.4 (May 11, 2018)
|
||||
|
||||
Fixed shallow renderer regression (introduced in 3.0.3) that caused `setState` updater to fail due to incorrect `this`. ([#26](https://github.com/reactjs/react-lifecycles-compat/pull/26))
|
||||
|
||||
## 3.0.3 (May 9, 2018)
|
||||
|
||||
Fixed an edge case bug where a batched update containing both a `setState` updater and a parent re-render could result in dropped `state` updates. ([#24](https://github.com/reactjs/react-lifecycles-compat/pull/24))
|
||||
|
||||
## 3.0.2 (April 11, 2018)
|
||||
|
||||
Replaced an unintentional template literal to ensure broader browser compatibility. ([ce42fe4](https://github.com/reactjs/react-lifecycles-compat/commit/ce42fe426e6348fd221bb4fd1905e392ceb823a9))
|
||||
|
||||
## 3.0.1 (April 10, 2018)
|
||||
|
||||
Replaced a few unintentional `let` keywords with `var` to ensure broader browser compatibility. ([#17](https://github.com/reactjs/react-lifecycles-compat/pull/17))
|
||||
|
||||
## 3.0.0 (April 9, 2018)
|
||||
|
||||
Throw an error for any polyfilled component that mixes old lifecycles (`componentWillMount`, `componentWillReceiveProps`, or `componentWillUpdate`) and new lifecycles (`getDerivedStateFromProps` or `getSnapshotBeforeUpdate`) as React 16.3+ does not support this case and will not invoke the old lifecycles. This error ensures consistent behavior between React 16.3+ and older versions. ([#14](https://github.com/reactjs/react-lifecycles-compat/pull/14))
|
||||
|
||||
## 2.0.1 (April 9, 2018)
|
||||
|
||||
Add a DEV mode warning for any polyfilled component that mixes old lifecycles (`componentWillMount`, `componentWillReceiveProps`, or `componentWillUpdate`) and new lifecycles (`getDerivedStateFromProps` or `getSnapshotBeforeUpdate`) as React 16.3+ does not support this case and will not invoke the old lifecycles. This warning ensures consistent behavior between React 16.3+ and older versions. ([#15](https://github.com/reactjs/react-lifecycles-compat/pull/15))
|
||||
|
||||
## 2.0.0 (April 4, 2018)
|
||||
|
||||
Package uses a named export and includes an ES6 module build. ([#11](https://github.com/reactjs/react-lifecycles-compat/pull/11))
|
||||
|
||||
```js
|
||||
// 1.x (before)
|
||||
import polyfill from 'react-lifecycles-compat';
|
||||
|
||||
// 2.x (after)
|
||||
import {polyfill} from 'react-lifecycles-compat';
|
||||
```
|
||||
|
||||
## 1.1.4 (April 3, 2018)
|
||||
|
||||
Improved handling of falsy return values from polyfilled `getSnapshotBeforeUpdate()` lifecycle. [#12](https://github.com/reactjs/react-lifecycles-compat/pull/12)
|
21
web/node_modules/react-lifecycles-compat/LICENSE.md
generated
vendored
Normal file
21
web/node_modules/react-lifecycles-compat/LICENSE.md
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2013-present, Facebook, Inc.
|
||||
|
||||
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.
|
57
web/node_modules/react-lifecycles-compat/README.md
generated
vendored
Normal file
57
web/node_modules/react-lifecycles-compat/README.md
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
# react-lifecycles-compat
|
||||
|
||||
## What is this project?
|
||||
|
||||
React version 17 will deprecate several of the class component API lifecycles: `componentWillMount`, `componentWillReceiveProps`, and `componentWillUpdate`. (Read the [Update on Async rendering blog post](https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html) to learn more about why.) A couple of new lifecycles are also being added to better support [async rendering mode](https://reactjs.org/blog/2018/03/01/sneak-peek-beyond-react-16.html).
|
||||
|
||||
Typically, this type of change would require third party libraries to release a new major version in order to adhere to semver. However, the `react-lifecycles-compat` polyfill offers a way to use the new lifecycles with older versions of React as well (0.14.9+) so no breaking release is required. This enables shared libraries to support both older and newer versions of React simultaneously.
|
||||
|
||||
## How can I use the polyfill
|
||||
|
||||
First, install the polyfill from NPM:
|
||||
```sh
|
||||
# Yarn
|
||||
yarn add react-lifecycles-compat
|
||||
|
||||
# NPM
|
||||
npm install react-lifecycles-compat --save
|
||||
```
|
||||
|
||||
Next, update your component and replace any of the deprecated lifecycles with new ones introduced with React 16.3. (Refer to the React docs for [examples of how to use the new lifecycles](https://reactjs.org/blog/2018/03/27/update-on-async-rendering.html).)
|
||||
|
||||
Lastly, use the polyfill to make the new lifecycles work with older versions of React:
|
||||
```js
|
||||
import React from 'react';
|
||||
import {polyfill} from 'react-lifecycles-compat';
|
||||
|
||||
class ExampleComponent extends React.Component {
|
||||
static getDerivedStateFromProps(nextProps, prevState) {
|
||||
// Normally this method would only work for React 16.3 and newer,
|
||||
// But the polyfill will make it work for older versions also!
|
||||
}
|
||||
|
||||
getSnapshotBeforeUpdate(prevProps, prevState) {
|
||||
// Normally this method would only work for React 16.3 and newer,
|
||||
// But the polyfill will make it work for older versions also!
|
||||
}
|
||||
|
||||
// render() and other methods ...
|
||||
}
|
||||
|
||||
// Polyfill your component so the new lifecycles will work with older versions of React:
|
||||
polyfill(ExampleComponent);
|
||||
|
||||
export default ExampleComponent;
|
||||
```
|
||||
|
||||
## Which lifecycles are supported?
|
||||
|
||||
Currently, this polyfill supports [static `getDerivedStateFromProps`](https://reactjs.org/docs/react-component.html#static-getderivedstatefromprops) and [`getSnapshotBeforeUpdate`](https://reactjs.org/docs/react-component.html#getsnapshotbeforeupdate)- both introduced in version 16.3.
|
||||
|
||||
## Validation
|
||||
|
||||
Note that in order for the polyfill to work, none of the following lifecycles can be defined by your component: `componentWillMount`, `componentWillReceiveProps`, or `componentWillUpdate`.
|
||||
|
||||
Note also that if your component contains `getSnapshotBeforeUpdate`, `componentDidUpdate` must be defined as well.
|
||||
|
||||
An error will be thrown if any of the above conditions are not met.
|
39
web/node_modules/react-lifecycles-compat/package.json
generated
vendored
Normal file
39
web/node_modules/react-lifecycles-compat/package.json
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
{
|
||||
"name": "react-lifecycles-compat",
|
||||
"version": "3.0.4",
|
||||
"description": "Backwards compatibility polyfill for React class components",
|
||||
"main": "react-lifecycles-compat.cjs.js",
|
||||
"module": "react-lifecycles-compat.es.js",
|
||||
"license": "MIT",
|
||||
"repository": "reactjs/react-lifecycles-compat",
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"install:dependencies": "node install.js",
|
||||
"lint": "eslint index.js",
|
||||
"prepublish": "npm test",
|
||||
"pretest": "npm run install:dependencies && npm run build",
|
||||
"prettier": "prettier --write {index,test}.js",
|
||||
"test": "jest test.js"
|
||||
},
|
||||
"files": [
|
||||
"react-lifecycles-compat.cjs.js",
|
||||
"react-lifecycles-compat.es.js",
|
||||
"react-lifecycles-compat.js",
|
||||
"react-lifecycles-compat.min.js"
|
||||
],
|
||||
"devDependencies": {
|
||||
"camelcase": "^5.0.0",
|
||||
"chalk": "^2.3.0",
|
||||
"eslint": "^4.16.0",
|
||||
"eslint-config-es5": "^0.5.0",
|
||||
"jest": "^22.1.4",
|
||||
"jest-cli": "^22.1.4",
|
||||
"prettier": "^1.10.2",
|
||||
"rollup": "^0.57.1",
|
||||
"rollup-plugin-replace": "^2.0.0",
|
||||
"rollup-plugin-uglify": "^3.0.0"
|
||||
},
|
||||
"devEngines": {
|
||||
"node": "8.5 || 9.x"
|
||||
}
|
||||
}
|
162
web/node_modules/react-lifecycles-compat/react-lifecycles-compat.cjs.js
generated
vendored
Normal file
162
web/node_modules/react-lifecycles-compat/react-lifecycles-compat.cjs.js
generated
vendored
Normal file
|
@ -0,0 +1,162 @@
|
|||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function componentWillMount() {
|
||||
// Call this.constructor.gDSFP to support sub-classes.
|
||||
var state = this.constructor.getDerivedStateFromProps(this.props, this.state);
|
||||
if (state !== null && state !== undefined) {
|
||||
this.setState(state);
|
||||
}
|
||||
}
|
||||
|
||||
function componentWillReceiveProps(nextProps) {
|
||||
// Call this.constructor.gDSFP to support sub-classes.
|
||||
// Use the setState() updater to ensure state isn't stale in certain edge cases.
|
||||
function updater(prevState) {
|
||||
var state = this.constructor.getDerivedStateFromProps(nextProps, prevState);
|
||||
return state !== null && state !== undefined ? state : null;
|
||||
}
|
||||
// Binding "this" is important for shallow renderer support.
|
||||
this.setState(updater.bind(this));
|
||||
}
|
||||
|
||||
function componentWillUpdate(nextProps, nextState) {
|
||||
try {
|
||||
var prevProps = this.props;
|
||||
var prevState = this.state;
|
||||
this.props = nextProps;
|
||||
this.state = nextState;
|
||||
this.__reactInternalSnapshotFlag = true;
|
||||
this.__reactInternalSnapshot = this.getSnapshotBeforeUpdate(
|
||||
prevProps,
|
||||
prevState
|
||||
);
|
||||
} finally {
|
||||
this.props = prevProps;
|
||||
this.state = prevState;
|
||||
}
|
||||
}
|
||||
|
||||
// React may warn about cWM/cWRP/cWU methods being deprecated.
|
||||
// Add a flag to suppress these warnings for this special case.
|
||||
componentWillMount.__suppressDeprecationWarning = true;
|
||||
componentWillReceiveProps.__suppressDeprecationWarning = true;
|
||||
componentWillUpdate.__suppressDeprecationWarning = true;
|
||||
|
||||
function polyfill(Component) {
|
||||
var prototype = Component.prototype;
|
||||
|
||||
if (!prototype || !prototype.isReactComponent) {
|
||||
throw new Error('Can only polyfill class components');
|
||||
}
|
||||
|
||||
if (
|
||||
typeof Component.getDerivedStateFromProps !== 'function' &&
|
||||
typeof prototype.getSnapshotBeforeUpdate !== 'function'
|
||||
) {
|
||||
return Component;
|
||||
}
|
||||
|
||||
// If new component APIs are defined, "unsafe" lifecycles won't be called.
|
||||
// Error if any of these lifecycles are present,
|
||||
// Because they would work differently between older and newer (16.3+) versions of React.
|
||||
var foundWillMountName = null;
|
||||
var foundWillReceivePropsName = null;
|
||||
var foundWillUpdateName = null;
|
||||
if (typeof prototype.componentWillMount === 'function') {
|
||||
foundWillMountName = 'componentWillMount';
|
||||
} else if (typeof prototype.UNSAFE_componentWillMount === 'function') {
|
||||
foundWillMountName = 'UNSAFE_componentWillMount';
|
||||
}
|
||||
if (typeof prototype.componentWillReceiveProps === 'function') {
|
||||
foundWillReceivePropsName = 'componentWillReceiveProps';
|
||||
} else if (typeof prototype.UNSAFE_componentWillReceiveProps === 'function') {
|
||||
foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
|
||||
}
|
||||
if (typeof prototype.componentWillUpdate === 'function') {
|
||||
foundWillUpdateName = 'componentWillUpdate';
|
||||
} else if (typeof prototype.UNSAFE_componentWillUpdate === 'function') {
|
||||
foundWillUpdateName = 'UNSAFE_componentWillUpdate';
|
||||
}
|
||||
if (
|
||||
foundWillMountName !== null ||
|
||||
foundWillReceivePropsName !== null ||
|
||||
foundWillUpdateName !== null
|
||||
) {
|
||||
var componentName = Component.displayName || Component.name;
|
||||
var newApiName =
|
||||
typeof Component.getDerivedStateFromProps === 'function'
|
||||
? 'getDerivedStateFromProps()'
|
||||
: 'getSnapshotBeforeUpdate()';
|
||||
|
||||
throw Error(
|
||||
'Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' +
|
||||
componentName +
|
||||
' uses ' +
|
||||
newApiName +
|
||||
' but also contains the following legacy lifecycles:' +
|
||||
(foundWillMountName !== null ? '\n ' + foundWillMountName : '') +
|
||||
(foundWillReceivePropsName !== null
|
||||
? '\n ' + foundWillReceivePropsName
|
||||
: '') +
|
||||
(foundWillUpdateName !== null ? '\n ' + foundWillUpdateName : '') +
|
||||
'\n\nThe above lifecycles should be removed. Learn more about this warning here:\n' +
|
||||
'https://fb.me/react-async-component-lifecycle-hooks'
|
||||
);
|
||||
}
|
||||
|
||||
// React <= 16.2 does not support static getDerivedStateFromProps.
|
||||
// As a workaround, use cWM and cWRP to invoke the new static lifecycle.
|
||||
// Newer versions of React will ignore these lifecycles if gDSFP exists.
|
||||
if (typeof Component.getDerivedStateFromProps === 'function') {
|
||||
prototype.componentWillMount = componentWillMount;
|
||||
prototype.componentWillReceiveProps = componentWillReceiveProps;
|
||||
}
|
||||
|
||||
// React <= 16.2 does not support getSnapshotBeforeUpdate.
|
||||
// As a workaround, use cWU to invoke the new lifecycle.
|
||||
// Newer versions of React will ignore that lifecycle if gSBU exists.
|
||||
if (typeof prototype.getSnapshotBeforeUpdate === 'function') {
|
||||
if (typeof prototype.componentDidUpdate !== 'function') {
|
||||
throw new Error(
|
||||
'Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype'
|
||||
);
|
||||
}
|
||||
|
||||
prototype.componentWillUpdate = componentWillUpdate;
|
||||
|
||||
var componentDidUpdate = prototype.componentDidUpdate;
|
||||
|
||||
prototype.componentDidUpdate = function componentDidUpdatePolyfill(
|
||||
prevProps,
|
||||
prevState,
|
||||
maybeSnapshot
|
||||
) {
|
||||
// 16.3+ will not execute our will-update method;
|
||||
// It will pass a snapshot value to did-update though.
|
||||
// Older versions will require our polyfilled will-update value.
|
||||
// We need to handle both cases, but can't just check for the presence of "maybeSnapshot",
|
||||
// Because for <= 15.x versions this might be a "prevContext" object.
|
||||
// We also can't just check "__reactInternalSnapshot",
|
||||
// Because get-snapshot might return a falsy value.
|
||||
// So check for the explicit __reactInternalSnapshotFlag flag to determine behavior.
|
||||
var snapshot = this.__reactInternalSnapshotFlag
|
||||
? this.__reactInternalSnapshot
|
||||
: maybeSnapshot;
|
||||
|
||||
componentDidUpdate.call(this, prevProps, prevState, snapshot);
|
||||
};
|
||||
}
|
||||
|
||||
return Component;
|
||||
}
|
||||
|
||||
exports.polyfill = polyfill;
|
158
web/node_modules/react-lifecycles-compat/react-lifecycles-compat.es.js
generated
vendored
Normal file
158
web/node_modules/react-lifecycles-compat/react-lifecycles-compat.es.js
generated
vendored
Normal file
|
@ -0,0 +1,158 @@
|
|||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function componentWillMount() {
|
||||
// Call this.constructor.gDSFP to support sub-classes.
|
||||
var state = this.constructor.getDerivedStateFromProps(this.props, this.state);
|
||||
if (state !== null && state !== undefined) {
|
||||
this.setState(state);
|
||||
}
|
||||
}
|
||||
|
||||
function componentWillReceiveProps(nextProps) {
|
||||
// Call this.constructor.gDSFP to support sub-classes.
|
||||
// Use the setState() updater to ensure state isn't stale in certain edge cases.
|
||||
function updater(prevState) {
|
||||
var state = this.constructor.getDerivedStateFromProps(nextProps, prevState);
|
||||
return state !== null && state !== undefined ? state : null;
|
||||
}
|
||||
// Binding "this" is important for shallow renderer support.
|
||||
this.setState(updater.bind(this));
|
||||
}
|
||||
|
||||
function componentWillUpdate(nextProps, nextState) {
|
||||
try {
|
||||
var prevProps = this.props;
|
||||
var prevState = this.state;
|
||||
this.props = nextProps;
|
||||
this.state = nextState;
|
||||
this.__reactInternalSnapshotFlag = true;
|
||||
this.__reactInternalSnapshot = this.getSnapshotBeforeUpdate(
|
||||
prevProps,
|
||||
prevState
|
||||
);
|
||||
} finally {
|
||||
this.props = prevProps;
|
||||
this.state = prevState;
|
||||
}
|
||||
}
|
||||
|
||||
// React may warn about cWM/cWRP/cWU methods being deprecated.
|
||||
// Add a flag to suppress these warnings for this special case.
|
||||
componentWillMount.__suppressDeprecationWarning = true;
|
||||
componentWillReceiveProps.__suppressDeprecationWarning = true;
|
||||
componentWillUpdate.__suppressDeprecationWarning = true;
|
||||
|
||||
function polyfill(Component) {
|
||||
var prototype = Component.prototype;
|
||||
|
||||
if (!prototype || !prototype.isReactComponent) {
|
||||
throw new Error('Can only polyfill class components');
|
||||
}
|
||||
|
||||
if (
|
||||
typeof Component.getDerivedStateFromProps !== 'function' &&
|
||||
typeof prototype.getSnapshotBeforeUpdate !== 'function'
|
||||
) {
|
||||
return Component;
|
||||
}
|
||||
|
||||
// If new component APIs are defined, "unsafe" lifecycles won't be called.
|
||||
// Error if any of these lifecycles are present,
|
||||
// Because they would work differently between older and newer (16.3+) versions of React.
|
||||
var foundWillMountName = null;
|
||||
var foundWillReceivePropsName = null;
|
||||
var foundWillUpdateName = null;
|
||||
if (typeof prototype.componentWillMount === 'function') {
|
||||
foundWillMountName = 'componentWillMount';
|
||||
} else if (typeof prototype.UNSAFE_componentWillMount === 'function') {
|
||||
foundWillMountName = 'UNSAFE_componentWillMount';
|
||||
}
|
||||
if (typeof prototype.componentWillReceiveProps === 'function') {
|
||||
foundWillReceivePropsName = 'componentWillReceiveProps';
|
||||
} else if (typeof prototype.UNSAFE_componentWillReceiveProps === 'function') {
|
||||
foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
|
||||
}
|
||||
if (typeof prototype.componentWillUpdate === 'function') {
|
||||
foundWillUpdateName = 'componentWillUpdate';
|
||||
} else if (typeof prototype.UNSAFE_componentWillUpdate === 'function') {
|
||||
foundWillUpdateName = 'UNSAFE_componentWillUpdate';
|
||||
}
|
||||
if (
|
||||
foundWillMountName !== null ||
|
||||
foundWillReceivePropsName !== null ||
|
||||
foundWillUpdateName !== null
|
||||
) {
|
||||
var componentName = Component.displayName || Component.name;
|
||||
var newApiName =
|
||||
typeof Component.getDerivedStateFromProps === 'function'
|
||||
? 'getDerivedStateFromProps()'
|
||||
: 'getSnapshotBeforeUpdate()';
|
||||
|
||||
throw Error(
|
||||
'Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' +
|
||||
componentName +
|
||||
' uses ' +
|
||||
newApiName +
|
||||
' but also contains the following legacy lifecycles:' +
|
||||
(foundWillMountName !== null ? '\n ' + foundWillMountName : '') +
|
||||
(foundWillReceivePropsName !== null
|
||||
? '\n ' + foundWillReceivePropsName
|
||||
: '') +
|
||||
(foundWillUpdateName !== null ? '\n ' + foundWillUpdateName : '') +
|
||||
'\n\nThe above lifecycles should be removed. Learn more about this warning here:\n' +
|
||||
'https://fb.me/react-async-component-lifecycle-hooks'
|
||||
);
|
||||
}
|
||||
|
||||
// React <= 16.2 does not support static getDerivedStateFromProps.
|
||||
// As a workaround, use cWM and cWRP to invoke the new static lifecycle.
|
||||
// Newer versions of React will ignore these lifecycles if gDSFP exists.
|
||||
if (typeof Component.getDerivedStateFromProps === 'function') {
|
||||
prototype.componentWillMount = componentWillMount;
|
||||
prototype.componentWillReceiveProps = componentWillReceiveProps;
|
||||
}
|
||||
|
||||
// React <= 16.2 does not support getSnapshotBeforeUpdate.
|
||||
// As a workaround, use cWU to invoke the new lifecycle.
|
||||
// Newer versions of React will ignore that lifecycle if gSBU exists.
|
||||
if (typeof prototype.getSnapshotBeforeUpdate === 'function') {
|
||||
if (typeof prototype.componentDidUpdate !== 'function') {
|
||||
throw new Error(
|
||||
'Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype'
|
||||
);
|
||||
}
|
||||
|
||||
prototype.componentWillUpdate = componentWillUpdate;
|
||||
|
||||
var componentDidUpdate = prototype.componentDidUpdate;
|
||||
|
||||
prototype.componentDidUpdate = function componentDidUpdatePolyfill(
|
||||
prevProps,
|
||||
prevState,
|
||||
maybeSnapshot
|
||||
) {
|
||||
// 16.3+ will not execute our will-update method;
|
||||
// It will pass a snapshot value to did-update though.
|
||||
// Older versions will require our polyfilled will-update value.
|
||||
// We need to handle both cases, but can't just check for the presence of "maybeSnapshot",
|
||||
// Because for <= 15.x versions this might be a "prevContext" object.
|
||||
// We also can't just check "__reactInternalSnapshot",
|
||||
// Because get-snapshot might return a falsy value.
|
||||
// So check for the explicit __reactInternalSnapshotFlag flag to determine behavior.
|
||||
var snapshot = this.__reactInternalSnapshotFlag
|
||||
? this.__reactInternalSnapshot
|
||||
: maybeSnapshot;
|
||||
|
||||
componentDidUpdate.call(this, prevProps, prevState, snapshot);
|
||||
};
|
||||
}
|
||||
|
||||
return Component;
|
||||
}
|
||||
|
||||
export { polyfill };
|
168
web/node_modules/react-lifecycles-compat/react-lifecycles-compat.js
generated
vendored
Normal file
168
web/node_modules/react-lifecycles-compat/react-lifecycles-compat.js
generated
vendored
Normal file
|
@ -0,0 +1,168 @@
|
|||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(factory((global.reactLifecyclesCompat = {})));
|
||||
}(this, (function (exports) { 'use strict';
|
||||
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
function componentWillMount() {
|
||||
// Call this.constructor.gDSFP to support sub-classes.
|
||||
var state = this.constructor.getDerivedStateFromProps(this.props, this.state);
|
||||
if (state !== null && state !== undefined) {
|
||||
this.setState(state);
|
||||
}
|
||||
}
|
||||
|
||||
function componentWillReceiveProps(nextProps) {
|
||||
// Call this.constructor.gDSFP to support sub-classes.
|
||||
// Use the setState() updater to ensure state isn't stale in certain edge cases.
|
||||
function updater(prevState) {
|
||||
var state = this.constructor.getDerivedStateFromProps(nextProps, prevState);
|
||||
return state !== null && state !== undefined ? state : null;
|
||||
}
|
||||
// Binding "this" is important for shallow renderer support.
|
||||
this.setState(updater.bind(this));
|
||||
}
|
||||
|
||||
function componentWillUpdate(nextProps, nextState) {
|
||||
try {
|
||||
var prevProps = this.props;
|
||||
var prevState = this.state;
|
||||
this.props = nextProps;
|
||||
this.state = nextState;
|
||||
this.__reactInternalSnapshotFlag = true;
|
||||
this.__reactInternalSnapshot = this.getSnapshotBeforeUpdate(
|
||||
prevProps,
|
||||
prevState
|
||||
);
|
||||
} finally {
|
||||
this.props = prevProps;
|
||||
this.state = prevState;
|
||||
}
|
||||
}
|
||||
|
||||
// React may warn about cWM/cWRP/cWU methods being deprecated.
|
||||
// Add a flag to suppress these warnings for this special case.
|
||||
componentWillMount.__suppressDeprecationWarning = true;
|
||||
componentWillReceiveProps.__suppressDeprecationWarning = true;
|
||||
componentWillUpdate.__suppressDeprecationWarning = true;
|
||||
|
||||
function polyfill(Component) {
|
||||
var prototype = Component.prototype;
|
||||
|
||||
if (!prototype || !prototype.isReactComponent) {
|
||||
throw new Error('Can only polyfill class components');
|
||||
}
|
||||
|
||||
if (
|
||||
typeof Component.getDerivedStateFromProps !== 'function' &&
|
||||
typeof prototype.getSnapshotBeforeUpdate !== 'function'
|
||||
) {
|
||||
return Component;
|
||||
}
|
||||
|
||||
// If new component APIs are defined, "unsafe" lifecycles won't be called.
|
||||
// Error if any of these lifecycles are present,
|
||||
// Because they would work differently between older and newer (16.3+) versions of React.
|
||||
var foundWillMountName = null;
|
||||
var foundWillReceivePropsName = null;
|
||||
var foundWillUpdateName = null;
|
||||
if (typeof prototype.componentWillMount === 'function') {
|
||||
foundWillMountName = 'componentWillMount';
|
||||
} else if (typeof prototype.UNSAFE_componentWillMount === 'function') {
|
||||
foundWillMountName = 'UNSAFE_componentWillMount';
|
||||
}
|
||||
if (typeof prototype.componentWillReceiveProps === 'function') {
|
||||
foundWillReceivePropsName = 'componentWillReceiveProps';
|
||||
} else if (typeof prototype.UNSAFE_componentWillReceiveProps === 'function') {
|
||||
foundWillReceivePropsName = 'UNSAFE_componentWillReceiveProps';
|
||||
}
|
||||
if (typeof prototype.componentWillUpdate === 'function') {
|
||||
foundWillUpdateName = 'componentWillUpdate';
|
||||
} else if (typeof prototype.UNSAFE_componentWillUpdate === 'function') {
|
||||
foundWillUpdateName = 'UNSAFE_componentWillUpdate';
|
||||
}
|
||||
if (
|
||||
foundWillMountName !== null ||
|
||||
foundWillReceivePropsName !== null ||
|
||||
foundWillUpdateName !== null
|
||||
) {
|
||||
var componentName = Component.displayName || Component.name;
|
||||
var newApiName =
|
||||
typeof Component.getDerivedStateFromProps === 'function'
|
||||
? 'getDerivedStateFromProps()'
|
||||
: 'getSnapshotBeforeUpdate()';
|
||||
|
||||
throw Error(
|
||||
'Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n' +
|
||||
componentName +
|
||||
' uses ' +
|
||||
newApiName +
|
||||
' but also contains the following legacy lifecycles:' +
|
||||
(foundWillMountName !== null ? '\n ' + foundWillMountName : '') +
|
||||
(foundWillReceivePropsName !== null
|
||||
? '\n ' + foundWillReceivePropsName
|
||||
: '') +
|
||||
(foundWillUpdateName !== null ? '\n ' + foundWillUpdateName : '') +
|
||||
'\n\nThe above lifecycles should be removed. Learn more about this warning here:\n' +
|
||||
'https://fb.me/react-async-component-lifecycle-hooks'
|
||||
);
|
||||
}
|
||||
|
||||
// React <= 16.2 does not support static getDerivedStateFromProps.
|
||||
// As a workaround, use cWM and cWRP to invoke the new static lifecycle.
|
||||
// Newer versions of React will ignore these lifecycles if gDSFP exists.
|
||||
if (typeof Component.getDerivedStateFromProps === 'function') {
|
||||
prototype.componentWillMount = componentWillMount;
|
||||
prototype.componentWillReceiveProps = componentWillReceiveProps;
|
||||
}
|
||||
|
||||
// React <= 16.2 does not support getSnapshotBeforeUpdate.
|
||||
// As a workaround, use cWU to invoke the new lifecycle.
|
||||
// Newer versions of React will ignore that lifecycle if gSBU exists.
|
||||
if (typeof prototype.getSnapshotBeforeUpdate === 'function') {
|
||||
if (typeof prototype.componentDidUpdate !== 'function') {
|
||||
throw new Error(
|
||||
'Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype'
|
||||
);
|
||||
}
|
||||
|
||||
prototype.componentWillUpdate = componentWillUpdate;
|
||||
|
||||
var componentDidUpdate = prototype.componentDidUpdate;
|
||||
|
||||
prototype.componentDidUpdate = function componentDidUpdatePolyfill(
|
||||
prevProps,
|
||||
prevState,
|
||||
maybeSnapshot
|
||||
) {
|
||||
// 16.3+ will not execute our will-update method;
|
||||
// It will pass a snapshot value to did-update though.
|
||||
// Older versions will require our polyfilled will-update value.
|
||||
// We need to handle both cases, but can't just check for the presence of "maybeSnapshot",
|
||||
// Because for <= 15.x versions this might be a "prevContext" object.
|
||||
// We also can't just check "__reactInternalSnapshot",
|
||||
// Because get-snapshot might return a falsy value.
|
||||
// So check for the explicit __reactInternalSnapshotFlag flag to determine behavior.
|
||||
var snapshot = this.__reactInternalSnapshotFlag
|
||||
? this.__reactInternalSnapshot
|
||||
: maybeSnapshot;
|
||||
|
||||
componentDidUpdate.call(this, prevProps, prevState, snapshot);
|
||||
};
|
||||
}
|
||||
|
||||
return Component;
|
||||
}
|
||||
|
||||
exports.polyfill = polyfill;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
1
web/node_modules/react-lifecycles-compat/react-lifecycles-compat.min.js
generated
vendored
Normal file
1
web/node_modules/react-lifecycles-compat/react-lifecycles-compat.min.js
generated
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(e.reactLifecyclesCompat={})}(this,function(e){"use strict";function t(){var e=this.constructor.getDerivedStateFromProps(this.props,this.state);null!==e&&void 0!==e&&this.setState(e)}function n(e){this.setState(function(t){var n=this.constructor.getDerivedStateFromProps(e,t);return null!==n&&void 0!==n?n:null}.bind(this))}function o(e,t){try{var n=this.props,o=this.state;this.props=e,this.state=t,this.__reactInternalSnapshotFlag=!0,this.__reactInternalSnapshot=this.getSnapshotBeforeUpdate(n,o)}finally{this.props=n,this.state=o}}t.__suppressDeprecationWarning=!0,n.__suppressDeprecationWarning=!0,o.__suppressDeprecationWarning=!0,e.polyfill=function(e){var i=e.prototype;if(!i||!i.isReactComponent)throw new Error("Can only polyfill class components");if("function"!=typeof e.getDerivedStateFromProps&&"function"!=typeof i.getSnapshotBeforeUpdate)return e;var p=null,l=null,r=null;if("function"==typeof i.componentWillMount?p="componentWillMount":"function"==typeof i.UNSAFE_componentWillMount&&(p="UNSAFE_componentWillMount"),"function"==typeof i.componentWillReceiveProps?l="componentWillReceiveProps":"function"==typeof i.UNSAFE_componentWillReceiveProps&&(l="UNSAFE_componentWillReceiveProps"),"function"==typeof i.componentWillUpdate?r="componentWillUpdate":"function"==typeof i.UNSAFE_componentWillUpdate&&(r="UNSAFE_componentWillUpdate"),null!==p||null!==l||null!==r){var s=e.displayName||e.name,a="function"==typeof e.getDerivedStateFromProps?"getDerivedStateFromProps()":"getSnapshotBeforeUpdate()";throw Error("Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n"+s+" uses "+a+" but also contains the following legacy lifecycles:"+(null!==p?"\n "+p:"")+(null!==l?"\n "+l:"")+(null!==r?"\n "+r:"")+"\n\nThe above lifecycles should be removed. Learn more about this warning here:\nhttps://fb.me/react-async-component-lifecycle-hooks")}if("function"==typeof e.getDerivedStateFromProps&&(i.componentWillMount=t,i.componentWillReceiveProps=n),"function"==typeof i.getSnapshotBeforeUpdate){if("function"!=typeof i.componentDidUpdate)throw new Error("Cannot polyfill getSnapshotBeforeUpdate() for components that do not define componentDidUpdate() on the prototype");i.componentWillUpdate=o;var c=i.componentDidUpdate;i.componentDidUpdate=function(e,t,n){var o=this.__reactInternalSnapshotFlag?this.__reactInternalSnapshot:n;c.call(this,e,t,o)}}return e},Object.defineProperty(e,"__esModule",{value:!0})});
|
Loading…
Add table
Add a link
Reference in a new issue