WIP - add extractor, generate snippet_data
This commit is contained in:
30
node_modules/hoist-non-react-statics/CHANGELOG.md
generated
vendored
Normal file
30
node_modules/hoist-non-react-statics/CHANGELOG.md
generated
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
# 3.3.0 (January 23, 2019)
|
||||
- Prevent hoisting of React.memo statics (#73)
|
||||
|
||||
# 3.2.1 (December 3, 2018)
|
||||
- Fixed `defaultProps`, `displayName` and `propTypes` being hoisted from `React.forwardRef` to `React.forwardRef`. ([#71])
|
||||
|
||||
# 3.2.0 (November 26, 2018)
|
||||
- Added support for `getDerivedStateFromError`. ([#68])
|
||||
- Added support for React versions less than 0.14. ([#69])
|
||||
|
||||
# 3.1.0 (October 30, 2018)
|
||||
- Added support for `contextType`. ([#62])
|
||||
- Reduced bundle size. ([e89c7a6])
|
||||
- Removed TypeScript definitions. ([#61])
|
||||
|
||||
# 3.0.1 (July 28, 2018)
|
||||
- Fixed prop-types warnings. ([e0846fe])
|
||||
|
||||
# 3.0.0 (July 27, 2018)
|
||||
- Dropped support for React versions less than 0.14. ([#55])
|
||||
- Added support for `React.forwardRef` components. ([#55])
|
||||
|
||||
[#55]: https://github.com/mridgway/hoist-non-react-statics/pull/55
|
||||
[#61]: https://github.com/mridgway/hoist-non-react-statics/pull/61
|
||||
[#62]: https://github.com/mridgway/hoist-non-react-statics/pull/62
|
||||
[#68]: https://github.com/mridgway/hoist-non-react-statics/pull/68
|
||||
[#69]: https://github.com/mridgway/hoist-non-react-statics/pull/69
|
||||
[#71]: https://github.com/mridgway/hoist-non-react-statics/pull/71
|
||||
[e0846fe]: https://github.com/mridgway/hoist-non-react-statics/commit/e0846feefbad8b34d300de9966ffd607aacb81a3
|
||||
[e89c7a6]: https://github.com/mridgway/hoist-non-react-statics/commit/e89c7a6168edc19eeadb2d149e600b888e8b0446
|
||||
29
node_modules/hoist-non-react-statics/LICENSE.md
generated
vendored
Normal file
29
node_modules/hoist-non-react-statics/LICENSE.md
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
Software License Agreement (BSD License)
|
||||
========================================
|
||||
|
||||
Copyright (c) 2015, Yahoo! Inc. All rights reserved.
|
||||
----------------------------------------------------
|
||||
|
||||
Redistribution and use of this software in source and binary forms, with or
|
||||
without modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
* Neither the name of Yahoo! Inc. nor the names of YUI's contributors may be
|
||||
used to endorse or promote products derived from this software without
|
||||
specific prior written permission of Yahoo! Inc.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
55
node_modules/hoist-non-react-statics/README.md
generated
vendored
Normal file
55
node_modules/hoist-non-react-statics/README.md
generated
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
# hoist-non-react-statics
|
||||
|
||||
[](http://badge.fury.io/js/hoist-non-react-statics)
|
||||
[](https://travis-ci.org/mridgway/hoist-non-react-statics)
|
||||
[](https://coveralls.io/r/mridgway/hoist-non-react-statics?branch=master)
|
||||
[](https://david-dm.org/mridgway/hoist-non-react-statics)
|
||||
[](https://david-dm.org/mridgway/hoist-non-react-statics#info=devDependencies)
|
||||
|
||||
Copies non-react specific statics from a child component to a parent component.
|
||||
Similar to `Object.assign`, but with React static keywords blacklisted from
|
||||
being overridden.
|
||||
|
||||
```bash
|
||||
$ npm install --save hoist-non-react-statics
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import hoistNonReactStatics from 'hoist-non-react-statics';
|
||||
|
||||
hoistNonReactStatics(targetComponent, sourceComponent);
|
||||
```
|
||||
|
||||
If you have specific statics that you don't want to be hoisted, you can also pass a third parameter to exclude them:
|
||||
|
||||
```js
|
||||
hoistNonReactStatics(targetComponent, sourceComponent, { myStatic: true, myOtherStatic: true });
|
||||
```
|
||||
|
||||
## What does this module do?
|
||||
|
||||
See this [explanation](https://facebook.github.io/react/docs/higher-order-components.html#static-methods-must-be-copied-over) from the React docs.
|
||||
|
||||
## Compatible React Versions
|
||||
|
||||
Please use latest 3.x. Versions prior to 3.x will not support ForwardRefs.
|
||||
|
||||
| hoist-non-react-statics Version | Compatible React Version |
|
||||
|--------------------------|-------------------------------|
|
||||
| 3.x | 0.13-16.x With ForwardRef Support |
|
||||
| 2.x | 0.13-16.x Without ForwardRef Support |
|
||||
| 1.x | 0.13-16.2 |
|
||||
|
||||
## Browser Support
|
||||
|
||||
This package uses `Object.defineProperty` which has a broken implementation in IE8. In order to use this package in IE8, you will need a polyfill that fixes this method.
|
||||
|
||||
## License
|
||||
This software is free to use under the Yahoo Inc. BSD license.
|
||||
See the [LICENSE file][] for license text and copyright information.
|
||||
|
||||
[LICENSE file]: https://github.com/mridgway/hoist-non-react-statics/blob/master/LICENSE.md
|
||||
|
||||
Third-party open source code used are listed in our [package.json file]( https://github.com/mridgway/hoist-non-react-statics/blob/master/package.json).
|
||||
103
node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js
generated
vendored
Normal file
103
node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.cjs.js
generated
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Copyright 2015, Yahoo! Inc.
|
||||
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
||||
*/
|
||||
var ReactIs = require('react-is');
|
||||
var REACT_STATICS = {
|
||||
childContextTypes: true,
|
||||
contextType: true,
|
||||
contextTypes: true,
|
||||
defaultProps: true,
|
||||
displayName: true,
|
||||
getDefaultProps: true,
|
||||
getDerivedStateFromError: true,
|
||||
getDerivedStateFromProps: true,
|
||||
mixins: true,
|
||||
propTypes: true,
|
||||
type: true
|
||||
};
|
||||
|
||||
var KNOWN_STATICS = {
|
||||
name: true,
|
||||
length: true,
|
||||
prototype: true,
|
||||
caller: true,
|
||||
callee: true,
|
||||
arguments: true,
|
||||
arity: true
|
||||
};
|
||||
|
||||
var FORWARD_REF_STATICS = {
|
||||
'$$typeof': true,
|
||||
render: true,
|
||||
defaultProps: true,
|
||||
displayName: true,
|
||||
propTypes: true
|
||||
};
|
||||
|
||||
var MEMO_STATICS = {
|
||||
'$$typeof': true,
|
||||
compare: true,
|
||||
defaultProps: true,
|
||||
displayName: true,
|
||||
propTypes: true,
|
||||
type: true
|
||||
};
|
||||
|
||||
var TYPE_STATICS = {};
|
||||
TYPE_STATICS[ReactIs.ForwardRef] = FORWARD_REF_STATICS;
|
||||
|
||||
function getStatics(component) {
|
||||
if (ReactIs.isMemo(component)) {
|
||||
return MEMO_STATICS;
|
||||
}
|
||||
return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
|
||||
}
|
||||
|
||||
var defineProperty = Object.defineProperty;
|
||||
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
||||
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
||||
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
||||
var getPrototypeOf = Object.getPrototypeOf;
|
||||
var objectPrototype = Object.prototype;
|
||||
|
||||
function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
|
||||
if (typeof sourceComponent !== 'string') {
|
||||
// don't hoist over string (html) components
|
||||
|
||||
if (objectPrototype) {
|
||||
var inheritedComponent = getPrototypeOf(sourceComponent);
|
||||
if (inheritedComponent && inheritedComponent !== objectPrototype) {
|
||||
hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
|
||||
}
|
||||
}
|
||||
|
||||
var keys = getOwnPropertyNames(sourceComponent);
|
||||
|
||||
if (getOwnPropertySymbols) {
|
||||
keys = keys.concat(getOwnPropertySymbols(sourceComponent));
|
||||
}
|
||||
|
||||
var targetStatics = getStatics(targetComponent);
|
||||
var sourceStatics = getStatics(sourceComponent);
|
||||
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var key = keys[i];
|
||||
if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
|
||||
var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
||||
try {
|
||||
// Avoid failures from read-only properties
|
||||
defineProperty(targetComponent, key, descriptor);
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
return targetComponent;
|
||||
}
|
||||
|
||||
return targetComponent;
|
||||
}
|
||||
|
||||
module.exports = hoistNonReactStatics;
|
||||
109
node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.js
generated
vendored
Normal file
109
node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.js
generated
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global.hoistNonReactStatics = factory());
|
||||
}(this, (function () { 'use strict';
|
||||
|
||||
/**
|
||||
* Copyright 2015, Yahoo! Inc.
|
||||
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
||||
*/
|
||||
var ReactIs = require('react-is');
|
||||
var REACT_STATICS = {
|
||||
childContextTypes: true,
|
||||
contextType: true,
|
||||
contextTypes: true,
|
||||
defaultProps: true,
|
||||
displayName: true,
|
||||
getDefaultProps: true,
|
||||
getDerivedStateFromError: true,
|
||||
getDerivedStateFromProps: true,
|
||||
mixins: true,
|
||||
propTypes: true,
|
||||
type: true
|
||||
};
|
||||
|
||||
var KNOWN_STATICS = {
|
||||
name: true,
|
||||
length: true,
|
||||
prototype: true,
|
||||
caller: true,
|
||||
callee: true,
|
||||
arguments: true,
|
||||
arity: true
|
||||
};
|
||||
|
||||
var FORWARD_REF_STATICS = {
|
||||
'$$typeof': true,
|
||||
render: true,
|
||||
defaultProps: true,
|
||||
displayName: true,
|
||||
propTypes: true
|
||||
};
|
||||
|
||||
var MEMO_STATICS = {
|
||||
'$$typeof': true,
|
||||
compare: true,
|
||||
defaultProps: true,
|
||||
displayName: true,
|
||||
propTypes: true,
|
||||
type: true
|
||||
};
|
||||
|
||||
var TYPE_STATICS = {};
|
||||
TYPE_STATICS[ReactIs.ForwardRef] = FORWARD_REF_STATICS;
|
||||
|
||||
function getStatics(component) {
|
||||
if (ReactIs.isMemo(component)) {
|
||||
return MEMO_STATICS;
|
||||
}
|
||||
return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
|
||||
}
|
||||
|
||||
var defineProperty = Object.defineProperty;
|
||||
var getOwnPropertyNames = Object.getOwnPropertyNames;
|
||||
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
||||
var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
||||
var getPrototypeOf = Object.getPrototypeOf;
|
||||
var objectPrototype = Object.prototype;
|
||||
|
||||
function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
|
||||
if (typeof sourceComponent !== 'string') {
|
||||
// don't hoist over string (html) components
|
||||
|
||||
if (objectPrototype) {
|
||||
var inheritedComponent = getPrototypeOf(sourceComponent);
|
||||
if (inheritedComponent && inheritedComponent !== objectPrototype) {
|
||||
hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
|
||||
}
|
||||
}
|
||||
|
||||
var keys = getOwnPropertyNames(sourceComponent);
|
||||
|
||||
if (getOwnPropertySymbols) {
|
||||
keys = keys.concat(getOwnPropertySymbols(sourceComponent));
|
||||
}
|
||||
|
||||
var targetStatics = getStatics(targetComponent);
|
||||
var sourceStatics = getStatics(sourceComponent);
|
||||
|
||||
for (var i = 0; i < keys.length; ++i) {
|
||||
var key = keys[i];
|
||||
if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
|
||||
var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
||||
try {
|
||||
// Avoid failures from read-only properties
|
||||
defineProperty(targetComponent, key, descriptor);
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
return targetComponent;
|
||||
}
|
||||
|
||||
return targetComponent;
|
||||
}
|
||||
|
||||
return hoistNonReactStatics;
|
||||
|
||||
})));
|
||||
1
node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.min.js
generated
vendored
Normal file
1
node_modules/hoist-non-react-statics/dist/hoist-non-react-statics.min.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.hoistNonReactStatics=t()}(this,function(){"use strict";var t=require("react-is"),r={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},f={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},o={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},p={};function d(e){return t.isMemo(e)?o:p[e.$$typeof]||r}p[t.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0};var u=Object.defineProperty,l=Object.getOwnPropertyNames,m=Object.getOwnPropertySymbols,g=Object.getOwnPropertyDescriptor,O=Object.getPrototypeOf,P=Object.prototype;return function e(t,r,o){if("string"!=typeof r){if(P){var p=O(r);p&&p!==P&&e(t,p,o)}var n=l(r);m&&(n=n.concat(m(r)));for(var a=d(t),i=d(r),s=0;s<n.length;++s){var y=n[s];if(!(f[y]||o&&o[y]||i&&i[y]||a&&a[y])){var c=g(r,y);try{u(t,y,c)}catch(e){}}}return t}return t}});
|
||||
92
node_modules/hoist-non-react-statics/package.json
generated
vendored
Normal file
92
node_modules/hoist-non-react-statics/package.json
generated
vendored
Normal file
@ -0,0 +1,92 @@
|
||||
{
|
||||
"_from": "hoist-non-react-statics@^3.3.0",
|
||||
"_id": "hoist-non-react-statics@3.3.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-0XsbTXxgiaCDYDIWFcwkmerZPSwywfUqYmwT4jzewKTQSWoE6FCMoUVOeBJWK3E/CrWbxRG3m5GzY4lnIwGRBA==",
|
||||
"_location": "/hoist-non-react-statics",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "hoist-non-react-statics@^3.3.0",
|
||||
"name": "hoist-non-react-statics",
|
||||
"escapedName": "hoist-non-react-statics",
|
||||
"rawSpec": "^3.3.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^3.3.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/react-hot-loader",
|
||||
"/react-redux"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.0.tgz",
|
||||
"_shasum": "b09178f0122184fb95acf525daaecb4d8f45958b",
|
||||
"_spec": "hoist-non-react-statics@^3.3.0",
|
||||
"_where": "/Users/stefanfejes/Projects/30-seconds-of-python-code/node_modules/react-hot-loader",
|
||||
"author": {
|
||||
"name": "Michael Ridgway",
|
||||
"email": "mcridgway@gmail.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/mridgway/hoist-non-react-statics/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"dependencies": {
|
||||
"react-is": "^16.7.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Copies non-react specific statics from a child component to a parent component",
|
||||
"devDependencies": {
|
||||
"babel": "^6.23.0",
|
||||
"babel-cli": "^6.24.1",
|
||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||
"babel-plugin-transform-react-jsx-source": "^6.22.0",
|
||||
"babel-preset-env": "^1.7.0",
|
||||
"babel-preset-es2015": "^6.24.1",
|
||||
"babel-preset-react": "^6.24.1",
|
||||
"babel-register": "^6.24.1",
|
||||
"chai": "^4.0.1",
|
||||
"coveralls": "^2.11.1",
|
||||
"create-react-class": "^15.5.3",
|
||||
"eslint": "^4.13.1",
|
||||
"istanbul": "^0.4.5",
|
||||
"mocha": "^3.4.2",
|
||||
"pre-commit": "^1.0.7",
|
||||
"prop-types": "^15.6.2",
|
||||
"react": "^16.7.0",
|
||||
"rimraf": "^2.6.2",
|
||||
"rollup": "^0.52.3",
|
||||
"rollup-plugin-babel": "^3.0.4",
|
||||
"rollup-plugin-uglify": "^2.0.1"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"dist",
|
||||
"index.d.ts"
|
||||
],
|
||||
"homepage": "https://github.com/mridgway/hoist-non-react-statics#readme",
|
||||
"keywords": [
|
||||
"react"
|
||||
],
|
||||
"license": "BSD-3-Clause",
|
||||
"main": "dist/hoist-non-react-statics.cjs.js",
|
||||
"name": "hoist-non-react-statics",
|
||||
"publishConfig": {
|
||||
"registry": "https://registry.npmjs.org/"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/mridgway/hoist-non-react-statics.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rollup -c",
|
||||
"cover": "node node_modules/istanbul/lib/cli.js cover --dir artifacts -- ./node_modules/mocha/bin/_mocha tests/unit/ --recursive --require babel/register --reporter spec",
|
||||
"lint": "eslint src",
|
||||
"prebuild": "rimraf dist",
|
||||
"prepublish": "npm test",
|
||||
"pretest": "npm run build",
|
||||
"test": "mocha tests/unit/ --recursive --compilers js:babel-register --reporter spec"
|
||||
},
|
||||
"version": "3.3.0"
|
||||
}
|
||||
101
node_modules/hoist-non-react-statics/src/index.js
generated
vendored
Normal file
101
node_modules/hoist-non-react-statics/src/index.js
generated
vendored
Normal file
@ -0,0 +1,101 @@
|
||||
/**
|
||||
* Copyright 2015, Yahoo! Inc.
|
||||
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
||||
*/
|
||||
const ReactIs = require('react-is');
|
||||
const REACT_STATICS = {
|
||||
childContextTypes: true,
|
||||
contextType: true,
|
||||
contextTypes: true,
|
||||
defaultProps: true,
|
||||
displayName: true,
|
||||
getDefaultProps: true,
|
||||
getDerivedStateFromError: true,
|
||||
getDerivedStateFromProps: true,
|
||||
mixins: true,
|
||||
propTypes: true,
|
||||
type: true
|
||||
};
|
||||
|
||||
const KNOWN_STATICS = {
|
||||
name: true,
|
||||
length: true,
|
||||
prototype: true,
|
||||
caller: true,
|
||||
callee: true,
|
||||
arguments: true,
|
||||
arity: true
|
||||
};
|
||||
|
||||
const FORWARD_REF_STATICS = {
|
||||
'$$typeof': true,
|
||||
render: true,
|
||||
defaultProps: true,
|
||||
displayName: true,
|
||||
propTypes: true
|
||||
};
|
||||
|
||||
const MEMO_STATICS = {
|
||||
'$$typeof': true,
|
||||
compare: true,
|
||||
defaultProps: true,
|
||||
displayName: true,
|
||||
propTypes: true,
|
||||
type: true,
|
||||
}
|
||||
|
||||
const TYPE_STATICS = {};
|
||||
TYPE_STATICS[ReactIs.ForwardRef] = FORWARD_REF_STATICS;
|
||||
|
||||
function getStatics(component) {
|
||||
if (ReactIs.isMemo(component)) {
|
||||
return MEMO_STATICS;
|
||||
}
|
||||
return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
|
||||
}
|
||||
|
||||
const defineProperty = Object.defineProperty;
|
||||
const getOwnPropertyNames = Object.getOwnPropertyNames;
|
||||
const getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
||||
const getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
|
||||
const getPrototypeOf = Object.getPrototypeOf;
|
||||
const objectPrototype = Object.prototype;
|
||||
|
||||
export default function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
|
||||
if (typeof sourceComponent !== 'string') { // don't hoist over string (html) components
|
||||
|
||||
if (objectPrototype) {
|
||||
const inheritedComponent = getPrototypeOf(sourceComponent);
|
||||
if (inheritedComponent && inheritedComponent !== objectPrototype) {
|
||||
hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
|
||||
}
|
||||
}
|
||||
|
||||
let keys = getOwnPropertyNames(sourceComponent);
|
||||
|
||||
if (getOwnPropertySymbols) {
|
||||
keys = keys.concat(getOwnPropertySymbols(sourceComponent));
|
||||
}
|
||||
|
||||
const targetStatics = getStatics(targetComponent);
|
||||
const sourceStatics = getStatics(sourceComponent);
|
||||
|
||||
for (let i = 0; i < keys.length; ++i) {
|
||||
const key = keys[i];
|
||||
if (!KNOWN_STATICS[key] &&
|
||||
!(blacklist && blacklist[key]) &&
|
||||
!(sourceStatics && sourceStatics[key]) &&
|
||||
!(targetStatics && targetStatics[key])
|
||||
) {
|
||||
const descriptor = getOwnPropertyDescriptor(sourceComponent, key);
|
||||
try { // Avoid failures from read-only properties
|
||||
defineProperty(targetComponent, key, descriptor);
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
return targetComponent;
|
||||
}
|
||||
|
||||
return targetComponent;
|
||||
};
|
||||
Reference in New Issue
Block a user