react-test-renderer 15.5.0 → 15.5.4

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.
Files changed (168) hide show
  1. package/lib/ReactShallowRenderer.js +6 -0
  2. package/lib/shallow/ARIADOMPropertyConfig.js +73 -0
  3. package/lib/shallow/AutoFocusUtils.js +23 -0
  4. package/lib/shallow/BeforeInputEventPlugin.js +384 -0
  5. package/lib/shallow/CSSProperty.js +147 -0
  6. package/lib/shallow/CSSPropertyOperations.js +208 -0
  7. package/lib/shallow/CallbackQueue.js +118 -0
  8. package/lib/shallow/ChangeEventPlugin.js +345 -0
  9. package/lib/shallow/DOMChildrenOperations.js +224 -0
  10. package/lib/shallow/DOMLazyTree.js +117 -0
  11. package/lib/shallow/DOMNamespaces.js +19 -0
  12. package/lib/shallow/DOMProperty.js +209 -0
  13. package/lib/shallow/DOMPropertyOperations.js +236 -0
  14. package/lib/shallow/Danger.js +47 -0
  15. package/lib/shallow/DefaultEventPluginOrder.js +25 -0
  16. package/lib/shallow/EnterLeaveEventPlugin.js +99 -0
  17. package/lib/shallow/EventConstants.js +91 -0
  18. package/lib/shallow/EventPluginHub.js +277 -0
  19. package/lib/shallow/EventPluginRegistry.js +254 -0
  20. package/lib/shallow/EventPluginUtils.js +225 -0
  21. package/lib/shallow/EventPropagators.js +133 -0
  22. package/lib/shallow/FallbackCompositionState.js +94 -0
  23. package/lib/shallow/HTMLDOMPropertyConfig.js +235 -0
  24. package/lib/shallow/KeyEscapeUtils.js +58 -0
  25. package/lib/shallow/LinkedValueUtils.js +137 -0
  26. package/lib/shallow/PluginModuleType.js +12 -0
  27. package/lib/shallow/PooledClass.js +111 -0
  28. package/lib/shallow/ReactBrowserEventEmitter.js +327 -0
  29. package/lib/shallow/ReactChildFiber.js +243 -0
  30. package/lib/shallow/ReactChildReconciler.js +153 -0
  31. package/lib/shallow/ReactComponentBrowserEnvironment.js +29 -0
  32. package/lib/shallow/ReactComponentEnvironment.js +45 -0
  33. package/lib/shallow/ReactCompositeComponent.js +901 -0
  34. package/lib/shallow/ReactCoroutine.js +80 -0
  35. package/lib/shallow/ReactDOM.js +110 -0
  36. package/lib/shallow/ReactDOMComponent.js +1000 -0
  37. package/lib/shallow/ReactDOMComponentFlags.js +17 -0
  38. package/lib/shallow/ReactDOMComponentTree.js +194 -0
  39. package/lib/shallow/ReactDOMContainerInfo.js +32 -0
  40. package/lib/shallow/ReactDOMEmptyComponent.js +59 -0
  41. package/lib/shallow/ReactDOMFeatureFlags.js +18 -0
  42. package/lib/shallow/ReactDOMFiber.js +97 -0
  43. package/lib/shallow/ReactDOMIDOperations.js +33 -0
  44. package/lib/shallow/ReactDOMInput.js +284 -0
  45. package/lib/shallow/ReactDOMInvalidARIAHook.js +92 -0
  46. package/lib/shallow/ReactDOMNullInputValuePropHook.js +42 -0
  47. package/lib/shallow/ReactDOMOption.js +122 -0
  48. package/lib/shallow/ReactDOMSelect.js +199 -0
  49. package/lib/shallow/ReactDOMSelection.js +211 -0
  50. package/lib/shallow/ReactDOMServer.js +25 -0
  51. package/lib/shallow/ReactDOMTextComponent.js +163 -0
  52. package/lib/shallow/ReactDOMTextarea.js +159 -0
  53. package/lib/shallow/ReactDOMTreeTraversal.js +135 -0
  54. package/lib/shallow/ReactDOMUnknownPropertyHook.js +111 -0
  55. package/lib/shallow/ReactDebugTool.js +358 -0
  56. package/lib/shallow/ReactDefaultBatchingStrategy.js +67 -0
  57. package/lib/shallow/ReactDefaultInjection.js +85 -0
  58. package/lib/shallow/ReactElementSymbol.js +19 -0
  59. package/lib/shallow/ReactEmptyComponent.js +29 -0
  60. package/lib/shallow/ReactErrorUtils.js +75 -0
  61. package/lib/shallow/ReactEventEmitterMixin.js +32 -0
  62. package/lib/shallow/ReactEventListener.js +154 -0
  63. package/lib/shallow/ReactFeatureFlags.js +21 -0
  64. package/lib/shallow/ReactFiber.js +190 -0
  65. package/lib/shallow/ReactFiberBeginWork.js +380 -0
  66. package/lib/shallow/ReactFiberCommitWork.js +78 -0
  67. package/lib/shallow/ReactFiberCompleteWork.js +208 -0
  68. package/lib/shallow/ReactFiberReconciler.js +64 -0
  69. package/lib/shallow/ReactFiberRoot.js +29 -0
  70. package/lib/shallow/ReactFiberScheduler.js +331 -0
  71. package/lib/shallow/ReactFiberUpdateQueue.js +77 -0
  72. package/lib/shallow/ReactHostComponent.js +67 -0
  73. package/lib/shallow/ReactHostOperationHistoryHook.js +33 -0
  74. package/lib/shallow/ReactInjection.js +33 -0
  75. package/lib/shallow/ReactInputSelection.js +123 -0
  76. package/lib/shallow/ReactInstanceMap.js +47 -0
  77. package/lib/shallow/ReactInstanceType.js +12 -0
  78. package/lib/shallow/ReactInstrumentation.js +23 -0
  79. package/lib/shallow/ReactInvalidSetStateWarningHook.js +36 -0
  80. package/lib/shallow/ReactMarkupChecksum.js +49 -0
  81. package/lib/shallow/ReactMount.js +537 -0
  82. package/lib/shallow/ReactMultiChild.js +449 -0
  83. package/lib/shallow/ReactMultiChildUpdateTypes.js +18 -0
  84. package/lib/shallow/ReactNodeTypes.js +39 -0
  85. package/lib/shallow/ReactOwner.js +93 -0
  86. package/lib/shallow/ReactPerf.js +500 -0
  87. package/lib/shallow/ReactPriorityLevel.js +20 -0
  88. package/lib/shallow/ReactPropTypeLocationNames.js +24 -0
  89. package/lib/shallow/ReactPropTypeLocations.js +12 -0
  90. package/lib/shallow/ReactPropTypesSecret.js +16 -0
  91. package/lib/shallow/ReactReconcileTransaction.js +177 -0
  92. package/lib/shallow/ReactReconciler.js +167 -0
  93. package/lib/shallow/ReactRef.js +88 -0
  94. package/lib/shallow/ReactReifiedYield.js +30 -0
  95. package/lib/shallow/ReactServerBatchingStrategy.js +21 -0
  96. package/lib/shallow/ReactServerRendering.js +89 -0
  97. package/lib/shallow/ReactServerRenderingTransaction.js +89 -0
  98. package/lib/shallow/ReactServerUpdateQueue.js +138 -0
  99. package/lib/shallow/ReactShallowRenderer.js +150 -0
  100. package/lib/shallow/ReactSimpleEmptyComponent.js +36 -0
  101. package/lib/shallow/ReactSyntheticEventType.js +14 -0
  102. package/lib/shallow/ReactTestEmptyComponent.js +36 -0
  103. package/lib/shallow/ReactTestMount.js +131 -0
  104. package/lib/shallow/ReactTestReconcileTransaction.js +128 -0
  105. package/lib/shallow/ReactTestRenderer.js +139 -0
  106. package/lib/shallow/ReactTestTextComponent.js +40 -0
  107. package/lib/shallow/ReactTypeOfWork.js +23 -0
  108. package/lib/shallow/ReactTypes.js +12 -0
  109. package/lib/shallow/ReactUpdateQueue.js +235 -0
  110. package/lib/shallow/ReactUpdates.js +250 -0
  111. package/lib/shallow/ReactVersion.js +13 -0
  112. package/lib/shallow/ResponderEventPlugin.js +507 -0
  113. package/lib/shallow/ResponderSyntheticEvent.js +38 -0
  114. package/lib/shallow/ResponderTouchHistoryStore.js +183 -0
  115. package/lib/shallow/SVGDOMPropertyConfig.js +301 -0
  116. package/lib/shallow/SelectEventPlugin.js +190 -0
  117. package/lib/shallow/SimpleEventPlugin.js +227 -0
  118. package/lib/shallow/SyntheticAnimationEvent.js +38 -0
  119. package/lib/shallow/SyntheticClipboardEvent.js +37 -0
  120. package/lib/shallow/SyntheticCompositionEvent.js +35 -0
  121. package/lib/shallow/SyntheticDragEvent.js +35 -0
  122. package/lib/shallow/SyntheticEvent.js +267 -0
  123. package/lib/shallow/SyntheticFocusEvent.js +35 -0
  124. package/lib/shallow/SyntheticInputEvent.js +36 -0
  125. package/lib/shallow/SyntheticKeyboardEvent.js +83 -0
  126. package/lib/shallow/SyntheticMouseEvent.js +71 -0
  127. package/lib/shallow/SyntheticTouchEvent.js +44 -0
  128. package/lib/shallow/SyntheticTransitionEvent.js +38 -0
  129. package/lib/shallow/SyntheticUIEvent.js +58 -0
  130. package/lib/shallow/SyntheticWheelEvent.js +53 -0
  131. package/lib/shallow/TapEventPlugin.js +115 -0
  132. package/lib/shallow/TouchHistoryMath.js +98 -0
  133. package/lib/shallow/Transaction.js +224 -0
  134. package/lib/shallow/ViewportMetrics.js +26 -0
  135. package/lib/shallow/accumulate.js +45 -0
  136. package/lib/shallow/accumulateInto.js +57 -0
  137. package/lib/shallow/adler32.js +43 -0
  138. package/lib/shallow/canDefineProperty.js +25 -0
  139. package/lib/shallow/checkReactTypeSpec.js +86 -0
  140. package/lib/shallow/createMicrosoftUnsafeLocalFunction.js +31 -0
  141. package/lib/shallow/dangerousStyleValue.js +78 -0
  142. package/lib/shallow/deprecated.js +56 -0
  143. package/lib/shallow/escapeTextContentForBrowser.js +122 -0
  144. package/lib/shallow/findDOMNode.js +59 -0
  145. package/lib/shallow/flattenChildren.js +75 -0
  146. package/lib/shallow/forEachAccumulated.js +30 -0
  147. package/lib/shallow/getEventCharCode.js +49 -0
  148. package/lib/shallow/getEventKey.js +101 -0
  149. package/lib/shallow/getEventModifierState.js +42 -0
  150. package/lib/shallow/getEventTarget.js +34 -0
  151. package/lib/shallow/getHostComponentFromComposite.js +29 -0
  152. package/lib/shallow/getIteratorFn.js +40 -0
  153. package/lib/shallow/getNodeForCharacterOffset.js +73 -0
  154. package/lib/shallow/getTextContentAccessor.js +32 -0
  155. package/lib/shallow/getVendorPrefixedEventName.js +100 -0
  156. package/lib/shallow/instantiateReactComponent.js +128 -0
  157. package/lib/shallow/isEventSupported.js +59 -0
  158. package/lib/shallow/isTextInputElement.js +50 -0
  159. package/lib/shallow/quoteAttributeValueForBrowser.js +25 -0
  160. package/lib/shallow/reactProdInvariant.js +38 -0
  161. package/lib/shallow/renderSubtreeIntoContainer.js +15 -0
  162. package/lib/shallow/setInnerHTML.js +97 -0
  163. package/lib/shallow/setTextContent.js +51 -0
  164. package/lib/shallow/shouldUpdateReactComponent.js +41 -0
  165. package/lib/shallow/traverseAllChildren.js +175 -0
  166. package/lib/shallow/validateDOMNesting.js +376 -0
  167. package/package.json +1 -1
  168. package/shallow.js +1 -1
