UNPKG

12 kBJavaScriptView Raw
1/** @license React v16.13.1
2 * react-test-renderer-shallow.production.min.js
3 *
4 * Copyright (c) Facebook, Inc. and its affiliates.
5 *
6 * This source code is licensed under the MIT license found in the
7 * LICENSE file in the root directory of this source tree.
8 */
9
10'use strict';var g=require("object-assign"),l=require("react"),m=require("react-is"),n=require("prop-types/checkPropTypes");function p(c){for(var d="https://reactjs.org/docs/error-decoder.html?invariant="+c,a=1;a<arguments.length;a++)d+="&args[]="+encodeURIComponent(arguments[a]);return"Minified React error #"+c+"; visit "+d+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}
11var q=/^(.*)[\\\/]/,t="function"===typeof Symbol&&Symbol.for,u=t?Symbol.for("react.portal"):60106,v=t?Symbol.for("react.fragment"):60107,w=t?Symbol.for("react.strict_mode"):60108,x=t?Symbol.for("react.profiler"):60114,y=t?Symbol.for("react.provider"):60109,z=t?Symbol.for("react.context"):60110,A=t?Symbol.for("react.forward_ref"):60112,B=t?Symbol.for("react.suspense"):60113,C=t?Symbol.for("react.suspense_list"):60120,D=t?Symbol.for("react.memo"):60115,E=t?Symbol.for("react.lazy"):60116,F=t?Symbol.for("react.block"):
1260121;
13function G(c){if(null==c)return null;if("function"===typeof c)return c.displayName||c.name||null;if("string"===typeof c)return c;switch(c){case v:return"Fragment";case u:return"Portal";case x:return"Profiler";case w:return"StrictMode";case B:return"Suspense";case C:return"SuspenseList"}if("object"===typeof c)switch(c.$$typeof){case z:return"Context.Consumer";case y:return"Context.Provider";case A:var d=c.render;d=d.displayName||d.name||"";return c.displayName||(""!==d?"ForwardRef("+d+")":"ForwardRef");case D:return G(c.type);
14case F:return G(c.render);case E:if(c=1===c._status?c._result:null)return G(c)}return null}function H(c,d){return c===d&&(0!==c||1/c===1/d)||c!==c&&d!==d}var I="function"===typeof Object.is?Object.is:H,J=Object.prototype.hasOwnProperty;function K(c,d){if(I(c,d))return!0;if("object"!==typeof c||null===c||"object"!==typeof d||null===d)return!1;var a=Object.keys(c),b=Object.keys(d);if(a.length!==b.length)return!1;for(b=0;b<a.length;b++)if(!J.call(d,a[b])||!I(c[a[b]],d[a[b]]))return!1;return!0}
15var L=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;L.hasOwnProperty("ReactCurrentDispatcher")||(L.ReactCurrentDispatcher={current:null});L.hasOwnProperty("ReactCurrentBatchConfig")||(L.ReactCurrentBatchConfig={suspense:null});
16var M=L.ReactCurrentDispatcher,N={},O=function(){function c(a){this._renderer=a;this._callbacks=[]}var d=c.prototype;d._enqueueCallback=function(a,b){"function"===typeof a&&b&&this._callbacks.push({callback:a,publicInstance:b})};d._invokeCallbacks=function(){var a=this._callbacks;this._callbacks=[];a.forEach(function(a){a.callback.call(a.publicInstance)})};d.isMounted=function(){return!!this._renderer._element};d.enqueueForceUpdate=function(a,b){this._enqueueCallback(b,a);this._renderer._forcedUpdate=
17!0;this._renderer.render(this._renderer._element,this._renderer._context)};d.enqueueReplaceState=function(a,b,e){this._enqueueCallback(e,a);this._renderer._newState=b;this._renderer.render(this._renderer._element,this._renderer._context)};d.enqueueSetState=function(a,b,e){this._enqueueCallback(e,a);e=this._renderer._newState||a.state;"function"===typeof b&&(b=b.call(a,e,a.props));null!==b&&void 0!==b&&(this._renderer._newState=g({},e,{},b),this._renderer.render(this._renderer._element,this._renderer._context))};
18return c}();function P(){return{memoizedState:null,queue:null,next:null}}function Q(c,d){return"function"===typeof d?d(c):d}
19var T=function(){function c(){this._reset()}var d=c.prototype;d._reset=function(){this._rendered=this._newState=this._instance=this._element=this._context=null;this._forcedUpdate=this._rendering=!1;this._updater=new O(this);this._dispatcher=this._createDispatcher();this._firstWorkInProgressHook=this._workInProgressHook=null;this._didScheduleRenderPhaseUpdate=this._isReRender=!1;this._renderPhaseUpdates=null;this._numberOfReRenders=0};d._validateCurrentlyRenderingComponent=function(){if(!this._rendering||
20this._instance)throw Error(p(321));};d._createDispatcher=function(){function a(){e._validateCurrentlyRenderingComponent()}function b(a,b,c){e._validateCurrentlyRenderingComponent();e._createWorkInProgressHook();var d=e._workInProgressHook;if(e._isReRender){c=d.queue;b=c.dispatch;if(0<e._numberOfReRenders){if(null!==e._renderPhaseUpdates){var f=e._renderPhaseUpdates.get(c);if(void 0!==f){e._renderPhaseUpdates.delete(c);c=d.memoizedState;do c=a(c,f.action),f=f.next;while(null!==f);d.memoizedState=c;
21return[c,b]}}return[d.memoizedState,b]}f=d.memoizedState;var r=c.first;if(null!==r){do f=a(f,r.action),r=r.next;while(null!==r);c.first=null;d.memoizedState=f}return[f,b]}a=a===Q?"function"===typeof b?b():b:void 0!==c?c(b):b;d.memoizedState=a;a=d.queue={first:null,dispatch:null};a=a.dispatch=e._dispatchAction.bind(e,a);return[d.memoizedState,a]}var e=this;return{readContext:function(a){return a._currentValue},useCallback:function(a){return a},useContext:function(a){e._validateCurrentlyRenderingComponent();
22return a._currentValue},useDebugValue:a,useEffect:a,useImperativeHandle:a,useLayoutEffect:a,useMemo:function(a,b){e._validateCurrentlyRenderingComponent();e._createWorkInProgressHook();b=void 0!==b?b:null;if(null!==e._workInProgressHook&&null!==e._workInProgressHook.memoizedState){var c=e._workInProgressHook.memoizedState,d=c[1];if(null!==b){a:if(null===d)d=!1;else{for(var f=0;f<d.length&&f<b.length;f++)if(!I(b[f],d[f])){d=!1;break a}d=!0}if(d)return c[0]}}a=a();e._workInProgressHook.memoizedState=
23[a,b];return a},useReducer:b,useRef:function(a){e._validateCurrentlyRenderingComponent();e._createWorkInProgressHook();var b=e._workInProgressHook.memoizedState;return null===b?(a={current:a},e._workInProgressHook.memoizedState=a):b},useState:function(a){return b(Q,a)},useResponder:function(a,b){return{props:b,responder:a}},useTransition:function(){e._validateCurrentlyRenderingComponent();return[function(a){a()},!1]},useDeferredValue:function(a){e._validateCurrentlyRenderingComponent();return a}}};
24d._dispatchAction=function(a,b){if(!(25>this._numberOfReRenders))throw Error(p(301));if(this._rendering){this._didScheduleRenderPhaseUpdate=!0;b={action:b,next:null};var e=this._renderPhaseUpdates;null===e&&(this._renderPhaseUpdates=e=new Map);var c=e.get(a);if(void 0===c)e.set(a,b);else{for(a=c;null!==a.next;)a=a.next;a.next=b}}else{b={action:b,next:null};e=a.first;if(null===e)a.first=b;else{for(;null!==e.next;)e=e.next;e.next=b}this.render(this._element,this._context)}};d._createWorkInProgressHook=
25function(){null===this._workInProgressHook?null===this._firstWorkInProgressHook?(this._isReRender=!1,this._firstWorkInProgressHook=this._workInProgressHook=P()):(this._isReRender=!0,this._workInProgressHook=this._firstWorkInProgressHook):null===this._workInProgressHook.next?(this._isReRender=!1,this._workInProgressHook=this._workInProgressHook.next=P()):(this._isReRender=!0,this._workInProgressHook=this._workInProgressHook.next);return this._workInProgressHook};d._finishHooks=function(a,b){this._didScheduleRenderPhaseUpdate?
26(this._didScheduleRenderPhaseUpdate=!1,this._numberOfReRenders+=1,this._workInProgressHook=null,this._rendering=!1,this.render(a,b)):(this._renderPhaseUpdates=this._workInProgressHook=null,this._numberOfReRenders=0)};d.getMountedInstance=function(){return this._instance};d.getRenderOutput=function(){return this._rendered};d.render=function(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:N;if(!l.isValidElement(a))throw Error(p(12,"function"===typeof a?" Instead of passing a component class, make sure to instantiate it by passing it to React.createElement.":
27""));if("string"===typeof a.type)throw Error(p(13,a.type));if(!m.isForwardRef(a)&&"function"!==typeof a.type&&!m.isMemo(a))throw Error(p(249,Array.isArray(a.type)?"array":null===a.type?"null":typeof a.type));if(!this._rendering){null!=this._element&&this._element.type!==a.type&&this._reset();var e=m.isMemo(a)?a.type.type:a.type,c=this._element;this._rendering=!0;this._element=a;var d;if((d=e.contextTypes)&&b){var k={},h;for(h in d)k[h]=b[h];d=k}else d=N;this._context=d;m.isMemo(a)&&e.propTypes&&(R=
28a,n(e.propTypes,a.props,"prop",G(e),S));if(this._instance)this._updateClassComponent(e,a,this._context);else if(e.prototype&&e.prototype.isReactComponent)this._instance=new e(a.props,this._context,this._updater),"function"===typeof e.getDerivedStateFromProps&&(b=e.getDerivedStateFromProps.call(null,a.props,this._instance.state),null!=b&&(this._instance.state=g({},this._instance.state,b))),e.contextTypes&&(R=a,b=(b=this._instance)&&b.constructor,n(e.contextTypes,this._context,"context",e.displayName||
29b&&b.displayName||e.name||b&&b.name||null,S),R=null),this._mountClassComponent(e,a,this._context);else if(d=!0,m.isMemo(a)&&null!==c&&(a.type.compare||K)(c.props,a.props)&&(d=!1),d){c=M.current;M.current=this._dispatcher;try{if(e.$$typeof===m.ForwardRef){if("function"!==typeof e.render)throw Error(p(322,typeof e.render));this._rendered=e.render.call(void 0,a.props,a.ref)}else this._rendered=e(a.props,this._context)}finally{M.current=c}this._finishHooks(a,b)}this._rendering=!1;this._updater._invokeCallbacks();
30return this.getRenderOutput()}};d.unmount=function(){this._instance&&"function"===typeof this._instance.componentWillUnmount&&this._instance.componentWillUnmount();this._reset()};d._mountClassComponent=function(a,b,c){this._instance.context=c;this._instance.props=b.props;this._instance.state=this._instance.state||null;this._instance.updater=this._updater;if("function"===typeof this._instance.UNSAFE_componentWillMount||"function"===typeof this._instance.componentWillMount)b=this._newState,"function"!==
31typeof a.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillMount&&this._instance.componentWillMount(),"function"===typeof this._instance.UNSAFE_componentWillMount&&this._instance.UNSAFE_componentWillMount()),b!==this._newState&&(this._instance.state=this._newState||N);this._rendered=this._instance.render()};d._updateClassComponent=function(a,b,c){b=b.props;var d=this._instance.state||N,e=this._instance.props;e!==
32b&&"function"!==typeof a.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillReceiveProps&&this._instance.componentWillReceiveProps(b,c),"function"===typeof this._instance.UNSAFE_componentWillReceiveProps&&this._instance.UNSAFE_componentWillReceiveProps(b,c));var k=this._newState||d;if("function"===typeof a.getDerivedStateFromProps){var h=a.getDerivedStateFromProps.call(null,b,k);null!=h&&(k=g({},k,h))}h=!0;this._forcedUpdate?
33(h=!0,this._forcedUpdate=!1):"function"===typeof this._instance.shouldComponentUpdate?h=!!this._instance.shouldComponentUpdate(b,k,c):a.prototype&&a.prototype.isPureReactComponent&&(h=!K(e,b)||!K(d,k));h&&"function"!==typeof a.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillUpdate&&this._instance.componentWillUpdate(b,k,c),"function"===typeof this._instance.UNSAFE_componentWillUpdate&&this._instance.UNSAFE_componentWillUpdate(b,
34k,c));this._instance.context=c;this._instance.props=b;this._instance.state=k;this._newState=null;h&&(this._rendered=this._instance.render())};return c}();T.createRenderer=function(){return new T};var R=null;function U(c){if(null==c)return"#empty";if("string"===typeof c||"number"===typeof c)return"#text";if("string"===typeof c.type)return c.type;c=m.isMemo(c)?c.type.type:c.type;return c.displayName||c.name||"Unknown"}
35function S(){var c="";if(R){var d=U(R),a=R._owner,b=R._source;a=a&&G(a.type);var e="";b?e=" (at "+b.fileName.replace(q,"")+":"+b.lineNumber+")":a&&(e=" (created by "+a+")");c+="\n in "+(d||"Unknown")+e}return c}module.exports=T.default||T;