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,358 @@
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 ReactInvalidSetStateWarningHook = require('./ReactInvalidSetStateWarningHook');
15
+ var ReactHostOperationHistoryHook = require('./ReactHostOperationHistoryHook');
16
+ var ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
17
+ var ExecutionEnvironment = require('fbjs/lib/ExecutionEnvironment');
18
+
19
+ var performanceNow = require('fbjs/lib/performanceNow');
20
+ var warning = require('fbjs/lib/warning');
21
+
22
+ var hooks = [];
23
+ var didHookThrowForEvent = {};
24
+
25
+ function callHook(event, fn, context, arg1, arg2, arg3, arg4, arg5) {
26
+ try {
27
+ fn.call(context, arg1, arg2, arg3, arg4, arg5);
28
+ } catch (e) {
29
+ process.env.NODE_ENV !== 'production' ? warning(didHookThrowForEvent[event], 'Exception thrown by hook while handling %s: %s', event, e + '\n' + e.stack) : void 0;
30
+ didHookThrowForEvent[event] = true;
31
+ }
32
+ }
33
+
34
+ function emitEvent(event, arg1, arg2, arg3, arg4, arg5) {
35
+ for (var i = 0; i < hooks.length; i++) {
36
+ var hook = hooks[i];
37
+ var fn = hook[event];
38
+ if (fn) {
39
+ callHook(event, fn, hook, arg1, arg2, arg3, arg4, arg5);
40
+ }
41
+ }
42
+ }
43
+
44
+ var isProfiling = false;
45
+ var flushHistory = [];
46
+ var lifeCycleTimerStack = [];
47
+ var currentFlushNesting = 0;
48
+ var currentFlushMeasurements = [];
49
+ var currentFlushStartTime = 0;
50
+ var currentTimerDebugID = null;
51
+ var currentTimerStartTime = 0;
52
+ var currentTimerNestedFlushDuration = 0;
53
+ var currentTimerType = null;
54
+
55
+ var lifeCycleTimerHasWarned = false;
56
+
57
+ function clearHistory() {
58
+ ReactComponentTreeHook.purgeUnmountedComponents();
59
+ ReactHostOperationHistoryHook.clearHistory();
60
+ }
61
+
62
+ function getTreeSnapshot(registeredIDs) {
63
+ return registeredIDs.reduce(function (tree, id) {
64
+ var ownerID = ReactComponentTreeHook.getOwnerID(id);
65
+ var parentID = ReactComponentTreeHook.getParentID(id);
66
+ tree[id] = {
67
+ displayName: ReactComponentTreeHook.getDisplayName(id),
68
+ text: ReactComponentTreeHook.getText(id),
69
+ updateCount: ReactComponentTreeHook.getUpdateCount(id),
70
+ childIDs: ReactComponentTreeHook.getChildIDs(id),
71
+ // Text nodes don't have owners but this is close enough.
72
+ ownerID: ownerID || parentID && ReactComponentTreeHook.getOwnerID(parentID) || 0,
73
+ parentID: parentID
74
+ };
75
+ return tree;
76
+ }, {});
77
+ }
78
+
79
+ function resetMeasurements() {
80
+ var previousStartTime = currentFlushStartTime;
81
+ var previousMeasurements = currentFlushMeasurements;
82
+ var previousOperations = ReactHostOperationHistoryHook.getHistory();
83
+
84
+ if (currentFlushNesting === 0) {
85
+ currentFlushStartTime = 0;
86
+ currentFlushMeasurements = [];
87
+ clearHistory();
88
+ return;
89
+ }
90
+
91
+ if (previousMeasurements.length || previousOperations.length) {
92
+ var registeredIDs = ReactComponentTreeHook.getRegisteredIDs();
93
+ flushHistory.push({
94
+ duration: performanceNow() - previousStartTime,
95
+ measurements: previousMeasurements || [],
96
+ operations: previousOperations || [],
97
+ treeSnapshot: getTreeSnapshot(registeredIDs)
98
+ });
99
+ }
100
+
101
+ clearHistory();
102
+ currentFlushStartTime = performanceNow();
103
+ currentFlushMeasurements = [];
104
+ }
105
+
106
+ function checkDebugID(debugID) {
107
+ var allowRoot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
108
+
109
+ if (allowRoot && debugID === 0) {
110
+ return;
111
+ }
112
+ if (!debugID) {
113
+ process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDebugTool: debugID may not be empty.') : void 0;
114
+ }
115
+ }
116
+
117
+ function beginLifeCycleTimer(debugID, timerType) {
118
+ if (currentFlushNesting === 0) {
119
+ return;
120
+ }
121
+ if (currentTimerType && !lifeCycleTimerHasWarned) {
122
+ process.env.NODE_ENV !== 'production' ? warning(false, '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;
123
+ lifeCycleTimerHasWarned = true;
124
+ }
125
+ currentTimerStartTime = performanceNow();
126
+ currentTimerNestedFlushDuration = 0;
127
+ currentTimerDebugID = debugID;
128
+ currentTimerType = timerType;
129
+ }
130
+
131
+ function endLifeCycleTimer(debugID, timerType) {
132
+ if (currentFlushNesting === 0) {
133
+ return;
134
+ }
135
+ if (currentTimerType !== timerType && !lifeCycleTimerHasWarned) {
136
+ process.env.NODE_ENV !== 'production' ? warning(false, '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;
137
+ lifeCycleTimerHasWarned = true;
138
+ }
139
+ if (isProfiling) {
140
+ currentFlushMeasurements.push({
141
+ timerType: timerType,
142
+ instanceID: debugID,
143
+ duration: performanceNow() - currentTimerStartTime - currentTimerNestedFlushDuration
144
+ });
145
+ }
146
+ currentTimerStartTime = 0;
147
+ currentTimerNestedFlushDuration = 0;
148
+ currentTimerDebugID = null;
149
+ currentTimerType = null;
150
+ }
151
+
152
+ function pauseCurrentLifeCycleTimer() {
153
+ var currentTimer = {
154
+ startTime: currentTimerStartTime,
155
+ nestedFlushStartTime: performanceNow(),
156
+ debugID: currentTimerDebugID,
157
+ timerType: currentTimerType
158
+ };
159
+ lifeCycleTimerStack.push(currentTimer);
160
+ currentTimerStartTime = 0;
161
+ currentTimerNestedFlushDuration = 0;
162
+ currentTimerDebugID = null;
163
+ currentTimerType = null;
164
+ }
165
+
166
+ function resumeCurrentLifeCycleTimer() {
167
+ var _lifeCycleTimerStack$ = lifeCycleTimerStack.pop(),
168
+ startTime = _lifeCycleTimerStack$.startTime,
169
+ nestedFlushStartTime = _lifeCycleTimerStack$.nestedFlushStartTime,
170
+ debugID = _lifeCycleTimerStack$.debugID,
171
+ timerType = _lifeCycleTimerStack$.timerType;
172
+
173
+ var nestedFlushDuration = performanceNow() - nestedFlushStartTime;
174
+ currentTimerStartTime = startTime;
175
+ currentTimerNestedFlushDuration += nestedFlushDuration;
176
+ currentTimerDebugID = debugID;
177
+ currentTimerType = timerType;
178
+ }
179
+
180
+ var lastMarkTimeStamp = 0;
181
+ var canUsePerformanceMeasure = typeof performance !== 'undefined' && typeof performance.mark === 'function' && typeof performance.clearMarks === 'function' && typeof performance.measure === 'function' && typeof performance.clearMeasures === 'function';
182
+
183
+ function shouldMark(debugID) {
184
+ if (!isProfiling || !canUsePerformanceMeasure) {
185
+ return false;
186
+ }
187
+ var element = ReactComponentTreeHook.getElement(debugID);
188
+ if (element == null || typeof element !== 'object') {
189
+ return false;
190
+ }
191
+ var isHostElement = typeof element.type === 'string';
192
+ if (isHostElement) {
193
+ return false;
194
+ }
195
+ return true;
196
+ }
197
+
198
+ function markBegin(debugID, markType) {
199
+ if (!shouldMark(debugID)) {
200
+ return;
201
+ }
202
+
203
+ var markName = debugID + '::' + markType;
204
+ lastMarkTimeStamp = performanceNow();
205
+ performance.mark(markName);
206
+ }
207
+
208
+ function markEnd(debugID, markType) {
209
+ if (!shouldMark(debugID)) {
210
+ return;
211
+ }
212
+
213
+ var markName = debugID + '::' + markType;
214
+ var displayName = ReactComponentTreeHook.getDisplayName(debugID) || 'Unknown';
215
+
216
+ // Chrome has an issue of dropping markers recorded too fast:
217
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=640652
218
+ // To work around this, we will not report very small measurements.
219
+ // I determined the magic number by tweaking it back and forth.
220
+ // 0.05ms was enough to prevent the issue, but I set it to 0.1ms to be safe.
221
+ // When the bug is fixed, we can `measure()` unconditionally if we want to.
222
+ var timeStamp = performanceNow();
223
+ if (timeStamp - lastMarkTimeStamp > 0.1) {
224
+ var measurementName = displayName + ' [' + markType + ']';
225
+ performance.measure(measurementName, markName);
226
+ }
227
+
228
+ performance.clearMarks(markName);
229
+ performance.clearMeasures(measurementName);
230
+ }
231
+
232
+ var ReactDebugTool = {
233
+ addHook: function (hook) {
234
+ hooks.push(hook);
235
+ },
236
+ removeHook: function (hook) {
237
+ for (var i = 0; i < hooks.length; i++) {
238
+ if (hooks[i] === hook) {
239
+ hooks.splice(i, 1);
240
+ i--;
241
+ }
242
+ }
243
+ },
244
+ isProfiling: function () {
245
+ return isProfiling;
246
+ },
247
+ beginProfiling: function () {
248
+ if (isProfiling) {
249
+ return;
250
+ }
251
+
252
+ isProfiling = true;
253
+ flushHistory.length = 0;
254
+ resetMeasurements();
255
+ ReactDebugTool.addHook(ReactHostOperationHistoryHook);
256
+ },
257
+ endProfiling: function () {
258
+ if (!isProfiling) {
259
+ return;
260
+ }
261
+
262
+ isProfiling = false;
263
+ resetMeasurements();
264
+ ReactDebugTool.removeHook(ReactHostOperationHistoryHook);
265
+ },
266
+ getFlushHistory: function () {
267
+ return flushHistory;
268
+ },
269
+ onBeginFlush: function () {
270
+ currentFlushNesting++;
271
+ resetMeasurements();
272
+ pauseCurrentLifeCycleTimer();
273
+ emitEvent('onBeginFlush');
274
+ },
275
+ onEndFlush: function () {
276
+ resetMeasurements();
277
+ currentFlushNesting--;
278
+ resumeCurrentLifeCycleTimer();
279
+ emitEvent('onEndFlush');
280
+ },
281
+ onBeginLifeCycleTimer: function (debugID, timerType) {
282
+ checkDebugID(debugID);
283
+ emitEvent('onBeginLifeCycleTimer', debugID, timerType);
284
+ markBegin(debugID, timerType);
285
+ beginLifeCycleTimer(debugID, timerType);
286
+ },
287
+ onEndLifeCycleTimer: function (debugID, timerType) {
288
+ checkDebugID(debugID);
289
+ endLifeCycleTimer(debugID, timerType);
290
+ markEnd(debugID, timerType);
291
+ emitEvent('onEndLifeCycleTimer', debugID, timerType);
292
+ },
293
+ onBeginProcessingChildContext: function () {
294
+ emitEvent('onBeginProcessingChildContext');
295
+ },
296
+ onEndProcessingChildContext: function () {
297
+ emitEvent('onEndProcessingChildContext');
298
+ },
299
+ onHostOperation: function (operation) {
300
+ checkDebugID(operation.instanceID);
301
+ emitEvent('onHostOperation', operation);
302
+ },
303
+ onSetState: function () {
304
+ emitEvent('onSetState');
305
+ },
306
+ onSetChildren: function (debugID, childDebugIDs) {
307
+ checkDebugID(debugID);
308
+ childDebugIDs.forEach(checkDebugID);
309
+ emitEvent('onSetChildren', debugID, childDebugIDs);
310
+ },
311
+ onBeforeMountComponent: function (debugID, element, parentDebugID) {
312
+ checkDebugID(debugID);
313
+ checkDebugID(parentDebugID, true);
314
+ emitEvent('onBeforeMountComponent', debugID, element, parentDebugID);
315
+ markBegin(debugID, 'mount');
316
+ },
317
+ onMountComponent: function (debugID) {
318
+ checkDebugID(debugID);
319
+ markEnd(debugID, 'mount');
320
+ emitEvent('onMountComponent', debugID);
321
+ },
322
+ onBeforeUpdateComponent: function (debugID, element) {
323
+ checkDebugID(debugID);
324
+ emitEvent('onBeforeUpdateComponent', debugID, element);
325
+ markBegin(debugID, 'update');
326
+ },
327
+ onUpdateComponent: function (debugID) {
328
+ checkDebugID(debugID);
329
+ markEnd(debugID, 'update');
330
+ emitEvent('onUpdateComponent', debugID);
331
+ },
332
+ onBeforeUnmountComponent: function (debugID) {
333
+ checkDebugID(debugID);
334
+ emitEvent('onBeforeUnmountComponent', debugID);
335
+ markBegin(debugID, 'unmount');
336
+ },
337
+ onUnmountComponent: function (debugID) {
338
+ checkDebugID(debugID);
339
+ markEnd(debugID, 'unmount');
340
+ emitEvent('onUnmountComponent', debugID);
341
+ },
342
+ onTestEvent: function () {
343
+ emitEvent('onTestEvent');
344
+ }
345
+ };
346
+
347
+ // TODO remove these when RN/www gets updated
348
+ ReactDebugTool.addDevtool = ReactDebugTool.addHook;
349
+ ReactDebugTool.removeDevtool = ReactDebugTool.removeHook;
350
+
351
+ ReactDebugTool.addHook(ReactInvalidSetStateWarningHook);
352
+ ReactDebugTool.addHook(ReactComponentTreeHook);
353
+ var url = ExecutionEnvironment.canUseDOM && window.location.href || '';
354
+ if (/[?&]react_perf\b/.test(url)) {
355
+ ReactDebugTool.beginProfiling();
356
+ }
357
+
358
+ module.exports = ReactDebugTool;
@@ -0,0 +1,67 @@
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
+ 'use strict';
12
+
13
+ var _assign = require('object-assign');
14
+
15
+ var ReactUpdates = require('./ReactUpdates');
16
+ var Transaction = require('./Transaction');
17
+
18
+ var emptyFunction = require('fbjs/lib/emptyFunction');
19
+
20
+ var RESET_BATCHED_UPDATES = {
21
+ initialize: emptyFunction,
22
+ close: function () {
23
+ ReactDefaultBatchingStrategy.isBatchingUpdates = false;
24
+ }
25
+ };
26
+
27
+ var FLUSH_BATCHED_UPDATES = {
28
+ initialize: emptyFunction,
29
+ close: ReactUpdates.flushBatchedUpdates.bind(ReactUpdates)
30
+ };
31
+
32
+ var TRANSACTION_WRAPPERS = [FLUSH_BATCHED_UPDATES, RESET_BATCHED_UPDATES];
33
+
34
+ function ReactDefaultBatchingStrategyTransaction() {
35
+ this.reinitializeTransaction();
36
+ }
37
+
38
+ _assign(ReactDefaultBatchingStrategyTransaction.prototype, Transaction, {
39
+ getTransactionWrappers: function () {
40
+ return TRANSACTION_WRAPPERS;
41
+ }
42
+ });
43
+
44
+ var transaction = new ReactDefaultBatchingStrategyTransaction();
45
+
46
+ var ReactDefaultBatchingStrategy = {
47
+ isBatchingUpdates: false,
48
+
49
+ /**
50
+ * Call the provided function in a context within which calls to `setState`
51
+ * and friends are batched such that components aren't updated unnecessarily.
52
+ */
53
+ batchedUpdates: function (callback, a, b, c, d, e) {
54
+ var alreadyBatchingUpdates = ReactDefaultBatchingStrategy.isBatchingUpdates;
55
+
56
+ ReactDefaultBatchingStrategy.isBatchingUpdates = true;
57
+
58
+ // The code is written this way to avoid extra allocations
59
+ if (alreadyBatchingUpdates) {
60
+ return callback(a, b, c, d, e);
61
+ } else {
62
+ return transaction.perform(callback, null, a, b, c, d, e);
63
+ }
64
+ }
65
+ };
66
+
67
+ module.exports = ReactDefaultBatchingStrategy;
@@ -0,0 +1,85 @@
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
+ 'use strict';
12
+
13
+ var ARIADOMPropertyConfig = require('./ARIADOMPropertyConfig');
14
+ var BeforeInputEventPlugin = require('./BeforeInputEventPlugin');
15
+ var ChangeEventPlugin = require('./ChangeEventPlugin');
16
+ var DefaultEventPluginOrder = require('./DefaultEventPluginOrder');
17
+ var EnterLeaveEventPlugin = require('./EnterLeaveEventPlugin');
18
+ var HTMLDOMPropertyConfig = require('./HTMLDOMPropertyConfig');
19
+ var ReactComponentBrowserEnvironment = require('./ReactComponentBrowserEnvironment');
20
+ var ReactDOMComponent = require('./ReactDOMComponent');
21
+ var ReactDOMComponentTree = require('./ReactDOMComponentTree');
22
+ var ReactDOMEmptyComponent = require('./ReactDOMEmptyComponent');
23
+ var ReactDOMTreeTraversal = require('./ReactDOMTreeTraversal');
24
+ var ReactDOMTextComponent = require('./ReactDOMTextComponent');
25
+ var ReactDefaultBatchingStrategy = require('./ReactDefaultBatchingStrategy');
26
+ var ReactEventListener = require('./ReactEventListener');
27
+ var ReactInjection = require('./ReactInjection');
28
+ var ReactReconcileTransaction = require('./ReactReconcileTransaction');
29
+ var SVGDOMPropertyConfig = require('./SVGDOMPropertyConfig');
30
+ var SelectEventPlugin = require('./SelectEventPlugin');
31
+ var SimpleEventPlugin = require('./SimpleEventPlugin');
32
+
33
+ var alreadyInjected = false;
34
+
35
+ function inject() {
36
+ if (alreadyInjected) {
37
+ // TODO: This is currently true because these injections are shared between
38
+ // the client and the server package. They should be built independently
39
+ // and not share any injection state. Then this problem will be solved.
40
+ return;
41
+ }
42
+ alreadyInjected = true;
43
+
44
+ ReactInjection.EventEmitter.injectReactEventListener(ReactEventListener);
45
+
46
+ /**
47
+ * Inject modules for resolving DOM hierarchy and plugin ordering.
48
+ */
49
+ ReactInjection.EventPluginHub.injectEventPluginOrder(DefaultEventPluginOrder);
50
+ ReactInjection.EventPluginUtils.injectComponentTree(ReactDOMComponentTree);
51
+ ReactInjection.EventPluginUtils.injectTreeTraversal(ReactDOMTreeTraversal);
52
+
53
+ /**
54
+ * Some important event plugins included by default (without having to require
55
+ * them).
56
+ */
57
+ ReactInjection.EventPluginHub.injectEventPluginsByName({
58
+ SimpleEventPlugin: SimpleEventPlugin,
59
+ EnterLeaveEventPlugin: EnterLeaveEventPlugin,
60
+ ChangeEventPlugin: ChangeEventPlugin,
61
+ SelectEventPlugin: SelectEventPlugin,
62
+ BeforeInputEventPlugin: BeforeInputEventPlugin
63
+ });
64
+
65
+ ReactInjection.HostComponent.injectGenericComponentClass(ReactDOMComponent);
66
+
67
+ ReactInjection.HostComponent.injectTextComponentClass(ReactDOMTextComponent);
68
+
69
+ ReactInjection.DOMProperty.injectDOMPropertyConfig(ARIADOMPropertyConfig);
70
+ ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
71
+ ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
72
+
73
+ ReactInjection.EmptyComponent.injectEmptyComponentFactory(function (instantiate) {
74
+ return new ReactDOMEmptyComponent(instantiate);
75
+ });
76
+
77
+ ReactInjection.Updates.injectReconcileTransaction(ReactReconcileTransaction);
78
+ ReactInjection.Updates.injectBatchingStrategy(ReactDefaultBatchingStrategy);
79
+
80
+ ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
81
+ }
82
+
83
+ module.exports = {
84
+ inject: inject
85
+ };
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Copyright 2014-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
+ // The Symbol used to tag the ReactElement type. If there is no native Symbol
15
+ // nor polyfill, then a plain number is used for performance.
16
+
17
+ var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
18
+
19
+ module.exports = REACT_ELEMENT_TYPE;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright 2014-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
+ 'use strict';
12
+
13
+ var emptyComponentFactory;
14
+
15
+ var ReactEmptyComponentInjection = {
16
+ injectEmptyComponentFactory: function (factory) {
17
+ emptyComponentFactory = factory;
18
+ }
19
+ };
20
+
21
+ var ReactEmptyComponent = {
22
+ create: function (instantiate) {
23
+ return emptyComponentFactory(instantiate);
24
+ }
25
+ };
26
+
27
+ ReactEmptyComponent.injection = ReactEmptyComponentInjection;
28
+
29
+ module.exports = ReactEmptyComponent;
@@ -0,0 +1,75 @@
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 caughtError = null;
15
+
16
+ /**
17
+ * Call a function while guarding against errors that happens within it.
18
+ *
19
+ * @param {String} name of the guard to use for logging or debugging
20
+ * @param {Function} func The function to invoke
21
+ * @param {*} a First argument
22
+ * @param {*} b Second argument
23
+ */
24
+ function invokeGuardedCallback(name, func, a) {
25
+ try {
26
+ func(a);
27
+ } catch (x) {
28
+ if (caughtError === null) {
29
+ caughtError = x;
30
+ }
31
+ }
32
+ }
33
+
34
+ var ReactErrorUtils = {
35
+ invokeGuardedCallback: invokeGuardedCallback,
36
+
37
+ /**
38
+ * Invoked by ReactTestUtils.Simulate so that any errors thrown by the event
39
+ * handler are sure to be rethrown by rethrowCaughtError.
40
+ */
41
+ invokeGuardedCallbackWithCatch: invokeGuardedCallback,
42
+
43
+ /**
44
+ * During execution of guarded functions we will capture the first error which
45
+ * we will rethrow to be handled by the top level error handler.
46
+ */
47
+ rethrowCaughtError: function () {
48
+ if (caughtError) {
49
+ var error = caughtError;
50
+ caughtError = null;
51
+ throw error;
52
+ }
53
+ }
54
+ };
55
+
56
+ if (process.env.NODE_ENV !== 'production') {
57
+ /**
58
+ * To help development we can get better devtools integration by simulating a
59
+ * real browser event.
60
+ */
61
+ if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
62
+ var fakeNode = document.createElement('react');
63
+ ReactErrorUtils.invokeGuardedCallback = function (name, func, a) {
64
+ var boundFunc = func.bind(null, a);
65
+ var evtType = 'react-' + name;
66
+ fakeNode.addEventListener(evtType, boundFunc, false);
67
+ var evt = document.createEvent('Event');
68
+ evt.initEvent(evtType, false, false);
69
+ fakeNode.dispatchEvent(evt);
70
+ fakeNode.removeEventListener(evtType, boundFunc, false);
71
+ };
72
+ }
73
+ }
74
+
75
+ module.exports = ReactErrorUtils;
@@ -0,0 +1,32 @@
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
+ 'use strict';
12
+
13
+ var EventPluginHub = require('./EventPluginHub');
14
+
15
+ function runEventQueueInBatch(events) {
16
+ EventPluginHub.enqueueEvents(events);
17
+ EventPluginHub.processEventQueue(false);
18
+ }
19
+
20
+ var ReactEventEmitterMixin = {
21
+
22
+ /**
23
+ * Streams a fired top-level event to `EventPluginHub` where plugins have the
24
+ * opportunity to create `ReactEvent`s to be dispatched.
25
+ */
26
+ handleTopLevel: function (topLevelType, targetInst, nativeEvent, nativeEventTarget) {
27
+ var events = EventPluginHub.extractEvents(topLevelType, targetInst, nativeEvent, nativeEventTarget);
28
+ runEventQueueInBatch(events);
29
+ }
30
+ };
31
+
32
+ module.exports = ReactEventEmitterMixin;