@@ -0,0 +1,500 @@
1
+ /**
2
+ * Copyright 2016-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ *
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var _assign = require('object-assign');
15
+
16
+ var _extends = _assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
17
+
18
+ var ReactDebugTool = require('./ReactDebugTool');
19
+ var warning = require('fbjs/lib/warning');
20
+ var alreadyWarned = false;
21
+
22
+ function roundFloat(val) {
23
+ var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
24
+
25
+ var n = Math.pow(10, base);
26
+ return Math.floor(val * n) / n;
27
+ }
28
+
29
+ // Flow type definition of console.table is too strict right now, see
30
+ // https://github.com/facebook/flow/pull/2353 for updates
31
+ function consoleTable(table) {
32
+ console.table(table);
33
+ }
34
+
35
+ function warnInProduction() {
36
+ if (alreadyWarned) {
37
+ return;
38
+ }
39
+ alreadyWarned = true;
40
+ if (typeof console !== 'undefined') {
41
+ console.error('ReactPerf is not supported in the production builds of React. ' + 'To collect measurements, please use the development build of React instead.');
42
+ }
43
+ }
44
+
45
+ function getLastMeasurements() {
46
+ if (!(process.env.NODE_ENV !== 'production')) {
47
+ warnInProduction();
48
+ return [];
49
+ }
50
+
51
+ return ReactDebugTool.getFlushHistory();
52
+ }
53
+
54
+ function getExclusive() {
55
+ var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();
56
+
57
+ if (!(process.env.NODE_ENV !== 'production')) {
58
+ warnInProduction();
59
+ return [];
60
+ }
61
+
62
+ var aggregatedStats = {};
63
+ var affectedIDs = {};
64
+
65
+ function updateAggregatedStats(treeSnapshot, instanceID, timerType, applyUpdate) {
66
+ var displayName = treeSnapshot[instanceID].displayName;
67
+
68
+ var key = displayName;
69
+ var stats = aggregatedStats[key];
70
+ if (!stats) {
71
+ affectedIDs[key] = {};
72
+ stats = aggregatedStats[key] = {
73
+ key: key,
74
+ instanceCount: 0,
75
+ counts: {},
76
+ durations: {},
77
+ totalDuration: 0
78
+ };
79
+ }
80
+ if (!stats.durations[timerType]) {
81
+ stats.durations[timerType] = 0;
82
+ }
83
+ if (!stats.counts[timerType]) {
84
+ stats.counts[timerType] = 0;
85
+ }
86
+ affectedIDs[key][instanceID] = true;
87
+ applyUpdate(stats);
88
+ }
89
+
90
+ flushHistory.forEach(function (flush) {
91
+ var measurements = flush.measurements,
92
+ treeSnapshot = flush.treeSnapshot;
93
+
94
+ measurements.forEach(function (measurement) {
95
+ var duration = measurement.duration,
96
+ instanceID = measurement.instanceID,
97
+ timerType = measurement.timerType;
98
+
99
+ updateAggregatedStats(treeSnapshot, instanceID, timerType, function (stats) {
100
+ stats.totalDuration += duration;
101
+ stats.durations[timerType] += duration;
102
+ stats.counts[timerType]++;
103
+ });
104
+ });
105
+ });
106
+
107
+ return Object.keys(aggregatedStats).map(function (key) {
108
+ return _extends({}, aggregatedStats[key], {
109
+ instanceCount: Object.keys(affectedIDs[key]).length
110
+ });
111
+ }).sort(function (a, b) {
112
+ return b.totalDuration - a.totalDuration;
113
+ });
114
+ }
115
+
116
+ function getInclusive() {
117
+ var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();
118
+
119
+ if (!(process.env.NODE_ENV !== 'production')) {
120
+ warnInProduction();
121
+ return [];
122
+ }
123
+
124
+ var aggregatedStats = {};
125
+ var affectedIDs = {};
126
+
127
+ function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {
128
+ var _treeSnapshot$instanc = treeSnapshot[instanceID],
129
+ displayName = _treeSnapshot$instanc.displayName,
130
+ ownerID = _treeSnapshot$instanc.ownerID;
131
+
132
+ var owner = treeSnapshot[ownerID];
133
+ var key = (owner ? owner.displayName + ' > ' : '') + displayName;
134
+ var stats = aggregatedStats[key];
135
+ if (!stats) {
136
+ affectedIDs[key] = {};
137
+ stats = aggregatedStats[key] = {
138
+ key: key,
139
+ instanceCount: 0,
140
+ inclusiveRenderDuration: 0,
141
+ renderCount: 0
142
+ };
143
+ }
144
+ affectedIDs[key][instanceID] = true;
145
+ applyUpdate(stats);
146
+ }
147
+
148
+ var isCompositeByID = {};
149
+ flushHistory.forEach(function (flush) {
150
+ var measurements = flush.measurements;
151
+
152
+ measurements.forEach(function (measurement) {
153
+ var instanceID = measurement.instanceID,
154
+ timerType = measurement.timerType;
155
+
156
+ if (timerType !== 'render') {
157
+ return;
158
+ }
159
+ isCompositeByID[instanceID] = true;
160
+ });
161
+ });
162
+
163
+ flushHistory.forEach(function (flush) {
164
+ var measurements = flush.measurements,
165
+ treeSnapshot = flush.treeSnapshot;
166
+
167
+ measurements.forEach(function (measurement) {
168
+ var duration = measurement.duration,
169
+ instanceID = measurement.instanceID,
170
+ timerType = measurement.timerType;
171
+
172
+ if (timerType !== 'render') {
173
+ return;
174
+ }
175
+ updateAggregatedStats(treeSnapshot, instanceID, function (stats) {
176
+ stats.renderCount++;
177
+ });
178
+ var nextParentID = instanceID;
179
+ while (nextParentID) {
180
+ // As we traverse parents, only count inclusive time towards composites.
181
+ // We know something is a composite if its render() was called.
182
+ if (isCompositeByID[nextParentID]) {
183
+ updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {
184
+ stats.inclusiveRenderDuration += duration;
185
+ });
186
+ }
187
+ nextParentID = treeSnapshot[nextParentID].parentID;
188
+ }
189
+ });
190
+ });
191
+
192
+ return Object.keys(aggregatedStats).map(function (key) {
193
+ return _extends({}, aggregatedStats[key], {
194
+ instanceCount: Object.keys(affectedIDs[key]).length
195
+ });
196
+ }).sort(function (a, b) {
197
+ return b.inclusiveRenderDuration - a.inclusiveRenderDuration;
198
+ });
199
+ }
200
+
201
+ function getWasted() {
202
+ var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();
203
+
204
+ if (!(process.env.NODE_ENV !== 'production')) {
205
+ warnInProduction();
206
+ return [];
207
+ }
208
+
209
+ var aggregatedStats = {};
210
+ var affectedIDs = {};
211
+
212
+ function updateAggregatedStats(treeSnapshot, instanceID, applyUpdate) {
213
+ var _treeSnapshot$instanc2 = treeSnapshot[instanceID],
214
+ displayName = _treeSnapshot$instanc2.displayName,
215
+ ownerID = _treeSnapshot$instanc2.ownerID;
216
+
217
+ var owner = treeSnapshot[ownerID];
218
+ var key = (owner ? owner.displayName + ' > ' : '') + displayName;
219
+ var stats = aggregatedStats[key];
220
+ if (!stats) {
221
+ affectedIDs[key] = {};
222
+ stats = aggregatedStats[key] = {
223
+ key: key,
224
+ instanceCount: 0,
225
+ inclusiveRenderDuration: 0,
226
+ renderCount: 0
227
+ };
228
+ }
229
+ affectedIDs[key][instanceID] = true;
230
+ applyUpdate(stats);
231
+ }
232
+
233
+ flushHistory.forEach(function (flush) {
234
+ var measurements = flush.measurements,
235
+ treeSnapshot = flush.treeSnapshot,
236
+ operations = flush.operations;
237
+
238
+ var isDefinitelyNotWastedByID = {};
239
+
240
+ // Find host components associated with an operation in this batch.
241
+ // Mark all components in their parent tree as definitely not wasted.
242
+ operations.forEach(function (operation) {
243
+ var instanceID = operation.instanceID;
244
+
245
+ var nextParentID = instanceID;
246
+ while (nextParentID) {
247
+ isDefinitelyNotWastedByID[nextParentID] = true;
248
+ nextParentID = treeSnapshot[nextParentID].parentID;
249
+ }
250
+ });
251
+
252
+ // Find composite components that rendered in this batch.
253
+ // These are potential candidates for being wasted renders.
254
+ var renderedCompositeIDs = {};
255
+ measurements.forEach(function (measurement) {
256
+ var instanceID = measurement.instanceID,
257
+ timerType = measurement.timerType;
258
+
259
+ if (timerType !== 'render') {
260
+ return;
261
+ }
262
+ renderedCompositeIDs[instanceID] = true;
263
+ });
264
+
265
+ measurements.forEach(function (measurement) {
266
+ var duration = measurement.duration,
267
+ instanceID = measurement.instanceID,
268
+ timerType = measurement.timerType;
269
+
270
+ if (timerType !== 'render') {
271
+ return;
272
+ }
273
+
274
+ // If there was a DOM update below this component, or it has just been
275
+ // mounted, its render() is not considered wasted.
276
+ var updateCount = treeSnapshot[instanceID].updateCount;
277
+
278
+ if (isDefinitelyNotWastedByID[instanceID] || updateCount === 0) {
279
+ return;
280
+ }
281
+
282
+ // We consider this render() wasted.
283
+ updateAggregatedStats(treeSnapshot, instanceID, function (stats) {
284
+ stats.renderCount++;
285
+ });
286
+
287
+ var nextParentID = instanceID;
288
+ while (nextParentID) {
289
+ // Any parents rendered during this batch are considered wasted
290
+ // unless we previously marked them as dirty.
291
+ var isWasted = renderedCompositeIDs[nextParentID] && !isDefinitelyNotWastedByID[nextParentID];
292
+ if (isWasted) {
293
+ updateAggregatedStats(treeSnapshot, nextParentID, function (stats) {
294
+ stats.inclusiveRenderDuration += duration;
295
+ });
296
+ }
297
+ nextParentID = treeSnapshot[nextParentID].parentID;
298
+ }
299
+ });
300
+ });
301
+
302
+ return Object.keys(aggregatedStats).map(function (key) {
303
+ return _extends({}, aggregatedStats[key], {
304
+ instanceCount: Object.keys(affectedIDs[key]).length
305
+ });
306
+ }).sort(function (a, b) {
307
+ return b.inclusiveRenderDuration - a.inclusiveRenderDuration;
308
+ });
309
+ }
310
+
311
+ function getOperations() {
312
+ var flushHistory = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getLastMeasurements();
313
+
314
+ if (!(process.env.NODE_ENV !== 'production')) {
315
+ warnInProduction();
316
+ return [];
317
+ }
318
+
319
+ var stats = [];
320
+ flushHistory.forEach(function (flush, flushIndex) {
321
+ var operations = flush.operations,
322
+ treeSnapshot = flush.treeSnapshot;
323
+
324
+ operations.forEach(function (operation) {
325
+ var instanceID = operation.instanceID,
326
+ type = operation.type,
327
+ payload = operation.payload;
328
+ var _treeSnapshot$instanc3 = treeSnapshot[instanceID],
329
+ displayName = _treeSnapshot$instanc3.displayName,
330
+ ownerID = _treeSnapshot$instanc3.ownerID;
331
+
332
+ var owner = treeSnapshot[ownerID];
333
+ var key = (owner ? owner.displayName + ' > ' : '') + displayName;
334
+
335
+ stats.push({
336
+ flushIndex: flushIndex,
337
+ instanceID: instanceID,
338
+ key: key,
339
+ type: type,
340
+ ownerID: ownerID,
341
+ payload: payload
342
+ });
343
+ });
344
+ });
345
+ return stats;
346
+ }
347
+
348
+ function printExclusive(flushHistory) {
349
+ if (!(process.env.NODE_ENV !== 'production')) {
350
+ warnInProduction();
351
+ return;
352
+ }
353
+
354
+ var stats = getExclusive(flushHistory);
355
+ var table = stats.map(function (item) {
356
+ var key = item.key,
357
+ instanceCount = item.instanceCount,
358
+ totalDuration = item.totalDuration;
359
+
360
+ var renderCount = item.counts.render || 0;
361
+ var renderDuration = item.durations.render || 0;
362
+ return {
363
+ 'Component': key,
364
+ 'Total time (ms)': roundFloat(totalDuration),
365
+ 'Instance count': instanceCount,
366
+ 'Total render time (ms)': roundFloat(renderDuration),
367
+ 'Average render time (ms)': renderCount ? roundFloat(renderDuration / renderCount) : undefined,
368
+ 'Render count': renderCount,
369
+ 'Total lifecycle time (ms)': roundFloat(totalDuration - renderDuration)
370
+ };
371
+ });
372
+ consoleTable(table);
373
+ }
374
+
375
+ function printInclusive(flushHistory) {
376
+ if (!(process.env.NODE_ENV !== 'production')) {
377
+ warnInProduction();
378
+ return;
379
+ }
380
+
381
+ var stats = getInclusive(flushHistory);
382
+ var table = stats.map(function (item) {
383
+ var key = item.key,
384
+ instanceCount = item.instanceCount,
385
+ inclusiveRenderDuration = item.inclusiveRenderDuration,
386
+ renderCount = item.renderCount;
387
+
388
+ return {
389
+ 'Owner > Component': key,
390
+ 'Inclusive render time (ms)': roundFloat(inclusiveRenderDuration),
391
+ 'Instance count': instanceCount,
392
+ 'Render count': renderCount
393
+ };
394
+ });
395
+ consoleTable(table);
396
+ }
397
+
398
+ function printWasted(flushHistory) {
399
+ if (!(process.env.NODE_ENV !== 'production')) {
400
+ warnInProduction();
401
+ return;
402
+ }
403
+
404
+ var stats = getWasted(flushHistory);
405
+ var table = stats.map(function (item) {
406
+ var key = item.key,
407
+ instanceCount = item.instanceCount,
408
+ inclusiveRenderDuration = item.inclusiveRenderDuration,
409
+ renderCount = item.renderCount;
410
+
411
+ return {
412
+ 'Owner > Component': key,
413
+ 'Inclusive wasted time (ms)': roundFloat(inclusiveRenderDuration),
414
+ 'Instance count': instanceCount,
415
+ 'Render count': renderCount
416
+ };
417
+ });
418
+ consoleTable(table);
419
+ }
420
+
421
+ function printOperations(flushHistory) {
422
+ if (!(process.env.NODE_ENV !== 'production')) {
423
+ warnInProduction();
424
+ return;
425
+ }
426
+
427
+ var stats = getOperations(flushHistory);
428
+ var table = stats.map(function (stat) {
429
+ return {
430
+ 'Owner > Node': stat.key,
431
+ 'Operation': stat.type,
432
+ 'Payload': typeof stat.payload === 'object' ? JSON.stringify(stat.payload) : stat.payload,
433
+ 'Flush index': stat.flushIndex,
434
+ 'Owner Component ID': stat.ownerID,
435
+ 'DOM Component ID': stat.instanceID
436
+ };
437
+ });
438
+ consoleTable(table);
439
+ }
440
+
441
+ var warnedAboutPrintDOM = false;
442
+ function printDOM(measurements) {
443
+ process.env.NODE_ENV !== 'production' ? warning(warnedAboutPrintDOM, '`ReactPerf.printDOM(...)` is deprecated. Use ' + '`ReactPerf.printOperations(...)` instead.') : void 0;
444
+ warnedAboutPrintDOM = true;
445
+ return printOperations(measurements);
446
+ }
447
+
448
+ var warnedAboutGetMeasurementsSummaryMap = false;
449
+ function getMeasurementsSummaryMap(measurements) {
450
+ process.env.NODE_ENV !== 'production' ? warning(warnedAboutGetMeasurementsSummaryMap, '`ReactPerf.getMeasurementsSummaryMap(...)` is deprecated. Use ' + '`ReactPerf.getWasted(...)` instead.') : void 0;
451
+ warnedAboutGetMeasurementsSummaryMap = true;
452
+ return getWasted(measurements);
453
+ }
454
+
455
+ function start() {
456
+ if (!(process.env.NODE_ENV !== 'production')) {
457
+ warnInProduction();
458
+ return;
459
+ }
460
+
461
+ ReactDebugTool.beginProfiling();
462
+ }
463
+
464
+ function stop() {
465
+ if (!(process.env.NODE_ENV !== 'production')) {
466
+ warnInProduction();
467
+ return;
468
+ }
469
+
470
+ ReactDebugTool.endProfiling();
471
+ }
472
+
473
+ function isRunning() {
474
+ if (!(process.env.NODE_ENV !== 'production')) {
475
+ warnInProduction();
476
+ return false;
477
+ }
478
+
479
+ return ReactDebugTool.isProfiling();
480
+ }
481
+
482
+ var ReactPerfAnalysis = {
483
+ getLastMeasurements: getLastMeasurements,
484
+ getExclusive: getExclusive,
485
+ getInclusive: getInclusive,
486
+ getWasted: getWasted,
487
+ getOperations: getOperations,
488
+ printExclusive: printExclusive,
489
+ printInclusive: printInclusive,
490
+ printWasted: printWasted,
491
+ printOperations: printOperations,
492
+ start: start,
493
+ stop: stop,
494
+ isRunning: isRunning,
495
+ // Deprecated:
496
+ printDOM: printDOM,
497
+ getMeasurementsSummaryMap: getMeasurementsSummaryMap
498
+ };
499
+
500
+ module.exports = ReactPerfAnalysis;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ *
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ module.exports = {
15
+ NoWork: 0, // No work is pending.
16
+ SynchronousPriority: 1, // For controlled text inputs. Synchronous side-effects.
17
+ AnimationPriority: 2, // Needs to complete before the next frame.
18
+ HighPriority: 3, // Interaction that needs to complete pretty soon to feel responsive.
19
+ LowPriority: 4, // Data fetching, or result from updating stores.
20
+ OffscreenPriority: 5 };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ *
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var ReactPropTypeLocationNames = {};
15
+
16
+ if (process.env.NODE_ENV !== 'production') {
17
+ ReactPropTypeLocationNames = {
18
+ prop: 'prop',
19
+ context: 'context',
20
+ childContext: 'child context'
21
+ };
22
+ }
23
+
24
+ module.exports = ReactPropTypeLocationNames;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ *
10
+ */
11
+
12
+ 'use strict';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Copyright 2013-present, Facebook, Inc.
3
+ * All rights reserved.
4
+ *
5
+ * This source code is licensed under the BSD-style license found in the
6
+ * LICENSE file in the root directory of this source tree. An additional grant
7
+ * of patent rights can be found in the PATENTS file in the same directory.
8
+ *
9
+ *
10
+ */
11
+
12
+ 'use strict';
13
+
14
+ var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
15
+
16
+ module.exports = ReactPropTypesSecret;