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,64 @@
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 _require = require('./ReactFiberRoot'),
15
+ createFiberRoot = _require.createFiberRoot;
16
+
17
+ var ReactFiberScheduler = require('./ReactFiberScheduler');
18
+
19
+ module.exports = function (config) {
20
+ var _ReactFiberScheduler = ReactFiberScheduler(config),
21
+ scheduleWork = _ReactFiberScheduler.scheduleWork,
22
+ performWithPriority = _ReactFiberScheduler.performWithPriority;
23
+
24
+ return {
25
+ mountContainer: function (element, containerInfo) {
26
+ var root = createFiberRoot(containerInfo);
27
+ var container = root.current;
28
+ // TODO: Use pending work/state instead of props.
29
+ // TODO: This should not override the pendingWorkPriority if there is
30
+ // higher priority work in the subtree.
31
+ container.pendingProps = element;
32
+
33
+ scheduleWork(root);
34
+
35
+ // It may seem strange that we don't return the root here, but that will
36
+ // allow us to have containers that are in the middle of the tree instead
37
+ // of being roots.
38
+ return container;
39
+ },
40
+ updateContainer: function (element, container) {
41
+ // TODO: If this is a nested container, this won't be the root.
42
+ var root = container.stateNode;
43
+ // TODO: Use pending work/state instead of props.
44
+ root.current.pendingProps = element;
45
+
46
+ scheduleWork(root);
47
+ },
48
+ unmountContainer: function (container) {
49
+ // TODO: If this is a nested container, this won't be the root.
50
+ var root = container.stateNode;
51
+ // TODO: Use pending work/state instead of props.
52
+ root.current.pendingProps = [];
53
+
54
+ scheduleWork(root);
55
+ },
56
+
57
+
58
+ performWithPriority: performWithPriority,
59
+
60
+ getPublicRootInstance: function (container) {
61
+ return null;
62
+ }
63
+ };
64
+ };
@@ -0,0 +1,29 @@
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 _require = require('./ReactFiber'),
15
+ createHostContainerFiber = _require.createHostContainerFiber;
16
+
17
+ exports.createFiberRoot = function (containerInfo) {
18
+ // Cyclic construction. This cheats the type system right now because
19
+ // stateNode is any.
20
+ var uninitializedFiber = createHostContainerFiber();
21
+ var root = {
22
+ current: uninitializedFiber,
23
+ containerInfo: containerInfo,
24
+ isScheduled: false,
25
+ nextScheduledRoot: null
26
+ };
27
+ uninitializedFiber.stateNode = root;
28
+ return root;
29
+ };
@@ -0,0 +1,331 @@
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 ReactFiberBeginWork = require('./ReactFiberBeginWork');
15
+ var ReactFiberCompleteWork = require('./ReactFiberCompleteWork');
16
+ var ReactFiberCommitWork = require('./ReactFiberCommitWork');
17
+
18
+ var _require = require('./ReactFiber'),
19
+ cloneFiber = _require.cloneFiber;
20
+
21
+ var _require2 = require('./ReactPriorityLevel'),
22
+ NoWork = _require2.NoWork,
23
+ LowPriority = _require2.LowPriority,
24
+ AnimationPriority = _require2.AnimationPriority,
25
+ SynchronousPriority = _require2.SynchronousPriority;
26
+
27
+ var timeHeuristicForUnitOfWork = 1;
28
+
29
+ module.exports = function (config) {
30
+ // Use a closure to circumvent the circular dependency between the scheduler
31
+ // and ReactFiberBeginWork. Don't know if there's a better way to do this.
32
+ var scheduler = void 0;
33
+ function getScheduler() {
34
+ return scheduler;
35
+ }
36
+
37
+ var _ReactFiberBeginWork = ReactFiberBeginWork(config, getScheduler),
38
+ beginWork = _ReactFiberBeginWork.beginWork;
39
+
40
+ var _ReactFiberCompleteWo = ReactFiberCompleteWork(config),
41
+ completeWork = _ReactFiberCompleteWo.completeWork;
42
+
43
+ var _ReactFiberCommitWork = ReactFiberCommitWork(config),
44
+ commitWork = _ReactFiberCommitWork.commitWork;
45
+
46
+ var scheduleAnimationCallback = config.scheduleAnimationCallback;
47
+ var scheduleDeferredCallback = config.scheduleDeferredCallback;
48
+
49
+ // The default priority to use for updates.
50
+ var defaultPriority = LowPriority;
51
+
52
+ // The next work in progress fiber that we're currently working on.
53
+ var nextUnitOfWork = null;
54
+ var nextPriorityLevel = NoWork;
55
+
56
+ // Linked list of roots with scheduled work on them.
57
+ var nextScheduledRoot = null;
58
+ var lastScheduledRoot = null;
59
+
60
+ function findNextUnitOfWork() {
61
+ // Clear out roots with no more work on them.
62
+ while (nextScheduledRoot && nextScheduledRoot.current.pendingWorkPriority === NoWork) {
63
+ nextScheduledRoot.isScheduled = false;
64
+ if (nextScheduledRoot === lastScheduledRoot) {
65
+ nextScheduledRoot = null;
66
+ lastScheduledRoot = null;
67
+ nextPriorityLevel = NoWork;
68
+ return null;
69
+ }
70
+ nextScheduledRoot = nextScheduledRoot.nextScheduledRoot;
71
+ }
72
+ // TODO: This is scanning one root at a time. It should be scanning all
73
+ // roots for high priority work before moving on to lower priorities.
74
+ var root = nextScheduledRoot;
75
+ var highestPriorityRoot = null;
76
+ var highestPriorityLevel = NoWork;
77
+ while (root) {
78
+ if (highestPriorityLevel === NoWork || highestPriorityLevel > root.current.pendingWorkPriority) {
79
+ highestPriorityLevel = root.current.pendingWorkPriority;
80
+ highestPriorityRoot = root;
81
+ }
82
+ // We didn't find anything to do in this root, so let's try the next one.
83
+ root = root.nextScheduledRoot;
84
+ }
85
+ if (highestPriorityRoot) {
86
+ nextPriorityLevel = highestPriorityLevel;
87
+ return cloneFiber(highestPriorityRoot.current, highestPriorityLevel);
88
+ }
89
+
90
+ nextPriorityLevel = NoWork;
91
+ return null;
92
+ }
93
+
94
+ function commitAllWork(finishedWork) {
95
+ // Commit all the side-effects within a tree.
96
+ // TODO: Error handling.
97
+ var effectfulFiber = finishedWork.firstEffect;
98
+ while (effectfulFiber) {
99
+ var current = effectfulFiber.alternate;
100
+ commitWork(current, effectfulFiber);
101
+ var next = effectfulFiber.nextEffect;
102
+ // Ensure that we clean these up so that we don't accidentally keep them.
103
+ // I'm not actually sure this matters because we can't reset firstEffect
104
+ // and lastEffect since they're on every node, not just the effectful
105
+ // ones. So we have to clean everything as we reuse nodes anyway.
106
+ effectfulFiber.nextEffect = null;
107
+ effectfulFiber = next;
108
+ }
109
+ }
110
+
111
+ function resetWorkPriority(workInProgress) {
112
+ var newPriority = NoWork;
113
+ // progressedChild is going to be the child set with the highest priority.
114
+ // Either it is the same as child, or it just bailed out because it choose
115
+ // not to do the work.
116
+ var child = workInProgress.progressedChild;
117
+ while (child) {
118
+ // Ensure that remaining work priority bubbles up.
119
+ if (child.pendingWorkPriority !== NoWork && (newPriority === NoWork || newPriority > child.pendingWorkPriority)) {
120
+ newPriority = child.pendingWorkPriority;
121
+ }
122
+ child = child.sibling;
123
+ }
124
+ workInProgress.pendingWorkPriority = newPriority;
125
+ }
126
+
127
+ function completeUnitOfWork(workInProgress) {
128
+ while (true) {
129
+ // The current, flushed, state of this fiber is the alternate.
130
+ // Ideally nothing should rely on this, but relying on it here
131
+ // means that we don't need an additional field on the work in
132
+ // progress.
133
+ var current = workInProgress.alternate;
134
+ var next = completeWork(current, workInProgress);
135
+
136
+ resetWorkPriority(workInProgress);
137
+
138
+ // The work is now done. We don't need this anymore. This flags
139
+ // to the system not to redo any work here.
140
+ workInProgress.pendingProps = null;
141
+ workInProgress.updateQueue = null;
142
+
143
+ var returnFiber = workInProgress['return'];
144
+
145
+ if (returnFiber) {
146
+ // Ensure that the first and last effect of the parent corresponds
147
+ // to the children's first and last effect. This probably relies on
148
+ // children completing in order.
149
+ if (!returnFiber.firstEffect) {
150
+ returnFiber.firstEffect = workInProgress.firstEffect;
151
+ }
152
+ if (workInProgress.lastEffect) {
153
+ if (returnFiber.lastEffect) {
154
+ returnFiber.lastEffect.nextEffect = workInProgress.firstEffect;
155
+ }
156
+ returnFiber.lastEffect = workInProgress.lastEffect;
157
+ }
158
+ }
159
+
160
+ if (next) {
161
+ // If completing this work spawned new work, do that next.
162
+ return next;
163
+ } else if (workInProgress.sibling) {
164
+ // If there is more work to do in this returnFiber, do that next.
165
+ return workInProgress.sibling;
166
+ } else if (returnFiber) {
167
+ // If there's no more work in this returnFiber. Complete the returnFiber.
168
+ workInProgress = returnFiber;
169
+ continue;
170
+ } else {
171
+ // If we're at the root, there's no more work to do. We can flush it.
172
+ var _root = workInProgress.stateNode;
173
+ if (_root.current === workInProgress) {
174
+ throw new Error('Cannot commit the same tree as before. This is probably a bug ' + 'related to the return field.');
175
+ }
176
+ _root.current = workInProgress;
177
+ // TODO: We can be smarter here and only look for more work in the
178
+ // "next" scheduled work since we've already scanned passed. That
179
+ // also ensures that work scheduled during reconciliation gets deferred.
180
+ // const hasMoreWork = workInProgress.pendingWorkPriority !== NoWork;
181
+ commitAllWork(workInProgress);
182
+ var nextWork = findNextUnitOfWork();
183
+ // if (!nextWork && hasMoreWork) {
184
+ // TODO: This can happen when some deep work completes and we don't
185
+ // know if this was the last one. We should be able to keep track of
186
+ // the highest priority still in the tree for one pass. But if we
187
+ // terminate an update we don't know.
188
+ // throw new Error('FiberRoots should not have flagged more work if there is none.');
189
+ // }
190
+ return nextWork;
191
+ }
192
+ }
193
+ }
194
+
195
+ function performUnitOfWork(workInProgress) {
196
+ // The current, flushed, state of this fiber is the alternate.
197
+ // Ideally nothing should rely on this, but relying on it here
198
+ // means that we don't need an additional field on the work in
199
+ // progress.
200
+ var current = workInProgress.alternate;
201
+ var next = beginWork(current, workInProgress, nextPriorityLevel);
202
+
203
+ if (next) {
204
+ // If this spawns new work, do that next.
205
+ return next;
206
+ } else {
207
+ // Otherwise, complete the current work.
208
+ return completeUnitOfWork(workInProgress);
209
+ }
210
+ }
211
+
212
+ function performDeferredWork(deadline) {
213
+ if (!nextUnitOfWork) {
214
+ nextUnitOfWork = findNextUnitOfWork();
215
+ }
216
+ while (nextUnitOfWork) {
217
+ if (deadline.timeRemaining() > timeHeuristicForUnitOfWork) {
218
+ nextUnitOfWork = performUnitOfWork(nextUnitOfWork);
219
+ if (!nextUnitOfWork) {
220
+ // Find more work. We might have time to complete some more.
221
+ nextUnitOfWork = findNextUnitOfWork();
222
+ }
223
+ } else {
224
+ scheduleDeferredCallback(performDeferredWork);
225
+ return;
226
+ }
227
+ }
228
+ }
229
+
230
+ function scheduleDeferredWork(root, priority) {
231
+ // We must reset the current unit of work pointer so that we restart the
232
+ // search from the root during the next tick, in case there is now higher
233
+ // priority work somewhere earlier than before.
234
+ if (priority <= nextPriorityLevel) {
235
+ nextUnitOfWork = null;
236
+ }
237
+
238
+ // Set the priority on the root, without deprioritizing
239
+ if (root.current.pendingWorkPriority === NoWork || priority <= root.current.pendingWorkPriority) {
240
+ root.current.pendingWorkPriority = priority;
241
+ }
242
+
243
+ if (root.isScheduled) {
244
+ // If we're already scheduled, we can bail out.
245
+ return;
246
+ }
247
+ root.isScheduled = true;
248
+ if (lastScheduledRoot) {
249
+ // Schedule ourselves to the end.
250
+ lastScheduledRoot.nextScheduledRoot = root;
251
+ lastScheduledRoot = root;
252
+ } else {
253
+ // We're the only work scheduled.
254
+ nextScheduledRoot = root;
255
+ lastScheduledRoot = root;
256
+ scheduleDeferredCallback(performDeferredWork);
257
+ }
258
+ }
259
+
260
+ function performAnimationWork() {
261
+ // Always start from the root
262
+ nextUnitOfWork = findNextUnitOfWork();
263
+ while (nextUnitOfWork && nextPriorityLevel !== NoWork) {
264
+ nextUnitOfWork = performUnitOfWork(nextUnitOfWork);
265
+ if (!nextUnitOfWork) {
266
+ // Keep searching for animation work until there's no more left
267
+ nextUnitOfWork = findNextUnitOfWork();
268
+ }
269
+ // Stop if the next unit of work is low priority
270
+ if (nextPriorityLevel > AnimationPriority) {
271
+ scheduleDeferredCallback(performDeferredWork);
272
+ return;
273
+ }
274
+ }
275
+ }
276
+
277
+ function scheduleAnimationWork(root, priorityLevel) {
278
+ // Set the priority on the root, without deprioritizing
279
+ if (root.current.pendingWorkPriority === NoWork || priorityLevel <= root.current.pendingWorkPriority) {
280
+ root.current.pendingWorkPriority = priorityLevel;
281
+ }
282
+
283
+ if (root.isScheduled) {
284
+ // If we're already scheduled, we can bail out.
285
+ return;
286
+ }
287
+ root.isScheduled = true;
288
+ if (lastScheduledRoot) {
289
+ // Schedule ourselves to the end.
290
+ lastScheduledRoot.nextScheduledRoot = root;
291
+ lastScheduledRoot = root;
292
+ } else {
293
+ // We're the only work scheduled.
294
+ nextScheduledRoot = root;
295
+ lastScheduledRoot = root;
296
+ scheduleAnimationCallback(performAnimationWork);
297
+ }
298
+ }
299
+
300
+ function scheduleWork(root) {
301
+ if (defaultPriority === SynchronousPriority) {
302
+ throw new Error('Not implemented yet');
303
+ }
304
+
305
+ if (defaultPriority === NoWork) {
306
+ return;
307
+ }
308
+ if (defaultPriority > AnimationPriority) {
309
+ scheduleDeferredWork(root, defaultPriority);
310
+ return;
311
+ }
312
+ scheduleAnimationWork(root, defaultPriority);
313
+ }
314
+
315
+ function performWithPriority(priorityLevel, fn) {
316
+ var previousDefaultPriority = defaultPriority;
317
+ defaultPriority = priorityLevel;
318
+ try {
319
+ fn();
320
+ } finally {
321
+ defaultPriority = previousDefaultPriority;
322
+ }
323
+ }
324
+
325
+ scheduler = {
326
+ scheduleWork: scheduleWork,
327
+ scheduleDeferredWork: scheduleDeferredWork,
328
+ performWithPriority: performWithPriority
329
+ };
330
+ return scheduler;
331
+ };
@@ -0,0 +1,77 @@
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 _assign = require('object-assign');
15
+
16
+ exports.createUpdateQueue = function (partialState) {
17
+ var queue = {
18
+ partialState: partialState,
19
+ callback: null,
20
+ callbackWasCalled: false,
21
+ next: null,
22
+ isReplace: false,
23
+ isForced: false,
24
+ tail: null
25
+ };
26
+ queue.tail = queue;
27
+ return queue;
28
+ };
29
+
30
+ exports.addToQueue = function (queue, partialState) {
31
+ var node = {
32
+ partialState: partialState,
33
+ callback: null,
34
+ callbackWasCalled: false,
35
+ next: null
36
+ };
37
+ queue.tail.next = node;
38
+ queue.tail = node;
39
+ return queue;
40
+ };
41
+
42
+ exports.addCallbackToQueue = function (queue, callback) {
43
+ if (queue.tail.callback) {
44
+ // If the tail already as a callback, add an empty node to queue
45
+ exports.addToQueue(queue, null);
46
+ }
47
+ queue.tail.callback = callback;
48
+ return queue;
49
+ };
50
+
51
+ exports.callCallbacks = function (queue, context) {
52
+ var node = queue;
53
+ while (node) {
54
+ if (node.callback && !node.callbackWasCalled) {
55
+ node.callbackWasCalled = true;
56
+ node.callback.call(context);
57
+ }
58
+ node = node.next;
59
+ }
60
+ };
61
+
62
+ exports.mergeUpdateQueue = function (queue, prevState, props) {
63
+ var node = queue;
64
+ var state = queue.isReplace ? null : _assign({}, prevState);
65
+ while (node) {
66
+ var _partialState = void 0;
67
+ if (typeof node.partialState === 'function') {
68
+ var updateFn = node.partialState;
69
+ _partialState = updateFn(state, props);
70
+ } else {
71
+ _partialState = node.partialState;
72
+ }
73
+ state = _assign(state || {}, _partialState);
74
+ node = node.next;
75
+ }
76
+ return state;
77
+ };
@@ -0,0 +1,67 @@
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 _prodInvariant = require('./reactProdInvariant');
14
+
15
+ var invariant = require('fbjs/lib/invariant');
16
+
17
+ var genericComponentClass = null;
18
+ var textComponentClass = null;
19
+
20
+ var ReactHostComponentInjection = {
21
+ // This accepts a class that receives the tag string. This is a catch all
22
+ // that can render any kind of tag.
23
+ injectGenericComponentClass: function (componentClass) {
24
+ genericComponentClass = componentClass;
25
+ },
26
+ // This accepts a text component class that takes the text string to be
27
+ // rendered as props.
28
+ injectTextComponentClass: function (componentClass) {
29
+ textComponentClass = componentClass;
30
+ }
31
+ };
32
+
33
+ /**
34
+ * Get a host internal component class for a specific tag.
35
+ *
36
+ * @param {ReactElement} element The element to create.
37
+ * @return {function} The internal class constructor function.
38
+ */
39
+ function createInternalComponent(element) {
40
+ !genericComponentClass ? process.env.NODE_ENV !== 'production' ? invariant(false, 'There is no registered component for the tag %s', element.type) : _prodInvariant('111', element.type) : void 0;
41
+ return new genericComponentClass(element);
42
+ }
43
+
44
+ /**
45
+ * @param {ReactText} text
46
+ * @return {ReactComponent}
47
+ */
48
+ function createInstanceForText(text) {
49
+ return new textComponentClass(text);
50
+ }
51
+
52
+ /**
53
+ * @param {ReactComponent} component
54
+ * @return {boolean}
55
+ */
56
+ function isTextComponent(component) {
57
+ return component instanceof textComponentClass;
58
+ }
59
+
60
+ var ReactHostComponent = {
61
+ createInternalComponent: createInternalComponent,
62
+ createInstanceForText: createInstanceForText,
63
+ isTextComponent: isTextComponent,
64
+ injection: ReactHostComponentInjection
65
+ };
66
+
67
+ module.exports = ReactHostComponent;
@@ -0,0 +1,33 @@
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 history = [];
15
+
16
+ var ReactHostOperationHistoryHook = {
17
+ onHostOperation: function (operation) {
18
+ history.push(operation);
19
+ },
20
+ clearHistory: function () {
21
+ if (ReactHostOperationHistoryHook._preventClearing) {
22
+ // Should only be used for tests.
23
+ return;
24
+ }
25
+
26
+ history = [];
27
+ },
28
+ getHistory: function () {
29
+ return history;
30
+ }
31
+ };
32
+
33
+ module.exports = ReactHostOperationHistoryHook;
@@ -0,0 +1,33 @@
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 DOMProperty = require('./DOMProperty');
14
+ var EventPluginHub = require('./EventPluginHub');
15
+ var EventPluginUtils = require('./EventPluginUtils');
16
+ var ReactComponentEnvironment = require('./ReactComponentEnvironment');
17
+ var ReactEmptyComponent = require('./ReactEmptyComponent');
18
+ var ReactBrowserEventEmitter = require('./ReactBrowserEventEmitter');
19
+ var ReactHostComponent = require('./ReactHostComponent');
20
+ var ReactUpdates = require('./ReactUpdates');
21
+
22
+ var ReactInjection = {
23
+ Component: ReactComponentEnvironment.injection,
24
+ DOMProperty: DOMProperty.injection,
25
+ EmptyComponent: ReactEmptyComponent.injection,
26
+ EventPluginHub: EventPluginHub.injection,
27
+ EventPluginUtils: EventPluginUtils.injection,
28
+ EventEmitter: ReactBrowserEventEmitter.injection,
29
+ HostComponent: ReactHostComponent.injection,
30
+ Updates: ReactUpdates.injection
31
+ };
32
+
33
+ module.exports = ReactInjection;