diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index 752ac5912..617cce49d 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -bde4b1659fd4aea796482f24d40c2e834fca635f \ No newline at end of file +de84d5c1079b12455058ee177fb3ff97cc0fb8d0 \ No newline at end of file diff --git a/Libraries/Renderer/oss/ReactFabric-dev.js b/Libraries/Renderer/oss/ReactFabric-dev.js index d4a4d86b2..eb3f3e078 100644 --- a/Libraries/Renderer/oss/ReactFabric-dev.js +++ b/Libraries/Renderer/oss/ReactFabric-dev.js @@ -523,21 +523,6 @@ var injection$1 = { } }; -function isEndish(topLevelType) { - return ( - topLevelType === "topMouseUp" || - topLevelType === "topTouchEnd" || - topLevelType === "topTouchCancel" - ); -} - -function isMoveish(topLevelType) { - return topLevelType === "topMouseMove" || topLevelType === "topTouchMove"; -} -function isStartish(topLevelType) { - return topLevelType === "topMouseDown" || topLevelType === "topTouchStart"; -} - var validateEventDispatches = void 0; { validateEventDispatches = function(event) { @@ -807,9 +792,7 @@ var HostRoot = 3; // Root of a host tree. Could be nested inside another node. var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. var HostComponent = 5; var HostText = 6; -var CallComponent = 7; -var CallHandlerPhase = 8; -var ReturnComponent = 9; + var Fragment = 10; var Mode = 11; var ContextConsumer = 12; @@ -1386,6 +1369,29 @@ var ResponderSyntheticEvent = SyntheticEvent$1.extend({ } }); +var TOP_TOUCH_START = "topTouchStart"; +var TOP_TOUCH_MOVE = "topTouchMove"; +var TOP_TOUCH_END = "topTouchEnd"; +var TOP_TOUCH_CANCEL = "topTouchCancel"; +var TOP_SCROLL = "topScroll"; +var TOP_SELECTION_CHANGE = "topSelectionChange"; + +function isStartish(topLevelType) { + return topLevelType === TOP_TOUCH_START; +} + +function isMoveish(topLevelType) { + return topLevelType === TOP_TOUCH_MOVE; +} + +function isEndish(topLevelType) { + return topLevelType === TOP_TOUCH_END || topLevelType === TOP_TOUCH_CANCEL; +} + +var startDependencies = [TOP_TOUCH_START]; +var moveDependencies = [TOP_TOUCH_MOVE]; +var endDependencies = [TOP_TOUCH_CANCEL, TOP_TOUCH_END]; + /** * Tracks the position and time of each active touch by `touch.identifier`. We * should typically only see IDs in the range of 1-20 because IDs get recycled @@ -1608,11 +1614,6 @@ var responderInst = null; */ var trackedTouchCount = 0; -/** - * Last reported number of active touches. - */ -var previousActiveTouches = 0; - var changeResponder = function(nextResponderInst, blockHostResponder) { var oldResponderInst = responderInst; responderInst = nextResponderInst; @@ -1634,7 +1635,8 @@ var eventTypes$1 = { phasedRegistrationNames: { bubbled: "onStartShouldSetResponder", captured: "onStartShouldSetResponderCapture" - } + }, + dependencies: startDependencies }, /** @@ -1650,7 +1652,8 @@ var eventTypes$1 = { phasedRegistrationNames: { bubbled: "onScrollShouldSetResponder", captured: "onScrollShouldSetResponderCapture" - } + }, + dependencies: [TOP_SCROLL] }, /** @@ -1664,7 +1667,8 @@ var eventTypes$1 = { phasedRegistrationNames: { bubbled: "onSelectionChangeShouldSetResponder", captured: "onSelectionChangeShouldSetResponderCapture" - } + }, + dependencies: [TOP_SELECTION_CHANGE] }, /** @@ -1675,22 +1679,45 @@ var eventTypes$1 = { phasedRegistrationNames: { bubbled: "onMoveShouldSetResponder", captured: "onMoveShouldSetResponderCapture" - } + }, + dependencies: moveDependencies }, /** * Direct responder events dispatched directly to responder. Do not bubble. */ - responderStart: { registrationName: "onResponderStart" }, - responderMove: { registrationName: "onResponderMove" }, - responderEnd: { registrationName: "onResponderEnd" }, - responderRelease: { registrationName: "onResponderRelease" }, - responderTerminationRequest: { - registrationName: "onResponderTerminationRequest" + responderStart: { + registrationName: "onResponderStart", + dependencies: startDependencies }, - responderGrant: { registrationName: "onResponderGrant" }, - responderReject: { registrationName: "onResponderReject" }, - responderTerminate: { registrationName: "onResponderTerminate" } + responderMove: { + registrationName: "onResponderMove", + dependencies: moveDependencies + }, + responderEnd: { + registrationName: "onResponderEnd", + dependencies: endDependencies + }, + responderRelease: { + registrationName: "onResponderRelease", + dependencies: endDependencies + }, + responderTerminationRequest: { + registrationName: "onResponderTerminationRequest", + dependencies: [] + }, + responderGrant: { + registrationName: "onResponderGrant", + dependencies: [] + }, + responderReject: { + registrationName: "onResponderReject", + dependencies: [] + }, + responderTerminate: { + registrationName: "onResponderTerminate", + dependencies: [] + } }; /** @@ -1893,7 +1920,7 @@ function setResponderAndExtractTransfer( ? eventTypes$1.startShouldSetResponder : isMoveish(topLevelType) ? eventTypes$1.moveShouldSetResponder - : topLevelType === "topSelectionChange" + : topLevelType === TOP_SELECTION_CHANGE ? eventTypes$1.selectionChangeShouldSetResponder : eventTypes$1.scrollShouldSetResponder; @@ -1998,8 +2025,8 @@ function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) { // responderIgnoreScroll: We are trying to migrate away from specifically // tracking native scroll events here and responderIgnoreScroll indicates we // will send topTouchCancel to handle canceling touch events instead - ((topLevelType === "topScroll" && !nativeEvent.responderIgnoreScroll) || - (trackedTouchCount > 0 && topLevelType === "topSelectionChange") || + ((topLevelType === TOP_SCROLL && !nativeEvent.responderIgnoreScroll) || + (trackedTouchCount > 0 && topLevelType === TOP_SELECTION_CHANGE) || isStartish(topLevelType) || isMoveish(topLevelType)) ); @@ -2105,7 +2132,7 @@ var ResponderEventPlugin = { } var isResponderTerminate = - responderInst && topLevelType === "topTouchCancel"; + responderInst && topLevelType === TOP_TOUCH_CANCEL; var isResponderRelease = responderInst && !isResponderTerminate && @@ -2127,23 +2154,10 @@ var ResponderEventPlugin = { changeResponder(null); } - var numberActiveTouches = - ResponderTouchHistoryStore.touchHistory.numberActiveTouches; - if ( - ResponderEventPlugin.GlobalInteractionHandler && - numberActiveTouches !== previousActiveTouches - ) { - ResponderEventPlugin.GlobalInteractionHandler.onChange( - numberActiveTouches - ); - } - previousActiveTouches = numberActiveTouches; - return extracted; }, GlobalResponderHandler: null, - GlobalInteractionHandler: null, injection: { /** @@ -2153,14 +2167,6 @@ var ResponderEventPlugin = { */ injectGlobalResponderHandler: function(GlobalResponderHandler) { ResponderEventPlugin.GlobalResponderHandler = GlobalResponderHandler; - }, - - /** - * @param {{onChange: (numberActiveTouches) => void} GlobalInteractionHandler - * Object that handles any change in the number of active touches. - */ - injectGlobalInteractionHandler: function(GlobalInteractionHandler) { - ResponderEventPlugin.GlobalInteractionHandler = GlobalInteractionHandler; } } }; @@ -2320,8 +2326,6 @@ injection.injectEventPluginsByName({ var hasSymbol = typeof Symbol === "function" && Symbol.for; var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 0xeac7; -var REACT_CALL_TYPE = hasSymbol ? Symbol.for("react.call") : 0xeac8; -var REACT_RETURN_TYPE = hasSymbol ? Symbol.for("react.return") : 0xeac9; var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 0xeaca; var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 0xeacb; var REACT_STRICT_MODE_TYPE = hasSymbol @@ -3335,8 +3339,6 @@ function getComponentName(fiber) { switch (type) { case REACT_ASYNC_MODE_TYPE: return "AsyncMode"; - case REACT_CALL_TYPE: - return "ReactCall"; case REACT_CONTEXT_TYPE: return "Context.Consumer"; case REACT_FRAGMENT_TYPE: @@ -3347,8 +3349,6 @@ function getComponentName(fiber) { return "Profiler(" + fiber.pendingProps.id + ")"; case REACT_PROVIDER_TYPE: return "Context.Provider"; - case REACT_RETURN_TYPE: - return "ReactReturn"; case REACT_STRICT_MODE_TYPE: return "StrictMode"; } @@ -3908,12 +3908,6 @@ function createFiberFromElement(element, mode, expirationTime) { break; case REACT_PROFILER_TYPE: return createFiberFromProfiler(pendingProps, mode, expirationTime, key); - case REACT_CALL_TYPE: - fiberTag = CallComponent; - break; - case REACT_RETURN_TYPE: - fiberTag = ReturnComponent; - break; case REACT_TIMEOUT_TYPE: fiberTag = TimeoutComponent; // Suspense does not require async, but its children should be strict @@ -4879,8 +4873,6 @@ var shouldIgnoreFiber = function(fiber) { case HostComponent: case HostText: case HostPortal: - case CallComponent: - case ReturnComponent: case Fragment: case ContextProvider: case ContextConsumer: @@ -8716,44 +8708,6 @@ var ReactFiberBeginWork = function( } } - function updateCallComponent(current, workInProgress, renderExpirationTime) { - var nextProps = workInProgress.pendingProps; - if (hasLegacyContextChanged()) { - // Normally we can bail out on props equality but if context has changed - // we don't do the bailout and we have to reuse existing props instead. - } else if (workInProgress.memoizedProps === nextProps) { - nextProps = workInProgress.memoizedProps; - // TODO: When bailing out, we might need to return the stateNode instead - // of the child. To check it for work. - // return bailoutOnAlreadyFinishedWork(current, workInProgress); - } - - var nextChildren = nextProps.children; - - // The following is a fork of reconcileChildrenAtExpirationTime but using - // stateNode to store the child. - if (current === null) { - workInProgress.stateNode = mountChildFibers( - workInProgress, - workInProgress.stateNode, - nextChildren, - renderExpirationTime - ); - } else { - workInProgress.stateNode = reconcileChildFibers( - workInProgress, - current.stateNode, - nextChildren, - renderExpirationTime - ); - } - - memoizeProps(workInProgress, nextProps); - // This doesn't take arbitrary time so we could synchronously just begin - // eagerly do the work of workInProgress.child as an optimization. - return workInProgress.stateNode; - } - function updateTimeoutComponent( current, workInProgress, @@ -9230,20 +9184,6 @@ var ReactFiberBeginWork = function( ); case HostText: return updateHostText(current, workInProgress); - case CallHandlerPhase: - // This is a restart. Reset the tag to the initial phase. - workInProgress.tag = CallComponent; - // Intentionally fall through since this is now the same. - case CallComponent: - return updateCallComponent( - current, - workInProgress, - renderExpirationTime - ); - case ReturnComponent: - // A return component is just a placeholder, we can just run through the - // next one immediately. - return null; case TimeoutComponent: return updateTimeoutComponent( current, @@ -9330,75 +9270,6 @@ var ReactFiberCompleteWork = function( workInProgress.effectTag |= Ref; } - function appendAllReturns(returns, workInProgress) { - var node = workInProgress.stateNode; - if (node) { - node.return = workInProgress; - } - while (node !== null) { - if ( - node.tag === HostComponent || - node.tag === HostText || - node.tag === HostPortal - ) { - invariant(false, "A call cannot have host component children."); - } else if (node.tag === ReturnComponent) { - returns.push(node.pendingProps.value); - } else if (node.child !== null) { - node.child.return = node; - node = node.child; - continue; - } - while (node.sibling === null) { - if (node.return === null || node.return === workInProgress) { - return; - } - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } - } - - function moveCallToHandlerPhase( - current, - workInProgress, - renderExpirationTime - ) { - var props = workInProgress.memoizedProps; - invariant( - props, - "Should be resolved by now. This error is likely caused by a bug in " + - "React. Please file an issue." - ); - - // First step of the call has completed. Now we need to do the second. - // TODO: It would be nice to have a multi stage call represented by a - // single component, or at least tail call optimize nested ones. Currently - // that requires additional fields that we don't want to add to the fiber. - // So this requires nested handlers. - // Note: This doesn't mutate the alternate node. I don't think it needs to - // since this stage is reset for every pass. - workInProgress.tag = CallHandlerPhase; - - // Build up the returns. - // TODO: Compare this to a generator or opaque helpers like Children. - var returns = []; - appendAllReturns(returns, workInProgress); - var fn = props.handler; - var childProps = props.props; - var nextChildren = fn(childProps, returns); - - var currentFirstChild = current !== null ? current.child : null; - workInProgress.child = reconcileChildFibers( - workInProgress, - currentFirstChild, - nextChildren, - renderExpirationTime - ); - return workInProgress.child; - } - function appendAllChildren(parent, workInProgress) { // We only have the top Fiber that was created but we need recurse down its // children to find all the terminal nodes. @@ -9792,19 +9663,6 @@ var ReactFiberCompleteWork = function( } return null; } - case CallComponent: - return moveCallToHandlerPhase( - current, - workInProgress, - renderExpirationTime - ); - case CallHandlerPhase: - // Reset the tag to now be a first phase call. - workInProgress.tag = CallComponent; - return null; - case ReturnComponent: - // Does nothing. - return null; case ForwardRef: return null; case TimeoutComponent: @@ -10285,10 +10143,6 @@ var ReactFiberCommitWork = function( safelyDetachRef(current); return; } - case CallComponent: { - commitNestedUnmounts(current.stateNode); - return; - } case HostPortal: { // TODO: this is recursive. // We are also not using this parent because @@ -10428,7 +10282,7 @@ var ReactFiberCommitWork = function( commitUpdate = mutation.commitUpdate, resetTextContent = mutation.resetTextContent, commitTextUpdate = mutation.commitTextUpdate, - appendChild = mutation.appendChild, + appendChild$$1 = mutation.appendChild, appendChildToContainer = mutation.appendChildToContainer, insertBefore = mutation.insertBefore, insertInContainerBefore = mutation.insertInContainerBefore, @@ -10547,7 +10401,7 @@ var ReactFiberCommitWork = function( if (isContainer) { appendChildToContainer(parent, node.stateNode); } else { - appendChild(parent, node.stateNode); + appendChild$$1(parent, node.stateNode); } } } else if (node.tag === HostPortal) { @@ -13027,12 +12881,17 @@ var ReactFiberScheduler = function(config) { var next = void 0; if (enableProfilerTimer) { - startBaseRenderTimer(); + if (workInProgress.mode & ProfileMode) { + startBaseRenderTimer(); + } + next = beginWork(current, workInProgress, nextRenderExpirationTime); - // Update "base" time if the render wasn't bailed out on. - recordElapsedBaseRenderTimeIfRunning(workInProgress); - stopBaseRenderTimerIfRunning(); + if (workInProgress.mode & ProfileMode) { + // Update "base" time if the render wasn't bailed out on. + recordElapsedBaseRenderTimeIfRunning(workInProgress); + stopBaseRenderTimerIfRunning(); + } } else { next = beginWork(current, workInProgress, nextRenderExpirationTime); } @@ -13822,13 +13681,13 @@ var ReactFiberScheduler = function(config) { var finishedWork = root.finishedWork; if (finishedWork !== null) { // This root is already complete. We can commit it. - completeRoot(root, finishedWork, expirationTime); + completeRoot$$1(root, finishedWork, expirationTime); } else { root.finishedWork = null; finishedWork = renderRoot(root, expirationTime, false); if (finishedWork !== null) { // We've completed the root. Commit it. - completeRoot(root, finishedWork, expirationTime); + completeRoot$$1(root, finishedWork, expirationTime); } } } else { @@ -13836,7 +13695,7 @@ var ReactFiberScheduler = function(config) { var _finishedWork = root.finishedWork; if (_finishedWork !== null) { // This root is already complete. We can commit it. - completeRoot(root, _finishedWork, expirationTime); + completeRoot$$1(root, _finishedWork, expirationTime); } else { root.finishedWork = null; _finishedWork = renderRoot(root, expirationTime, true); @@ -13845,7 +13704,7 @@ var ReactFiberScheduler = function(config) { // before committing. if (!shouldYield()) { // Still time left. Commit the root. - completeRoot(root, _finishedWork, expirationTime); + completeRoot$$1(root, _finishedWork, expirationTime); } else { // There's no time left. Mark this root as complete. We'll come // back and commit it later. @@ -13864,7 +13723,7 @@ var ReactFiberScheduler = function(config) { isRendering = false; } - function completeRoot(root, finishedWork, expirationTime) { + function completeRoot$$1(root, finishedWork, expirationTime) { // Check if there's a batch that matches this expiration time. var firstBatch = root.firstBatch; if (firstBatch !== null && firstBatch._expirationTime <= expirationTime) { @@ -14434,7 +14293,7 @@ var ReactFabricHostComponent = (function() { return ReactFabricHostComponent; })(); -var ReacFabricHostConfig = { +var ReactFabricHostConfig = { appendInitialChild: function(parentInstance, child) { FabricUIManager.appendChild(parentInstance.node, child.node); }, @@ -14470,7 +14329,7 @@ var ReacFabricHostConfig = { viewConfig.uiViewClassName, // viewName rootContainerInstance, // rootTag updatePayload, // props - internalInstanceHandle + internalInstanceHandle // internalInstanceHandle ); var component = new ReactFabricHostComponent(tag, viewConfig, props); @@ -14499,7 +14358,7 @@ var ReacFabricHostConfig = { "RCTRawText", // viewName rootContainerInstance, // rootTag { text: text }, // props - internalInstanceHandle + internalInstanceHandle // instance handle ); return { @@ -14593,18 +14452,26 @@ var ReacFabricHostConfig = { var clone = void 0; if (keepChildren) { if (updatePayload !== null) { - clone = FabricUIManager.cloneNodeWithNewProps(node, updatePayload); + clone = FabricUIManager.cloneNodeWithNewProps( + node, + updatePayload, + internalInstanceHandle + ); } else { - clone = FabricUIManager.cloneNode(node); + clone = FabricUIManager.cloneNode(node, internalInstanceHandle); } } else { if (updatePayload !== null) { clone = FabricUIManager.cloneNodeWithNewChildrenAndProps( node, - updatePayload + updatePayload, + internalInstanceHandle ); } else { - clone = FabricUIManager.cloneNodeWithNewChildren(node); + clone = FabricUIManager.cloneNodeWithNewChildren( + node, + internalInstanceHandle + ); } } return { @@ -14625,7 +14492,7 @@ var ReacFabricHostConfig = { } }; -var ReactFabricRenderer = reactReconciler(ReacFabricHostConfig); +var ReactFabricRenderer = reactReconciler(ReactFabricHostConfig); // Module provided by RN: var getInspectorDataForViewTag = void 0; @@ -14816,7 +14683,7 @@ var ReactFabric = { // Used as a mixin in many createClass-based components NativeMethodsMixin: NativeMethodsMixin(findNodeHandle, findHostInstance), // Used by react-native-github/Libraries/ components - ReactNativeComponentTree: ReactNativeComponentTree + ReactNativeComponentTree: ReactNativeComponentTree // ScrollResponder } }; diff --git a/Libraries/Renderer/oss/ReactFabric-prod.js b/Libraries/Renderer/oss/ReactFabric-prod.js index dd7e75d70..c4ca5aba4 100644 --- a/Libraries/Renderer/oss/ReactFabric-prod.js +++ b/Libraries/Renderer/oss/ReactFabric-prod.js @@ -100,19 +100,6 @@ var plugins = [], 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 executeDirectDispatch(event) { var dispatchListener = event._dispatchListeners, dispatchInstance = event._dispatchInstances; @@ -382,10 +369,19 @@ function addEventPoolingTo(EventConstructor) { EventConstructor.release = releasePooledEvent; } var ResponderSyntheticEvent = SyntheticEvent.extend({ - touchHistory: function() { - return null; - } - }), + touchHistory: function() { + return null; + } +}); +function isStartish(topLevelType) { + return "topTouchStart" === topLevelType; +} +function isMoveish(topLevelType) { + return "topTouchMove" === topLevelType; +} +var startDependencies = ["topTouchStart"], + moveDependencies = ["topTouchMove"], + endDependencies = ["topTouchCancel", "topTouchEnd"], touchBank = [], touchHistory = { touchBank: touchBank, @@ -491,19 +487,22 @@ var ResponderTouchHistoryStore = { (touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier); else if ( - isEndish(topLevelType) && - (nativeEvent.changedTouches.forEach(recordTouchEnd), - (touchHistory.numberActiveTouches = nativeEvent.touches.length), - 1 === touchHistory.numberActiveTouches) + "topTouchEnd" === topLevelType || + "topTouchCancel" === topLevelType ) - for (topLevelType = 0; topLevelType < touchBank.length; topLevelType++) - if ( - ((nativeEvent = touchBank[topLevelType]), - null != nativeEvent && nativeEvent.touchActive) - ) { - touchHistory.indexOfSingleActiveTouch = topLevelType; - break; - } + if ( + (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 }; @@ -519,8 +518,7 @@ function accumulate(current, next) { : Array.isArray(next) ? [current].concat(next) : [current, next]; } var responderInst = null, - trackedTouchCount = 0, - previousActiveTouches = 0; + trackedTouchCount = 0; function changeResponder(nextResponderInst, blockHostResponder) { var oldResponderInst = responderInst; responderInst = nextResponderInst; @@ -536,36 +534,59 @@ var eventTypes$1 = { phasedRegistrationNames: { bubbled: "onStartShouldSetResponder", captured: "onStartShouldSetResponderCapture" - } + }, + dependencies: startDependencies }, scrollShouldSetResponder: { phasedRegistrationNames: { bubbled: "onScrollShouldSetResponder", captured: "onScrollShouldSetResponderCapture" - } + }, + dependencies: ["topScroll"] }, selectionChangeShouldSetResponder: { phasedRegistrationNames: { bubbled: "onSelectionChangeShouldSetResponder", captured: "onSelectionChangeShouldSetResponderCapture" - } + }, + dependencies: ["topSelectionChange"] }, moveShouldSetResponder: { phasedRegistrationNames: { bubbled: "onMoveShouldSetResponder", captured: "onMoveShouldSetResponderCapture" - } + }, + dependencies: moveDependencies + }, + responderStart: { + registrationName: "onResponderStart", + dependencies: startDependencies + }, + responderMove: { + registrationName: "onResponderMove", + dependencies: moveDependencies + }, + responderEnd: { + registrationName: "onResponderEnd", + dependencies: endDependencies + }, + responderRelease: { + registrationName: "onResponderRelease", + dependencies: endDependencies }, - responderStart: { registrationName: "onResponderStart" }, - responderMove: { registrationName: "onResponderMove" }, - responderEnd: { registrationName: "onResponderEnd" }, - responderRelease: { registrationName: "onResponderRelease" }, responderTerminationRequest: { - registrationName: "onResponderTerminationRequest" + registrationName: "onResponderTerminationRequest", + dependencies: [] }, - responderGrant: { registrationName: "onResponderGrant" }, - responderReject: { registrationName: "onResponderReject" }, - responderTerminate: { registrationName: "onResponderTerminate" } + responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, + responderReject: { + registrationName: "onResponderReject", + dependencies: [] + }, + responderTerminate: { + registrationName: "onResponderTerminate", + dependencies: [] + } }, ResponderEventPlugin = { _getResponder: function() { @@ -579,7 +600,10 @@ var eventTypes$1 = { nativeEventTarget ) { if (isStartish(topLevelType)) trackedTouchCount += 1; - else if (isEndish(topLevelType)) + else if ( + "topTouchEnd" === topLevelType || + "topTouchCancel" === topLevelType + ) if (0 <= trackedTouchCount) --trackedTouchCount; else return ( @@ -749,7 +773,9 @@ var eventTypes$1 = { } else JSCompiler_temp = null; JSCompiler_temp$jscomp$0 = responderInst && isStartish(topLevelType); targetInst = responderInst && isMoveish(topLevelType); - depthA = responderInst && isEndish(topLevelType); + depthA = + responderInst && + ("topTouchEnd" === topLevelType || "topTouchCancel" === topLevelType); if ( (JSCompiler_temp$jscomp$0 = JSCompiler_temp$jscomp$0 ? eventTypes$1.responderStart @@ -777,7 +803,9 @@ var eventTypes$1 = { responderInst && "topTouchCancel" === topLevelType; if ( (topLevelType = - responderInst && !JSCompiler_temp$jscomp$0 && isEndish(topLevelType)) + responderInst && + !JSCompiler_temp$jscomp$0 && + ("topTouchEnd" === topLevelType || "topTouchCancel" === topLevelType)) ) a: { if ((topLevelType = nativeEvent.touches) && 0 !== topLevelType.length) @@ -819,23 +847,12 @@ var eventTypes$1 = { forEachAccumulated(nativeEvent, accumulateDirectDispatchesSingle), (JSCompiler_temp = accumulate(JSCompiler_temp, nativeEvent)), changeResponder(null); - nativeEvent = ResponderTouchHistoryStore.touchHistory.numberActiveTouches; - if ( - ResponderEventPlugin.GlobalInteractionHandler && - nativeEvent !== previousActiveTouches - ) - ResponderEventPlugin.GlobalInteractionHandler.onChange(nativeEvent); - previousActiveTouches = nativeEvent; return JSCompiler_temp; }, GlobalResponderHandler: null, - GlobalInteractionHandler: null, injection: { injectGlobalResponderHandler: function(GlobalResponderHandler) { ResponderEventPlugin.GlobalResponderHandler = GlobalResponderHandler; - }, - injectGlobalInteractionHandler: function(GlobalInteractionHandler) { - ResponderEventPlugin.GlobalInteractionHandler = GlobalInteractionHandler; } } }, @@ -922,8 +939,6 @@ injection.injectEventPluginsByName({ }); var 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, REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108, @@ -1213,8 +1228,6 @@ function getComponentName(fiber) { switch (type) { case REACT_ASYNC_MODE_TYPE: return "AsyncMode"; - case REACT_CALL_TYPE: - return "ReactCall"; case REACT_CONTEXT_TYPE: return "Context.Consumer"; case REACT_FRAGMENT_TYPE: @@ -1225,8 +1238,6 @@ function getComponentName(fiber) { return "Profiler(" + fiber.pendingProps.id + ")"; case REACT_PROVIDER_TYPE: return "Context.Provider"; - case REACT_RETURN_TYPE: - return "ReactReturn"; case REACT_STRICT_MODE_TYPE: return "StrictMode"; } @@ -1444,12 +1455,6 @@ function createFiberFromElement(element, mode, expirationTime) { (type.stateNode = { duration: 0, startTime: 0 }), type ); - case REACT_CALL_TYPE: - fiberTag = 7; - break; - case REACT_RETURN_TYPE: - fiberTag = 9; - break; case REACT_TIMEOUT_TYPE: fiberTag = 16; mode |= 2; @@ -3377,34 +3382,6 @@ function ReactFiberBeginWork( (workInProgress.memoizedProps = workInProgress.pendingProps), null ); - case 8: - workInProgress.tag = 7; - case 7: - return ( - (props = workInProgress.pendingProps), - hasLegacyContextChanged() || - workInProgress.memoizedProps !== props || - (props = workInProgress.memoizedProps), - (fn = props.children), - (workInProgress.stateNode = - null === current - ? mountChildFibers( - workInProgress, - workInProgress.stateNode, - fn, - renderExpirationTime - ) - : reconcileChildFibers( - workInProgress, - current.stateNode, - fn, - renderExpirationTime - )), - (workInProgress.memoizedProps = props), - workInProgress.stateNode - ); - case 9: - return null; case 16: return null; case 4: @@ -3687,7 +3664,7 @@ function ReactFiberCompleteWork( }; } else invariant(!1, "Noop reconciler is disabled."); return { - completeWork: function(current, workInProgress, renderExpirationTime) { + completeWork: function(current, workInProgress) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { case 1: @@ -3707,8 +3684,8 @@ function ReactFiberCompleteWork( return null; case 5: popHostContext(workInProgress); - renderExpirationTime = getRootHostContainer(); - var type = workInProgress.type; + var rootContainerInstance = getRootHostContainer(), + type = workInProgress.type; if (null !== current && null != workInProgress.stateNode) { var oldProps = current.memoizedProps, instance = workInProgress.stateNode, @@ -3718,7 +3695,7 @@ function ReactFiberCompleteWork( type, oldProps, newProps, - renderExpirationTime, + rootContainerInstance, currentHostContext ); updateHostComponent( @@ -3728,7 +3705,7 @@ function ReactFiberCompleteWork( type, oldProps, newProps, - renderExpirationTime, + rootContainerInstance, currentHostContext ); current.ref !== workInProgress.ref && @@ -3746,13 +3723,13 @@ function ReactFiberCompleteWork( popHydrationState(workInProgress) ? prepareToHydrateHostInstance( workInProgress, - renderExpirationTime, + rootContainerInstance, current ) && markUpdate(workInProgress) : ((oldProps = createInstance( type, newProps, - renderExpirationTime, + rootContainerInstance, current, workInProgress )), @@ -3761,7 +3738,7 @@ function ReactFiberCompleteWork( oldProps, type, newProps, - renderExpirationTime, + rootContainerInstance, current ) && markUpdate(workInProgress), (workInProgress.stateNode = oldProps)); @@ -3785,69 +3762,19 @@ function ReactFiberCompleteWork( ), null ); - current = getRootHostContainer(); - renderExpirationTime = getHostContext(); + rootContainerInstance = getRootHostContainer(); + type = getHostContext(); popHydrationState(workInProgress) ? prepareToHydrateHostTextInstance(workInProgress) && markUpdate(workInProgress) : (workInProgress.stateNode = createTextInstance( newProps, - current, - renderExpirationTime, + rootContainerInstance, + type, workInProgress )); } return null; - case 7: - newProps = workInProgress.memoizedProps; - invariant( - newProps, - "Should be resolved by now. This error is likely caused by a bug in React. Please file an issue." - ); - workInProgress.tag = 8; - type = []; - a: { - if ((oldProps = workInProgress.stateNode)) - oldProps.return = workInProgress; - for (; null !== oldProps; ) { - if ( - 5 === oldProps.tag || - 6 === oldProps.tag || - 4 === oldProps.tag - ) - invariant(!1, "A call cannot have host component children."); - else if (9 === oldProps.tag) - type.push(oldProps.pendingProps.value); - else if (null !== oldProps.child) { - oldProps.child.return = oldProps; - oldProps = oldProps.child; - continue; - } - for (; null === oldProps.sibling; ) { - if ( - null === oldProps.return || - oldProps.return === workInProgress - ) - break a; - oldProps = oldProps.return; - } - oldProps.sibling.return = oldProps.return; - oldProps = oldProps.sibling; - } - } - oldProps = newProps.handler; - newProps = oldProps(newProps.props, type); - workInProgress.child = reconcileChildFibers( - workInProgress, - null !== current ? current.child : null, - newProps, - renderExpirationTime - ); - return workInProgress.child; - case 8: - return (workInProgress.tag = 7), null; - case 9: - return null; case 14: return null; case 16: @@ -4059,43 +3986,6 @@ function ReactFiberCommitWork(config, captureError) { ? current(null) : (current.current = null)); } - function commitNestedUnmounts(root) { - for (var node = root; ; ) { - var current = node; - "function" === typeof onCommitUnmount && onCommitUnmount(current); - switch (current.tag) { - case 2: - safelyDetachRef(current); - var _instance6 = current.stateNode; - if ("function" === typeof _instance6.componentWillUnmount) - try { - (_instance6.props = current.memoizedProps), - (_instance6.state = current.memoizedState), - _instance6.componentWillUnmount(); - } catch (unmountError) { - captureError(current, unmountError); - } - break; - case 5: - safelyDetachRef(current); - break; - case 7: - commitNestedUnmounts(current.stateNode); - break; - case 4: - persistence && emptyPortalContainer(current); - } - if (null === node.child || (mutation && 4 === node.tag)) { - if (node === root) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === root) return; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } else (node.child.return = node), (node = node.child); - } - } var getPublicInstance = config.getPublicInstance, mutation = config.mutation, persistence = config.persistence, @@ -4137,12 +4027,45 @@ function ReactFiberCommitWork(config, captureError) { return { commitResetTextContent: function() {}, commitPlacement: function() {}, - commitDeletion: function(current) { - commitNestedUnmounts(current); - current.return = null; - current.child = null; - current.alternate && - ((current.alternate.child = null), (current.alternate.return = null)); + commitDeletion: function(current$jscomp$0) { + a: for (var node = current$jscomp$0; ; ) { + var current = node; + "function" === typeof onCommitUnmount && onCommitUnmount(current); + switch (current.tag) { + case 2: + safelyDetachRef(current); + var _instance6 = current.stateNode; + if ("function" === typeof _instance6.componentWillUnmount) + try { + (_instance6.props = current.memoizedProps), + (_instance6.state = current.memoizedState), + _instance6.componentWillUnmount(); + } catch (unmountError) { + captureError(current, unmountError); + } + break; + case 5: + safelyDetachRef(current); + break; + case 4: + persistence && emptyPortalContainer(current); + } + if (null === node.child || (mutation && 4 === node.tag)) { + if (node === current$jscomp$0) break; + for (; null === node.sibling; ) { + if (null === node.return || node.return === current$jscomp$0) + break a; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } else (node.child.return = node), (node = node.child); + } + current$jscomp$0.return = null; + current$jscomp$0.child = null; + current$jscomp$0.alternate && + ((current$jscomp$0.alternate.child = null), + (current$jscomp$0.alternate.return = null)); }, commitWork: function(current, finishedWork) { commitContainer(finishedWork); @@ -5182,22 +5105,23 @@ function ReactFiberScheduler(config) { isAsync ? ((isAsync = root.finishedWork), null !== isAsync - ? completeRoot(root, isAsync, expirationTime) + ? completeRoot$$1(root, isAsync, expirationTime) : ((root.finishedWork = null), (isAsync = renderRoot(root, expirationTime, !0)), null !== isAsync && (shouldYield() ? (root.finishedWork = isAsync) - : completeRoot(root, isAsync, expirationTime)))) + : completeRoot$$1(root, isAsync, expirationTime)))) : ((isAsync = root.finishedWork), null !== isAsync - ? completeRoot(root, isAsync, expirationTime) + ? completeRoot$$1(root, isAsync, expirationTime) : ((root.finishedWork = null), (isAsync = renderRoot(root, expirationTime, !1)), - null !== isAsync && completeRoot(root, isAsync, expirationTime))); + null !== isAsync && + completeRoot$$1(root, isAsync, expirationTime))); isRendering = !1; } - function completeRoot(root, finishedWork, expirationTime) { + function completeRoot$$1(root, finishedWork, expirationTime) { var firstBatch = root.firstBatch; if ( null !== firstBatch && @@ -5909,14 +5833,22 @@ var nextReactTag = 2, return { node: keepChildren ? null !== updatePayload - ? FabricUIManager.cloneNodeWithNewProps(type, updatePayload) - : FabricUIManager.cloneNode(type) + ? FabricUIManager.cloneNodeWithNewProps( + type, + updatePayload, + internalInstanceHandle + ) + : FabricUIManager.cloneNode(type, internalInstanceHandle) : null !== updatePayload ? FabricUIManager.cloneNodeWithNewChildrenAndProps( type, - updatePayload + updatePayload, + internalInstanceHandle ) - : FabricUIManager.cloneNodeWithNewChildren(type), + : FabricUIManager.cloneNodeWithNewChildren( + type, + internalInstanceHandle + ), canonical: instance.canonical }; }, diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js index de1791245..9b2b430c1 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js @@ -523,21 +523,6 @@ var injection$1 = { } }; -function isEndish(topLevelType) { - return ( - topLevelType === "topMouseUp" || - topLevelType === "topTouchEnd" || - topLevelType === "topTouchCancel" - ); -} - -function isMoveish(topLevelType) { - return topLevelType === "topMouseMove" || topLevelType === "topTouchMove"; -} -function isStartish(topLevelType) { - return topLevelType === "topMouseDown" || topLevelType === "topTouchStart"; -} - var validateEventDispatches = void 0; { validateEventDispatches = function(event) { @@ -961,9 +946,7 @@ var HostRoot = 3; // Root of a host tree. Could be nested inside another node. var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. var HostComponent = 5; var HostText = 6; -var CallComponent = 7; -var CallHandlerPhase = 8; -var ReturnComponent = 9; + var Fragment = 10; var Mode = 11; var ContextConsumer = 12; @@ -1540,6 +1523,29 @@ var ResponderSyntheticEvent = SyntheticEvent$1.extend({ } }); +var TOP_TOUCH_START = "topTouchStart"; +var TOP_TOUCH_MOVE = "topTouchMove"; +var TOP_TOUCH_END = "topTouchEnd"; +var TOP_TOUCH_CANCEL = "topTouchCancel"; +var TOP_SCROLL = "topScroll"; +var TOP_SELECTION_CHANGE = "topSelectionChange"; + +function isStartish(topLevelType) { + return topLevelType === TOP_TOUCH_START; +} + +function isMoveish(topLevelType) { + return topLevelType === TOP_TOUCH_MOVE; +} + +function isEndish(topLevelType) { + return topLevelType === TOP_TOUCH_END || topLevelType === TOP_TOUCH_CANCEL; +} + +var startDependencies = [TOP_TOUCH_START]; +var moveDependencies = [TOP_TOUCH_MOVE]; +var endDependencies = [TOP_TOUCH_CANCEL, TOP_TOUCH_END]; + /** * Tracks the position and time of each active touch by `touch.identifier`. We * should typically only see IDs in the range of 1-20 because IDs get recycled @@ -1762,11 +1768,6 @@ var responderInst = null; */ var trackedTouchCount = 0; -/** - * Last reported number of active touches. - */ -var previousActiveTouches = 0; - var changeResponder = function(nextResponderInst, blockHostResponder) { var oldResponderInst = responderInst; responderInst = nextResponderInst; @@ -1788,7 +1789,8 @@ var eventTypes$1 = { phasedRegistrationNames: { bubbled: "onStartShouldSetResponder", captured: "onStartShouldSetResponderCapture" - } + }, + dependencies: startDependencies }, /** @@ -1804,7 +1806,8 @@ var eventTypes$1 = { phasedRegistrationNames: { bubbled: "onScrollShouldSetResponder", captured: "onScrollShouldSetResponderCapture" - } + }, + dependencies: [TOP_SCROLL] }, /** @@ -1818,7 +1821,8 @@ var eventTypes$1 = { phasedRegistrationNames: { bubbled: "onSelectionChangeShouldSetResponder", captured: "onSelectionChangeShouldSetResponderCapture" - } + }, + dependencies: [TOP_SELECTION_CHANGE] }, /** @@ -1829,22 +1833,45 @@ var eventTypes$1 = { phasedRegistrationNames: { bubbled: "onMoveShouldSetResponder", captured: "onMoveShouldSetResponderCapture" - } + }, + dependencies: moveDependencies }, /** * Direct responder events dispatched directly to responder. Do not bubble. */ - responderStart: { registrationName: "onResponderStart" }, - responderMove: { registrationName: "onResponderMove" }, - responderEnd: { registrationName: "onResponderEnd" }, - responderRelease: { registrationName: "onResponderRelease" }, - responderTerminationRequest: { - registrationName: "onResponderTerminationRequest" + responderStart: { + registrationName: "onResponderStart", + dependencies: startDependencies }, - responderGrant: { registrationName: "onResponderGrant" }, - responderReject: { registrationName: "onResponderReject" }, - responderTerminate: { registrationName: "onResponderTerminate" } + responderMove: { + registrationName: "onResponderMove", + dependencies: moveDependencies + }, + responderEnd: { + registrationName: "onResponderEnd", + dependencies: endDependencies + }, + responderRelease: { + registrationName: "onResponderRelease", + dependencies: endDependencies + }, + responderTerminationRequest: { + registrationName: "onResponderTerminationRequest", + dependencies: [] + }, + responderGrant: { + registrationName: "onResponderGrant", + dependencies: [] + }, + responderReject: { + registrationName: "onResponderReject", + dependencies: [] + }, + responderTerminate: { + registrationName: "onResponderTerminate", + dependencies: [] + } }; /** @@ -2047,7 +2074,7 @@ function setResponderAndExtractTransfer( ? eventTypes$1.startShouldSetResponder : isMoveish(topLevelType) ? eventTypes$1.moveShouldSetResponder - : topLevelType === "topSelectionChange" + : topLevelType === TOP_SELECTION_CHANGE ? eventTypes$1.selectionChangeShouldSetResponder : eventTypes$1.scrollShouldSetResponder; @@ -2152,8 +2179,8 @@ function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) { // responderIgnoreScroll: We are trying to migrate away from specifically // tracking native scroll events here and responderIgnoreScroll indicates we // will send topTouchCancel to handle canceling touch events instead - ((topLevelType === "topScroll" && !nativeEvent.responderIgnoreScroll) || - (trackedTouchCount > 0 && topLevelType === "topSelectionChange") || + ((topLevelType === TOP_SCROLL && !nativeEvent.responderIgnoreScroll) || + (trackedTouchCount > 0 && topLevelType === TOP_SELECTION_CHANGE) || isStartish(topLevelType) || isMoveish(topLevelType)) ); @@ -2259,7 +2286,7 @@ var ResponderEventPlugin = { } var isResponderTerminate = - responderInst && topLevelType === "topTouchCancel"; + responderInst && topLevelType === TOP_TOUCH_CANCEL; var isResponderRelease = responderInst && !isResponderTerminate && @@ -2281,23 +2308,10 @@ var ResponderEventPlugin = { changeResponder(null); } - var numberActiveTouches = - ResponderTouchHistoryStore.touchHistory.numberActiveTouches; - if ( - ResponderEventPlugin.GlobalInteractionHandler && - numberActiveTouches !== previousActiveTouches - ) { - ResponderEventPlugin.GlobalInteractionHandler.onChange( - numberActiveTouches - ); - } - previousActiveTouches = numberActiveTouches; - return extracted; }, GlobalResponderHandler: null, - GlobalInteractionHandler: null, injection: { /** @@ -2307,14 +2321,6 @@ var ResponderEventPlugin = { */ injectGlobalResponderHandler: function(GlobalResponderHandler) { ResponderEventPlugin.GlobalResponderHandler = GlobalResponderHandler; - }, - - /** - * @param {{onChange: (numberActiveTouches) => void} GlobalInteractionHandler - * Object that handles any change in the number of active touches. - */ - injectGlobalInteractionHandler: function(GlobalInteractionHandler) { - ResponderEventPlugin.GlobalInteractionHandler = GlobalInteractionHandler; } } }; @@ -2752,8 +2758,6 @@ var ReactDebugCurrentFrame = ReactInternals.ReactDebugCurrentFrame; var hasSymbol = typeof Symbol === "function" && Symbol.for; var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 0xeac7; -var REACT_CALL_TYPE = hasSymbol ? Symbol.for("react.call") : 0xeac8; -var REACT_RETURN_TYPE = hasSymbol ? Symbol.for("react.return") : 0xeac9; var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 0xeaca; var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 0xeacb; var REACT_STRICT_MODE_TYPE = hasSymbol @@ -2796,8 +2800,6 @@ function getComponentName(fiber) { switch (type) { case REACT_ASYNC_MODE_TYPE: return "AsyncMode"; - case REACT_CALL_TYPE: - return "ReactCall"; case REACT_CONTEXT_TYPE: return "Context.Consumer"; case REACT_FRAGMENT_TYPE: @@ -2808,8 +2810,6 @@ function getComponentName(fiber) { return "Profiler(" + fiber.pendingProps.id + ")"; case REACT_PROVIDER_TYPE: return "Context.Provider"; - case REACT_RETURN_TYPE: - return "ReactReturn"; case REACT_STRICT_MODE_TYPE: return "StrictMode"; } @@ -3120,7 +3120,7 @@ var enablePersistentReconciler = false; var enableUserTimingAPI = true; var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; var warnAboutDeprecatedLifecycles = false; -var enableProfilerTimer = false; +var enableProfilerTimer = true; var fireGetDerivedStateFromPropsOnStateUpdates = true; // Only used in www builds. @@ -3367,12 +3367,6 @@ function createFiberFromElement(element, mode, expirationTime) { break; case REACT_PROFILER_TYPE: return createFiberFromProfiler(pendingProps, mode, expirationTime, key); - case REACT_CALL_TYPE: - fiberTag = CallComponent; - break; - case REACT_RETURN_TYPE: - fiberTag = ReturnComponent; - break; case REACT_TIMEOUT_TYPE: fiberTag = TimeoutComponent; // Suspense does not require async, but its children should be strict @@ -4338,8 +4332,6 @@ var shouldIgnoreFiber = function(fiber) { case HostComponent: case HostText: case HostPortal: - case CallComponent: - case ReturnComponent: case Fragment: case ContextProvider: case ContextConsumer: @@ -8175,44 +8167,6 @@ var ReactFiberBeginWork = function( } } - function updateCallComponent(current, workInProgress, renderExpirationTime) { - var nextProps = workInProgress.pendingProps; - if (hasLegacyContextChanged()) { - // Normally we can bail out on props equality but if context has changed - // we don't do the bailout and we have to reuse existing props instead. - } else if (workInProgress.memoizedProps === nextProps) { - nextProps = workInProgress.memoizedProps; - // TODO: When bailing out, we might need to return the stateNode instead - // of the child. To check it for work. - // return bailoutOnAlreadyFinishedWork(current, workInProgress); - } - - var nextChildren = nextProps.children; - - // The following is a fork of reconcileChildrenAtExpirationTime but using - // stateNode to store the child. - if (current === null) { - workInProgress.stateNode = mountChildFibers( - workInProgress, - workInProgress.stateNode, - nextChildren, - renderExpirationTime - ); - } else { - workInProgress.stateNode = reconcileChildFibers( - workInProgress, - current.stateNode, - nextChildren, - renderExpirationTime - ); - } - - memoizeProps(workInProgress, nextProps); - // This doesn't take arbitrary time so we could synchronously just begin - // eagerly do the work of workInProgress.child as an optimization. - return workInProgress.stateNode; - } - function updateTimeoutComponent( current, workInProgress, @@ -8689,20 +8643,6 @@ var ReactFiberBeginWork = function( ); case HostText: return updateHostText(current, workInProgress); - case CallHandlerPhase: - // This is a restart. Reset the tag to the initial phase. - workInProgress.tag = CallComponent; - // Intentionally fall through since this is now the same. - case CallComponent: - return updateCallComponent( - current, - workInProgress, - renderExpirationTime - ); - case ReturnComponent: - // A return component is just a placeholder, we can just run through the - // next one immediately. - return null; case TimeoutComponent: return updateTimeoutComponent( current, @@ -8789,75 +8729,6 @@ var ReactFiberCompleteWork = function( workInProgress.effectTag |= Ref; } - function appendAllReturns(returns, workInProgress) { - var node = workInProgress.stateNode; - if (node) { - node.return = workInProgress; - } - while (node !== null) { - if ( - node.tag === HostComponent || - node.tag === HostText || - node.tag === HostPortal - ) { - invariant(false, "A call cannot have host component children."); - } else if (node.tag === ReturnComponent) { - returns.push(node.pendingProps.value); - } else if (node.child !== null) { - node.child.return = node; - node = node.child; - continue; - } - while (node.sibling === null) { - if (node.return === null || node.return === workInProgress) { - return; - } - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } - } - - function moveCallToHandlerPhase( - current, - workInProgress, - renderExpirationTime - ) { - var props = workInProgress.memoizedProps; - invariant( - props, - "Should be resolved by now. This error is likely caused by a bug in " + - "React. Please file an issue." - ); - - // First step of the call has completed. Now we need to do the second. - // TODO: It would be nice to have a multi stage call represented by a - // single component, or at least tail call optimize nested ones. Currently - // that requires additional fields that we don't want to add to the fiber. - // So this requires nested handlers. - // Note: This doesn't mutate the alternate node. I don't think it needs to - // since this stage is reset for every pass. - workInProgress.tag = CallHandlerPhase; - - // Build up the returns. - // TODO: Compare this to a generator or opaque helpers like Children. - var returns = []; - appendAllReturns(returns, workInProgress); - var fn = props.handler; - var childProps = props.props; - var nextChildren = fn(childProps, returns); - - var currentFirstChild = current !== null ? current.child : null; - workInProgress.child = reconcileChildFibers( - workInProgress, - currentFirstChild, - nextChildren, - renderExpirationTime - ); - return workInProgress.child; - } - function appendAllChildren(parent, workInProgress) { // We only have the top Fiber that was created but we need recurse down its // children to find all the terminal nodes. @@ -9251,19 +9122,6 @@ var ReactFiberCompleteWork = function( } return null; } - case CallComponent: - return moveCallToHandlerPhase( - current, - workInProgress, - renderExpirationTime - ); - case CallHandlerPhase: - // Reset the tag to now be a first phase call. - workInProgress.tag = CallComponent; - return null; - case ReturnComponent: - // Does nothing. - return null; case ForwardRef: return null; case TimeoutComponent: @@ -9744,10 +9602,6 @@ var ReactFiberCommitWork = function( safelyDetachRef(current); return; } - case CallComponent: { - commitNestedUnmounts(current.stateNode); - return; - } case HostPortal: { // TODO: this is recursive. // We are also not using this parent because @@ -12486,12 +12340,17 @@ var ReactFiberScheduler = function(config) { var next = void 0; if (enableProfilerTimer) { - startBaseRenderTimer(); + if (workInProgress.mode & ProfileMode) { + startBaseRenderTimer(); + } + next = beginWork(current, workInProgress, nextRenderExpirationTime); - // Update "base" time if the render wasn't bailed out on. - recordElapsedBaseRenderTimeIfRunning(workInProgress); - stopBaseRenderTimerIfRunning(); + if (workInProgress.mode & ProfileMode) { + // Update "base" time if the render wasn't bailed out on. + recordElapsedBaseRenderTimeIfRunning(workInProgress); + stopBaseRenderTimerIfRunning(); + } } else { next = beginWork(current, workInProgress, nextRenderExpirationTime); } @@ -14476,7 +14335,7 @@ var ReactNativeHostConfig = { tag, // reactTag viewConfig.uiViewClassName, // viewName rootContainerInstance, // rootTag - updatePayload + updatePayload // props ); var component = new ReactNativeFiberHostComponent(tag, viewConfig); @@ -14505,7 +14364,7 @@ var ReactNativeHostConfig = { tag, // reactTag "RCTRawText", // viewName rootContainerInstance, // rootTag - { text: text } + { text: text } // props ); precacheFiberNode(internalInstanceHandle, tag); @@ -14533,7 +14392,7 @@ var ReactNativeHostConfig = { UIManager.setChildren( parentInstance._nativeTag, // containerTag - nativeTags + nativeTags // reactTags ); return false; @@ -14613,7 +14472,7 @@ var ReactNativeHostConfig = { [children.length - 1], // moveToIndices [], // addChildReactTags [], // addAtIndices - [] + [] // removeAtIndices ); } else { children.push(child); @@ -14624,7 +14483,7 @@ var ReactNativeHostConfig = { [], // moveToIndices [childTag], // addChildReactTags [children.length - 1], // addAtIndices - [] + [] // removeAtIndices ); } }, @@ -14632,14 +14491,14 @@ var ReactNativeHostConfig = { var childTag = typeof child === "number" ? child : child._nativeTag; UIManager.setChildren( parentInstance, // containerTag - [childTag] + [childTag] // reactTags ); }, commitTextUpdate: function(textInstance, oldText, newText) { UIManager.updateView( textInstance, // reactTag "RCTRawText", // viewName - { text: newText } + { text: newText } // props ); }, commitMount: function(instance, type, newProps, internalInstanceHandle) { @@ -14666,7 +14525,7 @@ var ReactNativeHostConfig = { UIManager.updateView( instance._nativeTag, // reactTag viewConfig.uiViewClassName, // viewName - updatePayload + updatePayload // props ); } }, @@ -14686,7 +14545,7 @@ var ReactNativeHostConfig = { [beforeChildIndex], // moveToIndices [], // addChildReactTags [], // addAtIndices - [] + [] // removeAtIndices ); } else { var _beforeChildIndex = children.indexOf(beforeChild); @@ -14700,7 +14559,7 @@ var ReactNativeHostConfig = { [], // moveToIndices [childTag], // addChildReactTags [_beforeChildIndex], // addAtIndices - [] + [] // removeAtIndices ); } }, @@ -14727,7 +14586,7 @@ var ReactNativeHostConfig = { [], // moveToIndices [], // addChildReactTags [], // addAtIndices - [index] + [index] // removeAtIndices ); }, removeChildFromContainer: function(parentInstance, child) { @@ -14738,7 +14597,7 @@ var ReactNativeHostConfig = { [], // moveToIndices [], // addChildReactTags [], // addAtIndices - [0] + [0] // removeAtIndices ); }, resetTextContent: function(instance) { diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js index 45cc8fca1..471d04181 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js @@ -164,19 +164,6 @@ var plugins = [], 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); @@ -477,10 +464,19 @@ function addEventPoolingTo(EventConstructor) { EventConstructor.release = releasePooledEvent; } var ResponderSyntheticEvent = SyntheticEvent.extend({ - touchHistory: function() { - return null; - } - }), + touchHistory: function() { + return null; + } +}); +function isStartish(topLevelType) { + return "topTouchStart" === topLevelType; +} +function isMoveish(topLevelType) { + return "topTouchMove" === topLevelType; +} +var startDependencies = ["topTouchStart"], + moveDependencies = ["topTouchMove"], + endDependencies = ["topTouchCancel", "topTouchEnd"], touchBank = [], touchHistory = { touchBank: touchBank, @@ -586,19 +582,22 @@ var ResponderTouchHistoryStore = { (touchHistory.indexOfSingleActiveTouch = nativeEvent.touches[0].identifier); else if ( - isEndish(topLevelType) && - (nativeEvent.changedTouches.forEach(recordTouchEnd), - (touchHistory.numberActiveTouches = nativeEvent.touches.length), - 1 === touchHistory.numberActiveTouches) + "topTouchEnd" === topLevelType || + "topTouchCancel" === topLevelType ) - for (topLevelType = 0; topLevelType < touchBank.length; topLevelType++) - if ( - ((nativeEvent = touchBank[topLevelType]), - null != nativeEvent && nativeEvent.touchActive) - ) { - touchHistory.indexOfSingleActiveTouch = topLevelType; - break; - } + if ( + (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 }; @@ -614,8 +613,7 @@ function accumulate(current, next) { : Array.isArray(next) ? [current].concat(next) : [current, next]; } var responderInst = null, - trackedTouchCount = 0, - previousActiveTouches = 0; + trackedTouchCount = 0; function changeResponder(nextResponderInst, blockHostResponder) { var oldResponderInst = responderInst; responderInst = nextResponderInst; @@ -631,36 +629,59 @@ var eventTypes$1 = { phasedRegistrationNames: { bubbled: "onStartShouldSetResponder", captured: "onStartShouldSetResponderCapture" - } + }, + dependencies: startDependencies }, scrollShouldSetResponder: { phasedRegistrationNames: { bubbled: "onScrollShouldSetResponder", captured: "onScrollShouldSetResponderCapture" - } + }, + dependencies: ["topScroll"] }, selectionChangeShouldSetResponder: { phasedRegistrationNames: { bubbled: "onSelectionChangeShouldSetResponder", captured: "onSelectionChangeShouldSetResponderCapture" - } + }, + dependencies: ["topSelectionChange"] }, moveShouldSetResponder: { phasedRegistrationNames: { bubbled: "onMoveShouldSetResponder", captured: "onMoveShouldSetResponderCapture" - } + }, + dependencies: moveDependencies + }, + responderStart: { + registrationName: "onResponderStart", + dependencies: startDependencies + }, + responderMove: { + registrationName: "onResponderMove", + dependencies: moveDependencies + }, + responderEnd: { + registrationName: "onResponderEnd", + dependencies: endDependencies + }, + responderRelease: { + registrationName: "onResponderRelease", + dependencies: endDependencies }, - responderStart: { registrationName: "onResponderStart" }, - responderMove: { registrationName: "onResponderMove" }, - responderEnd: { registrationName: "onResponderEnd" }, - responderRelease: { registrationName: "onResponderRelease" }, responderTerminationRequest: { - registrationName: "onResponderTerminationRequest" + registrationName: "onResponderTerminationRequest", + dependencies: [] }, - responderGrant: { registrationName: "onResponderGrant" }, - responderReject: { registrationName: "onResponderReject" }, - responderTerminate: { registrationName: "onResponderTerminate" } + responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, + responderReject: { + registrationName: "onResponderReject", + dependencies: [] + }, + responderTerminate: { + registrationName: "onResponderTerminate", + dependencies: [] + } }, ResponderEventPlugin = { _getResponder: function() { @@ -674,7 +695,10 @@ var eventTypes$1 = { nativeEventTarget ) { if (isStartish(topLevelType)) trackedTouchCount += 1; - else if (isEndish(topLevelType)) + else if ( + "topTouchEnd" === topLevelType || + "topTouchCancel" === topLevelType + ) if (0 <= trackedTouchCount) --trackedTouchCount; else return ( @@ -844,7 +868,9 @@ var eventTypes$1 = { } else JSCompiler_temp = null; JSCompiler_temp$jscomp$0 = responderInst && isStartish(topLevelType); targetInst = responderInst && isMoveish(topLevelType); - depthA = responderInst && isEndish(topLevelType); + depthA = + responderInst && + ("topTouchEnd" === topLevelType || "topTouchCancel" === topLevelType); if ( (JSCompiler_temp$jscomp$0 = JSCompiler_temp$jscomp$0 ? eventTypes$1.responderStart @@ -872,7 +898,9 @@ var eventTypes$1 = { responderInst && "topTouchCancel" === topLevelType; if ( (topLevelType = - responderInst && !JSCompiler_temp$jscomp$0 && isEndish(topLevelType)) + responderInst && + !JSCompiler_temp$jscomp$0 && + ("topTouchEnd" === topLevelType || "topTouchCancel" === topLevelType)) ) a: { if ((topLevelType = nativeEvent.touches) && 0 !== topLevelType.length) @@ -914,23 +942,12 @@ var eventTypes$1 = { forEachAccumulated(nativeEvent, accumulateDirectDispatchesSingle), (JSCompiler_temp = accumulate(JSCompiler_temp, nativeEvent)), changeResponder(null); - nativeEvent = ResponderTouchHistoryStore.touchHistory.numberActiveTouches; - if ( - ResponderEventPlugin.GlobalInteractionHandler && - nativeEvent !== previousActiveTouches - ) - ResponderEventPlugin.GlobalInteractionHandler.onChange(nativeEvent); - previousActiveTouches = nativeEvent; return JSCompiler_temp; }, GlobalResponderHandler: null, - GlobalInteractionHandler: null, injection: { injectGlobalResponderHandler: function(GlobalResponderHandler) { ResponderEventPlugin.GlobalResponderHandler = GlobalResponderHandler; - }, - injectGlobalInteractionHandler: function(GlobalInteractionHandler) { - ResponderEventPlugin.GlobalInteractionHandler = GlobalInteractionHandler; } } }, @@ -1128,8 +1145,6 @@ var ReactCurrentOwner = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, 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, REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108, @@ -1155,8 +1170,6 @@ function getComponentName(fiber) { switch (type) { case REACT_ASYNC_MODE_TYPE: return "AsyncMode"; - case REACT_CALL_TYPE: - return "ReactCall"; case REACT_CONTEXT_TYPE: return "Context.Consumer"; case REACT_FRAGMENT_TYPE: @@ -1167,8 +1180,6 @@ function getComponentName(fiber) { return "Profiler(" + fiber.pendingProps.id + ")"; case REACT_PROVIDER_TYPE: return "Context.Provider"; - case REACT_RETURN_TYPE: - return "ReactReturn"; case REACT_STRICT_MODE_TYPE: return "StrictMode"; } @@ -1386,12 +1397,6 @@ function createFiberFromElement(element, mode, expirationTime) { (type.stateNode = { duration: 0, startTime: 0 }), type ); - case REACT_CALL_TYPE: - fiberTag = 7; - break; - case REACT_RETURN_TYPE: - fiberTag = 9; - break; case REACT_TIMEOUT_TYPE: fiberTag = 16; mode |= 2; @@ -3319,34 +3324,6 @@ function ReactFiberBeginWork( (workInProgress.memoizedProps = workInProgress.pendingProps), null ); - case 8: - workInProgress.tag = 7; - case 7: - return ( - (props = workInProgress.pendingProps), - hasLegacyContextChanged() || - workInProgress.memoizedProps !== props || - (props = workInProgress.memoizedProps), - (fn = props.children), - (workInProgress.stateNode = - null === current - ? mountChildFibers( - workInProgress, - workInProgress.stateNode, - fn, - renderExpirationTime - ) - : reconcileChildFibers( - workInProgress, - current.stateNode, - fn, - renderExpirationTime - )), - (workInProgress.memoizedProps = props), - workInProgress.stateNode - ); - case 9: - return null; case 16: return null; case 4: @@ -3541,7 +3518,7 @@ function ReactFiberCompleteWork( ? invariant(!1, "Persistent reconciler is disabled.") : invariant(!1, "Noop reconciler is disabled."); return { - completeWork: function(current, workInProgress, renderExpirationTime) { + completeWork: function(current, workInProgress) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { case 1: @@ -3561,8 +3538,8 @@ function ReactFiberCompleteWork( return null; case 5: popHostContext(workInProgress); - renderExpirationTime = getRootHostContainer(); - var type = workInProgress.type; + var rootContainerInstance = getRootHostContainer(), + type = workInProgress.type; if (null !== current && null != workInProgress.stateNode) { var oldProps = current.memoizedProps, instance = workInProgress.stateNode, @@ -3572,7 +3549,7 @@ function ReactFiberCompleteWork( type, oldProps, newProps, - renderExpirationTime, + rootContainerInstance, currentHostContext ); updateHostComponent( @@ -3582,7 +3559,7 @@ function ReactFiberCompleteWork( type, oldProps, newProps, - renderExpirationTime, + rootContainerInstance, currentHostContext ); current.ref !== workInProgress.ref && @@ -3600,14 +3577,14 @@ function ReactFiberCompleteWork( if (popHydrationState(workInProgress)) prepareToHydrateHostInstance( workInProgress, - renderExpirationTime, + rootContainerInstance, current ) && markUpdate(workInProgress); else { oldProps = createInstance( type, newProps, - renderExpirationTime, + rootContainerInstance, current, workInProgress ); @@ -3645,7 +3622,7 @@ function ReactFiberCompleteWork( oldProps, type, newProps, - renderExpirationTime, + rootContainerInstance, current ) && markUpdate(workInProgress); workInProgress.stateNode = oldProps; @@ -3670,69 +3647,19 @@ function ReactFiberCompleteWork( ), null ); - current = getRootHostContainer(); - renderExpirationTime = getHostContext(); + rootContainerInstance = getRootHostContainer(); + type = getHostContext(); popHydrationState(workInProgress) ? prepareToHydrateHostTextInstance(workInProgress) && markUpdate(workInProgress) : (workInProgress.stateNode = createTextInstance( newProps, - current, - renderExpirationTime, + rootContainerInstance, + type, workInProgress )); } return null; - case 7: - newProps = workInProgress.memoizedProps; - invariant( - newProps, - "Should be resolved by now. This error is likely caused by a bug in React. Please file an issue." - ); - workInProgress.tag = 8; - type = []; - a: { - if ((oldProps = workInProgress.stateNode)) - oldProps.return = workInProgress; - for (; null !== oldProps; ) { - if ( - 5 === oldProps.tag || - 6 === oldProps.tag || - 4 === oldProps.tag - ) - invariant(!1, "A call cannot have host component children."); - else if (9 === oldProps.tag) - type.push(oldProps.pendingProps.value); - else if (null !== oldProps.child) { - oldProps.child.return = oldProps; - oldProps = oldProps.child; - continue; - } - for (; null === oldProps.sibling; ) { - if ( - null === oldProps.return || - oldProps.return === workInProgress - ) - break a; - oldProps = oldProps.return; - } - oldProps.sibling.return = oldProps.return; - oldProps = oldProps.sibling; - } - } - oldProps = newProps.handler; - newProps = oldProps(newProps.props, type); - workInProgress.child = reconcileChildFibers( - workInProgress, - null !== current ? current.child : null, - newProps, - renderExpirationTime - ); - return workInProgress.child; - case 8: - return (workInProgress.tag = 7), null; - case 9: - return null; case 14: return null; case 16: @@ -3833,28 +3760,10 @@ function ReactFiberCommitWork(config, captureError) { case 5: safelyDetachRef(current); break; - case 7: - commitNestedUnmounts(current.stateNode); - break; case 4: mutation && unmountHostComponents(current); } } - function commitNestedUnmounts(root) { - for (var node = root; ; ) - if ( - (commitUnmount(node), - null === node.child || (mutation && 4 === node.tag)) - ) { - if (node === root) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === root) return; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } else (node.child.return = node), (node = node.child); - } function isHostParent(fiber) { return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag; } @@ -3892,12 +3801,31 @@ function ReactFiberCommitWork(config, captureError) { } currentParentIsValid = !0; } - if (5 === node.tag || 6 === node.tag) - commitNestedUnmounts(node), - currentParentIsContainer - ? removeChildFromContainer(currentParent, node.stateNode) - : removeChild(currentParent, node.stateNode); - else if ( + if (5 === node.tag || 6 === node.tag) { + a: for (var root = node, node$jscomp$0 = root; ; ) + if ( + (commitUnmount(node$jscomp$0), + null === node$jscomp$0.child || + (mutation && 4 === node$jscomp$0.tag)) + ) { + if (node$jscomp$0 === root) break; + for (; null === node$jscomp$0.sibling; ) { + if ( + null === node$jscomp$0.return || + node$jscomp$0.return === root + ) + break a; + node$jscomp$0 = node$jscomp$0.return; + } + node$jscomp$0.sibling.return = node$jscomp$0.return; + node$jscomp$0 = node$jscomp$0.sibling; + } else + (node$jscomp$0.child.return = node$jscomp$0), + (node$jscomp$0 = node$jscomp$0.child); + currentParentIsContainer + ? removeChildFromContainer(currentParent, node.stateNode) + : removeChild(currentParent, node.stateNode); + } else if ( (4 === node.tag ? (currentParent = node.stateNode.containerInfo) : commitUnmount(node),