react-test-renderer 16.4.0 → 16.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/react-test-renderer-shallow.development.js +3 -3
- package/cjs/react-test-renderer-shallow.production.min.js +16 -16
- package/cjs/react-test-renderer.development.js +140 -91
- package/cjs/react-test-renderer.production.min.js +100 -99
- package/package.json +2 -2
- package/umd/react-test-renderer-shallow.development.js +3 -3
- package/umd/react-test-renderer-shallow.production.min.js +12 -12
- package/umd/react-test-renderer.development.js +140 -91
- package/umd/react-test-renderer.production.min.js +92 -92
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.4.
|
|
1
|
+
/** @license React v16.4.1
|
|
2
2
|
* react-test-renderer-shallow.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -261,10 +261,10 @@ var ReactShallowRenderer = function () {
|
|
|
261
261
|
|
|
262
262
|
|
|
263
263
|
if (typeof type.getDerivedStateFromProps === 'function') {
|
|
264
|
-
var
|
|
264
|
+
var oldState = this._newState || this._instance.state;
|
|
265
|
+
var partialState = type.getDerivedStateFromProps.call(null, props, oldState);
|
|
265
266
|
|
|
266
267
|
if (partialState != null) {
|
|
267
|
-
var oldState = this._newState || this._instance.state;
|
|
268
268
|
var newState = _assign({}, oldState, partialState);
|
|
269
269
|
this._instance.state = this._newState = newState;
|
|
270
270
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.4.
|
|
1
|
+
/** @license React v16.4.1
|
|
2
2
|
* react-test-renderer-shallow.production.min.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -8,18 +8,18 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
'use strict';var e=require("object-assign"),f=require("fbjs/lib/invariant"),l=require("react"),m=require("react-is"),n=require("fbjs/lib/emptyObject"),p=require("fbjs/lib/shallowEqual"),q=require("prop-types/checkPropTypes");
|
|
11
|
-
function r(
|
|
12
|
-
var t="function"===typeof Symbol&&Symbol.for,u=t?Symbol.for("react.portal"):60106,
|
|
13
|
-
function
|
|
14
|
-
function
|
|
15
|
-
var
|
|
16
|
-
"");"string"===typeof a.type?r("13",a.type):void 0;m.isForwardRef(a)||"function"===typeof a.type?void 0:r("249",Array.isArray(a.type)?"array":null===a.type?"null":typeof a.type);if(!this._rendering){this._rendering=!0;this._element=a;var
|
|
17
|
-
new a.type(a.props,this._context,this._updater),this._updateStateFromStaticLifecycle(a.props),a.type.hasOwnProperty("contextTypes")&&(
|
|
18
|
-
"function"===typeof this._instance.componentWillUnmount&&this._instance.componentWillUnmount();this._instance=this._rendered=this._newState=this._element=this._context=null};
|
|
19
|
-
typeof a.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillMount&&this._instance.componentWillMount(),"function"===typeof this._instance.UNSAFE_componentWillMount&&this._instance.UNSAFE_componentWillMount()),
|
|
20
|
-
|
|
21
|
-
k=!!this._instance.shouldComponentUpdate(
|
|
22
|
-
h;k&&(this._rendered=this._instance.render())};
|
|
23
|
-
var
|
|
24
|
-
!0;this._renderer.render(this._renderer._element,this._renderer._context)};
|
|
25
|
-
this._renderer._context))};return
|
|
11
|
+
function r(d){for(var a=arguments.length-1,b="https://reactjs.org/docs/error-decoder.html?invariant="+d,c=0;c<a;c++)b+="&args[]="+encodeURIComponent(arguments[c+1]);f(!1,"Minified React error #"+d+"; visit %s for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ",b)}
|
|
12
|
+
var t="function"===typeof Symbol&&Symbol.for,u=t?Symbol.for("react.portal"):60106,w=t?Symbol.for("react.fragment"):60107,x=t?Symbol.for("react.strict_mode"):60108,y=t?Symbol.for("react.profiler"):60114,z=t?Symbol.for("react.provider"):60109,A=t?Symbol.for("react.context"):60110,B=t?Symbol.for("react.async_mode"):60111,C=t?Symbol.for("react.forward_ref"):60112,D=t?Symbol.for("react.timeout"):60113;
|
|
13
|
+
function E(d){var a=d.type;if("function"===typeof a)return a.displayName||a.name;if("string"===typeof a)return a;switch(a){case B:return"AsyncMode";case A:return"Context.Consumer";case w:return"ReactFragment";case u:return"ReactPortal";case y:return"Profiler("+d.pendingProps.id+")";case z:return"Context.Provider";case x:return"StrictMode";case D:return"Timeout"}if("object"===typeof a&&null!==a)switch(a.$$typeof){case C:return d=a.render.displayName||a.render.name||"",""!==d?"ForwardRef("+d+")":"ForwardRef"}return null}
|
|
14
|
+
function F(d,a){if(!(d instanceof a))throw new TypeError("Cannot call a class as a function");}
|
|
15
|
+
var J=function(){function d(){F(this,d);this._rendered=this._newState=this._instance=this._element=this._context=null;this._forcedUpdate=this._rendering=!1;this._updater=new G(this)}d.prototype.getMountedInstance=function(){return this._instance};d.prototype.getRenderOutput=function(){return this._rendered};d.prototype.render=function(a){var b=1<arguments.length&&void 0!==arguments[1]?arguments[1]:n;l.isValidElement(a)?void 0:r("12","function"===typeof a?" Instead of passing a component class, make sure to instantiate it by passing it to React.createElement.":
|
|
16
|
+
"");"string"===typeof a.type?r("13",a.type):void 0;m.isForwardRef(a)||"function"===typeof a.type?void 0:r("249",Array.isArray(a.type)?"array":null===a.type?"null":typeof a.type);if(!this._rendering){this._rendering=!0;this._element=a;var c=a.type.contextTypes;if(c){var d={},g;for(g in c)d[g]=b[g];b=d}else b=n;this._context=b;this._instance?this._updateClassComponent(a,this._context):m.isForwardRef(a)?this._rendered=a.type.render(a.props,a.ref):(b=a.type,b.prototype&&b.prototype.isReactComponent?(this._instance=
|
|
17
|
+
new a.type(a.props,this._context,this._updater),this._updateStateFromStaticLifecycle(a.props),a.type.hasOwnProperty("contextTypes")&&(H=a,b=a.type,c=(c=this._instance)&&c.constructor,q(a.type.contextTypes,this._context,"context",b.displayName||c&&c.displayName||b.name||c&&c.name||null,I),H=null),this._mountClassComponent(a,this._context)):this._rendered=a.type(a.props,this._context));this._rendering=!1;this._updater._invokeCallbacks();return this.getRenderOutput()}};d.prototype.unmount=function(){this._instance&&
|
|
18
|
+
"function"===typeof this._instance.componentWillUnmount&&this._instance.componentWillUnmount();this._instance=this._rendered=this._newState=this._element=this._context=null};d.prototype._mountClassComponent=function(a,b){this._instance.context=b;this._instance.props=a.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"!==
|
|
19
|
+
typeof a.type.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.prototype._updateClassComponent=function(a,b){var c=a.props,d=a.type,g=this._instance.state||n,v=this._instance.props;
|
|
20
|
+
v!==c&&"function"!==typeof a.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillReceiveProps&&this._instance.componentWillReceiveProps(c,b),"function"===typeof this._instance.UNSAFE_componentWillReceiveProps&&this._instance.UNSAFE_componentWillReceiveProps(c,b));this._updateStateFromStaticLifecycle(c);var h=this._newState||g,k=!0;this._forcedUpdate?(k=!0,this._forcedUpdate=!1):"function"===typeof this._instance.shouldComponentUpdate?
|
|
21
|
+
k=!!this._instance.shouldComponentUpdate(c,h,b):d.prototype&&d.prototype.isPureReactComponent&&(k=!p(v,c)||!p(g,h));k&&"function"!==typeof a.type.getDerivedStateFromProps&&"function"!==typeof this._instance.getSnapshotBeforeUpdate&&("function"===typeof this._instance.componentWillUpdate&&this._instance.componentWillUpdate(c,h,b),"function"===typeof this._instance.UNSAFE_componentWillUpdate&&this._instance.UNSAFE_componentWillUpdate(c,h,b));this._instance.context=b;this._instance.props=c;this._instance.state=
|
|
22
|
+
h;k&&(this._rendered=this._instance.render())};d.prototype._updateStateFromStaticLifecycle=function(a){var b=this._element.type;if("function"===typeof b.getDerivedStateFromProps){var c=this._newState||this._instance.state;a=b.getDerivedStateFromProps.call(null,a,c);null!=a&&(c=e({},c,a),this._instance.state=this._newState=c)}};return d}();J.createRenderer=function(){return new J};
|
|
23
|
+
var G=function(){function d(a){F(this,d);this._renderer=a;this._callbacks=[]}d.prototype._enqueueCallback=function(a,b){"function"===typeof a&&b&&this._callbacks.push({callback:a,publicInstance:b})};d.prototype._invokeCallbacks=function(){var a=this._callbacks;this._callbacks=[];a.forEach(function(a){a.callback.call(a.publicInstance)})};d.prototype.isMounted=function(){return!!this._renderer._element};d.prototype.enqueueForceUpdate=function(a,b){this._enqueueCallback(b,a);this._renderer._forcedUpdate=
|
|
24
|
+
!0;this._renderer.render(this._renderer._element,this._renderer._context)};d.prototype.enqueueReplaceState=function(a,b,c){this._enqueueCallback(c,a);this._renderer._newState=b;this._renderer.render(this._renderer._element,this._renderer._context)};d.prototype.enqueueSetState=function(a,b,c){this._enqueueCallback(c,a);c=this._renderer._newState||a.state;"function"===typeof b&&(b=b.call(a,c,a.props));null!==b&&void 0!==b&&(this._renderer._newState=e({},c,b),this._renderer.render(this._renderer._element,
|
|
25
|
+
this._renderer._context))};return d}(),H=null;function I(){var d="";if(H){var a=null==H?"#empty":"string"===typeof H||"number"===typeof H?"#text":"string"===typeof H.type?H.type:H.type.displayName||H.type.name||"Unknown",b=H._owner,c=H._source;b=b&&E(b);a="\n in "+(a||"Unknown")+(c?" (at "+c.fileName.replace(/^.*[\\\/]/,"")+":"+c.lineNumber+")":b?" (created by "+b+")":"");d+=a}return d}var K={default:J},L=K&&J||K;module.exports=L.default?L.default:L;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.4.
|
|
1
|
+
/** @license React v16.4.1
|
|
2
2
|
* react-test-renderer.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) 2013-present, Facebook, Inc.
|
|
@@ -343,7 +343,8 @@ var yieldedValues = null;
|
|
|
343
343
|
|
|
344
344
|
function scheduleDeferredCallback$1(callback, options) {
|
|
345
345
|
scheduledCallback = callback;
|
|
346
|
-
|
|
346
|
+
var fakeCallbackId = 0;
|
|
347
|
+
return fakeCallbackId;
|
|
347
348
|
}
|
|
348
349
|
|
|
349
350
|
function cancelDeferredCallback$1(timeoutID) {
|
|
@@ -403,7 +404,19 @@ function flushThrough(expectedValues) {
|
|
|
403
404
|
}
|
|
404
405
|
if (yieldedValues === null) {
|
|
405
406
|
// Always return an array.
|
|
406
|
-
|
|
407
|
+
yieldedValues = [];
|
|
408
|
+
}
|
|
409
|
+
for (var i = 0; i < expectedValues.length; i++) {
|
|
410
|
+
var expectedValue = '"' + expectedValues[i] + '"';
|
|
411
|
+
var yieldedValue = i < yieldedValues.length ? '"' + yieldedValues[i] + '"' : 'nothing';
|
|
412
|
+
if (yieldedValue !== expectedValue) {
|
|
413
|
+
var error = new Error('flushThrough expected to yield ' + expectedValue + ', but ' + yieldedValue + ' was yielded');
|
|
414
|
+
// Attach expected and yielded arrays,
|
|
415
|
+
// So the caller could pretty print the diff (if desired).
|
|
416
|
+
error.expectedValues = expectedValues;
|
|
417
|
+
error.actualValues = yieldedValues;
|
|
418
|
+
throw error;
|
|
419
|
+
}
|
|
407
420
|
}
|
|
408
421
|
return yieldedValues;
|
|
409
422
|
}
|
|
@@ -690,7 +703,6 @@ var warnAboutDeprecatedLifecycles = false;
|
|
|
690
703
|
var warnAboutLegacyContextAPI = false;
|
|
691
704
|
var replayFailedUnitOfWorkWithInvokeGuardedCallback = false;
|
|
692
705
|
var enableProfilerTimer = false;
|
|
693
|
-
var fireGetDerivedStateFromPropsOnStateUpdates = true;
|
|
694
706
|
|
|
695
707
|
// Only used in www builds.
|
|
696
708
|
|
|
@@ -1493,6 +1505,8 @@ function FiberNode(tag, pendingProps, key, mode) {
|
|
|
1493
1505
|
this.alternate = null;
|
|
1494
1506
|
|
|
1495
1507
|
if (enableProfilerTimer) {
|
|
1508
|
+
this.actualDuration = 0;
|
|
1509
|
+
this.actualStartTime = 0;
|
|
1496
1510
|
this.selfBaseTime = 0;
|
|
1497
1511
|
this.treeBaseTime = 0;
|
|
1498
1512
|
}
|
|
@@ -1563,6 +1577,15 @@ function createWorkInProgress(current, pendingProps, expirationTime) {
|
|
|
1563
1577
|
workInProgress.nextEffect = null;
|
|
1564
1578
|
workInProgress.firstEffect = null;
|
|
1565
1579
|
workInProgress.lastEffect = null;
|
|
1580
|
+
|
|
1581
|
+
if (enableProfilerTimer) {
|
|
1582
|
+
// We intentionally reset, rather than copy, actualDuration & actualStartTime.
|
|
1583
|
+
// This prevents time from endlessly accumulating in new commits.
|
|
1584
|
+
// This has the downside of resetting values for different priority renders,
|
|
1585
|
+
// But works for yielding (the common case) and should support resuming.
|
|
1586
|
+
workInProgress.actualDuration = 0;
|
|
1587
|
+
workInProgress.actualStartTime = 0;
|
|
1588
|
+
}
|
|
1566
1589
|
}
|
|
1567
1590
|
|
|
1568
1591
|
workInProgress.expirationTime = expirationTime;
|
|
@@ -1688,13 +1711,6 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) {
|
|
|
1688
1711
|
var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode);
|
|
1689
1712
|
fiber.type = REACT_PROFILER_TYPE;
|
|
1690
1713
|
fiber.expirationTime = expirationTime;
|
|
1691
|
-
if (enableProfilerTimer) {
|
|
1692
|
-
fiber.stateNode = {
|
|
1693
|
-
elapsedPauseTimeAtStart: 0,
|
|
1694
|
-
duration: 0,
|
|
1695
|
-
startTime: 0
|
|
1696
|
-
};
|
|
1697
|
-
}
|
|
1698
1714
|
|
|
1699
1715
|
return fiber;
|
|
1700
1716
|
}
|
|
@@ -1758,6 +1774,8 @@ function assignFiberPropertiesInDEV(target, source) {
|
|
|
1758
1774
|
target.expirationTime = source.expirationTime;
|
|
1759
1775
|
target.alternate = source.alternate;
|
|
1760
1776
|
if (enableProfilerTimer) {
|
|
1777
|
+
target.actualDuration = source.actualDuration;
|
|
1778
|
+
target.actualStartTime = source.actualStartTime;
|
|
1761
1779
|
target.selfBaseTime = source.selfBaseTime;
|
|
1762
1780
|
target.treeBaseTime = source.treeBaseTime;
|
|
1763
1781
|
}
|
|
@@ -3183,9 +3201,9 @@ function markActualRenderTimeStarted(fiber) {
|
|
|
3183
3201
|
{
|
|
3184
3202
|
fiberStack$1.push(fiber);
|
|
3185
3203
|
}
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3204
|
+
|
|
3205
|
+
fiber.actualDuration = now() - fiber.actualDuration - totalElapsedPauseTime;
|
|
3206
|
+
fiber.actualStartTime = now();
|
|
3189
3207
|
}
|
|
3190
3208
|
|
|
3191
3209
|
function pauseActualRenderTimerIfRunning() {
|
|
@@ -3202,10 +3220,10 @@ function recordElapsedActualRenderTime(fiber) {
|
|
|
3202
3220
|
return;
|
|
3203
3221
|
}
|
|
3204
3222
|
{
|
|
3205
|
-
!(fiber === fiberStack$1.pop()) ? warning(false, 'Unexpected Fiber popped.') : void 0;
|
|
3223
|
+
!(fiber === fiberStack$1.pop()) ? warning(false, 'Unexpected Fiber (%s) popped.', getComponentName(fiber)) : void 0;
|
|
3206
3224
|
}
|
|
3207
|
-
|
|
3208
|
-
|
|
3225
|
+
|
|
3226
|
+
fiber.actualDuration = now() - totalElapsedPauseTime - fiber.actualDuration;
|
|
3209
3227
|
}
|
|
3210
3228
|
|
|
3211
3229
|
function resetActualRenderTimer() {
|
|
@@ -3812,10 +3830,8 @@ function updateClassInstance(current, workInProgress, renderExpirationTime) {
|
|
|
3812
3830
|
}
|
|
3813
3831
|
|
|
3814
3832
|
if (typeof getDerivedStateFromProps === 'function') {
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
newState = workInProgress.memoizedState;
|
|
3818
|
-
}
|
|
3833
|
+
applyDerivedStateFromProps(workInProgress, getDerivedStateFromProps, newProps);
|
|
3834
|
+
newState = workInProgress.memoizedState;
|
|
3819
3835
|
}
|
|
3820
3836
|
|
|
3821
3837
|
var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress, oldProps, newProps, oldState, newState, newContext);
|
|
@@ -4697,7 +4713,8 @@ function ChildReconciler(shouldTrackSideEffects) {
|
|
|
4697
4713
|
// Handle top level unkeyed fragments as if they were arrays.
|
|
4698
4714
|
// This leads to an ambiguity between <>{[...]}</> and <>...</>.
|
|
4699
4715
|
// We treat the ambiguous cases above the same.
|
|
4700
|
-
|
|
4716
|
+
var isUnkeyedTopLevelFragment = typeof newChild === 'object' && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
|
|
4717
|
+
if (isUnkeyedTopLevelFragment) {
|
|
4701
4718
|
newChild = newChild.props.children;
|
|
4702
4719
|
}
|
|
4703
4720
|
|
|
@@ -4734,7 +4751,7 @@ function ChildReconciler(shouldTrackSideEffects) {
|
|
|
4734
4751
|
warnOnFunctionType();
|
|
4735
4752
|
}
|
|
4736
4753
|
}
|
|
4737
|
-
if (typeof newChild === 'undefined') {
|
|
4754
|
+
if (typeof newChild === 'undefined' && !isUnkeyedTopLevelFragment) {
|
|
4738
4755
|
// If the new child is undefined, and the return fiber is a composite
|
|
4739
4756
|
// component, throw an error. If Fiber return types are disabled,
|
|
4740
4757
|
// we already threw above.
|
|
@@ -5146,11 +5163,6 @@ function updateMode(current, workInProgress) {
|
|
|
5146
5163
|
function updateProfiler(current, workInProgress) {
|
|
5147
5164
|
var nextProps = workInProgress.pendingProps;
|
|
5148
5165
|
if (enableProfilerTimer) {
|
|
5149
|
-
// Start render timer here and push start time onto queue
|
|
5150
|
-
markActualRenderTimeStarted(workInProgress);
|
|
5151
|
-
|
|
5152
|
-
// Let the "complete" phase know to stop the timer,
|
|
5153
|
-
// And the scheduler to record the measured time.
|
|
5154
5166
|
workInProgress.effectTag |= Update;
|
|
5155
5167
|
}
|
|
5156
5168
|
if (workInProgress.memoizedProps === nextProps) {
|
|
@@ -5858,11 +5870,6 @@ function bailoutOnLowPriority(current, workInProgress) {
|
|
|
5858
5870
|
case ContextProvider:
|
|
5859
5871
|
pushProvider(workInProgress);
|
|
5860
5872
|
break;
|
|
5861
|
-
case Profiler:
|
|
5862
|
-
if (enableProfilerTimer) {
|
|
5863
|
-
markActualRenderTimeStarted(workInProgress);
|
|
5864
|
-
}
|
|
5865
|
-
break;
|
|
5866
5873
|
}
|
|
5867
5874
|
// TODO: What if this is currently in progress?
|
|
5868
5875
|
// How can that happen? How is this not being cloned?
|
|
@@ -5881,6 +5888,12 @@ function memoizeState(workInProgress, nextState) {
|
|
|
5881
5888
|
}
|
|
5882
5889
|
|
|
5883
5890
|
function beginWork(current, workInProgress, renderExpirationTime) {
|
|
5891
|
+
if (enableProfilerTimer) {
|
|
5892
|
+
if (workInProgress.mode & ProfileMode) {
|
|
5893
|
+
markActualRenderTimeStarted(workInProgress);
|
|
5894
|
+
}
|
|
5895
|
+
}
|
|
5896
|
+
|
|
5884
5897
|
if (workInProgress.expirationTime === NoWork || workInProgress.expirationTime > renderExpirationTime) {
|
|
5885
5898
|
return bailoutOnLowPriority(current, workInProgress);
|
|
5886
5899
|
}
|
|
@@ -6085,6 +6098,13 @@ if (supportsMutation) {
|
|
|
6085
6098
|
|
|
6086
6099
|
function completeWork(current, workInProgress, renderExpirationTime) {
|
|
6087
6100
|
var newProps = workInProgress.pendingProps;
|
|
6101
|
+
|
|
6102
|
+
if (enableProfilerTimer) {
|
|
6103
|
+
if (workInProgress.mode & ProfileMode) {
|
|
6104
|
+
recordElapsedActualRenderTime(workInProgress);
|
|
6105
|
+
}
|
|
6106
|
+
}
|
|
6107
|
+
|
|
6088
6108
|
switch (workInProgress.tag) {
|
|
6089
6109
|
case FunctionalComponent:
|
|
6090
6110
|
return null;
|
|
@@ -6217,9 +6237,6 @@ function completeWork(current, workInProgress, renderExpirationTime) {
|
|
|
6217
6237
|
case Mode:
|
|
6218
6238
|
return null;
|
|
6219
6239
|
case Profiler:
|
|
6220
|
-
if (enableProfilerTimer) {
|
|
6221
|
-
recordElapsedActualRenderTime(workInProgress);
|
|
6222
|
-
}
|
|
6223
6240
|
return null;
|
|
6224
6241
|
case HostPortal:
|
|
6225
6242
|
popHostContainer(workInProgress);
|
|
@@ -6947,11 +6964,7 @@ function commitWork(current, finishedWork) {
|
|
|
6947
6964
|
{
|
|
6948
6965
|
if (enableProfilerTimer) {
|
|
6949
6966
|
var onRender = finishedWork.memoizedProps.onRender;
|
|
6950
|
-
onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.
|
|
6951
|
-
|
|
6952
|
-
// Reset actualTime after successful commit.
|
|
6953
|
-
// By default, we append to this time to account for errors and pauses.
|
|
6954
|
-
finishedWork.stateNode.duration = 0;
|
|
6967
|
+
onRender(finishedWork.memoizedProps.id, current === null ? 'mount' : 'update', finishedWork.actualDuration, finishedWork.treeBaseTime, finishedWork.actualStartTime, getCommitTime());
|
|
6955
6968
|
}
|
|
6956
6969
|
return;
|
|
6957
6970
|
}
|
|
@@ -7158,6 +7171,12 @@ function throwException(root, returnFiber, sourceFiber, value, renderIsExpired,
|
|
|
7158
7171
|
}
|
|
7159
7172
|
|
|
7160
7173
|
function unwindWork(workInProgress, renderIsExpired, renderExpirationTime) {
|
|
7174
|
+
if (enableProfilerTimer) {
|
|
7175
|
+
if (workInProgress.mode & ProfileMode) {
|
|
7176
|
+
recordElapsedActualRenderTime(workInProgress);
|
|
7177
|
+
}
|
|
7178
|
+
}
|
|
7179
|
+
|
|
7161
7180
|
switch (workInProgress.tag) {
|
|
7162
7181
|
case ClassComponent:
|
|
7163
7182
|
{
|
|
@@ -7206,6 +7225,14 @@ function unwindWork(workInProgress, renderIsExpired, renderExpirationTime) {
|
|
|
7206
7225
|
}
|
|
7207
7226
|
|
|
7208
7227
|
function unwindInterruptedWork(interruptedWork) {
|
|
7228
|
+
if (enableProfilerTimer) {
|
|
7229
|
+
if (interruptedWork.mode & ProfileMode) {
|
|
7230
|
+
// Resume in case we're picking up on work that was paused.
|
|
7231
|
+
resumeActualRenderTimerIfPaused();
|
|
7232
|
+
recordElapsedActualRenderTime(interruptedWork);
|
|
7233
|
+
}
|
|
7234
|
+
}
|
|
7235
|
+
|
|
7209
7236
|
switch (interruptedWork.tag) {
|
|
7210
7237
|
case ClassComponent:
|
|
7211
7238
|
{
|
|
@@ -7229,13 +7256,6 @@ function unwindInterruptedWork(interruptedWork) {
|
|
|
7229
7256
|
case ContextProvider:
|
|
7230
7257
|
popProvider(interruptedWork);
|
|
7231
7258
|
break;
|
|
7232
|
-
case Profiler:
|
|
7233
|
-
if (enableProfilerTimer) {
|
|
7234
|
-
// Resume in case we're picking up on work that was paused.
|
|
7235
|
-
resumeActualRenderTimerIfPaused();
|
|
7236
|
-
recordElapsedActualRenderTime(interruptedWork);
|
|
7237
|
-
}
|
|
7238
|
-
break;
|
|
7239
7259
|
default:
|
|
7240
7260
|
break;
|
|
7241
7261
|
}
|
|
@@ -7372,6 +7392,10 @@ if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) {
|
|
|
7372
7392
|
clearCaughtError();
|
|
7373
7393
|
|
|
7374
7394
|
if (enableProfilerTimer) {
|
|
7395
|
+
if (failedUnitOfWork.mode & ProfileMode) {
|
|
7396
|
+
recordElapsedActualRenderTime(failedUnitOfWork);
|
|
7397
|
+
}
|
|
7398
|
+
|
|
7375
7399
|
// Stop "base" render timer again (after the re-thrown error).
|
|
7376
7400
|
stopBaseRenderTimerIfRunning();
|
|
7377
7401
|
}
|
|
@@ -7605,6 +7629,8 @@ function commitRoot(finishedWork) {
|
|
|
7605
7629
|
stopCommitSnapshotEffectsTimer();
|
|
7606
7630
|
|
|
7607
7631
|
if (enableProfilerTimer) {
|
|
7632
|
+
// Mark the current commit time to be shared by all Profilers in this batch.
|
|
7633
|
+
// This enables them to be grouped later.
|
|
7608
7634
|
recordCommitTime();
|
|
7609
7635
|
}
|
|
7610
7636
|
|
|
@@ -8133,7 +8159,7 @@ function captureCommitPhaseError(fiber, error) {
|
|
|
8133
8159
|
function computeAsyncExpiration(currentTime) {
|
|
8134
8160
|
// Given the current clock time, returns an expiration time. We use rounding
|
|
8135
8161
|
// to batch like updates together.
|
|
8136
|
-
// Should complete within ~
|
|
8162
|
+
// Should complete within ~5000ms. 5250ms max.
|
|
8137
8163
|
var expirationMs = 5000;
|
|
8138
8164
|
var bucketSizeMs = 250;
|
|
8139
8165
|
return computeExpirationBucket(currentTime, expirationMs, bucketSizeMs);
|
|
@@ -8288,7 +8314,7 @@ var firstScheduledRoot = null;
|
|
|
8288
8314
|
var lastScheduledRoot = null;
|
|
8289
8315
|
|
|
8290
8316
|
var callbackExpirationTime = NoWork;
|
|
8291
|
-
var callbackID =
|
|
8317
|
+
var callbackID = void 0;
|
|
8292
8318
|
var isRendering = false;
|
|
8293
8319
|
var nextFlushedRoot = null;
|
|
8294
8320
|
var nextFlushedExpirationTime = NoWork;
|
|
@@ -8316,9 +8342,11 @@ function scheduleCallbackWithExpiration(expirationTime) {
|
|
|
8316
8342
|
// Existing callback has sufficient timeout. Exit.
|
|
8317
8343
|
return;
|
|
8318
8344
|
} else {
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
|
|
8345
|
+
if (callbackID !== null) {
|
|
8346
|
+
// Existing callback has insufficient timeout. Cancel and schedule a
|
|
8347
|
+
// new one.
|
|
8348
|
+
cancelDeferredCallback(callbackID);
|
|
8349
|
+
}
|
|
8322
8350
|
}
|
|
8323
8351
|
// The request callback timer is already running. Don't start a new one.
|
|
8324
8352
|
} else {
|
|
@@ -8507,7 +8535,7 @@ function performWork(minExpirationTime, isAsync, dl) {
|
|
|
8507
8535
|
// If we're inside a callback, set this to false since we just completed it.
|
|
8508
8536
|
if (deadline !== null) {
|
|
8509
8537
|
callbackExpirationTime = NoWork;
|
|
8510
|
-
callbackID =
|
|
8538
|
+
callbackID = null;
|
|
8511
8539
|
}
|
|
8512
8540
|
// If there's work left over, schedule a new callback.
|
|
8513
8541
|
if (nextFlushedExpirationTime !== NoWork) {
|
|
@@ -8561,7 +8589,6 @@ function performWorkOnRoot(root, expirationTime, isAsync) {
|
|
|
8561
8589
|
// This root is already complete. We can commit it.
|
|
8562
8590
|
completeRoot(root, finishedWork, expirationTime);
|
|
8563
8591
|
} else {
|
|
8564
|
-
root.finishedWork = null;
|
|
8565
8592
|
finishedWork = renderRoot(root, expirationTime, false);
|
|
8566
8593
|
if (finishedWork !== null) {
|
|
8567
8594
|
// We've completed the root. Commit it.
|
|
@@ -8575,7 +8602,6 @@ function performWorkOnRoot(root, expirationTime, isAsync) {
|
|
|
8575
8602
|
// This root is already complete. We can commit it.
|
|
8576
8603
|
completeRoot(root, _finishedWork, expirationTime);
|
|
8577
8604
|
} else {
|
|
8578
|
-
root.finishedWork = null;
|
|
8579
8605
|
_finishedWork = renderRoot(root, expirationTime, true);
|
|
8580
8606
|
if (_finishedWork !== null) {
|
|
8581
8607
|
// We've completed the root. Check the deadline one more time
|
|
@@ -9035,7 +9061,44 @@ function wrapFiber(fiber) {
|
|
|
9035
9061
|
return wrapper;
|
|
9036
9062
|
}
|
|
9037
9063
|
|
|
9038
|
-
var validWrapperTypes = new Set([FunctionalComponent, ClassComponent, HostComponent, ForwardRef
|
|
9064
|
+
var validWrapperTypes = new Set([FunctionalComponent, ClassComponent, HostComponent, ForwardRef,
|
|
9065
|
+
// Normally skipped, but used when there's more than one root child.
|
|
9066
|
+
HostRoot]);
|
|
9067
|
+
|
|
9068
|
+
function getChildren(parent) {
|
|
9069
|
+
var children = [];
|
|
9070
|
+
var startingNode = parent;
|
|
9071
|
+
var node = startingNode;
|
|
9072
|
+
if (node.child === null) {
|
|
9073
|
+
return children;
|
|
9074
|
+
}
|
|
9075
|
+
node.child.return = node;
|
|
9076
|
+
node = node.child;
|
|
9077
|
+
outer: while (true) {
|
|
9078
|
+
var descend = false;
|
|
9079
|
+
if (validWrapperTypes.has(node.tag)) {
|
|
9080
|
+
children.push(wrapFiber(node));
|
|
9081
|
+
} else if (node.tag === HostText) {
|
|
9082
|
+
children.push('' + node.memoizedProps);
|
|
9083
|
+
} else {
|
|
9084
|
+
descend = true;
|
|
9085
|
+
}
|
|
9086
|
+
if (descend && node.child !== null) {
|
|
9087
|
+
node.child.return = node;
|
|
9088
|
+
node = node.child;
|
|
9089
|
+
continue;
|
|
9090
|
+
}
|
|
9091
|
+
while (node.sibling === null) {
|
|
9092
|
+
if (node.return === startingNode) {
|
|
9093
|
+
break outer;
|
|
9094
|
+
}
|
|
9095
|
+
node = node.return;
|
|
9096
|
+
}
|
|
9097
|
+
node.sibling.return = node.return;
|
|
9098
|
+
node = node.sibling;
|
|
9099
|
+
}
|
|
9100
|
+
return children;
|
|
9101
|
+
}
|
|
9039
9102
|
|
|
9040
9103
|
var ReactTestInstance = function () {
|
|
9041
9104
|
ReactTestInstance.prototype._currentFiber = function _currentFiber() {
|
|
@@ -9112,6 +9175,13 @@ var ReactTestInstance = function () {
|
|
|
9112
9175
|
var parent = this._fiber.return;
|
|
9113
9176
|
while (parent !== null) {
|
|
9114
9177
|
if (validWrapperTypes.has(parent.tag)) {
|
|
9178
|
+
if (parent.tag === HostRoot) {
|
|
9179
|
+
// Special case: we only "materialize" instances for roots
|
|
9180
|
+
// if they have more than a single child. So we'll check that now.
|
|
9181
|
+
if (getChildren(parent).length < 2) {
|
|
9182
|
+
return null;
|
|
9183
|
+
}
|
|
9184
|
+
}
|
|
9115
9185
|
return wrapFiber(parent);
|
|
9116
9186
|
}
|
|
9117
9187
|
parent = parent.return;
|
|
@@ -9121,38 +9191,7 @@ var ReactTestInstance = function () {
|
|
|
9121
9191
|
}, {
|
|
9122
9192
|
key: 'children',
|
|
9123
9193
|
get: function () {
|
|
9124
|
-
|
|
9125
|
-
var startingNode = this._currentFiber();
|
|
9126
|
-
var node = startingNode;
|
|
9127
|
-
if (node.child === null) {
|
|
9128
|
-
return children;
|
|
9129
|
-
}
|
|
9130
|
-
node.child.return = node;
|
|
9131
|
-
node = node.child;
|
|
9132
|
-
outer: while (true) {
|
|
9133
|
-
var descend = false;
|
|
9134
|
-
if (validWrapperTypes.has(node.tag)) {
|
|
9135
|
-
children.push(wrapFiber(node));
|
|
9136
|
-
} else if (node.tag === HostText) {
|
|
9137
|
-
children.push('' + node.memoizedProps);
|
|
9138
|
-
} else {
|
|
9139
|
-
descend = true;
|
|
9140
|
-
}
|
|
9141
|
-
if (descend && node.child !== null) {
|
|
9142
|
-
node.child.return = node;
|
|
9143
|
-
node = node.child;
|
|
9144
|
-
continue;
|
|
9145
|
-
}
|
|
9146
|
-
while (node.sibling === null) {
|
|
9147
|
-
if (node.return === startingNode) {
|
|
9148
|
-
break outer;
|
|
9149
|
-
}
|
|
9150
|
-
node = node.return;
|
|
9151
|
-
}
|
|
9152
|
-
node.sibling.return = node.return;
|
|
9153
|
-
node = node.sibling;
|
|
9154
|
-
}
|
|
9155
|
-
return children;
|
|
9194
|
+
return getChildren(this._currentFiber());
|
|
9156
9195
|
}
|
|
9157
9196
|
}]);
|
|
9158
9197
|
|
|
@@ -9277,10 +9316,20 @@ var ReactTestRendererFiber = {
|
|
|
9277
9316
|
configurable: true,
|
|
9278
9317
|
enumerable: true,
|
|
9279
9318
|
get: function () {
|
|
9280
|
-
if (root === null
|
|
9319
|
+
if (root === null) {
|
|
9281
9320
|
throw new Error("Can't access .root on unmounted test renderer");
|
|
9282
9321
|
}
|
|
9283
|
-
|
|
9322
|
+
var children = getChildren(root.current);
|
|
9323
|
+
if (children.length === 0) {
|
|
9324
|
+
throw new Error("Can't access .root on unmounted test renderer");
|
|
9325
|
+
} else if (children.length === 1) {
|
|
9326
|
+
// Normally, we skip the root and just give you the child.
|
|
9327
|
+
return children[0];
|
|
9328
|
+
} else {
|
|
9329
|
+
// However, we give you the root if there's more than one root child.
|
|
9330
|
+
// We could make this the behavior for all cases but it would be a breaking change.
|
|
9331
|
+
return wrapFiber(root.current);
|
|
9332
|
+
}
|
|
9284
9333
|
}
|
|
9285
9334
|
});
|
|
9286
9335
|
|