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,224 @@
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 _prodInvariant = require('./reactProdInvariant');
15
+
16
+ var invariant = require('fbjs/lib/invariant');
17
+
18
+ var OBSERVED_ERROR = {};
19
+
20
+ /**
21
+ * `Transaction` creates a black box that is able to wrap any method such that
22
+ * certain invariants are maintained before and after the method is invoked
23
+ * (Even if an exception is thrown while invoking the wrapped method). Whoever
24
+ * instantiates a transaction can provide enforcers of the invariants at
25
+ * creation time. The `Transaction` class itself will supply one additional
26
+ * automatic invariant for you - the invariant that any transaction instance
27
+ * should not be run while it is already being run. You would typically create a
28
+ * single instance of a `Transaction` for reuse multiple times, that potentially
29
+ * is used to wrap several different methods. Wrappers are extremely simple -
30
+ * they only require implementing two methods.
31
+ *
32
+ * <pre>
33
+ * wrappers (injected at creation time)
34
+ * + +
35
+ * | |
36
+ * +-----------------|--------|--------------+
37
+ * | v | |
38
+ * | +---------------+ | |
39
+ * | +--| wrapper1 |---|----+ |
40
+ * | | +---------------+ v | |
41
+ * | | +-------------+ | |
42
+ * | | +----| wrapper2 |--------+ |
43
+ * | | | +-------------+ | | |
44
+ * | | | | | |
45
+ * | v v v v | wrapper
46
+ * | +---+ +---+ +---------+ +---+ +---+ | invariants
47
+ * perform(anyMethod) | | | | | | | | | | | | maintained
48
+ * +----------------->|-|---|-|---|-->|anyMethod|---|---|-|---|-|-------->
49
+ * | | | | | | | | | | | |
50
+ * | | | | | | | | | | | |
51
+ * | | | | | | | | | | | |
52
+ * | +---+ +---+ +---------+ +---+ +---+ |
53
+ * | initialize close |
54
+ * +-----------------------------------------+
55
+ * </pre>
56
+ *
57
+ * Use cases:
58
+ * - Preserving the input selection ranges before/after reconciliation.
59
+ * Restoring selection even in the event of an unexpected error.
60
+ * - Deactivating events while rearranging the DOM, preventing blurs/focuses,
61
+ * while guaranteeing that afterwards, the event system is reactivated.
62
+ * - Flushing a queue of collected DOM mutations to the main UI thread after a
63
+ * reconciliation takes place in a worker thread.
64
+ * - Invoking any collected `componentDidUpdate` callbacks after rendering new
65
+ * content.
66
+ * - (Future use case): Wrapping particular flushes of the `ReactWorker` queue
67
+ * to preserve the `scrollTop` (an automatic scroll aware DOM).
68
+ * - (Future use case): Layout calculations before and after DOM updates.
69
+ *
70
+ * Transactional plugin API:
71
+ * - A module that has an `initialize` method that returns any precomputation.
72
+ * - and a `close` method that accepts the precomputation. `close` is invoked
73
+ * when the wrapped process is completed, or has failed.
74
+ *
75
+ * @param {Array<TransactionalWrapper>} transactionWrapper Wrapper modules
76
+ * that implement `initialize` and `close`.
77
+ * @return {Transaction} Single transaction for reuse in thread.
78
+ *
79
+ * @class Transaction
80
+ */
81
+ var TransactionImpl = {
82
+ /**
83
+ * Sets up this instance so that it is prepared for collecting metrics. Does
84
+ * so such that this setup method may be used on an instance that is already
85
+ * initialized, in a way that does not consume additional memory upon reuse.
86
+ * That can be useful if you decide to make your subclass of this mixin a
87
+ * "PooledClass".
88
+ */
89
+ reinitializeTransaction: function () {
90
+ this.transactionWrappers = this.getTransactionWrappers();
91
+ if (this.wrapperInitData) {
92
+ this.wrapperInitData.length = 0;
93
+ } else {
94
+ this.wrapperInitData = [];
95
+ }
96
+ this._isInTransaction = false;
97
+ },
98
+
99
+ _isInTransaction: false,
100
+
101
+ /**
102
+ * @abstract
103
+ * @return {Array<TransactionWrapper>} Array of transaction wrappers.
104
+ */
105
+ getTransactionWrappers: null,
106
+
107
+ isInTransaction: function () {
108
+ return !!this._isInTransaction;
109
+ },
110
+
111
+ /**
112
+ * Executes the function within a safety window. Use this for the top level
113
+ * methods that result in large amounts of computation/mutations that would
114
+ * need to be safety checked. The optional arguments helps prevent the need
115
+ * to bind in many cases.
116
+ *
117
+ * @param {function} method Member of scope to call.
118
+ * @param {Object} scope Scope to invoke from.
119
+ * @param {Object?=} a Argument to pass to the method.
120
+ * @param {Object?=} b Argument to pass to the method.
121
+ * @param {Object?=} c Argument to pass to the method.
122
+ * @param {Object?=} d Argument to pass to the method.
123
+ * @param {Object?=} e Argument to pass to the method.
124
+ * @param {Object?=} f Argument to pass to the method.
125
+ *
126
+ * @return {*} Return value from `method`.
127
+ */
128
+ perform: function (method, scope, a, b, c, d, e, f) {
129
+ !!this.isInTransaction() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Transaction.perform(...): Cannot initialize a transaction when there is already an outstanding transaction.') : _prodInvariant('27') : void 0;
130
+ var errorThrown;
131
+ var ret;
132
+ try {
133
+ this._isInTransaction = true;
134
+ // Catching errors makes debugging more difficult, so we start with
135
+ // errorThrown set to true before setting it to false after calling
136
+ // close -- if it's still set to true in the finally block, it means
137
+ // one of these calls threw.
138
+ errorThrown = true;
139
+ this.initializeAll(0);
140
+ ret = method.call(scope, a, b, c, d, e, f);
141
+ errorThrown = false;
142
+ } finally {
143
+ try {
144
+ if (errorThrown) {
145
+ // If `method` throws, prefer to show that stack trace over any thrown
146
+ // by invoking `closeAll`.
147
+ try {
148
+ this.closeAll(0);
149
+ } catch (err) {}
150
+ } else {
151
+ // Since `method` didn't throw, we don't want to silence the exception
152
+ // here.
153
+ this.closeAll(0);
154
+ }
155
+ } finally {
156
+ this._isInTransaction = false;
157
+ }
158
+ }
159
+ return ret;
160
+ },
161
+
162
+ initializeAll: function (startIndex) {
163
+ var transactionWrappers = this.transactionWrappers;
164
+ for (var i = startIndex; i < transactionWrappers.length; i++) {
165
+ var wrapper = transactionWrappers[i];
166
+ try {
167
+ // Catching errors makes debugging more difficult, so we start with the
168
+ // OBSERVED_ERROR state before overwriting it with the real return value
169
+ // of initialize -- if it's still set to OBSERVED_ERROR in the finally
170
+ // block, it means wrapper.initialize threw.
171
+ this.wrapperInitData[i] = OBSERVED_ERROR;
172
+ this.wrapperInitData[i] = wrapper.initialize ? wrapper.initialize.call(this) : null;
173
+ } finally {
174
+ if (this.wrapperInitData[i] === OBSERVED_ERROR) {
175
+ // The initializer for wrapper i threw an error; initialize the
176
+ // remaining wrappers but silence any exceptions from them to ensure
177
+ // that the first error is the one to bubble up.
178
+ try {
179
+ this.initializeAll(i + 1);
180
+ } catch (err) {}
181
+ }
182
+ }
183
+ }
184
+ },
185
+
186
+ /**
187
+ * Invokes each of `this.transactionWrappers.close[i]` functions, passing into
188
+ * them the respective return values of `this.transactionWrappers.init[i]`
189
+ * (`close`rs that correspond to initializers that failed will not be
190
+ * invoked).
191
+ */
192
+ closeAll: function (startIndex) {
193
+ !this.isInTransaction() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Transaction.closeAll(): Cannot close transaction when none are open.') : _prodInvariant('28') : void 0;
194
+ var transactionWrappers = this.transactionWrappers;
195
+ for (var i = startIndex; i < transactionWrappers.length; i++) {
196
+ var wrapper = transactionWrappers[i];
197
+ var initData = this.wrapperInitData[i];
198
+ var errorThrown;
199
+ try {
200
+ // Catching errors makes debugging more difficult, so we start with
201
+ // errorThrown set to true before setting it to false after calling
202
+ // close -- if it's still set to true in the finally block, it means
203
+ // wrapper.close threw.
204
+ errorThrown = true;
205
+ if (initData !== OBSERVED_ERROR && wrapper.close) {
206
+ wrapper.close.call(this, initData);
207
+ }
208
+ errorThrown = false;
209
+ } finally {
210
+ if (errorThrown) {
211
+ // The closer for wrapper i threw an error; close the remaining
212
+ // wrappers but silence any exceptions from them to ensure that the
213
+ // first error is the one to bubble up.
214
+ try {
215
+ this.closeAll(i + 1);
216
+ } catch (e) {}
217
+ }
218
+ }
219
+ }
220
+ this.wrapperInitData.length = 0;
221
+ }
222
+ };
223
+
224
+ module.exports = TransactionImpl;
@@ -0,0 +1,26 @@
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 ViewportMetrics = {
14
+
15
+ currentScrollLeft: 0,
16
+
17
+ currentScrollTop: 0,
18
+
19
+ refreshScrollValues: function (scrollPosition) {
20
+ ViewportMetrics.currentScrollLeft = scrollPosition.x;
21
+ ViewportMetrics.currentScrollTop = scrollPosition.y;
22
+ }
23
+
24
+ };
25
+
26
+ module.exports = ViewportMetrics;
@@ -0,0 +1,45 @@
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 _prodInvariant = require('./reactProdInvariant');
15
+
16
+ var invariant = require('fbjs/lib/invariant');
17
+
18
+ /**
19
+ * Accumulates items that must not be null or undefined.
20
+ *
21
+ * This is used to conserve memory by avoiding array allocations.
22
+ *
23
+ * @return {*|array<*>} An accumulation of items.
24
+ */
25
+ function accumulate(current, next) {
26
+ !(next != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'accumulate(...): Accumulated items must be not be null or undefined.') : _prodInvariant('29') : void 0;
27
+
28
+ if (current == null) {
29
+ return next;
30
+ }
31
+
32
+ // Both are not empty. Warning: Never call x.concat(y) when you are not
33
+ // certain that x is an Array (x could be a string with concat method).
34
+ if (Array.isArray(current)) {
35
+ return current.concat(next);
36
+ }
37
+
38
+ if (Array.isArray(next)) {
39
+ return [current].concat(next);
40
+ }
41
+
42
+ return [current, next];
43
+ }
44
+
45
+ module.exports = accumulate;
@@ -0,0 +1,57 @@
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
+ var _prodInvariant = require('./reactProdInvariant');
15
+
16
+ var invariant = require('fbjs/lib/invariant');
17
+
18
+ /**
19
+ * Accumulates items that must not be null or undefined into the first one. This
20
+ * is used to conserve memory by avoiding array allocations, and thus sacrifices
21
+ * API cleanness. Since `current` can be null before being passed in and not
22
+ * null after this function, make sure to assign it back to `current`:
23
+ *
24
+ * `a = accumulateInto(a, b);`
25
+ *
26
+ * This API should be sparingly used. Try `accumulate` for something cleaner.
27
+ *
28
+ * @return {*|array<*>} An accumulation of items.
29
+ */
30
+
31
+ function accumulateInto(current, next) {
32
+ !(next != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'accumulateInto(...): Accumulated items must not be null or undefined.') : _prodInvariant('30') : void 0;
33
+
34
+ if (current == null) {
35
+ return next;
36
+ }
37
+
38
+ // Both are not empty. Warning: Never call x.concat(y) when you are not
39
+ // certain that x is an Array (x could be a string with concat method).
40
+ if (Array.isArray(current)) {
41
+ if (Array.isArray(next)) {
42
+ current.push.apply(current, next);
43
+ return current;
44
+ }
45
+ current.push(next);
46
+ return current;
47
+ }
48
+
49
+ if (Array.isArray(next)) {
50
+ // A bit too dangerous to mutate `next`.
51
+ return [current].concat(next);
52
+ }
53
+
54
+ return [current, next];
55
+ }
56
+
57
+ module.exports = accumulateInto;
@@ -0,0 +1,43 @@
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 MOD = 65521;
15
+
16
+ // adler32 is not cryptographically strong, and is only used to sanity check that
17
+ // markup generated on the server matches the markup generated on the client.
18
+ // This implementation (a modified version of the SheetJS version) has been optimized
19
+ // for our use case, at the expense of conforming to the adler32 specification
20
+ // for non-ascii inputs.
21
+ function adler32(data) {
22
+ var a = 1;
23
+ var b = 0;
24
+ var i = 0;
25
+ var l = data.length;
26
+ var m = l & ~0x3;
27
+ while (i < m) {
28
+ var n = Math.min(i + 4096, m);
29
+ for (; i < n; i += 4) {
30
+ b += (a += data.charCodeAt(i)) + (a += data.charCodeAt(i + 1)) + (a += data.charCodeAt(i + 2)) + (a += data.charCodeAt(i + 3));
31
+ }
32
+ a %= MOD;
33
+ b %= MOD;
34
+ }
35
+ for (; i < l; i++) {
36
+ b += a += data.charCodeAt(i);
37
+ }
38
+ a %= MOD;
39
+ b %= MOD;
40
+ return a | b << 16;
41
+ }
42
+
43
+ module.exports = adler32;
@@ -0,0 +1,25 @@
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 canDefineProperty = false;
15
+ if (process.env.NODE_ENV !== 'production') {
16
+ try {
17
+ // $FlowFixMe https://github.com/facebook/flow/issues/285
18
+ Object.defineProperty({}, 'x', { get: function () {} });
19
+ canDefineProperty = true;
20
+ } catch (x) {
21
+ // IE will fail on defineProperty
22
+ }
23
+ }
24
+
25
+ module.exports = canDefineProperty;
@@ -0,0 +1,86 @@
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 _prodInvariant = require('./reactProdInvariant');
14
+
15
+ var ReactPropTypeLocationNames = require('./ReactPropTypeLocationNames');
16
+ var ReactPropTypesSecret = require('./ReactPropTypesSecret');
17
+
18
+ var invariant = require('fbjs/lib/invariant');
19
+ var warning = require('fbjs/lib/warning');
20
+
21
+ var ReactComponentTreeHook;
22
+
23
+ if (typeof process !== 'undefined' && process.env && process.env.NODE_ENV === 'test') {
24
+ // Temporary hack.
25
+ // Inline requires don't work well with Jest:
26
+ // https://github.com/facebook/react/issues/7240
27
+ // Remove the inline requires when we don't need them anymore:
28
+ // https://github.com/facebook/react/pull/7178
29
+ ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
30
+ }
31
+
32
+ var loggedTypeFailures = {};
33
+
34
+ /**
35
+ * Assert that the values match with the type specs.
36
+ * Error messages are memorized and will only be shown once.
37
+ *
38
+ * @param {object} typeSpecs Map of name to a ReactPropType
39
+ * @param {object} values Runtime values that need to be type-checked
40
+ * @param {string} location e.g. "prop", "context", "child context"
41
+ * @param {string} componentName Name of the component for error messages.
42
+ * @param {?object} element The React element that is being type-checked
43
+ * @param {?number} debugID The React component instance that is being type-checked
44
+ * @private
45
+ */
46
+ function checkReactTypeSpec(typeSpecs, values, location, componentName, element, debugID) {
47
+ for (var typeSpecName in typeSpecs) {
48
+ if (typeSpecs.hasOwnProperty(typeSpecName)) {
49
+ var error;
50
+ // Prop type validation may throw. In case they do, we don't want to
51
+ // fail the render phase where it didn't fail before. So we log it.
52
+ // After these have been cleaned up, we'll let them throw.
53
+ try {
54
+ // This is intentionally an invariant that gets caught. It's the same
55
+ // behavior as without this statement except with a better message.
56
+ !(typeof typeSpecs[typeSpecName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName) : _prodInvariant('84', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName) : void 0;
57
+ error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
58
+ } catch (ex) {
59
+ error = ex;
60
+ }
61
+ process.env.NODE_ENV !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], typeSpecName, typeof error) : void 0;
62
+ if (error instanceof Error && !(error.message in loggedTypeFailures)) {
63
+ // Only monitor this failure once because there tends to be a lot of the
64
+ // same error.
65
+ loggedTypeFailures[error.message] = true;
66
+
67
+ var componentStackInfo = '';
68
+
69
+ if (process.env.NODE_ENV !== 'production') {
70
+ if (!ReactComponentTreeHook) {
71
+ ReactComponentTreeHook = require('react/lib/ReactComponentTreeHook');
72
+ }
73
+ if (debugID !== null) {
74
+ componentStackInfo = ReactComponentTreeHook.getStackAddendumByID(debugID);
75
+ } else if (element !== null) {
76
+ componentStackInfo = ReactComponentTreeHook.getCurrentStackAddendum(element);
77
+ }
78
+ }
79
+
80
+ process.env.NODE_ENV !== 'production' ? warning(false, 'Failed %s type: %s%s', location, error.message, componentStackInfo) : void 0;
81
+ }
82
+ }
83
+ }
84
+ }
85
+
86
+ module.exports = checkReactTypeSpec;
@@ -0,0 +1,31 @@
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
+ /* globals MSApp */
12
+
13
+ 'use strict';
14
+
15
+ /**
16
+ * Create a function which has 'unsafe' privileges (required by windows8 apps)
17
+ */
18
+
19
+ var createMicrosoftUnsafeLocalFunction = function (func) {
20
+ if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
21
+ return function (arg0, arg1, arg2, arg3) {
22
+ MSApp.execUnsafeLocalFunction(function () {
23
+ return func(arg0, arg1, arg2, arg3);
24
+ });
25
+ };
26
+ } else {
27
+ return func;
28
+ }
29
+ };
30
+
31
+ module.exports = createMicrosoftUnsafeLocalFunction;
@@ -0,0 +1,78 @@
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 CSSProperty = require('./CSSProperty');
14
+ var warning = require('fbjs/lib/warning');
15
+
16
+ var isUnitlessNumber = CSSProperty.isUnitlessNumber;
17
+ var styleWarnings = {};
18
+
19
+ /**
20
+ * Convert a value into the proper css writable value. The style name `name`
21
+ * should be logical (no hyphens), as specified
22
+ * in `CSSProperty.isUnitlessNumber`.
23
+ *
24
+ * @param {string} name CSS property name such as `topMargin`.
25
+ * @param {*} value CSS property value such as `10px`.
26
+ * @param {ReactDOMComponent} component
27
+ * @return {string} Normalized style value with dimensions applied.
28
+ */
29
+ function dangerousStyleValue(name, value, component) {
30
+ // Note that we've removed escapeTextForBrowser() calls here since the
31
+ // whole string will be escaped when the attribute is injected into
32
+ // the markup. If you provide unsafe user data here they can inject
33
+ // arbitrary CSS which may be problematic (I couldn't repro this):
34
+ // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
35
+ // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
36
+ // This is not an XSS hole but instead a potential CSS injection issue
37
+ // which has lead to a greater discussion about how we're going to
38
+ // trust URLs moving forward. See #2115901
39
+
40
+ var isEmpty = value == null || typeof value === 'boolean' || value === '';
41
+ if (isEmpty) {
42
+ return '';
43
+ }
44
+
45
+ var isNonNumeric = isNaN(value);
46
+ if (isNonNumeric || value === 0 || isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]) {
47
+ return '' + value; // cast to string
48
+ }
49
+
50
+ if (typeof value === 'string') {
51
+ if (process.env.NODE_ENV !== 'production') {
52
+ // Allow '0' to pass through without warning. 0 is already special and
53
+ // doesn't require units, so we don't need to warn about it.
54
+ if (component && value !== '0') {
55
+ var owner = component._currentElement._owner;
56
+ var ownerName = owner ? owner.getName() : null;
57
+ if (ownerName && !styleWarnings[ownerName]) {
58
+ styleWarnings[ownerName] = {};
59
+ }
60
+ var warned = false;
61
+ if (ownerName) {
62
+ var warnings = styleWarnings[ownerName];
63
+ warned = warnings[name];
64
+ if (!warned) {
65
+ warnings[name] = true;
66
+ }
67
+ }
68
+ if (!warned) {
69
+ process.env.NODE_ENV !== 'production' ? warning(false, 'a `%s` tag (owner: `%s`) was passed a numeric string value ' + 'for CSS property `%s` (value: `%s`) which will be treated ' + 'as a unitless number in a future version of React.', component._currentElement.type, ownerName || 'unknown', name, value) : void 0;
70
+ }
71
+ }
72
+ }
73
+ value = value.trim();
74
+ }
75
+ return value + 'px';
76
+ }
77
+
78
+ module.exports = dangerousStyleValue;
@@ -0,0 +1,56 @@
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
+ var warning = require('fbjs/lib/warning');
17
+
18
+ /**
19
+ * This will log a single deprecation notice per function and forward the call
20
+ * on to the new API.
21
+ *
22
+ * @param {string} fnName The name of the function
23
+ * @param {string} newModule The module that fn will exist in
24
+ * @param {string} newPackage The module that fn will exist in
25
+ * @param {*} ctx The context this forwarded call should run in
26
+ * @param {function} fn The function to forward on to
27
+ * @return {function} The function that will warn once and then call fn
28
+ */
29
+ function deprecated(fnName, newModule, newPackage, ctx, fn) {
30
+ var warned = false;
31
+ if (process.env.NODE_ENV !== 'production') {
32
+ var newFn = function () {
33
+ process.env.NODE_ENV !== 'production' ? warning(warned,
34
+ /* eslint-disable no-useless-concat */
35
+ // Require examples in this string must be split to prevent React's
36
+ // build tools from mistaking them for real requires.
37
+ // Otherwise the build tools will attempt to build a '%s' module.
38
+ 'React.%s is deprecated. Please use %s.%s from require' + '(\'%s\') ' + 'instead.', fnName, newModule, fnName, newPackage) : void 0;
39
+ /* eslint-enable no-useless-concat */
40
+ warned = true;
41
+ return fn.apply(ctx, arguments);
42
+ };
43
+ // We need to make sure all properties of the original fn are copied over.
44
+ // In particular, this is needed to support PropTypes
45
+ _assign(newFn, fn);
46
+
47
+ // Flow is not smart enough to figure out that newFn is of the same type as
48
+ // fn. Since we don't want to lose out the type of the function, casting
49
+ // to any and force flow to use T.
50
+ return newFn;
51
+ }
52
+
53
+ return fn;
54
+ }
55
+
56
+ module.exports = deprecated;