UNPKG

react-native

Version:

A framework for building native apps using React

1,468 lines (1,467 loc) • 202 kB
/** * Copyright (c) 2013-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @noflow * @providesModule ReactNativeRenderer-prod * @preventMunge */ "use strict"; require("InitializeCore"); var invariant = require("fbjs/lib/invariant"), emptyFunction = require("fbjs/lib/emptyFunction"), RCTEventEmitter = require("RCTEventEmitter"), UIManager = require("UIManager"), React = require("react"), ExceptionsManager = require("ExceptionsManager"), TextInputState = require("TextInputState"), deepDiffer = require("deepDiffer"), flattenStyle = require("flattenStyle"), emptyObject = require("fbjs/lib/emptyObject"), shallowEqual = require("fbjs/lib/shallowEqual"), ReactErrorUtils = { _caughtError: null, _hasCaughtError: !1, _rethrowError: null, _hasRethrowError: !1, injection: { injectErrorUtils: function(injectedErrorUtils) { invariant( "function" === typeof injectedErrorUtils.invokeGuardedCallback, "Injected invokeGuardedCallback() must be a function." ); invokeGuardedCallback = injectedErrorUtils.invokeGuardedCallback; } }, invokeGuardedCallback: function(name, func, context, a, b, c, d, e, f) { invokeGuardedCallback.apply(ReactErrorUtils, arguments); }, invokeGuardedCallbackAndCatchFirstError: function( name, func, context, a, b, c, d, e, f ) { ReactErrorUtils.invokeGuardedCallback.apply(this, arguments); if (ReactErrorUtils.hasCaughtError()) { var error = ReactErrorUtils.clearCaughtError(); ReactErrorUtils._hasRethrowError || ((ReactErrorUtils._hasRethrowError = !0), (ReactErrorUtils._rethrowError = error)); } }, rethrowCaughtError: function() { return rethrowCaughtError.apply(ReactErrorUtils, arguments); }, hasCaughtError: function() { return ReactErrorUtils._hasCaughtError; }, clearCaughtError: function() { if (ReactErrorUtils._hasCaughtError) { var error = ReactErrorUtils._caughtError; ReactErrorUtils._caughtError = null; ReactErrorUtils._hasCaughtError = !1; return error; } invariant( !1, "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." ); } }; function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { ReactErrorUtils._hasCaughtError = !1; ReactErrorUtils._caughtError = null; var funcArgs = Array.prototype.slice.call(arguments, 3); try { func.apply(context, funcArgs); } catch (error) { (ReactErrorUtils._caughtError = error), (ReactErrorUtils._hasCaughtError = !0); } } function rethrowCaughtError() { if (ReactErrorUtils._hasRethrowError) { var error = ReactErrorUtils._rethrowError; ReactErrorUtils._rethrowError = null; ReactErrorUtils._hasRethrowError = !1; throw error; } } var eventPluginOrder = null, namesToPlugins = {}; function recomputePluginOrdering() { if (eventPluginOrder) for (var pluginName in namesToPlugins) { var pluginModule = namesToPlugins[pluginName], pluginIndex = eventPluginOrder.indexOf(pluginName); invariant( -1 < pluginIndex, "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.", pluginName ); if (!plugins[pluginIndex]) { invariant( pluginModule.extractEvents, "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.", pluginName ); plugins[pluginIndex] = pluginModule; pluginIndex = pluginModule.eventTypes; for (var eventName in pluginIndex) { var JSCompiler_inline_result = void 0; var dispatchConfig = pluginIndex[eventName], pluginModule$jscomp$0 = pluginModule, eventName$jscomp$0 = eventName; invariant( !eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0), "EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.", eventName$jscomp$0 ); eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; if (phasedRegistrationNames) { for (JSCompiler_inline_result in phasedRegistrationNames) phasedRegistrationNames.hasOwnProperty( JSCompiler_inline_result ) && publishRegistrationName( phasedRegistrationNames[JSCompiler_inline_result], pluginModule$jscomp$0, eventName$jscomp$0 ); JSCompiler_inline_result = !0; } else dispatchConfig.registrationName ? (publishRegistrationName( dispatchConfig.registrationName, pluginModule$jscomp$0, eventName$jscomp$0 ), (JSCompiler_inline_result = !0)) : (JSCompiler_inline_result = !1); invariant( JSCompiler_inline_result, "EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.", eventName, pluginName ); } } } } function publishRegistrationName(registrationName, pluginModule) { invariant( !registrationNameModules[registrationName], "EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.", registrationName ); registrationNameModules[registrationName] = pluginModule; } var plugins = [], eventNameDispatchConfigs = {}, registrationNameModules = {}, getFiberCurrentPropsFromNode = null, getInstanceFromNode = null, getNodeFromInstance = null; function isEndish(topLevelType) { return ( "topMouseUp" === topLevelType || "topTouchEnd" === topLevelType || "topTouchCancel" === topLevelType ); } function isMoveish(topLevelType) { return "topMouseMove" === topLevelType || "topTouchMove" === topLevelType; } function isStartish(topLevelType) { return "topMouseDown" === topLevelType || "topTouchStart" === topLevelType; } function executeDispatch(event, simulated, listener, inst) { simulated = event.type || "unknown-event"; event.currentTarget = getNodeFromInstance(inst); ReactErrorUtils.invokeGuardedCallbackAndCatchFirstError( simulated, listener, void 0, event ); event.currentTarget = null; } function executeDirectDispatch(event) { var dispatchListener = event._dispatchListeners, dispatchInstance = event._dispatchInstances; invariant( !Array.isArray(dispatchListener), "executeDirectDispatch(...): Invalid `event`." ); event.currentTarget = dispatchListener ? getNodeFromInstance(dispatchInstance) : null; dispatchListener = dispatchListener ? dispatchListener(event) : null; event.currentTarget = null; event._dispatchListeners = null; event._dispatchInstances = null; return dispatchListener; } function accumulateInto(current, next) { invariant( null != next, "accumulateInto(...): Accumulated items must not be null or undefined." ); if (null == current) return next; if (Array.isArray(current)) { if (Array.isArray(next)) return current.push.apply(current, next), current; current.push(next); return current; } return Array.isArray(next) ? [current].concat(next) : [current, next]; } function forEachAccumulated(arr, cb, scope) { Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); } var eventQueue = null; function executeDispatchesAndReleaseTopLevel(e) { if (e) { var dispatchListeners = e._dispatchListeners, dispatchInstances = e._dispatchInstances; if (Array.isArray(dispatchListeners)) for ( var i = 0; i < dispatchListeners.length && !e.isPropagationStopped(); i++ ) executeDispatch(e, !1, dispatchListeners[i], dispatchInstances[i]); else dispatchListeners && executeDispatch(e, !1, dispatchListeners, dispatchInstances); e._dispatchListeners = null; e._dispatchInstances = null; e.isPersistent() || e.constructor.release(e); } } var injection = { 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." ); eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); recomputePluginOrdering(); }, injectEventPluginsByName: function(injectedNamesToPlugins) { var isOrderingDirty = !1, pluginName; for (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[pluginName] = pluginModule), (isOrderingDirty = !0)); } isOrderingDirty && recomputePluginOrdering(); } }; function getListener(inst, registrationName) { var listener = inst.stateNode; if (!listener) return null; var props = getFiberCurrentPropsFromNode(listener); if (!props) return null; listener = props[registrationName]; a: switch (registrationName) { case "onClick": case "onClickCapture": case "onDoubleClick": case "onDoubleClickCapture": case "onMouseDown": case "onMouseDownCapture": case "onMouseMove": case "onMouseMoveCapture": case "onMouseUp": case "onMouseUpCapture": (props = !props.disabled) || ((inst = inst.type), (props = !( "button" === inst || "input" === inst || "select" === inst || "textarea" === inst ))); inst = !props; break a; default: inst = !1; } if (inst) return null; invariant( !listener || "function" === typeof listener, "Expected `%s` listener to be a function, instead got a value of `%s` type.", registrationName, typeof listener ); return listener; } function getParent(inst) { do inst = inst["return"]; while (inst && 5 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); } function accumulateDirectionalDispatches(inst, phase, event) { if ( (phase = getListener( inst, event.dispatchConfig.phasedRegistrationNames[phase] )) ) (event._dispatchListeners = accumulateInto( event._dispatchListeners, phase )), (event._dispatchInstances = accumulateInto( event._dispatchInstances, inst )); } function accumulateTwoPhaseDispatchesSingle(event) { event && event.dispatchConfig.phasedRegistrationNames && traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); } function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { if (event && event.dispatchConfig.phasedRegistrationNames) { var targetInst = event._targetInst; targetInst = targetInst ? getParent(targetInst) : null; traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); } } function accumulateDirectDispatchesSingle(event) { if (event && event.dispatchConfig.registrationName) { var inst = event._targetInst; if (inst && event && event.dispatchConfig.registrationName) { var listener = getListener(inst, event.dispatchConfig.registrationName); listener && ((event._dispatchListeners = accumulateInto( event._dispatchListeners, listener )), (event._dispatchInstances = accumulateInto( event._dispatchInstances, inst ))); } } } var shouldBeReleasedProperties = "dispatchConfig _targetInst nativeEvent isDefaultPrevented isPropagationStopped _dispatchListeners _dispatchInstances".split( " " ), EventInterface = { type: null, target: null, currentTarget: emptyFunction.thatReturnsNull, eventPhase: null, bubbles: null, cancelable: null, timeStamp: function(event) { return event.timeStamp || Date.now(); }, defaultPrevented: null, isTrusted: null }; function SyntheticEvent( dispatchConfig, targetInst, nativeEvent, nativeEventTarget ) { this.dispatchConfig = dispatchConfig; this._targetInst = targetInst; this.nativeEvent = nativeEvent; dispatchConfig = this.constructor.Interface; for (var propName in dispatchConfig) dispatchConfig.hasOwnProperty(propName) && ((targetInst = dispatchConfig[propName]) ? (this[propName] = targetInst(nativeEvent)) : "target" === propName ? (this.target = nativeEventTarget) : (this[propName] = nativeEvent[propName])); this.isDefaultPrevented = (null != nativeEvent.defaultPrevented ? nativeEvent.defaultPrevented : !1 === nativeEvent.returnValue) ? emptyFunction.thatReturnsTrue : emptyFunction.thatReturnsFalse; this.isPropagationStopped = emptyFunction.thatReturnsFalse; return this; } 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), (this.isDefaultPrevented = emptyFunction.thatReturnsTrue)); }, stopPropagation: function() { var event = this.nativeEvent; event && (event.stopPropagation ? event.stopPropagation() : "unknown" !== typeof event.cancelBubble && (event.cancelBubble = !0), (this.isPropagationStopped = emptyFunction.thatReturnsTrue)); }, persist: function() { this.isPersistent = emptyFunction.thatReturnsTrue; }, isPersistent: emptyFunction.thatReturnsFalse, destructor: function() { var Interface = this.constructor.Interface, propName; for (propName in Interface) this[propName] = null; for ( Interface = 0; Interface < shouldBeReleasedProperties.length; Interface++ ) this[shouldBeReleasedProperties[Interface]] = null; } }); SyntheticEvent.Interface = EventInterface; SyntheticEvent.augmentClass = function(Class, Interface) { function E() {} E.prototype = this.prototype; var prototype = new E(); Object.assign(prototype, Class.prototype); Class.prototype = prototype; Class.prototype.constructor = Class; Class.Interface = Object.assign({}, this.Interface, Interface); Class.augmentClass = this.augmentClass; addEventPoolingTo(Class); }; addEventPoolingTo(SyntheticEvent); function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { if (this.eventPool.length) { var instance = this.eventPool.pop(); this.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst); return instance; } return new this(dispatchConfig, targetInst, nativeEvent, nativeInst); } function releasePooledEvent(event) { invariant( event instanceof this, "Trying to release an event instance into a pool of a different type." ); event.destructor(); 10 > this.eventPool.length && this.eventPool.push(event); } function addEventPoolingTo(EventConstructor) { EventConstructor.eventPool = []; EventConstructor.getPooled = getPooledEvent; EventConstructor.release = releasePooledEvent; } function ResponderSyntheticEvent( dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget ) { return SyntheticEvent.call( this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget ); } SyntheticEvent.augmentClass(ResponderSyntheticEvent, { touchHistory: function() { return null; } }); var touchBank = [], touchHistory = { touchBank: touchBank, numberActiveTouches: 0, indexOfSingleActiveTouch: -1, mostRecentTimeStamp: 0 }; function timestampForTouch(touch) { return touch.timeStamp || touch.timestamp; } function getTouchIdentifier(_ref) { _ref = _ref.identifier; invariant(null != _ref, "Touch object is missing identifier."); return _ref; } function recordTouchStart(touch) { var identifier = getTouchIdentifier(touch), touchRecord = touchBank[identifier]; touchRecord ? ((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))) : ((touchRecord = { touchActive: !0, startPageX: touch.pageX, startPageY: touch.pageY, startTimeStamp: timestampForTouch(touch), currentPageX: touch.pageX, currentPageY: touch.pageY, currentTimeStamp: timestampForTouch(touch), previousPageX: touch.pageX, previousPageY: touch.pageY, previousTimeStamp: timestampForTouch(touch) }), (touchBank[identifier] = touchRecord)); 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.currentTimeStamp = timestampForTouch(touch)), (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) : console.error( "Cannot record touch move without a touch start.\nTouch 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.currentTimeStamp = timestampForTouch(touch)), (touchHistory.mostRecentTimeStamp = timestampForTouch(touch))) : console.error( "Cannot record touch end without a touch start.\nTouch End: %s\n", "Touch Bank: %s", printTouch(touch), printTouchBank() ); } function printTouch(touch) { return JSON.stringify({ identifier: touch.identifier, pageX: touch.pageX, pageY: touch.pageY, timestamp: timestampForTouch(touch) }); } function printTouchBank() { var printed = JSON.stringify(touchBank.slice(0, 20)); 20 < touchBank.length && (printed += " (original size: " + touchBank.length + ")"); return printed; } var ResponderTouchHistoryStore = { recordTouchTrack: function(topLevelType, nativeEvent) { if (isMoveish(topLevelType)) nativeEvent.changedTouches.forEach(recordTouchMove); else if (isStartish(topLevelType)) nativeEvent.changedTouches.forEach(recordTouchStart), (touchHistory.numberActiveTouches = nativeEvent.touches.length), 1 === touchHistory.numberActiveTouches && (touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier); else if ( isEndish(topLevelType) && (nativeEvent.changedTouches.forEach(recordTouchEnd), (touchHistory.numberActiveTouches = nativeEvent.touches.length), 1 === touchHistory.numberActiveTouches) ) for (topLevelType = 0; topLevelType < touchBank.length; topLevelType++) if ( ((nativeEvent = touchBank[topLevelType]), null != nativeEvent && nativeEvent.touchActive) ) { touchHistory.indexOfSingleActiveTouch = topLevelType; break; } }, touchHistory: touchHistory }; function accumulate(current, next) { invariant( null != next, "accumulate(...): Accumulated items must be not be null or undefined." ); return null == current ? next : Array.isArray(current) ? current.concat(next) : Array.isArray(next) ? [current].concat(next) : [current, next]; } var responderInst = null, trackedTouchCount = 0, previousActiveTouches = 0; function changeResponder(nextResponderInst, blockHostResponder) { var oldResponderInst = responderInst; responderInst = nextResponderInst; if (null !== ResponderEventPlugin.GlobalResponderHandler) ResponderEventPlugin.GlobalResponderHandler.onChange( oldResponderInst, nextResponderInst, blockHostResponder ); } var eventTypes = { startShouldSetResponder: { phasedRegistrationNames: { bubbled: "onStartShouldSetResponder", captured: "onStartShouldSetResponderCapture" } }, scrollShouldSetResponder: { phasedRegistrationNames: { bubbled: "onScrollShouldSetResponder", captured: "onScrollShouldSetResponderCapture" } }, selectionChangeShouldSetResponder: { phasedRegistrationNames: { bubbled: "onSelectionChangeShouldSetResponder", captured: "onSelectionChangeShouldSetResponderCapture" } }, moveShouldSetResponder: { phasedRegistrationNames: { bubbled: "onMoveShouldSetResponder", captured: "onMoveShouldSetResponderCapture" } }, responderStart: { registrationName: "onResponderStart" }, responderMove: { registrationName: "onResponderMove" }, responderEnd: { registrationName: "onResponderEnd" }, responderRelease: { registrationName: "onResponderRelease" }, responderTerminationRequest: { registrationName: "onResponderTerminationRequest" }, responderGrant: { registrationName: "onResponderGrant" }, responderReject: { registrationName: "onResponderReject" }, responderTerminate: { registrationName: "onResponderTerminate" } }, ResponderEventPlugin = { _getResponder: function() { return responderInst; }, eventTypes: eventTypes, extractEvents: function( topLevelType, targetInst, nativeEvent, nativeEventTarget ) { if (isStartish(topLevelType)) trackedTouchCount += 1; else if (isEndish(topLevelType)) if (0 <= trackedTouchCount) --trackedTouchCount; else return ( console.error( "Ended a touch event which was not counted in `trackedTouchCount`." ), null ); ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent); if ( targetInst && (("topScroll" === topLevelType && !nativeEvent.responderIgnoreScroll) || (0 < trackedTouchCount && "topSelectionChange" === topLevelType) || isStartish(topLevelType) || isMoveish(topLevelType)) ) { var shouldSetEventType = isStartish(topLevelType) ? eventTypes.startShouldSetResponder : isMoveish(topLevelType) ? eventTypes.moveShouldSetResponder : "topSelectionChange" === topLevelType ? eventTypes.selectionChangeShouldSetResponder : eventTypes.scrollShouldSetResponder; if (responderInst) b: { var JSCompiler_temp = responderInst; for ( var depthA = 0, tempA = JSCompiler_temp; tempA; tempA = getParent(tempA) ) depthA++; tempA = 0; for (var tempB = targetInst; tempB; tempB = getParent(tempB)) tempA++; for (; 0 < depthA - tempA; ) (JSCompiler_temp = getParent(JSCompiler_temp)), depthA--; for (; 0 < tempA - depthA; ) (targetInst = getParent(targetInst)), tempA--; for (; depthA--; ) { if ( JSCompiler_temp === targetInst || JSCompiler_temp === targetInst.alternate ) break b; JSCompiler_temp = getParent(JSCompiler_temp); targetInst = getParent(targetInst); } JSCompiler_temp = null; } else JSCompiler_temp = targetInst; targetInst = JSCompiler_temp === responderInst; JSCompiler_temp = ResponderSyntheticEvent.getPooled( shouldSetEventType, JSCompiler_temp, nativeEvent, nativeEventTarget ); JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory; targetInst ? forEachAccumulated( JSCompiler_temp, accumulateTwoPhaseDispatchesSingleSkipTarget ) : forEachAccumulated( JSCompiler_temp, accumulateTwoPhaseDispatchesSingle ); b: { shouldSetEventType = JSCompiler_temp._dispatchListeners; targetInst = JSCompiler_temp._dispatchInstances; if (Array.isArray(shouldSetEventType)) for ( depthA = 0; depthA < shouldSetEventType.length && !JSCompiler_temp.isPropagationStopped(); depthA++ ) { if ( shouldSetEventType[depthA](JSCompiler_temp, targetInst[depthA]) ) { shouldSetEventType = targetInst[depthA]; break b; } } else if ( shouldSetEventType && shouldSetEventType(JSCompiler_temp, targetInst) ) { shouldSetEventType = targetInst; break b; } shouldSetEventType = null; } JSCompiler_temp._dispatchInstances = null; JSCompiler_temp._dispatchListeners = null; JSCompiler_temp.isPersistent() || JSCompiler_temp.constructor.release(JSCompiler_temp); if (shouldSetEventType && shouldSetEventType !== responderInst) if ( ((JSCompiler_temp = ResponderSyntheticEvent.getPooled( eventTypes.responderGrant, shouldSetEventType, nativeEvent, nativeEventTarget )), (JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory), forEachAccumulated( JSCompiler_temp, accumulateDirectDispatchesSingle ), (targetInst = !0 === executeDirectDispatch(JSCompiler_temp)), responderInst) ) if ( ((depthA = ResponderSyntheticEvent.getPooled( eventTypes.responderTerminationRequest, responderInst, nativeEvent, nativeEventTarget )), (depthA.touchHistory = ResponderTouchHistoryStore.touchHistory), forEachAccumulated(depthA, accumulateDirectDispatchesSingle), (tempA = !depthA._dispatchListeners || executeDirectDispatch(depthA)), depthA.isPersistent() || depthA.constructor.release(depthA), tempA) ) { depthA = ResponderSyntheticEvent.getPooled( eventTypes.responderTerminate, responderInst, nativeEvent, nativeEventTarget ); depthA.touchHistory = ResponderTouchHistoryStore.touchHistory; forEachAccumulated(depthA, accumulateDirectDispatchesSingle); var JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, [JSCompiler_temp, depthA] ); changeResponder(shouldSetEventType, targetInst); } else (shouldSetEventType = ResponderSyntheticEvent.getPooled( eventTypes.responderReject, shouldSetEventType, nativeEvent, nativeEventTarget )), (shouldSetEventType.touchHistory = ResponderTouchHistoryStore.touchHistory), forEachAccumulated( shouldSetEventType, accumulateDirectDispatchesSingle ), (JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, shouldSetEventType )); else (JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, JSCompiler_temp )), changeResponder(shouldSetEventType, targetInst); else JSCompiler_temp$jscomp$0 = null; } else JSCompiler_temp$jscomp$0 = null; shouldSetEventType = responderInst && isStartish(topLevelType); JSCompiler_temp = responderInst && isMoveish(topLevelType); targetInst = responderInst && isEndish(topLevelType); if ( (shouldSetEventType = shouldSetEventType ? eventTypes.responderStart : JSCompiler_temp ? eventTypes.responderMove : targetInst ? eventTypes.responderEnd : null) ) (shouldSetEventType = ResponderSyntheticEvent.getPooled( shouldSetEventType, responderInst, nativeEvent, nativeEventTarget )), (shouldSetEventType.touchHistory = ResponderTouchHistoryStore.touchHistory), forEachAccumulated( shouldSetEventType, accumulateDirectDispatchesSingle ), (JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, shouldSetEventType )); shouldSetEventType = responderInst && "topTouchCancel" === topLevelType; if ( (topLevelType = responderInst && !shouldSetEventType && isEndish(topLevelType)) ) a: { if ((topLevelType = nativeEvent.touches) && 0 !== topLevelType.length) for ( JSCompiler_temp = 0; JSCompiler_temp < topLevelType.length; JSCompiler_temp++ ) if ( ((targetInst = topLevelType[JSCompiler_temp].target), null !== targetInst && void 0 !== targetInst && 0 !== targetInst) ) { depthA = getInstanceFromNode(targetInst); b: { for (targetInst = responderInst; depthA; ) { if ( targetInst === depthA || targetInst === depthA.alternate ) { targetInst = !0; break b; } depthA = getParent(depthA); } targetInst = !1; } if (targetInst) { topLevelType = !1; break a; } } topLevelType = !0; } if ( (topLevelType = shouldSetEventType ? eventTypes.responderTerminate : topLevelType ? eventTypes.responderRelease : null) ) (nativeEvent = ResponderSyntheticEvent.getPooled( topLevelType, responderInst, nativeEvent, nativeEventTarget )), (nativeEvent.touchHistory = ResponderTouchHistoryStore.touchHistory), forEachAccumulated(nativeEvent, accumulateDirectDispatchesSingle), (JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, nativeEvent )), changeResponder(null); nativeEvent = ResponderTouchHistoryStore.touchHistory.numberActiveTouches; if ( ResponderEventPlugin.GlobalInteractionHandler && nativeEvent !== previousActiveTouches ) ResponderEventPlugin.GlobalInteractionHandler.onChange(nativeEvent); previousActiveTouches = nativeEvent; return JSCompiler_temp$jscomp$0; }, GlobalResponderHandler: null, GlobalInteractionHandler: null, injection: { injectGlobalResponderHandler: function(GlobalResponderHandler) { ResponderEventPlugin.GlobalResponderHandler = GlobalResponderHandler; }, injectGlobalInteractionHandler: function(GlobalInteractionHandler) { ResponderEventPlugin.GlobalInteractionHandler = GlobalInteractionHandler; } } }, customBubblingEventTypes = {}, customDirectEventTypes = {}, ReactNativeBridgeEventPlugin = { eventTypes: {}, extractEvents: function( topLevelType, targetInst, nativeEvent, nativeEventTarget ) { var bubbleDispatchConfig = customBubblingEventTypes[topLevelType], directDispatchConfig = customDirectEventTypes[topLevelType]; invariant( bubbleDispatchConfig || directDispatchConfig, 'Unsupported top level event type "%s" dispatched', topLevelType ); topLevelType = SyntheticEvent.getPooled( bubbleDispatchConfig || directDispatchConfig, targetInst, nativeEvent, nativeEventTarget ); if (bubbleDispatchConfig) forEachAccumulated(topLevelType, accumulateTwoPhaseDispatchesSingle); else if (directDispatchConfig) forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle); else return null; return topLevelType; }, processEventTypes: function(viewConfig) { var bubblingEventTypes = viewConfig.bubblingEventTypes; viewConfig = viewConfig.directEventTypes; if (null != bubblingEventTypes) for (var _topLevelType in bubblingEventTypes) null == customBubblingEventTypes[_topLevelType] && (ReactNativeBridgeEventPlugin.eventTypes[ _topLevelType ] = customBubblingEventTypes[_topLevelType] = bubblingEventTypes[_topLevelType]); if (null != viewConfig) for (var _topLevelType2 in viewConfig) null == customDirectEventTypes[_topLevelType2] && (ReactNativeBridgeEventPlugin.eventTypes[ _topLevelType2 ] = customDirectEventTypes[_topLevelType2] = viewConfig[_topLevelType2]); } }, instanceCache = {}, instanceProps = {}; function uncacheFiberNode(tag) { delete instanceCache[tag]; delete instanceProps[tag]; } function getInstanceFromTag(tag) { return instanceCache[tag] || null; } var ReactNativeComponentTree = Object.freeze({ precacheFiberNode: function(hostInst, tag) { instanceCache[tag] = hostInst; }, uncacheFiberNode: uncacheFiberNode, getClosestInstanceFromNode: getInstanceFromTag, getInstanceFromNode: getInstanceFromTag, getNodeFromInstance: function(inst) { inst = inst.stateNode._nativeTag; invariant(inst, "All native instances should have a tag."); return inst; }, getFiberCurrentPropsFromNode: function(stateNode) { return instanceProps[stateNode._nativeTag] || null; }, updateFiberProps: function(tag, props) { instanceProps[tag] = props; } }), restoreTarget = null, restoreQueue = null; function restoreStateOfTarget(target) { if ((target = getInstanceFromNode(target))) { invariant( null, "Fiber needs to be injected to handle a fiber target for controlled events. This error is likely caused by a bug in React. Please file an issue." ); var props = getFiberCurrentPropsFromNode(target.stateNode); null.restoreControlledState(target.stateNode, target.type, props); } } function fiberBatchedUpdates(fn, bookkeeping) { return fn(bookkeeping); } var isNestingBatched = !1; function batchedUpdates(fn, bookkeeping) { if (isNestingBatched) return fiberBatchedUpdates(fn, bookkeeping); isNestingBatched = !0; try { return fiberBatchedUpdates(fn, bookkeeping); } finally { if ( ((isNestingBatched = !1), restoreTarget && ((bookkeeping = restoreTarget), (fn = restoreQueue), (restoreQueue = restoreTarget = null), restoreStateOfTarget(bookkeeping), fn)) ) for (bookkeeping = 0; bookkeeping < fn.length; bookkeeping++) restoreStateOfTarget(fn[bookkeeping]); } } function handleTopLevel( topLevelType, targetInst, nativeEvent, nativeEventTarget ) { for (var events, i = 0; i < plugins.length; i++) { var possiblePlugin = plugins[i]; possiblePlugin && (possiblePlugin = possiblePlugin.extractEvents( topLevelType, targetInst, nativeEvent, nativeEventTarget )) && (events = accumulateInto(events, possiblePlugin)); } events && (eventQueue = accumulateInto(eventQueue, events)); topLevelType = eventQueue; eventQueue = null; topLevelType && (forEachAccumulated(topLevelType, executeDispatchesAndReleaseTopLevel), invariant( !eventQueue, "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." ), ReactErrorUtils.rethrowCaughtError()); } var ReactNativeTagHandles = { tagsStartAt: 1, tagCount: 1, allocateTag: function() { for (; this.reactTagIsNativeTopRootID(ReactNativeTagHandles.tagCount); ) ReactNativeTagHandles.tagCount++; var tag = ReactNativeTagHandles.tagCount; ReactNativeTagHandles.tagCount++; return tag; }, assertRootTag: function(tag) { invariant( this.reactTagIsNativeTopRootID(tag), "Expect a native root tag, instead got %s", tag ); }, reactTagIsNativeTopRootID: function(reactTag) { return 1 === reactTag % 10; } }, EMPTY_NATIVE_EVENT = {}; function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { var nativeEvent = nativeEventParam || EMPTY_NATIVE_EVENT, inst = getInstanceFromTag(rootNodeID); batchedUpdates(function() { handleTopLevel(topLevelType, inst, nativeEvent, nativeEvent.target); }); } var ReactNativeEventEmitter = Object.freeze({ getListener: getListener, registrationNames: registrationNameModules, _receiveRootNodeIDEvent: _receiveRootNodeIDEvent, receiveEvent: function(rootNodeID, topLevelType, nativeEventParam) { _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam); }, receiveTouches: function(eventTopLevelType, touches, changedIndices) { if ( "topTouchEnd" === eventTopLevelType || "topTouchCancel" === eventTopLevelType ) { var JSCompiler_temp = []; for (var i = 0; i < changedIndices.length; i++) { var index = changedIndices[i]; JSCompiler_temp.push(touches[index]); touches[index] = null; } for (i = changedIndices = 0; i < touches.length; i++) (index = touches[i]), null !== index && (touches[changedIndices++] = index); touches.length = changedIndices; } else for (JSCompiler_temp = [], i = 0; i < changedIndices.length; i++) JSCompiler_temp.push(touches[changedIndices[i]]); for ( changedIndices = 0; changedIndices < JSCompiler_temp.length; changedIndices++ ) { i = JSCompiler_temp[changedIndices]; i.changedTouches = JSCompiler_temp; i.touches = touches; index = null; var target = i.target; null === target || void 0 === target || target < ReactNativeTagHandles.tagsStartAt || (index = target); _receiveRootNodeIDEvent(index, eventTopLevelType, i); } }, handleTopLevel: handleTopLevel }); RCTEventEmitter.register(ReactNativeEventEmitter); injection.injectEventPluginOrder([ "ResponderEventPlugin", "ReactNativeBridgeEventPlugin" ]); getFiberCurrentPropsFromNode = ReactNativeComponentTree.getFiberCurrentPropsFromNode; getInstanceFromNode = ReactNativeComponentTree.getInstanceFromNode; getNodeFromInstance = ReactNativeComponentTree.getNodeFromInstance; ResponderEventPlugin.injection.injectGlobalResponderHandler({ onChange: function(from, to, blockNativeResponder) { null !== to ? UIManager.setJSResponder(to.stateNode._nativeTag, blockNativeResponder) : UIManager.clearJSResponder(); } }); injection.injectEventPluginsByName({ ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: ReactNativeBridgeEventPlugin }); function defaultShowDialog() { return !0; } var showDialog = defaultShowDialog, hasSymbol = "function" === typeof Symbol && Symbol["for"], REACT_ELEMENT_TYPE = hasSymbol ? Symbol["for"]("react.element") : 60103, REACT_CALL_TYPE = hasSymbol ? Symbol["for"]("react.call") : 60104, REACT_RETURN_TYPE = hasSymbol ? Symbol["for"]("react.return") : 60105, REACT_PORTAL_TYPE = hasSymbol ? Symbol["for"]("react.portal") : 60106, REACT_FRAGMENT_TYPE = hasSymbol ? Symbol["for"]("react.fragment") : 60107, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "undefined" === typeof maybeIterable) return null; maybeIterable = (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) || maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } function createPortal(children, containerInfo, implementation) { var key = 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; return { $$typeof: REACT_PORTAL_TYPE, key: null == key ? null : "" + key, children: children, containerInfo: containerInfo, implementation: implementation }; } var TouchHistoryMath = { centroidDimension: function( touchHistory, touchesChangedAfter, isXAxis, ofCurrent ) { var touchBank = touchHistory.touchBank, total = 0, count = 0; touchHistory = 1 === touchHistory.numberActiveTouches ? touchHistory.touchBank[touchHistory.indexOfSingleActiveTouch] : null; if (null !== touchHistory) touchHistory.touchActive && touchHistory.currentTimeStamp > touchesChangedAfter && ((total += ofCurrent && isXAxis ? touchHistory.currentPageX : ofCurrent && !isXAxis ? touchHistory.currentPageY : !ofCurrent && isXAxis ? touchHistory.previousPageX : touchHistory.previousPageY), (count = 1)); else for ( touchHistory = 0; touchHistory < touchBank.length; touchHistory++ ) { var touchTrack = touchBank[touchHistory]; null !== touchTrack && void 0 !== touchTrack && touchTrack.touchActive && touchTrack.currentTimeStamp >= touchesChangedAfter && ((total += ofCurrent && isXAxis ? touchTrack.currentPageX : ofCurrent && !isXAxis ? touchTrack.currentPageY : !ofCurrent && isXAxis ? touchTrack.previousPageX : touchTrack.previousPageY), count++); } return 0 < count ? total / count : TouchHistoryMath.noCentroid; }, currentCentroidXOfTouchesChangedAfter: function( touchHistory, touchesChangedAfter ) { return TouchHistoryMath.centroidDimension( touchHistory, touchesChangedAfter, !0, !0 ); }, currentCentroidYOfTouchesChangedAfter: function( touchHistory, touchesChangedAfter ) { return TouchHistoryMath.centroidDimension( touchHistory, touchesChangedAfter, !1, !0 ); }, previousCentroidXOfTouchesChangedAfter: function( touchHistory, touchesChangedAfter ) { return TouchHistoryMath.centroidDimension( touchHistory, touchesChangedAfter, !0, !1 ); }, previousCentroidYOfTouchesChangedAfter: function( touchHistory, touchesChangedAfter ) { return TouchHistoryMath.centroidDimension( touchHistory, touchesChangedAfter, !1, !1 ); }, currentCentroidX: function(touchHistory) { return TouchHistoryMath.centroidDimension(touchHistory, 0, !0, !0); }, currentCentroidY: function(touchHistory) { return TouchHistoryMath.centroidDimension(touchHistory, 0, !1, !0); }, noCentroid: -1 }, ReactCurrentOwner = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, ReactGlobalSharedState = Object.freeze({ ReactCurrentOwner: ReactCurrentOwner, ReactDebugCurrentFrame: null }), objects = {}, uniqueID = 1, emptyObject$2 = {}, ReactNativePropRegistry = (function() { function ReactNativePropRegistry() { if (!(this instanceof ReactNativePropRegistry)) throw new TypeError("Cannot call a class as a function"); } ReactNativePropRegistry.register = function(object) { var id = ++uniqueID; objects[id] = object; return id; }; ReactNativePropRegistry.getByID = function(id) { if (!id) return emptyObject$2; var object = objects[id]; return object ? object : (console.warn("Invalid style with id `" + id + "`. Skipping ..."), emptyObject$2); }; return ReactNativePropRegistry; })(), emptyObject$1 = {}, removedKeys = null, removedKeyCount = 0; function resolveObject(idOrObject) { return "number" === typeof idOrObject ? ReactNativePropRegistry.getByID(idOrObject) : idOrObject; } function restoreDeletedValuesInNestedArray( updatePayload, node, validAttributes ) { if (Array.isArray(node)) for (var i = node.length; i-- && 0 < removedKeyCount; ) restoreDeletedValuesInNestedArray( updatePayload, node[i], validAttributes ); else if (node && 0 < removedKeyCount) for (i in ((node = resolveObject(node)), removedKeys)) if (removedKeys[i]) { var nextProp = node[i]; if (void 0 !== nextProp) { var attributeConfig = validAttributes[i]; if (attributeConfig) { "function" === typeof nextProp && (nextProp = !0); "undefined" === typeof nextProp && (nextProp = null); if ("object" !== typeof attributeConfig) updatePayload[i] = nextProp; else if ( "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process ) (nextProp = "function" === typeof attributeConfig.process ? attributeConfig.process(nextProp) : nextProp), (updatePayload[i] = nextProp); removedKeys[i] = !1; removedKeyCount--; } } } } function diffNestedProperty( updatePayload, prevProp, nextProp, validAttributes ) { if (!updatePayload && prevProp === nextProp) return updatePayload; if (!prevProp || !nextProp) return nextProp ? addNestedProperty(updatePayload, nextProp, validAttributes) : prevProp ? clearNestedProperty(updatePayload, prevProp, validAttributes) : updatePayload; if (!Array.isArray(prevProp) && !Array.isArray(nextProp)) return diffProperties( updatePayload, resolveObject(prevProp), resolveObject(nextProp), validAttributes ); if (Array.isArray(prevProp) && Array.isArray(nextProp)) { var minLength = prevProp.length < nextProp.length ? prevProp.length : nextProp.length, i; for (i = 0; i < minLength; i++) updatePayload = diffNestedProperty( updatePayload, prevProp[i], nextProp[i], validAttributes ); for (; i < prevProp.length; i++) updatePayload = clearNestedProperty( updatePayload, prevProp[i], validAttributes ); for (; i < nextProp.length; i++) updatePayload = addNestedProperty( updatePayload, nextProp[i], validAttributes ); return updatePayload; } return Array.isArray(prevProp) ? diffProperties( updatePayload, flattenStyle(prevProp), resolveObject(nextProp), validAttributes ) : diffProperties( updatePayload, resolveObject(prevProp), flattenStyle(nextProp), validAttributes ); } function addNestedProperty(updatePayload, nextProp, validAttributes) { if (!nextProp) return updatePayload; if (!Array.isArray(nextProp)) return ( (nextProp = resolveObject(nextProp)), diffPropert