react 15.1.0 → 15.2.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/dist/react-with-addons.js +2685 -1842
- package/dist/react-with-addons.min.js +6 -6
- package/dist/react.js +2400 -1691
- package/dist/react.min.js +6 -6
- package/lib/CSSPropertyOperations.js +1 -1
- package/lib/CallbackQueue.js +3 -2
- package/lib/DOMChildrenOperations.js +9 -9
- package/lib/DOMLazyTree.js +3 -2
- package/lib/DOMProperty.js +5 -12
- package/lib/DOMPropertyOperations.js +21 -15
- package/lib/Danger.js +5 -101
- package/lib/DisabledInputUtils.js +5 -5
- package/lib/EventPluginHub.js +8 -2
- package/lib/EventPluginRegistry.js +13 -7
- package/lib/EventPluginUtils.js +3 -1
- package/lib/HTMLDOMPropertyConfig.js +1 -2
- package/lib/KeyEscapeUtils.js +2 -1
- package/lib/LinkedValueUtils.js +5 -3
- package/lib/NativeMethodsMixin.js +6 -4
- package/lib/PooledClass.js +4 -2
- package/lib/React.js +1 -1
- package/lib/ReactCSSTransitionGroupChild.js +15 -8
- package/lib/ReactChildReconciler.js +17 -8
- package/lib/ReactClass.js +14 -13
- package/lib/ReactComponent.js +3 -6
- package/lib/ReactComponentEnvironment.js +3 -1
- package/lib/ReactComponentTreeDevtool.js +89 -16
- package/lib/ReactComponentTreeTestUtils.js +87 -0
- package/lib/ReactCompositeComponent.js +87 -117
- package/lib/ReactDOM.js +2 -2
- package/lib/ReactDOMButton.js +2 -2
- package/lib/ReactDOMComponent.js +130 -76
- package/lib/ReactDOMComponentTree.js +23 -21
- package/lib/ReactDOMDebugTool.js +17 -11
- package/lib/ReactDOMEmptyComponent.js +9 -9
- package/lib/ReactDOMFactories.js +1 -1
- package/lib/ReactDOMFiber.js +78 -0
- package/lib/ReactDOMInput.js +64 -26
- package/lib/ReactDOMInstrumentation.js +7 -2
- package/lib/ReactDOMNullInputValuePropDevtool.js +43 -0
- package/lib/ReactDOMOption.js +40 -26
- package/lib/ReactDOMSelect.js +3 -16
- package/lib/ReactDOMTextComponent.js +21 -20
- package/lib/ReactDOMTextarea.js +59 -46
- package/lib/ReactDOMTreeTraversal.js +18 -16
- package/lib/ReactDOMUnknownPropertyDevtool.js +65 -17
- package/lib/ReactDebugTool.js +148 -95
- package/lib/ReactDefaultInjection.js +2 -2
- package/lib/ReactElement.js +64 -25
- package/lib/ReactElementValidator.js +26 -81
- package/lib/ReactEventListener.js +2 -2
- package/lib/ReactFeatureFlags.js +1 -0
- package/lib/ReactFragment.js +3 -1
- package/lib/{ReactNativeComponent.js → ReactHostComponent.js} +10 -29
- package/lib/{ReactNativeOperationHistoryDevtool.js → ReactHostOperationHistoryDevtool.js} +5 -5
- package/lib/ReactInjection.js +2 -2
- package/lib/ReactInstanceHandles.js +8 -6
- package/lib/ReactInstrumentation.js +7 -2
- package/lib/ReactMount.js +38 -32
- package/lib/ReactMultiChild.js +38 -11
- package/lib/ReactNativeAttributePayload.js +5 -2
- package/lib/ReactNativeBaseComponent.js +7 -7
- package/lib/ReactNativeBridgeEventPlugin.js +1 -1
- package/lib/ReactNativeComponentTree.js +8 -6
- package/lib/ReactNativeDOMIDOperations.js +1 -2
- package/lib/ReactNativeDefaultInjection.js +9 -7
- package/lib/ReactNativeGlobalResponderHandler.js +1 -1
- package/lib/ReactNativeMount.js +3 -14
- package/lib/ReactNativeReconcileTransaction.js +16 -0
- package/lib/ReactNativeTagHandles.js +3 -1
- package/lib/ReactNativeTextComponent.js +10 -9
- package/lib/ReactNativeTreeTraversal.js +11 -11
- package/lib/ReactNodeTypes.js +6 -3
- package/lib/ReactNoop.js +173 -0
- package/lib/ReactNoopUpdateQueue.js +6 -5
- package/lib/ReactOwner.js +4 -2
- package/lib/ReactPerf.js +83 -7
- package/lib/ReactPropTypes.js +23 -0
- package/lib/ReactReconcileTransaction.js +17 -1
- package/lib/ReactReconciler.js +12 -7
- package/lib/ReactServerRendering.js +5 -7
- package/lib/ReactServerRenderingTransaction.js +17 -0
- package/lib/ReactServerUpdateQueue.js +141 -0
- package/lib/ReactSimpleEmptyComponent.js +4 -4
- package/lib/ReactTestMount.js +115 -0
- package/lib/ReactTestReconcileTransaction.js +108 -0
- package/lib/ReactTestRenderer.js +133 -0
- package/lib/ReactTestUtils.js +17 -10
- package/lib/ReactTransitionChildMapping.js +7 -1
- package/lib/ReactTransitionGroup.js +41 -6
- package/lib/ReactUpdateQueue.js +13 -3
- package/lib/ReactUpdates.js +10 -18
- package/lib/ReactVersion.js +1 -1
- package/lib/ResponderEventPlugin.js +9 -7
- package/lib/ResponderTouchHistoryStore.js +99 -95
- package/lib/SimpleEventPlugin.js +3 -1
- package/lib/SyntheticEvent.js +2 -3
- package/lib/SyntheticUIEvent.js +1 -1
- package/lib/Transaction.js +4 -2
- package/lib/accumulate.js +17 -15
- package/lib/accumulateInto.js +11 -12
- package/lib/adler32.js +1 -0
- package/lib/checkReactTypeSpec.js +73 -0
- package/lib/createReactNativeComponentClass.js +2 -2
- package/lib/dangerousStyleValue.js +3 -1
- package/lib/deprecated.js +7 -1
- package/lib/escapeTextContentForBrowser.js +96 -12
- package/lib/findDOMNode.js +6 -4
- package/lib/findNodeHandle.js +5 -3
- package/lib/flattenChildren.js +22 -10
- package/lib/forEachAccumulated.js +3 -2
- package/lib/{getNativeComponentFromComposite.js → getHostComponentFromComposite.js} +4 -4
- package/lib/getIteratorFn.js +1 -0
- package/lib/instantiateReactComponent.js +21 -19
- package/lib/isTextInputElement.js +11 -1
- package/lib/onlyChild.js +3 -1
- package/lib/reactComponentExpect.js +3 -3
- package/lib/reactProdInvariant.js +39 -0
- package/lib/setInnerHTML.js +17 -1
- package/lib/setTextContent.js +8 -0
- package/lib/traverseAllChildren.js +3 -1
- package/lib/update.js +12 -11
- package/package.json +2 -2
- package/lib/MetaMatchers.js +0 -118
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var _prodInvariant = require('./reactProdInvariant');
|
|
15
|
+
|
|
14
16
|
var invariant = require('fbjs/lib/invariant');
|
|
15
17
|
|
|
16
18
|
/**
|
|
@@ -18,27 +20,27 @@ var invariant = require('fbjs/lib/invariant');
|
|
|
18
20
|
* different trees.
|
|
19
21
|
*/
|
|
20
22
|
function getLowestCommonAncestor(instA, instB) {
|
|
21
|
-
!('
|
|
22
|
-
!('
|
|
23
|
+
!('_hostNode' in instA) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromInstance: Invalid argument.') : _prodInvariant('33') : void 0;
|
|
24
|
+
!('_hostNode' in instB) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNodeFromInstance: Invalid argument.') : _prodInvariant('33') : void 0;
|
|
23
25
|
|
|
24
26
|
var depthA = 0;
|
|
25
|
-
for (var tempA = instA; tempA; tempA = tempA.
|
|
27
|
+
for (var tempA = instA; tempA; tempA = tempA._hostParent) {
|
|
26
28
|
depthA++;
|
|
27
29
|
}
|
|
28
30
|
var depthB = 0;
|
|
29
|
-
for (var tempB = instB; tempB; tempB = tempB.
|
|
31
|
+
for (var tempB = instB; tempB; tempB = tempB._hostParent) {
|
|
30
32
|
depthB++;
|
|
31
33
|
}
|
|
32
34
|
|
|
33
35
|
// If A is deeper, crawl up.
|
|
34
36
|
while (depthA - depthB > 0) {
|
|
35
|
-
instA = instA.
|
|
37
|
+
instA = instA._hostParent;
|
|
36
38
|
depthA--;
|
|
37
39
|
}
|
|
38
40
|
|
|
39
41
|
// If B is deeper, crawl up.
|
|
40
42
|
while (depthB - depthA > 0) {
|
|
41
|
-
instB = instB.
|
|
43
|
+
instB = instB._hostParent;
|
|
42
44
|
depthB--;
|
|
43
45
|
}
|
|
44
46
|
|
|
@@ -48,8 +50,8 @@ function getLowestCommonAncestor(instA, instB) {
|
|
|
48
50
|
if (instA === instB) {
|
|
49
51
|
return instA;
|
|
50
52
|
}
|
|
51
|
-
instA = instA.
|
|
52
|
-
instB = instB.
|
|
53
|
+
instA = instA._hostParent;
|
|
54
|
+
instB = instB._hostParent;
|
|
53
55
|
}
|
|
54
56
|
return null;
|
|
55
57
|
}
|
|
@@ -58,14 +60,14 @@ function getLowestCommonAncestor(instA, instB) {
|
|
|
58
60
|
* Return if A is an ancestor of B.
|
|
59
61
|
*/
|
|
60
62
|
function isAncestor(instA, instB) {
|
|
61
|
-
!('
|
|
62
|
-
!('
|
|
63
|
+
!('_hostNode' in instA) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'isAncestor: Invalid argument.') : _prodInvariant('35') : void 0;
|
|
64
|
+
!('_hostNode' in instB) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'isAncestor: Invalid argument.') : _prodInvariant('35') : void 0;
|
|
63
65
|
|
|
64
66
|
while (instB) {
|
|
65
67
|
if (instB === instA) {
|
|
66
68
|
return true;
|
|
67
69
|
}
|
|
68
|
-
instB = instB.
|
|
70
|
+
instB = instB._hostParent;
|
|
69
71
|
}
|
|
70
72
|
return false;
|
|
71
73
|
}
|
|
@@ -74,9 +76,9 @@ function isAncestor(instA, instB) {
|
|
|
74
76
|
* Return the parent instance of the passed-in instance.
|
|
75
77
|
*/
|
|
76
78
|
function getParentInstance(inst) {
|
|
77
|
-
!('
|
|
79
|
+
!('_hostNode' in inst) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getParentInstance: Invalid argument.') : _prodInvariant('36') : void 0;
|
|
78
80
|
|
|
79
|
-
return inst.
|
|
81
|
+
return inst._hostParent;
|
|
80
82
|
}
|
|
81
83
|
|
|
82
84
|
/**
|
|
@@ -86,7 +88,7 @@ function traverseTwoPhase(inst, fn, arg) {
|
|
|
86
88
|
var path = [];
|
|
87
89
|
while (inst) {
|
|
88
90
|
path.push(inst);
|
|
89
|
-
inst = inst.
|
|
91
|
+
inst = inst._hostParent;
|
|
90
92
|
}
|
|
91
93
|
var i;
|
|
92
94
|
for (i = path.length; i-- > 0;) {
|
|
@@ -109,12 +111,12 @@ function traverseEnterLeave(from, to, fn, argFrom, argTo) {
|
|
|
109
111
|
var pathFrom = [];
|
|
110
112
|
while (from && from !== common) {
|
|
111
113
|
pathFrom.push(from);
|
|
112
|
-
from = from.
|
|
114
|
+
from = from._hostParent;
|
|
113
115
|
}
|
|
114
116
|
var pathTo = [];
|
|
115
117
|
while (to && to !== common) {
|
|
116
118
|
pathTo.push(to);
|
|
117
|
-
to = to.
|
|
119
|
+
to = to._hostParent;
|
|
118
120
|
}
|
|
119
121
|
var i;
|
|
120
122
|
for (i = 0; i < pathFrom.length; i++) {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
var DOMProperty = require('./DOMProperty');
|
|
15
15
|
var EventPluginRegistry = require('./EventPluginRegistry');
|
|
16
|
+
var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
|
|
16
17
|
|
|
17
18
|
var warning = require('fbjs/lib/warning');
|
|
18
19
|
|
|
@@ -21,43 +22,90 @@ if (process.env.NODE_ENV !== 'production') {
|
|
|
21
22
|
children: true,
|
|
22
23
|
dangerouslySetInnerHTML: true,
|
|
23
24
|
key: true,
|
|
24
|
-
ref: true
|
|
25
|
+
ref: true,
|
|
26
|
+
|
|
27
|
+
autoFocus: true,
|
|
28
|
+
defaultValue: true,
|
|
29
|
+
valueLink: true,
|
|
30
|
+
defaultChecked: true,
|
|
31
|
+
checkedLink: true,
|
|
32
|
+
innerHTML: true,
|
|
33
|
+
suppressContentEditableWarning: true,
|
|
34
|
+
onFocusIn: true,
|
|
35
|
+
onFocusOut: true
|
|
25
36
|
};
|
|
26
37
|
var warnedProperties = {};
|
|
27
38
|
|
|
28
|
-
var
|
|
39
|
+
var validateProperty = function (tagName, name, debugID) {
|
|
29
40
|
if (DOMProperty.properties.hasOwnProperty(name) || DOMProperty.isCustomAttribute(name)) {
|
|
30
|
-
return;
|
|
41
|
+
return true;
|
|
31
42
|
}
|
|
32
43
|
if (reactProps.hasOwnProperty(name) && reactProps[name] || warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
|
|
33
|
-
return;
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
if (EventPluginRegistry.registrationNameModules.hasOwnProperty(name)) {
|
|
47
|
+
return true;
|
|
34
48
|
}
|
|
35
|
-
|
|
36
49
|
warnedProperties[name] = true;
|
|
37
50
|
var lowerCasedName = name.toLowerCase();
|
|
38
51
|
|
|
39
52
|
// data-* attributes should be lowercase; suggest the lowercase version
|
|
40
53
|
var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ? lowerCasedName : DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty.getPossibleStandardName[lowerCasedName] : null;
|
|
41
54
|
|
|
42
|
-
// For now, only warn when we have a suggested correction. This prevents
|
|
43
|
-
// logging too much when using transferPropsTo.
|
|
44
|
-
process.env.NODE_ENV !== 'production' ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?', name, standardName) : void 0;
|
|
45
|
-
|
|
46
55
|
var registrationName = EventPluginRegistry.possibleRegistrationNames.hasOwnProperty(lowerCasedName) ? EventPluginRegistry.possibleRegistrationNames[lowerCasedName] : null;
|
|
47
56
|
|
|
48
|
-
|
|
57
|
+
if (standardName != null) {
|
|
58
|
+
process.env.NODE_ENV !== 'production' ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?%s', name, standardName, ReactComponentTreeDevtool.getStackAddendumByID(debugID)) : void 0;
|
|
59
|
+
return true;
|
|
60
|
+
} else if (registrationName != null) {
|
|
61
|
+
process.env.NODE_ENV !== 'production' ? warning(registrationName == null, 'Unknown event handler property %s. Did you mean `%s`?%s', name, registrationName, ReactComponentTreeDevtool.getStackAddendumByID(debugID)) : void 0;
|
|
62
|
+
return true;
|
|
63
|
+
} else {
|
|
64
|
+
// We were unable to guess which prop the user intended.
|
|
65
|
+
// It is likely that the user was just blindly spreading/forwarding props
|
|
66
|
+
// Components should be careful to only render valid props/attributes.
|
|
67
|
+
// Warning will be invoked in warnUnknownProperties to allow grouping.
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
49
70
|
};
|
|
50
71
|
}
|
|
51
72
|
|
|
73
|
+
var warnUnknownProperties = function (debugID, element) {
|
|
74
|
+
var unknownProps = [];
|
|
75
|
+
for (var key in element.props) {
|
|
76
|
+
var isValid = validateProperty(element.type, key, debugID);
|
|
77
|
+
if (!isValid) {
|
|
78
|
+
unknownProps.push(key);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
var unknownPropString = unknownProps.map(function (prop) {
|
|
83
|
+
return '`' + prop + '`';
|
|
84
|
+
}).join(', ');
|
|
85
|
+
|
|
86
|
+
if (unknownProps.length === 1) {
|
|
87
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Unknown prop %s on <%s> tag. Remove this prop from the element. ' + 'For details, see https://fb.me/react-unknown-prop%s', unknownPropString, element.type, ReactComponentTreeDevtool.getStackAddendumByID(debugID)) : void 0;
|
|
88
|
+
} else if (unknownProps.length > 1) {
|
|
89
|
+
process.env.NODE_ENV !== 'production' ? warning(false, 'Unknown props %s on <%s> tag. Remove these props from the element. ' + 'For details, see https://fb.me/react-unknown-prop%s', unknownPropString, element.type, ReactComponentTreeDevtool.getStackAddendumByID(debugID)) : void 0;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
function handleElement(debugID, element) {
|
|
94
|
+
if (element == null || typeof element.type !== 'string') {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (element.type.indexOf('-') >= 0 || element.props.is) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
warnUnknownProperties(debugID, element);
|
|
101
|
+
}
|
|
102
|
+
|
|
52
103
|
var ReactDOMUnknownPropertyDevtool = {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
onSetValueForProperty: function (node, name, value) {
|
|
57
|
-
warnUnknownProperty(name);
|
|
104
|
+
onBeforeMountComponent: function (debugID, element) {
|
|
105
|
+
handleElement(debugID, element);
|
|
58
106
|
},
|
|
59
|
-
|
|
60
|
-
|
|
107
|
+
onBeforeUpdateComponent: function (debugID, element) {
|
|
108
|
+
handleElement(debugID, element);
|
|
61
109
|
}
|
|
62
110
|
};
|
|
63
111
|
|
package/lib/ReactDebugTool.js
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
'use strict';
|
|
13
13
|
|
|
14
|
+
var ReactInvalidSetStateWarningDevTool = require('./ReactInvalidSetStateWarningDevTool');
|
|
15
|
+
var ReactHostOperationHistoryDevtool = require('./ReactHostOperationHistoryDevtool');
|
|
16
|
+
var ReactComponentTreeDevtool = require('./ReactComponentTreeDevtool');
|
|
14
17
|
var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
|
|
15
18
|
|
|
16
19
|
var performanceNow = require('fbjs/lib/performanceNow');
|
|
@@ -20,32 +23,32 @@ var eventHandlers = [];
|
|
|
20
23
|
var handlerDoesThrowForEvent = {};
|
|
21
24
|
|
|
22
25
|
function emitEvent(handlerFunctionName, arg1, arg2, arg3, arg4, arg5) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
handler[handlerFunctionName](arg1, arg2, arg3, arg4, arg5);
|
|
28
|
-
}
|
|
29
|
-
} catch (e) {
|
|
30
|
-
process.env.NODE_ENV !== 'production' ? warning(!handlerDoesThrowForEvent[handlerFunctionName], 'exception thrown by devtool while handling %s: %s', handlerFunctionName, e.message) : void 0;
|
|
31
|
-
handlerDoesThrowForEvent[handlerFunctionName] = true;
|
|
26
|
+
eventHandlers.forEach(function (handler) {
|
|
27
|
+
try {
|
|
28
|
+
if (handler[handlerFunctionName]) {
|
|
29
|
+
handler[handlerFunctionName](arg1, arg2, arg3, arg4, arg5);
|
|
32
30
|
}
|
|
33
|
-
})
|
|
34
|
-
|
|
31
|
+
} catch (e) {
|
|
32
|
+
process.env.NODE_ENV !== 'production' ? warning(handlerDoesThrowForEvent[handlerFunctionName], 'exception thrown by devtool while handling %s: %s', handlerFunctionName, e + '\n' + e.stack) : void 0;
|
|
33
|
+
handlerDoesThrowForEvent[handlerFunctionName] = true;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
var isProfiling = false;
|
|
38
39
|
var flushHistory = [];
|
|
40
|
+
var lifeCycleTimerStack = [];
|
|
39
41
|
var currentFlushNesting = 0;
|
|
40
42
|
var currentFlushMeasurements = null;
|
|
41
43
|
var currentFlushStartTime = null;
|
|
42
44
|
var currentTimerDebugID = null;
|
|
43
45
|
var currentTimerStartTime = null;
|
|
46
|
+
var currentTimerNestedFlushDuration = null;
|
|
44
47
|
var currentTimerType = null;
|
|
45
48
|
|
|
46
49
|
function clearHistory() {
|
|
47
50
|
ReactComponentTreeDevtool.purgeUnmountedComponents();
|
|
48
|
-
|
|
51
|
+
ReactHostOperationHistoryDevtool.clearHistory();
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
function getTreeSnapshot(registeredIDs) {
|
|
@@ -66,38 +69,94 @@ function getTreeSnapshot(registeredIDs) {
|
|
|
66
69
|
}
|
|
67
70
|
|
|
68
71
|
function resetMeasurements() {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
var previousOperations = ReactNativeOperationHistoryDevtool.getHistory();
|
|
73
|
-
|
|
74
|
-
if (!isProfiling || currentFlushNesting === 0) {
|
|
75
|
-
currentFlushStartTime = null;
|
|
76
|
-
currentFlushMeasurements = null;
|
|
77
|
-
clearHistory();
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
if (previousMeasurements.length || previousOperations.length) {
|
|
82
|
-
var registeredIDs = ReactComponentTreeDevtool.getRegisteredIDs();
|
|
83
|
-
flushHistory.push({
|
|
84
|
-
duration: performanceNow() - previousStartTime,
|
|
85
|
-
measurements: previousMeasurements || [],
|
|
86
|
-
operations: previousOperations || [],
|
|
87
|
-
treeSnapshot: getTreeSnapshot(registeredIDs)
|
|
88
|
-
});
|
|
89
|
-
}
|
|
72
|
+
var previousStartTime = currentFlushStartTime;
|
|
73
|
+
var previousMeasurements = currentFlushMeasurements || [];
|
|
74
|
+
var previousOperations = ReactHostOperationHistoryDevtool.getHistory();
|
|
90
75
|
|
|
76
|
+
if (currentFlushNesting === 0) {
|
|
77
|
+
currentFlushStartTime = null;
|
|
78
|
+
currentFlushMeasurements = null;
|
|
91
79
|
clearHistory();
|
|
92
|
-
|
|
93
|
-
currentFlushMeasurements = [];
|
|
80
|
+
return;
|
|
94
81
|
}
|
|
82
|
+
|
|
83
|
+
if (previousMeasurements.length || previousOperations.length) {
|
|
84
|
+
var registeredIDs = ReactComponentTreeDevtool.getRegisteredIDs();
|
|
85
|
+
flushHistory.push({
|
|
86
|
+
duration: performanceNow() - previousStartTime,
|
|
87
|
+
measurements: previousMeasurements || [],
|
|
88
|
+
operations: previousOperations || [],
|
|
89
|
+
treeSnapshot: getTreeSnapshot(registeredIDs)
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
clearHistory();
|
|
94
|
+
currentFlushStartTime = performanceNow();
|
|
95
|
+
currentFlushMeasurements = [];
|
|
95
96
|
}
|
|
96
97
|
|
|
97
98
|
function checkDebugID(debugID) {
|
|
98
99
|
process.env.NODE_ENV !== 'production' ? warning(debugID, 'ReactDebugTool: debugID may not be empty.') : void 0;
|
|
99
100
|
}
|
|
100
101
|
|
|
102
|
+
function beginLifeCycleTimer(debugID, timerType) {
|
|
103
|
+
if (currentFlushNesting === 0) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
process.env.NODE_ENV !== 'production' ? warning(!currentTimerType, 'There is an internal error in the React performance measurement code. ' + 'Did not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another') : void 0;
|
|
107
|
+
currentTimerStartTime = performanceNow();
|
|
108
|
+
currentTimerNestedFlushDuration = 0;
|
|
109
|
+
currentTimerDebugID = debugID;
|
|
110
|
+
currentTimerType = timerType;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function endLifeCycleTimer(debugID, timerType) {
|
|
114
|
+
if (currentFlushNesting === 0) {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
process.env.NODE_ENV !== 'production' ? warning(currentTimerType === timerType, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another') : void 0;
|
|
118
|
+
if (isProfiling) {
|
|
119
|
+
currentFlushMeasurements.push({
|
|
120
|
+
timerType: timerType,
|
|
121
|
+
instanceID: debugID,
|
|
122
|
+
duration: performanceNow() - currentTimerStartTime - currentTimerNestedFlushDuration
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
currentTimerStartTime = null;
|
|
126
|
+
currentTimerNestedFlushDuration = null;
|
|
127
|
+
currentTimerDebugID = null;
|
|
128
|
+
currentTimerType = null;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function pauseCurrentLifeCycleTimer() {
|
|
132
|
+
var currentTimer = {
|
|
133
|
+
startTime: currentTimerStartTime,
|
|
134
|
+
nestedFlushStartTime: performanceNow(),
|
|
135
|
+
debugID: currentTimerDebugID,
|
|
136
|
+
timerType: currentTimerType
|
|
137
|
+
};
|
|
138
|
+
lifeCycleTimerStack.push(currentTimer);
|
|
139
|
+
currentTimerStartTime = null;
|
|
140
|
+
currentTimerNestedFlushDuration = null;
|
|
141
|
+
currentTimerDebugID = null;
|
|
142
|
+
currentTimerType = null;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function resumeCurrentLifeCycleTimer() {
|
|
146
|
+
var _lifeCycleTimerStack$ = lifeCycleTimerStack.pop();
|
|
147
|
+
|
|
148
|
+
var startTime = _lifeCycleTimerStack$.startTime;
|
|
149
|
+
var nestedFlushStartTime = _lifeCycleTimerStack$.nestedFlushStartTime;
|
|
150
|
+
var debugID = _lifeCycleTimerStack$.debugID;
|
|
151
|
+
var timerType = _lifeCycleTimerStack$.timerType;
|
|
152
|
+
|
|
153
|
+
var nestedFlushDuration = performanceNow() - nestedFlushStartTime;
|
|
154
|
+
currentTimerStartTime = startTime;
|
|
155
|
+
currentTimerNestedFlushDuration += nestedFlushDuration;
|
|
156
|
+
currentTimerDebugID = debugID;
|
|
157
|
+
currentTimerType = timerType;
|
|
158
|
+
}
|
|
159
|
+
|
|
101
160
|
var ReactDebugTool = {
|
|
102
161
|
addDevtool: function (devtool) {
|
|
103
162
|
eventHandlers.push(devtool);
|
|
@@ -110,73 +169,51 @@ var ReactDebugTool = {
|
|
|
110
169
|
}
|
|
111
170
|
}
|
|
112
171
|
},
|
|
172
|
+
isProfiling: function () {
|
|
173
|
+
return isProfiling;
|
|
174
|
+
},
|
|
113
175
|
beginProfiling: function () {
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
isProfiling = true;
|
|
120
|
-
flushHistory.length = 0;
|
|
121
|
-
resetMeasurements();
|
|
176
|
+
if (isProfiling) {
|
|
177
|
+
return;
|
|
122
178
|
}
|
|
179
|
+
|
|
180
|
+
isProfiling = true;
|
|
181
|
+
flushHistory.length = 0;
|
|
182
|
+
resetMeasurements();
|
|
183
|
+
ReactDebugTool.addDevtool(ReactHostOperationHistoryDevtool);
|
|
123
184
|
},
|
|
124
185
|
endProfiling: function () {
|
|
125
|
-
if (
|
|
126
|
-
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
isProfiling = false;
|
|
131
|
-
resetMeasurements();
|
|
186
|
+
if (!isProfiling) {
|
|
187
|
+
return;
|
|
132
188
|
}
|
|
189
|
+
|
|
190
|
+
isProfiling = false;
|
|
191
|
+
resetMeasurements();
|
|
192
|
+
ReactDebugTool.removeDevtool(ReactHostOperationHistoryDevtool);
|
|
133
193
|
},
|
|
134
194
|
getFlushHistory: function () {
|
|
135
|
-
|
|
136
|
-
return flushHistory;
|
|
137
|
-
}
|
|
195
|
+
return flushHistory;
|
|
138
196
|
},
|
|
139
197
|
onBeginFlush: function () {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
198
|
+
currentFlushNesting++;
|
|
199
|
+
resetMeasurements();
|
|
200
|
+
pauseCurrentLifeCycleTimer();
|
|
144
201
|
emitEvent('onBeginFlush');
|
|
145
202
|
},
|
|
146
203
|
onEndFlush: function () {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
204
|
+
resetMeasurements();
|
|
205
|
+
currentFlushNesting--;
|
|
206
|
+
resumeCurrentLifeCycleTimer();
|
|
151
207
|
emitEvent('onEndFlush');
|
|
152
208
|
},
|
|
153
209
|
onBeginLifeCycleTimer: function (debugID, timerType) {
|
|
154
210
|
checkDebugID(debugID);
|
|
155
211
|
emitEvent('onBeginLifeCycleTimer', debugID, timerType);
|
|
156
|
-
|
|
157
|
-
if (isProfiling && currentFlushNesting > 0) {
|
|
158
|
-
process.env.NODE_ENV !== 'production' ? warning(!currentTimerType, 'There is an internal error in the React performance measurement code. ' + 'Did not expect %s timer to start while %s timer is still in ' + 'progress for %s instance.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another') : void 0;
|
|
159
|
-
currentTimerStartTime = performanceNow();
|
|
160
|
-
currentTimerDebugID = debugID;
|
|
161
|
-
currentTimerType = timerType;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
212
|
+
beginLifeCycleTimer(debugID, timerType);
|
|
164
213
|
},
|
|
165
214
|
onEndLifeCycleTimer: function (debugID, timerType) {
|
|
166
215
|
checkDebugID(debugID);
|
|
167
|
-
|
|
168
|
-
if (isProfiling && currentFlushNesting > 0) {
|
|
169
|
-
process.env.NODE_ENV !== 'production' ? warning(currentTimerType === timerType, 'There is an internal error in the React performance measurement code. ' + 'We did not expect %s timer to stop while %s timer is still in ' + 'progress for %s instance. Please report this as a bug in React.', timerType, currentTimerType || 'no', debugID === currentTimerDebugID ? 'the same' : 'another') : void 0;
|
|
170
|
-
currentFlushMeasurements.push({
|
|
171
|
-
timerType: timerType,
|
|
172
|
-
instanceID: debugID,
|
|
173
|
-
duration: performanceNow() - currentTimerStartTime
|
|
174
|
-
});
|
|
175
|
-
currentTimerStartTime = null;
|
|
176
|
-
currentTimerDebugID = null;
|
|
177
|
-
currentTimerType = null;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
216
|
+
endLifeCycleTimer(debugID, timerType);
|
|
180
217
|
emitEvent('onEndLifeCycleTimer', debugID, timerType);
|
|
181
218
|
},
|
|
182
219
|
onBeginReconcilerTimer: function (debugID, timerType) {
|
|
@@ -187,15 +224,21 @@ var ReactDebugTool = {
|
|
|
187
224
|
checkDebugID(debugID);
|
|
188
225
|
emitEvent('onEndReconcilerTimer', debugID, timerType);
|
|
189
226
|
},
|
|
227
|
+
onError: function (debugID) {
|
|
228
|
+
if (currentTimerDebugID != null) {
|
|
229
|
+
endLifeCycleTimer(currentTimerDebugID, currentTimerType);
|
|
230
|
+
}
|
|
231
|
+
emitEvent('onError', debugID);
|
|
232
|
+
},
|
|
190
233
|
onBeginProcessingChildContext: function () {
|
|
191
234
|
emitEvent('onBeginProcessingChildContext');
|
|
192
235
|
},
|
|
193
236
|
onEndProcessingChildContext: function () {
|
|
194
237
|
emitEvent('onEndProcessingChildContext');
|
|
195
238
|
},
|
|
196
|
-
|
|
239
|
+
onHostOperation: function (debugID, type, payload) {
|
|
197
240
|
checkDebugID(debugID);
|
|
198
|
-
emitEvent('
|
|
241
|
+
emitEvent('onHostOperation', debugID, type, payload);
|
|
199
242
|
},
|
|
200
243
|
onSetState: function () {
|
|
201
244
|
emitEvent('onSetState');
|
|
@@ -206,12 +249,17 @@ var ReactDebugTool = {
|
|
|
206
249
|
},
|
|
207
250
|
onSetChildren: function (debugID, childDebugIDs) {
|
|
208
251
|
checkDebugID(debugID);
|
|
252
|
+
childDebugIDs.forEach(checkDebugID);
|
|
209
253
|
emitEvent('onSetChildren', debugID, childDebugIDs);
|
|
210
254
|
},
|
|
211
255
|
onSetOwner: function (debugID, ownerDebugID) {
|
|
212
256
|
checkDebugID(debugID);
|
|
213
257
|
emitEvent('onSetOwner', debugID, ownerDebugID);
|
|
214
258
|
},
|
|
259
|
+
onSetParent: function (debugID, parentDebugID) {
|
|
260
|
+
checkDebugID(debugID);
|
|
261
|
+
emitEvent('onSetParent', debugID, parentDebugID);
|
|
262
|
+
},
|
|
215
263
|
onSetText: function (debugID, text) {
|
|
216
264
|
checkDebugID(debugID);
|
|
217
265
|
emitEvent('onSetText', debugID, text);
|
|
@@ -220,10 +268,18 @@ var ReactDebugTool = {
|
|
|
220
268
|
checkDebugID(debugID);
|
|
221
269
|
emitEvent('onMountRootComponent', debugID);
|
|
222
270
|
},
|
|
271
|
+
onBeforeMountComponent: function (debugID, element) {
|
|
272
|
+
checkDebugID(debugID);
|
|
273
|
+
emitEvent('onBeforeMountComponent', debugID, element);
|
|
274
|
+
},
|
|
223
275
|
onMountComponent: function (debugID) {
|
|
224
276
|
checkDebugID(debugID);
|
|
225
277
|
emitEvent('onMountComponent', debugID);
|
|
226
278
|
},
|
|
279
|
+
onBeforeUpdateComponent: function (debugID, element) {
|
|
280
|
+
checkDebugID(debugID);
|
|
281
|
+
emitEvent('onBeforeUpdateComponent', debugID, element);
|
|
282
|
+
},
|
|
227
283
|
onUpdateComponent: function (debugID) {
|
|
228
284
|
checkDebugID(debugID);
|
|
229
285
|
emitEvent('onUpdateComponent', debugID);
|
|
@@ -231,20 +287,17 @@ var ReactDebugTool = {
|
|
|
231
287
|
onUnmountComponent: function (debugID) {
|
|
232
288
|
checkDebugID(debugID);
|
|
233
289
|
emitEvent('onUnmountComponent', debugID);
|
|
290
|
+
},
|
|
291
|
+
onTestEvent: function () {
|
|
292
|
+
emitEvent('onTestEvent');
|
|
234
293
|
}
|
|
235
294
|
};
|
|
236
295
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
ReactDebugTool.
|
|
242
|
-
ReactDebugTool.addDevtool(ReactComponentTreeDevtool);
|
|
243
|
-
ReactDebugTool.addDevtool(ReactNativeOperationHistoryDevtool);
|
|
244
|
-
var url = ExecutionEnvironment.canUseDOM && window.location.href || '';
|
|
245
|
-
if (/[?&]react_perf\b/.test(url)) {
|
|
246
|
-
ReactDebugTool.beginProfiling();
|
|
247
|
-
}
|
|
296
|
+
ReactDebugTool.addDevtool(ReactInvalidSetStateWarningDevTool);
|
|
297
|
+
ReactDebugTool.addDevtool(ReactComponentTreeDevtool);
|
|
298
|
+
var url = ExecutionEnvironment.canUseDOM && window.location.href || '';
|
|
299
|
+
if (/[?&]react_perf\b/.test(url)) {
|
|
300
|
+
ReactDebugTool.beginProfiling();
|
|
248
301
|
}
|
|
249
302
|
|
|
250
303
|
module.exports = ReactDebugTool;
|