react 15.2.0 → 15.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/react-with-addons.js +1099 -999
- package/dist/react-with-addons.min.js +6 -7
- package/dist/react.js +1034 -935
- package/dist/react.min.js +6 -6
- package/lib/DOMProperty.js +0 -9
- package/lib/DOMPropertyOperations.js +4 -12
- package/lib/Danger.js +0 -98
- package/lib/KeyEscapeUtils.js +2 -1
- package/lib/PooledClass.js +1 -1
- package/lib/ReactChildReconciler.js +3 -3
- package/lib/ReactComponentTreeDevtool.js +0 -5
- package/lib/ReactCompositeComponent.js +23 -13
- package/lib/ReactDOMComponent.js +1 -1
- package/lib/ReactDOMDebugTool.js +11 -11
- package/lib/ReactDOMFiber.js +78 -0
- package/lib/ReactDOMInput.js +17 -15
- package/lib/ReactDOMInstrumentation.js +7 -2
- package/lib/ReactDOMNullInputValuePropDevtool.js +43 -0
- package/lib/ReactDOMSelect.js +0 -13
- package/lib/ReactDOMTextarea.js +0 -14
- package/lib/ReactDebugTool.js +75 -83
- package/lib/ReactFeatureFlags.js +1 -0
- package/lib/ReactInstrumentation.js +7 -2
- package/lib/ReactMount.js +15 -17
- package/lib/ReactMultiChild.js +8 -3
- package/lib/ReactNativeMount.js +2 -13
- package/lib/ReactNativeReconcileTransaction.js +16 -0
- package/lib/ReactNodeTypes.js +1 -0
- package/lib/ReactNoop.js +100 -3
- package/lib/ReactNoopUpdateQueue.js +6 -5
- package/lib/ReactReconcileTransaction.js +16 -0
- package/lib/ReactServerRendering.js +1 -5
- package/lib/ReactServerRenderingTransaction.js +17 -0
- package/lib/ReactServerUpdateQueue.js +141 -0
- package/lib/ReactTestMount.js +1 -12
- package/lib/ReactTestReconcileTransaction.js +8 -0
- package/lib/ReactTransitionGroup.js +1 -0
- package/lib/ReactUpdateQueue.js +4 -2
- package/lib/ReactUpdates.js +1 -10
- package/lib/ReactVersion.js +1 -1
- package/lib/ResponderEventPlugin.js +1 -1
- package/lib/ResponderTouchHistoryStore.js +97 -95
- package/lib/accumulate.js +14 -14
- package/lib/accumulateInto.js +8 -11
- package/lib/adler32.js +1 -0
- package/lib/checkReactTypeSpec.js +7 -5
- package/lib/deprecated.js +7 -1
- package/lib/flattenChildren.js +11 -8
- package/lib/forEachAccumulated.js +3 -2
- package/lib/getIteratorFn.js +1 -0
- package/lib/instantiateReactComponent.js +8 -7
- package/lib/isTextInputElement.js +11 -1
- package/lib/reactProdInvariant.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2015-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
|
+
* @providesModule ReactServerUpdateQueue
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
16
|
+
|
|
17
|
+
var ReactUpdateQueue = require('./ReactUpdateQueue');
|
|
18
|
+
var Transaction = require('./Transaction');
|
|
19
|
+
var warning = require('fbjs/lib/warning');
|
|
20
|
+
|
|
21
|
+
function warnNoop(publicInstance, callerName) {
|
|
22
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
23
|
+
var constructor = publicInstance.constructor;
|
|
24
|
+
process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): Can only update a mounting component. ' + 'This usually means you called %s() outside componentWillMount() on the server. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, constructor && (constructor.displayName || constructor.name) || 'ReactClass') : void 0;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* This is the update queue used for server rendering.
|
|
30
|
+
* It delegates to ReactUpdateQueue while server rendering is in progress and
|
|
31
|
+
* switches to ReactNoopUpdateQueue after the transaction has completed.
|
|
32
|
+
* @class ReactServerUpdateQueue
|
|
33
|
+
* @param {Transaction} transaction
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
var ReactServerUpdateQueue = function () {
|
|
37
|
+
/* :: transaction: Transaction; */
|
|
38
|
+
|
|
39
|
+
function ReactServerUpdateQueue(transaction) {
|
|
40
|
+
_classCallCheck(this, ReactServerUpdateQueue);
|
|
41
|
+
|
|
42
|
+
this.transaction = transaction;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Checks whether or not this composite component is mounted.
|
|
47
|
+
* @param {ReactClass} publicInstance The instance we want to test.
|
|
48
|
+
* @return {boolean} True if mounted, false otherwise.
|
|
49
|
+
* @protected
|
|
50
|
+
* @final
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
ReactServerUpdateQueue.prototype.isMounted = function isMounted(publicInstance) {
|
|
55
|
+
return false;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Enqueue a callback that will be executed after all the pending updates
|
|
60
|
+
* have processed.
|
|
61
|
+
*
|
|
62
|
+
* @param {ReactClass} publicInstance The instance to use as `this` context.
|
|
63
|
+
* @param {?function} callback Called after state is updated.
|
|
64
|
+
* @internal
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
ReactServerUpdateQueue.prototype.enqueueCallback = function enqueueCallback(publicInstance, callback, callerName) {
|
|
69
|
+
if (this.transaction.isInTransaction()) {
|
|
70
|
+
ReactUpdateQueue.enqueueCallback(publicInstance, callback, callerName);
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Forces an update. This should only be invoked when it is known with
|
|
76
|
+
* certainty that we are **not** in a DOM transaction.
|
|
77
|
+
*
|
|
78
|
+
* You may want to call this when you know that some deeper aspect of the
|
|
79
|
+
* component's state has changed but `setState` was not called.
|
|
80
|
+
*
|
|
81
|
+
* This will not invoke `shouldComponentUpdate`, but it will invoke
|
|
82
|
+
* `componentWillUpdate` and `componentDidUpdate`.
|
|
83
|
+
*
|
|
84
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
ReactServerUpdateQueue.prototype.enqueueForceUpdate = function enqueueForceUpdate(publicInstance) {
|
|
90
|
+
if (this.transaction.isInTransaction()) {
|
|
91
|
+
ReactUpdateQueue.enqueueForceUpdate(publicInstance);
|
|
92
|
+
} else {
|
|
93
|
+
warnNoop(publicInstance, 'forceUpdate');
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Replaces all of the state. Always use this or `setState` to mutate state.
|
|
99
|
+
* You should treat `this.state` as immutable.
|
|
100
|
+
*
|
|
101
|
+
* There is no guarantee that `this.state` will be immediately updated, so
|
|
102
|
+
* accessing `this.state` after calling this method may return the old value.
|
|
103
|
+
*
|
|
104
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
105
|
+
* @param {object|function} completeState Next state.
|
|
106
|
+
* @internal
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
ReactServerUpdateQueue.prototype.enqueueReplaceState = function enqueueReplaceState(publicInstance, completeState) {
|
|
111
|
+
if (this.transaction.isInTransaction()) {
|
|
112
|
+
ReactUpdateQueue.enqueueReplaceState(publicInstance, completeState);
|
|
113
|
+
} else {
|
|
114
|
+
warnNoop(publicInstance, 'replaceState');
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Sets a subset of the state. This only exists because _pendingState is
|
|
120
|
+
* internal. This provides a merging strategy that is not available to deep
|
|
121
|
+
* properties which is confusing. TODO: Expose pendingState or don't use it
|
|
122
|
+
* during the merge.
|
|
123
|
+
*
|
|
124
|
+
* @param {ReactClass} publicInstance The instance that should rerender.
|
|
125
|
+
* @param {object|function} partialState Next partial state to be merged with state.
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
ReactServerUpdateQueue.prototype.enqueueSetState = function enqueueSetState(publicInstance, partialState) {
|
|
131
|
+
if (this.transaction.isInTransaction()) {
|
|
132
|
+
ReactUpdateQueue.enqueueSetState(publicInstance, partialState);
|
|
133
|
+
} else {
|
|
134
|
+
warnNoop(publicInstance, 'setState');
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
return ReactServerUpdateQueue;
|
|
139
|
+
}();
|
|
140
|
+
|
|
141
|
+
module.exports = ReactServerUpdateQueue;
|
package/lib/ReactTestMount.js
CHANGED
|
@@ -96,17 +96,7 @@ var ReactHostMount = {
|
|
|
96
96
|
// }
|
|
97
97
|
// }
|
|
98
98
|
|
|
99
|
-
var instance = instantiateReactComponent(nextWrappedElement);
|
|
100
|
-
|
|
101
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
102
|
-
// Mute future events from the top level wrapper.
|
|
103
|
-
// It is an implementation detail that devtools should not know about.
|
|
104
|
-
instance._debugID = 0;
|
|
105
|
-
|
|
106
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
107
|
-
ReactInstrumentation.debugTool.onBeginFlush();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
99
|
+
var instance = instantiateReactComponent(nextWrappedElement, false);
|
|
110
100
|
|
|
111
101
|
// The initial render is synchronous but any updates that happen during
|
|
112
102
|
// rendering, in componentWillMount or componentDidMount, will be batched
|
|
@@ -116,7 +106,6 @@ var ReactHostMount = {
|
|
|
116
106
|
if (process.env.NODE_ENV !== 'production') {
|
|
117
107
|
// The instance here is TopLevelWrapper so we report mount for its child.
|
|
118
108
|
ReactInstrumentation.debugTool.onMountRootComponent(instance._renderedComponent._debugID);
|
|
119
|
-
ReactInstrumentation.debugTool.onEndFlush();
|
|
120
109
|
}
|
|
121
110
|
return new ReactTestInstance(instance);
|
|
122
111
|
}
|
|
@@ -16,6 +16,7 @@ var _assign = require('object-assign');
|
|
|
16
16
|
var CallbackQueue = require('./CallbackQueue');
|
|
17
17
|
var PooledClass = require('./PooledClass');
|
|
18
18
|
var Transaction = require('./Transaction');
|
|
19
|
+
var ReactUpdateQueue = require('./ReactUpdateQueue');
|
|
19
20
|
|
|
20
21
|
/**
|
|
21
22
|
* Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks during
|
|
@@ -83,6 +84,13 @@ var Mixin = {
|
|
|
83
84
|
return this.reactMountReady;
|
|
84
85
|
},
|
|
85
86
|
|
|
87
|
+
/**
|
|
88
|
+
* @return {object} The queue to collect React async events.
|
|
89
|
+
*/
|
|
90
|
+
getUpdateQueue: function () {
|
|
91
|
+
return ReactUpdateQueue;
|
|
92
|
+
},
|
|
93
|
+
|
|
86
94
|
/**
|
|
87
95
|
* `PooledClass` looks for this, and will invoke this before allowing this
|
|
88
96
|
* instance to be reused.
|
|
@@ -236,6 +236,7 @@ var ReactTransitionGroup = React.createClass({
|
|
|
236
236
|
delete props.childFactory;
|
|
237
237
|
delete props.transitionLeaveTimeout;
|
|
238
238
|
delete props.transitionEnterTimeout;
|
|
239
|
+
delete props.transitionAppearTimeout;
|
|
239
240
|
delete props.component;
|
|
240
241
|
|
|
241
242
|
return React.createElement(this.props.component, props, childrenToRender);
|
package/lib/ReactUpdateQueue.js
CHANGED
|
@@ -209,8 +209,10 @@ var ReactUpdateQueue = {
|
|
|
209
209
|
enqueueUpdate(internalInstance);
|
|
210
210
|
},
|
|
211
211
|
|
|
212
|
-
enqueueElementInternal: function (internalInstance,
|
|
213
|
-
internalInstance._pendingElement =
|
|
212
|
+
enqueueElementInternal: function (internalInstance, nextElement, nextContext) {
|
|
213
|
+
internalInstance._pendingElement = nextElement;
|
|
214
|
+
// TODO: introduce _pendingContext instead of setting it directly.
|
|
215
|
+
internalInstance._context = nextContext;
|
|
214
216
|
enqueueUpdate(internalInstance);
|
|
215
217
|
},
|
|
216
218
|
|
package/lib/ReactUpdates.js
CHANGED
|
@@ -17,7 +17,6 @@ var _prodInvariant = require('./reactProdInvariant'),
|
|
|
17
17
|
var CallbackQueue = require('./CallbackQueue');
|
|
18
18
|
var PooledClass = require('./PooledClass');
|
|
19
19
|
var ReactFeatureFlags = require('./ReactFeatureFlags');
|
|
20
|
-
var ReactInstrumentation = require('./ReactInstrumentation');
|
|
21
20
|
var ReactReconciler = require('./ReactReconciler');
|
|
22
21
|
var Transaction = require('./Transaction');
|
|
23
22
|
|
|
@@ -164,10 +163,6 @@ function runBatchedUpdates(transaction) {
|
|
|
164
163
|
}
|
|
165
164
|
|
|
166
165
|
var flushBatchedUpdates = function () {
|
|
167
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
168
|
-
ReactInstrumentation.debugTool.onBeginFlush();
|
|
169
|
-
}
|
|
170
|
-
|
|
171
166
|
// ReactUpdatesFlushTransaction's wrappers will clear the dirtyComponents
|
|
172
167
|
// array and perform any updates enqueued by mount-ready handlers (i.e.,
|
|
173
168
|
// componentDidUpdate) but we need to check here too in order to catch
|
|
@@ -187,10 +182,6 @@ var flushBatchedUpdates = function () {
|
|
|
187
182
|
CallbackQueue.release(queue);
|
|
188
183
|
}
|
|
189
184
|
}
|
|
190
|
-
|
|
191
|
-
if (process.env.NODE_ENV !== 'production') {
|
|
192
|
-
ReactInstrumentation.debugTool.onEndFlush();
|
|
193
|
-
}
|
|
194
185
|
};
|
|
195
186
|
|
|
196
187
|
/**
|
|
@@ -203,7 +194,7 @@ function enqueueUpdate(component) {
|
|
|
203
194
|
// Various parts of our code (such as ReactCompositeComponent's
|
|
204
195
|
// _renderValidatedComponent) assume that calls to render aren't nested;
|
|
205
196
|
// verify that that's the case. (This is called by each top-level update
|
|
206
|
-
// function, like
|
|
197
|
+
// function, like setState, forceUpdate, etc.; creation and
|
|
207
198
|
// destruction of top-level components is guarded in ReactMount.)
|
|
208
199
|
|
|
209
200
|
if (!batchingStrategy.isBatchingUpdates) {
|
package/lib/ReactVersion.js
CHANGED
|
@@ -438,7 +438,7 @@ var ResponderEventPlugin = {
|
|
|
438
438
|
!(trackedTouchCount >= 0) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Ended a touch event which was not counted in trackedTouchCount.') : _prodInvariant('132') : void 0;
|
|
439
439
|
}
|
|
440
440
|
|
|
441
|
-
ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent
|
|
441
|
+
ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent);
|
|
442
442
|
|
|
443
443
|
var extracted = canTriggerTransfer(topLevelType, targetInst, nativeEvent) ? setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, nativeEventTarget) : null;
|
|
444
444
|
// Responder may or may not have transferred on a new touch start/move.
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
8
8
|
*
|
|
9
9
|
* @providesModule ResponderTouchHistoryStore
|
|
10
|
+
*
|
|
10
11
|
*/
|
|
11
12
|
|
|
12
13
|
'use strict';
|
|
@@ -16,30 +17,22 @@ var _prodInvariant = require('./reactProdInvariant');
|
|
|
16
17
|
var EventPluginUtils = require('./EventPluginUtils');
|
|
17
18
|
|
|
18
19
|
var invariant = require('fbjs/lib/invariant');
|
|
20
|
+
var warning = require('fbjs/lib/warning');
|
|
19
21
|
|
|
22
|
+
var isEndish = EventPluginUtils.isEndish;
|
|
20
23
|
var isMoveish = EventPluginUtils.isMoveish;
|
|
21
24
|
var isStartish = EventPluginUtils.isStartish;
|
|
22
|
-
var isEndish = EventPluginUtils.isEndish;
|
|
23
|
-
|
|
24
|
-
var MAX_TOUCH_BANK = 20;
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
* see IDs
|
|
29
|
-
*
|
|
30
|
-
* logic modules so precomputing it is very helpful to do once.
|
|
31
|
-
* Each touch object in `touchBank` is of the following form:
|
|
32
|
-
* { touchActive: boolean,
|
|
33
|
-
* startTimeStamp: number,
|
|
34
|
-
* startPageX: number,
|
|
35
|
-
* startPageY: number,
|
|
36
|
-
* currentPageX: number,
|
|
37
|
-
* currentPageY: number,
|
|
38
|
-
* currentTimeStamp: number
|
|
39
|
-
* }
|
|
27
|
+
* Tracks the position and time of each active touch by `touch.identifier`. We
|
|
28
|
+
* should typically only see IDs in the range of 1-20 because IDs get recycled
|
|
29
|
+
* when touches end and start again.
|
|
40
30
|
*/
|
|
31
|
+
|
|
32
|
+
var MAX_TOUCH_BANK = 20;
|
|
33
|
+
var touchBank = [];
|
|
41
34
|
var touchHistory = {
|
|
42
|
-
touchBank:
|
|
35
|
+
touchBank: touchBank,
|
|
43
36
|
numberActiveTouches: 0,
|
|
44
37
|
// If there is only one active touch, we remember its location. This prevents
|
|
45
38
|
// us having to loop through all of the touches all the time in the most
|
|
@@ -48,24 +41,23 @@ var touchHistory = {
|
|
|
48
41
|
mostRecentTimeStamp: 0
|
|
49
42
|
};
|
|
50
43
|
|
|
51
|
-
|
|
44
|
+
function timestampForTouch(touch) {
|
|
52
45
|
// The legacy internal implementation provides "timeStamp", which has been
|
|
53
46
|
// renamed to "timestamp". Let both work for now while we iron it out
|
|
54
47
|
// TODO (evv): rename timeStamp to timestamp in internal code
|
|
55
48
|
return touch.timeStamp || touch.timestamp;
|
|
56
|
-
}
|
|
49
|
+
}
|
|
57
50
|
|
|
58
51
|
/**
|
|
59
52
|
* TODO: Instead of making gestures recompute filtered velocity, we could
|
|
60
53
|
* include a built in velocity computation that can be reused globally.
|
|
61
|
-
* @param {Touch} touch Native touch object.
|
|
62
54
|
*/
|
|
63
|
-
|
|
55
|
+
function createTouchRecord(touch) {
|
|
64
56
|
return {
|
|
65
57
|
touchActive: true,
|
|
66
|
-
startTimeStamp: timestampForTouch(touch),
|
|
67
58
|
startPageX: touch.pageX,
|
|
68
59
|
startPageY: touch.pageY,
|
|
60
|
+
startTimeStamp: timestampForTouch(touch),
|
|
69
61
|
currentPageX: touch.pageX,
|
|
70
62
|
currentPageY: touch.pageY,
|
|
71
63
|
currentTimeStamp: timestampForTouch(touch),
|
|
@@ -73,91 +65,101 @@ var initializeTouchData = function (touch) {
|
|
|
73
65
|
previousPageY: touch.pageY,
|
|
74
66
|
previousTimeStamp: timestampForTouch(touch)
|
|
75
67
|
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
var identifier =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
var
|
|
101
|
-
var
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
validateTouch(touch);
|
|
105
|
-
}
|
|
106
|
-
if (touchTrack) {
|
|
107
|
-
reinitializeTouchTrack(touchTrack, touch);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function resetTouchRecord(touchRecord, touch) {
|
|
71
|
+
touchRecord.touchActive = true;
|
|
72
|
+
touchRecord.startPageX = touch.pageX;
|
|
73
|
+
touchRecord.startPageY = touch.pageY;
|
|
74
|
+
touchRecord.startTimeStamp = timestampForTouch(touch);
|
|
75
|
+
touchRecord.currentPageX = touch.pageX;
|
|
76
|
+
touchRecord.currentPageY = touch.pageY;
|
|
77
|
+
touchRecord.currentTimeStamp = timestampForTouch(touch);
|
|
78
|
+
touchRecord.previousPageX = touch.pageX;
|
|
79
|
+
touchRecord.previousPageY = touch.pageY;
|
|
80
|
+
touchRecord.previousTimeStamp = timestampForTouch(touch);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function getTouchIdentifier(_ref) {
|
|
84
|
+
var identifier = _ref.identifier;
|
|
85
|
+
|
|
86
|
+
!(identifier != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Touch object is missing identifier.') : _prodInvariant('138') : void 0;
|
|
87
|
+
process.env.NODE_ENV !== 'production' ? warning(identifier <= MAX_TOUCH_BANK, 'Touch identifier %s is greater than maximum supported %s which causes ' + 'performance issues backfilling array locations for all of the indices.', identifier, MAX_TOUCH_BANK) : void 0;
|
|
88
|
+
return identifier;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function recordTouchStart(touch) {
|
|
92
|
+
var identifier = getTouchIdentifier(touch);
|
|
93
|
+
var touchRecord = touchBank[identifier];
|
|
94
|
+
if (touchRecord) {
|
|
95
|
+
resetTouchRecord(touchRecord, touch);
|
|
108
96
|
} else {
|
|
109
|
-
touchBank[
|
|
97
|
+
touchBank[identifier] = createTouchRecord(touch);
|
|
110
98
|
}
|
|
111
99
|
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
var
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function recordTouchMove(touch) {
|
|
103
|
+
var touchRecord = touchBank[getTouchIdentifier(touch)];
|
|
104
|
+
if (touchRecord) {
|
|
105
|
+
touchRecord.touchActive = true;
|
|
106
|
+
touchRecord.previousPageX = touchRecord.currentPageX;
|
|
107
|
+
touchRecord.previousPageY = touchRecord.currentPageY;
|
|
108
|
+
touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
|
|
109
|
+
touchRecord.currentPageX = touch.pageX;
|
|
110
|
+
touchRecord.currentPageY = touch.pageY;
|
|
111
|
+
touchRecord.currentTimeStamp = timestampForTouch(touch);
|
|
112
|
+
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
113
|
+
} else {
|
|
114
|
+
console.error('Cannot record touch move without a touch start.\n' + 'Touch Move: %s\n', 'Touch Bank: %s', printTouch(touch), printTouchBank());
|
|
120
115
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
!touchTrack ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Touch data should have been recorded on start') : _prodInvariant('134') : void 0;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function recordTouchEnd(touch) {
|
|
119
|
+
var touchRecord = touchBank[getTouchIdentifier(touch)];
|
|
120
|
+
if (touchRecord) {
|
|
121
|
+
touchRecord.touchActive = false;
|
|
122
|
+
touchRecord.previousPageX = touchRecord.currentPageX;
|
|
123
|
+
touchRecord.previousPageY = touchRecord.currentPageY;
|
|
124
|
+
touchRecord.previousTimeStamp = touchRecord.currentTimeStamp;
|
|
125
|
+
touchRecord.currentPageX = touch.pageX;
|
|
126
|
+
touchRecord.currentPageY = touch.pageY;
|
|
127
|
+
touchRecord.currentTimeStamp = timestampForTouch(touch);
|
|
128
|
+
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
|
129
|
+
} else {
|
|
130
|
+
console.error('Cannot record touch end without a touch start.\n' + 'Touch End: %s\n', 'Touch Bank: %s', printTouch(touch), printTouchBank());
|
|
137
131
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
};
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function printTouch(touch) {
|
|
135
|
+
return JSON.stringify({
|
|
136
|
+
identifier: touch.identifier,
|
|
137
|
+
pageX: touch.pageX,
|
|
138
|
+
pageY: touch.pageY,
|
|
139
|
+
timestamp: timestampForTouch(touch)
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function printTouchBank() {
|
|
144
|
+
var printed = JSON.stringify(touchBank.slice(0, MAX_TOUCH_BANK));
|
|
145
|
+
if (touchBank.length > MAX_TOUCH_BANK) {
|
|
146
|
+
printed += ' (original size: ' + touchBank.length + ')';
|
|
147
|
+
}
|
|
148
|
+
return printed;
|
|
149
|
+
}
|
|
147
150
|
|
|
148
151
|
var ResponderTouchHistoryStore = {
|
|
149
152
|
recordTouchTrack: function (topLevelType, nativeEvent) {
|
|
150
|
-
var touchBank = touchHistory.touchBank;
|
|
151
153
|
if (isMoveish(topLevelType)) {
|
|
152
|
-
nativeEvent.changedTouches.forEach(
|
|
154
|
+
nativeEvent.changedTouches.forEach(recordTouchMove);
|
|
153
155
|
} else if (isStartish(topLevelType)) {
|
|
154
|
-
nativeEvent.changedTouches.forEach(
|
|
156
|
+
nativeEvent.changedTouches.forEach(recordTouchStart);
|
|
155
157
|
touchHistory.numberActiveTouches = nativeEvent.touches.length;
|
|
156
158
|
if (touchHistory.numberActiveTouches === 1) {
|
|
157
159
|
touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier;
|
|
158
160
|
}
|
|
159
161
|
} else if (isEndish(topLevelType)) {
|
|
160
|
-
nativeEvent.changedTouches.forEach(
|
|
162
|
+
nativeEvent.changedTouches.forEach(recordTouchEnd);
|
|
161
163
|
touchHistory.numberActiveTouches = nativeEvent.touches.length;
|
|
162
164
|
if (touchHistory.numberActiveTouches === 1) {
|
|
163
165
|
for (var i = 0; i < touchBank.length; i++) {
|
|
@@ -168,14 +170,14 @@ var ResponderTouchHistoryStore = {
|
|
|
168
170
|
}
|
|
169
171
|
}
|
|
170
172
|
if (process.env.NODE_ENV !== 'production') {
|
|
171
|
-
var
|
|
172
|
-
|
|
173
|
-
!foundActive ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot find single active touch') : _prodInvariant('135') : void 0;
|
|
173
|
+
var activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch];
|
|
174
|
+
process.env.NODE_ENV !== 'production' ? warning(activeRecord != null && activeRecord.touchActive, 'Cannot find single active touch.') : void 0;
|
|
174
175
|
}
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
178
|
},
|
|
178
179
|
|
|
180
|
+
|
|
179
181
|
touchHistory: touchHistory
|
|
180
182
|
};
|
|
181
183
|
|