mirror of
https://github.com/status-im/react-native.git
synced 2025-02-03 13:14:42 +00:00
Refactor of Fiber integration with React Fiber + Stack
Summary: This PR aims to update the Inspector tool in React Native to use the new inspection APIs that have been added to the ReactNative renderer: https://github.com/facebook/react/pull/9691 This PR also cleans up the code in `Inspector.js` so there's no usage of React's internals. Closes https://github.com/facebook/react-native/pull/14160 Reviewed By: bvaughn Differential Revision: D5129280 Pulled By: trueadm fbshipit-source-id: b1b077c04f46b0f52cdea0e19b4154441558f77a
This commit is contained in:
parent
da50811609
commit
59e41b4485
@ -12,8 +12,8 @@
|
||||
'use strict';
|
||||
|
||||
const BoxInspector = require('BoxInspector');
|
||||
const React = require('React');
|
||||
const PropTypes = require('prop-types');
|
||||
const React = require('React');
|
||||
const StyleInspector = require('StyleInspector');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const Text = require('Text');
|
||||
@ -76,14 +76,14 @@ class ElementProperties extends React.Component {
|
||||
<View style={styles.breadcrumb}>
|
||||
{mapWithSeparator(
|
||||
this.props.hierarchy,
|
||||
(item, i) => (
|
||||
(hierarchyItem, i) => (
|
||||
<TouchableHighlight
|
||||
key={'item-' + i}
|
||||
style={[styles.breadItem, i === selection && styles.selected]}
|
||||
// $FlowFixMe found when converting React.createClass to ES6
|
||||
onPress={() => this.props.setSelection(i)}>
|
||||
<Text style={styles.breadItemText}>
|
||||
{getInstanceName(item)}
|
||||
{hierarchyItem.name}
|
||||
</Text>
|
||||
</TouchableHighlight>
|
||||
),
|
||||
@ -109,16 +109,6 @@ class ElementProperties extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
function getInstanceName(instance) {
|
||||
if (instance.getName) {
|
||||
return instance.getName();
|
||||
}
|
||||
if (instance.constructor && instance.constructor.displayName) {
|
||||
return instance.constructor.displayName;
|
||||
}
|
||||
return 'Unknown';
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
breadSep: {
|
||||
fontSize: 8,
|
||||
|
@ -17,17 +17,31 @@
|
||||
const Dimensions = require('Dimensions');
|
||||
const InspectorOverlay = require('InspectorOverlay');
|
||||
const InspectorPanel = require('InspectorPanel');
|
||||
const InspectorUtils = require('InspectorUtils');
|
||||
const Platform = require('Platform');
|
||||
const React = require('React');
|
||||
const ReactNative = require('ReactNative');
|
||||
const StyleSheet = require('StyleSheet');
|
||||
const Touchable = require('Touchable');
|
||||
const UIManager = require('UIManager');
|
||||
const View = require('View');
|
||||
|
||||
if (window.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
||||
// required for devtools to be able to edit react native styles
|
||||
window.__REACT_DEVTOOLS_GLOBAL_HOOK__.resolveRNStyle = require('flattenStyle');
|
||||
const emptyObject = require('fbjs/lib/emptyObject');
|
||||
const invariant = require('invariant');
|
||||
|
||||
export type ReactRenderer = {
|
||||
getInspectorDataForViewTag: (viewTag: number) => Object,
|
||||
};
|
||||
|
||||
const hook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
||||
const renderer: ReactRenderer = findRenderer();
|
||||
// required for devtools to be able to edit react native styles
|
||||
hook.resolveRNStyle = require('flattenStyle');
|
||||
|
||||
function findRenderer(): ReactRenderer {
|
||||
const renderers = hook._renderers;
|
||||
const keys = Object.keys(renderers);
|
||||
invariant(keys.length === 1, 'Expected to find exactly one React Native renderer on DevTools hook.');
|
||||
return renderers[keys[0]];
|
||||
}
|
||||
|
||||
class Inspector extends React.Component {
|
||||
@ -67,13 +81,10 @@ class Inspector extends React.Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if (window.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
||||
(this : any).attachToDevtools = this.attachToDevtools.bind(this);
|
||||
window.__REACT_DEVTOOLS_GLOBAL_HOOK__.on('react-devtools', this.attachToDevtools);
|
||||
// if devtools is already started
|
||||
if (window.__REACT_DEVTOOLS_GLOBAL_HOOK__.reactDevtoolsAgent) {
|
||||
this.attachToDevtools(window.__REACT_DEVTOOLS_GLOBAL_HOOK__.reactDevtoolsAgent);
|
||||
}
|
||||
hook.on('react-devtools', this.attachToDevtools);
|
||||
// if devtools is already started
|
||||
if (hook.reactDevtoolsAgent) {
|
||||
this.attachToDevtools(hook.reactDevtoolsAgent);
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,9 +92,7 @@ class Inspector extends React.Component {
|
||||
if (this._subs) {
|
||||
this._subs.map(fn => fn());
|
||||
}
|
||||
if (window.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
|
||||
window.__REACT_DEVTOOLS_GLOBAL_HOOK__.off('react-devtools', this.attachToDevtools);
|
||||
}
|
||||
hook.off('react-devtools', this.attachToDevtools);
|
||||
}
|
||||
|
||||
componentWillReceiveProps(newProps: Object) {
|
||||
@ -94,12 +103,18 @@ class Inspector extends React.Component {
|
||||
let _hideWait = null;
|
||||
const hlSub = agent.sub('highlight', ({node, name, props}) => {
|
||||
clearTimeout(_hideWait);
|
||||
|
||||
if (typeof node !== 'number') {
|
||||
// Fiber
|
||||
node = ReactNative.findNodeHandle(node);
|
||||
}
|
||||
|
||||
UIManager.measure(node, (x, y, width, height, left, top) => {
|
||||
this.setState({
|
||||
hierarchy: [],
|
||||
inspected: {
|
||||
frame: {left, top, width, height},
|
||||
style: props ? props.style : {},
|
||||
style: props ? props.style : emptyObject,
|
||||
},
|
||||
});
|
||||
});
|
||||
@ -126,17 +141,21 @@ class Inspector extends React.Component {
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
setSelection(i: number) {
|
||||
const instance = this.state.hierarchy[i];
|
||||
// if we inspect a stateless component we can't use the getPublicInstance method
|
||||
// therefore we use the internal _instance property directly.
|
||||
const publicInstance = instance['_instance'] || {};
|
||||
const source = instance['_currentElement'] && instance['_currentElement']['_source'];
|
||||
UIManager.measure(instance.getHostNode(), (x, y, width, height, left, top) => {
|
||||
const hierarchyItem = this.state.hierarchy[i];
|
||||
// we pass in ReactNative.findNodeHandle as the method is injected
|
||||
const {
|
||||
measure,
|
||||
props,
|
||||
source,
|
||||
} = hierarchyItem.getInspectorData(ReactNative.findNodeHandle);
|
||||
|
||||
measure((x, y, width, height, left, top) => {
|
||||
this.setState({
|
||||
inspected: {
|
||||
frame: {left, top, width, height},
|
||||
style: publicInstance.props ? publicInstance.props.style : {},
|
||||
style: props.style,
|
||||
source,
|
||||
},
|
||||
selection: i,
|
||||
@ -144,28 +163,28 @@ class Inspector extends React.Component {
|
||||
});
|
||||
}
|
||||
|
||||
onTouchInstance(touched: Object, frame: Object, pointerY: number) {
|
||||
onTouchViewTag(touchedViewTag: number, frame: Object, pointerY: number) {
|
||||
// Most likely the touched instance is a native wrapper (like RCTView)
|
||||
// which is not very interesting. Most likely user wants a composite
|
||||
// instance that contains it (like View)
|
||||
const hierarchy = InspectorUtils.getOwnerHierarchy(touched);
|
||||
const instance = InspectorUtils.lastNotNativeInstance(hierarchy);
|
||||
const {
|
||||
hierarchy,
|
||||
instance,
|
||||
props,
|
||||
selection,
|
||||
source,
|
||||
} = renderer.getInspectorDataForViewTag(touchedViewTag);
|
||||
|
||||
if (this.state.devtoolsAgent) {
|
||||
this.state.devtoolsAgent.selectFromReactInstance(instance, true);
|
||||
}
|
||||
|
||||
// if we inspect a stateless component we can't use the getPublicInstance method
|
||||
// therefore we use the internal _instance property directly.
|
||||
const publicInstance = instance['_instance'] || {};
|
||||
const props = publicInstance.props || {};
|
||||
const source = instance['_currentElement'] && instance['_currentElement']['_source'];
|
||||
this.setState({
|
||||
panelPos: pointerY > Dimensions.get('window').height / 2 ? 'top' : 'bottom',
|
||||
selection: hierarchy.indexOf(instance),
|
||||
selection,
|
||||
hierarchy,
|
||||
inspected: {
|
||||
style: props.style || {},
|
||||
style: props.style,
|
||||
frame,
|
||||
source,
|
||||
},
|
||||
@ -214,7 +233,7 @@ class Inspector extends React.Component {
|
||||
<InspectorOverlay
|
||||
inspected={this.state.inspected}
|
||||
inspectedViewTag={this.state.inspectedViewTag}
|
||||
onTouchInstance={this.onTouchInstance.bind(this)}
|
||||
onTouchViewTag={this.onTouchViewTag.bind(this)}
|
||||
/>}
|
||||
<View style={[styles.panelContainer, panelContainerStyle]}>
|
||||
<InspectorPanel
|
||||
|
@ -12,13 +12,12 @@
|
||||
'use strict';
|
||||
|
||||
var Dimensions = require('Dimensions');
|
||||
var InspectorUtils = require('InspectorUtils');
|
||||
var React = require('React');
|
||||
var ElementBox = require('ElementBox');
|
||||
var PropTypes = require('prop-types');
|
||||
var React = require('React');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var UIManager = require('UIManager');
|
||||
var View = require('View');
|
||||
var ElementBox = require('ElementBox');
|
||||
|
||||
type EventLike = {
|
||||
nativeEvent: Object,
|
||||
@ -31,7 +30,7 @@ class InspectorOverlay extends React.Component {
|
||||
style?: any,
|
||||
},
|
||||
inspectedViewTag?: number,
|
||||
onTouchInstance: Function,
|
||||
onTouchViewTag: (tag: number, frame: Object, pointerY: number) => void,
|
||||
};
|
||||
|
||||
static propTypes = {
|
||||
@ -40,7 +39,7 @@ class InspectorOverlay extends React.Component {
|
||||
style: PropTypes.any,
|
||||
}),
|
||||
inspectedViewTag: PropTypes.number,
|
||||
onTouchInstance: PropTypes.func.isRequired,
|
||||
onTouchViewTag: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
findViewForTouchEvent = (e: EventLike) => {
|
||||
@ -49,11 +48,7 @@ class InspectorOverlay extends React.Component {
|
||||
this.props.inspectedViewTag,
|
||||
[locationX, locationY],
|
||||
(nativeViewTag, left, top, width, height) => {
|
||||
var instance = InspectorUtils.findInstanceByNativeTag(nativeViewTag);
|
||||
if (!instance) {
|
||||
return;
|
||||
}
|
||||
this.props.onTouchInstance(instance, {left, top, width, height}, locationY);
|
||||
this.props.onTouchViewTag(nativeViewTag, {left, top, width, height}, locationY);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
@ -1,47 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule InspectorUtils
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ReactNativeComponentTree = require('ReactNativeComponentTree');
|
||||
|
||||
function traverseOwnerTreeUp(hierarchy, instance) {
|
||||
if (instance) {
|
||||
hierarchy.unshift(instance);
|
||||
traverseOwnerTreeUp(hierarchy, instance._currentElement._owner);
|
||||
}
|
||||
}
|
||||
|
||||
function findInstanceByNativeTag(nativeTag) {
|
||||
var instance = ReactNativeComponentTree.getInstanceFromNode(nativeTag);
|
||||
if (!instance || typeof instance.tag === 'number') {
|
||||
// TODO(sema): We've disabled the inspector when using Fiber. Fix #15953531
|
||||
return null;
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
function getOwnerHierarchy(instance) {
|
||||
var hierarchy = [];
|
||||
traverseOwnerTreeUp(hierarchy, instance);
|
||||
return hierarchy;
|
||||
}
|
||||
|
||||
function lastNotNativeInstance(hierarchy) {
|
||||
for (let i = hierarchy.length - 1; i > 1; i--) {
|
||||
const instance = hierarchy[i];
|
||||
if (!instance.viewConfig) {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
return hierarchy[0];
|
||||
}
|
||||
|
||||
module.exports = {findInstanceByNativeTag, getOwnerHierarchy, lastNotNativeInstance};
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -84,9 +84,9 @@ var ReactNativeComponentTree = {
|
||||
function recomputePluginOrdering() {
|
||||
if (eventPluginOrder) for (var pluginName in namesToPlugins) {
|
||||
var pluginModule = namesToPlugins[pluginName], pluginIndex = eventPluginOrder.indexOf(pluginName);
|
||||
if (invariant(pluginIndex > -1, "EventPluginRegistry: Cannot inject event plugins that do not exist in " + "the plugin ordering, `%s`.", pluginName),
|
||||
if (invariant(pluginIndex > -1, "EventPluginRegistry: Cannot inject event plugins that do not exist in " + "the plugin ordering, `%s`.", pluginName),
|
||||
!EventPluginRegistry.plugins[pluginIndex]) {
|
||||
invariant(pluginModule.extractEvents, "EventPluginRegistry: Event plugins must implement an `extractEvents` " + "method, but `%s` does not.", pluginName),
|
||||
invariant(pluginModule.extractEvents, "EventPluginRegistry: Event plugins must implement an `extractEvents` " + "method, but `%s` does not.", pluginName),
|
||||
EventPluginRegistry.plugins[pluginIndex] = pluginModule;
|
||||
var publishedEvents = pluginModule.eventTypes;
|
||||
for (var eventName in publishedEvents) invariant(publishEventForPlugin(publishedEvents[eventName], pluginModule, eventName), "EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.", eventName, pluginName);
|
||||
@ -95,7 +95,7 @@ function recomputePluginOrdering() {
|
||||
}
|
||||
|
||||
function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
|
||||
invariant(!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName), "EventPluginHub: More than one plugin attempted to publish the same " + "event name, `%s`.", eventName),
|
||||
invariant(!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName), "EventPluginHub: More than one plugin attempted to publish the same " + "event name, `%s`.", eventName),
|
||||
EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
|
||||
var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
|
||||
if (phasedRegistrationNames) {
|
||||
@ -105,12 +105,12 @@ function publishEventForPlugin(dispatchConfig, pluginModule, eventName) {
|
||||
}
|
||||
return !0;
|
||||
}
|
||||
return !!dispatchConfig.registrationName && (publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName),
|
||||
return !!dispatchConfig.registrationName && (publishRegistrationName(dispatchConfig.registrationName, pluginModule, eventName),
|
||||
!0);
|
||||
}
|
||||
|
||||
function publishRegistrationName(registrationName, pluginModule, eventName) {
|
||||
invariant(!EventPluginRegistry.registrationNameModules[registrationName], "EventPluginHub: More than one plugin attempted to publish the same " + "registration name, `%s`.", registrationName),
|
||||
invariant(!EventPluginRegistry.registrationNameModules[registrationName], "EventPluginHub: More than one plugin attempted to publish the same " + "registration name, `%s`.", registrationName),
|
||||
EventPluginRegistry.registrationNameModules[registrationName] = pluginModule, EventPluginRegistry.registrationNameDependencies[registrationName] = pluginModule.eventTypes[eventName].dependencies;
|
||||
}
|
||||
|
||||
@ -121,14 +121,14 @@ var EventPluginRegistry = {
|
||||
registrationNameDependencies: {},
|
||||
possibleRegistrationNames: null,
|
||||
injectEventPluginOrder: function(injectedEventPluginOrder) {
|
||||
invariant(!eventPluginOrder, "EventPluginRegistry: Cannot inject event plugin ordering more than " + "once. You are likely trying to load more than one copy of React."),
|
||||
invariant(!eventPluginOrder, "EventPluginRegistry: Cannot inject event plugin ordering more than " + "once. You are likely trying to load more than one copy of React."),
|
||||
eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder), recomputePluginOrdering();
|
||||
},
|
||||
injectEventPluginsByName: function(injectedNamesToPlugins) {
|
||||
var isOrderingDirty = !1;
|
||||
for (var pluginName in injectedNamesToPlugins) if (injectedNamesToPlugins.hasOwnProperty(pluginName)) {
|
||||
var pluginModule = injectedNamesToPlugins[pluginName];
|
||||
namesToPlugins.hasOwnProperty(pluginName) && namesToPlugins[pluginName] === pluginModule || (invariant(!namesToPlugins[pluginName], "EventPluginRegistry: Cannot inject two different event plugins " + "using the same name, `%s`.", pluginName),
|
||||
namesToPlugins.hasOwnProperty(pluginName) && namesToPlugins[pluginName] === pluginModule || (invariant(!namesToPlugins[pluginName], "EventPluginRegistry: Cannot inject two different event plugins " + "using the same name, `%s`.", pluginName),
|
||||
namesToPlugins[pluginName] = pluginModule, isOrderingDirty = !0);
|
||||
}
|
||||
isOrderingDirty && recomputePluginOrdering();
|
||||
@ -149,7 +149,7 @@ var EventPluginRegistry = {
|
||||
}, ReactErrorUtils = {
|
||||
injection: {
|
||||
injectErrorUtils: function(injectedErrorUtils) {
|
||||
invariant("function" == typeof injectedErrorUtils.invokeGuardedCallback, "Injected invokeGuardedCallback() must be a function."),
|
||||
invariant("function" == typeof injectedErrorUtils.invokeGuardedCallback, "Injected invokeGuardedCallback() must be a function."),
|
||||
invokeGuardedCallback = injectedErrorUtils.invokeGuardedCallback;
|
||||
}
|
||||
},
|
||||
@ -183,7 +183,7 @@ function isStartish(topLevelType) {
|
||||
|
||||
function executeDispatch(event, simulated, listener, inst) {
|
||||
var type = event.type || "unknown-event";
|
||||
event.currentTarget = EventPluginUtils.getNodeFromInstance(inst), ReactErrorUtils_1.invokeGuardedCallbackAndCatchFirstError(type, listener, void 0, event),
|
||||
event.currentTarget = EventPluginUtils.getNodeFromInstance(inst), ReactErrorUtils_1.invokeGuardedCallbackAndCatchFirstError(type, listener, void 0, event),
|
||||
event.currentTarget = null;
|
||||
}
|
||||
|
||||
@ -208,10 +208,10 @@ function executeDispatchesInOrderStopAtTrue(event) {
|
||||
|
||||
function executeDirectDispatch(event) {
|
||||
var dispatchListener = event._dispatchListeners, dispatchInstance = event._dispatchInstances;
|
||||
invariant(!Array.isArray(dispatchListener), "executeDirectDispatch(...): Invalid `event`."),
|
||||
invariant(!Array.isArray(dispatchListener), "executeDirectDispatch(...): Invalid `event`."),
|
||||
event.currentTarget = dispatchListener ? EventPluginUtils.getNodeFromInstance(dispatchInstance) : null;
|
||||
var res = dispatchListener ? dispatchListener(event) : null;
|
||||
return event.currentTarget = null, event._dispatchListeners = null, event._dispatchInstances = null,
|
||||
return event.currentTarget = null, event._dispatchListeners = null, event._dispatchInstances = null,
|
||||
res;
|
||||
}
|
||||
|
||||
@ -240,8 +240,8 @@ var EventPluginUtils = {
|
||||
}, EventPluginUtils_1 = EventPluginUtils;
|
||||
|
||||
function accumulateInto(current, next) {
|
||||
return invariant(null != next, "accumulateInto(...): Accumulated items must not be null or undefined."),
|
||||
null == current ? next : Array.isArray(current) ? Array.isArray(next) ? (current.push.apply(current, next),
|
||||
return invariant(null != next, "accumulateInto(...): Accumulated items must not be null or undefined."),
|
||||
null == current ? next : Array.isArray(current) ? Array.isArray(next) ? (current.push.apply(current, next),
|
||||
current) : (current.push(next), current) : Array.isArray(next) ? [ current ].concat(next) : [ current, next ];
|
||||
}
|
||||
|
||||
@ -302,7 +302,7 @@ var EventPluginHub = {
|
||||
var _props = currentElement.props;
|
||||
if (listener = _props[registrationName], shouldPreventMouseEvent(registrationName, currentElement.type, _props)) return null;
|
||||
}
|
||||
return invariant(!listener || "function" == typeof listener, "Expected %s listener to be a function, instead got type %s", registrationName, typeof listener),
|
||||
return invariant(!listener || "function" == typeof listener, "Expected %s listener to be a function, instead got type %s", registrationName, typeof listener),
|
||||
listener;
|
||||
},
|
||||
extractEvents: function(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
|
||||
@ -320,8 +320,8 @@ var EventPluginHub = {
|
||||
},
|
||||
processEventQueue: function(simulated) {
|
||||
var processingEventQueue = eventQueue;
|
||||
eventQueue = null, simulated ? forEachAccumulated_1(processingEventQueue, executeDispatchesAndReleaseSimulated) : forEachAccumulated_1(processingEventQueue, executeDispatchesAndReleaseTopLevel),
|
||||
invariant(!eventQueue, "processEventQueue(): Additional events were enqueued while processing " + "an event queue. Support for this has not yet been implemented."),
|
||||
eventQueue = null, simulated ? forEachAccumulated_1(processingEventQueue, executeDispatchesAndReleaseSimulated) : forEachAccumulated_1(processingEventQueue, executeDispatchesAndReleaseTopLevel),
|
||||
invariant(!eventQueue, "processEventQueue(): Additional events were enqueued while processing " + "an event queue. Support for this has not yet been implemented."),
|
||||
ReactErrorUtils_1.rethrowCaughtError();
|
||||
}
|
||||
}, EventPluginHub_1 = EventPluginHub, ReactTypeOfWork = {
|
||||
@ -381,7 +381,7 @@ function traverseTwoPhase(inst, fn, arg) {
|
||||
}
|
||||
|
||||
function traverseEnterLeave(from, to, fn, argFrom, argTo) {
|
||||
for (var common = from && to ? getLowestCommonAncestor(from, to) : null, pathFrom = []; from && from !== common; ) pathFrom.push(from),
|
||||
for (var common = from && to ? getLowestCommonAncestor(from, to) : null, pathFrom = []; from && from !== common; ) pathFrom.push(from),
|
||||
from = getParent(from);
|
||||
for (var pathTo = []; to && to !== common; ) pathTo.push(to), to = getParent(to);
|
||||
var i;
|
||||
@ -404,7 +404,7 @@ function listenerAtPhase(inst, event, propagationPhase) {
|
||||
|
||||
function accumulateDirectionalDispatches(inst, phase, event) {
|
||||
var listener = listenerAtPhase(inst, event, phase);
|
||||
listener && (event._dispatchListeners = accumulateInto_1(event._dispatchListeners, listener),
|
||||
listener && (event._dispatchListeners = accumulateInto_1(event._dispatchListeners, listener),
|
||||
event._dispatchInstances = accumulateInto_1(event._dispatchInstances, inst));
|
||||
}
|
||||
|
||||
@ -422,7 +422,7 @@ function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
|
||||
function accumulateDispatches(inst, ignoredDirection, event) {
|
||||
if (inst && event && event.dispatchConfig.registrationName) {
|
||||
var registrationName = event.dispatchConfig.registrationName, listener = getListener(inst, registrationName);
|
||||
listener && (event._dispatchListeners = accumulateInto_1(event._dispatchListeners, listener),
|
||||
listener && (event._dispatchListeners = accumulateInto_1(event._dispatchListeners, listener),
|
||||
event._dispatchInstances = accumulateInto_1(event._dispatchInstances, inst));
|
||||
}
|
||||
}
|
||||
@ -482,12 +482,12 @@ var EventPropagators = {
|
||||
return new Klass(a1, a2, a3, a4);
|
||||
}, standardReleaser = function(instance) {
|
||||
var Klass = this;
|
||||
invariant(instance instanceof Klass, "Trying to release an instance into a pool of a different type."),
|
||||
invariant(instance instanceof Klass, "Trying to release an instance into a pool of a different type."),
|
||||
instance.destructor(), Klass.instancePool.length < Klass.poolSize && Klass.instancePool.push(instance);
|
||||
}, DEFAULT_POOL_SIZE = 10, DEFAULT_POOLER = oneArgumentPooler, addPoolingTo = function(CopyConstructor, pooler) {
|
||||
var NewKlass = CopyConstructor;
|
||||
return NewKlass.instancePool = [], NewKlass.getPooled = pooler || DEFAULT_POOLER,
|
||||
NewKlass.poolSize || (NewKlass.poolSize = DEFAULT_POOL_SIZE), NewKlass.release = standardReleaser,
|
||||
return NewKlass.instancePool = [], NewKlass.getPooled = pooler || DEFAULT_POOLER,
|
||||
NewKlass.poolSize || (NewKlass.poolSize = DEFAULT_POOL_SIZE), NewKlass.release = standardReleaser,
|
||||
NewKlass;
|
||||
}, PooledClass = {
|
||||
addPoolingTo: addPoolingTo,
|
||||
@ -517,7 +517,7 @@ function SyntheticEvent(dispatchConfig, targetInst, nativeEvent, nativeEventTarg
|
||||
normalize ? this[propName] = normalize(nativeEvent) : "target" === propName ? this.target = nativeEventTarget : this[propName] = nativeEvent[propName];
|
||||
}
|
||||
var defaultPrevented = null != nativeEvent.defaultPrevented ? nativeEvent.defaultPrevented : !1 === nativeEvent.returnValue;
|
||||
return this.isDefaultPrevented = defaultPrevented ? emptyFunction.thatReturnsTrue : emptyFunction.thatReturnsFalse,
|
||||
return this.isDefaultPrevented = defaultPrevented ? emptyFunction.thatReturnsTrue : emptyFunction.thatReturnsFalse,
|
||||
this.isPropagationStopped = emptyFunction.thatReturnsFalse, this;
|
||||
}
|
||||
|
||||
@ -525,12 +525,12 @@ Object.assign(SyntheticEvent.prototype, {
|
||||
preventDefault: function() {
|
||||
this.defaultPrevented = !0;
|
||||
var event = this.nativeEvent;
|
||||
event && (event.preventDefault ? event.preventDefault() : "unknown" != typeof event.returnValue && (event.returnValue = !1),
|
||||
event && (event.preventDefault ? event.preventDefault() : "unknown" != typeof event.returnValue && (event.returnValue = !1),
|
||||
this.isDefaultPrevented = emptyFunction.thatReturnsTrue);
|
||||
},
|
||||
stopPropagation: function() {
|
||||
var event = this.nativeEvent;
|
||||
event && (event.stopPropagation ? event.stopPropagation() : "unknown" != typeof event.cancelBubble && (event.cancelBubble = !0),
|
||||
event && (event.stopPropagation ? event.stopPropagation() : "unknown" != typeof event.cancelBubble && (event.cancelBubble = !0),
|
||||
this.isPropagationStopped = emptyFunction.thatReturnsTrue);
|
||||
},
|
||||
persist: function() {
|
||||
@ -546,8 +546,8 @@ Object.assign(SyntheticEvent.prototype, {
|
||||
var Super = this, E = function() {};
|
||||
E.prototype = Super.prototype;
|
||||
var prototype = new E();
|
||||
Object.assign(prototype, Class.prototype), Class.prototype = prototype, Class.prototype.constructor = Class,
|
||||
Class.Interface = Object.assign({}, Super.Interface, Interface), Class.augmentClass = Super.augmentClass,
|
||||
Object.assign(prototype, Class.prototype), Class.prototype = prototype, Class.prototype.constructor = Class,
|
||||
Class.Interface = Object.assign({}, Super.Interface, Interface), Class.augmentClass = Super.augmentClass,
|
||||
PooledClass_1.addPoolingTo(Class, PooledClass_1.fourArgumentPooler);
|
||||
}, PooledClass_1.addPoolingTo(SyntheticEvent, PooledClass_1.fourArgumentPooler);
|
||||
|
||||
@ -561,7 +561,7 @@ var SyntheticEvent_1 = SyntheticEvent, _extends = Object.assign || function(targ
|
||||
|
||||
for (var bubblingTypeName in customBubblingEventTypes) allTypesByEventName[bubblingTypeName] = customBubblingEventTypes[bubblingTypeName];
|
||||
|
||||
for (var directTypeName in customDirectEventTypes) warning(!customBubblingEventTypes[directTypeName], "Event cannot be both direct and bubbling: %s", directTypeName),
|
||||
for (var directTypeName in customDirectEventTypes) warning(!customBubblingEventTypes[directTypeName], "Event cannot be both direct and bubbling: %s", directTypeName),
|
||||
allTypesByEventName[directTypeName] = customDirectEventTypes[directTypeName];
|
||||
|
||||
var ReactNativeBridgeEventPlugin = {
|
||||
@ -612,7 +612,7 @@ function restoreStateOfTarget(target) {
|
||||
var props = EventPluginUtils_1.getFiberCurrentPropsFromNode(internalInstance.stateNode);
|
||||
return void fiberHostComponent.restoreControlledState(internalInstance.stateNode, internalInstance.type, props);
|
||||
}
|
||||
invariant("function" == typeof internalInstance.restoreControlledState, "The internal instance must be a React host component."),
|
||||
invariant("function" == typeof internalInstance.restoreControlledState, "The internal instance must be a React host component."),
|
||||
internalInstance.restoreControlledState();
|
||||
}
|
||||
}
|
||||
@ -701,7 +701,7 @@ var ReactGenericBatchingInjection = {
|
||||
var touch = changedTouches[jj];
|
||||
touch.changedTouches = changedTouches, touch.touches = touches;
|
||||
var nativeEvent = touch, rootNodeID = null, target = nativeEvent.target;
|
||||
null !== target && void 0 !== target && (target < ReactNativeTagHandles_1.tagsStartAt || (rootNodeID = target)),
|
||||
null !== target && void 0 !== target && (target < ReactNativeTagHandles_1.tagsStartAt || (rootNodeID = target)),
|
||||
ReactNativeEventEmitter._receiveRootNodeIDEvent(rootNodeID, eventTopLevelType, nativeEvent);
|
||||
}
|
||||
}
|
||||
@ -751,38 +751,38 @@ function createTouchRecord(touch) {
|
||||
}
|
||||
|
||||
function resetTouchRecord(touchRecord, touch) {
|
||||
touchRecord.touchActive = !0, touchRecord.startPageX = touch.pageX, touchRecord.startPageY = touch.pageY,
|
||||
touchRecord.startTimeStamp = timestampForTouch(touch), touchRecord.currentPageX = touch.pageX,
|
||||
touchRecord.currentPageY = touch.pageY, touchRecord.currentTimeStamp = timestampForTouch(touch),
|
||||
touchRecord.previousPageX = touch.pageX, touchRecord.previousPageY = touch.pageY,
|
||||
touchRecord.touchActive = !0, touchRecord.startPageX = touch.pageX, touchRecord.startPageY = touch.pageY,
|
||||
touchRecord.startTimeStamp = timestampForTouch(touch), touchRecord.currentPageX = touch.pageX,
|
||||
touchRecord.currentPageY = touch.pageY, touchRecord.currentTimeStamp = timestampForTouch(touch),
|
||||
touchRecord.previousPageX = touch.pageX, touchRecord.previousPageY = touch.pageY,
|
||||
touchRecord.previousTimeStamp = timestampForTouch(touch);
|
||||
}
|
||||
|
||||
function getTouchIdentifier(_ref) {
|
||||
var identifier = _ref.identifier;
|
||||
return invariant(null != identifier, "Touch object is missing identifier."), 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),
|
||||
return invariant(null != identifier, "Touch object is missing identifier."), 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),
|
||||
identifier;
|
||||
}
|
||||
|
||||
function recordTouchStart(touch) {
|
||||
var identifier = getTouchIdentifier(touch), touchRecord = touchBank[identifier];
|
||||
touchRecord ? resetTouchRecord(touchRecord, touch) : touchBank[identifier] = createTouchRecord(touch),
|
||||
touchRecord ? resetTouchRecord(touchRecord, touch) : touchBank[identifier] = createTouchRecord(touch),
|
||||
touchHistory.mostRecentTimeStamp = timestampForTouch(touch);
|
||||
}
|
||||
|
||||
function recordTouchMove(touch) {
|
||||
var touchRecord = touchBank[getTouchIdentifier(touch)];
|
||||
touchRecord ? (touchRecord.touchActive = !0, touchRecord.previousPageX = touchRecord.currentPageX,
|
||||
touchRecord.previousPageY = touchRecord.currentPageY, touchRecord.previousTimeStamp = touchRecord.currentTimeStamp,
|
||||
touchRecord.currentPageX = touch.pageX, touchRecord.currentPageY = touch.pageY,
|
||||
touchRecord ? (touchRecord.touchActive = !0, touchRecord.previousPageX = touchRecord.currentPageX,
|
||||
touchRecord.previousPageY = touchRecord.currentPageY, touchRecord.previousTimeStamp = touchRecord.currentTimeStamp,
|
||||
touchRecord.currentPageX = touch.pageX, touchRecord.currentPageY = touch.pageY,
|
||||
touchRecord.currentTimeStamp = timestampForTouch(touch), touchHistory.mostRecentTimeStamp = timestampForTouch(touch)) : console.error("Cannot record touch move without a touch start.\n" + "Touch Move: %s\n", "Touch Bank: %s", printTouch(touch), printTouchBank());
|
||||
}
|
||||
|
||||
function recordTouchEnd(touch) {
|
||||
var touchRecord = touchBank[getTouchIdentifier(touch)];
|
||||
touchRecord ? (touchRecord.touchActive = !1, touchRecord.previousPageX = touchRecord.currentPageX,
|
||||
touchRecord.previousPageY = touchRecord.currentPageY, touchRecord.previousTimeStamp = touchRecord.currentTimeStamp,
|
||||
touchRecord.currentPageX = touch.pageX, touchRecord.currentPageY = touch.pageY,
|
||||
touchRecord ? (touchRecord.touchActive = !1, touchRecord.previousPageX = touchRecord.currentPageX,
|
||||
touchRecord.previousPageY = touchRecord.currentPageY, touchRecord.previousTimeStamp = touchRecord.currentTimeStamp,
|
||||
touchRecord.currentPageX = touch.pageX, touchRecord.currentPageY = touch.pageY,
|
||||
touchRecord.currentTimeStamp = timestampForTouch(touch), touchHistory.mostRecentTimeStamp = timestampForTouch(touch)) : console.error("Cannot record touch end without a touch start.\n" + "Touch End: %s\n", "Touch Bank: %s", printTouch(touch), printTouchBank());
|
||||
}
|
||||
|
||||
@ -797,14 +797,14 @@ function printTouch(touch) {
|
||||
|
||||
function printTouchBank() {
|
||||
var printed = JSON.stringify(touchBank.slice(0, MAX_TOUCH_BANK));
|
||||
return touchBank.length > MAX_TOUCH_BANK && (printed += " (original size: " + touchBank.length + ")"),
|
||||
return touchBank.length > MAX_TOUCH_BANK && (printed += " (original size: " + touchBank.length + ")"),
|
||||
printed;
|
||||
}
|
||||
|
||||
var ResponderTouchHistoryStore = {
|
||||
recordTouchTrack: function(topLevelType, nativeEvent) {
|
||||
if (isMoveish$2(topLevelType)) nativeEvent.changedTouches.forEach(recordTouchMove); else if (isStartish$2(topLevelType)) nativeEvent.changedTouches.forEach(recordTouchStart),
|
||||
touchHistory.numberActiveTouches = nativeEvent.touches.length, 1 === touchHistory.numberActiveTouches && (touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier); else if (isEndish$2(topLevelType) && (nativeEvent.changedTouches.forEach(recordTouchEnd),
|
||||
if (isMoveish$2(topLevelType)) nativeEvent.changedTouches.forEach(recordTouchMove); else if (isStartish$2(topLevelType)) nativeEvent.changedTouches.forEach(recordTouchStart),
|
||||
touchHistory.numberActiveTouches = nativeEvent.touches.length, 1 === touchHistory.numberActiveTouches && (touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier); else if (isEndish$2(topLevelType) && (nativeEvent.changedTouches.forEach(recordTouchEnd),
|
||||
touchHistory.numberActiveTouches = nativeEvent.touches.length, 1 === touchHistory.numberActiveTouches)) for (var i = 0; i < touchBank.length; i++) {
|
||||
var touchTrackToCheck = touchBank[i];
|
||||
if (null != touchTrackToCheck && touchTrackToCheck.touchActive) {
|
||||
@ -817,7 +817,7 @@ var ResponderTouchHistoryStore = {
|
||||
}, ResponderTouchHistoryStore_1 = ResponderTouchHistoryStore;
|
||||
|
||||
function accumulate(current, next) {
|
||||
return invariant(null != next, "accumulate(...): Accumulated items must be not be null or undefined."),
|
||||
return invariant(null != next, "accumulate(...): Accumulated items must be not be null or undefined."),
|
||||
null == current ? next : Array.isArray(current) ? current.concat(next) : Array.isArray(next) ? [ current ].concat(next) : [ current, next ];
|
||||
}
|
||||
|
||||
@ -879,24 +879,24 @@ function setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, n
|
||||
var shouldSetEventType = isStartish$1(topLevelType) ? eventTypes.startShouldSetResponder : isMoveish$1(topLevelType) ? eventTypes.moveShouldSetResponder : "topSelectionChange" === topLevelType ? eventTypes.selectionChangeShouldSetResponder : eventTypes.scrollShouldSetResponder, bubbleShouldSetFrom = responderInst ? ReactTreeTraversal.getLowestCommonAncestor(responderInst, targetInst) : targetInst, skipOverBubbleShouldSetFrom = bubbleShouldSetFrom === responderInst, shouldSetEvent = ResponderSyntheticEvent_1.getPooled(shouldSetEventType, bubbleShouldSetFrom, nativeEvent, nativeEventTarget);
|
||||
shouldSetEvent.touchHistory = ResponderTouchHistoryStore_1.touchHistory, skipOverBubbleShouldSetFrom ? EventPropagators_1.accumulateTwoPhaseDispatchesSkipTarget(shouldSetEvent) : EventPropagators_1.accumulateTwoPhaseDispatches(shouldSetEvent);
|
||||
var wantsResponderInst = executeDispatchesInOrderStopAtTrue$1(shouldSetEvent);
|
||||
if (shouldSetEvent.isPersistent() || shouldSetEvent.constructor.release(shouldSetEvent),
|
||||
if (shouldSetEvent.isPersistent() || shouldSetEvent.constructor.release(shouldSetEvent),
|
||||
!wantsResponderInst || wantsResponderInst === responderInst) return null;
|
||||
var extracted, grantEvent = ResponderSyntheticEvent_1.getPooled(eventTypes.responderGrant, wantsResponderInst, nativeEvent, nativeEventTarget);
|
||||
grantEvent.touchHistory = ResponderTouchHistoryStore_1.touchHistory, EventPropagators_1.accumulateDirectDispatches(grantEvent);
|
||||
var blockHostResponder = !0 === executeDirectDispatch$1(grantEvent);
|
||||
if (responderInst) {
|
||||
var terminationRequestEvent = ResponderSyntheticEvent_1.getPooled(eventTypes.responderTerminationRequest, responderInst, nativeEvent, nativeEventTarget);
|
||||
terminationRequestEvent.touchHistory = ResponderTouchHistoryStore_1.touchHistory,
|
||||
terminationRequestEvent.touchHistory = ResponderTouchHistoryStore_1.touchHistory,
|
||||
EventPropagators_1.accumulateDirectDispatches(terminationRequestEvent);
|
||||
var shouldSwitch = !hasDispatches$1(terminationRequestEvent) || executeDirectDispatch$1(terminationRequestEvent);
|
||||
if (terminationRequestEvent.isPersistent() || terminationRequestEvent.constructor.release(terminationRequestEvent),
|
||||
if (terminationRequestEvent.isPersistent() || terminationRequestEvent.constructor.release(terminationRequestEvent),
|
||||
shouldSwitch) {
|
||||
var terminateEvent = ResponderSyntheticEvent_1.getPooled(eventTypes.responderTerminate, responderInst, nativeEvent, nativeEventTarget);
|
||||
terminateEvent.touchHistory = ResponderTouchHistoryStore_1.touchHistory, EventPropagators_1.accumulateDirectDispatches(terminateEvent),
|
||||
terminateEvent.touchHistory = ResponderTouchHistoryStore_1.touchHistory, EventPropagators_1.accumulateDirectDispatches(terminateEvent),
|
||||
extracted = accumulate_1(extracted, [ grantEvent, terminateEvent ]), changeResponder(wantsResponderInst, blockHostResponder);
|
||||
} else {
|
||||
var rejectEvent = ResponderSyntheticEvent_1.getPooled(eventTypes.responderReject, wantsResponderInst, nativeEvent, nativeEventTarget);
|
||||
rejectEvent.touchHistory = ResponderTouchHistoryStore_1.touchHistory, EventPropagators_1.accumulateDirectDispatches(rejectEvent),
|
||||
rejectEvent.touchHistory = ResponderTouchHistoryStore_1.touchHistory, EventPropagators_1.accumulateDirectDispatches(rejectEvent),
|
||||
extracted = accumulate_1(extracted, rejectEvent);
|
||||
}
|
||||
} else extracted = accumulate_1(extracted, grantEvent), changeResponder(wantsResponderInst, blockHostResponder);
|
||||
@ -927,7 +927,7 @@ var ResponderEventPlugin = {
|
||||
eventTypes: eventTypes,
|
||||
extractEvents: function(topLevelType, targetInst, nativeEvent, nativeEventTarget) {
|
||||
if (isStartish$1(topLevelType)) trackedTouchCount += 1; else if (isEndish$1(topLevelType)) {
|
||||
if (!(trackedTouchCount >= 0)) return console.error("Ended a touch event which was not counted in `trackedTouchCount`."),
|
||||
if (!(trackedTouchCount >= 0)) return console.error("Ended a touch event which was not counted in `trackedTouchCount`."),
|
||||
null;
|
||||
trackedTouchCount -= 1;
|
||||
}
|
||||
@ -935,17 +935,17 @@ var ResponderEventPlugin = {
|
||||
var extracted = canTriggerTransfer(topLevelType, targetInst, nativeEvent) ? setResponderAndExtractTransfer(topLevelType, targetInst, nativeEvent, nativeEventTarget) : null, isResponderTouchStart = responderInst && isStartish$1(topLevelType), isResponderTouchMove = responderInst && isMoveish$1(topLevelType), isResponderTouchEnd = responderInst && isEndish$1(topLevelType), incrementalTouch = isResponderTouchStart ? eventTypes.responderStart : isResponderTouchMove ? eventTypes.responderMove : isResponderTouchEnd ? eventTypes.responderEnd : null;
|
||||
if (incrementalTouch) {
|
||||
var gesture = ResponderSyntheticEvent_1.getPooled(incrementalTouch, responderInst, nativeEvent, nativeEventTarget);
|
||||
gesture.touchHistory = ResponderTouchHistoryStore_1.touchHistory, EventPropagators_1.accumulateDirectDispatches(gesture),
|
||||
gesture.touchHistory = ResponderTouchHistoryStore_1.touchHistory, EventPropagators_1.accumulateDirectDispatches(gesture),
|
||||
extracted = accumulate_1(extracted, gesture);
|
||||
}
|
||||
var isResponderTerminate = responderInst && "topTouchCancel" === topLevelType, isResponderRelease = responderInst && !isResponderTerminate && isEndish$1(topLevelType) && noResponderTouches(nativeEvent), finalTouch = isResponderTerminate ? eventTypes.responderTerminate : isResponderRelease ? eventTypes.responderRelease : null;
|
||||
if (finalTouch) {
|
||||
var finalEvent = ResponderSyntheticEvent_1.getPooled(finalTouch, responderInst, nativeEvent, nativeEventTarget);
|
||||
finalEvent.touchHistory = ResponderTouchHistoryStore_1.touchHistory, EventPropagators_1.accumulateDirectDispatches(finalEvent),
|
||||
finalEvent.touchHistory = ResponderTouchHistoryStore_1.touchHistory, EventPropagators_1.accumulateDirectDispatches(finalEvent),
|
||||
extracted = accumulate_1(extracted, finalEvent), changeResponder(null);
|
||||
}
|
||||
var numberActiveTouches = ResponderTouchHistoryStore_1.touchHistory.numberActiveTouches;
|
||||
return ResponderEventPlugin.GlobalInteractionHandler && numberActiveTouches !== previousActiveTouches && ResponderEventPlugin.GlobalInteractionHandler.onChange(numberActiveTouches),
|
||||
return ResponderEventPlugin.GlobalInteractionHandler && numberActiveTouches !== previousActiveTouches && ResponderEventPlugin.GlobalInteractionHandler.onChange(numberActiveTouches),
|
||||
previousActiveTouches = numberActiveTouches, extracted;
|
||||
},
|
||||
GlobalResponderHandler: null,
|
||||
@ -961,8 +961,8 @@ var ResponderEventPlugin = {
|
||||
}, ResponderEventPlugin_1 = ResponderEventPlugin;
|
||||
|
||||
function inject() {
|
||||
RCTEventEmitter.register(ReactNativeEventEmitter_1), EventPluginHub_1.injection.injectEventPluginOrder(ReactNativeEventPluginOrder_1),
|
||||
EventPluginUtils_1.injection.injectComponentTree(ReactNativeComponentTree_1), ResponderEventPlugin_1.injection.injectGlobalResponderHandler(ReactNativeGlobalResponderHandler_1),
|
||||
RCTEventEmitter.register(ReactNativeEventEmitter_1), EventPluginHub_1.injection.injectEventPluginOrder(ReactNativeEventPluginOrder_1),
|
||||
EventPluginUtils_1.injection.injectComponentTree(ReactNativeComponentTree_1), ResponderEventPlugin_1.injection.injectGlobalResponderHandler(ReactNativeGlobalResponderHandler_1),
|
||||
EventPluginHub_1.injection.injectEventPluginsByName({
|
||||
ResponderEventPlugin: ResponderEventPlugin_1,
|
||||
ReactNativeBridgeEventPlugin: ReactNativeBridgeEventPlugin_1
|
||||
@ -990,7 +990,7 @@ var ReactOwner = {
|
||||
if (owner && owner.tag === ClassComponent) {
|
||||
var inst = owner.stateNode;
|
||||
(inst.refs === emptyObject ? inst.refs = {} : inst.refs)[ref] = component.getPublicInstance();
|
||||
} else invariant(isValidOwner(owner), "addComponentAsRefTo(...): Only a ReactOwner can have refs. You might " + "be adding a ref to a component that was not created inside a component's " + "`render` method, or you have multiple copies of React loaded " + "(details: https://fb.me/react-refs-must-have-owner)."),
|
||||
} else invariant(isValidOwner(owner), "addComponentAsRefTo(...): Only a ReactOwner can have refs. You might " + "be adding a ref to a component that was not created inside a component's " + "`render` method, or you have multiple copies of React loaded " + "(details: https://fb.me/react-refs-must-have-owner)."),
|
||||
owner.attachRef(ref, component);
|
||||
},
|
||||
removeComponentAsRefFrom: function(component, ref, owner) {
|
||||
@ -1020,10 +1020,10 @@ ReactRef.attachRefs = function(instance, element) {
|
||||
}
|
||||
}, ReactRef.shouldUpdateRefs = function(prevElement, nextElement) {
|
||||
var prevRef = null, prevOwner = null;
|
||||
null !== prevElement && "object" == typeof prevElement && (prevRef = prevElement.ref,
|
||||
null !== prevElement && "object" == typeof prevElement && (prevRef = prevElement.ref,
|
||||
prevOwner = prevElement._owner);
|
||||
var nextRef = null, nextOwner = null;
|
||||
return null !== nextElement && "object" == typeof nextElement && (nextRef = nextElement.ref,
|
||||
return null !== nextElement && "object" == typeof nextElement && (nextRef = nextElement.ref,
|
||||
nextOwner = nextElement._owner), prevRef !== nextRef || "string" == typeof nextRef && nextOwner !== prevOwner;
|
||||
}, ReactRef.detachRefs = function(instance, element) {
|
||||
if (null !== element && "object" == typeof element) {
|
||||
@ -1041,7 +1041,7 @@ function attachRefs() {
|
||||
var ReactReconciler = {
|
||||
mountComponent: function(internalInstance, transaction, hostParent, hostContainerInfo, context, parentDebugID) {
|
||||
var markup = internalInstance.mountComponent(transaction, hostParent, hostContainerInfo, context, parentDebugID);
|
||||
return internalInstance._currentElement && null != internalInstance._currentElement.ref && transaction.getReactMountReady().enqueue(attachRefs, internalInstance),
|
||||
return internalInstance._currentElement && null != internalInstance._currentElement.ref && transaction.getReactMountReady().enqueue(attachRefs, internalInstance),
|
||||
markup;
|
||||
},
|
||||
getHostNode: function(internalInstance) {
|
||||
@ -1054,7 +1054,7 @@ var ReactReconciler = {
|
||||
var prevElement = internalInstance._currentElement;
|
||||
if (nextElement !== prevElement || context !== internalInstance._context) {
|
||||
var refsChanged = ReactRef_1.shouldUpdateRefs(prevElement, nextElement);
|
||||
refsChanged && ReactRef_1.detachRefs(internalInstance, prevElement), internalInstance.receiveComponent(nextElement, transaction, context),
|
||||
refsChanged && ReactRef_1.detachRefs(internalInstance, prevElement), internalInstance.receiveComponent(nextElement, transaction, context),
|
||||
refsChanged && internalInstance._currentElement && null != internalInstance._currentElement.ref && transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
|
||||
}
|
||||
},
|
||||
@ -1082,7 +1082,7 @@ var ReactReconciler = {
|
||||
enableAsyncSubtreeAPI: !1
|
||||
}, ReactFeatureFlags_1 = ReactFeatureFlags, OBSERVED_ERROR = {}, TransactionImpl = {
|
||||
reinitializeTransaction: function() {
|
||||
this.transactionWrappers = this.getTransactionWrappers(), this.wrapperInitData ? this.wrapperInitData.length = 0 : this.wrapperInitData = [],
|
||||
this.transactionWrappers = this.getTransactionWrappers(), this.wrapperInitData ? this.wrapperInitData.length = 0 : this.wrapperInitData = [],
|
||||
this._isInTransaction = !1;
|
||||
},
|
||||
_isInTransaction: !1,
|
||||
@ -1094,7 +1094,7 @@ var ReactReconciler = {
|
||||
invariant(!this.isInTransaction(), "Transaction.perform(...): Cannot initialize a transaction when there " + "is already an outstanding transaction.");
|
||||
var errorThrown, ret;
|
||||
try {
|
||||
this._isInTransaction = !0, errorThrown = !0, this.initializeAll(0), ret = method.call(scope, a, b, c, d, e, f),
|
||||
this._isInTransaction = !0, errorThrown = !0, this.initializeAll(0), ret = method.call(scope, a, b, c, d, e, f),
|
||||
errorThrown = !1;
|
||||
} finally {
|
||||
try {
|
||||
@ -1124,7 +1124,7 @@ var ReactReconciler = {
|
||||
for (var transactionWrappers = this.transactionWrappers, i = startIndex; i < transactionWrappers.length; i++) {
|
||||
var errorThrown, wrapper = transactionWrappers[i], initData = this.wrapperInitData[i];
|
||||
try {
|
||||
errorThrown = !0, initData !== OBSERVED_ERROR && wrapper.close && wrapper.close.call(this, initData),
|
||||
errorThrown = !0, initData !== OBSERVED_ERROR && wrapper.close && wrapper.close.call(this, initData),
|
||||
errorThrown = !1;
|
||||
} finally {
|
||||
if (errorThrown) try {
|
||||
@ -1145,7 +1145,7 @@ var NESTED_UPDATES = {
|
||||
this.dirtyComponentsLength = dirtyComponents.length;
|
||||
},
|
||||
close: function() {
|
||||
this.dirtyComponentsLength !== dirtyComponents.length ? (dirtyComponents.splice(0, this.dirtyComponentsLength),
|
||||
this.dirtyComponentsLength !== dirtyComponents.length ? (dirtyComponents.splice(0, this.dirtyComponentsLength),
|
||||
flushBatchedUpdates()) : dirtyComponents.length = 0;
|
||||
}
|
||||
}, TRANSACTION_WRAPPERS = [ NESTED_UPDATES ];
|
||||
@ -1159,7 +1159,7 @@ Object.assign(ReactUpdatesFlushTransaction.prototype, Transaction, {
|
||||
return TRANSACTION_WRAPPERS;
|
||||
},
|
||||
destructor: function() {
|
||||
this.dirtyComponentsLength = null, ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction),
|
||||
this.dirtyComponentsLength = null, ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction),
|
||||
this.reconcileTransaction = null;
|
||||
},
|
||||
perform: function(method, scope, a) {
|
||||
@ -1177,16 +1177,16 @@ function mountOrderComparator(c1, c2) {
|
||||
|
||||
function runBatchedUpdates(transaction) {
|
||||
var len = transaction.dirtyComponentsLength;
|
||||
invariant(len === dirtyComponents.length, "Expected flush transaction's stored dirty-components length (%s) to " + "match dirty-components array length (%s).", len, dirtyComponents.length),
|
||||
invariant(len === dirtyComponents.length, "Expected flush transaction's stored dirty-components length (%s) to " + "match dirty-components array length (%s).", len, dirtyComponents.length),
|
||||
dirtyComponents.sort(mountOrderComparator), updateBatchNumber++;
|
||||
for (var i = 0; i < len; i++) {
|
||||
var markerName, component = dirtyComponents[i];
|
||||
if (ReactFeatureFlags_1.logTopLevelRenders) {
|
||||
var namedComponent = component;
|
||||
component._currentElement.type.isReactTopLevelWrapper && (namedComponent = component._renderedComponent),
|
||||
component._currentElement.type.isReactTopLevelWrapper && (namedComponent = component._renderedComponent),
|
||||
markerName = "React update: " + namedComponent.getName(), console.time(markerName);
|
||||
}
|
||||
ReactReconciler_1.performUpdateIfNecessary(component, transaction.reconcileTransaction, updateBatchNumber),
|
||||
ReactReconciler_1.performUpdateIfNecessary(component, transaction.reconcileTransaction, updateBatchNumber),
|
||||
markerName && console.timeEnd(markerName);
|
||||
}
|
||||
}
|
||||
@ -1205,13 +1205,13 @@ function enqueueUpdate$1(component) {
|
||||
|
||||
var ReactUpdatesInjection = {
|
||||
injectReconcileTransaction: function(ReconcileTransaction) {
|
||||
invariant(ReconcileTransaction, "ReactUpdates: must provide a reconcile transaction class"),
|
||||
invariant(ReconcileTransaction, "ReactUpdates: must provide a reconcile transaction class"),
|
||||
ReactUpdates.ReactReconcileTransaction = ReconcileTransaction;
|
||||
},
|
||||
injectBatchingStrategy: function(_batchingStrategy) {
|
||||
invariant(_batchingStrategy, "ReactUpdates: must provide a batching strategy"),
|
||||
invariant("function" == typeof _batchingStrategy.batchedUpdates, "ReactUpdates: must provide a batchedUpdates() function"),
|
||||
invariant("boolean" == typeof _batchingStrategy.isBatchingUpdates, "ReactUpdates: must provide an isBatchingUpdates boolean attribute"),
|
||||
invariant(_batchingStrategy, "ReactUpdates: must provide a batching strategy"),
|
||||
invariant("function" == typeof _batchingStrategy.batchedUpdates, "ReactUpdates: must provide a batchedUpdates() function"),
|
||||
invariant("boolean" == typeof _batchingStrategy.isBatchingUpdates, "ReactUpdates: must provide an isBatchingUpdates boolean attribute"),
|
||||
batchingStrategy = _batchingStrategy;
|
||||
},
|
||||
getBatchingStrategy: function() {
|
||||
@ -1242,30 +1242,30 @@ var ReactUpdateQueue = {
|
||||
return !!internalInstance && !!internalInstance._renderedComponent;
|
||||
},
|
||||
enqueueCallbackInternal: function(internalInstance, callback) {
|
||||
internalInstance._pendingCallbacks ? internalInstance._pendingCallbacks.push(callback) : internalInstance._pendingCallbacks = [ callback ],
|
||||
internalInstance._pendingCallbacks ? internalInstance._pendingCallbacks.push(callback) : internalInstance._pendingCallbacks = [ callback ],
|
||||
enqueueUpdate(internalInstance);
|
||||
},
|
||||
enqueueForceUpdate: function(publicInstance, callback, callerName) {
|
||||
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
|
||||
internalInstance && (callback = void 0 === callback ? null : callback, null !== callback && (internalInstance._pendingCallbacks ? internalInstance._pendingCallbacks.push(callback) : internalInstance._pendingCallbacks = [ callback ]),
|
||||
internalInstance && (callback = void 0 === callback ? null : callback, null !== callback && (internalInstance._pendingCallbacks ? internalInstance._pendingCallbacks.push(callback) : internalInstance._pendingCallbacks = [ callback ]),
|
||||
internalInstance._pendingForceUpdate = !0, enqueueUpdate(internalInstance));
|
||||
},
|
||||
enqueueReplaceState: function(publicInstance, completeState, callback, callerName) {
|
||||
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
|
||||
internalInstance && (internalInstance._pendingStateQueue = [ completeState ], internalInstance._pendingReplaceState = !0,
|
||||
callback = void 0 === callback ? null : callback, null !== callback && (internalInstance._pendingCallbacks ? internalInstance._pendingCallbacks.push(callback) : internalInstance._pendingCallbacks = [ callback ]),
|
||||
internalInstance && (internalInstance._pendingStateQueue = [ completeState ], internalInstance._pendingReplaceState = !0,
|
||||
callback = void 0 === callback ? null : callback, null !== callback && (internalInstance._pendingCallbacks ? internalInstance._pendingCallbacks.push(callback) : internalInstance._pendingCallbacks = [ callback ]),
|
||||
enqueueUpdate(internalInstance));
|
||||
},
|
||||
enqueueSetState: function(publicInstance, partialState, callback, callerName) {
|
||||
var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
|
||||
if (internalInstance) {
|
||||
(internalInstance._pendingStateQueue || (internalInstance._pendingStateQueue = [])).push(partialState),
|
||||
callback = void 0 === callback ? null : callback, null !== callback && (internalInstance._pendingCallbacks ? internalInstance._pendingCallbacks.push(callback) : internalInstance._pendingCallbacks = [ callback ]),
|
||||
(internalInstance._pendingStateQueue || (internalInstance._pendingStateQueue = [])).push(partialState),
|
||||
callback = void 0 === callback ? null : callback, null !== callback && (internalInstance._pendingCallbacks ? internalInstance._pendingCallbacks.push(callback) : internalInstance._pendingCallbacks = [ callback ]),
|
||||
enqueueUpdate(internalInstance);
|
||||
}
|
||||
},
|
||||
enqueueElementInternal: function(internalInstance, nextElement, nextContext) {
|
||||
internalInstance._pendingElement = nextElement, internalInstance._context = nextContext,
|
||||
internalInstance._pendingElement = nextElement, internalInstance._context = nextContext,
|
||||
enqueueUpdate(internalInstance);
|
||||
}
|
||||
}, ReactUpdateQueue_1 = ReactUpdateQueue, injected = !1, ReactComponentEnvironment = {
|
||||
@ -1273,9 +1273,9 @@ var ReactUpdateQueue = {
|
||||
processChildrenUpdates: null,
|
||||
injection: {
|
||||
injectEnvironment: function(environment) {
|
||||
invariant(!injected, "ReactCompositeComponent: injectEnvironment() can only be called once."),
|
||||
ReactComponentEnvironment.replaceNodeWithMarkup = environment.replaceNodeWithMarkup,
|
||||
ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates,
|
||||
invariant(!injected, "ReactCompositeComponent: injectEnvironment() can only be called once."),
|
||||
ReactComponentEnvironment.replaceNodeWithMarkup = environment.replaceNodeWithMarkup,
|
||||
ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates,
|
||||
injected = !0;
|
||||
}
|
||||
}
|
||||
@ -1317,28 +1317,28 @@ function isPureComponent(Component) {
|
||||
|
||||
var nextMountID = 1, ReactCompositeComponent = {
|
||||
construct: function(element) {
|
||||
this._currentElement = element, this._rootNodeID = 0, this._compositeType = null,
|
||||
this._instance = null, this._hostParent = null, this._hostContainerInfo = null,
|
||||
this._updateBatchNumber = null, this._pendingElement = null, this._pendingStateQueue = null,
|
||||
this._pendingReplaceState = !1, this._pendingForceUpdate = !1, this._renderedNodeType = null,
|
||||
this._renderedComponent = null, this._context = null, this._mountOrder = 0, this._topLevelWrapper = null,
|
||||
this._currentElement = element, this._rootNodeID = 0, this._compositeType = null,
|
||||
this._instance = null, this._hostParent = null, this._hostContainerInfo = null,
|
||||
this._updateBatchNumber = null, this._pendingElement = null, this._pendingStateQueue = null,
|
||||
this._pendingReplaceState = !1, this._pendingForceUpdate = !1, this._renderedNodeType = null,
|
||||
this._renderedComponent = null, this._context = null, this._mountOrder = 0, this._topLevelWrapper = null,
|
||||
this._pendingCallbacks = null, this._calledComponentWillUnmount = !1;
|
||||
},
|
||||
mountComponent: function(transaction, hostParent, hostContainerInfo, context) {
|
||||
this._context = context, this._mountOrder = nextMountID++, this._hostParent = hostParent,
|
||||
this._context = context, this._mountOrder = nextMountID++, this._hostParent = hostParent,
|
||||
this._hostContainerInfo = hostContainerInfo;
|
||||
var renderedElement, publicProps = this._currentElement.props, publicContext = this._processContext(context), Component = this._currentElement.type, updateQueue = transaction.getUpdateQueue(), doConstruct = shouldConstruct(Component), inst = this._constructComponent(doConstruct, publicProps, publicContext, updateQueue);
|
||||
doConstruct || null != inst && null != inst.render ? isPureComponent(Component) ? this._compositeType = ReactCompositeComponentTypes$1.PureClass : this._compositeType = ReactCompositeComponentTypes$1.ImpureClass : (renderedElement = inst,
|
||||
invariant(null === inst || !1 === inst || React.isValidElement(inst), "%s(...): A valid React element (or null) must be returned. You may have " + "returned undefined, an array or some other invalid object.", Component.displayName || Component.name || "Component"),
|
||||
inst = new StatelessComponent(Component), this._compositeType = ReactCompositeComponentTypes$1.StatelessFunctional),
|
||||
inst.props = publicProps, inst.context = publicContext, inst.refs = emptyObject,
|
||||
doConstruct || null != inst && null != inst.render ? isPureComponent(Component) ? this._compositeType = ReactCompositeComponentTypes$1.PureClass : this._compositeType = ReactCompositeComponentTypes$1.ImpureClass : (renderedElement = inst,
|
||||
invariant(null === inst || !1 === inst || React.isValidElement(inst), "%s(...): A valid React element (or null) must be returned. You may have " + "returned undefined, an array or some other invalid object.", Component.displayName || Component.name || "Component"),
|
||||
inst = new StatelessComponent(Component), this._compositeType = ReactCompositeComponentTypes$1.StatelessFunctional),
|
||||
inst.props = publicProps, inst.context = publicContext, inst.refs = emptyObject,
|
||||
inst.updater = updateQueue, this._instance = inst, ReactInstanceMap_1.set(inst, this);
|
||||
var initialState = inst.state;
|
||||
void 0 === initialState && (inst.state = initialState = null), invariant("object" == typeof initialState && !Array.isArray(initialState), "%s.state: must be set to an object or null", this.getName() || "ReactCompositeComponent"),
|
||||
this._pendingStateQueue = null, this._pendingReplaceState = !1, this._pendingForceUpdate = !1,
|
||||
void 0 === initialState && (inst.state = initialState = null), invariant("object" == typeof initialState && !Array.isArray(initialState), "%s.state: must be set to an object or null", this.getName() || "ReactCompositeComponent"),
|
||||
this._pendingStateQueue = null, this._pendingReplaceState = !1, this._pendingForceUpdate = !1,
|
||||
inst.componentWillMount && (inst.componentWillMount(), this._pendingStateQueue && (inst.state = this._processPendingState(inst.props, inst.context)));
|
||||
var markup;
|
||||
markup = inst.unstable_handleError ? this.performInitialMountWithErrorHandling(renderedElement, hostParent, hostContainerInfo, transaction, context) : this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context),
|
||||
markup = inst.unstable_handleError ? this.performInitialMountWithErrorHandling(renderedElement, hostParent, hostContainerInfo, transaction, context) : this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context),
|
||||
inst.componentDidMount && transaction.getReactMountReady().enqueue(inst.componentDidMount, inst);
|
||||
var callbacks = this._pendingCallbacks;
|
||||
if (callbacks) {
|
||||
@ -1359,8 +1359,8 @@ var nextMountID = 1, ReactCompositeComponent = {
|
||||
try {
|
||||
markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context);
|
||||
} catch (e) {
|
||||
transaction.rollback(checkpoint), this._instance.unstable_handleError(e), this._pendingStateQueue && (this._instance.state = this._processPendingState(this._instance.props, this._instance.context)),
|
||||
checkpoint = transaction.checkpoint(), this._renderedComponent.unmountComponent(!0, !0),
|
||||
transaction.rollback(checkpoint), this._instance.unstable_handleError(e), this._pendingStateQueue && (this._instance.state = this._processPendingState(this._instance.props, this._instance.context)),
|
||||
checkpoint = transaction.checkpoint(), this._renderedComponent.unmountComponent(!0, !0),
|
||||
transaction.rollback(checkpoint), markup = this.performInitialMount(renderedElement, hostParent, hostContainerInfo, transaction, context);
|
||||
}
|
||||
return markup;
|
||||
@ -1378,17 +1378,17 @@ var nextMountID = 1, ReactCompositeComponent = {
|
||||
unmountComponent: function(safely, skipLifecycle) {
|
||||
if (this._renderedComponent) {
|
||||
var inst = this._instance;
|
||||
if (inst.componentWillUnmount && !inst._calledComponentWillUnmount) if (inst._calledComponentWillUnmount = !0,
|
||||
if (inst.componentWillUnmount && !inst._calledComponentWillUnmount) if (inst._calledComponentWillUnmount = !0,
|
||||
safely) {
|
||||
if (!skipLifecycle) {
|
||||
var name = this.getName() + ".componentWillUnmount()";
|
||||
ReactErrorUtils_1.invokeGuardedCallbackAndCatchFirstError(name, inst.componentWillUnmount, inst);
|
||||
}
|
||||
} else inst.componentWillUnmount();
|
||||
this._renderedComponent && (ReactReconciler_1.unmountComponent(this._renderedComponent, safely, skipLifecycle),
|
||||
this._renderedNodeType = null, this._renderedComponent = null, this._instance = null),
|
||||
this._pendingStateQueue = null, this._pendingReplaceState = !1, this._pendingForceUpdate = !1,
|
||||
this._pendingCallbacks = null, this._pendingElement = null, this._context = null,
|
||||
this._renderedComponent && (ReactReconciler_1.unmountComponent(this._renderedComponent, safely, skipLifecycle),
|
||||
this._renderedNodeType = null, this._renderedComponent = null, this._instance = null),
|
||||
this._pendingStateQueue = null, this._pendingReplaceState = !1, this._pendingForceUpdate = !1,
|
||||
this._pendingCallbacks = null, this._pendingElement = null, this._context = null,
|
||||
this._rootNodeID = 0, this._topLevelWrapper = null, ReactInstanceMap_1.remove(inst);
|
||||
}
|
||||
},
|
||||
@ -1427,7 +1427,7 @@ var nextMountID = 1, ReactCompositeComponent = {
|
||||
var inst = this._instance;
|
||||
invariant(null != inst, "Attempted to update component `%s` that has already been unmounted " + "(or failed to mount).", this.getName() || "ReactCompositeComponent");
|
||||
var nextContext, willReceive = !1;
|
||||
this._context === nextUnmaskedContext ? nextContext = inst.context : (nextContext = this._processContext(nextUnmaskedContext),
|
||||
this._context === nextUnmaskedContext ? nextContext = inst.context : (nextContext = this._processContext(nextUnmaskedContext),
|
||||
willReceive = !0);
|
||||
var prevProps = prevParentElement.props, nextProps = nextParentElement.props;
|
||||
if (prevParentElement !== nextParentElement && (willReceive = !0), willReceive && inst.componentWillReceiveProps) {
|
||||
@ -1443,9 +1443,9 @@ var nextMountID = 1, ReactCompositeComponent = {
|
||||
var prevState = inst.state;
|
||||
shouldUpdate = willReceive || nextState !== prevState, inst.shouldComponentUpdate ? shouldUpdate = inst.shouldComponentUpdate(nextProps, nextState, nextContext) : this._compositeType === ReactCompositeComponentTypes$1.PureClass && (shouldUpdate = !shallowEqual(prevProps, nextProps) || !shallowEqual(inst.state, nextState));
|
||||
}
|
||||
if (this._updateBatchNumber = null, shouldUpdate ? (this._pendingForceUpdate = !1,
|
||||
this._performComponentUpdate(nextParentElement, nextProps, nextState, nextContext, transaction, nextUnmaskedContext)) : (this._currentElement = nextParentElement,
|
||||
this._context = nextUnmaskedContext, inst.props = nextProps, inst.state = nextState,
|
||||
if (this._updateBatchNumber = null, shouldUpdate ? (this._pendingForceUpdate = !1,
|
||||
this._performComponentUpdate(nextParentElement, nextProps, nextState, nextContext, transaction, nextUnmaskedContext)) : (this._currentElement = nextParentElement,
|
||||
this._context = nextUnmaskedContext, inst.props = nextProps, inst.state = nextState,
|
||||
inst.context = nextContext), callbacks) for (var j = 0; j < callbacks.length; j++) transaction.getReactMountReady().enqueue(callbacks[j], this.getPublicInstance());
|
||||
},
|
||||
_processPendingState: function(props, context) {
|
||||
@ -1460,9 +1460,9 @@ var nextMountID = 1, ReactCompositeComponent = {
|
||||
},
|
||||
_performComponentUpdate: function(nextElement, nextProps, nextState, nextContext, transaction, unmaskedContext) {
|
||||
var prevProps, prevState, inst = this._instance, hasComponentDidUpdate = !!inst.componentDidUpdate;
|
||||
hasComponentDidUpdate && (prevProps = inst.props, prevState = inst.state), inst.componentWillUpdate && inst.componentWillUpdate(nextProps, nextState, nextContext),
|
||||
this._currentElement = nextElement, this._context = unmaskedContext, inst.props = nextProps,
|
||||
inst.state = nextState, inst.context = nextContext, inst.unstable_handleError ? this._updateRenderedComponentWithErrorHandling(transaction, unmaskedContext) : this._updateRenderedComponent(transaction, unmaskedContext),
|
||||
hasComponentDidUpdate && (prevProps = inst.props, prevState = inst.state), inst.componentWillUpdate && inst.componentWillUpdate(nextProps, nextState, nextContext),
|
||||
this._currentElement = nextElement, this._context = unmaskedContext, inst.props = nextProps,
|
||||
inst.state = nextState, inst.context = nextContext, inst.unstable_handleError ? this._updateRenderedComponentWithErrorHandling(transaction, unmaskedContext) : this._updateRenderedComponent(transaction, unmaskedContext),
|
||||
hasComponentDidUpdate && transaction.getReactMountReady().enqueue(inst.componentDidUpdate.bind(inst, prevProps, prevState), inst);
|
||||
},
|
||||
_updateRenderedComponentWithErrorHandling: function(transaction, context) {
|
||||
@ -1470,8 +1470,8 @@ var nextMountID = 1, ReactCompositeComponent = {
|
||||
try {
|
||||
this._updateRenderedComponent(transaction, context);
|
||||
} catch (e) {
|
||||
transaction.rollback(checkpoint), this._instance.unstable_handleError(e), this._pendingStateQueue && (this._instance.state = this._processPendingState(this._instance.props, this._instance.context)),
|
||||
checkpoint = transaction.checkpoint(), this._updateRenderedComponentWithNextElement(transaction, context, null, !0),
|
||||
transaction.rollback(checkpoint), this._instance.unstable_handleError(e), this._pendingStateQueue && (this._instance.state = this._processPendingState(this._instance.props, this._instance.context)),
|
||||
checkpoint = transaction.checkpoint(), this._updateRenderedComponentWithNextElement(transaction, context, null, !0),
|
||||
this._updateRenderedComponent(transaction, context);
|
||||
}
|
||||
},
|
||||
@ -1489,7 +1489,7 @@ var nextMountID = 1, ReactCompositeComponent = {
|
||||
var child = this._instantiateReactComponent(nextRenderedElement, nodeType !== ReactNodeTypes_1.EMPTY);
|
||||
this._renderedComponent = child;
|
||||
var nextMarkup = ReactReconciler_1.mountComponent(child, transaction, this._hostParent, this._hostContainerInfo, this._processChildContext(context), 0);
|
||||
ReactFeatureFlags_1.prepareNewChildrenBeforeUnmountInStack && ReactReconciler_1.unmountComponent(prevComponentInstance, safely, !1),
|
||||
ReactFeatureFlags_1.prepareNewChildrenBeforeUnmountInStack && ReactReconciler_1.unmountComponent(prevComponentInstance, safely, !1),
|
||||
this._replaceNodeWithMarkup(oldHostNode, nextMarkup, prevComponentInstance);
|
||||
}
|
||||
},
|
||||
@ -1510,7 +1510,7 @@ var nextMountID = 1, ReactCompositeComponent = {
|
||||
ReactCurrentOwner$1.current = null;
|
||||
}
|
||||
}
|
||||
return invariant(null === renderedElement || !1 === renderedElement || React.isValidElement(renderedElement), "%s.render(): A valid React element (or null) must be returned. You may have " + "returned undefined, an array or some other invalid object.", this.getName() || "ReactCompositeComponent"),
|
||||
return invariant(null === renderedElement || !1 === renderedElement || React.isValidElement(renderedElement), "%s.render(): A valid React element (or null) must be returned. You may have " + "returned undefined, an array or some other invalid object.", this.getName() || "ReactCompositeComponent"),
|
||||
renderedElement;
|
||||
},
|
||||
attachRef: function(ref, component) {
|
||||
@ -1553,7 +1553,7 @@ var ReactEmptyComponent_1 = ReactEmptyComponent, genericComponentClass = null, t
|
||||
};
|
||||
|
||||
function createInternalComponent(element) {
|
||||
return invariant(genericComponentClass, "There is no registered component for the tag %s", element.type),
|
||||
return invariant(genericComponentClass, "There is no registered component for the tag %s", element.type),
|
||||
new genericComponentClass(element);
|
||||
}
|
||||
|
||||
@ -1594,7 +1594,7 @@ function instantiateReactComponent(node, shouldHaveDebugID) {
|
||||
var info = "";
|
||||
info += getDeclarationErrorAddendum(element._owner), invariant(!1, "Element type is invalid: expected a string (for built-in components) " + "or a class/function (for composite components) but got: %s.%s", null == type ? type : typeof type, info);
|
||||
}
|
||||
"string" == typeof element.type ? instance = ReactHostComponent_1.createInternalComponent(element) : isInternalComponentType(element.type) ? (instance = new element.type(element),
|
||||
"string" == typeof element.type ? instance = ReactHostComponent_1.createInternalComponent(element) : isInternalComponentType(element.type) ? (instance = new element.type(element),
|
||||
instance.getHostNode || (instance.getHostNode = instance.getNativeNode)) : instance = new ReactCompositeComponentWrapper(element);
|
||||
} else "string" == typeof node || "number" == typeof node ? instance = ReactHostComponent_1.createInstanceForText(node) : invariant(!1, "Encountered invalid React node of type %s", typeof node);
|
||||
return instance._mountIndex = 0, instance._mountImage = null, instance;
|
||||
@ -1619,7 +1619,7 @@ function findNodeHandle(componentOrHandle) {
|
||||
if (null == componentOrHandle) return null;
|
||||
if ("number" == typeof componentOrHandle) return componentOrHandle;
|
||||
var component = componentOrHandle, internalInstance = ReactInstanceMap_1.get(component);
|
||||
return internalInstance ? injectedFindNode(internalInstance) : component || (invariant("object" == typeof component && ("_rootNodeID" in component || "_nativeTag" in component) || null != component.render && "function" == typeof component.render, "findNodeHandle(...): Argument is not a component " + "(type: %s, keys: %s)", typeof component, Object.keys(component)),
|
||||
return internalInstance ? injectedFindNode(internalInstance) : component || (invariant("object" == typeof component && ("_rootNodeID" in component || "_nativeTag" in component) || null != component.render && "function" == typeof component.render, "findNodeHandle(...): Argument is not a component " + "(type: %s, keys: %s)", typeof component, Object.keys(component)),
|
||||
void invariant(!1, "findNodeHandle(...): Unable to find node handle for unmounted " + "component."));
|
||||
}
|
||||
|
||||
@ -1636,7 +1636,7 @@ function mountComponentIntoNode(componentInstance, containerTag, transaction) {
|
||||
|
||||
function batchedMountComponentIntoNode(componentInstance, containerTag) {
|
||||
var transaction = ReactUpdates_1.ReactReconcileTransaction.getPooled();
|
||||
transaction.perform(mountComponentIntoNode, null, componentInstance, containerTag, transaction),
|
||||
transaction.perform(mountComponentIntoNode, null, componentInstance, containerTag, transaction),
|
||||
ReactUpdates_1.ReactReconcileTransaction.release(transaction);
|
||||
}
|
||||
|
||||
@ -1649,12 +1649,12 @@ var ReactNativeMount = {
|
||||
}), topRootNodeID = containerTag, prevComponent = ReactNativeMount._instancesByContainerID[topRootNodeID];
|
||||
if (prevComponent) {
|
||||
var prevWrappedElement = prevComponent._currentElement, prevElement = prevWrappedElement.props.child;
|
||||
if (shouldUpdateReactComponent_1(prevElement, nextElement)) return ReactUpdateQueue_1.enqueueElementInternal(prevComponent, nextWrappedElement, emptyObject),
|
||||
callback && ReactUpdateQueue_1.enqueueCallbackInternal(prevComponent, callback),
|
||||
if (shouldUpdateReactComponent_1(prevElement, nextElement)) return ReactUpdateQueue_1.enqueueElementInternal(prevComponent, nextWrappedElement, emptyObject),
|
||||
callback && ReactUpdateQueue_1.enqueueCallbackInternal(prevComponent, callback),
|
||||
prevComponent;
|
||||
ReactNativeMount.unmountComponentAtNode(containerTag);
|
||||
}
|
||||
if (!ReactNativeTagHandles_1.reactTagIsNativeTopRootID(containerTag)) return console.error("You cannot render into anything but a top root"),
|
||||
if (!ReactNativeTagHandles_1.reactTagIsNativeTopRootID(containerTag)) return console.error("You cannot render into anything but a top root"),
|
||||
null;
|
||||
ReactNativeTagHandles_1.assertRootTag(containerTag);
|
||||
var instance = instantiateReactComponent_1(nextWrappedElement, !1);
|
||||
@ -1664,7 +1664,7 @@ var ReactNativeMount = {
|
||||
nonNullCallback.call(instance._renderedComponent.getPublicInstance());
|
||||
} ];
|
||||
}
|
||||
return ReactUpdates_1.batchedUpdates(batchedMountComponentIntoNode, instance, containerTag),
|
||||
return ReactUpdates_1.batchedUpdates(batchedMountComponentIntoNode, instance, containerTag),
|
||||
instance._renderedComponent.getPublicInstance();
|
||||
},
|
||||
_mountImageIntoNode: function(mountImage, containerID) {
|
||||
@ -1675,10 +1675,10 @@ var ReactNativeMount = {
|
||||
ReactNativeMount.unmountComponentAtNode(containerTag), UIManager.removeRootView(containerTag);
|
||||
},
|
||||
unmountComponentAtNode: function(containerTag) {
|
||||
if (!ReactNativeTagHandles_1.reactTagIsNativeTopRootID(containerTag)) return console.error("You cannot render into anything but a top root"),
|
||||
if (!ReactNativeTagHandles_1.reactTagIsNativeTopRootID(containerTag)) return console.error("You cannot render into anything but a top root"),
|
||||
!1;
|
||||
var instance = ReactNativeMount._instancesByContainerID[containerTag];
|
||||
return !!instance && (ReactNativeMount.unmountComponentFromNode(instance, containerTag),
|
||||
return !!instance && (ReactNativeMount.unmountComponentFromNode(instance, containerTag),
|
||||
delete ReactNativeMount._instancesByContainerID[containerTag], !0);
|
||||
},
|
||||
unmountComponentFromNode: function(instance, containerID) {
|
||||
@ -1714,7 +1714,7 @@ var transaction = new ReactDefaultBatchingStrategyTransaction(), ReactDefaultBat
|
||||
if (childrenUpdates.length) {
|
||||
for (var moveFromIndices, moveToIndices, addChildTags, addAtIndices, removeAtIndices, containerTag = ReactNativeComponentTree_1.getNodeFromInstance(inst), i = 0; i < childrenUpdates.length; i++) {
|
||||
var update = childrenUpdates[i];
|
||||
if ("MOVE_EXISTING" === update.type) (moveFromIndices || (moveFromIndices = [])).push(update.fromIndex),
|
||||
if ("MOVE_EXISTING" === update.type) (moveFromIndices || (moveFromIndices = [])).push(update.fromIndex),
|
||||
(moveToIndices || (moveToIndices = [])).push(update.toIndex); else if ("REMOVE_NODE" === update.type) (removeAtIndices || (removeAtIndices = [])).push(update.fromIndex); else if ("INSERT_MARKUP" === update.type) {
|
||||
var mountImage = update.content, tag = mountImage;
|
||||
(addAtIndices || (addAtIndices = [])).push(update.toIndex), (addChildTags || (addChildTags = [])).push(tag);
|
||||
@ -1742,16 +1742,16 @@ function _classCallCheck(instance, Constructor) {
|
||||
|
||||
var CallbackQueue = function() {
|
||||
function CallbackQueue(arg) {
|
||||
_classCallCheck(this, CallbackQueue), this._callbacks = null, this._contexts = null,
|
||||
_classCallCheck(this, CallbackQueue), this._callbacks = null, this._contexts = null,
|
||||
this._arg = arg;
|
||||
}
|
||||
return CallbackQueue.prototype.enqueue = function(callback, context) {
|
||||
this._callbacks = this._callbacks || [], this._callbacks.push(callback), this._contexts = this._contexts || [],
|
||||
this._callbacks = this._callbacks || [], this._callbacks.push(callback), this._contexts = this._contexts || [],
|
||||
this._contexts.push(context);
|
||||
}, CallbackQueue.prototype.notifyAll = function() {
|
||||
var callbacks = this._callbacks, contexts = this._contexts, arg = this._arg;
|
||||
if (callbacks && contexts) {
|
||||
invariant(callbacks.length === contexts.length, "Mismatched list of contexts in callback queue"),
|
||||
invariant(callbacks.length === contexts.length, "Mismatched list of contexts in callback queue"),
|
||||
this._callbacks = null, this._contexts = null;
|
||||
for (var i = 0; i < callbacks.length; i++) validateCallback_1(callbacks[i]), callbacks[i].call(contexts[i], arg);
|
||||
callbacks.length = 0, contexts.length = 0;
|
||||
@ -1799,7 +1799,7 @@ var Mixin = {
|
||||
}
|
||||
};
|
||||
|
||||
Object.assign(ReactNativeReconcileTransaction.prototype, Transaction, ReactNativeReconcileTransaction, Mixin),
|
||||
Object.assign(ReactNativeReconcileTransaction.prototype, Transaction, ReactNativeReconcileTransaction, Mixin),
|
||||
PooledClass_1.addPoolingTo(ReactNativeReconcileTransaction);
|
||||
|
||||
var ReactNativeReconcileTransaction_1 = ReactNativeReconcileTransaction, ReactNativeComponentEnvironment = {
|
||||
@ -1808,13 +1808,13 @@ var ReactNativeReconcileTransaction_1 = ReactNativeReconcileTransaction, ReactNa
|
||||
clearNode: function() {},
|
||||
ReactReconcileTransaction: ReactNativeReconcileTransaction_1
|
||||
}, ReactNativeComponentEnvironment_1 = ReactNativeComponentEnvironment, ReactNativeTextComponent = function(text) {
|
||||
this._currentElement = text, this._stringText = "" + text, this._hostParent = null,
|
||||
this._currentElement = text, this._stringText = "" + text, this._hostParent = null,
|
||||
this._rootNodeID = 0;
|
||||
};
|
||||
|
||||
Object.assign(ReactNativeTextComponent.prototype, {
|
||||
mountComponent: function(transaction, hostParent, hostContainerInfo, context) {
|
||||
invariant(context.isInAParentText, 'RawText "%s" must be wrapped in an explicit <Text> component.', this._stringText),
|
||||
invariant(context.isInAParentText, 'RawText "%s" must be wrapped in an explicit <Text> component.', this._stringText),
|
||||
this._hostParent = hostParent;
|
||||
var tag = ReactNativeTagHandles_1.allocateTag();
|
||||
this._rootNodeID = tag;
|
||||
@ -1836,7 +1836,7 @@ Object.assign(ReactNativeTextComponent.prototype, {
|
||||
}
|
||||
},
|
||||
unmountComponent: function() {
|
||||
ReactNativeComponentTree_1.uncacheNode(this), this._currentElement = null, this._stringText = null,
|
||||
ReactNativeComponentTree_1.uncacheNode(this), this._currentElement = null, this._stringText = null,
|
||||
this._rootNodeID = 0;
|
||||
}
|
||||
});
|
||||
@ -1854,7 +1854,7 @@ Object.assign(ReactSimpleEmptyComponent.prototype, {
|
||||
return ReactReconciler_1.getHostNode(this._renderedComponent);
|
||||
},
|
||||
unmountComponent: function(safely, skipLifecycle) {
|
||||
ReactReconciler_1.unmountComponent(this._renderedComponent, safely, skipLifecycle),
|
||||
ReactReconciler_1.unmountComponent(this._renderedComponent, safely, skipLifecycle),
|
||||
this._renderedComponent = null;
|
||||
}
|
||||
});
|
||||
@ -1862,9 +1862,9 @@ Object.assign(ReactSimpleEmptyComponent.prototype, {
|
||||
var ReactSimpleEmptyComponent_1 = ReactSimpleEmptyComponent;
|
||||
|
||||
function inject$1() {
|
||||
ReactGenericBatching_1.injection.injectStackBatchedUpdates(ReactUpdates_1.batchedUpdates),
|
||||
ReactUpdates_1.injection.injectReconcileTransaction(ReactNativeComponentEnvironment_1.ReactReconcileTransaction),
|
||||
ReactUpdates_1.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy_1),
|
||||
ReactGenericBatching_1.injection.injectStackBatchedUpdates(ReactUpdates_1.batchedUpdates),
|
||||
ReactUpdates_1.injection.injectReconcileTransaction(ReactNativeComponentEnvironment_1.ReactReconcileTransaction),
|
||||
ReactUpdates_1.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy_1),
|
||||
ReactComponentEnvironment_1.injection.injectEnvironment(ReactNativeComponentEnvironment_1);
|
||||
var EmptyComponent = function(instantiate) {
|
||||
var View = require("View");
|
||||
@ -1875,10 +1875,10 @@ function inject$1() {
|
||||
}
|
||||
}), instantiate);
|
||||
};
|
||||
ReactEmptyComponent_1.injection.injectEmptyComponentFactory(EmptyComponent), ReactHostComponent_1.injection.injectTextComponentClass(ReactNativeTextComponent_1),
|
||||
ReactEmptyComponent_1.injection.injectEmptyComponentFactory(EmptyComponent), ReactHostComponent_1.injection.injectTextComponentClass(ReactNativeTextComponent_1),
|
||||
ReactHostComponent_1.injection.injectGenericComponentClass(function(tag) {
|
||||
var info = "";
|
||||
"string" == typeof tag && /^[a-z]/.test(tag) && (info += " Each component name should start with an uppercase letter."),
|
||||
"string" == typeof tag && /^[a-z]/.test(tag) && (info += " Each component name should start with an uppercase letter."),
|
||||
invariant(!1, "Expected a component class, got %s.%s", tag, info);
|
||||
});
|
||||
}
|
||||
@ -1912,7 +1912,7 @@ var objects = {}, uniqueID = 1, emptyObject$3 = {}, ReactNativePropRegistry = fu
|
||||
}, ReactNativePropRegistry.getByID = function(id) {
|
||||
if (!id) return emptyObject$3;
|
||||
var object = objects[id];
|
||||
return object || (console.warn("Invalid style with id `" + id + "`. Skipping ..."),
|
||||
return object || (console.warn("Invalid style with id `" + id + "`. Skipping ..."),
|
||||
emptyObject$3);
|
||||
}, ReactNativePropRegistry;
|
||||
}(), ReactNativePropRegistry_1 = ReactNativePropRegistry, emptyObject$2 = {}, removedKeys = null, removedKeyCount = 0;
|
||||
@ -1933,7 +1933,7 @@ function restoreDeletedValuesInNestedArray(updatePayload, node, validAttributes)
|
||||
if (void 0 !== nextProp) {
|
||||
var attributeConfig = validAttributes[propKey];
|
||||
if (attributeConfig) {
|
||||
if ("function" == typeof nextProp && (nextProp = !0), void 0 === nextProp && (nextProp = null),
|
||||
if ("function" == typeof nextProp && (nextProp = !0), void 0 === nextProp && (nextProp = null),
|
||||
"object" != typeof attributeConfig) updatePayload[propKey] = nextProp; else if ("function" == typeof attributeConfig.diff || "function" == typeof attributeConfig.process) {
|
||||
var nextValue = "function" == typeof attributeConfig.process ? attributeConfig.process(nextProp) : nextProp;
|
||||
updatePayload[propKey] = nextValue;
|
||||
@ -1973,10 +1973,10 @@ function clearNestedProperty(updatePayload, prevProp, validAttributes) {
|
||||
|
||||
function diffProperties(updatePayload, prevProps, nextProps, validAttributes) {
|
||||
var attributeConfig, nextProp, prevProp;
|
||||
for (var propKey in nextProps) if (attributeConfig = validAttributes[propKey]) if (prevProp = prevProps[propKey],
|
||||
nextProp = nextProps[propKey], "function" == typeof nextProp && (nextProp = !0,
|
||||
"function" == typeof prevProp && (prevProp = !0)), void 0 === nextProp && (nextProp = null,
|
||||
void 0 === prevProp && (prevProp = null)), removedKeys && (removedKeys[propKey] = !1),
|
||||
for (var propKey in nextProps) if (attributeConfig = validAttributes[propKey]) if (prevProp = prevProps[propKey],
|
||||
nextProp = nextProps[propKey], "function" == typeof nextProp && (nextProp = !0,
|
||||
"function" == typeof prevProp && (prevProp = !0)), void 0 === nextProp && (nextProp = null,
|
||||
void 0 === prevProp && (prevProp = null)), removedKeys && (removedKeys[propKey] = !1),
|
||||
updatePayload && void 0 !== updatePayload[propKey]) {
|
||||
if ("object" != typeof attributeConfig) updatePayload[propKey] = nextProp; else if ("function" == typeof attributeConfig.diff || "function" == typeof attributeConfig.process) {
|
||||
var nextValue = "function" == typeof attributeConfig.process ? attributeConfig.process(nextProp) : nextProp;
|
||||
@ -1984,13 +1984,13 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) {
|
||||
}
|
||||
} else if (prevProp !== nextProp) if ("object" != typeof attributeConfig) defaultDiffer(prevProp, nextProp) && ((updatePayload || (updatePayload = {}))[propKey] = nextProp); else if ("function" == typeof attributeConfig.diff || "function" == typeof attributeConfig.process) {
|
||||
var shouldUpdate = void 0 === prevProp || ("function" == typeof attributeConfig.diff ? attributeConfig.diff(prevProp, nextProp) : defaultDiffer(prevProp, nextProp));
|
||||
shouldUpdate && (nextValue = "function" == typeof attributeConfig.process ? attributeConfig.process(nextProp) : nextProp,
|
||||
shouldUpdate && (nextValue = "function" == typeof attributeConfig.process ? attributeConfig.process(nextProp) : nextProp,
|
||||
(updatePayload || (updatePayload = {}))[propKey] = nextValue);
|
||||
} else removedKeys = null, removedKeyCount = 0, updatePayload = diffNestedProperty(updatePayload, prevProp, nextProp, attributeConfig),
|
||||
removedKeyCount > 0 && updatePayload && (restoreDeletedValuesInNestedArray(updatePayload, nextProp, attributeConfig),
|
||||
} else removedKeys = null, removedKeyCount = 0, updatePayload = diffNestedProperty(updatePayload, prevProp, nextProp, attributeConfig),
|
||||
removedKeyCount > 0 && updatePayload && (restoreDeletedValuesInNestedArray(updatePayload, nextProp, attributeConfig),
|
||||
removedKeys = null);
|
||||
for (propKey in prevProps) void 0 === nextProps[propKey] && (attributeConfig = validAttributes[propKey]) && (updatePayload && void 0 !== updatePayload[propKey] || void 0 !== (prevProp = prevProps[propKey]) && ("object" != typeof attributeConfig || "function" == typeof attributeConfig.diff || "function" == typeof attributeConfig.process ? ((updatePayload || (updatePayload = {}))[propKey] = null,
|
||||
removedKeys || (removedKeys = {}), removedKeys[propKey] || (removedKeys[propKey] = !0,
|
||||
for (propKey in prevProps) void 0 === nextProps[propKey] && (attributeConfig = validAttributes[propKey]) && (updatePayload && void 0 !== updatePayload[propKey] || void 0 !== (prevProp = prevProps[propKey]) && ("object" != typeof attributeConfig || "function" == typeof attributeConfig.diff || "function" == typeof attributeConfig.process ? ((updatePayload || (updatePayload = {}))[propKey] = null,
|
||||
removedKeys || (removedKeys = {}), removedKeys[propKey] || (removedKeys[propKey] = !0,
|
||||
removedKeyCount++)) : updatePayload = clearNestedProperty(updatePayload, prevProp, attributeConfig)));
|
||||
return updatePayload;
|
||||
}
|
||||
@ -2026,7 +2026,7 @@ function mountSafeCallback$1(context, callback) {
|
||||
function throwOnStylesProp$1(component, props) {
|
||||
if (void 0 !== props.styles) {
|
||||
var owner = component._owner || null, name = component.constructor.displayName, msg = "`styles` is not a supported property of `" + name + "`, did " + "you mean `style` (singular)?";
|
||||
throw owner && owner.constructor && owner.constructor.displayName && (msg += "\n\nCheck the `" + owner.constructor.displayName + "` parent " + " component."),
|
||||
throw owner && owner.constructor && owner.constructor.displayName && (msg += "\n\nCheck the `" + owner.constructor.displayName + "` parent " + " component."),
|
||||
new Error(msg);
|
||||
}
|
||||
}
|
||||
@ -2091,12 +2091,12 @@ injectedSetNativeProps = ReactNativeFeatureFlags$1.useFiber ? setNativePropsFibe
|
||||
var NativeMethodsMixin_1 = NativeMethodsMixin, TouchHistoryMath = {
|
||||
centroidDimension: function(touchHistory, touchesChangedAfter, isXAxis, ofCurrent) {
|
||||
var touchBank = touchHistory.touchBank, total = 0, count = 0, oneTouchData = 1 === touchHistory.numberActiveTouches ? touchHistory.touchBank[touchHistory.indexOfSingleActiveTouch] : null;
|
||||
if (null !== oneTouchData) oneTouchData.touchActive && oneTouchData.currentTimeStamp > touchesChangedAfter && (total += ofCurrent && isXAxis ? oneTouchData.currentPageX : ofCurrent && !isXAxis ? oneTouchData.currentPageY : !ofCurrent && isXAxis ? oneTouchData.previousPageX : oneTouchData.previousPageY,
|
||||
if (null !== oneTouchData) oneTouchData.touchActive && oneTouchData.currentTimeStamp > touchesChangedAfter && (total += ofCurrent && isXAxis ? oneTouchData.currentPageX : ofCurrent && !isXAxis ? oneTouchData.currentPageY : !ofCurrent && isXAxis ? oneTouchData.previousPageX : oneTouchData.previousPageY,
|
||||
count = 1); else for (var i = 0; i < touchBank.length; i++) {
|
||||
var touchTrack = touchBank[i];
|
||||
if (null !== touchTrack && void 0 !== touchTrack && touchTrack.touchActive && touchTrack.currentTimeStamp >= touchesChangedAfter) {
|
||||
var toAdd;
|
||||
toAdd = ofCurrent && isXAxis ? touchTrack.currentPageX : ofCurrent && !isXAxis ? touchTrack.currentPageY : !ofCurrent && isXAxis ? touchTrack.previousPageX : touchTrack.previousPageY,
|
||||
toAdd = ofCurrent && isXAxis ? touchTrack.currentPageX : ofCurrent && !isXAxis ? touchTrack.currentPageY : !ofCurrent && isXAxis ? touchTrack.previousPageX : touchTrack.previousPageY,
|
||||
total += toAdd, count++;
|
||||
}
|
||||
}
|
||||
@ -2161,13 +2161,13 @@ function getComponentKey(component, index) {
|
||||
|
||||
function traverseStackChildrenImpl(children, nameSoFar, callback, traverseContext) {
|
||||
var type = typeof children;
|
||||
if ("undefined" !== type && "boolean" !== type || (children = null), null === children || "string" === type || "number" === type || "object" === type && children.$$typeof === ReactElementSymbol) return callback(traverseContext, children, "" === nameSoFar ? SEPARATOR + getComponentKey(children, 0) : nameSoFar),
|
||||
if ("undefined" !== type && "boolean" !== type || (children = null), null === children || "string" === type || "number" === type || "object" === type && children.$$typeof === ReactElementSymbol) return callback(traverseContext, children, "" === nameSoFar ? SEPARATOR + getComponentKey(children, 0) : nameSoFar),
|
||||
1;
|
||||
var child, nextName, subtreeCount = 0, nextNamePrefix = "" === nameSoFar ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
||||
if (Array.isArray(children)) for (var i = 0; i < children.length; i++) child = children[i],
|
||||
if (Array.isArray(children)) for (var i = 0; i < children.length; i++) child = children[i],
|
||||
nextName = nextNamePrefix + getComponentKey(child, i), subtreeCount += traverseStackChildrenImpl(child, nextName, callback, traverseContext); else {
|
||||
var iteratorFn = getIteratorFn_1(children);
|
||||
if (iteratorFn) for (var step, iterator = iteratorFn.call(children), ii = 0; !(step = iterator.next()).done; ) child = step.value,
|
||||
if (iteratorFn) for (var step, iterator = iteratorFn.call(children), ii = 0; !(step = iterator.next()).done; ) child = step.value,
|
||||
nextName = nextNamePrefix + getComponentKey(child, ii++), subtreeCount += traverseStackChildrenImpl(child, nextName, callback, traverseContext); else if ("object" === type) {
|
||||
var addendum = "", childrenString = "" + children;
|
||||
invariant(!1, "Objects are not valid as a React child (found: %s).%s", "[object Object]" === childrenString ? "object with keys {" + Object.keys(children).join(", ") + "}" : childrenString, addendum);
|
||||
@ -2193,7 +2193,7 @@ var ReactChildReconciler = {
|
||||
instantiateChildren: function(nestedChildNodes, transaction, context, selfDebugID) {
|
||||
if (null == nestedChildNodes) return null;
|
||||
var childInstances = {};
|
||||
return traverseStackChildren_1(nestedChildNodes, instantiateChild, childInstances),
|
||||
return traverseStackChildren_1(nestedChildNodes, instantiateChild, childInstances),
|
||||
childInstances;
|
||||
},
|
||||
updateChildren: function(prevChildren, nextChildren, mountImages, removedNodes, transaction, hostParent, hostContainerInfo, context, selfDebugID) {
|
||||
@ -2202,18 +2202,18 @@ var ReactChildReconciler = {
|
||||
for (name in nextChildren) if (nextChildren.hasOwnProperty(name)) {
|
||||
prevChild = prevChildren && prevChildren[name];
|
||||
var prevElement = prevChild && prevChild._currentElement, nextElement = nextChildren[name];
|
||||
if (null != prevChild && shouldUpdateReactComponent_1(prevElement, nextElement)) ReactReconciler_1.receiveComponent(prevChild, nextElement, transaction, context),
|
||||
if (null != prevChild && shouldUpdateReactComponent_1(prevElement, nextElement)) ReactReconciler_1.receiveComponent(prevChild, nextElement, transaction, context),
|
||||
nextChildren[name] = prevChild; else {
|
||||
!ReactFeatureFlags_1.prepareNewChildrenBeforeUnmountInStack && prevChild && (removedNodes[name] = ReactReconciler_1.getHostNode(prevChild),
|
||||
!ReactFeatureFlags_1.prepareNewChildrenBeforeUnmountInStack && prevChild && (removedNodes[name] = ReactReconciler_1.getHostNode(prevChild),
|
||||
ReactReconciler_1.unmountComponent(prevChild, !1, !1));
|
||||
var nextChildInstance = instantiateReactComponent_1(nextElement, !0);
|
||||
nextChildren[name] = nextChildInstance;
|
||||
var nextChildMountImage = ReactReconciler_1.mountComponent(nextChildInstance, transaction, hostParent, hostContainerInfo, context, selfDebugID);
|
||||
mountImages.push(nextChildMountImage), ReactFeatureFlags_1.prepareNewChildrenBeforeUnmountInStack && prevChild && (removedNodes[name] = ReactReconciler_1.getHostNode(prevChild),
|
||||
mountImages.push(nextChildMountImage), ReactFeatureFlags_1.prepareNewChildrenBeforeUnmountInStack && prevChild && (removedNodes[name] = ReactReconciler_1.getHostNode(prevChild),
|
||||
ReactReconciler_1.unmountComponent(prevChild, !1, !1));
|
||||
}
|
||||
}
|
||||
for (name in prevChildren) !prevChildren.hasOwnProperty(name) || nextChildren && nextChildren.hasOwnProperty(name) || (prevChild = prevChildren[name],
|
||||
for (name in prevChildren) !prevChildren.hasOwnProperty(name) || nextChildren && nextChildren.hasOwnProperty(name) || (prevChild = prevChildren[name],
|
||||
removedNodes[name] = ReactReconciler_1.getHostNode(prevChild), ReactReconciler_1.unmountComponent(prevChild, !1, !1));
|
||||
}
|
||||
},
|
||||
@ -2237,7 +2237,7 @@ function flattenSingleChildIntoContext(traverseContext, child, name, selfDebugID
|
||||
function flattenStackChildren(children, selfDebugID) {
|
||||
if (null == children) return children;
|
||||
var result = {};
|
||||
return traverseStackChildren_1(children, flattenSingleChildIntoContext, result),
|
||||
return traverseStackChildren_1(children, flattenSingleChildIntoContext, result),
|
||||
result;
|
||||
}
|
||||
|
||||
@ -2312,8 +2312,8 @@ var ReactMultiChild = {
|
||||
},
|
||||
_reconcilerUpdateChildren: function(prevChildren, nextNestedChildrenElements, mountImages, removedNodes, transaction, context) {
|
||||
var nextChildren, selfDebugID = 0;
|
||||
return nextChildren = flattenStackChildren_1(nextNestedChildrenElements, selfDebugID),
|
||||
ReactChildReconciler_1.updateChildren(prevChildren, nextChildren, mountImages, removedNodes, transaction, this, this._hostContainerInfo, context, selfDebugID),
|
||||
return nextChildren = flattenStackChildren_1(nextNestedChildrenElements, selfDebugID),
|
||||
ReactChildReconciler_1.updateChildren(prevChildren, nextChildren, mountImages, removedNodes, transaction, this, this._hostContainerInfo, context, selfDebugID),
|
||||
nextChildren;
|
||||
},
|
||||
mountChildren: function(nestedChildren, transaction, context) {
|
||||
@ -2347,9 +2347,9 @@ var ReactMultiChild = {
|
||||
var name, updates = null, nextIndex = 0, lastIndex = 0, nextMountIndex = 0, lastPlacedNode = null;
|
||||
for (name in nextChildren) if (nextChildren.hasOwnProperty(name)) {
|
||||
var prevChild = prevChildren && prevChildren[name], nextChild = nextChildren[name];
|
||||
prevChild === nextChild ? (updates = enqueue(updates, this.moveChild(prevChild, lastPlacedNode, nextIndex, lastIndex)),
|
||||
lastIndex = Math.max(prevChild._mountIndex, lastIndex), prevChild._mountIndex = nextIndex) : (prevChild && (lastIndex = Math.max(prevChild._mountIndex, lastIndex)),
|
||||
updates = enqueue(updates, this._mountChildAtIndex(nextChild, mountImages[nextMountIndex], lastPlacedNode, nextIndex, transaction, context)),
|
||||
prevChild === nextChild ? (updates = enqueue(updates, this.moveChild(prevChild, lastPlacedNode, nextIndex, lastIndex)),
|
||||
lastIndex = Math.max(prevChild._mountIndex, lastIndex), prevChild._mountIndex = nextIndex) : (prevChild && (lastIndex = Math.max(prevChild._mountIndex, lastIndex)),
|
||||
updates = enqueue(updates, this._mountChildAtIndex(nextChild, mountImages[nextMountIndex], lastPlacedNode, nextIndex, transaction, context)),
|
||||
nextMountIndex++), nextIndex++, lastPlacedNode = ReactReconciler_1.getHostNode(nextChild);
|
||||
}
|
||||
for (name in removedNodes) removedNodes.hasOwnProperty(name) && (updates = enqueue(updates, this._unmountChild(prevChildren[name], removedNodes[name])));
|
||||
@ -2358,7 +2358,7 @@ var ReactMultiChild = {
|
||||
},
|
||||
unmountChildren: function(safely, skipLifecycle) {
|
||||
var renderedChildren = this._renderedChildren;
|
||||
ReactChildReconciler_1.unmountChildren(renderedChildren, safely, skipLifecycle),
|
||||
ReactChildReconciler_1.unmountChildren(renderedChildren, safely, skipLifecycle),
|
||||
this._renderedChildren = null;
|
||||
},
|
||||
moveChild: function(child, afterNode, toIndex, lastIndex) {
|
||||
@ -2386,7 +2386,7 @@ ReactNativeBaseComponent.Mixin = {
|
||||
return this;
|
||||
},
|
||||
unmountComponent: function(safely, skipLifecycle) {
|
||||
ReactNativeComponentTree_1.uncacheNode(this), this.unmountChildren(safely, skipLifecycle),
|
||||
ReactNativeComponentTree_1.uncacheNode(this), this.unmountChildren(safely, skipLifecycle),
|
||||
this._rootNodeID = 0;
|
||||
},
|
||||
initializeChildren: function(children, containerTag, transaction, context) {
|
||||
@ -2403,9 +2403,12 @@ ReactNativeBaseComponent.Mixin = {
|
||||
var prevElement = this._currentElement;
|
||||
this._currentElement = nextElement;
|
||||
var updatePayload = ReactNativeAttributePayload_1.diff(prevElement.props, nextElement.props, this.viewConfig.validAttributes);
|
||||
updatePayload && UIManager.updateView(this._rootNodeID, this.viewConfig.uiViewClassName, updatePayload),
|
||||
updatePayload && UIManager.updateView(this._rootNodeID, this.viewConfig.uiViewClassName, updatePayload),
|
||||
this.updateChildren(nextElement.props.children, transaction, context);
|
||||
},
|
||||
getName: function() {
|
||||
return this.constructor.displayName || this.constructor.name || "Unknown";
|
||||
},
|
||||
getHostNode: function() {
|
||||
return this._rootNodeID;
|
||||
},
|
||||
@ -2413,24 +2416,24 @@ ReactNativeBaseComponent.Mixin = {
|
||||
var tag = ReactNativeTagHandles_1.allocateTag();
|
||||
this._rootNodeID = tag, this._hostParent = hostParent, this._hostContainerInfo = hostContainerInfo;
|
||||
var updatePayload = ReactNativeAttributePayload_1.create(this._currentElement.props, this.viewConfig.validAttributes), nativeTopRootTag = hostContainerInfo._tag;
|
||||
return UIManager.createView(tag, this.viewConfig.uiViewClassName, nativeTopRootTag, updatePayload),
|
||||
ReactNativeComponentTree_1.precacheNode(this, tag), this.initializeChildren(this._currentElement.props.children, tag, transaction, context),
|
||||
return UIManager.createView(tag, this.viewConfig.uiViewClassName, nativeTopRootTag, updatePayload),
|
||||
ReactNativeComponentTree_1.precacheNode(this, tag), this.initializeChildren(this._currentElement.props.children, tag, transaction, context),
|
||||
tag;
|
||||
}
|
||||
}, Object.assign(ReactNativeBaseComponent.prototype, ReactMultiChild_1, ReactNativeBaseComponent.Mixin, NativeMethodsMixin_1);
|
||||
|
||||
var ReactNativeBaseComponent_1 = ReactNativeBaseComponent, createReactNativeComponentClassStack = function(viewConfig) {
|
||||
var Constructor = function(element) {
|
||||
this._currentElement = element, this._topLevelWrapper = null, this._hostParent = null,
|
||||
this._currentElement = element, this._topLevelWrapper = null, this._hostParent = null,
|
||||
this._hostContainerInfo = null, this._rootNodeID = 0, this._renderedChildren = null;
|
||||
};
|
||||
return Constructor.displayName = viewConfig.uiViewClassName, Constructor.viewConfig = viewConfig,
|
||||
Constructor.propTypes = viewConfig.propTypes, Constructor.prototype = new ReactNativeBaseComponent_1(viewConfig),
|
||||
return Constructor.displayName = viewConfig.uiViewClassName, Constructor.viewConfig = viewConfig,
|
||||
Constructor.propTypes = viewConfig.propTypes, Constructor.prototype = new ReactNativeBaseComponent_1(viewConfig),
|
||||
Constructor.prototype.constructor = Constructor, Constructor;
|
||||
}, createReactNativeComponentClassStack_1 = createReactNativeComponentClassStack, createReactNativeComponentClass = ReactNativeFeatureFlags$1.useFiber ? DevOnlyStubShim : createReactNativeComponentClassStack_1, findNumericNodeHandle$1 = ReactNativeFeatureFlags$1.useFiber ? DevOnlyStubShim : findNumericNodeHandleStack;
|
||||
|
||||
function takeSnapshot(view, options) {
|
||||
return "number" != typeof view && "window" !== view && (view = findNumericNodeHandle$1(view) || "window"),
|
||||
return "number" != typeof view && "window" !== view && (view = findNumericNodeHandle$1(view) || "window"),
|
||||
UIManager.__takeSnapshot(view, options);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user