From d02d86a7c9c104c2948b7fe4ddb5189359cc5019 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 16 Apr 2018 19:36:36 +0200 Subject: [PATCH 01/45] Add TopLevelEventTypes --- .../src/events/BrowserEventConstants.js | 151 +++++++++--------- .../src/events/TopLevelEventTypes.js | 82 ++++++++++ 2 files changed, 158 insertions(+), 75 deletions(-) create mode 100644 packages/react-dom/src/events/TopLevelEventTypes.js diff --git a/packages/react-dom/src/events/BrowserEventConstants.js b/packages/react-dom/src/events/BrowserEventConstants.js index 203752892f69c..c12044d77eb45 100644 --- a/packages/react-dom/src/events/BrowserEventConstants.js +++ b/packages/react-dom/src/events/BrowserEventConstants.js @@ -3,9 +3,13 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. + * + * @flow */ +import * as TopLevelEventTypes from './TopLevelEventTypes'; import getVendorPrefixedEventName from './getVendorPrefixedEventName'; +import type {TopLevelTypes} from './TopLevelEventTypes'; /** * Types of raw signals from the browser caught at the top level. @@ -14,84 +18,81 @@ import getVendorPrefixedEventName from './getVendorPrefixedEventName'; * bubble (which we trap at a lower node than `document`), binding * at `document` would cause duplicate events so we don't include them here. */ -export const topLevelTypes = { - topAnimationEnd: getVendorPrefixedEventName('animationend'), - topAnimationIteration: getVendorPrefixedEventName('animationiteration'), - topAnimationStart: getVendorPrefixedEventName('animationstart'), - topBlur: 'blur', - topCancel: 'cancel', - topChange: 'change', - topClick: 'click', - topClose: 'close', - topCompositionEnd: 'compositionend', - topCompositionStart: 'compositionstart', - topCompositionUpdate: 'compositionupdate', - topContextMenu: 'contextmenu', - topCopy: 'copy', - topCut: 'cut', - topDoubleClick: 'dblclick', - topDrag: 'drag', - topDragEnd: 'dragend', - topDragEnter: 'dragenter', - topDragExit: 'dragexit', - topDragLeave: 'dragleave', - topDragOver: 'dragover', - topDragStart: 'dragstart', - topDrop: 'drop', - topFocus: 'focus', - topInput: 'input', - topKeyDown: 'keydown', - topKeyPress: 'keypress', - topKeyUp: 'keyup', - topLoad: 'load', - topLoadStart: 'loadstart', - topMouseDown: 'mousedown', - topMouseMove: 'mousemove', - topMouseOut: 'mouseout', - topMouseOver: 'mouseover', - topMouseUp: 'mouseup', - topPaste: 'paste', - topScroll: 'scroll', - topSelectionChange: 'selectionchange', - topTextInput: 'textInput', - topToggle: 'toggle', - topTouchCancel: 'touchcancel', - topTouchEnd: 'touchend', - topTouchMove: 'touchmove', - topTouchStart: 'touchstart', - topTransitionEnd: getVendorPrefixedEventName('transitionend'), - topWheel: 'wheel', -}; +export const topLevelTypes: Map = new Map([ + [TopLevelEventTypes.TOP_ANIMATION_END, getVendorPrefixedEventName('animationend')], + [TopLevelEventTypes.TOP_ANIMATION_ITERATION, getVendorPrefixedEventName('animationiteration')], + [TopLevelEventTypes.TOP_ANIMATION_START, getVendorPrefixedEventName('animationstart')], + [TopLevelEventTypes.TOP_BLUR, 'blur'], + [TopLevelEventTypes.TOP_CANCEL, 'cancel'], + [TopLevelEventTypes.TOP_CHANGE, 'change'], + [TopLevelEventTypes.TOP_CLICK, 'click'], + [TopLevelEventTypes.TOP_CLOSE, 'close'], + [TopLevelEventTypes.TOP_COMPOSITION_END, 'compositionend'], + [TopLevelEventTypes.TOP_COMPOSITION_START, 'compositionstart'], + [TopLevelEventTypes.TOP_COMPOSITION_UPDATE, 'compositionupdate'], + [TopLevelEventTypes.TOP_CONTEXT_MENU, 'contextmenu'], + [TopLevelEventTypes.TOP_COPY, 'copy'], + [TopLevelEventTypes.TOP_CUT, 'cut'], + [TopLevelEventTypes.TOP_DOUBLE_CLICK, 'dblclick'], + [TopLevelEventTypes.TOP_DRAG, 'drag'], + [TopLevelEventTypes.TOP_DRAG_END, 'dragend'], + [TopLevelEventTypes.TOP_DRAG_ENTER, 'dragenter'], + [TopLevelEventTypes.TOP_DRAG_EXIT, 'dragexit'], + [TopLevelEventTypes.TOP_DRAG_LEAVE, 'dragleave'], + [TopLevelEventTypes.TOP_DRAG_OVER, 'dragover'], + [TopLevelEventTypes.TOP_DRAG_START, 'dragstart'], + [TopLevelEventTypes.TOP_DROP, 'drop'], + [TopLevelEventTypes.TOP_FOCUS, 'focus'], + [TopLevelEventTypes.TOP_KEY_DOWN, 'keydown'], + [TopLevelEventTypes.TOP_KEY_PRESS, 'keypress'], + [TopLevelEventTypes.TOP_KEY_UP, 'keyup'], + [TopLevelEventTypes.TOP_LOAD, 'load'], + [TopLevelEventTypes.TOP_LOAD_START, 'loadstart'], + [TopLevelEventTypes.TOP_MOUSE_DOWN, 'mousedown'], + [TopLevelEventTypes.TOP_MOUSE_MOVE, 'mousemove'], + [TopLevelEventTypes.TOP_MOUSE_OUT, 'mouseout'], + [TopLevelEventTypes.TOP_MOUSE_OVER, 'mouseover'], + [TopLevelEventTypes.TOP_MOUSE_UP, 'mouseup'], + [TopLevelEventTypes.TOP_PASTE, 'paste'], + [TopLevelEventTypes.TOP_SCROLL, 'scroll'], + [TopLevelEventTypes.TOP_SELECTION_CHANGE, 'selectionchange'], + [TopLevelEventTypes.TOP_TEXT_INPUT, 'textInput'], + [TopLevelEventTypes.TOP_TOGGLE, 'toggle'], + [TopLevelEventTypes.TOP_TOUCH_CANCEL, 'touchcancel'], + [TopLevelEventTypes.TOP_TOUCH_END, 'touchend'], + [TopLevelEventTypes.TOP_TOUCH_MOVE, 'touchmove'], + [TopLevelEventTypes.TOP_TOUCH_START, 'touchstart'], + [TopLevelEventTypes.TOP_TRANSITION_END, getVendorPrefixedEventName('transitionend')], + [TopLevelEventTypes.TOP_WHEEL, 'wheel'], +]); // There are so many media events, it makes sense to just // maintain a list of them. Note these aren't technically // "top-level" since they don't bubble. We should come up // with a better naming convention if we come to refactoring // the event system. -export const mediaEventTypes = { - topAbort: 'abort', - topCanPlay: 'canplay', - topCanPlayThrough: 'canplaythrough', - topDurationChange: 'durationchange', - topEmptied: 'emptied', - topEncrypted: 'encrypted', - topEnded: 'ended', - topError: 'error', - topLoadedData: 'loadeddata', - topLoadedMetadata: 'loadedmetadata', - topLoadStart: 'loadstart', - topPause: 'pause', - topPlay: 'play', - topPlaying: 'playing', - topProgress: 'progress', - topRateChange: 'ratechange', - topSeeked: 'seeked', - topSeeking: 'seeking', - topStalled: 'stalled', - topSuspend: 'suspend', - topTimeUpdate: 'timeupdate', - topVolumeChange: 'volumechange', - topWaiting: 'waiting', -}; - -export type TopLevelTypes = $Enum; +export const mediaEventTypes: Map = new Map([ + [TopLevelEventTypes.TOP_ABORT, 'abort'], + [TopLevelEventTypes.TOP_CAN_PLAY, 'canplay'], + [TopLevelEventTypes.TOP_CAN_PLAY_THROUGH, 'canplaythrough'], + [TopLevelEventTypes.TOP_DURATION_CHANGE, 'durationchange'], + [TopLevelEventTypes.TOP_EMPTIED, 'emptied'], + [TopLevelEventTypes.TOP_ENCRYPTED, 'encrypted'], + [TopLevelEventTypes.TOP_ENDED, 'ended'], + [TopLevelEventTypes.TOP_ERROR, 'error'], + [TopLevelEventTypes.TOP_LOADED_DATA, 'loadeddata'], + [TopLevelEventTypes.TOP_LOADED_METADATA, 'loadedmetadata'], + [TopLevelEventTypes.TOP_LOAD_START, 'loadstart'], + [TopLevelEventTypes.TOP_PAUSE, 'pause'], + [TopLevelEventTypes.TOP_PLAY, 'play'], + [TopLevelEventTypes.TOP_PLAYING, 'playing'], + [TopLevelEventTypes.TOP_PROGRESS, 'progress'], + [TopLevelEventTypes.TOP_RATE_CHANGE, 'ratechange'], + [TopLevelEventTypes.TOP_SEEKED, 'seeked'], + [TopLevelEventTypes.TOP_SEEKING, 'seeking'], + [TopLevelEventTypes.TOP_STALLED, 'stalled'], + [TopLevelEventTypes.TOP_SUSPEND, 'suspend'], + [TopLevelEventTypes.TOP_TIME_UPDATE, 'timeupdate'], + [TopLevelEventTypes.TOP_VOLUME_CHANGE, 'volumechange'], + [TopLevelEventTypes.TOP_WAITING, 'waiting'], +]); diff --git a/packages/react-dom/src/events/TopLevelEventTypes.js b/packages/react-dom/src/events/TopLevelEventTypes.js new file mode 100644 index 0000000000000..8e7eabf5236e6 --- /dev/null +++ b/packages/react-dom/src/events/TopLevelEventTypes.js @@ -0,0 +1,82 @@ +/** + * 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. + * + * @flow + */ + +export const TOP_ABORT = 0; +export const TOP_ANIMATION_END = 1; +export const TOP_ANIMATION_ITERATION = 2; +export const TOP_ANIMATION_START = 3; +export const TOP_BLUR = 4; +export const TOP_CANCEL = 5; +export const TOP_CAN_PLAY = 6; +export const TOP_CAN_PLAY_THROUGH = 7; +export const TOP_CHANGE = 8; +export const TOP_CLICK = 9; +export const TOP_CLOSE = 10; +export const TOP_COMPOSITION_END = 11; +export const TOP_COMPOSITION_START = 12; +export const TOP_COMPOSITION_UPDATE = 13; +export const TOP_CONTEXT_MENU = 14; +export const TOP_COPY = 15; +export const TOP_CUT = 16; +export const TOP_DOUBLE_CLICK = 17; +export const TOP_DRAG = 18; +export const TOP_DRAG_END = 19; +export const TOP_DRAG_ENTER = 20; +export const TOP_DRAG_EXIT = 21; +export const TOP_DRAG_LEAVE = 22; +export const TOP_DRAG_OVER = 23; +export const TOP_DRAG_START = 24; +export const TOP_DROP = 25; +export const TOP_DURATION_CHANGE = 26; +export const TOP_EMPTIED = 27; +export const TOP_ENCRYPTED = 28; +export const TOP_ENDED = 29; +export const TOP_ERROR = 30; +export const TOP_FOCUS = 31; +export const TOP_INPUT = 32; +export const TOP_INVALID = 33; +export const TOP_KEY_DOWN = 34; +export const TOP_KEY_PRESS = 35; +export const TOP_KEY_UP = 36; +export const TOP_LOADED_DATA = 37; +export const TOP_LOAD = 38; +export const TOP_LOADED_METADATA = 39; +export const TOP_LOAD_START = 40; +export const TOP_MOUSE_DOWN = 41; +export const TOP_MOUSE_MOVE = 42; +export const TOP_MOUSE_OUT = 43; +export const TOP_MOUSE_OVER = 44; +export const TOP_MOUSE_UP = 45; +export const TOP_PASTE = 46; +export const TOP_PAUSE = 47; +export const TOP_PLAY = 48; +export const TOP_PLAYING = 49; +export const TOP_PROGRESS = 50; +export const TOP_RATE_CHANGE = 51; +export const TOP_RESET = 52; +export const TOP_SCROLL = 53; +export const TOP_SEEKED = 54; +export const TOP_SEEKING = 55; +export const TOP_SELECTION_CHANGE = 56; +export const TOP_STALLED = 57; +export const TOP_SUBMIT = 58; +export const TOP_SUSPEND = 59; +export const TOP_TEXT_INPUT = 60; +export const TOP_TIME_UPDATE = 61; +export const TOP_TOGGLE = 62; +export const TOP_TOUCH_CANCEL = 63; +export const TOP_TOUCH_END = 64; +export const TOP_TOUCH_MOVE = 65; +export const TOP_TOUCH_START = 66; +export const TOP_TRANSITION_END = 67; +export const TOP_VOLUME_CHANGE = 68; +export const TOP_WAITING = 69; +export const TOP_WHEEL = 70; + +export type TopLevelTypes = number; From 45713ceab9769288bb2b5d7b5b6163f3eef3dcfd Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 16 Apr 2018 19:55:20 +0200 Subject: [PATCH 02/45] Fix `ReactBrowserEventEmitter` --- .../src/events/BrowserEventConstants.js | 4 +++ .../src/events/ReactBrowserEventEmitter.js | 31 ++++++++++++------- .../src/events/ReactDOMEventListener.js | 15 +++++---- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/packages/react-dom/src/events/BrowserEventConstants.js b/packages/react-dom/src/events/BrowserEventConstants.js index c12044d77eb45..03d377314c805 100644 --- a/packages/react-dom/src/events/BrowserEventConstants.js +++ b/packages/react-dom/src/events/BrowserEventConstants.js @@ -96,3 +96,7 @@ export const mediaEventTypes: Map = new Map([ [TopLevelEventTypes.TOP_VOLUME_CHANGE, 'volumechange'], [TopLevelEventTypes.TOP_WAITING, 'waiting'], ]); + +export function getRawEventName(topLevelType: TopLevelTypes): ?string { + return topLevelTypes.get(topLevelType) || mediaEventTypes.get(topLevelType); +} diff --git a/packages/react-dom/src/events/ReactBrowserEventEmitter.js b/packages/react-dom/src/events/ReactBrowserEventEmitter.js index 8991734a750a3..624befa755d95 100644 --- a/packages/react-dom/src/events/ReactBrowserEventEmitter.js +++ b/packages/react-dom/src/events/ReactBrowserEventEmitter.js @@ -6,6 +6,13 @@ */ import {registrationNameDependencies} from 'events/EventPluginRegistry'; +import { + TOP_BLUR, + TOP_CANCEL, + TOP_CLOSE, + TOP_FOCUS, + TOP_SCROLL, +} from './TopLevelEventTypes'; import { setEnabled, isEnabled, @@ -13,7 +20,7 @@ import { trapCapturedEvent, } from './ReactDOMEventListener'; import isEventSupported from './isEventSupported'; -import {topLevelTypes} from './BrowserEventConstants'; +import {getRawEventName} from './BrowserEventConstants'; /** * Summary of `ReactBrowserEventEmitter` event handling: @@ -118,27 +125,27 @@ export function listenTo(registrationName, contentDocumentHandle) { for (let i = 0; i < dependencies.length; i++) { const dependency = dependencies[i]; if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) { - if (dependency === 'topScroll') { - trapCapturedEvent('topScroll', 'scroll', mountAt); - } else if (dependency === 'topFocus' || dependency === 'topBlur') { - trapCapturedEvent('topFocus', 'focus', mountAt); - trapCapturedEvent('topBlur', 'blur', mountAt); + if (dependency === TOP_SCROLL) { + trapCapturedEvent(TOP_SCROLL, mountAt); + } else if (dependency === TOP_FOCUS || dependency === TOP_BLUR) { + trapCapturedEvent(TOP_FOCUS, mountAt); + trapCapturedEvent(TOP_BLUR, mountAt); // to make sure blur and focus event listeners are only attached once isListening.topBlur = true; isListening.topFocus = true; - } else if (dependency === 'topCancel') { + } else if (dependency === TOP_CANCEL) { if (isEventSupported('cancel', true)) { - trapCapturedEvent('topCancel', 'cancel', mountAt); + trapCapturedEvent(TOP_CANCEL, mountAt); } isListening.topCancel = true; - } else if (dependency === 'topClose') { + } else if (dependency === TOP_CLOSE) { if (isEventSupported('close', true)) { - trapCapturedEvent('topClose', 'close', mountAt); + trapCapturedEvent(TOP_CLOSE, mountAt); } isListening.topClose = true; - } else if (topLevelTypes.hasOwnProperty(dependency)) { - trapBubbledEvent(dependency, topLevelTypes[dependency], mountAt); + } else if (getRawEventName(dependency)) { + trapBubbledEvent(dependency, mountAt); } isListening[dependency] = true; diff --git a/packages/react-dom/src/events/ReactDOMEventListener.js b/packages/react-dom/src/events/ReactDOMEventListener.js index df831eb848224..fd0cf0580652f 100644 --- a/packages/react-dom/src/events/ReactDOMEventListener.js +++ b/packages/react-dom/src/events/ReactDOMEventListener.js @@ -14,6 +14,7 @@ import {addEventBubbleListener, addEventCaptureListener} from './EventListener'; import getEventTarget from './getEventTarget'; import {getClosestInstanceFromNode} from '../client/ReactDOMComponentTree'; import SimpleEventPlugin from './SimpleEventPlugin'; +import {getRawEventName} from './BrowserEventConstants'; const {isInteractiveTopLevelEventType} = SimpleEventPlugin; @@ -112,14 +113,13 @@ export function isEnabled() { /** * Traps top-level events by using event bubbling. * - * @param {string} topLevelType Record from `BrowserEventConstants`. - * @param {string} handlerBaseName Event name (e.g. "click"). + * @param {number} topLevelType Number from `TopLevelEventTypes`. * @param {object} element Element on which to attach listener. * @return {?object} An object with a remove function which will forcefully * remove the listener. * @internal */ -export function trapBubbledEvent(topLevelType, handlerBaseName, element) { +export function trapBubbledEvent(topLevelType, element) { if (!element) { return null; } @@ -129,7 +129,7 @@ export function trapBubbledEvent(topLevelType, handlerBaseName, element) { addEventBubbleListener( element, - handlerBaseName, + getRawEventName(topLevelType), // Check if interactive and wrap in interactiveUpdates dispatch.bind(null, topLevelType), ); @@ -138,14 +138,13 @@ export function trapBubbledEvent(topLevelType, handlerBaseName, element) { /** * Traps a top-level event by using event capturing. * - * @param {string} topLevelType Record from `BrowserEventConstants`. - * @param {string} handlerBaseName Event name (e.g. "click"). + * @param {number} topLevelType Number from `TopLevelEventTypes`. * @param {object} element Element on which to attach listener. * @return {?object} An object with a remove function which will forcefully * remove the listener. * @internal */ -export function trapCapturedEvent(topLevelType, handlerBaseName, element) { +export function trapCapturedEvent(topLevelType, element) { if (!element) { return null; } @@ -155,7 +154,7 @@ export function trapCapturedEvent(topLevelType, handlerBaseName, element) { addEventCaptureListener( element, - handlerBaseName, + getRawEventName(topLevelType), // Check if interactive and wrap in interactiveUpdates dispatch.bind(null, topLevelType), ); From 5f11da0c79c3587b8f32e5675a36dd8a57e21443 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 16 Apr 2018 20:01:22 +0200 Subject: [PATCH 03/45] Fix EventPluginUtils --- packages/events/EventPluginUtils.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/events/EventPluginUtils.js b/packages/events/EventPluginUtils.js index d5e5a5e847754..dbb2c7fa33565 100644 --- a/packages/events/EventPluginUtils.js +++ b/packages/events/EventPluginUtils.js @@ -9,6 +9,16 @@ import ReactErrorUtils from 'shared/ReactErrorUtils'; import invariant from 'fbjs/lib/invariant'; import warning from 'fbjs/lib/warning'; +import { + TOP_MOUSE_DOWN, + TOP_MOUSE_MOVE, + TOP_MOUSE_UP, + TOP_TOUCH_CANCEL, + TOP_TOUCH_END, + TOP_TOUCH_MOVE, + TOP_TOUCH_START, +} from './TopLevelEventTypes'; + export let getFiberCurrentPropsFromNode = null; export let getInstanceFromNode = null; export let getNodeFromInstance = null; @@ -32,17 +42,17 @@ export const injection = { export function isEndish(topLevelType) { return ( - topLevelType === 'topMouseUp' || - topLevelType === 'topTouchEnd' || - topLevelType === 'topTouchCancel' + topLevelType === TOP_MOUSE_UP || + topLevelType === TOP_TOUCH_END || + topLevelType === TOP_TOUCH_CANCEL ); } export function isMoveish(topLevelType) { - return topLevelType === 'topMouseMove' || topLevelType === 'topTouchMove'; + return topLevelType === TOP_MOUSE_MOVE || topLevelType === TOP_TOUCH_MOVE; } export function isStartish(topLevelType) { - return topLevelType === 'topMouseDown' || topLevelType === 'topTouchStart'; + return topLevelType === TOP_MOUSE_DOWN || topLevelType === TOP_TOUCH_START; } let validateEventDispatches; From 58a24ba66b7faaf138518773f1966a8a9c3e41db Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 16 Apr 2018 20:01:27 +0200 Subject: [PATCH 04/45] Fix TapEventPlugin --- .../react-dom/src/events/TapEventPlugin.js | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/packages/react-dom/src/events/TapEventPlugin.js b/packages/react-dom/src/events/TapEventPlugin.js index e1e67a5d70ef9..168b531d0b68e 100644 --- a/packages/react-dom/src/events/TapEventPlugin.js +++ b/packages/react-dom/src/events/TapEventPlugin.js @@ -10,6 +10,16 @@ import {isStartish, isEndish} from 'events/EventPluginUtils'; import {accumulateTwoPhaseDispatches} from 'events/EventPropagators'; import TouchEventUtils from 'fbjs/lib/TouchEventUtils'; +import { + TOP_MOUSE_DOWN, + TOP_MOUSE_MOVE, + TOP_MOUSE_UP, + TOP_TOUCH_CANCEL, + TOP_TOUCH_END, + TOP_TOUCH_MOVE, + TOP_TOUCH_START, +} from './TopLevelEventTypes'; +import type {TopLevelTypes} from './TopLevelEventTypes'; import SyntheticUIEvent from './SyntheticUIEvent'; @@ -75,13 +85,17 @@ function getDistance(coords: CoordinatesType, nativeEvent: _Touch): number { } const touchEvents = [ - 'topTouchStart', - 'topTouchCancel', - 'topTouchEnd', - 'topTouchMove', + TOP_TOUCH_START, + TOP_TOUCH_CANCEL, + TOP_TOUCH_END, + TOP_TOUCH_MOVE, ]; -const dependencies = ['topMouseDown', 'topMouseMove', 'topMouseUp'].concat( +const dependencies = [ + TOP_MOUSE_DOWN, + TOP_MOUSE_MOVE, + TOP_MOUSE_UP, +].concat( touchEvents, ); @@ -105,7 +119,7 @@ const TapEventPlugin = { eventTypes: eventTypes, extractEvents: function( - topLevelType: mixed, + topLevelType: TopLevelTypes, targetInst: mixed, nativeEvent: _Touch, nativeEventTarget: EventTarget, From 390fb516999078e639f34b6e557be36156290bcb Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 16 Apr 2018 20:05:09 +0200 Subject: [PATCH 05/45] Fix ResponderEventPlugin --- packages/events/ResponderEventPlugin.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/events/ResponderEventPlugin.js b/packages/events/ResponderEventPlugin.js index 202f8931f991f..e4a01add7efe4 100644 --- a/packages/events/ResponderEventPlugin.js +++ b/packages/events/ResponderEventPlugin.js @@ -23,6 +23,11 @@ import { } from './EventPropagators'; import ResponderSyntheticEvent from './ResponderSyntheticEvent'; import ResponderTouchHistoryStore from './ResponderTouchHistoryStore'; +import { + TOP_SCROLL, + TOP_SELECTION_CHANGE, + TOP_TOUCH_CANCEL, +} from './TopLevelEventTypes'; import accumulate from './accumulate'; /** @@ -322,7 +327,7 @@ function setResponderAndExtractTransfer( ? eventTypes.startShouldSetResponder : isMoveish(topLevelType) ? eventTypes.moveShouldSetResponder - : topLevelType === 'topSelectionChange' + : topLevelType === TOP_SELECTION_CHANGE ? eventTypes.selectionChangeShouldSetResponder : eventTypes.scrollShouldSetResponder; @@ -418,7 +423,7 @@ function setResponderAndExtractTransfer( * element to claim responder status. Any start event could trigger a transfer * of responderInst. Any move event could trigger a transfer. * - * @param {string} topLevelType Record from `BrowserEventConstants`. + * @param {number} topLevelType Number from `TopLevelEventTypes`. * @return {boolean} True if a transfer of responder could possibly occur. */ function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) { @@ -427,8 +432,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)) ); @@ -534,7 +539,7 @@ const ResponderEventPlugin = { } const isResponderTerminate = - responderInst && topLevelType === 'topTouchCancel'; + responderInst && topLevelType === TOP_TOUCH_CANCEL; const isResponderRelease = responderInst && !isResponderTerminate && From 3dcbf4db8b32996a1fe755609298d0b5d0716938 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 16 Apr 2018 20:22:40 +0200 Subject: [PATCH 06/45] Update ReactDOMFiberComponent --- .../src/client/ReactDOMFiberComponent.js | 64 ++++++++++--------- .../src/events/BrowserEventConstants.js | 16 ++++- 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/packages/react-dom/src/client/ReactDOMFiberComponent.js b/packages/react-dom/src/client/ReactDOMFiberComponent.js index ceb20873c2af2..543a4a3ac2531 100644 --- a/packages/react-dom/src/client/ReactDOMFiberComponent.js +++ b/packages/react-dom/src/client/ReactDOMFiberComponent.js @@ -10,6 +10,14 @@ // TODO: direct imports like some-package/src/* are bad. Fix me. import ReactDebugCurrentFiber from 'react-reconciler/src/ReactDebugCurrentFiber'; import {registrationNameModules} from 'events/EventPluginRegistry'; +import { + TOP_ERROR, + TOP_INVALID, + TOP_LOAD, + TOP_RESET, + TOP_SUBMIT, + TOP_TOGGLE, +} from '../events/TopLevelEventTypes'; import emptyFunction from 'fbjs/lib/emptyFunction'; import warning from 'fbjs/lib/warning'; @@ -440,43 +448,41 @@ export function setInitialProperties( switch (tag) { case 'iframe': case 'object': - trapBubbledEvent('topLoad', 'load', domElement); + trapBubbledEvent(TOP_LOAD, domElement); props = rawProps; break; case 'video': case 'audio': // Create listener for each media event - for (const event in mediaEventTypes) { - if (mediaEventTypes.hasOwnProperty(event)) { - trapBubbledEvent(event, mediaEventTypes[event], domElement); - } - } + mediaEventTypes.forEach(topEventName => { + trapBubbledEvent(topEventName, domElement); + }); props = rawProps; break; case 'source': - trapBubbledEvent('topError', 'error', domElement); + trapBubbledEvent(TOP_ERROR, domElement); props = rawProps; break; case 'img': case 'image': case 'link': - trapBubbledEvent('topError', 'error', domElement); - trapBubbledEvent('topLoad', 'load', domElement); + trapBubbledEvent(TOP_ERROR, domElement); + trapBubbledEvent(TOP_LOAD, domElement); props = rawProps; break; case 'form': - trapBubbledEvent('topReset', 'reset', domElement); - trapBubbledEvent('topSubmit', 'submit', domElement); + trapBubbledEvent(TOP_RESET, domElement); + trapBubbledEvent(TOP_SUBMIT, domElement); props = rawProps; break; case 'details': - trapBubbledEvent('topToggle', 'toggle', domElement); + trapBubbledEvent(TOP_TOGGLE, domElement); props = rawProps; break; case 'input': ReactDOMFiberInput.initWrapperState(domElement, rawProps); props = ReactDOMFiberInput.getHostProps(domElement, rawProps); - trapBubbledEvent('topInvalid', 'invalid', domElement); + trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening // to onChange. Even if there is no listener. ensureListeningTo(rootContainerElement, 'onChange'); @@ -488,7 +494,7 @@ export function setInitialProperties( case 'select': ReactDOMFiberSelect.initWrapperState(domElement, rawProps); props = ReactDOMFiberSelect.getHostProps(domElement, rawProps); - trapBubbledEvent('topInvalid', 'invalid', domElement); + trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening // to onChange. Even if there is no listener. ensureListeningTo(rootContainerElement, 'onChange'); @@ -496,7 +502,7 @@ export function setInitialProperties( case 'textarea': ReactDOMFiberTextarea.initWrapperState(domElement, rawProps); props = ReactDOMFiberTextarea.getHostProps(domElement, rawProps); - trapBubbledEvent('topInvalid', 'invalid', domElement); + trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening // to onChange. Even if there is no listener. ensureListeningTo(rootContainerElement, 'onChange'); @@ -829,36 +835,34 @@ export function diffHydratedProperties( switch (tag) { case 'iframe': case 'object': - trapBubbledEvent('topLoad', 'load', domElement); + trapBubbledEvent(TOP_LOAD, domElement); break; case 'video': case 'audio': // Create listener for each media event - for (const event in mediaEventTypes) { - if (mediaEventTypes.hasOwnProperty(event)) { - trapBubbledEvent(event, mediaEventTypes[event], domElement); - } - } + mediaEventTypes.forEach(topEventName => { + trapBubbledEvent(topEventName, domElement); + }); break; case 'source': - trapBubbledEvent('topError', 'error', domElement); + trapBubbledEvent(TOP_ERROR, domElement); break; case 'img': case 'image': case 'link': - trapBubbledEvent('topError', 'error', domElement); - trapBubbledEvent('topLoad', 'load', domElement); + trapBubbledEvent(TOP_ERROR, domElement); + trapBubbledEvent(TOP_LOAD, domElement); break; case 'form': - trapBubbledEvent('topReset', 'reset', domElement); - trapBubbledEvent('topSubmit', 'submit', domElement); + trapBubbledEvent(TOP_RESET, domElement); + trapBubbledEvent(TOP_SUBMIT, domElement); break; case 'details': - trapBubbledEvent('topToggle', 'toggle', domElement); + trapBubbledEvent(TOP_TOGGLE, domElement); break; case 'input': ReactDOMFiberInput.initWrapperState(domElement, rawProps); - trapBubbledEvent('topInvalid', 'invalid', domElement); + trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening // to onChange. Even if there is no listener. ensureListeningTo(rootContainerElement, 'onChange'); @@ -868,14 +872,14 @@ export function diffHydratedProperties( break; case 'select': ReactDOMFiberSelect.initWrapperState(domElement, rawProps); - trapBubbledEvent('topInvalid', 'invalid', domElement); + trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening // to onChange. Even if there is no listener. ensureListeningTo(rootContainerElement, 'onChange'); break; case 'textarea': ReactDOMFiberTextarea.initWrapperState(domElement, rawProps); - trapBubbledEvent('topInvalid', 'invalid', domElement); + trapBubbledEvent(TOP_INVALID, domElement); // For controlled components we always need to ensure we're listening // to onChange. Even if there is no listener. ensureListeningTo(rootContainerElement, 'onChange'); diff --git a/packages/react-dom/src/events/BrowserEventConstants.js b/packages/react-dom/src/events/BrowserEventConstants.js index 03d377314c805..d6a478f9744d5 100644 --- a/packages/react-dom/src/events/BrowserEventConstants.js +++ b/packages/react-dom/src/events/BrowserEventConstants.js @@ -97,6 +97,20 @@ export const mediaEventTypes: Map = new Map([ [TopLevelEventTypes.TOP_WAITING, 'waiting'], ]); +const nonTopEventTypes: Map = new Map([ + // [TopLevelEventTypes.TOP_INPUT, 'abort'], + [TopLevelEventTypes.TOP_INVALID, 'invalid'], + [TopLevelEventTypes.TOP_RESET, 'reset'], + [TopLevelEventTypes.TOP_SUBMIT, 'submit'], +]); + export function getRawEventName(topLevelType: TopLevelTypes): ?string { - return topLevelTypes.get(topLevelType) || mediaEventTypes.get(topLevelType); + const eventName: ?string = topLevelTypes.get(topLevelType) + || mediaEventTypes.get(topLevelType) + || nonTopEventTypes.get(topLevelType); + + if (!eventName) { + throw new Error(`Not handling ${topLevelType}`); + } + return null; } From 1fb5cd8720168e7e371ea105d46bcdbb84b35c8b Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 16 Apr 2018 20:28:30 +0200 Subject: [PATCH 07/45] Fix BeforeInputEventPlugin --- .../src/events/BeforeInputEventPlugin.js | 92 +++++++++++-------- .../src/events/BrowserEventConstants.js | 2 +- 2 files changed, 53 insertions(+), 41 deletions(-) diff --git a/packages/react-dom/src/events/BeforeInputEventPlugin.js b/packages/react-dom/src/events/BeforeInputEventPlugin.js index 3307a70bdec6c..a7ec9f7f7b3ce 100644 --- a/packages/react-dom/src/events/BeforeInputEventPlugin.js +++ b/packages/react-dom/src/events/BeforeInputEventPlugin.js @@ -5,9 +5,21 @@ * LICENSE file in the root directory of this source tree. */ -import type {TopLevelTypes} from './BrowserEventConstants'; +import type {TopLevelTypes} from './TopLevelEventTypes'; import {accumulateTwoPhaseDispatches} from 'events/EventPropagators'; +import { + TOP_BLUR, + TOP_COMPOSITION_START, + TOP_COMPOSITION_END, + TOP_COMPOSITION_UPDATE, + TOP_KEY_DOWN, + TOP_KEY_PRESS, + TOP_KEY_UP, + TOP_MOUSE_DOWN, + TOP_TEXT_INPUT, + TOP_PASTE, +} from './TopLevelEventTypes'; import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment'; import * as FallbackCompositionState from './FallbackCompositionState'; @@ -50,10 +62,10 @@ const eventTypes = { captured: 'onBeforeInputCapture', }, dependencies: [ - 'topCompositionEnd', - 'topKeyPress', - 'topTextInput', - 'topPaste', + TOP_COMPOSITION_END, + TOP_KEY_PRESS, + TOP_TEXT_INPUT, + TOP_PASTE, ], }, compositionEnd: { @@ -62,12 +74,12 @@ const eventTypes = { captured: 'onCompositionEndCapture', }, dependencies: [ - 'topBlur', - 'topCompositionEnd', - 'topKeyDown', - 'topKeyPress', - 'topKeyUp', - 'topMouseDown', + TOP_BLUR, + TOP_COMPOSITION_END, + TOP_KEY_DOWN, + TOP_KEY_PRESS, + TOP_KEY_UP, + TOP_MOUSE_DOWN, ], }, compositionStart: { @@ -76,12 +88,12 @@ const eventTypes = { captured: 'onCompositionStartCapture', }, dependencies: [ - 'topBlur', - 'topCompositionStart', - 'topKeyDown', - 'topKeyPress', - 'topKeyUp', - 'topMouseDown', + TOP_BLUR, + TOP_COMPOSITION_START, + TOP_KEY_DOWN, + TOP_KEY_PRESS, + TOP_KEY_UP, + TOP_MOUSE_DOWN, ], }, compositionUpdate: { @@ -90,12 +102,12 @@ const eventTypes = { captured: 'onCompositionUpdateCapture', }, dependencies: [ - 'topBlur', - 'topCompositionUpdate', - 'topKeyDown', - 'topKeyPress', - 'topKeyUp', - 'topMouseDown', + TOP_BLUR, + TOP_COMPOSITION_UPDATE, + TOP_KEY_DOWN, + TOP_KEY_PRESS, + TOP_KEY_UP, + TOP_MOUSE_DOWN, ], }, }; @@ -124,11 +136,11 @@ function isKeypressCommand(nativeEvent) { */ function getCompositionEventType(topLevelType) { switch (topLevelType) { - case 'topCompositionStart': + case TOP_COMPOSITION_START: return eventTypes.compositionStart; - case 'topCompositionEnd': + case TOP_COMPOSITION_END: return eventTypes.compositionEnd; - case 'topCompositionUpdate': + case TOP_COMPOSITION_UPDATE: return eventTypes.compositionUpdate; } } @@ -142,7 +154,7 @@ function getCompositionEventType(topLevelType) { * @return {boolean} */ function isFallbackCompositionStart(topLevelType, nativeEvent) { - return topLevelType === 'topKeyDown' && nativeEvent.keyCode === START_KEYCODE; + return topLevelType === TOP_KEY_DOWN && nativeEvent.keyCode === START_KEYCODE; } /** @@ -154,16 +166,16 @@ function isFallbackCompositionStart(topLevelType, nativeEvent) { */ function isFallbackCompositionEnd(topLevelType, nativeEvent) { switch (topLevelType) { - case 'topKeyUp': + case TOP_KEY_UP: // Command keys insert or clear IME input. return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1; - case 'topKeyDown': + case TOP_KEY_DOWN: // Expect IME keyCode on each keydown. If we get any other // code we must have exited earlier. return nativeEvent.keyCode !== START_KEYCODE; - case 'topKeyPress': - case 'topMouseDown': - case 'topBlur': + case TOP_KEY_PRESS: + case TOP_MOUSE_DOWN: + case TOP_BLUR: // Events are not possible without cancelling IME. return true; default: @@ -252,15 +264,15 @@ function extractCompositionEvent( } /** - * @param {TopLevelTypes} topLevelType Record from `BrowserEventConstants`. + * @param {TopLevelTypes} topLevelType Number from `TopLevelTypes`. * @param {object} nativeEvent Native browser event. * @return {?string} The string corresponding to this `beforeInput` event. */ function getNativeBeforeInputChars(topLevelType: TopLevelTypes, nativeEvent) { switch (topLevelType) { - case 'topCompositionEnd': + case TOP_COMPOSITION_END: return getDataFromCustomEvent(nativeEvent); - case 'topKeyPress': + case TOP_KEY_PRESS: /** * If native `textInput` events are available, our goal is to make * use of them. However, there is a special case: the spacebar key. @@ -283,7 +295,7 @@ function getNativeBeforeInputChars(topLevelType: TopLevelTypes, nativeEvent) { hasSpaceKeypress = true; return SPACEBAR_CHAR; - case 'topTextInput': + case TOP_TEXT_INPUT: // Record the characters to be added to the DOM. const chars = nativeEvent.data; @@ -317,7 +329,7 @@ function getFallbackBeforeInputChars(topLevelType: TopLevelTypes, nativeEvent) { // compositionevent, otherwise extract it at fallback events. if (isComposing) { if ( - topLevelType === 'topCompositionEnd' || + topLevelType === TOP_COMPOSITION_END || (!canUseCompositionEvent && isFallbackCompositionEnd(topLevelType, nativeEvent)) ) { @@ -330,11 +342,11 @@ function getFallbackBeforeInputChars(topLevelType: TopLevelTypes, nativeEvent) { } switch (topLevelType) { - case 'topPaste': + case TOP_PASTE: // If a paste event occurs after a keypress, throw out the input // chars. Paste events should not lead to BeforeInput events. return null; - case 'topKeyPress': + case TOP_KEY_PRESS: /** * As of v27, Firefox may fire keypress events even when no character * will be inserted. A few possibilities: @@ -365,7 +377,7 @@ function getFallbackBeforeInputChars(topLevelType: TopLevelTypes, nativeEvent) { } } return null; - case 'topCompositionEnd': + case TOP_COMPOSITION_END: return useFallbackCompositionData ? null : nativeEvent.data; default: return null; diff --git a/packages/react-dom/src/events/BrowserEventConstants.js b/packages/react-dom/src/events/BrowserEventConstants.js index d6a478f9744d5..5837c7765355a 100644 --- a/packages/react-dom/src/events/BrowserEventConstants.js +++ b/packages/react-dom/src/events/BrowserEventConstants.js @@ -98,7 +98,7 @@ export const mediaEventTypes: Map = new Map([ ]); const nonTopEventTypes: Map = new Map([ - // [TopLevelEventTypes.TOP_INPUT, 'abort'], + // [TopLevelEventTypes.TOP_INPUT, 'input'], [TopLevelEventTypes.TOP_INVALID, 'invalid'], [TopLevelEventTypes.TOP_RESET, 'reset'], [TopLevelEventTypes.TOP_SUBMIT, 'submit'], From 96ce3cd8ace31d78c0a6f5e0f30a61d1374e141b Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 16 Apr 2018 20:31:46 +0200 Subject: [PATCH 08/45] Fix ChangeEventPlugin --- .../react-dom/src/events/ChangeEventPlugin.js | 44 ++++++++++++------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/packages/react-dom/src/events/ChangeEventPlugin.js b/packages/react-dom/src/events/ChangeEventPlugin.js index 5e0dcbb3be4b9..2bdf3409b125d 100644 --- a/packages/react-dom/src/events/ChangeEventPlugin.js +++ b/packages/react-dom/src/events/ChangeEventPlugin.js @@ -10,6 +10,16 @@ import {accumulateTwoPhaseDispatches} from 'events/EventPropagators'; import {enqueueStateRestore} from 'events/ReactControlledComponent'; import {batchedUpdates} from 'events/ReactGenericBatching'; import SyntheticEvent from 'events/SyntheticEvent'; +import { + TOP_BLUR, + TOP_CHANGE, + TOP_CLICK, + TOP_FOCUS, + TOP_INPUT, + TOP_KEY_DOWN, + TOP_KEY_UP, + TOP_SELECTION_CHANGE, +} from './TopLevelEventTypes'; import isTextInputElement from 'shared/isTextInputElement'; import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment'; @@ -26,14 +36,14 @@ const eventTypes = { captured: 'onChangeCapture', }, dependencies: [ - 'topBlur', - 'topChange', - 'topClick', - 'topFocus', - 'topInput', - 'topKeyDown', - 'topKeyUp', - 'topSelectionChange', + TOP_BLUR, + TOP_CHANGE, + TOP_CLICK, + TOP_FOCUS, + TOP_INPUT, + TOP_KEY_DOWN, + TOP_KEY_UP, + TOP_SELECTION_CHANGE, ], }, }; @@ -100,7 +110,7 @@ function getInstIfValueChanged(targetInst) { } function getTargetInstForChangeEvent(topLevelType, targetInst) { - if (topLevelType === 'topChange') { + if (topLevelType === TOP_CHANGE) { return targetInst; } } @@ -155,7 +165,7 @@ function handlePropertyChange(nativeEvent) { } function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) { - if (topLevelType === 'topFocus') { + if (topLevelType === TOP_FOCUS) { // In IE9, propertychange fires for most input events but is buggy and // doesn't fire when text is deleted, but conveniently, selectionchange // appears to fire in all of the remaining cases so we catch those and @@ -168,7 +178,7 @@ function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) { // missed a blur event somehow. stopWatchingForValueChange(); startWatchingForValueChange(target, targetInst); - } else if (topLevelType === 'topBlur') { + } else if (topLevelType === TOP_BLUR) { stopWatchingForValueChange(); } } @@ -176,9 +186,9 @@ function handleEventsForInputEventPolyfill(topLevelType, target, targetInst) { // For IE8 and IE9. function getTargetInstForInputEventPolyfill(topLevelType, targetInst) { if ( - topLevelType === 'topSelectionChange' || - topLevelType === 'topKeyUp' || - topLevelType === 'topKeyDown' + topLevelType === TOP_SELECTION_CHANGE || + topLevelType === TOP_KEY_UP || + topLevelType === TOP_KEY_DOWN ) { // On the selectionchange event, the target is just document which isn't // helpful for us so just check activeElement instead. @@ -210,13 +220,13 @@ function shouldUseClickEvent(elem) { } function getTargetInstForClickEvent(topLevelType, targetInst) { - if (topLevelType === 'topClick') { + if (topLevelType === TOP_CLICK) { return getInstIfValueChanged(targetInst); } } function getTargetInstForInputOrChangeEvent(topLevelType, targetInst) { - if (topLevelType === 'topInput' || topLevelType === 'topChange') { + if (topLevelType === TOP_INPUT || topLevelType === TOP_CHANGE) { return getInstIfValueChanged(targetInst); } } @@ -292,7 +302,7 @@ const ChangeEventPlugin = { } // When blurring, set the value attribute for number inputs - if (topLevelType === 'topBlur') { + if (topLevelType === TOP_BLUR) { handleControlledInputBlur(targetInst, targetNode); } }, From 737626a941e5c2a999550655eb57eba4e6e81f4e Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 16 Apr 2018 20:33:22 +0200 Subject: [PATCH 09/45] Fix EnterLeaveEventPlugin --- .../react-dom/src/events/EnterLeaveEventPlugin.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/react-dom/src/events/EnterLeaveEventPlugin.js b/packages/react-dom/src/events/EnterLeaveEventPlugin.js index 9a2be568c108c..2c1fdec3cf0c4 100644 --- a/packages/react-dom/src/events/EnterLeaveEventPlugin.js +++ b/packages/react-dom/src/events/EnterLeaveEventPlugin.js @@ -6,6 +6,7 @@ */ import {accumulateEnterLeaveDispatches} from 'events/EventPropagators'; +import {TOP_MOUSE_OUT, TOP_MOUSE_OVER} from './TopLevelEventTypes'; import SyntheticMouseEvent from './SyntheticMouseEvent'; import { @@ -16,11 +17,11 @@ import { const eventTypes = { mouseEnter: { registrationName: 'onMouseEnter', - dependencies: ['topMouseOut', 'topMouseOver'], + dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER], }, mouseLeave: { registrationName: 'onMouseLeave', - dependencies: ['topMouseOut', 'topMouseOver'], + dependencies: [TOP_MOUSE_OUT, TOP_MOUSE_OVER], }, }; @@ -41,12 +42,12 @@ const EnterLeaveEventPlugin = { nativeEventTarget, ) { if ( - topLevelType === 'topMouseOver' && + topLevelType === TOP_MOUSE_OVER && (nativeEvent.relatedTarget || nativeEvent.fromElement) ) { return null; } - if (topLevelType !== 'topMouseOut' && topLevelType !== 'topMouseOver') { + if (topLevelType !== TOP_MOUSE_OUT && topLevelType !== TOP_MOUSE_OVER) { // Must not be a mouse in or mouse out - ignoring. return null; } @@ -67,7 +68,7 @@ const EnterLeaveEventPlugin = { let from; let to; - if (topLevelType === 'topMouseOut') { + if (topLevelType === TOP_MOUSE_OUT) { from = targetInst; const related = nativeEvent.relatedTarget || nativeEvent.toElement; to = related ? getClosestInstanceFromNode(related) : null; From a03d896bb712e1716fea4a1d6549cb9e66435ff5 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 16 Apr 2018 20:35:02 +0200 Subject: [PATCH 10/45] Add missing non top event type used in ChangeEventPlugin --- packages/react-dom/src/events/BrowserEventConstants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dom/src/events/BrowserEventConstants.js b/packages/react-dom/src/events/BrowserEventConstants.js index 5837c7765355a..081e7c2038cca 100644 --- a/packages/react-dom/src/events/BrowserEventConstants.js +++ b/packages/react-dom/src/events/BrowserEventConstants.js @@ -98,7 +98,7 @@ export const mediaEventTypes: Map = new Map([ ]); const nonTopEventTypes: Map = new Map([ - // [TopLevelEventTypes.TOP_INPUT, 'input'], + [TopLevelEventTypes.TOP_INPUT, 'input'], [TopLevelEventTypes.TOP_INVALID, 'invalid'], [TopLevelEventTypes.TOP_RESET, 'reset'], [TopLevelEventTypes.TOP_SUBMIT, 'submit'], From d58cd301a56f00a03c58fe205993b9cdad68bb8c Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 16 Apr 2018 20:35:11 +0200 Subject: [PATCH 11/45] Fix SelectEventPlugin --- .../react-dom/src/events/SelectEventPlugin.js | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/packages/react-dom/src/events/SelectEventPlugin.js b/packages/react-dom/src/events/SelectEventPlugin.js index e6193c7973a8c..9243d2f1743a4 100644 --- a/packages/react-dom/src/events/SelectEventPlugin.js +++ b/packages/react-dom/src/events/SelectEventPlugin.js @@ -8,6 +8,16 @@ import {accumulateTwoPhaseDispatches} from 'events/EventPropagators'; import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment'; import SyntheticEvent from 'events/SyntheticEvent'; +import { + TOP_BLUR, + TOP_CONTEXT_MENU, + TOP_FOCUS, + TOP_KEY_DOWN, + TOP_KEY_UP, + TOP_MOUSE_DOWN, + TOP_MOUSE_UP, + TOP_SELECTION_CHANGE, +} from './TopLevelEventTypes'; import isTextInputElement from 'shared/isTextInputElement'; import getActiveElement from 'fbjs/lib/getActiveElement'; import shallowEqual from 'fbjs/lib/shallowEqual'; @@ -29,14 +39,14 @@ const eventTypes = { captured: 'onSelectCapture', }, dependencies: [ - 'topBlur', - 'topContextMenu', - 'topFocus', - 'topKeyDown', - 'topKeyUp', - 'topMouseDown', - 'topMouseUp', - 'topSelectionChange', + TOP_BLUR, + TOP_CONTEXT_MENU, + TOP_FOCUS, + TOP_KEY_DOWN, + TOP_KEY_UP, + TOP_MOUSE_DOWN, + TOP_MOUSE_UP, + TOP_SELECTION_CHANGE, ], }, }; @@ -156,7 +166,7 @@ const SelectEventPlugin = { switch (topLevelType) { // Track the input node that has focus. - case 'topFocus': + case TOP_FOCUS: if ( isTextInputElement(targetNode) || targetNode.contentEditable === 'true' @@ -166,18 +176,18 @@ const SelectEventPlugin = { lastSelection = null; } break; - case 'topBlur': + case TOP_BLUR: activeElement = null; activeElementInst = null; lastSelection = null; break; // Don't fire the event while the user is dragging. This matches the // semantics of the native select event. - case 'topMouseDown': + case TOP_MOUSE_DOWN: mouseDown = true; break; - case 'topContextMenu': - case 'topMouseUp': + case TOP_CONTEXT_MENU: + case TOP_MOUSE_UP: mouseDown = false; return constructSelectEvent(nativeEvent, nativeEventTarget); // Chrome and IE fire non-standard event when selection is changed (and @@ -189,13 +199,13 @@ const SelectEventPlugin = { // keyup, but we check on keydown as well in the case of holding down a // key, when multiple keydown events are fired but only one keyup is. // This is also our approach for IE handling, for the reason above. - case 'topSelectionChange': + case TOP_SELECTION_CHANGE: if (skipSelectionChangeEvent) { break; } // falls through - case 'topKeyDown': - case 'topKeyUp': + case TOP_KEY_DOWN: + case TOP_KEY_UP: return constructSelectEvent(nativeEvent, nativeEventTarget); } From e1b91662f162abd5ee7bfa7146bcf26f24a6f0ff Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 16 Apr 2018 20:55:47 +0200 Subject: [PATCH 12/45] Fix SimpleEventPlugin --- packages/events/PluginModuleType.js | 2 +- packages/events/ReactSyntheticEventType.js | 2 +- .../react-dom/src/events/SimpleEventPlugin.js | 295 +++++++++--------- 3 files changed, 151 insertions(+), 148 deletions(-) diff --git a/packages/events/PluginModuleType.js b/packages/events/PluginModuleType.js index 5657ac3514b6c..8bac932e23f50 100644 --- a/packages/events/PluginModuleType.js +++ b/packages/events/PluginModuleType.js @@ -22,7 +22,7 @@ export type PluginName = string; export type PluginModule = { eventTypes: EventTypes, extractEvents: ( - topLevelType: string, + topLevelType: number, targetInst: Fiber, nativeTarget: NativeEvent, nativeEventTarget: EventTarget, diff --git a/packages/events/ReactSyntheticEventType.js b/packages/events/ReactSyntheticEventType.js index b2b0b688fc602..8319074b0a191 100644 --- a/packages/events/ReactSyntheticEventType.js +++ b/packages/events/ReactSyntheticEventType.js @@ -11,7 +11,7 @@ import type {Fiber} from 'react-reconciler/src/ReactFiber'; export type DispatchConfig = { - dependencies: Array, + dependencies: Array, phasedRegistrationNames?: { bubbled: string, captured: string, diff --git a/packages/react-dom/src/events/SimpleEventPlugin.js b/packages/react-dom/src/events/SimpleEventPlugin.js index 602624dd312f7..1f9a2b4dcfcfc 100644 --- a/packages/react-dom/src/events/SimpleEventPlugin.js +++ b/packages/react-dom/src/events/SimpleEventPlugin.js @@ -7,7 +7,7 @@ * @flow */ -import type {TopLevelTypes} from './BrowserEventConstants'; +import type {TopLevelTypes} from './TopLevelEventTypes'; import type { DispatchConfig, ReactSyntheticEvent, @@ -17,6 +17,8 @@ import type {EventTypes, PluginModule} from 'events/PluginModuleType'; import {accumulateTwoPhaseDispatches} from 'events/EventPropagators'; import SyntheticEvent from 'events/SyntheticEvent'; + +import * as TopLevelEventTypes from './TopLevelEventTypes'; import warning from 'fbjs/lib/warning'; import SyntheticAnimationEvent from './SyntheticAnimationEvent'; @@ -31,6 +33,7 @@ import SyntheticUIEvent from './SyntheticUIEvent'; import SyntheticWheelEvent from './SyntheticWheelEvent'; import getEventCharCode from './getEventCharCode'; + /** * Turns * ['abort', ...] @@ -49,85 +52,85 @@ import getEventCharCode from './getEventCharCode'; * 'topAbort': { sameConfig } * }; */ -const interactiveEventTypeNames: Array = [ - 'blur', - 'cancel', - 'click', - 'close', - 'contextMenu', - 'copy', - 'cut', - 'doubleClick', - 'dragEnd', - 'dragStart', - 'drop', - 'focus', - 'input', - 'invalid', - 'keyDown', - 'keyPress', - 'keyUp', - 'mouseDown', - 'mouseUp', - 'paste', - 'pause', - 'play', - 'rateChange', - 'reset', - 'seeked', - 'submit', - 'touchCancel', - 'touchEnd', - 'touchStart', - 'volumeChange', +type EventTuple = [TopLevelTypes, string]; +const interactiveEventTypeNames: Array = [ + [TopLevelEventTypes.TOP_BLUR, 'blur'], + [TopLevelEventTypes.TOP_CANCEL, 'cancel'], + [TopLevelEventTypes.TOP_CLICK, 'click'], + [TopLevelEventTypes.TOP_CLOSE, 'close'], + [TopLevelEventTypes.TOP_CONTEXT_MENU, 'contextMenu'], + [TopLevelEventTypes.TOP_COPY, 'copy'], + [TopLevelEventTypes.TOP_CUT, 'cut'], + [TopLevelEventTypes.TOP_DOUBLE_CLICK, 'doubleClick'], + [TopLevelEventTypes.TOP_DRAG_END, 'dragEnd'], + [TopLevelEventTypes.TOP_DRAG_START, 'dragStart'], + [TopLevelEventTypes.TOP_DROP, 'drop'], + [TopLevelEventTypes.TOP_FOCUS, 'focus'], + [TopLevelEventTypes.TOP_INPUT, 'input'], + [TopLevelEventTypes.TOP_INVALID, 'invalid'], + [TopLevelEventTypes.TOP_KEY_DOWN, 'keyDown'], + [TopLevelEventTypes.TOP_KEY_PRESS, 'keyPress'], + [TopLevelEventTypes.TOP_KEY_UP, 'keyUp'], + [TopLevelEventTypes.TOP_MOUSE_DOWN, 'mouseDown'], + [TopLevelEventTypes.TOP_MOUSE_UP, 'mouseUp'], + [TopLevelEventTypes.TOP_PASTE, 'paste'], + [TopLevelEventTypes.TOP_PAUSE, 'pause'], + [TopLevelEventTypes.TOP_PLAY, 'play'], + [TopLevelEventTypes.TOP_RATE_CHANGE, 'rateChange'], + [TopLevelEventTypes.TOP_RESET, 'reset'], + [TopLevelEventTypes.TOP_SEEKED, 'seeked'], + [TopLevelEventTypes.TOP_SUBMIT, 'submit'], + [TopLevelEventTypes.TOP_TOUCH_CANCEL, 'touchCancel'], + [TopLevelEventTypes.TOP_TOUCH_END, 'touchEnd'], + [TopLevelEventTypes.TOP_TOUCH_START, 'touchStart'], + [TopLevelEventTypes.TOP_VOLUME_CHANGE, 'volumeChange'], ]; -const nonInteractiveEventTypeNames: Array = [ - 'abort', - 'animationEnd', - 'animationIteration', - 'animationStart', - 'canPlay', - 'canPlayThrough', - 'drag', - 'dragEnter', - 'dragExit', - 'dragLeave', - 'dragOver', - 'durationChange', - 'emptied', - 'encrypted', - 'ended', - 'error', - 'load', - 'loadedData', - 'loadedMetadata', - 'loadStart', - 'mouseMove', - 'mouseOut', - 'mouseOver', - 'playing', - 'progress', - 'scroll', - 'seeking', - 'stalled', - 'suspend', - 'timeUpdate', - 'toggle', - 'touchMove', - 'transitionEnd', - 'waiting', - 'wheel', +const nonInteractiveEventTypeNames: Array = [ + [TopLevelEventTypes.TOP_ABORT, 'abort'], + [TopLevelEventTypes.TOP_ANIMATION_END, 'animationEnd'], + [TopLevelEventTypes.TOP_ANIMATION_ITERATION, 'animationIteration'], + [TopLevelEventTypes.TOP_ANIMATION_START, 'animationStart'], + [TopLevelEventTypes.TOP_CAN_PLAY, 'canPlay'], + [TopLevelEventTypes.TOP_CAN_PLAY_THROUGH, 'canPlayThrough'], + [TopLevelEventTypes.TOP_DRAG, 'drag'], + [TopLevelEventTypes.TOP_DRAG_ENTER, 'dragEnter'], + [TopLevelEventTypes.TOP_DRAG_EXIT, 'dragExit'], + [TopLevelEventTypes.TOP_DRAG_LEAVE, 'dragLeave'], + [TopLevelEventTypes.TOP_DRAG_OVER, 'dragOver'], + [TopLevelEventTypes.TOP_DURATION_CHANGE, 'durationChange'], + [TopLevelEventTypes.TOP_EMPTIED, 'emptied'], + [TopLevelEventTypes.TOP_ENCRYPTED, 'encrypted'], + [TopLevelEventTypes.TOP_ENDED, 'ended'], + [TopLevelEventTypes.TOP_ERROR, 'error'], + [TopLevelEventTypes.TOP_LOAD, 'load'], + [TopLevelEventTypes.TOP_LOADED_DATA, 'loadedData'], + [TopLevelEventTypes.TOP_LOADED_METADATA, 'loadedMetadata'], + [TopLevelEventTypes.TOP_LOAD_START, 'loadStart'], + [TopLevelEventTypes.TOP_MOUSE_MOVE, 'mouseMove'], + [TopLevelEventTypes.TOP_MOUSE_OUT, 'mouseOut'], + [TopLevelEventTypes.TOP_MOUSE_OVER, 'mouseOver'], + [TopLevelEventTypes.TOP_PLAYING, 'playing'], + [TopLevelEventTypes.TOP_PROGRESS, 'progress'], + [TopLevelEventTypes.TOP_SCROLL, 'scroll'], + [TopLevelEventTypes.TOP_SEEKING, 'seeking'], + [TopLevelEventTypes.TOP_STALLED, 'stalled'], + [TopLevelEventTypes.TOP_SUSPEND, 'suspend'], + [TopLevelEventTypes.TOP_TIME_UPDATE, 'timeUpdate'], + [TopLevelEventTypes.TOP_TOGGLE, 'toggle'], + [TopLevelEventTypes.TOP_TOUCH_MOVE, 'touchMove'], + [TopLevelEventTypes.TOP_TRANSITION_END, 'transitionEnd'], + [TopLevelEventTypes.TOP_WAITING, 'waiting'], + [TopLevelEventTypes.TOP_WHEEL, 'wheel'], ]; const eventTypes: EventTypes = {}; -const topLevelEventsToDispatchConfig: { - [key: TopLevelTypes]: DispatchConfig, -} = {}; +const topLevelEventsToDispatchConfig: Map = new Map(); -function addEventTypeNameToConfig(event: string, isInteractive: boolean) { +function addEventTypeNameToConfig(eventTuple: EventTuple, isInteractive: boolean) { + const topEvent = eventTuple[0]; + const event = eventTuple[1]; const capitalizedEvent = event[0].toUpperCase() + event.slice(1); const onEvent = 'on' + capitalizedEvent; - const topEvent = 'top' + capitalizedEvent; const type = { phasedRegistrationNames: { @@ -138,56 +141,56 @@ function addEventTypeNameToConfig(event: string, isInteractive: boolean) { isInteractive, }; eventTypes[event] = type; - topLevelEventsToDispatchConfig[topEvent] = type; + topLevelEventsToDispatchConfig.set(topEvent, type); } -interactiveEventTypeNames.forEach(eventTypeName => { - addEventTypeNameToConfig(eventTypeName, true); +interactiveEventTypeNames.forEach(eventTuple => { + addEventTypeNameToConfig(eventTuple, true); }); -nonInteractiveEventTypeNames.forEach(eventTypeName => { - addEventTypeNameToConfig(eventTypeName, false); +nonInteractiveEventTypeNames.forEach(eventTuple => { + addEventTypeNameToConfig(eventTuple, false); }); // Only used in DEV for exhaustiveness validation. -const knownHTMLTopLevelTypes = [ - 'topAbort', - 'topCancel', - 'topCanPlay', - 'topCanPlayThrough', - 'topClose', - 'topDurationChange', - 'topEmptied', - 'topEncrypted', - 'topEnded', - 'topError', - 'topInput', - 'topInvalid', - 'topLoad', - 'topLoadedData', - 'topLoadedMetadata', - 'topLoadStart', - 'topPause', - 'topPlay', - 'topPlaying', - 'topProgress', - 'topRateChange', - 'topReset', - 'topSeeked', - 'topSeeking', - 'topStalled', - 'topSubmit', - 'topSuspend', - 'topTimeUpdate', - 'topToggle', - 'topVolumeChange', - 'topWaiting', +const knownHTMLTopLevelTypes: Array = [ + TopLevelEventTypes.TOP_ABORT, + TopLevelEventTypes.TOP_CANCEL, + TopLevelEventTypes.TOP_CAN_PLAY, + TopLevelEventTypes.TOP_CAN_PLAY_THROUGH, + TopLevelEventTypes.TOP_CLOSE, + TopLevelEventTypes.TOP_DURATION_CHANGE, + TopLevelEventTypes.TOP_EMPTIED, + TopLevelEventTypes.TOP_ENCRYPTED, + TopLevelEventTypes.TOP_ENDED, + TopLevelEventTypes.TOP_ERROR, + TopLevelEventTypes.TOP_INPUT, + TopLevelEventTypes.TOP_INVALID, + TopLevelEventTypes.TOP_LOAD, + TopLevelEventTypes.TOP_LOADED_DATA, + TopLevelEventTypes.TOP_LOADED_METADATA, + TopLevelEventTypes.TOP_LOAD_START, + TopLevelEventTypes.TOP_PAUSE, + TopLevelEventTypes.TOP_PLAY, + TopLevelEventTypes.TOP_PLAYING, + TopLevelEventTypes.TOP_PROGRESS, + TopLevelEventTypes.TOP_RATE_CHANGE, + TopLevelEventTypes.TOP_RESET, + TopLevelEventTypes.TOP_SEEKED, + TopLevelEventTypes.TOP_SEEKING, + TopLevelEventTypes.TOP_STALLED, + TopLevelEventTypes.TOP_SUBMIT, + TopLevelEventTypes.TOP_SUSPEND, + TopLevelEventTypes.TOP_TIME_UPDATE, + TopLevelEventTypes.TOP_TOGGLE, + TopLevelEventTypes.TOP_VOLUME_CHANGE, + TopLevelEventTypes.TOP_WAITING, ]; const SimpleEventPlugin: PluginModule = { eventTypes: eventTypes, isInteractiveTopLevelEventType(topLevelType: TopLevelTypes): boolean { - const config = topLevelEventsToDispatchConfig[topLevelType]; + const config = topLevelEventsToDispatchConfig.get(topLevelType); return config !== undefined && config.isInteractive === true; }, @@ -197,13 +200,13 @@ const SimpleEventPlugin: PluginModule = { nativeEvent: MouseEvent, nativeEventTarget: EventTarget, ): null | ReactSyntheticEvent { - const dispatchConfig = topLevelEventsToDispatchConfig[topLevelType]; + const dispatchConfig = topLevelEventsToDispatchConfig.get(topLevelType); if (!dispatchConfig) { return null; } let EventConstructor; switch (topLevelType) { - case 'topKeyPress': + case TopLevelEventTypes.TOP_KEY_PRESS: // Firefox creates a keypress event for function keys too. This removes // the unwanted keypress events. Enter is however both printable and // non-printable. One would expect Tab to be as well (but it isn't). @@ -211,65 +214,65 @@ const SimpleEventPlugin: PluginModule = { return null; } /* falls through */ - case 'topKeyDown': - case 'topKeyUp': + case TopLevelEventTypes.TOP_KEY_DOWN: + case TopLevelEventTypes.TOP_KEY_UP: EventConstructor = SyntheticKeyboardEvent; break; - case 'topBlur': - case 'topFocus': + case TopLevelEventTypes.TOP_BLUR: + case TopLevelEventTypes.TOP_FOCUS: EventConstructor = SyntheticFocusEvent; break; - case 'topClick': + case TopLevelEventTypes.TOP_CLICK: // Firefox creates a click event on right mouse clicks. This removes the // unwanted click events. if (nativeEvent.button === 2) { return null; } /* falls through */ - case 'topDoubleClick': - case 'topMouseDown': - case 'topMouseMove': - case 'topMouseUp': + case TopLevelEventTypes.TOP_DOUBLE_CLICK: + case TopLevelEventTypes.TOP_MOUSE_DOWN: + case TopLevelEventTypes.TOP_MOUSE_MOVE: + case TopLevelEventTypes.TOP_MOUSE_UP: // TODO: Disabled elements should not respond to mouse events /* falls through */ - case 'topMouseOut': - case 'topMouseOver': - case 'topContextMenu': + case TopLevelEventTypes.TOP_MOUSE_OUT: + case TopLevelEventTypes.TOP_MOUSE_OVER: + case TopLevelEventTypes.TOP_CONTEXT_MENU: EventConstructor = SyntheticMouseEvent; break; - case 'topDrag': - case 'topDragEnd': - case 'topDragEnter': - case 'topDragExit': - case 'topDragLeave': - case 'topDragOver': - case 'topDragStart': - case 'topDrop': + case TopLevelEventTypes.TOP_DRAG: + case TopLevelEventTypes.TOP_DRAG_END: + case TopLevelEventTypes.TOP_DRAG_ENTER: + case TopLevelEventTypes.TOP_DRAG_EXIT: + case TopLevelEventTypes.TOP_DRAG_LEAVE: + case TopLevelEventTypes.TOP_DRAG_OVER: + case TopLevelEventTypes.TOP_DRAG_START: + case TopLevelEventTypes.TOP_DROP: EventConstructor = SyntheticDragEvent; break; - case 'topTouchCancel': - case 'topTouchEnd': - case 'topTouchMove': - case 'topTouchStart': + case TopLevelEventTypes.TOP_TOUCH_CANCEL: + case TopLevelEventTypes.TOP_TOUCH_END: + case TopLevelEventTypes.TOP_TOUCH_MOVE: + case TopLevelEventTypes.TOP_TOUCH_START: EventConstructor = SyntheticTouchEvent; break; - case 'topAnimationEnd': - case 'topAnimationIteration': - case 'topAnimationStart': + case TopLevelEventTypes.TOP_ANIMATION_END: + case TopLevelEventTypes.TOP_ANIMATION_ITERATION: + case TopLevelEventTypes.TOP_ANIMATION_START: EventConstructor = SyntheticAnimationEvent; break; - case 'topTransitionEnd': + case TopLevelEventTypes.TOP_TRANSITION_END: EventConstructor = SyntheticTransitionEvent; break; - case 'topScroll': + case TopLevelEventTypes.TOP_SCROLL: EventConstructor = SyntheticUIEvent; break; - case 'topWheel': + case TopLevelEventTypes.TOP_WHEEL: EventConstructor = SyntheticWheelEvent; break; - case 'topCopy': - case 'topCut': - case 'topPaste': + case TopLevelEventTypes.TOP_COPY: + case TopLevelEventTypes.TOP_CUT: + case TopLevelEventTypes.TOP_PASTE: EventConstructor = SyntheticClipboardEvent; break; default: From f07a64fe0893c715fa2ea0c43c4117fa3944a435 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 16 Apr 2018 21:04:22 +0200 Subject: [PATCH 13/45] Fix outstanding Flow issues and move TopLevelEventTypes --- packages/events/EventPluginHub.js | 5 +++-- packages/{react-dom/src => }/events/TopLevelEventTypes.js | 0 packages/react-dom/src/client/ReactDOMFiberComponent.js | 2 +- packages/react-dom/src/events/BeforeInputEventPlugin.js | 4 ++-- packages/react-dom/src/events/BrowserEventConstants.js | 5 +++-- packages/react-dom/src/events/ChangeEventPlugin.js | 2 +- packages/react-dom/src/events/EnterLeaveEventPlugin.js | 2 +- packages/react-dom/src/events/ReactBrowserEventEmitter.js | 2 +- packages/react-dom/src/events/SelectEventPlugin.js | 2 +- packages/react-dom/src/events/SimpleEventPlugin.js | 4 ++-- packages/react-dom/src/events/TapEventPlugin.js | 4 ++-- .../src/ReactNativeBridgeEventPlugin.js | 3 ++- .../react-native-renderer/src/ReactNativeEventEmitter.js | 5 +++-- 13 files changed, 22 insertions(+), 18 deletions(-) rename packages/{react-dom/src => }/events/TopLevelEventTypes.js (100%) diff --git a/packages/events/EventPluginHub.js b/packages/events/EventPluginHub.js index d59ba35ff68c7..140c9bfc7e39a 100644 --- a/packages/events/EventPluginHub.js +++ b/packages/events/EventPluginHub.js @@ -25,6 +25,7 @@ import type {PluginModule} from './PluginModuleType'; import type {ReactSyntheticEvent} from './ReactSyntheticEventType'; import type {Fiber} from 'react-reconciler/src/ReactFiber'; import type {AnyNativeEvent} from './PluginModuleType'; +import type {TopLevelTypes} from './TopLevelEventTypes'; /** * Internal queue of events that have accumulated their dispatches and are @@ -165,7 +166,7 @@ export function getListener(inst: Fiber, registrationName: string) { * @internal */ function extractEvents( - topLevelType: string, + topLevelType: TopLevelTypes, targetInst: Fiber, nativeEvent: AnyNativeEvent, nativeEventTarget: EventTarget, @@ -227,7 +228,7 @@ export function runEventsInBatch( } export function runExtractedEventsInBatch( - topLevelType: string, + topLevelType: TopLevelTypes, targetInst: Fiber, nativeEvent: AnyNativeEvent, nativeEventTarget: EventTarget, diff --git a/packages/react-dom/src/events/TopLevelEventTypes.js b/packages/events/TopLevelEventTypes.js similarity index 100% rename from packages/react-dom/src/events/TopLevelEventTypes.js rename to packages/events/TopLevelEventTypes.js diff --git a/packages/react-dom/src/client/ReactDOMFiberComponent.js b/packages/react-dom/src/client/ReactDOMFiberComponent.js index 543a4a3ac2531..de13b564d26d1 100644 --- a/packages/react-dom/src/client/ReactDOMFiberComponent.js +++ b/packages/react-dom/src/client/ReactDOMFiberComponent.js @@ -17,7 +17,7 @@ import { TOP_RESET, TOP_SUBMIT, TOP_TOGGLE, -} from '../events/TopLevelEventTypes'; +} from 'events/TopLevelEventTypes'; import emptyFunction from 'fbjs/lib/emptyFunction'; import warning from 'fbjs/lib/warning'; diff --git a/packages/react-dom/src/events/BeforeInputEventPlugin.js b/packages/react-dom/src/events/BeforeInputEventPlugin.js index a7ec9f7f7b3ce..11853b6166adb 100644 --- a/packages/react-dom/src/events/BeforeInputEventPlugin.js +++ b/packages/react-dom/src/events/BeforeInputEventPlugin.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import type {TopLevelTypes} from './TopLevelEventTypes'; +import type {TopLevelTypes} from 'events/TopLevelEventTypes'; import {accumulateTwoPhaseDispatches} from 'events/EventPropagators'; import { @@ -19,7 +19,7 @@ import { TOP_MOUSE_DOWN, TOP_TEXT_INPUT, TOP_PASTE, -} from './TopLevelEventTypes'; +} from 'events/TopLevelEventTypes'; import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment'; import * as FallbackCompositionState from './FallbackCompositionState'; diff --git a/packages/react-dom/src/events/BrowserEventConstants.js b/packages/react-dom/src/events/BrowserEventConstants.js index 081e7c2038cca..f53ac986fd145 100644 --- a/packages/react-dom/src/events/BrowserEventConstants.js +++ b/packages/react-dom/src/events/BrowserEventConstants.js @@ -7,9 +7,10 @@ * @flow */ -import * as TopLevelEventTypes from './TopLevelEventTypes'; +import * as TopLevelEventTypes from 'events/TopLevelEventTypes'; +import type {TopLevelTypes} from 'events/TopLevelEventTypes'; + import getVendorPrefixedEventName from './getVendorPrefixedEventName'; -import type {TopLevelTypes} from './TopLevelEventTypes'; /** * Types of raw signals from the browser caught at the top level. diff --git a/packages/react-dom/src/events/ChangeEventPlugin.js b/packages/react-dom/src/events/ChangeEventPlugin.js index 2bdf3409b125d..c85a1af6e2604 100644 --- a/packages/react-dom/src/events/ChangeEventPlugin.js +++ b/packages/react-dom/src/events/ChangeEventPlugin.js @@ -19,7 +19,7 @@ import { TOP_KEY_DOWN, TOP_KEY_UP, TOP_SELECTION_CHANGE, -} from './TopLevelEventTypes'; +} from 'events/TopLevelEventTypes'; import isTextInputElement from 'shared/isTextInputElement'; import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment'; diff --git a/packages/react-dom/src/events/EnterLeaveEventPlugin.js b/packages/react-dom/src/events/EnterLeaveEventPlugin.js index 2c1fdec3cf0c4..4841095b69d6f 100644 --- a/packages/react-dom/src/events/EnterLeaveEventPlugin.js +++ b/packages/react-dom/src/events/EnterLeaveEventPlugin.js @@ -6,7 +6,7 @@ */ import {accumulateEnterLeaveDispatches} from 'events/EventPropagators'; -import {TOP_MOUSE_OUT, TOP_MOUSE_OVER} from './TopLevelEventTypes'; +import {TOP_MOUSE_OUT, TOP_MOUSE_OVER} from 'events/TopLevelEventTypes'; import SyntheticMouseEvent from './SyntheticMouseEvent'; import { diff --git a/packages/react-dom/src/events/ReactBrowserEventEmitter.js b/packages/react-dom/src/events/ReactBrowserEventEmitter.js index 624befa755d95..bfd25895731b8 100644 --- a/packages/react-dom/src/events/ReactBrowserEventEmitter.js +++ b/packages/react-dom/src/events/ReactBrowserEventEmitter.js @@ -12,7 +12,7 @@ import { TOP_CLOSE, TOP_FOCUS, TOP_SCROLL, -} from './TopLevelEventTypes'; +} from 'events/TopLevelEventTypes'; import { setEnabled, isEnabled, diff --git a/packages/react-dom/src/events/SelectEventPlugin.js b/packages/react-dom/src/events/SelectEventPlugin.js index 9243d2f1743a4..8cbcf4c208d2e 100644 --- a/packages/react-dom/src/events/SelectEventPlugin.js +++ b/packages/react-dom/src/events/SelectEventPlugin.js @@ -17,7 +17,7 @@ import { TOP_MOUSE_DOWN, TOP_MOUSE_UP, TOP_SELECTION_CHANGE, -} from './TopLevelEventTypes'; +} from 'events/TopLevelEventTypes'; import isTextInputElement from 'shared/isTextInputElement'; import getActiveElement from 'fbjs/lib/getActiveElement'; import shallowEqual from 'fbjs/lib/shallowEqual'; diff --git a/packages/react-dom/src/events/SimpleEventPlugin.js b/packages/react-dom/src/events/SimpleEventPlugin.js index 1f9a2b4dcfcfc..d44495fe3080a 100644 --- a/packages/react-dom/src/events/SimpleEventPlugin.js +++ b/packages/react-dom/src/events/SimpleEventPlugin.js @@ -7,7 +7,7 @@ * @flow */ -import type {TopLevelTypes} from './TopLevelEventTypes'; +import type {TopLevelTypes} from 'events/TopLevelEventTypes'; import type { DispatchConfig, ReactSyntheticEvent, @@ -18,7 +18,7 @@ import type {EventTypes, PluginModule} from 'events/PluginModuleType'; import {accumulateTwoPhaseDispatches} from 'events/EventPropagators'; import SyntheticEvent from 'events/SyntheticEvent'; -import * as TopLevelEventTypes from './TopLevelEventTypes'; +import * as TopLevelEventTypes from 'events/TopLevelEventTypes'; import warning from 'fbjs/lib/warning'; import SyntheticAnimationEvent from './SyntheticAnimationEvent'; diff --git a/packages/react-dom/src/events/TapEventPlugin.js b/packages/react-dom/src/events/TapEventPlugin.js index 168b531d0b68e..e3eae2155eb3d 100644 --- a/packages/react-dom/src/events/TapEventPlugin.js +++ b/packages/react-dom/src/events/TapEventPlugin.js @@ -18,8 +18,8 @@ import { TOP_TOUCH_END, TOP_TOUCH_MOVE, TOP_TOUCH_START, -} from './TopLevelEventTypes'; -import type {TopLevelTypes} from './TopLevelEventTypes'; +} from 'events/TopLevelEventTypes'; +import type {TopLevelTypes} from 'events/TopLevelEventTypes'; import SyntheticUIEvent from './SyntheticUIEvent'; diff --git a/packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js b/packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js index 69bc7a260a558..100cca947f962 100644 --- a/packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js +++ b/packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js @@ -12,6 +12,7 @@ import { accumulateTwoPhaseDispatches, accumulateDirectDispatches, } from 'events/EventPropagators'; +import type {TopLevelTypes} from 'events/TopLevelEventTypes'; import * as ReactNativeViewConfigRegistry from 'ReactNativeViewConfigRegistry'; import SyntheticEvent from 'events/SyntheticEvent'; import invariant from 'fbjs/lib/invariant'; @@ -29,7 +30,7 @@ const ReactNativeBridgeEventPlugin = { * @see {EventPluginHub.extractEvents} */ extractEvents: function( - topLevelType: string, + topLevelType: TopLevelTypes, targetInst: Object, nativeEvent: AnyNativeEvent, nativeEventTarget: Object, diff --git a/packages/react-native-renderer/src/ReactNativeEventEmitter.js b/packages/react-native-renderer/src/ReactNativeEventEmitter.js index e43644a620826..916bad7818037 100644 --- a/packages/react-native-renderer/src/ReactNativeEventEmitter.js +++ b/packages/react-native-renderer/src/ReactNativeEventEmitter.js @@ -15,6 +15,7 @@ import warning from 'fbjs/lib/warning'; import {getInstanceFromNode} from './ReactNativeComponentTree'; import type {AnyNativeEvent} from 'events/PluginModuleType'; +import type {TopLevelTypes} from 'events/TopLevelEventTypes'; export {getListener, registrationNameModules as registrationNames}; @@ -88,7 +89,7 @@ const removeTouchesAtIndices = function( */ export function _receiveRootNodeIDEvent( rootNodeID: number, - topLevelType: string, + topLevelType: TopLevelTypes, nativeEventParam: ?AnyNativeEvent, ) { const nativeEvent = nativeEventParam || EMPTY_NATIVE_EVENT; @@ -114,7 +115,7 @@ export function _receiveRootNodeIDEvent( */ export function receiveEvent( rootNodeID: number, - topLevelType: string, + topLevelType: TopLevelTypes, nativeEventParam: AnyNativeEvent, ) { _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam); From da64f27462ba416767678077486bf26bd8507dda Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 16 Apr 2018 21:17:07 +0200 Subject: [PATCH 14/45] Inline a list of all events in `ReactTestUtils` --- .../src/test-utils/ReactTestUtils.js | 86 ++++++++++++++++--- 1 file changed, 72 insertions(+), 14 deletions(-) diff --git a/packages/react-dom/src/test-utils/ReactTestUtils.js b/packages/react-dom/src/test-utils/ReactTestUtils.js index e7cf69b5509cc..54958a88a7786 100644 --- a/packages/react-dom/src/test-utils/ReactTestUtils.js +++ b/packages/react-dom/src/test-utils/ReactTestUtils.js @@ -18,8 +18,6 @@ import { import SyntheticEvent from 'events/SyntheticEvent'; import invariant from 'fbjs/lib/invariant'; -import {topLevelTypes, mediaEventTypes} from '../events/BrowserEventConstants'; - const {findDOMNode} = ReactDOM; const { EventPluginHub, @@ -457,22 +455,82 @@ function makeNativeSimulator(eventType) { }; } -const eventKeys = [].concat( - Object.keys(topLevelTypes), - Object.keys(mediaEventTypes), -); - -eventKeys.forEach(function(eventType) { - // Event type is stored as 'topClick' - we transform that to 'click' - const convenienceName = - eventType.indexOf('top') === 0 - ? eventType.charAt(3).toLowerCase() + eventType.substr(4) - : eventType; +[ + 'animationEnd', + 'animationIteration', + 'animationStart', + 'blur', + 'cancel', + 'change', + 'click', + 'close', + 'compositionEnd', + 'compositionStart', + 'compositionUpdate', + 'contextMenu', + 'copy', + 'cut', + 'doubleClick', + 'drag', + 'dragEnd', + 'dragEnter', + 'dragExit', + 'dragLeave', + 'dragOver', + 'dragStart', + 'drop', + 'focus', + 'input', + 'keyDown', + 'keyPress', + 'keyUp', + 'load', + 'loadStart', + 'mouseDown', + 'mouseMove', + 'mouseOut', + 'mouseOver', + 'mouseUp', + 'paste', + 'scroll', + 'selectionChange', + 'textInput', + 'toggle', + 'touchCancel', + 'touchEnd', + 'touchMove', + 'touchStart', + 'transitionEnd', + 'wheel', + 'abort', + 'canPlay', + 'canPlayThrough', + 'durationChange', + 'emptied', + 'encrypted', + 'ended', + 'error', + 'loadedData', + 'loadedMetadata', + 'loadStart', + 'pause', + 'play', + 'playing', + 'progress', + 'rateChange', + 'seeked', + 'seeking', + 'stalled', + 'suspend', + 'timeUpdate', + 'VolumeChange', + 'waiting', +].forEach(function(eventType) { /** * @param {!Element|ReactDOMComponent} domComponentOrNode * @param {?Event} nativeEventData Fake native event to use in SyntheticEvent. */ - ReactTestUtils.SimulateNative[convenienceName] = makeNativeSimulator( + ReactTestUtils.SimulateNative[eventType] = makeNativeSimulator( eventType, ); }); From 16c39e56747350fa2ef6fe6bcf462d744f043624 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 17 Apr 2018 10:46:27 +0200 Subject: [PATCH 15/45] Fix tests --- packages/events/ResponderTouchHistoryStore.js | 2 +- .../ResponderEventPlugin-test.internal.js | 28 ++-- .../react-dom/src/__tests__/ReactDOM-test.js | 4 +- .../src/__tests__/ReactDOMFiber-test.js | 10 +- .../src/__tests__/ReactDOMInput-test.js | 4 +- .../src/client/ReactDOMFiberComponent.js | 4 +- .../src/events/BeforeInputEventPlugin.js | 2 +- .../src/events/BrowserEventConstants.js | 16 +- .../src/events/ReactBrowserEventEmitter.js | 16 +- .../react-dom/src/events/SimpleEventPlugin.js | 8 +- .../src/test-utils/ReactTestUtils.js | 153 +++++++++--------- .../ReactNativeEvents-test.internal.js | 28 ++-- 12 files changed, 149 insertions(+), 126 deletions(-) diff --git a/packages/events/ResponderTouchHistoryStore.js b/packages/events/ResponderTouchHistoryStore.js index 0c703a5970017..d8c3eb29ebb88 100644 --- a/packages/events/ResponderTouchHistoryStore.js +++ b/packages/events/ResponderTouchHistoryStore.js @@ -177,7 +177,7 @@ function printTouchBank(): string { } const ResponderTouchHistoryStore = { - recordTouchTrack(topLevelType: string, nativeEvent: TouchEvent): void { + recordTouchTrack(topLevelType: number, nativeEvent: TouchEvent): void { if (isMoveish(topLevelType)) { nativeEvent.changedTouches.forEach(recordTouchMove); } else if (isStartish(topLevelType)) { diff --git a/packages/events/__tests__/ResponderEventPlugin-test.internal.js b/packages/events/__tests__/ResponderEventPlugin-test.internal.js index d583126f0b1bc..90bf5200ef4c3 100644 --- a/packages/events/__tests__/ResponderEventPlugin-test.internal.js +++ b/packages/events/__tests__/ResponderEventPlugin-test.internal.js @@ -11,6 +11,14 @@ const {HostComponent} = require('shared/ReactTypeOfWork'); +const { + TOP_SCROLL, + TOP_TOUCH_CANCEL, + TOP_TOUCH_END, + TOP_TOUCH_MOVE, + TOP_TOUCH_START, +} = require('../TopLevelEventTypes'); + let EventPluginHub; let ResponderEventPlugin; @@ -66,13 +74,13 @@ const _touchConfig = function( const allTouchObjects = allTouchHandles.map(touch); const changedTouchObjects = subsequence(allTouchObjects, changedIndices); const activeTouchObjects = - topType === 'topTouchStart' + topType === TOP_TOUCH_START ? allTouchObjects - : topType === 'topTouchMove' + : topType === TOP_TOUCH_MOVE ? allTouchObjects - : topType === 'topTouchEnd' + : topType === TOP_TOUCH_END ? antiSubsequence(allTouchObjects, changedIndices) - : topType === 'topTouchCancel' + : topType === TOP_TOUCH_CANCEL ? antiSubsequence(allTouchObjects, changedIndices) : null; @@ -107,7 +115,7 @@ const _touchConfig = function( */ const startConfig = function(nodeHandle, allTouchHandles, changedIndices) { return _touchConfig( - 'topTouchStart', + TOP_TOUCH_START, nodeHandle, allTouchHandles, changedIndices, @@ -120,7 +128,7 @@ const startConfig = function(nodeHandle, allTouchHandles, changedIndices) { */ const moveConfig = function(nodeHandle, allTouchHandles, changedIndices) { return _touchConfig( - 'topTouchMove', + TOP_TOUCH_MOVE, nodeHandle, allTouchHandles, changedIndices, @@ -133,7 +141,7 @@ const moveConfig = function(nodeHandle, allTouchHandles, changedIndices) { */ const endConfig = function(nodeHandle, allTouchHandles, changedIndices) { return _touchConfig( - 'topTouchEnd', + TOP_TOUCH_END, nodeHandle, allTouchHandles, changedIndices, @@ -1292,7 +1300,7 @@ describe('ResponderEventPlugin', () => { config.responderReject.parent = {order: 5}; run(config, three, { - topLevelType: 'topScroll', + topLevelType: TOP_SCROLL, targetInst: getInstanceFromNode(three.parent), nativeEvent: {}, }); @@ -1319,7 +1327,7 @@ describe('ResponderEventPlugin', () => { config.responderTerminate.child = {order: 5}; run(config, three, { - topLevelType: 'topScroll', + topLevelType: TOP_SCROLL, targetInst: getInstanceFromNode(three.parent), nativeEvent: {}, }); @@ -1357,7 +1365,7 @@ describe('ResponderEventPlugin', () => { config.responderTerminate.child = {order: 1}; const nativeEvent = _touchConfig( - 'topTouchCancel', + TOP_TOUCH_CANCEL, three.child, [three.child], [0], diff --git a/packages/react-dom/src/__tests__/ReactDOM-test.js b/packages/react-dom/src/__tests__/ReactDOM-test.js index 5e7d2772e3e2e..32ad6ebed6f2d 100644 --- a/packages/react-dom/src/__tests__/ReactDOM-test.js +++ b/packages/react-dom/src/__tests__/ReactDOM-test.js @@ -13,6 +13,8 @@ let React = require('react'); let ReactDOM = require('react-dom'); const ReactTestUtils = require('react-dom/test-utils'); +const { TOP_CLICK } = require('events/TopLevelEventTypes'); + describe('ReactDOM', () => { // TODO: uncomment this test once we can run in phantom, which // supports real submit events. @@ -313,7 +315,7 @@ describe('ReactDOM', () => { fakeNativeEvent.target = node; fakeNativeEvent.path = [node, container]; ReactTestUtils.simulateNativeEventOnNode( - 'topClick', + TOP_CLICK, node, fakeNativeEvent, ); diff --git a/packages/react-dom/src/__tests__/ReactDOMFiber-test.js b/packages/react-dom/src/__tests__/ReactDOMFiber-test.js index deffd4680df91..a280d1b1309de 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFiber-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFiber-test.js @@ -14,6 +14,8 @@ const ReactDOM = require('react-dom'); const ReactTestUtils = require('react-dom/test-utils'); const PropTypes = require('prop-types'); +const { TOP_CLICK, TOP_MOUSE_OUT, TOP_MOUSE_OVER } = require('events/TopLevelEventTypes'); + describe('ReactDOMFiber', () => { let container; @@ -840,7 +842,7 @@ describe('ReactDOMFiber', () => { const fakeNativeEvent = {}; ReactTestUtils.simulateNativeEventOnNode( - 'topClick', + TOP_CLICK, portal, fakeNativeEvent, ); @@ -858,13 +860,13 @@ describe('ReactDOMFiber', () => { function simulateMouseMove(from, to) { if (from) { - ReactTestUtils.simulateNativeEventOnNode('topMouseOut', from, { + ReactTestUtils.simulateNativeEventOnNode(TOP_MOUSE_OUT, from, { target: from, relatedTarget: to, }); } if (to) { - ReactTestUtils.simulateNativeEventOnNode('topMouseOver', to, { + ReactTestUtils.simulateNativeEventOnNode(TOP_MOUSE_OVER, to, { target: to, relatedTarget: from, }); @@ -985,7 +987,7 @@ describe('ReactDOMFiber', () => { function click(target) { const fakeNativeEvent = {}; ReactTestUtils.simulateNativeEventOnNode( - 'topClick', + TOP_CLICK, target, fakeNativeEvent, ); diff --git a/packages/react-dom/src/__tests__/ReactDOMInput-test.js b/packages/react-dom/src/__tests__/ReactDOMInput-test.js index 03eed7bc1ec65..f35e33e3b3207 100644 --- a/packages/react-dom/src/__tests__/ReactDOMInput-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMInput-test.js @@ -11,6 +11,8 @@ const emptyFunction = require('fbjs/lib/emptyFunction'); +const { TOP_INPUT } = require('events/TopLevelEventTypes'); + describe('ReactDOMInput', () => { let React; let ReactDOM; @@ -697,7 +699,7 @@ describe('ReactDOMInput', () => { const fakeNativeEvent = function() {}; fakeNativeEvent.target = node; fakeNativeEvent.path = [node, container]; - ReactTestUtils.simulateNativeEventOnNode('topInput', node, fakeNativeEvent); + ReactTestUtils.simulateNativeEventOnNode(TOP_INPUT, node, fakeNativeEvent); expect(handled).toBe(true); }); diff --git a/packages/react-dom/src/client/ReactDOMFiberComponent.js b/packages/react-dom/src/client/ReactDOMFiberComponent.js index de13b564d26d1..f5477eec769bc 100644 --- a/packages/react-dom/src/client/ReactDOMFiberComponent.js +++ b/packages/react-dom/src/client/ReactDOMFiberComponent.js @@ -454,7 +454,7 @@ export function setInitialProperties( case 'video': case 'audio': // Create listener for each media event - mediaEventTypes.forEach(topEventName => { + mediaEventTypes.forEach((_value, topEventName) => { trapBubbledEvent(topEventName, domElement); }); props = rawProps; @@ -840,7 +840,7 @@ export function diffHydratedProperties( case 'video': case 'audio': // Create listener for each media event - mediaEventTypes.forEach(topEventName => { + mediaEventTypes.forEach((_value, topEventName) => { trapBubbledEvent(topEventName, domElement); }); break; diff --git a/packages/react-dom/src/events/BeforeInputEventPlugin.js b/packages/react-dom/src/events/BeforeInputEventPlugin.js index 11853b6166adb..034b0fd147f85 100644 --- a/packages/react-dom/src/events/BeforeInputEventPlugin.js +++ b/packages/react-dom/src/events/BeforeInputEventPlugin.js @@ -318,7 +318,7 @@ function getNativeBeforeInputChars(topLevelType: TopLevelTypes, nativeEvent) { * For browsers that do not provide the `textInput` event, extract the * appropriate string to use for SyntheticInputEvent. * - * @param {string} topLevelType Record from `BrowserEventConstants`. + * @param {number} topLevelType Number from `TopLevelEventTypes`. * @param {object} nativeEvent Native browser event. * @return {?string} The fallback string for this `beforeInput` event. */ diff --git a/packages/react-dom/src/events/BrowserEventConstants.js b/packages/react-dom/src/events/BrowserEventConstants.js index f53ac986fd145..9f563eb370df3 100644 --- a/packages/react-dom/src/events/BrowserEventConstants.js +++ b/packages/react-dom/src/events/BrowserEventConstants.js @@ -9,6 +9,7 @@ import * as TopLevelEventTypes from 'events/TopLevelEventTypes'; import type {TopLevelTypes} from 'events/TopLevelEventTypes'; +import invariant from 'fbjs/lib/invariant'; import getVendorPrefixedEventName from './getVendorPrefixedEventName'; @@ -106,12 +107,13 @@ const nonTopEventTypes: Map = new Map([ ]); export function getRawEventName(topLevelType: TopLevelTypes): ?string { - const eventName: ?string = topLevelTypes.get(topLevelType) - || mediaEventTypes.get(topLevelType) - || nonTopEventTypes.get(topLevelType); + const eventName: ?string = topLevelTypes.get(topLevelType) + || mediaEventTypes.get(topLevelType) + || nonTopEventTypes.get(topLevelType); - if (!eventName) { - throw new Error(`Not handling ${topLevelType}`); - } - return null; + invariant( + eventName, + 'BrowserEventConstants: Could not look up raw event name of topLevelType.', + ); + return eventName; } diff --git a/packages/react-dom/src/events/ReactBrowserEventEmitter.js b/packages/react-dom/src/events/ReactBrowserEventEmitter.js index bfd25895731b8..bd8d7c6f2f16a 100644 --- a/packages/react-dom/src/events/ReactBrowserEventEmitter.js +++ b/packages/react-dom/src/events/ReactBrowserEventEmitter.js @@ -91,7 +91,7 @@ function getListeningForDocument(mountAt) { // directly. if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) { mountAt[topListenersIDKey] = reactTopListenersCounter++; - alreadyListeningTo[mountAt[topListenersIDKey]] = {}; + alreadyListeningTo[mountAt[topListenersIDKey]] = new Map(); } return alreadyListeningTo[mountAt[topListenersIDKey]]; } @@ -124,7 +124,7 @@ export function listenTo(registrationName, contentDocumentHandle) { for (let i = 0; i < dependencies.length; i++) { const dependency = dependencies[i]; - if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) { + if (!isListening.get(dependency)) { if (dependency === TOP_SCROLL) { trapCapturedEvent(TOP_SCROLL, mountAt); } else if (dependency === TOP_FOCUS || dependency === TOP_BLUR) { @@ -132,23 +132,23 @@ export function listenTo(registrationName, contentDocumentHandle) { trapCapturedEvent(TOP_BLUR, mountAt); // to make sure blur and focus event listeners are only attached once - isListening.topBlur = true; - isListening.topFocus = true; + isListening.set(TOP_BLUR, true); + isListening.set(TOP_FOCUS, true); } else if (dependency === TOP_CANCEL) { if (isEventSupported('cancel', true)) { trapCapturedEvent(TOP_CANCEL, mountAt); } - isListening.topCancel = true; + isListening.set(TOP_CANCEL, true); } else if (dependency === TOP_CLOSE) { if (isEventSupported('close', true)) { trapCapturedEvent(TOP_CLOSE, mountAt); } - isListening.topClose = true; + isListening.set(TOP_CLOSE, true); } else if (getRawEventName(dependency)) { trapBubbledEvent(dependency, mountAt); } - isListening[dependency] = true; + isListening.set(dependency, true); } } } @@ -158,7 +158,7 @@ export function isListeningToAllDependencies(registrationName, mountAt) { const dependencies = registrationNameDependencies[registrationName]; for (let i = 0; i < dependencies.length; i++) { const dependency = dependencies[i]; - if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) { + if (!isListening.get(dependency)) { return false; } } diff --git a/packages/react-dom/src/events/SimpleEventPlugin.js b/packages/react-dom/src/events/SimpleEventPlugin.js index d44495fe3080a..96d6ef5add8fa 100644 --- a/packages/react-dom/src/events/SimpleEventPlugin.js +++ b/packages/react-dom/src/events/SimpleEventPlugin.js @@ -44,13 +44,13 @@ import getEventCharCode from './getEventCharCode'; * bubbled: 'onAbort', * captured: 'onAbortCapture', * }, - * dependencies: ['topAbort'], + * dependencies: [TOP_ABORT], * }, * ... * }; - * topLevelEventsToDispatchConfig = { - * 'topAbort': { sameConfig } - * }; + * topLevelEventsToDispatchConfig = new Map([ + * [TOP_ABORT, { sameConfig }], + * ]); */ type EventTuple = [TopLevelTypes, string]; const interactiveEventTypeNames: Array = [ diff --git a/packages/react-dom/src/test-utils/ReactTestUtils.js b/packages/react-dom/src/test-utils/ReactTestUtils.js index 54958a88a7786..ce4df00273b39 100644 --- a/packages/react-dom/src/test-utils/ReactTestUtils.js +++ b/packages/react-dom/src/test-utils/ReactTestUtils.js @@ -16,6 +16,7 @@ import { HostText, } from 'shared/ReactTypeOfWork'; import SyntheticEvent from 'events/SyntheticEvent'; +import * as TopLevelEventTypes from 'events/TopLevelEventTypes'; import invariant from 'fbjs/lib/invariant'; const {findDOMNode} = ReactDOM; @@ -292,7 +293,7 @@ const ReactTestUtils = { /** * Simulates a top level event being dispatched from a raw event that occurred * on an `Element` node. - * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes` + * @param {number} topLevelType A number from `TopLevelEventTypes` * @param {!Element} node The dom to simulate an event occurring on. * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent. */ @@ -434,20 +435,20 @@ buildSimulators(); * to dispatch synthetic events. */ -function makeNativeSimulator(eventType) { +function makeNativeSimulator(eventType, topLevelType) { return function(domComponentOrNode, nativeEventData) { const fakeNativeEvent = new Event(eventType); Object.assign(fakeNativeEvent, nativeEventData); if (ReactTestUtils.isDOMComponent(domComponentOrNode)) { ReactTestUtils.simulateNativeEventOnDOMComponent( - eventType, + topLevelType, domComponentOrNode, fakeNativeEvent, ); } else if (domComponentOrNode.tagName) { // Will allow on actual dom nodes. ReactTestUtils.simulateNativeEventOnNode( - eventType, + topLevelType, domComponentOrNode, fakeNativeEvent, ); @@ -456,82 +457,86 @@ function makeNativeSimulator(eventType) { } [ - 'animationEnd', - 'animationIteration', - 'animationStart', - 'blur', - 'cancel', - 'change', - 'click', - 'close', - 'compositionEnd', - 'compositionStart', - 'compositionUpdate', - 'contextMenu', - 'copy', - 'cut', - 'doubleClick', - 'drag', - 'dragEnd', - 'dragEnter', - 'dragExit', - 'dragLeave', - 'dragOver', - 'dragStart', - 'drop', - 'focus', - 'input', - 'keyDown', - 'keyPress', - 'keyUp', - 'load', - 'loadStart', - 'mouseDown', - 'mouseMove', - 'mouseOut', - 'mouseOver', - 'mouseUp', - 'paste', - 'scroll', - 'selectionChange', - 'textInput', - 'toggle', - 'touchCancel', - 'touchEnd', - 'touchMove', - 'touchStart', - 'transitionEnd', - 'wheel', - 'abort', - 'canPlay', - 'canPlayThrough', - 'durationChange', - 'emptied', - 'encrypted', - 'ended', - 'error', - 'loadedData', - 'loadedMetadata', - 'loadStart', - 'pause', - 'play', - 'playing', - 'progress', - 'rateChange', - 'seeked', - 'seeking', - 'stalled', - 'suspend', - 'timeUpdate', - 'VolumeChange', - 'waiting', -].forEach(function(eventType) { + [TopLevelEventTypes.TOP_ANIMATION_END, 'animationEnd'], + [TopLevelEventTypes.TOP_ANIMATION_ITERATION, 'animationIteration'], + [TopLevelEventTypes.TOP_ANIMATION_START, 'animationStart'], + [TopLevelEventTypes.TOP_BLUR, 'blur'], + [TopLevelEventTypes.TOP_CANCEL, 'cancel'], + [TopLevelEventTypes.TOP_CHANGE, 'change'], + [TopLevelEventTypes.TOP_CLICK, 'click'], + [TopLevelEventTypes.TOP_CLOSE, 'close'], + [TopLevelEventTypes.TOP_COMPOSITION_END, 'compositionEnd'], + [TopLevelEventTypes.TOP_COMPOSITION_START, 'compositionStart'], + [TopLevelEventTypes.TOP_COMPOSITION_UPDATE, 'compositionUpdate'], + [TopLevelEventTypes.TOP_CONTEXT_MENU, 'contextMenu'], + [TopLevelEventTypes.TOP_COPY, 'copy'], + [TopLevelEventTypes.TOP_CUT, 'cut'], + [TopLevelEventTypes.TOP_DOUBLE_CLICK, 'doubleClick'], + [TopLevelEventTypes.TOP_DRAG, 'drag'], + [TopLevelEventTypes.TOP_DRAG_END, 'dragEnd'], + [TopLevelEventTypes.TOP_DRAG_ENTER, 'dragEnter'], + [TopLevelEventTypes.TOP_DRAG_EXIT, 'dragExit'], + [TopLevelEventTypes.TOP_DRAG_LEAVE, 'dragLeave'], + [TopLevelEventTypes.TOP_DRAG_OVER, 'dragOver'], + [TopLevelEventTypes.TOP_DRAG_START, 'dragStart'], + [TopLevelEventTypes.TOP_DROP, 'drop'], + [TopLevelEventTypes.TOP_FOCUS, 'focus'], + [TopLevelEventTypes.TOP_INPUT, 'input'], + [TopLevelEventTypes.TOP_KEY_DOWN, 'keyDown'], + [TopLevelEventTypes.TOP_KEY_PRESS, 'keyPress'], + [TopLevelEventTypes.TOP_KEY_UP, 'keyUp'], + [TopLevelEventTypes.TOP_LOAD, 'load'], + [TopLevelEventTypes.TOP_LOAD_START, 'loadStart'], + [TopLevelEventTypes.TOP_MOUSE_DOWN, 'mouseDown'], + [TopLevelEventTypes.TOP_MOUSE_MOVE, 'mouseMove'], + [TopLevelEventTypes.TOP_MOUSE_OUT, 'mouseOut'], + [TopLevelEventTypes.TOP_MOUSE_OVER, 'mouseOver'], + [TopLevelEventTypes.TOP_MOUSE_UP, 'mouseUp'], + [TopLevelEventTypes.TOP_PASTE, 'paste'], + [TopLevelEventTypes.TOP_SCROLL, 'scroll'], + [TopLevelEventTypes.TOP_SELECTION_CHANGE, 'selectionChange'], + [TopLevelEventTypes.TOP_TEXT_INPUT, 'textInput'], + [TopLevelEventTypes.TOP_TOGGLE, 'toggle'], + [TopLevelEventTypes.TOP_TOUCH_CANCEL, 'touchCancel'], + [TopLevelEventTypes.TOP_TOUCH_END, 'touchEnd'], + [TopLevelEventTypes.TOP_TOUCH_MOVE, 'touchMove'], + [TopLevelEventTypes.TOP_TOUCH_START, 'touchStart'], + [TopLevelEventTypes.TOP_TRANSITION_END, 'transitionEnd'], + [TopLevelEventTypes.TOP_WHEEL, 'wheel'], + [TopLevelEventTypes.TOP_ABORT, 'abort'], + [TopLevelEventTypes.TOP_CAN_PLAY, 'canPlay'], + [TopLevelEventTypes.TOP_CAN_PLAY_THROUGH, 'canPlayThrough'], + [TopLevelEventTypes.TOP_DURATION_CHANGE, 'durationChange'], + [TopLevelEventTypes.TOP_EMPTIED, 'emptied'], + [TopLevelEventTypes.TOP_ENCRYPTED, 'encrypted'], + [TopLevelEventTypes.TOP_ENDED, 'ended'], + [TopLevelEventTypes.TOP_ERROR, 'error'], + [TopLevelEventTypes.TOP_LOADED_DATA, 'loadedData'], + [TopLevelEventTypes.TOP_LOADED_METADATA, 'loadedMetadata'], + [TopLevelEventTypes.TOP_LOAD_START, 'loadStart'], + [TopLevelEventTypes.TOP_PAUSE, 'pause'], + [TopLevelEventTypes.TOP_PLAY, 'play'], + [TopLevelEventTypes.TOP_PLAYING, 'playing'], + [TopLevelEventTypes.TOP_PROGRESS, 'progress'], + [TopLevelEventTypes.TOP_RATE_CHANGE, 'rateChange'], + [TopLevelEventTypes.TOP_SEEKED, 'seeked'], + [TopLevelEventTypes.TOP_SEEKING, 'seeking'], + [TopLevelEventTypes.TOP_STALLED, 'stalled'], + [TopLevelEventTypes.TOP_SUSPEND, 'suspend'], + [TopLevelEventTypes.TOP_TIME_UPDATE, 'timeUpdate'], + [TopLevelEventTypes.TOP_VOLUME_CHANGE, 'volumeChange'], + [TopLevelEventTypes.TOP_WAITING, 'waiting'], +].forEach(function(tuple) { + const topLevelType = tuple[0]; + const eventType = tuple[1]; + /** * @param {!Element|ReactDOMComponent} domComponentOrNode * @param {?Event} nativeEventData Fake native event to use in SyntheticEvent. */ ReactTestUtils.SimulateNative[eventType] = makeNativeSimulator( eventType, + topLevelType, ); }); diff --git a/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js b/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js index 07fbe1692aa6a..6a510d1724cc4 100644 --- a/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js +++ b/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js @@ -17,6 +17,7 @@ let ReactNative; let ResponderEventPlugin; let UIManager; let createReactNativeComponentClass; +let TopLevelEventTypes; // Parallels requireNativeComponent() in that it lazily constructs a view config, // And registers view manager event types with ReactNativeViewConfigRegistry. @@ -71,6 +72,7 @@ beforeEach(() => { UIManager = require('UIManager'); createReactNativeComponentClass = require('ReactNativeViewConfigRegistry') .register; + TopLevelEventTypes = require('events/TopLevelEventTypes'); }); it('fails if unknown/unsupported event types are dispatched', () => { @@ -128,12 +130,12 @@ it('handles events', () => { )[0]; EventEmitter.receiveTouches( - 'topTouchStart', + TopLevelEventTypes.TOP_TOUCH_START, [{target: innerTag, identifier: 17}], [0], ); EventEmitter.receiveTouches( - 'topTouchEnd', + TopLevelEventTypes.TOP_TOUCH_END, [{target: innerTag, identifier: 17}], [0], ); @@ -200,23 +202,23 @@ it('handles events on text nodes', () => { )[0]; EventEmitter.receiveTouches( - 'topTouchStart', + TopLevelEventTypes.TOP_TOUCH_START, [{target: innerTagString, identifier: 17}], [0], ); EventEmitter.receiveTouches( - 'topTouchEnd', + TopLevelEventTypes.TOP_TOUCH_END, [{target: innerTagString, identifier: 17}], [0], ); EventEmitter.receiveTouches( - 'topTouchStart', + TopLevelEventTypes.TOP_TOUCH_START, [{target: innerTagNumber, identifier: 18}], [0], ); EventEmitter.receiveTouches( - 'topTouchEnd', + TopLevelEventTypes.TOP_TOUCH_END, [{target: innerTagNumber, identifier: 18}], [0], ); @@ -276,7 +278,7 @@ it('handles when a responder is unmounted while a touch sequence is in progress' ); EventEmitter.receiveTouches( - 'topTouchStart', + TopLevelEventTypes.TOP_TOUCH_START, [{target: getViewById('one'), identifier: 17}], [0], ); @@ -304,7 +306,7 @@ it('handles when a responder is unmounted while a touch sequence is in progress' // log.splice(0); EventEmitter.receiveTouches( - 'topTouchEnd', + TopLevelEventTypes.TOP_TOUCH_END, [{target: getViewById('two'), identifier: 17}], [0], ); @@ -313,7 +315,7 @@ it('handles when a responder is unmounted while a touch sequence is in progress' expect(log).toEqual([]); EventEmitter.receiveTouches( - 'topTouchStart', + TopLevelEventTypes.TOP_TOUCH_START, [{target: getViewById('two'), identifier: 17}], [0], ); @@ -373,7 +375,7 @@ it('handles events without target', () => { render(true); EventEmitter.receiveTouches( - 'topTouchStart', + TopLevelEventTypes.TOP_TOUCH_START, [{target: getViewById('one'), identifier: 17}], [0], ); @@ -382,7 +384,7 @@ it('handles events without target', () => { render(false); EventEmitter.receiveTouches( - 'topTouchEnd', + TopLevelEventTypes.TOP_TOUCH_END, [{target: getViewById('one'), identifier: 17}], [0], ); @@ -390,7 +392,7 @@ it('handles events without target', () => { expect(getResponderId()).toBe(null); EventEmitter.receiveTouches( - 'topTouchStart', + TopLevelEventTypes.TOP_TOUCH_START, [{target: getViewById('two'), identifier: 18}], [0], ); @@ -398,7 +400,7 @@ it('handles events without target', () => { expect(getResponderId()).toBe('two'); EventEmitter.receiveTouches( - 'topTouchEnd', + TopLevelEventTypes.TOP_TOUCH_END, [{target: getViewById('two'), identifier: 18}], [0], ); From 4a7114ee7c213f5adbfe61e484e1227f59157551 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 17 Apr 2018 10:50:56 +0200 Subject: [PATCH 16/45] Make it pretty --- .../react-dom/src/__tests__/ReactDOM-test.js | 2 +- .../src/__tests__/ReactDOMFiber-test.js | 6 +++- .../src/__tests__/ReactDOMInput-test.js | 2 +- .../src/events/BrowserEventConstants.js | 29 ++++++++++++++----- .../react-dom/src/events/SimpleEventPlugin.js | 11 +++++-- .../react-dom/src/events/TapEventPlugin.js | 6 +--- 6 files changed, 37 insertions(+), 19 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactDOM-test.js b/packages/react-dom/src/__tests__/ReactDOM-test.js index 32ad6ebed6f2d..1af9656703ec4 100644 --- a/packages/react-dom/src/__tests__/ReactDOM-test.js +++ b/packages/react-dom/src/__tests__/ReactDOM-test.js @@ -13,7 +13,7 @@ let React = require('react'); let ReactDOM = require('react-dom'); const ReactTestUtils = require('react-dom/test-utils'); -const { TOP_CLICK } = require('events/TopLevelEventTypes'); +const {TOP_CLICK} = require('events/TopLevelEventTypes'); describe('ReactDOM', () => { // TODO: uncomment this test once we can run in phantom, which diff --git a/packages/react-dom/src/__tests__/ReactDOMFiber-test.js b/packages/react-dom/src/__tests__/ReactDOMFiber-test.js index a280d1b1309de..2044b47961952 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFiber-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFiber-test.js @@ -14,7 +14,11 @@ const ReactDOM = require('react-dom'); const ReactTestUtils = require('react-dom/test-utils'); const PropTypes = require('prop-types'); -const { TOP_CLICK, TOP_MOUSE_OUT, TOP_MOUSE_OVER } = require('events/TopLevelEventTypes'); +const { + TOP_CLICK, + TOP_MOUSE_OUT, + TOP_MOUSE_OVER, +} = require('events/TopLevelEventTypes'); describe('ReactDOMFiber', () => { let container; diff --git a/packages/react-dom/src/__tests__/ReactDOMInput-test.js b/packages/react-dom/src/__tests__/ReactDOMInput-test.js index f35e33e3b3207..b90820fbd1ac7 100644 --- a/packages/react-dom/src/__tests__/ReactDOMInput-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMInput-test.js @@ -11,7 +11,7 @@ const emptyFunction = require('fbjs/lib/emptyFunction'); -const { TOP_INPUT } = require('events/TopLevelEventTypes'); +const {TOP_INPUT} = require('events/TopLevelEventTypes'); describe('ReactDOMInput', () => { let React; diff --git a/packages/react-dom/src/events/BrowserEventConstants.js b/packages/react-dom/src/events/BrowserEventConstants.js index 9f563eb370df3..5f031ef33a39e 100644 --- a/packages/react-dom/src/events/BrowserEventConstants.js +++ b/packages/react-dom/src/events/BrowserEventConstants.js @@ -21,9 +21,18 @@ import getVendorPrefixedEventName from './getVendorPrefixedEventName'; * at `document` would cause duplicate events so we don't include them here. */ export const topLevelTypes: Map = new Map([ - [TopLevelEventTypes.TOP_ANIMATION_END, getVendorPrefixedEventName('animationend')], - [TopLevelEventTypes.TOP_ANIMATION_ITERATION, getVendorPrefixedEventName('animationiteration')], - [TopLevelEventTypes.TOP_ANIMATION_START, getVendorPrefixedEventName('animationstart')], + [ + TopLevelEventTypes.TOP_ANIMATION_END, + getVendorPrefixedEventName('animationend'), + ], + [ + TopLevelEventTypes.TOP_ANIMATION_ITERATION, + getVendorPrefixedEventName('animationiteration'), + ], + [ + TopLevelEventTypes.TOP_ANIMATION_START, + getVendorPrefixedEventName('animationstart'), + ], [TopLevelEventTypes.TOP_BLUR, 'blur'], [TopLevelEventTypes.TOP_CANCEL, 'cancel'], [TopLevelEventTypes.TOP_CHANGE, 'change'], @@ -64,7 +73,10 @@ export const topLevelTypes: Map = new Map([ [TopLevelEventTypes.TOP_TOUCH_END, 'touchend'], [TopLevelEventTypes.TOP_TOUCH_MOVE, 'touchmove'], [TopLevelEventTypes.TOP_TOUCH_START, 'touchstart'], - [TopLevelEventTypes.TOP_TRANSITION_END, getVendorPrefixedEventName('transitionend')], + [ + TopLevelEventTypes.TOP_TRANSITION_END, + getVendorPrefixedEventName('transitionend'), + ], [TopLevelEventTypes.TOP_WHEEL, 'wheel'], ]); @@ -106,10 +118,11 @@ const nonTopEventTypes: Map = new Map([ [TopLevelEventTypes.TOP_SUBMIT, 'submit'], ]); -export function getRawEventName(topLevelType: TopLevelTypes): ?string { - const eventName: ?string = topLevelTypes.get(topLevelType) - || mediaEventTypes.get(topLevelType) - || nonTopEventTypes.get(topLevelType); +export function getRawEventName(topLevelType: TopLevelTypes): string { + const eventName = + topLevelTypes.get(topLevelType) || + mediaEventTypes.get(topLevelType) || + nonTopEventTypes.get(topLevelType); invariant( eventName, diff --git a/packages/react-dom/src/events/SimpleEventPlugin.js b/packages/react-dom/src/events/SimpleEventPlugin.js index 96d6ef5add8fa..1ec82550c16f3 100644 --- a/packages/react-dom/src/events/SimpleEventPlugin.js +++ b/packages/react-dom/src/events/SimpleEventPlugin.js @@ -33,7 +33,6 @@ import SyntheticUIEvent from './SyntheticUIEvent'; import SyntheticWheelEvent from './SyntheticWheelEvent'; import getEventCharCode from './getEventCharCode'; - /** * Turns * ['abort', ...] @@ -124,9 +123,15 @@ const nonInteractiveEventTypeNames: Array = [ ]; const eventTypes: EventTypes = {}; -const topLevelEventsToDispatchConfig: Map = new Map(); +const topLevelEventsToDispatchConfig: Map< + TopLevelTypes, + DispatchConfig, +> = new Map(); -function addEventTypeNameToConfig(eventTuple: EventTuple, isInteractive: boolean) { +function addEventTypeNameToConfig( + eventTuple: EventTuple, + isInteractive: boolean, +) { const topEvent = eventTuple[0]; const event = eventTuple[1]; const capitalizedEvent = event[0].toUpperCase() + event.slice(1); diff --git a/packages/react-dom/src/events/TapEventPlugin.js b/packages/react-dom/src/events/TapEventPlugin.js index e3eae2155eb3d..1cbae966bada8 100644 --- a/packages/react-dom/src/events/TapEventPlugin.js +++ b/packages/react-dom/src/events/TapEventPlugin.js @@ -91,11 +91,7 @@ const touchEvents = [ TOP_TOUCH_MOVE, ]; -const dependencies = [ - TOP_MOUSE_DOWN, - TOP_MOUSE_MOVE, - TOP_MOUSE_UP, -].concat( +const dependencies = [TOP_MOUSE_DOWN, TOP_MOUSE_MOVE, TOP_MOUSE_UP].concat( touchEvents, ); From 2a87568cd481f8c775fe68e35be9abd7d9fa5f3a Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 17 Apr 2018 11:06:46 +0200 Subject: [PATCH 17/45] Fix completly unrelated typo --- fixtures/dom/src/components/fixtures/password-inputs/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fixtures/dom/src/components/fixtures/password-inputs/index.js b/fixtures/dom/src/components/fixtures/password-inputs/index.js index f94dce97dcefc..1c37f09d58ba9 100644 --- a/fixtures/dom/src/components/fixtures/password-inputs/index.js +++ b/fixtures/dom/src/components/fixtures/password-inputs/index.js @@ -15,7 +15,7 @@ function NumberInputs() { `} affectedBrowsers="IE Edge, IE 11"> -
  • Type any string (not an actual password
  • +
  • Type any string (not an actual password)
  • From 0d864caa78c0931b5e0ef4f6f21cfcced8ea7b95 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 17 Apr 2018 16:04:57 +0200 Subject: [PATCH 18/45] =?UTF-8?q?Don=E2=80=99t=20use=20map=20constructor?= =?UTF-8?q?=20because=20of=20IE11?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/events/BrowserEventConstants.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/react-dom/src/events/BrowserEventConstants.js b/packages/react-dom/src/events/BrowserEventConstants.js index 5f031ef33a39e..8b1e8e44bc93e 100644 --- a/packages/react-dom/src/events/BrowserEventConstants.js +++ b/packages/react-dom/src/events/BrowserEventConstants.js @@ -13,6 +13,18 @@ import invariant from 'fbjs/lib/invariant'; import getVendorPrefixedEventName from './getVendorPrefixedEventName'; +/** + * Small helper function to create a map using the Map constructor arguments. + * This is needed because IE11 does not implement that constructor. + */ +function makeMap(values: Array<[K, V]>): Map { + const map: Map = new Map(); + values.forEach(([k, v]) => { + map.set(k, v); + }); + return map; +} + /** * Types of raw signals from the browser caught at the top level. * @@ -20,7 +32,7 @@ import getVendorPrefixedEventName from './getVendorPrefixedEventName'; * bubble (which we trap at a lower node than `document`), binding * at `document` would cause duplicate events so we don't include them here. */ -export const topLevelTypes: Map = new Map([ +export const topLevelTypes: Map = makeMap([ [ TopLevelEventTypes.TOP_ANIMATION_END, getVendorPrefixedEventName('animationend'), @@ -85,7 +97,7 @@ export const topLevelTypes: Map = new Map([ // "top-level" since they don't bubble. We should come up // with a better naming convention if we come to refactoring // the event system. -export const mediaEventTypes: Map = new Map([ +export const mediaEventTypes: Map = makeMap([ [TopLevelEventTypes.TOP_ABORT, 'abort'], [TopLevelEventTypes.TOP_CAN_PLAY, 'canplay'], [TopLevelEventTypes.TOP_CAN_PLAY_THROUGH, 'canplaythrough'], @@ -111,7 +123,7 @@ export const mediaEventTypes: Map = new Map([ [TopLevelEventTypes.TOP_WAITING, 'waiting'], ]); -const nonTopEventTypes: Map = new Map([ +const nonTopEventTypes: Map = makeMap([ [TopLevelEventTypes.TOP_INPUT, 'input'], [TopLevelEventTypes.TOP_INVALID, 'invalid'], [TopLevelEventTypes.TOP_RESET, 'reset'], From 586708e61adbd5893f72bccb1ca15d7302fd0a2b Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Sat, 21 Apr 2018 12:08:02 +0200 Subject: [PATCH 19/45] Update typings, revert changes to native code --- packages/events/EventPluginHub.js | 6 ++-- packages/events/PluginModuleType.js | 3 +- packages/events/ReactSyntheticEventType.js | 3 +- packages/events/TopLevelEventTypes.js | 2 +- .../src/events/BeforeInputEventPlugin.js | 8 +++--- .../src/events/BrowserEventConstants.js | 10 +++---- .../react-dom/src/events/SimpleEventPlugin.js | 12 ++++---- .../react-dom/src/events/TapEventPlugin.js | 4 +-- .../src/ReactNativeBridgeEventPlugin.js | 4 +-- .../src/ReactNativeEventEmitter.js | 5 ++-- .../ReactNativeEvents-test.internal.js | 28 +++++++++---------- 11 files changed, 42 insertions(+), 43 deletions(-) diff --git a/packages/events/EventPluginHub.js b/packages/events/EventPluginHub.js index 140c9bfc7e39a..27840402efe82 100644 --- a/packages/events/EventPluginHub.js +++ b/packages/events/EventPluginHub.js @@ -25,7 +25,7 @@ import type {PluginModule} from './PluginModuleType'; import type {ReactSyntheticEvent} from './ReactSyntheticEventType'; import type {Fiber} from 'react-reconciler/src/ReactFiber'; import type {AnyNativeEvent} from './PluginModuleType'; -import type {TopLevelTypes} from './TopLevelEventTypes'; +import type {TopLevelType} from './TopLevelEventTypes'; /** * Internal queue of events that have accumulated their dispatches and are @@ -166,7 +166,7 @@ export function getListener(inst: Fiber, registrationName: string) { * @internal */ function extractEvents( - topLevelType: TopLevelTypes, + topLevelType: TopLevelType, targetInst: Fiber, nativeEvent: AnyNativeEvent, nativeEventTarget: EventTarget, @@ -228,7 +228,7 @@ export function runEventsInBatch( } export function runExtractedEventsInBatch( - topLevelType: TopLevelTypes, + topLevelType: TopLevelType, targetInst: Fiber, nativeEvent: AnyNativeEvent, nativeEventTarget: EventTarget, diff --git a/packages/events/PluginModuleType.js b/packages/events/PluginModuleType.js index 8bac932e23f50..26e7637f40e82 100644 --- a/packages/events/PluginModuleType.js +++ b/packages/events/PluginModuleType.js @@ -12,6 +12,7 @@ import type { DispatchConfig, ReactSyntheticEvent, } from './ReactSyntheticEventType'; +import type { TopLevelType } from './TopLevelEventTypes'; export type EventTypes = {[key: string]: DispatchConfig}; @@ -22,7 +23,7 @@ export type PluginName = string; export type PluginModule = { eventTypes: EventTypes, extractEvents: ( - topLevelType: number, + topLevelType: TopLevelType, targetInst: Fiber, nativeTarget: NativeEvent, nativeEventTarget: EventTarget, diff --git a/packages/events/ReactSyntheticEventType.js b/packages/events/ReactSyntheticEventType.js index 8319074b0a191..2f248f7029855 100644 --- a/packages/events/ReactSyntheticEventType.js +++ b/packages/events/ReactSyntheticEventType.js @@ -9,9 +9,10 @@ */ import type {Fiber} from 'react-reconciler/src/ReactFiber'; +import type {TopLevelType} from './TopLevelEventTypes'; export type DispatchConfig = { - dependencies: Array, + dependencies: Array, phasedRegistrationNames?: { bubbled: string, captured: string, diff --git a/packages/events/TopLevelEventTypes.js b/packages/events/TopLevelEventTypes.js index 8e7eabf5236e6..07bb3071dac6b 100644 --- a/packages/events/TopLevelEventTypes.js +++ b/packages/events/TopLevelEventTypes.js @@ -79,4 +79,4 @@ export const TOP_VOLUME_CHANGE = 68; export const TOP_WAITING = 69; export const TOP_WHEEL = 70; -export type TopLevelTypes = number; +export type TopLevelType = number | string; diff --git a/packages/react-dom/src/events/BeforeInputEventPlugin.js b/packages/react-dom/src/events/BeforeInputEventPlugin.js index 034b0fd147f85..237a153dbdd4a 100644 --- a/packages/react-dom/src/events/BeforeInputEventPlugin.js +++ b/packages/react-dom/src/events/BeforeInputEventPlugin.js @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import type {TopLevelTypes} from 'events/TopLevelEventTypes'; +import type {TopLevelType} from 'events/TopLevelEventTypes'; import {accumulateTwoPhaseDispatches} from 'events/EventPropagators'; import { @@ -264,11 +264,11 @@ function extractCompositionEvent( } /** - * @param {TopLevelTypes} topLevelType Number from `TopLevelTypes`. + * @param {TopLevelType} topLevelType Number from `TopLevelType`. * @param {object} nativeEvent Native browser event. * @return {?string} The string corresponding to this `beforeInput` event. */ -function getNativeBeforeInputChars(topLevelType: TopLevelTypes, nativeEvent) { +function getNativeBeforeInputChars(topLevelType: TopLevelType, nativeEvent) { switch (topLevelType) { case TOP_COMPOSITION_END: return getDataFromCustomEvent(nativeEvent); @@ -322,7 +322,7 @@ function getNativeBeforeInputChars(topLevelType: TopLevelTypes, nativeEvent) { * @param {object} nativeEvent Native browser event. * @return {?string} The fallback string for this `beforeInput` event. */ -function getFallbackBeforeInputChars(topLevelType: TopLevelTypes, nativeEvent) { +function getFallbackBeforeInputChars(topLevelType: TopLevelType, nativeEvent) { // If we are currently composing (IME) and using a fallback to do so, // try to extract the composed characters from the fallback object. // If composition event is available, we extract a string only at diff --git a/packages/react-dom/src/events/BrowserEventConstants.js b/packages/react-dom/src/events/BrowserEventConstants.js index 8b1e8e44bc93e..e269919334838 100644 --- a/packages/react-dom/src/events/BrowserEventConstants.js +++ b/packages/react-dom/src/events/BrowserEventConstants.js @@ -8,7 +8,7 @@ */ import * as TopLevelEventTypes from 'events/TopLevelEventTypes'; -import type {TopLevelTypes} from 'events/TopLevelEventTypes'; +import type {TopLevelType} from 'events/TopLevelEventTypes'; import invariant from 'fbjs/lib/invariant'; import getVendorPrefixedEventName from './getVendorPrefixedEventName'; @@ -32,7 +32,7 @@ function makeMap(values: Array<[K, V]>): Map { * bubble (which we trap at a lower node than `document`), binding * at `document` would cause duplicate events so we don't include them here. */ -export const topLevelTypes: Map = makeMap([ +export const topLevelTypes: Map = makeMap([ [ TopLevelEventTypes.TOP_ANIMATION_END, getVendorPrefixedEventName('animationend'), @@ -97,7 +97,7 @@ export const topLevelTypes: Map = makeMap([ // "top-level" since they don't bubble. We should come up // with a better naming convention if we come to refactoring // the event system. -export const mediaEventTypes: Map = makeMap([ +export const mediaEventTypes: Map = makeMap([ [TopLevelEventTypes.TOP_ABORT, 'abort'], [TopLevelEventTypes.TOP_CAN_PLAY, 'canplay'], [TopLevelEventTypes.TOP_CAN_PLAY_THROUGH, 'canplaythrough'], @@ -123,14 +123,14 @@ export const mediaEventTypes: Map = makeMap([ [TopLevelEventTypes.TOP_WAITING, 'waiting'], ]); -const nonTopEventTypes: Map = makeMap([ +const nonTopEventTypes: Map = makeMap([ [TopLevelEventTypes.TOP_INPUT, 'input'], [TopLevelEventTypes.TOP_INVALID, 'invalid'], [TopLevelEventTypes.TOP_RESET, 'reset'], [TopLevelEventTypes.TOP_SUBMIT, 'submit'], ]); -export function getRawEventName(topLevelType: TopLevelTypes): string { +export function getRawEventName(topLevelType: TopLevelType): string { const eventName = topLevelTypes.get(topLevelType) || mediaEventTypes.get(topLevelType) || diff --git a/packages/react-dom/src/events/SimpleEventPlugin.js b/packages/react-dom/src/events/SimpleEventPlugin.js index 1ec82550c16f3..31b96a14b5a23 100644 --- a/packages/react-dom/src/events/SimpleEventPlugin.js +++ b/packages/react-dom/src/events/SimpleEventPlugin.js @@ -7,7 +7,7 @@ * @flow */ -import type {TopLevelTypes} from 'events/TopLevelEventTypes'; +import type {TopLevelType} from 'events/TopLevelEventTypes'; import type { DispatchConfig, ReactSyntheticEvent, @@ -51,7 +51,7 @@ import getEventCharCode from './getEventCharCode'; * [TOP_ABORT, { sameConfig }], * ]); */ -type EventTuple = [TopLevelTypes, string]; +type EventTuple = [TopLevelType, string]; const interactiveEventTypeNames: Array = [ [TopLevelEventTypes.TOP_BLUR, 'blur'], [TopLevelEventTypes.TOP_CANCEL, 'cancel'], @@ -124,7 +124,7 @@ const nonInteractiveEventTypeNames: Array = [ const eventTypes: EventTypes = {}; const topLevelEventsToDispatchConfig: Map< - TopLevelTypes, + TopLevelType, DispatchConfig, > = new Map(); @@ -157,7 +157,7 @@ nonInteractiveEventTypeNames.forEach(eventTuple => { }); // Only used in DEV for exhaustiveness validation. -const knownHTMLTopLevelTypes: Array = [ +const knownHTMLTopLevelTypes: Array = [ TopLevelEventTypes.TOP_ABORT, TopLevelEventTypes.TOP_CANCEL, TopLevelEventTypes.TOP_CAN_PLAY, @@ -194,13 +194,13 @@ const knownHTMLTopLevelTypes: Array = [ const SimpleEventPlugin: PluginModule = { eventTypes: eventTypes, - isInteractiveTopLevelEventType(topLevelType: TopLevelTypes): boolean { + isInteractiveTopLevelEventType(topLevelType: TopLevelType): boolean { const config = topLevelEventsToDispatchConfig.get(topLevelType); return config !== undefined && config.isInteractive === true; }, extractEvents: function( - topLevelType: TopLevelTypes, + topLevelType: TopLevelType, targetInst: Fiber, nativeEvent: MouseEvent, nativeEventTarget: EventTarget, diff --git a/packages/react-dom/src/events/TapEventPlugin.js b/packages/react-dom/src/events/TapEventPlugin.js index 1cbae966bada8..73533b86228fb 100644 --- a/packages/react-dom/src/events/TapEventPlugin.js +++ b/packages/react-dom/src/events/TapEventPlugin.js @@ -19,7 +19,7 @@ import { TOP_TOUCH_MOVE, TOP_TOUCH_START, } from 'events/TopLevelEventTypes'; -import type {TopLevelTypes} from 'events/TopLevelEventTypes'; +import type {TopLevelType} from 'events/TopLevelEventTypes'; import SyntheticUIEvent from './SyntheticUIEvent'; @@ -115,7 +115,7 @@ const TapEventPlugin = { eventTypes: eventTypes, extractEvents: function( - topLevelType: TopLevelTypes, + topLevelType: TopLevelType, targetInst: mixed, nativeEvent: _Touch, nativeEventTarget: EventTarget, diff --git a/packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js b/packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js index 100cca947f962..59cd7c8f28b2f 100644 --- a/packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js +++ b/packages/react-native-renderer/src/ReactNativeBridgeEventPlugin.js @@ -12,7 +12,7 @@ import { accumulateTwoPhaseDispatches, accumulateDirectDispatches, } from 'events/EventPropagators'; -import type {TopLevelTypes} from 'events/TopLevelEventTypes'; +import type {TopLevelType} from 'events/TopLevelEventTypes'; import * as ReactNativeViewConfigRegistry from 'ReactNativeViewConfigRegistry'; import SyntheticEvent from 'events/SyntheticEvent'; import invariant from 'fbjs/lib/invariant'; @@ -30,7 +30,7 @@ const ReactNativeBridgeEventPlugin = { * @see {EventPluginHub.extractEvents} */ extractEvents: function( - topLevelType: TopLevelTypes, + topLevelType: TopLevelType, targetInst: Object, nativeEvent: AnyNativeEvent, nativeEventTarget: Object, diff --git a/packages/react-native-renderer/src/ReactNativeEventEmitter.js b/packages/react-native-renderer/src/ReactNativeEventEmitter.js index 916bad7818037..e43644a620826 100644 --- a/packages/react-native-renderer/src/ReactNativeEventEmitter.js +++ b/packages/react-native-renderer/src/ReactNativeEventEmitter.js @@ -15,7 +15,6 @@ import warning from 'fbjs/lib/warning'; import {getInstanceFromNode} from './ReactNativeComponentTree'; import type {AnyNativeEvent} from 'events/PluginModuleType'; -import type {TopLevelTypes} from 'events/TopLevelEventTypes'; export {getListener, registrationNameModules as registrationNames}; @@ -89,7 +88,7 @@ const removeTouchesAtIndices = function( */ export function _receiveRootNodeIDEvent( rootNodeID: number, - topLevelType: TopLevelTypes, + topLevelType: string, nativeEventParam: ?AnyNativeEvent, ) { const nativeEvent = nativeEventParam || EMPTY_NATIVE_EVENT; @@ -115,7 +114,7 @@ export function _receiveRootNodeIDEvent( */ export function receiveEvent( rootNodeID: number, - topLevelType: TopLevelTypes, + topLevelType: string, nativeEventParam: AnyNativeEvent, ) { _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam); diff --git a/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js b/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js index 6a510d1724cc4..07fbe1692aa6a 100644 --- a/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js +++ b/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js @@ -17,7 +17,6 @@ let ReactNative; let ResponderEventPlugin; let UIManager; let createReactNativeComponentClass; -let TopLevelEventTypes; // Parallels requireNativeComponent() in that it lazily constructs a view config, // And registers view manager event types with ReactNativeViewConfigRegistry. @@ -72,7 +71,6 @@ beforeEach(() => { UIManager = require('UIManager'); createReactNativeComponentClass = require('ReactNativeViewConfigRegistry') .register; - TopLevelEventTypes = require('events/TopLevelEventTypes'); }); it('fails if unknown/unsupported event types are dispatched', () => { @@ -130,12 +128,12 @@ it('handles events', () => { )[0]; EventEmitter.receiveTouches( - TopLevelEventTypes.TOP_TOUCH_START, + 'topTouchStart', [{target: innerTag, identifier: 17}], [0], ); EventEmitter.receiveTouches( - TopLevelEventTypes.TOP_TOUCH_END, + 'topTouchEnd', [{target: innerTag, identifier: 17}], [0], ); @@ -202,23 +200,23 @@ it('handles events on text nodes', () => { )[0]; EventEmitter.receiveTouches( - TopLevelEventTypes.TOP_TOUCH_START, + 'topTouchStart', [{target: innerTagString, identifier: 17}], [0], ); EventEmitter.receiveTouches( - TopLevelEventTypes.TOP_TOUCH_END, + 'topTouchEnd', [{target: innerTagString, identifier: 17}], [0], ); EventEmitter.receiveTouches( - TopLevelEventTypes.TOP_TOUCH_START, + 'topTouchStart', [{target: innerTagNumber, identifier: 18}], [0], ); EventEmitter.receiveTouches( - TopLevelEventTypes.TOP_TOUCH_END, + 'topTouchEnd', [{target: innerTagNumber, identifier: 18}], [0], ); @@ -278,7 +276,7 @@ it('handles when a responder is unmounted while a touch sequence is in progress' ); EventEmitter.receiveTouches( - TopLevelEventTypes.TOP_TOUCH_START, + 'topTouchStart', [{target: getViewById('one'), identifier: 17}], [0], ); @@ -306,7 +304,7 @@ it('handles when a responder is unmounted while a touch sequence is in progress' // log.splice(0); EventEmitter.receiveTouches( - TopLevelEventTypes.TOP_TOUCH_END, + 'topTouchEnd', [{target: getViewById('two'), identifier: 17}], [0], ); @@ -315,7 +313,7 @@ it('handles when a responder is unmounted while a touch sequence is in progress' expect(log).toEqual([]); EventEmitter.receiveTouches( - TopLevelEventTypes.TOP_TOUCH_START, + 'topTouchStart', [{target: getViewById('two'), identifier: 17}], [0], ); @@ -375,7 +373,7 @@ it('handles events without target', () => { render(true); EventEmitter.receiveTouches( - TopLevelEventTypes.TOP_TOUCH_START, + 'topTouchStart', [{target: getViewById('one'), identifier: 17}], [0], ); @@ -384,7 +382,7 @@ it('handles events without target', () => { render(false); EventEmitter.receiveTouches( - TopLevelEventTypes.TOP_TOUCH_END, + 'topTouchEnd', [{target: getViewById('one'), identifier: 17}], [0], ); @@ -392,7 +390,7 @@ it('handles events without target', () => { expect(getResponderId()).toBe(null); EventEmitter.receiveTouches( - TopLevelEventTypes.TOP_TOUCH_START, + 'topTouchStart', [{target: getViewById('two'), identifier: 18}], [0], ); @@ -400,7 +398,7 @@ it('handles events without target', () => { expect(getResponderId()).toBe('two'); EventEmitter.receiveTouches( - TopLevelEventTypes.TOP_TOUCH_END, + 'topTouchEnd', [{target: getViewById('two'), identifier: 18}], [0], ); From 12c9ac3fe76278930fbb718159ef41334bca5251 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Sat, 21 Apr 2018 13:08:10 +0200 Subject: [PATCH 20/45] Make topLevelTypes in ResponderEventPlugin injectable and create DOM and ReactNative variant --- packages/events/EventPluginUtils.js | 25 -- packages/events/PluginModuleType.js | 2 +- packages/events/ResponderEventPlugin.js | 64 ++++- packages/events/ResponderTouchHistoryStore.js | 29 +- packages/events/TopLevelEventTypes.js | 72 ----- .../ResponderEventPlugin-test.internal.js | 7 +- .../react-dom/src/__tests__/ReactDOM-test.js | 2 +- .../src/__tests__/ReactDOMFiber-test.js | 2 +- .../src/__tests__/ReactDOMInput-test.js | 2 +- .../src/client/ReactDOMFiberComponent.js | 16 +- .../src/events/BeforeInputEventPlugin.js | 6 +- .../src/events/BrowserEventConstants.js | 149 +++++----- .../react-dom/src/events/ChangeEventPlugin.js | 8 +- .../src/events/DOMEventPluginOrder.js | 4 +- .../src/events/DOMEventPluginUtils.js | 31 +++ .../src/events/DOMResponderEventPlugin.js | 34 +++ .../src/events/DOMTopLevelEventTypes.js | 80 ++++++ .../src/events/EnterLeaveEventPlugin.js | 2 +- .../src/events/ReactBrowserEventEmitter.js | 2 +- .../react-dom/src/events/SelectEventPlugin.js | 10 +- .../react-dom/src/events/SimpleEventPlugin.js | 262 +++++++++--------- .../react-dom/src/events/TapEventPlugin.js | 8 +- .../__tests__/TapEventPlugin-test.internal.js | 0 .../src/test-utils/ReactTestUtils.js | 141 +++++----- .../ReactDOMUnstableNativeDependencies.js | 5 +- .../src/ReactNativeEventPluginOrder.js | 2 +- .../src/ReactNativeInjectionShared.js | 6 +- .../src/ReactNativeResponderEventPlugin.js | 22 ++ 28 files changed, 567 insertions(+), 426 deletions(-) create mode 100644 packages/react-dom/src/events/DOMEventPluginUtils.js create mode 100644 packages/react-dom/src/events/DOMResponderEventPlugin.js create mode 100644 packages/react-dom/src/events/DOMTopLevelEventTypes.js rename packages/react-dom/src/{ => events}/__tests__/TapEventPlugin-test.internal.js (100%) create mode 100644 packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js diff --git a/packages/events/EventPluginUtils.js b/packages/events/EventPluginUtils.js index dbb2c7fa33565..19a89e30de825 100644 --- a/packages/events/EventPluginUtils.js +++ b/packages/events/EventPluginUtils.js @@ -9,16 +9,6 @@ import ReactErrorUtils from 'shared/ReactErrorUtils'; import invariant from 'fbjs/lib/invariant'; import warning from 'fbjs/lib/warning'; -import { - TOP_MOUSE_DOWN, - TOP_MOUSE_MOVE, - TOP_MOUSE_UP, - TOP_TOUCH_CANCEL, - TOP_TOUCH_END, - TOP_TOUCH_MOVE, - TOP_TOUCH_START, -} from './TopLevelEventTypes'; - export let getFiberCurrentPropsFromNode = null; export let getInstanceFromNode = null; export let getNodeFromInstance = null; @@ -40,21 +30,6 @@ export const injection = { }, }; -export function isEndish(topLevelType) { - return ( - topLevelType === TOP_MOUSE_UP || - topLevelType === TOP_TOUCH_END || - topLevelType === TOP_TOUCH_CANCEL - ); -} - -export function isMoveish(topLevelType) { - return topLevelType === TOP_MOUSE_MOVE || topLevelType === TOP_TOUCH_MOVE; -} -export function isStartish(topLevelType) { - return topLevelType === TOP_MOUSE_DOWN || topLevelType === TOP_TOUCH_START; -} - let validateEventDispatches; if (__DEV__) { validateEventDispatches = function(event) { diff --git a/packages/events/PluginModuleType.js b/packages/events/PluginModuleType.js index 26e7637f40e82..22d53b1ccb567 100644 --- a/packages/events/PluginModuleType.js +++ b/packages/events/PluginModuleType.js @@ -12,7 +12,7 @@ import type { DispatchConfig, ReactSyntheticEvent, } from './ReactSyntheticEventType'; -import type { TopLevelType } from './TopLevelEventTypes'; +import type {TopLevelType} from './TopLevelEventTypes'; export type EventTypes = {[key: string]: DispatchConfig}; diff --git a/packages/events/ResponderEventPlugin.js b/packages/events/ResponderEventPlugin.js index e4a01add7efe4..9c3010f1e38c7 100644 --- a/packages/events/ResponderEventPlugin.js +++ b/packages/events/ResponderEventPlugin.js @@ -6,11 +6,9 @@ */ import {getLowestCommonAncestor, isAncestor} from 'shared/ReactTreeTraversal'; +import invariant from 'fbjs/lib/invariant'; import { - isStartish, - isMoveish, - isEndish, executeDirectDispatch, hasDispatches, executeDispatchesInOrderStopAtTrue, @@ -23,13 +21,37 @@ import { } from './EventPropagators'; import ResponderSyntheticEvent from './ResponderSyntheticEvent'; import ResponderTouchHistoryStore from './ResponderTouchHistoryStore'; -import { - TOP_SCROLL, - TOP_SELECTION_CHANGE, - TOP_TOUCH_CANCEL, -} from './TopLevelEventTypes'; import accumulate from './accumulate'; + +function isStartish(topLevelType) { + return ( + topLevelType === ResponderEventPlugin.TopLevelTypes.topMouseDown || + topLevelType === ResponderEventPlugin.TopLevelTypes.topTouchStart + ); +} + +function isMoveish(topLevelType) { + return ( + topLevelType === ResponderEventPlugin.TopLevelTypes.topMouseMove || + topLevelType === ResponderEventPlugin.TopLevelTypes.topTouchMove + ); +} + +function isEndish(topLevelType) { + return ( + topLevelType === ResponderEventPlugin.TopLevelTypes.topMouseUp || + topLevelType === ResponderEventPlugin.TopLevelTypes.topTouchEnd || + topLevelType === ResponderEventPlugin.TopLevelTypes.topTouchCancel + ); +} + +ResponderTouchHistoryStore.injection.injectEventUtils({ + isStartish, + isMoveish, + isEndish, +}); + /** * Instance of element that should respond to touch/move types of interactions, * as indicated explicitly by relevant callbacks. @@ -327,7 +349,7 @@ function setResponderAndExtractTransfer( ? eventTypes.startShouldSetResponder : isMoveish(topLevelType) ? eventTypes.moveShouldSetResponder - : topLevelType === TOP_SELECTION_CHANGE + : topLevelType === ResponderEventPlugin.TopLevelTypes.topSelectionChange ? eventTypes.selectionChangeShouldSetResponder : eventTypes.scrollShouldSetResponder; @@ -432,8 +454,11 @@ 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 === TOP_SCROLL && !nativeEvent.responderIgnoreScroll) || - (trackedTouchCount > 0 && topLevelType === TOP_SELECTION_CHANGE) || + ((topLevelType === ResponderEventPlugin.TopLevelTypes.topScroll && + !nativeEvent.responderIgnoreScroll) || + (trackedTouchCount > 0 && + topLevelType === + ResponderEventPlugin.TopLevelTypes.topSelectionChange) || isStartish(topLevelType) || isMoveish(topLevelType)) ); @@ -484,6 +509,11 @@ const ResponderEventPlugin = { nativeEvent, nativeEventTarget, ) { + invariant( + ResponderEventPlugin.TopLevelTypes, + 'ResponderEventPlugin requires TopLevelTypes to be injected first.', + ); + if (isStartish(topLevelType)) { trackedTouchCount += 1; } else if (isEndish(topLevelType)) { @@ -539,7 +569,8 @@ const ResponderEventPlugin = { } const isResponderTerminate = - responderInst && topLevelType === TOP_TOUCH_CANCEL; + responderInst && + topLevelType === ResponderEventPlugin.TopLevelTypes.topTouchCancel; const isResponderRelease = responderInst && !isResponderTerminate && @@ -578,6 +609,7 @@ const ResponderEventPlugin = { GlobalResponderHandler: null, GlobalInteractionHandler: null, + TopLevelTypes: null, injection: { /** @@ -596,6 +628,14 @@ const ResponderEventPlugin = { injectGlobalInteractionHandler: function(GlobalInteractionHandler) { ResponderEventPlugin.GlobalInteractionHandler = GlobalInteractionHandler; }, + + /** + * @param Object TopLevelTypes + * Object that maps top level types to the ID used in the react system. + */ + injectTopLevelTypes: function(TopLevelTypes) { + ResponderEventPlugin.TopLevelTypes = TopLevelTypes; + }, }, }; diff --git a/packages/events/ResponderTouchHistoryStore.js b/packages/events/ResponderTouchHistoryStore.js index d8c3eb29ebb88..81c49aa8d6560 100644 --- a/packages/events/ResponderTouchHistoryStore.js +++ b/packages/events/ResponderTouchHistoryStore.js @@ -10,7 +10,7 @@ import invariant from 'fbjs/lib/invariant'; import warning from 'fbjs/lib/warning'; -import {isEndish, isMoveish, isStartish} from './EventPluginUtils'; +import type {TopLevelType} from './TopLevelEventTypes'; /** * Tracks the position and time of each active touch by `touch.identifier`. We @@ -176,8 +176,20 @@ function printTouchBank(): string { return printed; } +type EventUtils = { + isStartish: (topLevelType: TopLevelType) => boolean, + isMoveish: (topLevelType: TopLevelType) => boolean, + isEndish: (topLevelType: TopLevelType) => boolean, +} + const ResponderTouchHistoryStore = { - recordTouchTrack(topLevelType: number, nativeEvent: TouchEvent): void { + recordTouchTrack(topLevelType: TopLevelType, nativeEvent: TouchEvent): void { + invariant( + ResponderTouchHistoryStore.EventUtils, + 'ResponderTouchHistoryStore requires EventUtils to be injected first.', + ); + const {isStartish, isMoveish, isEndish} = ResponderTouchHistoryStore.EventUtils + if (isMoveish(topLevelType)) { nativeEvent.changedTouches.forEach(recordTouchMove); } else if (isStartish(topLevelType)) { @@ -210,6 +222,19 @@ const ResponderTouchHistoryStore = { }, touchHistory, + + EventUtils: (null: ?EventUtils), + + injection: { + /** + * @param {isMoveish: Function, isStartish: Function, isEndish: Function} GlobalResponderHandler + * Object that handles any change in responder. Use this to inject + * integration with an existing touch handling system etc. + */ + injectEventUtils: function(_EventUtils: EventUtils) { + ResponderTouchHistoryStore.EventUtils = _EventUtils; + }, + }, }; export default ResponderTouchHistoryStore; diff --git a/packages/events/TopLevelEventTypes.js b/packages/events/TopLevelEventTypes.js index 07bb3071dac6b..c5323e5440143 100644 --- a/packages/events/TopLevelEventTypes.js +++ b/packages/events/TopLevelEventTypes.js @@ -7,76 +7,4 @@ * @flow */ -export const TOP_ABORT = 0; -export const TOP_ANIMATION_END = 1; -export const TOP_ANIMATION_ITERATION = 2; -export const TOP_ANIMATION_START = 3; -export const TOP_BLUR = 4; -export const TOP_CANCEL = 5; -export const TOP_CAN_PLAY = 6; -export const TOP_CAN_PLAY_THROUGH = 7; -export const TOP_CHANGE = 8; -export const TOP_CLICK = 9; -export const TOP_CLOSE = 10; -export const TOP_COMPOSITION_END = 11; -export const TOP_COMPOSITION_START = 12; -export const TOP_COMPOSITION_UPDATE = 13; -export const TOP_CONTEXT_MENU = 14; -export const TOP_COPY = 15; -export const TOP_CUT = 16; -export const TOP_DOUBLE_CLICK = 17; -export const TOP_DRAG = 18; -export const TOP_DRAG_END = 19; -export const TOP_DRAG_ENTER = 20; -export const TOP_DRAG_EXIT = 21; -export const TOP_DRAG_LEAVE = 22; -export const TOP_DRAG_OVER = 23; -export const TOP_DRAG_START = 24; -export const TOP_DROP = 25; -export const TOP_DURATION_CHANGE = 26; -export const TOP_EMPTIED = 27; -export const TOP_ENCRYPTED = 28; -export const TOP_ENDED = 29; -export const TOP_ERROR = 30; -export const TOP_FOCUS = 31; -export const TOP_INPUT = 32; -export const TOP_INVALID = 33; -export const TOP_KEY_DOWN = 34; -export const TOP_KEY_PRESS = 35; -export const TOP_KEY_UP = 36; -export const TOP_LOADED_DATA = 37; -export const TOP_LOAD = 38; -export const TOP_LOADED_METADATA = 39; -export const TOP_LOAD_START = 40; -export const TOP_MOUSE_DOWN = 41; -export const TOP_MOUSE_MOVE = 42; -export const TOP_MOUSE_OUT = 43; -export const TOP_MOUSE_OVER = 44; -export const TOP_MOUSE_UP = 45; -export const TOP_PASTE = 46; -export const TOP_PAUSE = 47; -export const TOP_PLAY = 48; -export const TOP_PLAYING = 49; -export const TOP_PROGRESS = 50; -export const TOP_RATE_CHANGE = 51; -export const TOP_RESET = 52; -export const TOP_SCROLL = 53; -export const TOP_SEEKED = 54; -export const TOP_SEEKING = 55; -export const TOP_SELECTION_CHANGE = 56; -export const TOP_STALLED = 57; -export const TOP_SUBMIT = 58; -export const TOP_SUSPEND = 59; -export const TOP_TEXT_INPUT = 60; -export const TOP_TIME_UPDATE = 61; -export const TOP_TOGGLE = 62; -export const TOP_TOUCH_CANCEL = 63; -export const TOP_TOUCH_END = 64; -export const TOP_TOUCH_MOVE = 65; -export const TOP_TOUCH_START = 66; -export const TOP_TRANSITION_END = 67; -export const TOP_VOLUME_CHANGE = 68; -export const TOP_WAITING = 69; -export const TOP_WHEEL = 70; - export type TopLevelType = number | string; diff --git a/packages/events/__tests__/ResponderEventPlugin-test.internal.js b/packages/events/__tests__/ResponderEventPlugin-test.internal.js index 90bf5200ef4c3..aa8c00c349684 100644 --- a/packages/events/__tests__/ResponderEventPlugin-test.internal.js +++ b/packages/events/__tests__/ResponderEventPlugin-test.internal.js @@ -11,13 +11,16 @@ const {HostComponent} = require('shared/ReactTypeOfWork'); +// To test this module against public API, we'll use the DOM version of +// ResponderEventPlugin for these tests. This version will require the +// DOM specific top event IDs. const { TOP_SCROLL, TOP_TOUCH_CANCEL, TOP_TOUCH_END, TOP_TOUCH_MOVE, TOP_TOUCH_START, -} = require('../TopLevelEventTypes'); +} = require('react-dom/src/events/DOMTopLevelEventTypes'); let EventPluginHub; let ResponderEventPlugin; @@ -409,7 +412,7 @@ describe('ResponderEventPlugin', () => { const injectComponentTree = ReactDOMUnstableNativeDependencies.injectComponentTree; ResponderEventPlugin = - ReactDOMUnstableNativeDependencies.ResponderEventPlugin; + ReactDOMUnstableNativeDependencies.DOMResponderEventPlugin; deleteAllListeners(GRANDPARENT_INST); deleteAllListeners(PARENT_INST); diff --git a/packages/react-dom/src/__tests__/ReactDOM-test.js b/packages/react-dom/src/__tests__/ReactDOM-test.js index 1af9656703ec4..ca3a8f013690e 100644 --- a/packages/react-dom/src/__tests__/ReactDOM-test.js +++ b/packages/react-dom/src/__tests__/ReactDOM-test.js @@ -13,7 +13,7 @@ let React = require('react'); let ReactDOM = require('react-dom'); const ReactTestUtils = require('react-dom/test-utils'); -const {TOP_CLICK} = require('events/TopLevelEventTypes'); +const {TOP_CLICK} = require('../events/DOMTopLevelEventTypes'); describe('ReactDOM', () => { // TODO: uncomment this test once we can run in phantom, which diff --git a/packages/react-dom/src/__tests__/ReactDOMFiber-test.js b/packages/react-dom/src/__tests__/ReactDOMFiber-test.js index 2044b47961952..8fecb85d120dc 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFiber-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFiber-test.js @@ -18,7 +18,7 @@ const { TOP_CLICK, TOP_MOUSE_OUT, TOP_MOUSE_OVER, -} = require('events/TopLevelEventTypes'); +} = require('../events/DOMTopLevelEventTypes'); describe('ReactDOMFiber', () => { let container; diff --git a/packages/react-dom/src/__tests__/ReactDOMInput-test.js b/packages/react-dom/src/__tests__/ReactDOMInput-test.js index b90820fbd1ac7..9e539c42aa0ea 100644 --- a/packages/react-dom/src/__tests__/ReactDOMInput-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMInput-test.js @@ -11,7 +11,7 @@ const emptyFunction = require('fbjs/lib/emptyFunction'); -const {TOP_INPUT} = require('events/TopLevelEventTypes'); +const {TOP_INPUT} = require('../events/DOMTopLevelEventTypes'); describe('ReactDOMInput', () => { let React; diff --git a/packages/react-dom/src/client/ReactDOMFiberComponent.js b/packages/react-dom/src/client/ReactDOMFiberComponent.js index f5477eec769bc..9ceb06d700a43 100644 --- a/packages/react-dom/src/client/ReactDOMFiberComponent.js +++ b/packages/react-dom/src/client/ReactDOMFiberComponent.js @@ -10,14 +10,6 @@ // TODO: direct imports like some-package/src/* are bad. Fix me. import ReactDebugCurrentFiber from 'react-reconciler/src/ReactDebugCurrentFiber'; import {registrationNameModules} from 'events/EventPluginRegistry'; -import { - TOP_ERROR, - TOP_INVALID, - TOP_LOAD, - TOP_RESET, - TOP_SUBMIT, - TOP_TOGGLE, -} from 'events/TopLevelEventTypes'; import emptyFunction from 'fbjs/lib/emptyFunction'; import warning from 'fbjs/lib/warning'; @@ -29,6 +21,14 @@ import * as ReactDOMFiberTextarea from './ReactDOMFiberTextarea'; import * as inputValueTracking from './inputValueTracking'; import setInnerHTML from './setInnerHTML'; import setTextContent from './setTextContent'; +import { + TOP_ERROR, + TOP_INVALID, + TOP_LOAD, + TOP_RESET, + TOP_SUBMIT, + TOP_TOGGLE, +} from '../events/DOMTopLevelEventTypes'; import {listenTo, trapBubbledEvent} from '../events/ReactBrowserEventEmitter'; import {mediaEventTypes} from '../events/BrowserEventConstants'; import * as CSSPropertyOperations from '../shared/CSSPropertyOperations'; diff --git a/packages/react-dom/src/events/BeforeInputEventPlugin.js b/packages/react-dom/src/events/BeforeInputEventPlugin.js index 237a153dbdd4a..9bdb8dab7d01c 100644 --- a/packages/react-dom/src/events/BeforeInputEventPlugin.js +++ b/packages/react-dom/src/events/BeforeInputEventPlugin.js @@ -8,6 +8,8 @@ import type {TopLevelType} from 'events/TopLevelEventTypes'; import {accumulateTwoPhaseDispatches} from 'events/EventPropagators'; +import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment'; + import { TOP_BLUR, TOP_COMPOSITION_START, @@ -19,9 +21,7 @@ import { TOP_MOUSE_DOWN, TOP_TEXT_INPUT, TOP_PASTE, -} from 'events/TopLevelEventTypes'; -import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment'; - +} from './DOMTopLevelEventTypes'; import * as FallbackCompositionState from './FallbackCompositionState'; import SyntheticCompositionEvent from './SyntheticCompositionEvent'; import SyntheticInputEvent from './SyntheticInputEvent'; diff --git a/packages/react-dom/src/events/BrowserEventConstants.js b/packages/react-dom/src/events/BrowserEventConstants.js index e269919334838..3949b5c4c5b3a 100644 --- a/packages/react-dom/src/events/BrowserEventConstants.js +++ b/packages/react-dom/src/events/BrowserEventConstants.js @@ -7,10 +7,10 @@ * @flow */ -import * as TopLevelEventTypes from 'events/TopLevelEventTypes'; import type {TopLevelType} from 'events/TopLevelEventTypes'; import invariant from 'fbjs/lib/invariant'; +import * as DOMTopLevelEventTypes from './DOMTopLevelEventTypes'; import getVendorPrefixedEventName from './getVendorPrefixedEventName'; /** @@ -34,62 +34,62 @@ function makeMap(values: Array<[K, V]>): Map { */ export const topLevelTypes: Map = makeMap([ [ - TopLevelEventTypes.TOP_ANIMATION_END, + DOMTopLevelEventTypes.TOP_ANIMATION_END, getVendorPrefixedEventName('animationend'), ], [ - TopLevelEventTypes.TOP_ANIMATION_ITERATION, + DOMTopLevelEventTypes.TOP_ANIMATION_ITERATION, getVendorPrefixedEventName('animationiteration'), ], [ - TopLevelEventTypes.TOP_ANIMATION_START, + DOMTopLevelEventTypes.TOP_ANIMATION_START, getVendorPrefixedEventName('animationstart'), ], - [TopLevelEventTypes.TOP_BLUR, 'blur'], - [TopLevelEventTypes.TOP_CANCEL, 'cancel'], - [TopLevelEventTypes.TOP_CHANGE, 'change'], - [TopLevelEventTypes.TOP_CLICK, 'click'], - [TopLevelEventTypes.TOP_CLOSE, 'close'], - [TopLevelEventTypes.TOP_COMPOSITION_END, 'compositionend'], - [TopLevelEventTypes.TOP_COMPOSITION_START, 'compositionstart'], - [TopLevelEventTypes.TOP_COMPOSITION_UPDATE, 'compositionupdate'], - [TopLevelEventTypes.TOP_CONTEXT_MENU, 'contextmenu'], - [TopLevelEventTypes.TOP_COPY, 'copy'], - [TopLevelEventTypes.TOP_CUT, 'cut'], - [TopLevelEventTypes.TOP_DOUBLE_CLICK, 'dblclick'], - [TopLevelEventTypes.TOP_DRAG, 'drag'], - [TopLevelEventTypes.TOP_DRAG_END, 'dragend'], - [TopLevelEventTypes.TOP_DRAG_ENTER, 'dragenter'], - [TopLevelEventTypes.TOP_DRAG_EXIT, 'dragexit'], - [TopLevelEventTypes.TOP_DRAG_LEAVE, 'dragleave'], - [TopLevelEventTypes.TOP_DRAG_OVER, 'dragover'], - [TopLevelEventTypes.TOP_DRAG_START, 'dragstart'], - [TopLevelEventTypes.TOP_DROP, 'drop'], - [TopLevelEventTypes.TOP_FOCUS, 'focus'], - [TopLevelEventTypes.TOP_KEY_DOWN, 'keydown'], - [TopLevelEventTypes.TOP_KEY_PRESS, 'keypress'], - [TopLevelEventTypes.TOP_KEY_UP, 'keyup'], - [TopLevelEventTypes.TOP_LOAD, 'load'], - [TopLevelEventTypes.TOP_LOAD_START, 'loadstart'], - [TopLevelEventTypes.TOP_MOUSE_DOWN, 'mousedown'], - [TopLevelEventTypes.TOP_MOUSE_MOVE, 'mousemove'], - [TopLevelEventTypes.TOP_MOUSE_OUT, 'mouseout'], - [TopLevelEventTypes.TOP_MOUSE_OVER, 'mouseover'], - [TopLevelEventTypes.TOP_MOUSE_UP, 'mouseup'], - [TopLevelEventTypes.TOP_PASTE, 'paste'], - [TopLevelEventTypes.TOP_SCROLL, 'scroll'], - [TopLevelEventTypes.TOP_SELECTION_CHANGE, 'selectionchange'], - [TopLevelEventTypes.TOP_TEXT_INPUT, 'textInput'], - [TopLevelEventTypes.TOP_TOGGLE, 'toggle'], - [TopLevelEventTypes.TOP_TOUCH_CANCEL, 'touchcancel'], - [TopLevelEventTypes.TOP_TOUCH_END, 'touchend'], - [TopLevelEventTypes.TOP_TOUCH_MOVE, 'touchmove'], - [TopLevelEventTypes.TOP_TOUCH_START, 'touchstart'], + [DOMTopLevelEventTypes.TOP_BLUR, 'blur'], + [DOMTopLevelEventTypes.TOP_CANCEL, 'cancel'], + [DOMTopLevelEventTypes.TOP_CHANGE, 'change'], + [DOMTopLevelEventTypes.TOP_CLICK, 'click'], + [DOMTopLevelEventTypes.TOP_CLOSE, 'close'], + [DOMTopLevelEventTypes.TOP_COMPOSITION_END, 'compositionend'], + [DOMTopLevelEventTypes.TOP_COMPOSITION_START, 'compositionstart'], + [DOMTopLevelEventTypes.TOP_COMPOSITION_UPDATE, 'compositionupdate'], + [DOMTopLevelEventTypes.TOP_CONTEXT_MENU, 'contextmenu'], + [DOMTopLevelEventTypes.TOP_COPY, 'copy'], + [DOMTopLevelEventTypes.TOP_CUT, 'cut'], + [DOMTopLevelEventTypes.TOP_DOUBLE_CLICK, 'dblclick'], + [DOMTopLevelEventTypes.TOP_DRAG, 'drag'], + [DOMTopLevelEventTypes.TOP_DRAG_END, 'dragend'], + [DOMTopLevelEventTypes.TOP_DRAG_ENTER, 'dragenter'], + [DOMTopLevelEventTypes.TOP_DRAG_EXIT, 'dragexit'], + [DOMTopLevelEventTypes.TOP_DRAG_LEAVE, 'dragleave'], + [DOMTopLevelEventTypes.TOP_DRAG_OVER, 'dragover'], + [DOMTopLevelEventTypes.TOP_DRAG_START, 'dragstart'], + [DOMTopLevelEventTypes.TOP_DROP, 'drop'], + [DOMTopLevelEventTypes.TOP_FOCUS, 'focus'], + [DOMTopLevelEventTypes.TOP_KEY_DOWN, 'keydown'], + [DOMTopLevelEventTypes.TOP_KEY_PRESS, 'keypress'], + [DOMTopLevelEventTypes.TOP_KEY_UP, 'keyup'], + [DOMTopLevelEventTypes.TOP_LOAD, 'load'], + [DOMTopLevelEventTypes.TOP_LOAD_START, 'loadstart'], + [DOMTopLevelEventTypes.TOP_MOUSE_DOWN, 'mousedown'], + [DOMTopLevelEventTypes.TOP_MOUSE_MOVE, 'mousemove'], + [DOMTopLevelEventTypes.TOP_MOUSE_OUT, 'mouseout'], + [DOMTopLevelEventTypes.TOP_MOUSE_OVER, 'mouseover'], + [DOMTopLevelEventTypes.TOP_MOUSE_UP, 'mouseup'], + [DOMTopLevelEventTypes.TOP_PASTE, 'paste'], + [DOMTopLevelEventTypes.TOP_SCROLL, 'scroll'], + [DOMTopLevelEventTypes.TOP_SELECTION_CHANGE, 'selectionchange'], + [DOMTopLevelEventTypes.TOP_TEXT_INPUT, 'textInput'], + [DOMTopLevelEventTypes.TOP_TOGGLE, 'toggle'], + [DOMTopLevelEventTypes.TOP_TOUCH_CANCEL, 'touchcancel'], + [DOMTopLevelEventTypes.TOP_TOUCH_END, 'touchend'], + [DOMTopLevelEventTypes.TOP_TOUCH_MOVE, 'touchmove'], + [DOMTopLevelEventTypes.TOP_TOUCH_START, 'touchstart'], [ - TopLevelEventTypes.TOP_TRANSITION_END, + DOMTopLevelEventTypes.TOP_TRANSITION_END, getVendorPrefixedEventName('transitionend'), ], - [TopLevelEventTypes.TOP_WHEEL, 'wheel'], + [DOMTopLevelEventTypes.TOP_WHEEL, 'wheel'], ]); // There are so many media events, it makes sense to just @@ -98,36 +98,36 @@ export const topLevelTypes: Map = makeMap([ // with a better naming convention if we come to refactoring // the event system. export const mediaEventTypes: Map = makeMap([ - [TopLevelEventTypes.TOP_ABORT, 'abort'], - [TopLevelEventTypes.TOP_CAN_PLAY, 'canplay'], - [TopLevelEventTypes.TOP_CAN_PLAY_THROUGH, 'canplaythrough'], - [TopLevelEventTypes.TOP_DURATION_CHANGE, 'durationchange'], - [TopLevelEventTypes.TOP_EMPTIED, 'emptied'], - [TopLevelEventTypes.TOP_ENCRYPTED, 'encrypted'], - [TopLevelEventTypes.TOP_ENDED, 'ended'], - [TopLevelEventTypes.TOP_ERROR, 'error'], - [TopLevelEventTypes.TOP_LOADED_DATA, 'loadeddata'], - [TopLevelEventTypes.TOP_LOADED_METADATA, 'loadedmetadata'], - [TopLevelEventTypes.TOP_LOAD_START, 'loadstart'], - [TopLevelEventTypes.TOP_PAUSE, 'pause'], - [TopLevelEventTypes.TOP_PLAY, 'play'], - [TopLevelEventTypes.TOP_PLAYING, 'playing'], - [TopLevelEventTypes.TOP_PROGRESS, 'progress'], - [TopLevelEventTypes.TOP_RATE_CHANGE, 'ratechange'], - [TopLevelEventTypes.TOP_SEEKED, 'seeked'], - [TopLevelEventTypes.TOP_SEEKING, 'seeking'], - [TopLevelEventTypes.TOP_STALLED, 'stalled'], - [TopLevelEventTypes.TOP_SUSPEND, 'suspend'], - [TopLevelEventTypes.TOP_TIME_UPDATE, 'timeupdate'], - [TopLevelEventTypes.TOP_VOLUME_CHANGE, 'volumechange'], - [TopLevelEventTypes.TOP_WAITING, 'waiting'], + [DOMTopLevelEventTypes.TOP_ABORT, 'abort'], + [DOMTopLevelEventTypes.TOP_CAN_PLAY, 'canplay'], + [DOMTopLevelEventTypes.TOP_CAN_PLAY_THROUGH, 'canplaythrough'], + [DOMTopLevelEventTypes.TOP_DURATION_CHANGE, 'durationchange'], + [DOMTopLevelEventTypes.TOP_EMPTIED, 'emptied'], + [DOMTopLevelEventTypes.TOP_ENCRYPTED, 'encrypted'], + [DOMTopLevelEventTypes.TOP_ENDED, 'ended'], + [DOMTopLevelEventTypes.TOP_ERROR, 'error'], + [DOMTopLevelEventTypes.TOP_LOADED_DATA, 'loadeddata'], + [DOMTopLevelEventTypes.TOP_LOADED_METADATA, 'loadedmetadata'], + [DOMTopLevelEventTypes.TOP_LOAD_START, 'loadstart'], + [DOMTopLevelEventTypes.TOP_PAUSE, 'pause'], + [DOMTopLevelEventTypes.TOP_PLAY, 'play'], + [DOMTopLevelEventTypes.TOP_PLAYING, 'playing'], + [DOMTopLevelEventTypes.TOP_PROGRESS, 'progress'], + [DOMTopLevelEventTypes.TOP_RATE_CHANGE, 'ratechange'], + [DOMTopLevelEventTypes.TOP_SEEKED, 'seeked'], + [DOMTopLevelEventTypes.TOP_SEEKING, 'seeking'], + [DOMTopLevelEventTypes.TOP_STALLED, 'stalled'], + [DOMTopLevelEventTypes.TOP_SUSPEND, 'suspend'], + [DOMTopLevelEventTypes.TOP_TIME_UPDATE, 'timeupdate'], + [DOMTopLevelEventTypes.TOP_VOLUME_CHANGE, 'volumechange'], + [DOMTopLevelEventTypes.TOP_WAITING, 'waiting'], ]); const nonTopEventTypes: Map = makeMap([ - [TopLevelEventTypes.TOP_INPUT, 'input'], - [TopLevelEventTypes.TOP_INVALID, 'invalid'], - [TopLevelEventTypes.TOP_RESET, 'reset'], - [TopLevelEventTypes.TOP_SUBMIT, 'submit'], + [DOMTopLevelEventTypes.TOP_INPUT, 'input'], + [DOMTopLevelEventTypes.TOP_INVALID, 'invalid'], + [DOMTopLevelEventTypes.TOP_RESET, 'reset'], + [DOMTopLevelEventTypes.TOP_SUBMIT, 'submit'], ]); export function getRawEventName(topLevelType: TopLevelType): string { @@ -138,7 +138,8 @@ export function getRawEventName(topLevelType: TopLevelType): string { invariant( eventName, - 'BrowserEventConstants: Could not look up raw event name of topLevelType.', + 'BrowserEventConstants: Could not look up raw event name of topLevelType: %s.', + topLevelType, ); return eventName; } diff --git a/packages/react-dom/src/events/ChangeEventPlugin.js b/packages/react-dom/src/events/ChangeEventPlugin.js index c85a1af6e2604..ce0d328d876d5 100644 --- a/packages/react-dom/src/events/ChangeEventPlugin.js +++ b/packages/react-dom/src/events/ChangeEventPlugin.js @@ -10,6 +10,9 @@ import {accumulateTwoPhaseDispatches} from 'events/EventPropagators'; import {enqueueStateRestore} from 'events/ReactControlledComponent'; import {batchedUpdates} from 'events/ReactGenericBatching'; import SyntheticEvent from 'events/SyntheticEvent'; +import isTextInputElement from 'shared/isTextInputElement'; +import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment'; + import { TOP_BLUR, TOP_CHANGE, @@ -19,10 +22,7 @@ import { TOP_KEY_DOWN, TOP_KEY_UP, TOP_SELECTION_CHANGE, -} from 'events/TopLevelEventTypes'; -import isTextInputElement from 'shared/isTextInputElement'; -import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment'; - +} from './DOMTopLevelEventTypes'; import getEventTarget from './getEventTarget'; import isEventSupported from './isEventSupported'; import {getNodeFromInstance} from '../client/ReactDOMComponentTree'; diff --git a/packages/react-dom/src/events/DOMEventPluginOrder.js b/packages/react-dom/src/events/DOMEventPluginOrder.js index 0896938b97831..e6eefb6859486 100644 --- a/packages/react-dom/src/events/DOMEventPluginOrder.js +++ b/packages/react-dom/src/events/DOMEventPluginOrder.js @@ -11,11 +11,11 @@ * plugins, without having to package every one of them. This is better than * having plugins be ordered in the same order that they are injected because * that ordering would be influenced by the packaging order. - * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that + * `DOMResponderEventPlugin` must occur before `SimpleEventPlugin` so that * preventing default on events is convenient in `SimpleEventPlugin` handlers. */ const DOMEventPluginOrder = [ - 'ResponderEventPlugin', + 'DOMResponderEventPlugin', 'SimpleEventPlugin', 'TapEventPlugin', 'EnterLeaveEventPlugin', diff --git a/packages/react-dom/src/events/DOMEventPluginUtils.js b/packages/react-dom/src/events/DOMEventPluginUtils.js new file mode 100644 index 0000000000000..42fba7911ac36 --- /dev/null +++ b/packages/react-dom/src/events/DOMEventPluginUtils.js @@ -0,0 +1,31 @@ +/** + * 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. + */ + +import { + TOP_MOUSE_DOWN, + TOP_MOUSE_MOVE, + TOP_MOUSE_UP, + TOP_TOUCH_CANCEL, + TOP_TOUCH_END, + TOP_TOUCH_MOVE, + TOP_TOUCH_START, +} from './DOMTopLevelEventTypes'; + +export function isEndish(topLevelType) { +return ( + topLevelType === TOP_MOUSE_UP || + topLevelType === TOP_TOUCH_END || + topLevelType === TOP_TOUCH_CANCEL +); +} + +export function isMoveish(topLevelType) { +return topLevelType === TOP_MOUSE_MOVE || topLevelType === TOP_TOUCH_MOVE; +} +export function isStartish(topLevelType) { +return topLevelType === TOP_MOUSE_DOWN || topLevelType === TOP_TOUCH_START; +} diff --git a/packages/react-dom/src/events/DOMResponderEventPlugin.js b/packages/react-dom/src/events/DOMResponderEventPlugin.js new file mode 100644 index 0000000000000..fb7860c4c156f --- /dev/null +++ b/packages/react-dom/src/events/DOMResponderEventPlugin.js @@ -0,0 +1,34 @@ +/** + * 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. + */ + +import ResponderEventPlugin from 'events/ResponderEventPlugin'; + +import { + TOP_MOUSE_DOWN, + TOP_MOUSE_MOVE, + TOP_MOUSE_UP, + TOP_SCROLL, + TOP_SELECTION_CHANGE, + TOP_TOUCH_CANCEL, + TOP_TOUCH_END, + TOP_TOUCH_MOVE, + TOP_TOUCH_START, + } from './DOMTopLevelEventTypes'; + +ResponderEventPlugin.injection.injectTopLevelTypes({ + topMouseDown: TOP_MOUSE_DOWN, + topMouseMove: TOP_MOUSE_MOVE, + topMouseUp: TOP_MOUSE_UP, + topScroll: TOP_SCROLL, + topSelectionChange: TOP_SELECTION_CHANGE, + topTouchCancel: TOP_TOUCH_CANCEL, + topTouchEnd: TOP_TOUCH_END, + topTouchMove: TOP_TOUCH_MOVE, + topTouchStart: TOP_TOUCH_START, +}); + +export default ResponderEventPlugin; diff --git a/packages/react-dom/src/events/DOMTopLevelEventTypes.js b/packages/react-dom/src/events/DOMTopLevelEventTypes.js new file mode 100644 index 0000000000000..5e81961a2f4c4 --- /dev/null +++ b/packages/react-dom/src/events/DOMTopLevelEventTypes.js @@ -0,0 +1,80 @@ +/** + * 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. + * + * @flow + */ + +export const TOP_ABORT = 0; +export const TOP_ANIMATION_END = 1; +export const TOP_ANIMATION_ITERATION = 2; +export const TOP_ANIMATION_START = 3; +export const TOP_BLUR = 4; +export const TOP_CANCEL = 5; +export const TOP_CAN_PLAY = 6; +export const TOP_CAN_PLAY_THROUGH = 7; +export const TOP_CHANGE = 8; +export const TOP_CLICK = 9; +export const TOP_CLOSE = 10; +export const TOP_COMPOSITION_END = 11; +export const TOP_COMPOSITION_START = 12; +export const TOP_COMPOSITION_UPDATE = 13; +export const TOP_CONTEXT_MENU = 14; +export const TOP_COPY = 15; +export const TOP_CUT = 16; +export const TOP_DOUBLE_CLICK = 17; +export const TOP_DRAG = 18; +export const TOP_DRAG_END = 19; +export const TOP_DRAG_ENTER = 20; +export const TOP_DRAG_EXIT = 21; +export const TOP_DRAG_LEAVE = 22; +export const TOP_DRAG_OVER = 23; +export const TOP_DRAG_START = 24; +export const TOP_DROP = 25; +export const TOP_DURATION_CHANGE = 26; +export const TOP_EMPTIED = 27; +export const TOP_ENCRYPTED = 28; +export const TOP_ENDED = 29; +export const TOP_ERROR = 30; +export const TOP_FOCUS = 31; +export const TOP_INPUT = 32; +export const TOP_INVALID = 33; +export const TOP_KEY_DOWN = 34; +export const TOP_KEY_PRESS = 35; +export const TOP_KEY_UP = 36; +export const TOP_LOADED_DATA = 37; +export const TOP_LOAD = 38; +export const TOP_LOADED_METADATA = 39; +export const TOP_LOAD_START = 40; +export const TOP_MOUSE_DOWN = 41; +export const TOP_MOUSE_MOVE = 42; +export const TOP_MOUSE_OUT = 43; +export const TOP_MOUSE_OVER = 44; +export const TOP_MOUSE_UP = 45; +export const TOP_PASTE = 46; +export const TOP_PAUSE = 47; +export const TOP_PLAY = 48; +export const TOP_PLAYING = 49; +export const TOP_PROGRESS = 50; +export const TOP_RATE_CHANGE = 51; +export const TOP_RESET = 52; +export const TOP_SCROLL = 53; +export const TOP_SEEKED = 54; +export const TOP_SEEKING = 55; +export const TOP_SELECTION_CHANGE = 56; +export const TOP_STALLED = 57; +export const TOP_SUBMIT = 58; +export const TOP_SUSPEND = 59; +export const TOP_TEXT_INPUT = 60; +export const TOP_TIME_UPDATE = 61; +export const TOP_TOGGLE = 62; +export const TOP_TOUCH_CANCEL = 63; +export const TOP_TOUCH_END = 64; +export const TOP_TOUCH_MOVE = 65; +export const TOP_TOUCH_START = 66; +export const TOP_TRANSITION_END = 67; +export const TOP_VOLUME_CHANGE = 68; +export const TOP_WAITING = 69; +export const TOP_WHEEL = 70; diff --git a/packages/react-dom/src/events/EnterLeaveEventPlugin.js b/packages/react-dom/src/events/EnterLeaveEventPlugin.js index 4841095b69d6f..3e15dd8a90cd2 100644 --- a/packages/react-dom/src/events/EnterLeaveEventPlugin.js +++ b/packages/react-dom/src/events/EnterLeaveEventPlugin.js @@ -6,8 +6,8 @@ */ import {accumulateEnterLeaveDispatches} from 'events/EventPropagators'; -import {TOP_MOUSE_OUT, TOP_MOUSE_OVER} from 'events/TopLevelEventTypes'; +import {TOP_MOUSE_OUT, TOP_MOUSE_OVER} from './DOMTopLevelEventTypes'; import SyntheticMouseEvent from './SyntheticMouseEvent'; import { getClosestInstanceFromNode, diff --git a/packages/react-dom/src/events/ReactBrowserEventEmitter.js b/packages/react-dom/src/events/ReactBrowserEventEmitter.js index bd8d7c6f2f16a..ef5f31e136e41 100644 --- a/packages/react-dom/src/events/ReactBrowserEventEmitter.js +++ b/packages/react-dom/src/events/ReactBrowserEventEmitter.js @@ -12,7 +12,7 @@ import { TOP_CLOSE, TOP_FOCUS, TOP_SCROLL, -} from 'events/TopLevelEventTypes'; +} from './DOMTopLevelEventTypes'; import { setEnabled, isEnabled, diff --git a/packages/react-dom/src/events/SelectEventPlugin.js b/packages/react-dom/src/events/SelectEventPlugin.js index 8cbcf4c208d2e..81cc5d5186740 100644 --- a/packages/react-dom/src/events/SelectEventPlugin.js +++ b/packages/react-dom/src/events/SelectEventPlugin.js @@ -8,6 +8,10 @@ import {accumulateTwoPhaseDispatches} from 'events/EventPropagators'; import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment'; import SyntheticEvent from 'events/SyntheticEvent'; +import isTextInputElement from 'shared/isTextInputElement'; +import getActiveElement from 'fbjs/lib/getActiveElement'; +import shallowEqual from 'fbjs/lib/shallowEqual'; + import { TOP_BLUR, TOP_CONTEXT_MENU, @@ -17,11 +21,7 @@ import { TOP_MOUSE_DOWN, TOP_MOUSE_UP, TOP_SELECTION_CHANGE, -} from 'events/TopLevelEventTypes'; -import isTextInputElement from 'shared/isTextInputElement'; -import getActiveElement from 'fbjs/lib/getActiveElement'; -import shallowEqual from 'fbjs/lib/shallowEqual'; - +} from './DOMTopLevelEventTypes'; import {isListeningToAllDependencies} from './ReactBrowserEventEmitter'; import {getNodeFromInstance} from '../client/ReactDOMComponentTree'; import * as ReactInputSelection from '../client/ReactInputSelection'; diff --git a/packages/react-dom/src/events/SimpleEventPlugin.js b/packages/react-dom/src/events/SimpleEventPlugin.js index 31b96a14b5a23..e9a108dcf2a9f 100644 --- a/packages/react-dom/src/events/SimpleEventPlugin.js +++ b/packages/react-dom/src/events/SimpleEventPlugin.js @@ -18,7 +18,7 @@ import type {EventTypes, PluginModule} from 'events/PluginModuleType'; import {accumulateTwoPhaseDispatches} from 'events/EventPropagators'; import SyntheticEvent from 'events/SyntheticEvent'; -import * as TopLevelEventTypes from 'events/TopLevelEventTypes'; +import * as DOMTopLevelEventTypes from './DOMTopLevelEventTypes'; import warning from 'fbjs/lib/warning'; import SyntheticAnimationEvent from './SyntheticAnimationEvent'; @@ -53,73 +53,73 @@ import getEventCharCode from './getEventCharCode'; */ type EventTuple = [TopLevelType, string]; const interactiveEventTypeNames: Array = [ - [TopLevelEventTypes.TOP_BLUR, 'blur'], - [TopLevelEventTypes.TOP_CANCEL, 'cancel'], - [TopLevelEventTypes.TOP_CLICK, 'click'], - [TopLevelEventTypes.TOP_CLOSE, 'close'], - [TopLevelEventTypes.TOP_CONTEXT_MENU, 'contextMenu'], - [TopLevelEventTypes.TOP_COPY, 'copy'], - [TopLevelEventTypes.TOP_CUT, 'cut'], - [TopLevelEventTypes.TOP_DOUBLE_CLICK, 'doubleClick'], - [TopLevelEventTypes.TOP_DRAG_END, 'dragEnd'], - [TopLevelEventTypes.TOP_DRAG_START, 'dragStart'], - [TopLevelEventTypes.TOP_DROP, 'drop'], - [TopLevelEventTypes.TOP_FOCUS, 'focus'], - [TopLevelEventTypes.TOP_INPUT, 'input'], - [TopLevelEventTypes.TOP_INVALID, 'invalid'], - [TopLevelEventTypes.TOP_KEY_DOWN, 'keyDown'], - [TopLevelEventTypes.TOP_KEY_PRESS, 'keyPress'], - [TopLevelEventTypes.TOP_KEY_UP, 'keyUp'], - [TopLevelEventTypes.TOP_MOUSE_DOWN, 'mouseDown'], - [TopLevelEventTypes.TOP_MOUSE_UP, 'mouseUp'], - [TopLevelEventTypes.TOP_PASTE, 'paste'], - [TopLevelEventTypes.TOP_PAUSE, 'pause'], - [TopLevelEventTypes.TOP_PLAY, 'play'], - [TopLevelEventTypes.TOP_RATE_CHANGE, 'rateChange'], - [TopLevelEventTypes.TOP_RESET, 'reset'], - [TopLevelEventTypes.TOP_SEEKED, 'seeked'], - [TopLevelEventTypes.TOP_SUBMIT, 'submit'], - [TopLevelEventTypes.TOP_TOUCH_CANCEL, 'touchCancel'], - [TopLevelEventTypes.TOP_TOUCH_END, 'touchEnd'], - [TopLevelEventTypes.TOP_TOUCH_START, 'touchStart'], - [TopLevelEventTypes.TOP_VOLUME_CHANGE, 'volumeChange'], + [DOMTopLevelEventTypes.TOP_BLUR, 'blur'], + [DOMTopLevelEventTypes.TOP_CANCEL, 'cancel'], + [DOMTopLevelEventTypes.TOP_CLICK, 'click'], + [DOMTopLevelEventTypes.TOP_CLOSE, 'close'], + [DOMTopLevelEventTypes.TOP_CONTEXT_MENU, 'contextMenu'], + [DOMTopLevelEventTypes.TOP_COPY, 'copy'], + [DOMTopLevelEventTypes.TOP_CUT, 'cut'], + [DOMTopLevelEventTypes.TOP_DOUBLE_CLICK, 'doubleClick'], + [DOMTopLevelEventTypes.TOP_DRAG_END, 'dragEnd'], + [DOMTopLevelEventTypes.TOP_DRAG_START, 'dragStart'], + [DOMTopLevelEventTypes.TOP_DROP, 'drop'], + [DOMTopLevelEventTypes.TOP_FOCUS, 'focus'], + [DOMTopLevelEventTypes.TOP_INPUT, 'input'], + [DOMTopLevelEventTypes.TOP_INVALID, 'invalid'], + [DOMTopLevelEventTypes.TOP_KEY_DOWN, 'keyDown'], + [DOMTopLevelEventTypes.TOP_KEY_PRESS, 'keyPress'], + [DOMTopLevelEventTypes.TOP_KEY_UP, 'keyUp'], + [DOMTopLevelEventTypes.TOP_MOUSE_DOWN, 'mouseDown'], + [DOMTopLevelEventTypes.TOP_MOUSE_UP, 'mouseUp'], + [DOMTopLevelEventTypes.TOP_PASTE, 'paste'], + [DOMTopLevelEventTypes.TOP_PAUSE, 'pause'], + [DOMTopLevelEventTypes.TOP_PLAY, 'play'], + [DOMTopLevelEventTypes.TOP_RATE_CHANGE, 'rateChange'], + [DOMTopLevelEventTypes.TOP_RESET, 'reset'], + [DOMTopLevelEventTypes.TOP_SEEKED, 'seeked'], + [DOMTopLevelEventTypes.TOP_SUBMIT, 'submit'], + [DOMTopLevelEventTypes.TOP_TOUCH_CANCEL, 'touchCancel'], + [DOMTopLevelEventTypes.TOP_TOUCH_END, 'touchEnd'], + [DOMTopLevelEventTypes.TOP_TOUCH_START, 'touchStart'], + [DOMTopLevelEventTypes.TOP_VOLUME_CHANGE, 'volumeChange'], ]; const nonInteractiveEventTypeNames: Array = [ - [TopLevelEventTypes.TOP_ABORT, 'abort'], - [TopLevelEventTypes.TOP_ANIMATION_END, 'animationEnd'], - [TopLevelEventTypes.TOP_ANIMATION_ITERATION, 'animationIteration'], - [TopLevelEventTypes.TOP_ANIMATION_START, 'animationStart'], - [TopLevelEventTypes.TOP_CAN_PLAY, 'canPlay'], - [TopLevelEventTypes.TOP_CAN_PLAY_THROUGH, 'canPlayThrough'], - [TopLevelEventTypes.TOP_DRAG, 'drag'], - [TopLevelEventTypes.TOP_DRAG_ENTER, 'dragEnter'], - [TopLevelEventTypes.TOP_DRAG_EXIT, 'dragExit'], - [TopLevelEventTypes.TOP_DRAG_LEAVE, 'dragLeave'], - [TopLevelEventTypes.TOP_DRAG_OVER, 'dragOver'], - [TopLevelEventTypes.TOP_DURATION_CHANGE, 'durationChange'], - [TopLevelEventTypes.TOP_EMPTIED, 'emptied'], - [TopLevelEventTypes.TOP_ENCRYPTED, 'encrypted'], - [TopLevelEventTypes.TOP_ENDED, 'ended'], - [TopLevelEventTypes.TOP_ERROR, 'error'], - [TopLevelEventTypes.TOP_LOAD, 'load'], - [TopLevelEventTypes.TOP_LOADED_DATA, 'loadedData'], - [TopLevelEventTypes.TOP_LOADED_METADATA, 'loadedMetadata'], - [TopLevelEventTypes.TOP_LOAD_START, 'loadStart'], - [TopLevelEventTypes.TOP_MOUSE_MOVE, 'mouseMove'], - [TopLevelEventTypes.TOP_MOUSE_OUT, 'mouseOut'], - [TopLevelEventTypes.TOP_MOUSE_OVER, 'mouseOver'], - [TopLevelEventTypes.TOP_PLAYING, 'playing'], - [TopLevelEventTypes.TOP_PROGRESS, 'progress'], - [TopLevelEventTypes.TOP_SCROLL, 'scroll'], - [TopLevelEventTypes.TOP_SEEKING, 'seeking'], - [TopLevelEventTypes.TOP_STALLED, 'stalled'], - [TopLevelEventTypes.TOP_SUSPEND, 'suspend'], - [TopLevelEventTypes.TOP_TIME_UPDATE, 'timeUpdate'], - [TopLevelEventTypes.TOP_TOGGLE, 'toggle'], - [TopLevelEventTypes.TOP_TOUCH_MOVE, 'touchMove'], - [TopLevelEventTypes.TOP_TRANSITION_END, 'transitionEnd'], - [TopLevelEventTypes.TOP_WAITING, 'waiting'], - [TopLevelEventTypes.TOP_WHEEL, 'wheel'], + [DOMTopLevelEventTypes.TOP_ABORT, 'abort'], + [DOMTopLevelEventTypes.TOP_ANIMATION_END, 'animationEnd'], + [DOMTopLevelEventTypes.TOP_ANIMATION_ITERATION, 'animationIteration'], + [DOMTopLevelEventTypes.TOP_ANIMATION_START, 'animationStart'], + [DOMTopLevelEventTypes.TOP_CAN_PLAY, 'canPlay'], + [DOMTopLevelEventTypes.TOP_CAN_PLAY_THROUGH, 'canPlayThrough'], + [DOMTopLevelEventTypes.TOP_DRAG, 'drag'], + [DOMTopLevelEventTypes.TOP_DRAG_ENTER, 'dragEnter'], + [DOMTopLevelEventTypes.TOP_DRAG_EXIT, 'dragExit'], + [DOMTopLevelEventTypes.TOP_DRAG_LEAVE, 'dragLeave'], + [DOMTopLevelEventTypes.TOP_DRAG_OVER, 'dragOver'], + [DOMTopLevelEventTypes.TOP_DURATION_CHANGE, 'durationChange'], + [DOMTopLevelEventTypes.TOP_EMPTIED, 'emptied'], + [DOMTopLevelEventTypes.TOP_ENCRYPTED, 'encrypted'], + [DOMTopLevelEventTypes.TOP_ENDED, 'ended'], + [DOMTopLevelEventTypes.TOP_ERROR, 'error'], + [DOMTopLevelEventTypes.TOP_LOAD, 'load'], + [DOMTopLevelEventTypes.TOP_LOADED_DATA, 'loadedData'], + [DOMTopLevelEventTypes.TOP_LOADED_METADATA, 'loadedMetadata'], + [DOMTopLevelEventTypes.TOP_LOAD_START, 'loadStart'], + [DOMTopLevelEventTypes.TOP_MOUSE_MOVE, 'mouseMove'], + [DOMTopLevelEventTypes.TOP_MOUSE_OUT, 'mouseOut'], + [DOMTopLevelEventTypes.TOP_MOUSE_OVER, 'mouseOver'], + [DOMTopLevelEventTypes.TOP_PLAYING, 'playing'], + [DOMTopLevelEventTypes.TOP_PROGRESS, 'progress'], + [DOMTopLevelEventTypes.TOP_SCROLL, 'scroll'], + [DOMTopLevelEventTypes.TOP_SEEKING, 'seeking'], + [DOMTopLevelEventTypes.TOP_STALLED, 'stalled'], + [DOMTopLevelEventTypes.TOP_SUSPEND, 'suspend'], + [DOMTopLevelEventTypes.TOP_TIME_UPDATE, 'timeUpdate'], + [DOMTopLevelEventTypes.TOP_TOGGLE, 'toggle'], + [DOMTopLevelEventTypes.TOP_TOUCH_MOVE, 'touchMove'], + [DOMTopLevelEventTypes.TOP_TRANSITION_END, 'transitionEnd'], + [DOMTopLevelEventTypes.TOP_WAITING, 'waiting'], + [DOMTopLevelEventTypes.TOP_WHEEL, 'wheel'], ]; const eventTypes: EventTypes = {}; @@ -158,37 +158,37 @@ nonInteractiveEventTypeNames.forEach(eventTuple => { // Only used in DEV for exhaustiveness validation. const knownHTMLTopLevelTypes: Array = [ - TopLevelEventTypes.TOP_ABORT, - TopLevelEventTypes.TOP_CANCEL, - TopLevelEventTypes.TOP_CAN_PLAY, - TopLevelEventTypes.TOP_CAN_PLAY_THROUGH, - TopLevelEventTypes.TOP_CLOSE, - TopLevelEventTypes.TOP_DURATION_CHANGE, - TopLevelEventTypes.TOP_EMPTIED, - TopLevelEventTypes.TOP_ENCRYPTED, - TopLevelEventTypes.TOP_ENDED, - TopLevelEventTypes.TOP_ERROR, - TopLevelEventTypes.TOP_INPUT, - TopLevelEventTypes.TOP_INVALID, - TopLevelEventTypes.TOP_LOAD, - TopLevelEventTypes.TOP_LOADED_DATA, - TopLevelEventTypes.TOP_LOADED_METADATA, - TopLevelEventTypes.TOP_LOAD_START, - TopLevelEventTypes.TOP_PAUSE, - TopLevelEventTypes.TOP_PLAY, - TopLevelEventTypes.TOP_PLAYING, - TopLevelEventTypes.TOP_PROGRESS, - TopLevelEventTypes.TOP_RATE_CHANGE, - TopLevelEventTypes.TOP_RESET, - TopLevelEventTypes.TOP_SEEKED, - TopLevelEventTypes.TOP_SEEKING, - TopLevelEventTypes.TOP_STALLED, - TopLevelEventTypes.TOP_SUBMIT, - TopLevelEventTypes.TOP_SUSPEND, - TopLevelEventTypes.TOP_TIME_UPDATE, - TopLevelEventTypes.TOP_TOGGLE, - TopLevelEventTypes.TOP_VOLUME_CHANGE, - TopLevelEventTypes.TOP_WAITING, + DOMTopLevelEventTypes.TOP_ABORT, + DOMTopLevelEventTypes.TOP_CANCEL, + DOMTopLevelEventTypes.TOP_CAN_PLAY, + DOMTopLevelEventTypes.TOP_CAN_PLAY_THROUGH, + DOMTopLevelEventTypes.TOP_CLOSE, + DOMTopLevelEventTypes.TOP_DURATION_CHANGE, + DOMTopLevelEventTypes.TOP_EMPTIED, + DOMTopLevelEventTypes.TOP_ENCRYPTED, + DOMTopLevelEventTypes.TOP_ENDED, + DOMTopLevelEventTypes.TOP_ERROR, + DOMTopLevelEventTypes.TOP_INPUT, + DOMTopLevelEventTypes.TOP_INVALID, + DOMTopLevelEventTypes.TOP_LOAD, + DOMTopLevelEventTypes.TOP_LOADED_DATA, + DOMTopLevelEventTypes.TOP_LOADED_METADATA, + DOMTopLevelEventTypes.TOP_LOAD_START, + DOMTopLevelEventTypes.TOP_PAUSE, + DOMTopLevelEventTypes.TOP_PLAY, + DOMTopLevelEventTypes.TOP_PLAYING, + DOMTopLevelEventTypes.TOP_PROGRESS, + DOMTopLevelEventTypes.TOP_RATE_CHANGE, + DOMTopLevelEventTypes.TOP_RESET, + DOMTopLevelEventTypes.TOP_SEEKED, + DOMTopLevelEventTypes.TOP_SEEKING, + DOMTopLevelEventTypes.TOP_STALLED, + DOMTopLevelEventTypes.TOP_SUBMIT, + DOMTopLevelEventTypes.TOP_SUSPEND, + DOMTopLevelEventTypes.TOP_TIME_UPDATE, + DOMTopLevelEventTypes.TOP_TOGGLE, + DOMTopLevelEventTypes.TOP_VOLUME_CHANGE, + DOMTopLevelEventTypes.TOP_WAITING, ]; const SimpleEventPlugin: PluginModule = { @@ -211,7 +211,7 @@ const SimpleEventPlugin: PluginModule = { } let EventConstructor; switch (topLevelType) { - case TopLevelEventTypes.TOP_KEY_PRESS: + case DOMTopLevelEventTypes.TOP_KEY_PRESS: // Firefox creates a keypress event for function keys too. This removes // the unwanted keypress events. Enter is however both printable and // non-printable. One would expect Tab to be as well (but it isn't). @@ -219,65 +219,65 @@ const SimpleEventPlugin: PluginModule = { return null; } /* falls through */ - case TopLevelEventTypes.TOP_KEY_DOWN: - case TopLevelEventTypes.TOP_KEY_UP: + case DOMTopLevelEventTypes.TOP_KEY_DOWN: + case DOMTopLevelEventTypes.TOP_KEY_UP: EventConstructor = SyntheticKeyboardEvent; break; - case TopLevelEventTypes.TOP_BLUR: - case TopLevelEventTypes.TOP_FOCUS: + case DOMTopLevelEventTypes.TOP_BLUR: + case DOMTopLevelEventTypes.TOP_FOCUS: EventConstructor = SyntheticFocusEvent; break; - case TopLevelEventTypes.TOP_CLICK: + case DOMTopLevelEventTypes.TOP_CLICK: // Firefox creates a click event on right mouse clicks. This removes the // unwanted click events. if (nativeEvent.button === 2) { return null; } /* falls through */ - case TopLevelEventTypes.TOP_DOUBLE_CLICK: - case TopLevelEventTypes.TOP_MOUSE_DOWN: - case TopLevelEventTypes.TOP_MOUSE_MOVE: - case TopLevelEventTypes.TOP_MOUSE_UP: + case DOMTopLevelEventTypes.TOP_DOUBLE_CLICK: + case DOMTopLevelEventTypes.TOP_MOUSE_DOWN: + case DOMTopLevelEventTypes.TOP_MOUSE_MOVE: + case DOMTopLevelEventTypes.TOP_MOUSE_UP: // TODO: Disabled elements should not respond to mouse events /* falls through */ - case TopLevelEventTypes.TOP_MOUSE_OUT: - case TopLevelEventTypes.TOP_MOUSE_OVER: - case TopLevelEventTypes.TOP_CONTEXT_MENU: + case DOMTopLevelEventTypes.TOP_MOUSE_OUT: + case DOMTopLevelEventTypes.TOP_MOUSE_OVER: + case DOMTopLevelEventTypes.TOP_CONTEXT_MENU: EventConstructor = SyntheticMouseEvent; break; - case TopLevelEventTypes.TOP_DRAG: - case TopLevelEventTypes.TOP_DRAG_END: - case TopLevelEventTypes.TOP_DRAG_ENTER: - case TopLevelEventTypes.TOP_DRAG_EXIT: - case TopLevelEventTypes.TOP_DRAG_LEAVE: - case TopLevelEventTypes.TOP_DRAG_OVER: - case TopLevelEventTypes.TOP_DRAG_START: - case TopLevelEventTypes.TOP_DROP: + case DOMTopLevelEventTypes.TOP_DRAG: + case DOMTopLevelEventTypes.TOP_DRAG_END: + case DOMTopLevelEventTypes.TOP_DRAG_ENTER: + case DOMTopLevelEventTypes.TOP_DRAG_EXIT: + case DOMTopLevelEventTypes.TOP_DRAG_LEAVE: + case DOMTopLevelEventTypes.TOP_DRAG_OVER: + case DOMTopLevelEventTypes.TOP_DRAG_START: + case DOMTopLevelEventTypes.TOP_DROP: EventConstructor = SyntheticDragEvent; break; - case TopLevelEventTypes.TOP_TOUCH_CANCEL: - case TopLevelEventTypes.TOP_TOUCH_END: - case TopLevelEventTypes.TOP_TOUCH_MOVE: - case TopLevelEventTypes.TOP_TOUCH_START: + case DOMTopLevelEventTypes.TOP_TOUCH_CANCEL: + case DOMTopLevelEventTypes.TOP_TOUCH_END: + case DOMTopLevelEventTypes.TOP_TOUCH_MOVE: + case DOMTopLevelEventTypes.TOP_TOUCH_START: EventConstructor = SyntheticTouchEvent; break; - case TopLevelEventTypes.TOP_ANIMATION_END: - case TopLevelEventTypes.TOP_ANIMATION_ITERATION: - case TopLevelEventTypes.TOP_ANIMATION_START: + case DOMTopLevelEventTypes.TOP_ANIMATION_END: + case DOMTopLevelEventTypes.TOP_ANIMATION_ITERATION: + case DOMTopLevelEventTypes.TOP_ANIMATION_START: EventConstructor = SyntheticAnimationEvent; break; - case TopLevelEventTypes.TOP_TRANSITION_END: + case DOMTopLevelEventTypes.TOP_TRANSITION_END: EventConstructor = SyntheticTransitionEvent; break; - case TopLevelEventTypes.TOP_SCROLL: + case DOMTopLevelEventTypes.TOP_SCROLL: EventConstructor = SyntheticUIEvent; break; - case TopLevelEventTypes.TOP_WHEEL: + case DOMTopLevelEventTypes.TOP_WHEEL: EventConstructor = SyntheticWheelEvent; break; - case TopLevelEventTypes.TOP_COPY: - case TopLevelEventTypes.TOP_CUT: - case TopLevelEventTypes.TOP_PASTE: + case DOMTopLevelEventTypes.TOP_COPY: + case DOMTopLevelEventTypes.TOP_CUT: + case DOMTopLevelEventTypes.TOP_PASTE: EventConstructor = SyntheticClipboardEvent; break; default: diff --git a/packages/react-dom/src/events/TapEventPlugin.js b/packages/react-dom/src/events/TapEventPlugin.js index 73533b86228fb..cc36d19e57ff1 100644 --- a/packages/react-dom/src/events/TapEventPlugin.js +++ b/packages/react-dom/src/events/TapEventPlugin.js @@ -7,9 +7,10 @@ * @flow */ -import {isStartish, isEndish} from 'events/EventPluginUtils'; import {accumulateTwoPhaseDispatches} from 'events/EventPropagators'; import TouchEventUtils from 'fbjs/lib/TouchEventUtils'; +import type {TopLevelType} from 'events/TopLevelEventTypes'; + import { TOP_MOUSE_DOWN, TOP_MOUSE_MOVE, @@ -18,9 +19,8 @@ import { TOP_TOUCH_END, TOP_TOUCH_MOVE, TOP_TOUCH_START, -} from 'events/TopLevelEventTypes'; -import type {TopLevelType} from 'events/TopLevelEventTypes'; - +} from './DOMTopLevelEventTypes'; +import {isStartish, isEndish} from './DOMEventPluginUtils'; import SyntheticUIEvent from './SyntheticUIEvent'; /** diff --git a/packages/react-dom/src/__tests__/TapEventPlugin-test.internal.js b/packages/react-dom/src/events/__tests__/TapEventPlugin-test.internal.js similarity index 100% rename from packages/react-dom/src/__tests__/TapEventPlugin-test.internal.js rename to packages/react-dom/src/events/__tests__/TapEventPlugin-test.internal.js diff --git a/packages/react-dom/src/test-utils/ReactTestUtils.js b/packages/react-dom/src/test-utils/ReactTestUtils.js index ce4df00273b39..e2df5e6908f6a 100644 --- a/packages/react-dom/src/test-utils/ReactTestUtils.js +++ b/packages/react-dom/src/test-utils/ReactTestUtils.js @@ -16,9 +16,10 @@ import { HostText, } from 'shared/ReactTypeOfWork'; import SyntheticEvent from 'events/SyntheticEvent'; -import * as TopLevelEventTypes from 'events/TopLevelEventTypes'; import invariant from 'fbjs/lib/invariant'; +import * as DOMTopLevelEventTypes from '../events/DOMTopLevelEventTypes'; + const {findDOMNode} = ReactDOM; const { EventPluginHub, @@ -457,75 +458,75 @@ function makeNativeSimulator(eventType, topLevelType) { } [ - [TopLevelEventTypes.TOP_ANIMATION_END, 'animationEnd'], - [TopLevelEventTypes.TOP_ANIMATION_ITERATION, 'animationIteration'], - [TopLevelEventTypes.TOP_ANIMATION_START, 'animationStart'], - [TopLevelEventTypes.TOP_BLUR, 'blur'], - [TopLevelEventTypes.TOP_CANCEL, 'cancel'], - [TopLevelEventTypes.TOP_CHANGE, 'change'], - [TopLevelEventTypes.TOP_CLICK, 'click'], - [TopLevelEventTypes.TOP_CLOSE, 'close'], - [TopLevelEventTypes.TOP_COMPOSITION_END, 'compositionEnd'], - [TopLevelEventTypes.TOP_COMPOSITION_START, 'compositionStart'], - [TopLevelEventTypes.TOP_COMPOSITION_UPDATE, 'compositionUpdate'], - [TopLevelEventTypes.TOP_CONTEXT_MENU, 'contextMenu'], - [TopLevelEventTypes.TOP_COPY, 'copy'], - [TopLevelEventTypes.TOP_CUT, 'cut'], - [TopLevelEventTypes.TOP_DOUBLE_CLICK, 'doubleClick'], - [TopLevelEventTypes.TOP_DRAG, 'drag'], - [TopLevelEventTypes.TOP_DRAG_END, 'dragEnd'], - [TopLevelEventTypes.TOP_DRAG_ENTER, 'dragEnter'], - [TopLevelEventTypes.TOP_DRAG_EXIT, 'dragExit'], - [TopLevelEventTypes.TOP_DRAG_LEAVE, 'dragLeave'], - [TopLevelEventTypes.TOP_DRAG_OVER, 'dragOver'], - [TopLevelEventTypes.TOP_DRAG_START, 'dragStart'], - [TopLevelEventTypes.TOP_DROP, 'drop'], - [TopLevelEventTypes.TOP_FOCUS, 'focus'], - [TopLevelEventTypes.TOP_INPUT, 'input'], - [TopLevelEventTypes.TOP_KEY_DOWN, 'keyDown'], - [TopLevelEventTypes.TOP_KEY_PRESS, 'keyPress'], - [TopLevelEventTypes.TOP_KEY_UP, 'keyUp'], - [TopLevelEventTypes.TOP_LOAD, 'load'], - [TopLevelEventTypes.TOP_LOAD_START, 'loadStart'], - [TopLevelEventTypes.TOP_MOUSE_DOWN, 'mouseDown'], - [TopLevelEventTypes.TOP_MOUSE_MOVE, 'mouseMove'], - [TopLevelEventTypes.TOP_MOUSE_OUT, 'mouseOut'], - [TopLevelEventTypes.TOP_MOUSE_OVER, 'mouseOver'], - [TopLevelEventTypes.TOP_MOUSE_UP, 'mouseUp'], - [TopLevelEventTypes.TOP_PASTE, 'paste'], - [TopLevelEventTypes.TOP_SCROLL, 'scroll'], - [TopLevelEventTypes.TOP_SELECTION_CHANGE, 'selectionChange'], - [TopLevelEventTypes.TOP_TEXT_INPUT, 'textInput'], - [TopLevelEventTypes.TOP_TOGGLE, 'toggle'], - [TopLevelEventTypes.TOP_TOUCH_CANCEL, 'touchCancel'], - [TopLevelEventTypes.TOP_TOUCH_END, 'touchEnd'], - [TopLevelEventTypes.TOP_TOUCH_MOVE, 'touchMove'], - [TopLevelEventTypes.TOP_TOUCH_START, 'touchStart'], - [TopLevelEventTypes.TOP_TRANSITION_END, 'transitionEnd'], - [TopLevelEventTypes.TOP_WHEEL, 'wheel'], - [TopLevelEventTypes.TOP_ABORT, 'abort'], - [TopLevelEventTypes.TOP_CAN_PLAY, 'canPlay'], - [TopLevelEventTypes.TOP_CAN_PLAY_THROUGH, 'canPlayThrough'], - [TopLevelEventTypes.TOP_DURATION_CHANGE, 'durationChange'], - [TopLevelEventTypes.TOP_EMPTIED, 'emptied'], - [TopLevelEventTypes.TOP_ENCRYPTED, 'encrypted'], - [TopLevelEventTypes.TOP_ENDED, 'ended'], - [TopLevelEventTypes.TOP_ERROR, 'error'], - [TopLevelEventTypes.TOP_LOADED_DATA, 'loadedData'], - [TopLevelEventTypes.TOP_LOADED_METADATA, 'loadedMetadata'], - [TopLevelEventTypes.TOP_LOAD_START, 'loadStart'], - [TopLevelEventTypes.TOP_PAUSE, 'pause'], - [TopLevelEventTypes.TOP_PLAY, 'play'], - [TopLevelEventTypes.TOP_PLAYING, 'playing'], - [TopLevelEventTypes.TOP_PROGRESS, 'progress'], - [TopLevelEventTypes.TOP_RATE_CHANGE, 'rateChange'], - [TopLevelEventTypes.TOP_SEEKED, 'seeked'], - [TopLevelEventTypes.TOP_SEEKING, 'seeking'], - [TopLevelEventTypes.TOP_STALLED, 'stalled'], - [TopLevelEventTypes.TOP_SUSPEND, 'suspend'], - [TopLevelEventTypes.TOP_TIME_UPDATE, 'timeUpdate'], - [TopLevelEventTypes.TOP_VOLUME_CHANGE, 'volumeChange'], - [TopLevelEventTypes.TOP_WAITING, 'waiting'], + [DOMTopLevelEventTypes.TOP_ANIMATION_END, 'animationEnd'], + [DOMTopLevelEventTypes.TOP_ANIMATION_ITERATION, 'animationIteration'], + [DOMTopLevelEventTypes.TOP_ANIMATION_START, 'animationStart'], + [DOMTopLevelEventTypes.TOP_BLUR, 'blur'], + [DOMTopLevelEventTypes.TOP_CANCEL, 'cancel'], + [DOMTopLevelEventTypes.TOP_CHANGE, 'change'], + [DOMTopLevelEventTypes.TOP_CLICK, 'click'], + [DOMTopLevelEventTypes.TOP_CLOSE, 'close'], + [DOMTopLevelEventTypes.TOP_COMPOSITION_END, 'compositionEnd'], + [DOMTopLevelEventTypes.TOP_COMPOSITION_START, 'compositionStart'], + [DOMTopLevelEventTypes.TOP_COMPOSITION_UPDATE, 'compositionUpdate'], + [DOMTopLevelEventTypes.TOP_CONTEXT_MENU, 'contextMenu'], + [DOMTopLevelEventTypes.TOP_COPY, 'copy'], + [DOMTopLevelEventTypes.TOP_CUT, 'cut'], + [DOMTopLevelEventTypes.TOP_DOUBLE_CLICK, 'doubleClick'], + [DOMTopLevelEventTypes.TOP_DRAG, 'drag'], + [DOMTopLevelEventTypes.TOP_DRAG_END, 'dragEnd'], + [DOMTopLevelEventTypes.TOP_DRAG_ENTER, 'dragEnter'], + [DOMTopLevelEventTypes.TOP_DRAG_EXIT, 'dragExit'], + [DOMTopLevelEventTypes.TOP_DRAG_LEAVE, 'dragLeave'], + [DOMTopLevelEventTypes.TOP_DRAG_OVER, 'dragOver'], + [DOMTopLevelEventTypes.TOP_DRAG_START, 'dragStart'], + [DOMTopLevelEventTypes.TOP_DROP, 'drop'], + [DOMTopLevelEventTypes.TOP_FOCUS, 'focus'], + [DOMTopLevelEventTypes.TOP_INPUT, 'input'], + [DOMTopLevelEventTypes.TOP_KEY_DOWN, 'keyDown'], + [DOMTopLevelEventTypes.TOP_KEY_PRESS, 'keyPress'], + [DOMTopLevelEventTypes.TOP_KEY_UP, 'keyUp'], + [DOMTopLevelEventTypes.TOP_LOAD, 'load'], + [DOMTopLevelEventTypes.TOP_LOAD_START, 'loadStart'], + [DOMTopLevelEventTypes.TOP_MOUSE_DOWN, 'mouseDown'], + [DOMTopLevelEventTypes.TOP_MOUSE_MOVE, 'mouseMove'], + [DOMTopLevelEventTypes.TOP_MOUSE_OUT, 'mouseOut'], + [DOMTopLevelEventTypes.TOP_MOUSE_OVER, 'mouseOver'], + [DOMTopLevelEventTypes.TOP_MOUSE_UP, 'mouseUp'], + [DOMTopLevelEventTypes.TOP_PASTE, 'paste'], + [DOMTopLevelEventTypes.TOP_SCROLL, 'scroll'], + [DOMTopLevelEventTypes.TOP_SELECTION_CHANGE, 'selectionChange'], + [DOMTopLevelEventTypes.TOP_TEXT_INPUT, 'textInput'], + [DOMTopLevelEventTypes.TOP_TOGGLE, 'toggle'], + [DOMTopLevelEventTypes.TOP_TOUCH_CANCEL, 'touchCancel'], + [DOMTopLevelEventTypes.TOP_TOUCH_END, 'touchEnd'], + [DOMTopLevelEventTypes.TOP_TOUCH_MOVE, 'touchMove'], + [DOMTopLevelEventTypes.TOP_TOUCH_START, 'touchStart'], + [DOMTopLevelEventTypes.TOP_TRANSITION_END, 'transitionEnd'], + [DOMTopLevelEventTypes.TOP_WHEEL, 'wheel'], + [DOMTopLevelEventTypes.TOP_ABORT, 'abort'], + [DOMTopLevelEventTypes.TOP_CAN_PLAY, 'canPlay'], + [DOMTopLevelEventTypes.TOP_CAN_PLAY_THROUGH, 'canPlayThrough'], + [DOMTopLevelEventTypes.TOP_DURATION_CHANGE, 'durationChange'], + [DOMTopLevelEventTypes.TOP_EMPTIED, 'emptied'], + [DOMTopLevelEventTypes.TOP_ENCRYPTED, 'encrypted'], + [DOMTopLevelEventTypes.TOP_ENDED, 'ended'], + [DOMTopLevelEventTypes.TOP_ERROR, 'error'], + [DOMTopLevelEventTypes.TOP_LOADED_DATA, 'loadedData'], + [DOMTopLevelEventTypes.TOP_LOADED_METADATA, 'loadedMetadata'], + [DOMTopLevelEventTypes.TOP_LOAD_START, 'loadStart'], + [DOMTopLevelEventTypes.TOP_PAUSE, 'pause'], + [DOMTopLevelEventTypes.TOP_PLAY, 'play'], + [DOMTopLevelEventTypes.TOP_PLAYING, 'playing'], + [DOMTopLevelEventTypes.TOP_PROGRESS, 'progress'], + [DOMTopLevelEventTypes.TOP_RATE_CHANGE, 'rateChange'], + [DOMTopLevelEventTypes.TOP_SEEKED, 'seeked'], + [DOMTopLevelEventTypes.TOP_SEEKING, 'seeking'], + [DOMTopLevelEventTypes.TOP_STALLED, 'stalled'], + [DOMTopLevelEventTypes.TOP_SUSPEND, 'suspend'], + [DOMTopLevelEventTypes.TOP_TIME_UPDATE, 'timeUpdate'], + [DOMTopLevelEventTypes.TOP_VOLUME_CHANGE, 'volumeChange'], + [DOMTopLevelEventTypes.TOP_WAITING, 'waiting'], ].forEach(function(tuple) { const topLevelType = tuple[0]; const eventType = tuple[1]; diff --git a/packages/react-dom/src/unstable-native-dependencies/ReactDOMUnstableNativeDependencies.js b/packages/react-dom/src/unstable-native-dependencies/ReactDOMUnstableNativeDependencies.js index 763a4f38d0683..a332519539a79 100644 --- a/packages/react-dom/src/unstable-native-dependencies/ReactDOMUnstableNativeDependencies.js +++ b/packages/react-dom/src/unstable-native-dependencies/ReactDOMUnstableNativeDependencies.js @@ -7,13 +7,14 @@ import ReactDOM from 'react-dom'; import * as EventPluginUtils from 'events/EventPluginUtils'; -import ResponderEventPlugin from 'events/ResponderEventPlugin'; import ResponderTouchHistoryStore from 'events/ResponderTouchHistoryStore'; +import DOMResponderEventPlugin from '../events/DOMResponderEventPlugin'; + // This is used by react-native-web. export const injectComponentTree = EventPluginUtils.injection.injectComponentTree; -export {ResponderEventPlugin, ResponderTouchHistoryStore}; +export {DOMResponderEventPlugin, ResponderTouchHistoryStore}; // Inject react-dom's ComponentTree into this module. const { diff --git a/packages/react-native-renderer/src/ReactNativeEventPluginOrder.js b/packages/react-native-renderer/src/ReactNativeEventPluginOrder.js index de6029b20c649..68b91bf2c378e 100644 --- a/packages/react-native-renderer/src/ReactNativeEventPluginOrder.js +++ b/packages/react-native-renderer/src/ReactNativeEventPluginOrder.js @@ -8,7 +8,7 @@ */ const ReactNativeEventPluginOrder = [ - 'ResponderEventPlugin', + 'ReactNativeResponderEventPlugin', 'ReactNativeBridgeEventPlugin', ]; diff --git a/packages/react-native-renderer/src/ReactNativeInjectionShared.js b/packages/react-native-renderer/src/ReactNativeInjectionShared.js index cc35fdebe961a..78c93d410d54e 100644 --- a/packages/react-native-renderer/src/ReactNativeInjectionShared.js +++ b/packages/react-native-renderer/src/ReactNativeInjectionShared.js @@ -18,9 +18,9 @@ import 'InitializeCore'; import * as EventPluginHub from 'events/EventPluginHub'; import * as EventPluginUtils from 'events/EventPluginUtils'; -import ResponderEventPlugin from 'events/ResponderEventPlugin'; import ReactNativeBridgeEventPlugin from './ReactNativeBridgeEventPlugin'; +import ReactNativeResponderEventPlugin from './ReactNativeResponderEventPlugin'; import * as ReactNativeComponentTree from './ReactNativeComponentTree'; import ReactNativeEventPluginOrder from './ReactNativeEventPluginOrder'; import ReactNativeGlobalResponderHandler from './ReactNativeGlobalResponderHandler'; @@ -31,7 +31,7 @@ import ReactNativeGlobalResponderHandler from './ReactNativeGlobalResponderHandl EventPluginHub.injection.injectEventPluginOrder(ReactNativeEventPluginOrder); EventPluginUtils.injection.injectComponentTree(ReactNativeComponentTree); -ResponderEventPlugin.injection.injectGlobalResponderHandler( +ReactNativeResponderEventPlugin.injection.injectGlobalResponderHandler( ReactNativeGlobalResponderHandler, ); @@ -40,6 +40,6 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler( * them). */ EventPluginHub.injection.injectEventPluginsByName({ - ResponderEventPlugin: ResponderEventPlugin, + ReactNativeResponderEventPlugin: ReactNativeResponderEventPlugin, ReactNativeBridgeEventPlugin: ReactNativeBridgeEventPlugin, }); diff --git a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js new file mode 100644 index 0000000000000..52b05f8a085b8 --- /dev/null +++ b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js @@ -0,0 +1,22 @@ +/** + * 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. + */ + +import ResponderEventPlugin from 'events/ResponderEventPlugin'; + +ResponderEventPlugin.injection.injectTopLevelTypes({ + topMouseDown: 'topMouseDown', + topMouseMove: 'topMouseMove', + topMouseUp: 'topMouseUp', + topScroll: 'topScroll', + topSelectionChange: 'topSelectionChange', + topTouchCancel: 'topTouchCancel', + topTouchEnd: 'topTouchEnd', + topTouchMove: 'topTouchMove', + topTouchStart: 'topTouchStart', +}); + +export default ResponderEventPlugin; From 9d684fc7fbf59f1f27a19dcd52b9a85daacc1c9a Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Sat, 21 Apr 2018 13:28:32 +0200 Subject: [PATCH 21/45] Set proper dependencies for DOMResponderEventPlugin --- .../src/events/DOMResponderEventPlugin.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/react-dom/src/events/DOMResponderEventPlugin.js b/packages/react-dom/src/events/DOMResponderEventPlugin.js index fb7860c4c156f..b4bde54a0389b 100644 --- a/packages/react-dom/src/events/DOMResponderEventPlugin.js +++ b/packages/react-dom/src/events/DOMResponderEventPlugin.js @@ -19,6 +19,23 @@ import { TOP_TOUCH_START, } from './DOMTopLevelEventTypes'; +const endDependencies = [TOP_TOUCH_CANCEL, TOP_TOUCH_END, TOP_MOUSE_UP]; +const moveDependencies = [TOP_TOUCH_MOVE, TOP_MOUSE_MOVE]; +const startDependencies = [TOP_TOUCH_START, TOP_MOUSE_DOWN]; + +ResponderEventPlugin.eventTypes.responderMove.dependencies = moveDependencies; +ResponderEventPlugin.eventTypes.responderEnd.dependencies = endDependencies; +ResponderEventPlugin.eventTypes.responderStart.dependencies = startDependencies; +ResponderEventPlugin.eventTypes.responderRelease.dependencies = endDependencies; +ResponderEventPlugin.eventTypes.responderTerminationRequest.dependencies = []; +ResponderEventPlugin.eventTypes.responderGrant.dependencies = []; +ResponderEventPlugin.eventTypes.responderReject.dependencies = []; +ResponderEventPlugin.eventTypes.responderTerminate.dependencies = []; +ResponderEventPlugin.eventTypes.moveShouldSetResponder.dependencies = moveDependencies; +ResponderEventPlugin.eventTypes.selectionChangeShouldSetResponder.dependencies = [TOP_SELECTION_CHANGE]; +ResponderEventPlugin.eventTypes.scrollShouldSetResponder.dependencies = [TOP_SCROLL]; +ResponderEventPlugin.eventTypes.startShouldSetResponder.dependencies = startDependencies; + ResponderEventPlugin.injection.injectTopLevelTypes({ topMouseDown: TOP_MOUSE_DOWN, topMouseMove: TOP_MOUSE_MOVE, From c27ab85b8ee8f23868348d5fb0b8edf9f3d90f15 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Sat, 21 Apr 2018 13:38:25 +0200 Subject: [PATCH 22/45] Prettify --- packages/events/ResponderEventPlugin.js | 1 - packages/events/ResponderTouchHistoryStore.js | 8 ++++++-- .../react-dom/src/events/DOMEventPluginUtils.js | 14 +++++++------- .../src/events/DOMResponderEventPlugin.js | 10 +++++++--- 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/packages/events/ResponderEventPlugin.js b/packages/events/ResponderEventPlugin.js index 9c3010f1e38c7..8914d2db42054 100644 --- a/packages/events/ResponderEventPlugin.js +++ b/packages/events/ResponderEventPlugin.js @@ -23,7 +23,6 @@ import ResponderSyntheticEvent from './ResponderSyntheticEvent'; import ResponderTouchHistoryStore from './ResponderTouchHistoryStore'; import accumulate from './accumulate'; - function isStartish(topLevelType) { return ( topLevelType === ResponderEventPlugin.TopLevelTypes.topMouseDown || diff --git a/packages/events/ResponderTouchHistoryStore.js b/packages/events/ResponderTouchHistoryStore.js index 81c49aa8d6560..a930da4fb2367 100644 --- a/packages/events/ResponderTouchHistoryStore.js +++ b/packages/events/ResponderTouchHistoryStore.js @@ -180,7 +180,7 @@ type EventUtils = { isStartish: (topLevelType: TopLevelType) => boolean, isMoveish: (topLevelType: TopLevelType) => boolean, isEndish: (topLevelType: TopLevelType) => boolean, -} +}; const ResponderTouchHistoryStore = { recordTouchTrack(topLevelType: TopLevelType, nativeEvent: TouchEvent): void { @@ -188,7 +188,11 @@ const ResponderTouchHistoryStore = { ResponderTouchHistoryStore.EventUtils, 'ResponderTouchHistoryStore requires EventUtils to be injected first.', ); - const {isStartish, isMoveish, isEndish} = ResponderTouchHistoryStore.EventUtils + const { + isStartish, + isMoveish, + isEndish, + } = ResponderTouchHistoryStore.EventUtils; if (isMoveish(topLevelType)) { nativeEvent.changedTouches.forEach(recordTouchMove); diff --git a/packages/react-dom/src/events/DOMEventPluginUtils.js b/packages/react-dom/src/events/DOMEventPluginUtils.js index 42fba7911ac36..a03ac1099d459 100644 --- a/packages/react-dom/src/events/DOMEventPluginUtils.js +++ b/packages/react-dom/src/events/DOMEventPluginUtils.js @@ -16,16 +16,16 @@ import { } from './DOMTopLevelEventTypes'; export function isEndish(topLevelType) { -return ( - topLevelType === TOP_MOUSE_UP || - topLevelType === TOP_TOUCH_END || - topLevelType === TOP_TOUCH_CANCEL -); + return ( + topLevelType === TOP_MOUSE_UP || + topLevelType === TOP_TOUCH_END || + topLevelType === TOP_TOUCH_CANCEL + ); } export function isMoveish(topLevelType) { -return topLevelType === TOP_MOUSE_MOVE || topLevelType === TOP_TOUCH_MOVE; + return topLevelType === TOP_MOUSE_MOVE || topLevelType === TOP_TOUCH_MOVE; } export function isStartish(topLevelType) { -return topLevelType === TOP_MOUSE_DOWN || topLevelType === TOP_TOUCH_START; + return topLevelType === TOP_MOUSE_DOWN || topLevelType === TOP_TOUCH_START; } diff --git a/packages/react-dom/src/events/DOMResponderEventPlugin.js b/packages/react-dom/src/events/DOMResponderEventPlugin.js index b4bde54a0389b..e665616d474d6 100644 --- a/packages/react-dom/src/events/DOMResponderEventPlugin.js +++ b/packages/react-dom/src/events/DOMResponderEventPlugin.js @@ -17,7 +17,7 @@ import { TOP_TOUCH_END, TOP_TOUCH_MOVE, TOP_TOUCH_START, - } from './DOMTopLevelEventTypes'; +} from './DOMTopLevelEventTypes'; const endDependencies = [TOP_TOUCH_CANCEL, TOP_TOUCH_END, TOP_MOUSE_UP]; const moveDependencies = [TOP_TOUCH_MOVE, TOP_MOUSE_MOVE]; @@ -32,8 +32,12 @@ ResponderEventPlugin.eventTypes.responderGrant.dependencies = []; ResponderEventPlugin.eventTypes.responderReject.dependencies = []; ResponderEventPlugin.eventTypes.responderTerminate.dependencies = []; ResponderEventPlugin.eventTypes.moveShouldSetResponder.dependencies = moveDependencies; -ResponderEventPlugin.eventTypes.selectionChangeShouldSetResponder.dependencies = [TOP_SELECTION_CHANGE]; -ResponderEventPlugin.eventTypes.scrollShouldSetResponder.dependencies = [TOP_SCROLL]; +ResponderEventPlugin.eventTypes.selectionChangeShouldSetResponder.dependencies = [ + TOP_SELECTION_CHANGE, +]; +ResponderEventPlugin.eventTypes.scrollShouldSetResponder.dependencies = [ + TOP_SCROLL, +]; ResponderEventPlugin.eventTypes.startShouldSetResponder.dependencies = startDependencies; ResponderEventPlugin.injection.injectTopLevelTypes({ From 4043f87eb6c9708818569cf66e1ab15de8dc2cf5 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Sat, 21 Apr 2018 15:05:38 +0200 Subject: [PATCH 23/45] Make some react dom tests no longer depend on internal API --- .../react-dom/src/__tests__/ReactDOM-test.js | 13 +--- .../src/__tests__/ReactDOMFiber-test.js | 26 ++------ .../src/__tests__/ReactDOMInput-test.js | 9 +-- .../src/test-utils/ReactTestUtils.js | 62 +++++++++---------- 4 files changed, 39 insertions(+), 71 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactDOM-test.js b/packages/react-dom/src/__tests__/ReactDOM-test.js index ca3a8f013690e..cca40165fd458 100644 --- a/packages/react-dom/src/__tests__/ReactDOM-test.js +++ b/packages/react-dom/src/__tests__/ReactDOM-test.js @@ -13,8 +13,6 @@ let React = require('react'); let ReactDOM = require('react-dom'); const ReactTestUtils = require('react-dom/test-utils'); -const {TOP_CLICK} = require('../events/DOMTopLevelEventTypes'); - describe('ReactDOM', () => { // TODO: uncomment this test once we can run in phantom, which // supports real submit events. @@ -311,14 +309,9 @@ describe('ReactDOM', () => { const actual = []; function click(node) { - const fakeNativeEvent = function() {}; - fakeNativeEvent.target = node; - fakeNativeEvent.path = [node, container]; - ReactTestUtils.simulateNativeEventOnNode( - TOP_CLICK, - node, - fakeNativeEvent, - ); + ReactTestUtils.Simulate.click(node, { + path: [node, container], + }); } class Wrapper extends React.Component { diff --git a/packages/react-dom/src/__tests__/ReactDOMFiber-test.js b/packages/react-dom/src/__tests__/ReactDOMFiber-test.js index 8fecb85d120dc..a93dda6ce11e8 100644 --- a/packages/react-dom/src/__tests__/ReactDOMFiber-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMFiber-test.js @@ -14,12 +14,6 @@ const ReactDOM = require('react-dom'); const ReactTestUtils = require('react-dom/test-utils'); const PropTypes = require('prop-types'); -const { - TOP_CLICK, - TOP_MOUSE_OUT, - TOP_MOUSE_OVER, -} = require('../events/DOMTopLevelEventTypes'); - describe('ReactDOMFiber', () => { let container; @@ -844,12 +838,7 @@ describe('ReactDOMFiber', () => { expect(portal.tagName).toBe('DIV'); - const fakeNativeEvent = {}; - ReactTestUtils.simulateNativeEventOnNode( - TOP_CLICK, - portal, - fakeNativeEvent, - ); + ReactTestUtils.Simulate.click(portal); expect(ops).toEqual(['portal clicked', 'parent clicked']); }); @@ -864,14 +853,12 @@ describe('ReactDOMFiber', () => { function simulateMouseMove(from, to) { if (from) { - ReactTestUtils.simulateNativeEventOnNode(TOP_MOUSE_OUT, from, { - target: from, + ReactTestUtils.SimulateNative.mouseOut(from, { relatedTarget: to, }); } if (to) { - ReactTestUtils.simulateNativeEventOnNode(TOP_MOUSE_OVER, to, { - target: to, + ReactTestUtils.SimulateNative.mouseOver(to, { relatedTarget: from, }); } @@ -989,12 +976,7 @@ describe('ReactDOMFiber', () => { expect(node.tagName).toEqual('DIV'); function click(target) { - const fakeNativeEvent = {}; - ReactTestUtils.simulateNativeEventOnNode( - TOP_CLICK, - target, - fakeNativeEvent, - ); + ReactTestUtils.Simulate.click(target); } click(node); diff --git a/packages/react-dom/src/__tests__/ReactDOMInput-test.js b/packages/react-dom/src/__tests__/ReactDOMInput-test.js index 9e539c42aa0ea..f5513557ec3c0 100644 --- a/packages/react-dom/src/__tests__/ReactDOMInput-test.js +++ b/packages/react-dom/src/__tests__/ReactDOMInput-test.js @@ -11,8 +11,6 @@ const emptyFunction = require('fbjs/lib/emptyFunction'); -const {TOP_INPUT} = require('../events/DOMTopLevelEventTypes'); - describe('ReactDOMInput', () => { let React; let ReactDOM; @@ -696,10 +694,9 @@ describe('ReactDOMInput', () => { setUntrackedValue.call(node, 'giraffe'); - const fakeNativeEvent = function() {}; - fakeNativeEvent.target = node; - fakeNativeEvent.path = [node, container]; - ReactTestUtils.simulateNativeEventOnNode(TOP_INPUT, node, fakeNativeEvent); + ReactTestUtils.SimulateNative.input(node, { + path: [node, container], + }); expect(handled).toBe(true); }); diff --git a/packages/react-dom/src/test-utils/ReactTestUtils.js b/packages/react-dom/src/test-utils/ReactTestUtils.js index e2df5e6908f6a..c974b8ed8ae3e 100644 --- a/packages/react-dom/src/test-utils/ReactTestUtils.js +++ b/packages/react-dom/src/test-utils/ReactTestUtils.js @@ -36,6 +36,33 @@ function Event(suffix) {} * @class ReactTestUtils */ +/** + * Simulates a top level event being dispatched from a raw event that occurred + * on an `Element` node. + * @param {number} topLevelType A number from `TopLevelEventTypes` + * @param {!Element} node The dom to simulate an event occurring on. + * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent. + */ +function simulateNativeEventOnNode(topLevelType, node, fakeNativeEvent) { + fakeNativeEvent.target = node; + ReactDOMEventListener.dispatchEvent(topLevelType, fakeNativeEvent); +} + +/** + * Simulates a top level event being dispatched from a raw event that occurred + * on the `ReactDOMComponent` `comp`. + * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes`. + * @param {!ReactDOMComponent} comp + * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent. + */ +function simulateNativeEventOnDOMComponent( + topLevelType, + comp, + fakeNativeEvent, +) { + simulateNativeEventOnNode(topLevelType, findDOMNode(comp), fakeNativeEvent); +} + function findAllInRenderedFiberTreeInternal(fiber, test) { if (!fiber) { return []; @@ -291,37 +318,6 @@ const ReactTestUtils = { return this; }, - /** - * Simulates a top level event being dispatched from a raw event that occurred - * on an `Element` node. - * @param {number} topLevelType A number from `TopLevelEventTypes` - * @param {!Element} node The dom to simulate an event occurring on. - * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent. - */ - simulateNativeEventOnNode: function(topLevelType, node, fakeNativeEvent) { - fakeNativeEvent.target = node; - ReactDOMEventListener.dispatchEvent(topLevelType, fakeNativeEvent); - }, - - /** - * Simulates a top level event being dispatched from a raw event that occurred - * on the `ReactDOMComponent` `comp`. - * @param {Object} topLevelType A type from `BrowserEventConstants.topLevelTypes`. - * @param {!ReactDOMComponent} comp - * @param {?Event} fakeNativeEvent Fake native event to use in SyntheticEvent. - */ - simulateNativeEventOnDOMComponent: function( - topLevelType, - comp, - fakeNativeEvent, - ) { - ReactTestUtils.simulateNativeEventOnNode( - topLevelType, - findDOMNode(comp), - fakeNativeEvent, - ); - }, - nativeTouchData: function(x, y) { return { touches: [{pageX: x, pageY: y}], @@ -441,14 +437,14 @@ function makeNativeSimulator(eventType, topLevelType) { const fakeNativeEvent = new Event(eventType); Object.assign(fakeNativeEvent, nativeEventData); if (ReactTestUtils.isDOMComponent(domComponentOrNode)) { - ReactTestUtils.simulateNativeEventOnDOMComponent( + simulateNativeEventOnDOMComponent( topLevelType, domComponentOrNode, fakeNativeEvent, ); } else if (domComponentOrNode.tagName) { // Will allow on actual dom nodes. - ReactTestUtils.simulateNativeEventOnNode( + simulateNativeEventOnNode( topLevelType, domComponentOrNode, fakeNativeEvent, From f0299404be344f2e4e2f9899508ef94d254514ab Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Sat, 21 Apr 2018 16:03:33 +0200 Subject: [PATCH 24/45] Use factories to create top level speific generic event modules --- packages/events/ResponderEventPlugin.js | 641 ------------------ packages/events/createResponderEventPlugin.js | 623 +++++++++++++++++ ...js => createResponderTouchHistoryStore.js} | 127 ++-- .../src/events/DOMResponderEventPlugin.js | 59 +- .../ReactDOMUnstableNativeDependencies.js | 5 +- .../src/ReactNativeResponderEventPlugin.js | 17 +- .../ReactNativeEvents-test.internal.js | 9 +- 7 files changed, 747 insertions(+), 734 deletions(-) delete mode 100644 packages/events/ResponderEventPlugin.js create mode 100644 packages/events/createResponderEventPlugin.js rename packages/events/{ResponderTouchHistoryStore.js => createResponderTouchHistoryStore.js} (70%) diff --git a/packages/events/ResponderEventPlugin.js b/packages/events/ResponderEventPlugin.js deleted file mode 100644 index 8914d2db42054..0000000000000 --- a/packages/events/ResponderEventPlugin.js +++ /dev/null @@ -1,641 +0,0 @@ -/** - * 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. - */ - -import {getLowestCommonAncestor, isAncestor} from 'shared/ReactTreeTraversal'; -import invariant from 'fbjs/lib/invariant'; - -import { - executeDirectDispatch, - hasDispatches, - executeDispatchesInOrderStopAtTrue, - getInstanceFromNode, -} from './EventPluginUtils'; -import { - accumulateDirectDispatches, - accumulateTwoPhaseDispatches, - accumulateTwoPhaseDispatchesSkipTarget, -} from './EventPropagators'; -import ResponderSyntheticEvent from './ResponderSyntheticEvent'; -import ResponderTouchHistoryStore from './ResponderTouchHistoryStore'; -import accumulate from './accumulate'; - -function isStartish(topLevelType) { - return ( - topLevelType === ResponderEventPlugin.TopLevelTypes.topMouseDown || - topLevelType === ResponderEventPlugin.TopLevelTypes.topTouchStart - ); -} - -function isMoveish(topLevelType) { - return ( - topLevelType === ResponderEventPlugin.TopLevelTypes.topMouseMove || - topLevelType === ResponderEventPlugin.TopLevelTypes.topTouchMove - ); -} - -function isEndish(topLevelType) { - return ( - topLevelType === ResponderEventPlugin.TopLevelTypes.topMouseUp || - topLevelType === ResponderEventPlugin.TopLevelTypes.topTouchEnd || - topLevelType === ResponderEventPlugin.TopLevelTypes.topTouchCancel - ); -} - -ResponderTouchHistoryStore.injection.injectEventUtils({ - isStartish, - isMoveish, - isEndish, -}); - -/** - * Instance of element that should respond to touch/move types of interactions, - * as indicated explicitly by relevant callbacks. - */ -let responderInst = null; - -/** - * Count of current touches. A textInput should become responder iff the - * selection changes while there is a touch on the screen. - */ -let trackedTouchCount = 0; - -/** - * Last reported number of active touches. - */ -let previousActiveTouches = 0; - -const changeResponder = function(nextResponderInst, blockHostResponder) { - const oldResponderInst = responderInst; - responderInst = nextResponderInst; - if (ResponderEventPlugin.GlobalResponderHandler !== null) { - ResponderEventPlugin.GlobalResponderHandler.onChange( - oldResponderInst, - nextResponderInst, - blockHostResponder, - ); - } -}; - -const eventTypes = { - /** - * On a `touchStart`/`mouseDown`, is it desired that this element become the - * responder? - */ - startShouldSetResponder: { - phasedRegistrationNames: { - bubbled: 'onStartShouldSetResponder', - captured: 'onStartShouldSetResponderCapture', - }, - }, - - /** - * On a `scroll`, is it desired that this element become the responder? This - * is usually not needed, but should be used to retroactively infer that a - * `touchStart` had occurred during momentum scroll. During a momentum scroll, - * a touch start will be immediately followed by a scroll event if the view is - * currently scrolling. - * - * TODO: This shouldn't bubble. - */ - scrollShouldSetResponder: { - phasedRegistrationNames: { - bubbled: 'onScrollShouldSetResponder', - captured: 'onScrollShouldSetResponderCapture', - }, - }, - - /** - * On text selection change, should this element become the responder? This - * is needed for text inputs or other views with native selection, so the - * JS view can claim the responder. - * - * TODO: This shouldn't bubble. - */ - selectionChangeShouldSetResponder: { - phasedRegistrationNames: { - bubbled: 'onSelectionChangeShouldSetResponder', - captured: 'onSelectionChangeShouldSetResponderCapture', - }, - }, - - /** - * On a `touchMove`/`mouseMove`, is it desired that this element become the - * responder? - */ - moveShouldSetResponder: { - phasedRegistrationNames: { - bubbled: 'onMoveShouldSetResponder', - captured: 'onMoveShouldSetResponderCapture', - }, - }, - - /** - * 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', - }, - responderGrant: {registrationName: 'onResponderGrant'}, - responderReject: {registrationName: 'onResponderReject'}, - responderTerminate: {registrationName: 'onResponderTerminate'}, -}; - -/** - * - * Responder System: - * ---------------- - * - * - A global, solitary "interaction lock" on a view. - * - If a node becomes the responder, it should convey visual feedback - * immediately to indicate so, either by highlighting or moving accordingly. - * - To be the responder means, that touches are exclusively important to that - * responder view, and no other view. - * - While touches are still occurring, the responder lock can be transferred to - * a new view, but only to increasingly "higher" views (meaning ancestors of - * the current responder). - * - * Responder being granted: - * ------------------------ - * - * - Touch starts, moves, and scrolls can cause an ID to become the responder. - * - We capture/bubble `startShouldSetResponder`/`moveShouldSetResponder` to - * the "appropriate place". - * - If nothing is currently the responder, the "appropriate place" is the - * initiating event's `targetID`. - * - If something *is* already the responder, the "appropriate place" is the - * first common ancestor of the event target and the current `responderInst`. - * - Some negotiation happens: See the timing diagram below. - * - Scrolled views automatically become responder. The reasoning is that a - * platform scroll view that isn't built on top of the responder system has - * began scrolling, and the active responder must now be notified that the - * interaction is no longer locked to it - the system has taken over. - * - * - Responder being released: - * As soon as no more touches that *started* inside of descendants of the - * *current* responderInst, an `onResponderRelease` event is dispatched to the - * current responder, and the responder lock is released. - * - * TODO: - * - on "end", a callback hook for `onResponderEndShouldRemainResponder` that - * determines if the responder lock should remain. - * - If a view shouldn't "remain" the responder, any active touches should by - * default be considered "dead" and do not influence future negotiations or - * bubble paths. It should be as if those touches do not exist. - * -- For multitouch: Usually a translate-z will choose to "remain" responder - * after one out of many touches ended. For translate-y, usually the view - * doesn't wish to "remain" responder after one of many touches end. - * - Consider building this on top of a `stopPropagation` model similar to - * `W3C` events. - * - Ensure that `onResponderTerminate` is called on touch cancels, whether or - * not `onResponderTerminationRequest` returns `true` or `false`. - * - */ - -/* Negotiation Performed - +-----------------------+ - / \ -Process low level events to + Current Responder + wantsResponderID -determine who to perform negot-| (if any exists at all) | -iation/transition | Otherwise just pass through| --------------------------------+----------------------------+------------------+ -Bubble to find first ID | | -to return true:wantsResponderID| | - | | - +-------------+ | | - | onTouchStart| | | - +------+------+ none | | - | return| | -+-----------v-------------+true| +------------------------+ | -|onStartShouldSetResponder|----->|onResponderStart (cur) |<-----------+ -+-----------+-------------+ | +------------------------+ | | - | | | +--------+-------+ - | returned true for| false:REJECT +-------->|onResponderReject - | wantsResponderID | | | +----------------+ - | (now attempt | +------------------+-----+ | - | handoff) | | onResponder | | - +------------------->| TerminationRequest| | - | +------------------+-----+ | - | | | +----------------+ - | true:GRANT +-------->|onResponderGrant| - | | +--------+-------+ - | +------------------------+ | | - | | onResponderTerminate |<-----------+ - | +------------------+-----+ | - | | | +----------------+ - | +-------->|onResponderStart| - | | +----------------+ -Bubble to find first ID | | -to return true:wantsResponderID| | - | | - +-------------+ | | - | onTouchMove | | | - +------+------+ none | | - | return| | -+-----------v-------------+true| +------------------------+ | -|onMoveShouldSetResponder |----->|onResponderMove (cur) |<-----------+ -+-----------+-------------+ | +------------------------+ | | - | | | +--------+-------+ - | returned true for| false:REJECT +-------->|onResponderRejec| - | wantsResponderID | | | +----------------+ - | (now attempt | +------------------+-----+ | - | handoff) | | onResponder | | - +------------------->| TerminationRequest| | - | +------------------+-----+ | - | | | +----------------+ - | true:GRANT +-------->|onResponderGrant| - | | +--------+-------+ - | +------------------------+ | | - | | onResponderTerminate |<-----------+ - | +------------------+-----+ | - | | | +----------------+ - | +-------->|onResponderMove | - | | +----------------+ - | | - | | - Some active touch started| | - inside current responder | +------------------------+ | - +------------------------->| onResponderEnd | | - | | +------------------------+ | - +---+---------+ | | - | onTouchEnd | | | - +---+---------+ | | - | | +------------------------+ | - +------------------------->| onResponderEnd | | - No active touches started| +-----------+------------+ | - inside current responder | | | - | v | - | +------------------------+ | - | | onResponderRelease | | - | +------------------------+ | - | | - + + */ - -/** - * A note about event ordering in the `EventPluginHub`. - * - * Suppose plugins are injected in the following order: - * - * `[R, S, C]` - * - * To help illustrate the example, assume `S` is `SimpleEventPlugin` (for - * `onClick` etc) and `R` is `ResponderEventPlugin`. - * - * "Deferred-Dispatched Events": - * - * - The current event plugin system will traverse the list of injected plugins, - * in order, and extract events by collecting the plugin's return value of - * `extractEvents()`. - * - These events that are returned from `extractEvents` are "deferred - * dispatched events". - * - When returned from `extractEvents`, deferred-dispatched events contain an - * "accumulation" of deferred dispatches. - * - These deferred dispatches are accumulated/collected before they are - * returned, but processed at a later time by the `EventPluginHub` (hence the - * name deferred). - * - * In the process of returning their deferred-dispatched events, event plugins - * themselves can dispatch events on-demand without returning them from - * `extractEvents`. Plugins might want to do this, so that they can use event - * dispatching as a tool that helps them decide which events should be extracted - * in the first place. - * - * "On-Demand-Dispatched Events": - * - * - On-demand-dispatched events are not returned from `extractEvents`. - * - On-demand-dispatched events are dispatched during the process of returning - * the deferred-dispatched events. - * - They should not have side effects. - * - They should be avoided, and/or eventually be replaced with another - * abstraction that allows event plugins to perform multiple "rounds" of event - * extraction. - * - * Therefore, the sequence of event dispatches becomes: - * - * - `R`s on-demand events (if any) (dispatched by `R` on-demand) - * - `S`s on-demand events (if any) (dispatched by `S` on-demand) - * - `C`s on-demand events (if any) (dispatched by `C` on-demand) - * - `R`s extracted events (if any) (dispatched by `EventPluginHub`) - * - `S`s extracted events (if any) (dispatched by `EventPluginHub`) - * - `C`s extracted events (if any) (dispatched by `EventPluginHub`) - * - * In the case of `ResponderEventPlugin`: If the `startShouldSetResponder` - * on-demand dispatch returns `true` (and some other details are satisfied) the - * `onResponderGrant` deferred dispatched event is returned from - * `extractEvents`. The sequence of dispatch executions in this case - * will appear as follows: - * - * - `startShouldSetResponder` (`ResponderEventPlugin` dispatches on-demand) - * - `touchStartCapture` (`EventPluginHub` dispatches as usual) - * - `touchStart` (`EventPluginHub` dispatches as usual) - * - `responderGrant/Reject` (`EventPluginHub` dispatches as usual) - */ - -function setResponderAndExtractTransfer( - topLevelType, - targetInst, - nativeEvent, - nativeEventTarget, -) { - const shouldSetEventType = isStartish(topLevelType) - ? eventTypes.startShouldSetResponder - : isMoveish(topLevelType) - ? eventTypes.moveShouldSetResponder - : topLevelType === ResponderEventPlugin.TopLevelTypes.topSelectionChange - ? eventTypes.selectionChangeShouldSetResponder - : eventTypes.scrollShouldSetResponder; - - // TODO: stop one short of the current responder. - const bubbleShouldSetFrom = !responderInst - ? targetInst - : getLowestCommonAncestor(responderInst, targetInst); - - // When capturing/bubbling the "shouldSet" event, we want to skip the target - // (deepest ID) if it happens to be the current responder. The reasoning: - // It's strange to get an `onMoveShouldSetResponder` when you're *already* - // the responder. - const skipOverBubbleShouldSetFrom = bubbleShouldSetFrom === responderInst; - const shouldSetEvent = ResponderSyntheticEvent.getPooled( - shouldSetEventType, - bubbleShouldSetFrom, - nativeEvent, - nativeEventTarget, - ); - shouldSetEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; - if (skipOverBubbleShouldSetFrom) { - accumulateTwoPhaseDispatchesSkipTarget(shouldSetEvent); - } else { - accumulateTwoPhaseDispatches(shouldSetEvent); - } - const wantsResponderInst = executeDispatchesInOrderStopAtTrue(shouldSetEvent); - if (!shouldSetEvent.isPersistent()) { - shouldSetEvent.constructor.release(shouldSetEvent); - } - - if (!wantsResponderInst || wantsResponderInst === responderInst) { - return null; - } - let extracted; - const grantEvent = ResponderSyntheticEvent.getPooled( - eventTypes.responderGrant, - wantsResponderInst, - nativeEvent, - nativeEventTarget, - ); - grantEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; - - accumulateDirectDispatches(grantEvent); - const blockHostResponder = executeDirectDispatch(grantEvent) === true; - if (responderInst) { - const terminationRequestEvent = ResponderSyntheticEvent.getPooled( - eventTypes.responderTerminationRequest, - responderInst, - nativeEvent, - nativeEventTarget, - ); - terminationRequestEvent.touchHistory = - ResponderTouchHistoryStore.touchHistory; - accumulateDirectDispatches(terminationRequestEvent); - const shouldSwitch = - !hasDispatches(terminationRequestEvent) || - executeDirectDispatch(terminationRequestEvent); - if (!terminationRequestEvent.isPersistent()) { - terminationRequestEvent.constructor.release(terminationRequestEvent); - } - - if (shouldSwitch) { - const terminateEvent = ResponderSyntheticEvent.getPooled( - eventTypes.responderTerminate, - responderInst, - nativeEvent, - nativeEventTarget, - ); - terminateEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; - accumulateDirectDispatches(terminateEvent); - extracted = accumulate(extracted, [grantEvent, terminateEvent]); - changeResponder(wantsResponderInst, blockHostResponder); - } else { - const rejectEvent = ResponderSyntheticEvent.getPooled( - eventTypes.responderReject, - wantsResponderInst, - nativeEvent, - nativeEventTarget, - ); - rejectEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; - accumulateDirectDispatches(rejectEvent); - extracted = accumulate(extracted, rejectEvent); - } - } else { - extracted = accumulate(extracted, grantEvent); - changeResponder(wantsResponderInst, blockHostResponder); - } - return extracted; -} - -/** - * A transfer is a negotiation between a currently set responder and the next - * element to claim responder status. Any start event could trigger a transfer - * of responderInst. Any move event could trigger a transfer. - * - * @param {number} topLevelType Number from `TopLevelEventTypes`. - * @return {boolean} True if a transfer of responder could possibly occur. - */ -function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) { - return ( - topLevelInst && - // 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 === ResponderEventPlugin.TopLevelTypes.topScroll && - !nativeEvent.responderIgnoreScroll) || - (trackedTouchCount > 0 && - topLevelType === - ResponderEventPlugin.TopLevelTypes.topSelectionChange) || - isStartish(topLevelType) || - isMoveish(topLevelType)) - ); -} - -/** - * Returns whether or not this touch end event makes it such that there are no - * longer any touches that started inside of the current `responderInst`. - * - * @param {NativeEvent} nativeEvent Native touch end event. - * @return {boolean} Whether or not this touch end event ends the responder. - */ -function noResponderTouches(nativeEvent) { - const touches = nativeEvent.touches; - if (!touches || touches.length === 0) { - return true; - } - for (let i = 0; i < touches.length; i++) { - const activeTouch = touches[i]; - const target = activeTouch.target; - if (target !== null && target !== undefined && target !== 0) { - // Is the original touch location inside of the current responder? - const targetInst = getInstanceFromNode(target); - if (isAncestor(responderInst, targetInst)) { - return false; - } - } - } - return true; -} - -const ResponderEventPlugin = { - /* For unit testing only */ - _getResponder: function() { - return responderInst; - }, - - eventTypes: eventTypes, - - /** - * We must be resilient to `targetInst` being `null` on `touchMove` or - * `touchEnd`. On certain platforms, this means that a native scroll has - * assumed control and the original touch targets are destroyed. - */ - extractEvents: function( - topLevelType, - targetInst, - nativeEvent, - nativeEventTarget, - ) { - invariant( - ResponderEventPlugin.TopLevelTypes, - 'ResponderEventPlugin requires TopLevelTypes to be injected first.', - ); - - if (isStartish(topLevelType)) { - trackedTouchCount += 1; - } else if (isEndish(topLevelType)) { - if (trackedTouchCount >= 0) { - trackedTouchCount -= 1; - } else { - console.error( - 'Ended a touch event which was not counted in `trackedTouchCount`.', - ); - return null; - } - } - - ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent); - - let extracted = canTriggerTransfer(topLevelType, targetInst, nativeEvent) - ? setResponderAndExtractTransfer( - topLevelType, - targetInst, - nativeEvent, - nativeEventTarget, - ) - : null; - // Responder may or may not have transferred on a new touch start/move. - // Regardless, whoever is the responder after any potential transfer, we - // direct all touch start/move/ends to them in the form of - // `onResponderMove/Start/End`. These will be called for *every* additional - // finger that move/start/end, dispatched directly to whoever is the - // current responder at that moment, until the responder is "released". - // - // These multiple individual change touch events are are always bookended - // by `onResponderGrant`, and one of - // (`onResponderRelease/onResponderTerminate`). - const isResponderTouchStart = responderInst && isStartish(topLevelType); - const isResponderTouchMove = responderInst && isMoveish(topLevelType); - const isResponderTouchEnd = responderInst && isEndish(topLevelType); - const incrementalTouch = isResponderTouchStart - ? eventTypes.responderStart - : isResponderTouchMove - ? eventTypes.responderMove - : isResponderTouchEnd ? eventTypes.responderEnd : null; - - if (incrementalTouch) { - const gesture = ResponderSyntheticEvent.getPooled( - incrementalTouch, - responderInst, - nativeEvent, - nativeEventTarget, - ); - gesture.touchHistory = ResponderTouchHistoryStore.touchHistory; - accumulateDirectDispatches(gesture); - extracted = accumulate(extracted, gesture); - } - - const isResponderTerminate = - responderInst && - topLevelType === ResponderEventPlugin.TopLevelTypes.topTouchCancel; - const isResponderRelease = - responderInst && - !isResponderTerminate && - isEndish(topLevelType) && - noResponderTouches(nativeEvent); - const finalTouch = isResponderTerminate - ? eventTypes.responderTerminate - : isResponderRelease ? eventTypes.responderRelease : null; - if (finalTouch) { - const finalEvent = ResponderSyntheticEvent.getPooled( - finalTouch, - responderInst, - nativeEvent, - nativeEventTarget, - ); - finalEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; - accumulateDirectDispatches(finalEvent); - extracted = accumulate(extracted, finalEvent); - changeResponder(null); - } - - const numberActiveTouches = - ResponderTouchHistoryStore.touchHistory.numberActiveTouches; - if ( - ResponderEventPlugin.GlobalInteractionHandler && - numberActiveTouches !== previousActiveTouches - ) { - ResponderEventPlugin.GlobalInteractionHandler.onChange( - numberActiveTouches, - ); - } - previousActiveTouches = numberActiveTouches; - - return extracted; - }, - - GlobalResponderHandler: null, - GlobalInteractionHandler: null, - TopLevelTypes: null, - - injection: { - /** - * @param {{onChange: (ReactID, ReactID) => void} GlobalResponderHandler - * Object that handles any change in responder. Use this to inject - * integration with an existing touch handling system etc. - */ - 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; - }, - - /** - * @param Object TopLevelTypes - * Object that maps top level types to the ID used in the react system. - */ - injectTopLevelTypes: function(TopLevelTypes) { - ResponderEventPlugin.TopLevelTypes = TopLevelTypes; - }, - }, -}; - -export default ResponderEventPlugin; diff --git a/packages/events/createResponderEventPlugin.js b/packages/events/createResponderEventPlugin.js new file mode 100644 index 0000000000000..ade65782263a7 --- /dev/null +++ b/packages/events/createResponderEventPlugin.js @@ -0,0 +1,623 @@ +/** + * 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. + */ + +import {getLowestCommonAncestor, isAncestor} from 'shared/ReactTreeTraversal'; +import invariant from 'fbjs/lib/invariant'; + +import { + executeDirectDispatch, + hasDispatches, + executeDispatchesInOrderStopAtTrue, + getInstanceFromNode, +} from './EventPluginUtils'; +import { + accumulateDirectDispatches, + accumulateTwoPhaseDispatches, + accumulateTwoPhaseDispatchesSkipTarget, +} from './EventPropagators'; +import ResponderSyntheticEvent from './ResponderSyntheticEvent'; +import accumulate from './accumulate'; + +/** + * + * Responder System: + * ---------------- + * + * - A global, solitary "interaction lock" on a view. + * - If a node becomes the responder, it should convey visual feedback + * immediately to indicate so, either by highlighting or moving accordingly. + * - To be the responder means, that touches are exclusively important to that + * responder view, and no other view. + * - While touches are still occurring, the responder lock can be transferred to + * a new view, but only to increasingly "higher" views (meaning ancestors of + * the current responder). + * + * Responder being granted: + * ------------------------ + * + * - Touch starts, moves, and scrolls can cause an ID to become the responder. + * - We capture/bubble `startShouldSetResponder`/`moveShouldSetResponder` to + * the "appropriate place". + * - If nothing is currently the responder, the "appropriate place" is the + * initiating event's `targetID`. + * - If something *is* already the responder, the "appropriate place" is the + * first common ancestor of the event target and the current `responderInst`. + * - Some negotiation happens: See the timing diagram below. + * - Scrolled views automatically become responder. The reasoning is that a + * platform scroll view that isn't built on top of the responder system has + * began scrolling, and the active responder must now be notified that the + * interaction is no longer locked to it - the system has taken over. + * + * - Responder being released: + * As soon as no more touches that *started* inside of descendants of the + * *current* responderInst, an `onResponderRelease` event is dispatched to the + * current responder, and the responder lock is released. + * + * TODO: + * - on "end", a callback hook for `onResponderEndShouldRemainResponder` that + * determines if the responder lock should remain. + * - If a view shouldn't "remain" the responder, any active touches should by + * default be considered "dead" and do not influence future negotiations or + * bubble paths. It should be as if those touches do not exist. + * -- For multitouch: Usually a translate-z will choose to "remain" responder + * after one out of many touches ended. For translate-y, usually the view + * doesn't wish to "remain" responder after one of many touches end. + * - Consider building this on top of a `stopPropagation` model similar to + * `W3C` events. + * - Ensure that `onResponderTerminate` is called on touch cancels, whether or + * not `onResponderTerminationRequest` returns `true` or `false`. + * + */ + +/* Negotiation Performed + +-----------------------+ + / \ +Process low level events to + Current Responder + wantsResponderID +determine who to perform negot-| (if any exists at all) | +iation/transition | Otherwise just pass through| +-------------------------------+----------------------------+------------------+ +Bubble to find first ID | | +to return true:wantsResponderID| | + | | + +-------------+ | | + | onTouchStart| | | + +------+------+ none | | + | return| | ++-----------v-------------+true| +------------------------+ | +|onStartShouldSetResponder|----->|onResponderStart (cur) |<-----------+ ++-----------+-------------+ | +------------------------+ | | + | | | +--------+-------+ + | returned true for| false:REJECT +-------->|onResponderReject + | wantsResponderID | | | +----------------+ + | (now attempt | +------------------+-----+ | + | handoff) | | onResponder | | + +------------------->| TerminationRequest| | + | +------------------+-----+ | + | | | +----------------+ + | true:GRANT +-------->|onResponderGrant| + | | +--------+-------+ + | +------------------------+ | | + | | onResponderTerminate |<-----------+ + | +------------------+-----+ | + | | | +----------------+ + | +-------->|onResponderStart| + | | +----------------+ +Bubble to find first ID | | +to return true:wantsResponderID| | + | | + +-------------+ | | + | onTouchMove | | | + +------+------+ none | | + | return| | ++-----------v-------------+true| +------------------------+ | +|onMoveShouldSetResponder |----->|onResponderMove (cur) |<-----------+ ++-----------+-------------+ | +------------------------+ | | + | | | +--------+-------+ + | returned true for| false:REJECT +-------->|onResponderRejec| + | wantsResponderID | | | +----------------+ + | (now attempt | +------------------+-----+ | + | handoff) | | onResponder | | + +------------------->| TerminationRequest| | + | +------------------+-----+ | + | | | +----------------+ + | true:GRANT +-------->|onResponderGrant| + | | +--------+-------+ + | +------------------------+ | | + | | onResponderTerminate |<-----------+ + | +------------------+-----+ | + | | | +----------------+ + | +-------->|onResponderMove | + | | +----------------+ + | | + | | + Some active touch started| | + inside current responder | +------------------------+ | + +------------------------->| onResponderEnd | | + | | +------------------------+ | + +---+---------+ | | + | onTouchEnd | | | + +---+---------+ | | + | | +------------------------+ | + +------------------------->| onResponderEnd | | + No active touches started| +-----------+------------+ | + inside current responder | | | + | v | + | +------------------------+ | + | | onResponderRelease | | + | +------------------------+ | + | | + + + */ + +/** + * A note about event ordering in the `EventPluginHub`. + * + * Suppose plugins are injected in the following order: + * + * `[R, S, C]` + * + * To help illustrate the example, assume `S` is `SimpleEventPlugin` (for + * `onClick` etc) and `R` is `ResponderEventPlugin`. + * + * "Deferred-Dispatched Events": + * + * - The current event plugin system will traverse the list of injected plugins, + * in order, and extract events by collecting the plugin's return value of + * `extractEvents()`. + * - These events that are returned from `extractEvents` are "deferred + * dispatched events". + * - When returned from `extractEvents`, deferred-dispatched events contain an + * "accumulation" of deferred dispatches. + * - These deferred dispatches are accumulated/collected before they are + * returned, but processed at a later time by the `EventPluginHub` (hence the + * name deferred). + * + * In the process of returning their deferred-dispatched events, event plugins + * themselves can dispatch events on-demand without returning them from + * `extractEvents`. Plugins might want to do this, so that they can use event + * dispatching as a tool that helps them decide which events should be extracted + * in the first place. + * + * "On-Demand-Dispatched Events": + * + * - On-demand-dispatched events are not returned from `extractEvents`. + * - On-demand-dispatched events are dispatched during the process of returning + * the deferred-dispatched events. + * - They should not have side effects. + * - They should be avoided, and/or eventually be replaced with another + * abstraction that allows event plugins to perform multiple "rounds" of event + * extraction. + * + * Therefore, the sequence of event dispatches becomes: + * + * - `R`s on-demand events (if any) (dispatched by `R` on-demand) + * - `S`s on-demand events (if any) (dispatched by `S` on-demand) + * - `C`s on-demand events (if any) (dispatched by `C` on-demand) + * - `R`s extracted events (if any) (dispatched by `EventPluginHub`) + * - `S`s extracted events (if any) (dispatched by `EventPluginHub`) + * - `C`s extracted events (if any) (dispatched by `EventPluginHub`) + * + * In the case of `ResponderEventPlugin`: If the `startShouldSetResponder` + * on-demand dispatch returns `true` (and some other details are satisfied) the + * `onResponderGrant` deferred dispatched event is returned from + * `extractEvents`. The sequence of dispatch executions in this case + * will appear as follows: + * + * - `startShouldSetResponder` (`ResponderEventPlugin` dispatches on-demand) + * - `touchStartCapture` (`EventPluginHub` dispatches as usual) + * - `touchStart` (`EventPluginHub` dispatches as usual) + * - `responderGrant/Reject` (`EventPluginHub` dispatches as usual) + */ +export default function createResponderEventPlugin( + TopLevelTypes, + ResponderTouchHistoryStore, +) { + function isStartish(topLevelType) { + return ( + topLevelType === TopLevelTypes.topMouseDown || + topLevelType === TopLevelTypes.topTouchStart + ); + } + + function isMoveish(topLevelType) { + return ( + topLevelType === TopLevelTypes.topMouseMove || + topLevelType === TopLevelTypes.topTouchMove + ); + } + + function isEndish(topLevelType) { + return ( + topLevelType === TopLevelTypes.topMouseUp || + topLevelType === TopLevelTypes.topTouchEnd || + topLevelType === TopLevelTypes.topTouchCancel + ); + } + + /** + * Instance of element that should respond to touch/move types of interactions, + * as indicated explicitly by relevant callbacks. + */ + let responderInst = null; + + /** + * Count of current touches. A textInput should become responder iff the + * selection changes while there is a touch on the screen. + */ + let trackedTouchCount = 0; + + /** + * Last reported number of active touches. + */ + let previousActiveTouches = 0; + + const changeResponder = function(nextResponderInst, blockHostResponder) { + const oldResponderInst = responderInst; + responderInst = nextResponderInst; + if (ResponderEventPlugin.GlobalResponderHandler !== null) { + ResponderEventPlugin.GlobalResponderHandler.onChange( + oldResponderInst, + nextResponderInst, + blockHostResponder, + ); + } + }; + + const eventTypes = { + /** + * On a `touchStart`/`mouseDown`, is it desired that this element become the + * responder? + */ + startShouldSetResponder: { + phasedRegistrationNames: { + bubbled: 'onStartShouldSetResponder', + captured: 'onStartShouldSetResponderCapture', + }, + }, + + /** + * On a `scroll`, is it desired that this element become the responder? This + * is usually not needed, but should be used to retroactively infer that a + * `touchStart` had occurred during momentum scroll. During a momentum scroll, + * a touch start will be immediately followed by a scroll event if the view is + * currently scrolling. + * + * TODO: This shouldn't bubble. + */ + scrollShouldSetResponder: { + phasedRegistrationNames: { + bubbled: 'onScrollShouldSetResponder', + captured: 'onScrollShouldSetResponderCapture', + }, + }, + + /** + * On text selection change, should this element become the responder? This + * is needed for text inputs or other views with native selection, so the + * JS view can claim the responder. + * + * TODO: This shouldn't bubble. + */ + selectionChangeShouldSetResponder: { + phasedRegistrationNames: { + bubbled: 'onSelectionChangeShouldSetResponder', + captured: 'onSelectionChangeShouldSetResponderCapture', + }, + }, + + /** + * On a `touchMove`/`mouseMove`, is it desired that this element become the + * responder? + */ + moveShouldSetResponder: { + phasedRegistrationNames: { + bubbled: 'onMoveShouldSetResponder', + captured: 'onMoveShouldSetResponderCapture', + }, + }, + + /** + * 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', + }, + responderGrant: {registrationName: 'onResponderGrant'}, + responderReject: {registrationName: 'onResponderReject'}, + responderTerminate: {registrationName: 'onResponderTerminate'}, + }; + + function setResponderAndExtractTransfer( + topLevelType, + targetInst, + nativeEvent, + nativeEventTarget, + ) { + const shouldSetEventType = isStartish(topLevelType) + ? eventTypes.startShouldSetResponder + : isMoveish(topLevelType) + ? eventTypes.moveShouldSetResponder + : topLevelType === TopLevelTypes.topSelectionChange + ? eventTypes.selectionChangeShouldSetResponder + : eventTypes.scrollShouldSetResponder; + + // TODO: stop one short of the current responder. + const bubbleShouldSetFrom = !responderInst + ? targetInst + : getLowestCommonAncestor(responderInst, targetInst); + + // When capturing/bubbling the "shouldSet" event, we want to skip the target + // (deepest ID) if it happens to be the current responder. The reasoning: + // It's strange to get an `onMoveShouldSetResponder` when you're *already* + // the responder. + const skipOverBubbleShouldSetFrom = bubbleShouldSetFrom === responderInst; + const shouldSetEvent = ResponderSyntheticEvent.getPooled( + shouldSetEventType, + bubbleShouldSetFrom, + nativeEvent, + nativeEventTarget, + ); + shouldSetEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; + if (skipOverBubbleShouldSetFrom) { + accumulateTwoPhaseDispatchesSkipTarget(shouldSetEvent); + } else { + accumulateTwoPhaseDispatches(shouldSetEvent); + } + const wantsResponderInst = executeDispatchesInOrderStopAtTrue( + shouldSetEvent, + ); + if (!shouldSetEvent.isPersistent()) { + shouldSetEvent.constructor.release(shouldSetEvent); + } + + if (!wantsResponderInst || wantsResponderInst === responderInst) { + return null; + } + let extracted; + const grantEvent = ResponderSyntheticEvent.getPooled( + eventTypes.responderGrant, + wantsResponderInst, + nativeEvent, + nativeEventTarget, + ); + grantEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; + + accumulateDirectDispatches(grantEvent); + const blockHostResponder = executeDirectDispatch(grantEvent) === true; + if (responderInst) { + const terminationRequestEvent = ResponderSyntheticEvent.getPooled( + eventTypes.responderTerminationRequest, + responderInst, + nativeEvent, + nativeEventTarget, + ); + terminationRequestEvent.touchHistory = + ResponderTouchHistoryStore.touchHistory; + accumulateDirectDispatches(terminationRequestEvent); + const shouldSwitch = + !hasDispatches(terminationRequestEvent) || + executeDirectDispatch(terminationRequestEvent); + if (!terminationRequestEvent.isPersistent()) { + terminationRequestEvent.constructor.release(terminationRequestEvent); + } + + if (shouldSwitch) { + const terminateEvent = ResponderSyntheticEvent.getPooled( + eventTypes.responderTerminate, + responderInst, + nativeEvent, + nativeEventTarget, + ); + terminateEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; + accumulateDirectDispatches(terminateEvent); + extracted = accumulate(extracted, [grantEvent, terminateEvent]); + changeResponder(wantsResponderInst, blockHostResponder); + } else { + const rejectEvent = ResponderSyntheticEvent.getPooled( + eventTypes.responderReject, + wantsResponderInst, + nativeEvent, + nativeEventTarget, + ); + rejectEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; + accumulateDirectDispatches(rejectEvent); + extracted = accumulate(extracted, rejectEvent); + } + } else { + extracted = accumulate(extracted, grantEvent); + changeResponder(wantsResponderInst, blockHostResponder); + } + return extracted; + } + + /** + * A transfer is a negotiation between a currently set responder and the next + * element to claim responder status. Any start event could trigger a transfer + * of responderInst. Any move event could trigger a transfer. + * + * @param {number} topLevelType Number from `TopLevelEventTypes`. + * @return {boolean} True if a transfer of responder could possibly occur. + */ + function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) { + return ( + topLevelInst && + // 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 === TopLevelTypes.topScroll && + !nativeEvent.responderIgnoreScroll) || + (trackedTouchCount > 0 && + topLevelType === TopLevelTypes.topSelectionChange) || + isStartish(topLevelType) || + isMoveish(topLevelType)) + ); + } + + /** + * Returns whether or not this touch end event makes it such that there are no + * longer any touches that started inside of the current `responderInst`. + * + * @param {NativeEvent} nativeEvent Native touch end event. + * @return {boolean} Whether or not this touch end event ends the responder. + */ + function noResponderTouches(nativeEvent) { + const touches = nativeEvent.touches; + if (!touches || touches.length === 0) { + return true; + } + for (let i = 0; i < touches.length; i++) { + const activeTouch = touches[i]; + const target = activeTouch.target; + if (target !== null && target !== undefined && target !== 0) { + // Is the original touch location inside of the current responder? + const targetInst = getInstanceFromNode(target); + if (isAncestor(responderInst, targetInst)) { + return false; + } + } + } + return true; + } + + const ResponderEventPlugin = { + /* For unit testing only */ + _getResponder: function() { + return responderInst; + }, + + eventTypes: eventTypes, + + /** + * We must be resilient to `targetInst` being `null` on `touchMove` or + * `touchEnd`. On certain platforms, this means that a native scroll has + * assumed control and the original touch targets are destroyed. + */ + extractEvents: function( + topLevelType, + targetInst, + nativeEvent, + nativeEventTarget, + ) { + if (isStartish(topLevelType)) { + trackedTouchCount += 1; + } else if (isEndish(topLevelType)) { + if (trackedTouchCount >= 0) { + trackedTouchCount -= 1; + } else { + console.error( + 'Ended a touch event which was not counted in `trackedTouchCount`.', + ); + return null; + } + } + + ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent); + + let extracted = canTriggerTransfer(topLevelType, targetInst, nativeEvent) + ? setResponderAndExtractTransfer( + topLevelType, + targetInst, + nativeEvent, + nativeEventTarget, + ) + : null; + // Responder may or may not have transferred on a new touch start/move. + // Regardless, whoever is the responder after any potential transfer, we + // direct all touch start/move/ends to them in the form of + // `onResponderMove/Start/End`. These will be called for *every* additional + // finger that move/start/end, dispatched directly to whoever is the + // current responder at that moment, until the responder is "released". + // + // These multiple individual change touch events are are always bookended + // by `onResponderGrant`, and one of + // (`onResponderRelease/onResponderTerminate`). + const isResponderTouchStart = responderInst && isStartish(topLevelType); + const isResponderTouchMove = responderInst && isMoveish(topLevelType); + const isResponderTouchEnd = responderInst && isEndish(topLevelType); + const incrementalTouch = isResponderTouchStart + ? eventTypes.responderStart + : isResponderTouchMove + ? eventTypes.responderMove + : isResponderTouchEnd ? eventTypes.responderEnd : null; + + if (incrementalTouch) { + const gesture = ResponderSyntheticEvent.getPooled( + incrementalTouch, + responderInst, + nativeEvent, + nativeEventTarget, + ); + gesture.touchHistory = ResponderTouchHistoryStore.touchHistory; + accumulateDirectDispatches(gesture); + extracted = accumulate(extracted, gesture); + } + + const isResponderTerminate = + responderInst && topLevelType === TopLevelTypes.topTouchCancel; + const isResponderRelease = + responderInst && + !isResponderTerminate && + isEndish(topLevelType) && + noResponderTouches(nativeEvent); + const finalTouch = isResponderTerminate + ? eventTypes.responderTerminate + : isResponderRelease ? eventTypes.responderRelease : null; + if (finalTouch) { + const finalEvent = ResponderSyntheticEvent.getPooled( + finalTouch, + responderInst, + nativeEvent, + nativeEventTarget, + ); + finalEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; + accumulateDirectDispatches(finalEvent); + extracted = accumulate(extracted, finalEvent); + changeResponder(null); + } + + const numberActiveTouches = + ResponderTouchHistoryStore.touchHistory.numberActiveTouches; + if ( + ResponderEventPlugin.GlobalInteractionHandler && + numberActiveTouches !== previousActiveTouches + ) { + ResponderEventPlugin.GlobalInteractionHandler.onChange( + numberActiveTouches, + ); + } + previousActiveTouches = numberActiveTouches; + + return extracted; + }, + + GlobalResponderHandler: null, + GlobalInteractionHandler: null, + + injection: { + /** + * @param {{onChange: (ReactID, ReactID) => void} GlobalResponderHandler + * Object that handles any change in responder. Use this to inject + * integration with an existing touch handling system etc. + */ + 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; + }, + }, + }; + return ResponderEventPlugin; +} diff --git a/packages/events/ResponderTouchHistoryStore.js b/packages/events/createResponderTouchHistoryStore.js similarity index 70% rename from packages/events/ResponderTouchHistoryStore.js rename to packages/events/createResponderTouchHistoryStore.js index a930da4fb2367..c6922479cdf4d 100644 --- a/packages/events/ResponderTouchHistoryStore.js +++ b/packages/events/createResponderTouchHistoryStore.js @@ -176,69 +176,80 @@ function printTouchBank(): string { return printed; } -type EventUtils = { - isStartish: (topLevelType: TopLevelType) => boolean, - isMoveish: (topLevelType: TopLevelType) => boolean, - isEndish: (topLevelType: TopLevelType) => boolean, +type RequiredTopLevelTypes = { + topMouseDown: TopLevelType, + topTouchStart: TopLevelType, + topMouseMove: TopLevelType, + topTouchMove: TopLevelType, + topMouseUp: TopLevelType, + topTouchEnd: TopLevelType, + topTouchCancel: TopLevelType, }; -const ResponderTouchHistoryStore = { - recordTouchTrack(topLevelType: TopLevelType, nativeEvent: TouchEvent): void { - invariant( - ResponderTouchHistoryStore.EventUtils, - 'ResponderTouchHistoryStore requires EventUtils to be injected first.', +export default function createResponderTouchHistoryStore( + TopLevelTypes: RequiredTopLevelTypes, +) { + function isStartish(topLevelType) { + return ( + topLevelType === TopLevelTypes.topMouseDown || + topLevelType === TopLevelTypes.topTouchStart ); - const { - isStartish, - isMoveish, - isEndish, - } = ResponderTouchHistoryStore.EventUtils; - - if (isMoveish(topLevelType)) { - nativeEvent.changedTouches.forEach(recordTouchMove); - } else if (isStartish(topLevelType)) { - nativeEvent.changedTouches.forEach(recordTouchStart); - touchHistory.numberActiveTouches = nativeEvent.touches.length; - if (touchHistory.numberActiveTouches === 1) { - touchHistory.indexOfSingleActiveTouch = - nativeEvent.touches[0].identifier; - } - } else if (isEndish(topLevelType)) { - nativeEvent.changedTouches.forEach(recordTouchEnd); - touchHistory.numberActiveTouches = nativeEvent.touches.length; - if (touchHistory.numberActiveTouches === 1) { - for (let i = 0; i < touchBank.length; i++) { - const touchTrackToCheck = touchBank[i]; - if (touchTrackToCheck != null && touchTrackToCheck.touchActive) { - touchHistory.indexOfSingleActiveTouch = i; - break; - } - } - if (__DEV__) { - const activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch]; - warning( - activeRecord != null && activeRecord.touchActive, - 'Cannot find single active touch.', - ); - } - } - } - }, + } - touchHistory, + function isMoveish(topLevelType) { + return ( + topLevelType === TopLevelTypes.topMouseMove || + topLevelType === TopLevelTypes.topTouchMove + ); + } - EventUtils: (null: ?EventUtils), + function isEndish(topLevelType) { + return ( + topLevelType === TopLevelTypes.topMouseUp || + topLevelType === TopLevelTypes.topTouchEnd || + topLevelType === TopLevelTypes.topTouchCancel + ); + } - injection: { - /** - * @param {isMoveish: Function, isStartish: Function, isEndish: Function} GlobalResponderHandler - * Object that handles any change in responder. Use this to inject - * integration with an existing touch handling system etc. - */ - injectEventUtils: function(_EventUtils: EventUtils) { - ResponderTouchHistoryStore.EventUtils = _EventUtils; + const ResponderTouchHistoryStore = { + recordTouchTrack( + topLevelType: TopLevelType, + nativeEvent: TouchEvent, + ): void { + if (isMoveish(topLevelType)) { + nativeEvent.changedTouches.forEach(recordTouchMove); + } else if (isStartish(topLevelType)) { + nativeEvent.changedTouches.forEach(recordTouchStart); + touchHistory.numberActiveTouches = nativeEvent.touches.length; + if (touchHistory.numberActiveTouches === 1) { + touchHistory.indexOfSingleActiveTouch = + nativeEvent.touches[0].identifier; + } + } else if (isEndish(topLevelType)) { + nativeEvent.changedTouches.forEach(recordTouchEnd); + touchHistory.numberActiveTouches = nativeEvent.touches.length; + if (touchHistory.numberActiveTouches === 1) { + for (let i = 0; i < touchBank.length; i++) { + const touchTrackToCheck = touchBank[i]; + if (touchTrackToCheck != null && touchTrackToCheck.touchActive) { + touchHistory.indexOfSingleActiveTouch = i; + break; + } + } + if (__DEV__) { + const activeRecord = + touchBank[touchHistory.indexOfSingleActiveTouch]; + warning( + activeRecord != null && activeRecord.touchActive, + 'Cannot find single active touch.', + ); + } + } + } }, - }, -}; -export default ResponderTouchHistoryStore; + touchHistory, + }; + + return ResponderTouchHistoryStore; +} diff --git a/packages/react-dom/src/events/DOMResponderEventPlugin.js b/packages/react-dom/src/events/DOMResponderEventPlugin.js index e665616d474d6..9f40e7d2ee357 100644 --- a/packages/react-dom/src/events/DOMResponderEventPlugin.js +++ b/packages/react-dom/src/events/DOMResponderEventPlugin.js @@ -5,7 +5,8 @@ * LICENSE file in the root directory of this source tree. */ -import ResponderEventPlugin from 'events/ResponderEventPlugin'; +import createResponderTouchHistoryStore from 'events/createResponderTouchHistoryStore'; +import createResponderEventPlugin from 'events/createResponderEventPlugin'; import { TOP_MOUSE_DOWN, @@ -19,28 +20,7 @@ import { TOP_TOUCH_START, } from './DOMTopLevelEventTypes'; -const endDependencies = [TOP_TOUCH_CANCEL, TOP_TOUCH_END, TOP_MOUSE_UP]; -const moveDependencies = [TOP_TOUCH_MOVE, TOP_MOUSE_MOVE]; -const startDependencies = [TOP_TOUCH_START, TOP_MOUSE_DOWN]; - -ResponderEventPlugin.eventTypes.responderMove.dependencies = moveDependencies; -ResponderEventPlugin.eventTypes.responderEnd.dependencies = endDependencies; -ResponderEventPlugin.eventTypes.responderStart.dependencies = startDependencies; -ResponderEventPlugin.eventTypes.responderRelease.dependencies = endDependencies; -ResponderEventPlugin.eventTypes.responderTerminationRequest.dependencies = []; -ResponderEventPlugin.eventTypes.responderGrant.dependencies = []; -ResponderEventPlugin.eventTypes.responderReject.dependencies = []; -ResponderEventPlugin.eventTypes.responderTerminate.dependencies = []; -ResponderEventPlugin.eventTypes.moveShouldSetResponder.dependencies = moveDependencies; -ResponderEventPlugin.eventTypes.selectionChangeShouldSetResponder.dependencies = [ - TOP_SELECTION_CHANGE, -]; -ResponderEventPlugin.eventTypes.scrollShouldSetResponder.dependencies = [ - TOP_SCROLL, -]; -ResponderEventPlugin.eventTypes.startShouldSetResponder.dependencies = startDependencies; - -ResponderEventPlugin.injection.injectTopLevelTypes({ +const TopLevelTypes = { topMouseDown: TOP_MOUSE_DOWN, topMouseMove: TOP_MOUSE_MOVE, topMouseUp: TOP_MOUSE_UP, @@ -50,6 +30,35 @@ ResponderEventPlugin.injection.injectTopLevelTypes({ topTouchEnd: TOP_TOUCH_END, topTouchMove: TOP_TOUCH_MOVE, topTouchStart: TOP_TOUCH_START, -}); +}; + +export const ResponderTouchHistoryStore = createResponderTouchHistoryStore( + TopLevelTypes, +); +const DOMResponderEventPlugin = createResponderEventPlugin( + TopLevelTypes, + ResponderTouchHistoryStore, +); + +const endDependencies = [TOP_TOUCH_CANCEL, TOP_TOUCH_END, TOP_MOUSE_UP]; +const moveDependencies = [TOP_TOUCH_MOVE, TOP_MOUSE_MOVE]; +const startDependencies = [TOP_TOUCH_START, TOP_MOUSE_DOWN]; + +DOMResponderEventPlugin.eventTypes.responderMove.dependencies = moveDependencies; +DOMResponderEventPlugin.eventTypes.responderEnd.dependencies = endDependencies; +DOMResponderEventPlugin.eventTypes.responderStart.dependencies = startDependencies; +DOMResponderEventPlugin.eventTypes.responderRelease.dependencies = endDependencies; +DOMResponderEventPlugin.eventTypes.responderTerminationRequest.dependencies = []; +DOMResponderEventPlugin.eventTypes.responderGrant.dependencies = []; +DOMResponderEventPlugin.eventTypes.responderReject.dependencies = []; +DOMResponderEventPlugin.eventTypes.responderTerminate.dependencies = []; +DOMResponderEventPlugin.eventTypes.moveShouldSetResponder.dependencies = moveDependencies; +DOMResponderEventPlugin.eventTypes.selectionChangeShouldSetResponder.dependencies = [ + TOP_SELECTION_CHANGE, +]; +DOMResponderEventPlugin.eventTypes.scrollShouldSetResponder.dependencies = [ + TOP_SCROLL, +]; +DOMResponderEventPlugin.eventTypes.startShouldSetResponder.dependencies = startDependencies; -export default ResponderEventPlugin; +export default DOMResponderEventPlugin; diff --git a/packages/react-dom/src/unstable-native-dependencies/ReactDOMUnstableNativeDependencies.js b/packages/react-dom/src/unstable-native-dependencies/ReactDOMUnstableNativeDependencies.js index a332519539a79..fd23b7e92578a 100644 --- a/packages/react-dom/src/unstable-native-dependencies/ReactDOMUnstableNativeDependencies.js +++ b/packages/react-dom/src/unstable-native-dependencies/ReactDOMUnstableNativeDependencies.js @@ -7,9 +7,10 @@ import ReactDOM from 'react-dom'; import * as EventPluginUtils from 'events/EventPluginUtils'; -import ResponderTouchHistoryStore from 'events/ResponderTouchHistoryStore'; -import DOMResponderEventPlugin from '../events/DOMResponderEventPlugin'; +import DOMResponderEventPlugin, { + ResponderTouchHistoryStore, +} from '../events/DOMResponderEventPlugin'; // This is used by react-native-web. export const injectComponentTree = diff --git a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js index 52b05f8a085b8..d826ccc842406 100644 --- a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js +++ b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js @@ -5,9 +5,10 @@ * LICENSE file in the root directory of this source tree. */ -import ResponderEventPlugin from 'events/ResponderEventPlugin'; +import createResponderTouchHistoryStore from 'events/createResponderTouchHistoryStore'; +import createResponderEventPlugin from 'events/createResponderEventPlugin'; -ResponderEventPlugin.injection.injectTopLevelTypes({ +const TopLevelTypes = { topMouseDown: 'topMouseDown', topMouseMove: 'topMouseMove', topMouseUp: 'topMouseUp', @@ -17,6 +18,14 @@ ResponderEventPlugin.injection.injectTopLevelTypes({ topTouchEnd: 'topTouchEnd', topTouchMove: 'topTouchMove', topTouchStart: 'topTouchStart', -}); +}; -export default ResponderEventPlugin; +const ResponderTouchHistoryStore = createResponderTouchHistoryStore( + TopLevelTypes, +); +const DOMResponderEventPlugin = createResponderEventPlugin( + TopLevelTypes, + ResponderTouchHistoryStore, +); + +export default DOMResponderEventPlugin; diff --git a/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js b/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js index 07fbe1692aa6a..05e3a34d81152 100644 --- a/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js +++ b/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js @@ -14,7 +14,7 @@ let PropTypes; let RCTEventEmitter; let React; let ReactNative; -let ResponderEventPlugin; +let ReactNativeResponderEventPlugin; let UIManager; let createReactNativeComponentClass; @@ -67,7 +67,8 @@ beforeEach(() => { RCTEventEmitter = require('RCTEventEmitter'); React = require('react'); ReactNative = require('react-native-renderer'); - ResponderEventPlugin = require('events/ResponderEventPlugin').default; + ReactNativeResponderEventPlugin = require('../ReactNativeResponderEventPlugin') + .default; UIManager = require('UIManager'); createReactNativeComponentClass = require('ReactNativeViewConfigRegistry') .register; @@ -244,7 +245,7 @@ it('handles when a responder is unmounted while a touch sequence is in progress' } function getResponderId() { - const responder = ResponderEventPlugin._getResponder(); + const responder = ReactNativeResponderEventPlugin._getResponder(); if (responder === null) { return null; } @@ -334,7 +335,7 @@ it('handles events without target', () => { } function getResponderId() { - const responder = ResponderEventPlugin._getResponder(); + const responder = ReactNativeResponderEventPlugin._getResponder(); if (responder === null) { return null; } From 0ace5a1eafebe7ae11b9359e3889ccdb33895fba Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Sat, 21 Apr 2018 16:16:49 +0200 Subject: [PATCH 25/45] Remove unused dependency --- packages/events/createResponderEventPlugin.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/events/createResponderEventPlugin.js b/packages/events/createResponderEventPlugin.js index ade65782263a7..d57cbd38ca2d6 100644 --- a/packages/events/createResponderEventPlugin.js +++ b/packages/events/createResponderEventPlugin.js @@ -6,7 +6,6 @@ */ import {getLowestCommonAncestor, isAncestor} from 'shared/ReactTreeTraversal'; -import invariant from 'fbjs/lib/invariant'; import { executeDirectDispatch, From 653492c3cd27a103133642fae2ce7078fab7c75f Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Mon, 23 Apr 2018 18:38:38 +0200 Subject: [PATCH 26/45] Revert exposed module renaming, hide store creation, and inline dependency decleration --- .../ResponderEventPlugin-test.internal.js | 2 +- packages/events/createResponderEventPlugin.js | 61 +++++++++++++++---- .../createResponderTouchHistoryStore.js | 36 +---------- .../src/events/DOMEventPluginOrder.js | 4 +- .../src/events/DOMResponderEventPlugin.js | 34 ++--------- .../ReactDOMUnstableNativeDependencies.js | 4 +- .../src/ReactNativeEventPluginOrder.js | 2 +- .../src/ReactNativeInjectionShared.js | 2 +- .../src/ReactNativeResponderEventPlugin.js | 11 +--- 9 files changed, 67 insertions(+), 89 deletions(-) diff --git a/packages/events/__tests__/ResponderEventPlugin-test.internal.js b/packages/events/__tests__/ResponderEventPlugin-test.internal.js index aa8c00c349684..6afce41635c47 100644 --- a/packages/events/__tests__/ResponderEventPlugin-test.internal.js +++ b/packages/events/__tests__/ResponderEventPlugin-test.internal.js @@ -412,7 +412,7 @@ describe('ResponderEventPlugin', () => { const injectComponentTree = ReactDOMUnstableNativeDependencies.injectComponentTree; ResponderEventPlugin = - ReactDOMUnstableNativeDependencies.DOMResponderEventPlugin; + ReactDOMUnstableNativeDependencies.ResponderEventPlugin; deleteAllListeners(GRANDPARENT_INST); deleteAllListeners(PARENT_INST); diff --git a/packages/events/createResponderEventPlugin.js b/packages/events/createResponderEventPlugin.js index d57cbd38ca2d6..116e348a7dfcd 100644 --- a/packages/events/createResponderEventPlugin.js +++ b/packages/events/createResponderEventPlugin.js @@ -20,6 +20,7 @@ import { } from './EventPropagators'; import ResponderSyntheticEvent from './ResponderSyntheticEvent'; import accumulate from './accumulate'; +import createResponderTouchHistoryStore from './createResponderTouchHistoryStore'; /** * @@ -210,10 +211,7 @@ to return true:wantsResponderID| | * - `touchStart` (`EventPluginHub` dispatches as usual) * - `responderGrant/Reject` (`EventPluginHub` dispatches as usual) */ -export default function createResponderEventPlugin( - TopLevelTypes, - ResponderTouchHistoryStore, -) { +export default function createResponderEventPlugin(TopLevelTypes) { function isStartish(topLevelType) { return ( topLevelType === TopLevelTypes.topMouseDown || @@ -236,6 +234,12 @@ export default function createResponderEventPlugin( ); } + const ResponderTouchHistoryStore = createResponderTouchHistoryStore( + isStartish, + isMoveish, + isEndish, + ); + /** * Instance of element that should respond to touch/move types of interactions, * as indicated explicitly by relevant callbacks. @@ -265,6 +269,20 @@ export default function createResponderEventPlugin( } }; + const startDependencies = [ + TopLevelTypes.TOP_TOUCH_START, + TopLevelTypes.TOP_MOUSE_DOWN, + ]; + const moveDependencies = [ + TopLevelTypes.TOP_TOUCH_MOVE, + TopLevelTypes.TOP_MOUSE_MOVE, + ]; + const endDependencies = [ + TopLevelTypes.TOP_TOUCH_CANCEL, + TopLevelTypes.TOP_TOUCH_END, + TopLevelTypes.TOP_MOUSE_UP, + ]; + const eventTypes = { /** * On a `touchStart`/`mouseDown`, is it desired that this element become the @@ -275,6 +293,7 @@ export default function createResponderEventPlugin( bubbled: 'onStartShouldSetResponder', captured: 'onStartShouldSetResponderCapture', }, + dependencies: startDependencies, }, /** @@ -291,6 +310,7 @@ export default function createResponderEventPlugin( bubbled: 'onScrollShouldSetResponder', captured: 'onScrollShouldSetResponderCapture', }, + dependencies: [TopLevelTypes.TOP_SCROLL], }, /** @@ -305,6 +325,7 @@ export default function createResponderEventPlugin( bubbled: 'onSelectionChangeShouldSetResponder', captured: 'onSelectionChangeShouldSetResponderCapture', }, + dependencies: [TopLevelTypes.TOP_SELECTION_CHANGE], }, /** @@ -316,21 +337,35 @@ export default function createResponderEventPlugin( 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'}, + responderStart: { + registrationName: 'onResponderStart', + dependencies: startDependencies, + }, + responderMove: { + registrationName: 'onResponderMove', + dependencies: moveDependencies, + }, + responderEnd: { + registrationName: 'onResponderEnd', + dependencies: endDependencies, + }, responderRelease: {registrationName: 'onResponderRelease'}, responderTerminationRequest: { registrationName: 'onResponderTerminationRequest', + dependencies: [], + }, + responderGrant: {registrationName: 'onResponderGrant', dependencies: []}, + responderReject: {registrationName: 'onResponderReject', dependencies: []}, + responderTerminate: { + registrationName: 'onResponderTerminate', + dependencies: [], }, - responderGrant: {registrationName: 'onResponderGrant'}, - responderReject: {registrationName: 'onResponderReject'}, - responderTerminate: {registrationName: 'onResponderTerminate'}, }; function setResponderAndExtractTransfer( @@ -618,5 +653,9 @@ export default function createResponderEventPlugin( }, }, }; - return ResponderEventPlugin; + + return { + ResponderEventPlugin, + ResponderTouchHistoryStore, + }; } diff --git a/packages/events/createResponderTouchHistoryStore.js b/packages/events/createResponderTouchHistoryStore.js index c6922479cdf4d..442a0d4ac0a15 100644 --- a/packages/events/createResponderTouchHistoryStore.js +++ b/packages/events/createResponderTouchHistoryStore.js @@ -176,41 +176,11 @@ function printTouchBank(): string { return printed; } -type RequiredTopLevelTypes = { - topMouseDown: TopLevelType, - topTouchStart: TopLevelType, - topMouseMove: TopLevelType, - topTouchMove: TopLevelType, - topMouseUp: TopLevelType, - topTouchEnd: TopLevelType, - topTouchCancel: TopLevelType, -}; - export default function createResponderTouchHistoryStore( - TopLevelTypes: RequiredTopLevelTypes, + isStartish: (topLevelType: TopLevelType) => boolean, + isMoveish: (topLevelType: TopLevelType) => boolean, + isEndish: (topLevelType: TopLevelType) => boolean, ) { - function isStartish(topLevelType) { - return ( - topLevelType === TopLevelTypes.topMouseDown || - topLevelType === TopLevelTypes.topTouchStart - ); - } - - function isMoveish(topLevelType) { - return ( - topLevelType === TopLevelTypes.topMouseMove || - topLevelType === TopLevelTypes.topTouchMove - ); - } - - function isEndish(topLevelType) { - return ( - topLevelType === TopLevelTypes.topMouseUp || - topLevelType === TopLevelTypes.topTouchEnd || - topLevelType === TopLevelTypes.topTouchCancel - ); - } - const ResponderTouchHistoryStore = { recordTouchTrack( topLevelType: TopLevelType, diff --git a/packages/react-dom/src/events/DOMEventPluginOrder.js b/packages/react-dom/src/events/DOMEventPluginOrder.js index e6eefb6859486..0896938b97831 100644 --- a/packages/react-dom/src/events/DOMEventPluginOrder.js +++ b/packages/react-dom/src/events/DOMEventPluginOrder.js @@ -11,11 +11,11 @@ * plugins, without having to package every one of them. This is better than * having plugins be ordered in the same order that they are injected because * that ordering would be influenced by the packaging order. - * `DOMResponderEventPlugin` must occur before `SimpleEventPlugin` so that + * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that * preventing default on events is convenient in `SimpleEventPlugin` handlers. */ const DOMEventPluginOrder = [ - 'DOMResponderEventPlugin', + 'ResponderEventPlugin', 'SimpleEventPlugin', 'TapEventPlugin', 'EnterLeaveEventPlugin', diff --git a/packages/react-dom/src/events/DOMResponderEventPlugin.js b/packages/react-dom/src/events/DOMResponderEventPlugin.js index 9f40e7d2ee357..96de77dc0ec6a 100644 --- a/packages/react-dom/src/events/DOMResponderEventPlugin.js +++ b/packages/react-dom/src/events/DOMResponderEventPlugin.js @@ -5,7 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -import createResponderTouchHistoryStore from 'events/createResponderTouchHistoryStore'; import createResponderEventPlugin from 'events/createResponderEventPlugin'; import { @@ -32,33 +31,10 @@ const TopLevelTypes = { topTouchStart: TOP_TOUCH_START, }; -export const ResponderTouchHistoryStore = createResponderTouchHistoryStore( - TopLevelTypes, -); -const DOMResponderEventPlugin = createResponderEventPlugin( - TopLevelTypes, +const { + ResponderEventPlugin, ResponderTouchHistoryStore, -); +} = createResponderEventPlugin(TopLevelTypes); -const endDependencies = [TOP_TOUCH_CANCEL, TOP_TOUCH_END, TOP_MOUSE_UP]; -const moveDependencies = [TOP_TOUCH_MOVE, TOP_MOUSE_MOVE]; -const startDependencies = [TOP_TOUCH_START, TOP_MOUSE_DOWN]; - -DOMResponderEventPlugin.eventTypes.responderMove.dependencies = moveDependencies; -DOMResponderEventPlugin.eventTypes.responderEnd.dependencies = endDependencies; -DOMResponderEventPlugin.eventTypes.responderStart.dependencies = startDependencies; -DOMResponderEventPlugin.eventTypes.responderRelease.dependencies = endDependencies; -DOMResponderEventPlugin.eventTypes.responderTerminationRequest.dependencies = []; -DOMResponderEventPlugin.eventTypes.responderGrant.dependencies = []; -DOMResponderEventPlugin.eventTypes.responderReject.dependencies = []; -DOMResponderEventPlugin.eventTypes.responderTerminate.dependencies = []; -DOMResponderEventPlugin.eventTypes.moveShouldSetResponder.dependencies = moveDependencies; -DOMResponderEventPlugin.eventTypes.selectionChangeShouldSetResponder.dependencies = [ - TOP_SELECTION_CHANGE, -]; -DOMResponderEventPlugin.eventTypes.scrollShouldSetResponder.dependencies = [ - TOP_SCROLL, -]; -DOMResponderEventPlugin.eventTypes.startShouldSetResponder.dependencies = startDependencies; - -export default DOMResponderEventPlugin; +export default ResponderEventPlugin; +export {ResponderTouchHistoryStore}; diff --git a/packages/react-dom/src/unstable-native-dependencies/ReactDOMUnstableNativeDependencies.js b/packages/react-dom/src/unstable-native-dependencies/ReactDOMUnstableNativeDependencies.js index fd23b7e92578a..2d637f3697f61 100644 --- a/packages/react-dom/src/unstable-native-dependencies/ReactDOMUnstableNativeDependencies.js +++ b/packages/react-dom/src/unstable-native-dependencies/ReactDOMUnstableNativeDependencies.js @@ -8,14 +8,14 @@ import ReactDOM from 'react-dom'; import * as EventPluginUtils from 'events/EventPluginUtils'; -import DOMResponderEventPlugin, { +import ResponderEventPlugin, { ResponderTouchHistoryStore, } from '../events/DOMResponderEventPlugin'; // This is used by react-native-web. export const injectComponentTree = EventPluginUtils.injection.injectComponentTree; -export {DOMResponderEventPlugin, ResponderTouchHistoryStore}; +export {ResponderEventPlugin, ResponderTouchHistoryStore}; // Inject react-dom's ComponentTree into this module. const { diff --git a/packages/react-native-renderer/src/ReactNativeEventPluginOrder.js b/packages/react-native-renderer/src/ReactNativeEventPluginOrder.js index 68b91bf2c378e..de6029b20c649 100644 --- a/packages/react-native-renderer/src/ReactNativeEventPluginOrder.js +++ b/packages/react-native-renderer/src/ReactNativeEventPluginOrder.js @@ -8,7 +8,7 @@ */ const ReactNativeEventPluginOrder = [ - 'ReactNativeResponderEventPlugin', + 'ResponderEventPlugin', 'ReactNativeBridgeEventPlugin', ]; diff --git a/packages/react-native-renderer/src/ReactNativeInjectionShared.js b/packages/react-native-renderer/src/ReactNativeInjectionShared.js index 78c93d410d54e..d9766488339ef 100644 --- a/packages/react-native-renderer/src/ReactNativeInjectionShared.js +++ b/packages/react-native-renderer/src/ReactNativeInjectionShared.js @@ -40,6 +40,6 @@ ReactNativeResponderEventPlugin.injection.injectGlobalResponderHandler( * them). */ EventPluginHub.injection.injectEventPluginsByName({ - ReactNativeResponderEventPlugin: ReactNativeResponderEventPlugin, + ResponderEventPlugin: ReactNativeResponderEventPlugin, ReactNativeBridgeEventPlugin: ReactNativeBridgeEventPlugin, }); diff --git a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js index d826ccc842406..202a7dc0a78c7 100644 --- a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js +++ b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js @@ -5,7 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -import createResponderTouchHistoryStore from 'events/createResponderTouchHistoryStore'; import createResponderEventPlugin from 'events/createResponderEventPlugin'; const TopLevelTypes = { @@ -20,12 +19,6 @@ const TopLevelTypes = { topTouchStart: 'topTouchStart', }; -const ResponderTouchHistoryStore = createResponderTouchHistoryStore( - TopLevelTypes, -); -const DOMResponderEventPlugin = createResponderEventPlugin( - TopLevelTypes, - ResponderTouchHistoryStore, -); +const {ResponderEventPlugin} = createResponderEventPlugin(TopLevelTypes); -export default DOMResponderEventPlugin; +export default ResponderEventPlugin; From 7e8b34ffb660396b9872a29e1bc463104f6b0e73 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 24 Apr 2018 00:49:21 +0200 Subject: [PATCH 27/45] Add Flow types to createResponderEventPlugin and its consumers --- packages/events/createResponderEventPlugin.js | 88 +++++++++++++------ .../src/events/DOMResponderEventPlugin.js | 2 + .../src/ReactNativeResponderEventPlugin.js | 2 + 3 files changed, 66 insertions(+), 26 deletions(-) diff --git a/packages/events/createResponderEventPlugin.js b/packages/events/createResponderEventPlugin.js index 116e348a7dfcd..8f31e5e101a5a 100644 --- a/packages/events/createResponderEventPlugin.js +++ b/packages/events/createResponderEventPlugin.js @@ -3,6 +3,8 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. + * + * @flow */ import {getLowestCommonAncestor, isAncestor} from 'shared/ReactTreeTraversal'; @@ -22,6 +24,11 @@ import ResponderSyntheticEvent from './ResponderSyntheticEvent'; import accumulate from './accumulate'; import createResponderTouchHistoryStore from './createResponderTouchHistoryStore'; +import type {TopLevelType} from './TopLevelEventTypes'; +import type {AnyNativeEvent} from './PluginModuleType'; +import type {ReactSyntheticEvent} from './ReactSyntheticEventType'; +import type {Fiber} from 'react-reconciler/src/ReactFiber'; + /** * * Responder System: @@ -211,7 +218,26 @@ to return true:wantsResponderID| | * - `touchStart` (`EventPluginHub` dispatches as usual) * - `responderGrant/Reject` (`EventPluginHub` dispatches as usual) */ -export default function createResponderEventPlugin(TopLevelTypes) { + +type GlobalResponderHandlerType = { + onChange: (from: any, to: any, blockNativeResponder: any) => void, +}; + +type GlobalInteractionHandlerType = { + onChange: (numberActiveTouches: number) => void, +}; + +export default function createResponderEventPlugin(TopLevelTypes: { + topMouseDown: TopLevelType, + topMouseMove: TopLevelType, + topMouseUp: TopLevelType, + topScroll: TopLevelType, + topSelectionChange: TopLevelType, + topTouchCancel: TopLevelType, + topTouchEnd: TopLevelType, + topTouchMove: TopLevelType, + topTouchStart: TopLevelType, +}) { function isStartish(topLevelType) { return ( topLevelType === TopLevelTypes.topMouseDown || @@ -270,17 +296,17 @@ export default function createResponderEventPlugin(TopLevelTypes) { }; const startDependencies = [ - TopLevelTypes.TOP_TOUCH_START, - TopLevelTypes.TOP_MOUSE_DOWN, + TopLevelTypes.topTouchStart, + TopLevelTypes.topMouseDown, ]; const moveDependencies = [ - TopLevelTypes.TOP_TOUCH_MOVE, - TopLevelTypes.TOP_MOUSE_MOVE, + TopLevelTypes.topTouchMove, + TopLevelTypes.topMouseMove, ]; const endDependencies = [ - TopLevelTypes.TOP_TOUCH_CANCEL, - TopLevelTypes.TOP_TOUCH_END, - TopLevelTypes.TOP_MOUSE_UP, + TopLevelTypes.topTouchCancel, + TopLevelTypes.topTouchEnd, + TopLevelTypes.topMouseUp, ]; const eventTypes = { @@ -310,7 +336,7 @@ export default function createResponderEventPlugin(TopLevelTypes) { bubbled: 'onScrollShouldSetResponder', captured: 'onScrollShouldSetResponderCapture', }, - dependencies: [TopLevelTypes.TOP_SCROLL], + dependencies: [TopLevelTypes.topScroll], }, /** @@ -325,7 +351,7 @@ export default function createResponderEventPlugin(TopLevelTypes) { bubbled: 'onSelectionChangeShouldSetResponder', captured: 'onSelectionChangeShouldSetResponderCapture', }, - dependencies: [TopLevelTypes.TOP_SELECTION_CHANGE], + dependencies: [TopLevelTypes.topSelectionChange], }, /** @@ -355,7 +381,10 @@ export default function createResponderEventPlugin(TopLevelTypes) { registrationName: 'onResponderEnd', dependencies: endDependencies, }, - responderRelease: {registrationName: 'onResponderRelease'}, + responderRelease: { + registrationName: 'onResponderRelease', + dependencies: [], + }, responderTerminationRequest: { registrationName: 'onResponderTerminationRequest', dependencies: [], @@ -369,10 +398,10 @@ export default function createResponderEventPlugin(TopLevelTypes) { }; function setResponderAndExtractTransfer( - topLevelType, - targetInst, - nativeEvent, - nativeEventTarget, + topLevelType: TopLevelType, + targetInst: Fiber, + nativeEvent: AnyNativeEvent, + nativeEventTarget: EventTarget, ) { const shouldSetEventType = isStartish(topLevelType) ? eventTypes.startShouldSetResponder @@ -501,7 +530,7 @@ export default function createResponderEventPlugin(TopLevelTypes) { * @param {NativeEvent} nativeEvent Native touch end event. * @return {boolean} Whether or not this touch end event ends the responder. */ - function noResponderTouches(nativeEvent) { + function noResponderTouches(nativeEvent: any) { const touches = nativeEvent.touches; if (!touches || touches.length === 0) { return true; @@ -534,11 +563,11 @@ export default function createResponderEventPlugin(TopLevelTypes) { * assumed control and the original touch targets are destroyed. */ extractEvents: function( - topLevelType, - targetInst, - nativeEvent, - nativeEventTarget, - ) { + topLevelType: TopLevelType, + targetInst: Fiber, + nativeEvent: AnyNativeEvent, + nativeEventTarget: EventTarget, + ): any { if (isStartish(topLevelType)) { trackedTouchCount += 1; } else if (isEndish(topLevelType)) { @@ -552,7 +581,10 @@ export default function createResponderEventPlugin(TopLevelTypes) { } } - ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent); + ResponderTouchHistoryStore.recordTouchTrack( + topLevelType, + (nativeEvent: any), + ); let extracted = canTriggerTransfer(topLevelType, targetInst, nativeEvent) ? setResponderAndExtractTransfer( @@ -631,8 +663,8 @@ export default function createResponderEventPlugin(TopLevelTypes) { return extracted; }, - GlobalResponderHandler: null, - GlobalInteractionHandler: null, + GlobalResponderHandler: (null: null | GlobalResponderHandlerType), + GlobalInteractionHandler: (null: null | GlobalInteractionHandlerType), injection: { /** @@ -640,7 +672,9 @@ export default function createResponderEventPlugin(TopLevelTypes) { * Object that handles any change in responder. Use this to inject * integration with an existing touch handling system etc. */ - injectGlobalResponderHandler: function(GlobalResponderHandler) { + injectGlobalResponderHandler: function( + GlobalResponderHandler: GlobalResponderHandlerType, + ) { ResponderEventPlugin.GlobalResponderHandler = GlobalResponderHandler; }, @@ -648,7 +682,9 @@ export default function createResponderEventPlugin(TopLevelTypes) { * @param {{onChange: (numberActiveTouches) => void} GlobalInteractionHandler * Object that handles any change in the number of active touches. */ - injectGlobalInteractionHandler: function(GlobalInteractionHandler) { + injectGlobalInteractionHandler: function( + GlobalInteractionHandler: GlobalInteractionHandlerType, + ) { ResponderEventPlugin.GlobalInteractionHandler = GlobalInteractionHandler; }, }, diff --git a/packages/react-dom/src/events/DOMResponderEventPlugin.js b/packages/react-dom/src/events/DOMResponderEventPlugin.js index 96de77dc0ec6a..39bd63e8a8953 100644 --- a/packages/react-dom/src/events/DOMResponderEventPlugin.js +++ b/packages/react-dom/src/events/DOMResponderEventPlugin.js @@ -3,6 +3,8 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. + * + * @flow */ import createResponderEventPlugin from 'events/createResponderEventPlugin'; diff --git a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js index 202a7dc0a78c7..7b56d54d691c1 100644 --- a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js +++ b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js @@ -3,6 +3,8 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. + * + * @flow */ import createResponderEventPlugin from 'events/createResponderEventPlugin'; From 2d21c09fcbac2569d92e9950733799c905001abb Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 24 Apr 2018 01:14:22 +0200 Subject: [PATCH 28/45] Remove unused dependency --- packages/events/createResponderEventPlugin.js | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/events/createResponderEventPlugin.js b/packages/events/createResponderEventPlugin.js index 8f31e5e101a5a..0a3f0c2184c4b 100644 --- a/packages/events/createResponderEventPlugin.js +++ b/packages/events/createResponderEventPlugin.js @@ -26,7 +26,6 @@ import createResponderTouchHistoryStore from './createResponderTouchHistoryStore import type {TopLevelType} from './TopLevelEventTypes'; import type {AnyNativeEvent} from './PluginModuleType'; -import type {ReactSyntheticEvent} from './ReactSyntheticEventType'; import type {Fiber} from 'react-reconciler/src/ReactFiber'; /** From d1c390b6fd96f58511da700c914cc8bc64530061 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 24 Apr 2018 02:03:00 +0200 Subject: [PATCH 29/45] Use opaque flow type for TopLevelType --- packages/events/TopLevelEventTypes.js | 3 +- .../src/events/DOMTopLevelEventTypes.js | 144 +++++++++--------- .../src/ReactNativeEventEmitter.js | 7 +- .../src/ReactNativeResponderEventPlugin.js | 20 +-- 4 files changed, 90 insertions(+), 84 deletions(-) diff --git a/packages/events/TopLevelEventTypes.js b/packages/events/TopLevelEventTypes.js index c5323e5440143..c3c75fd09097d 100644 --- a/packages/events/TopLevelEventTypes.js +++ b/packages/events/TopLevelEventTypes.js @@ -7,4 +7,5 @@ * @flow */ -export type TopLevelType = number | string; +// eslint-disable-next-line no-undef +export opaque type TopLevelType = number | string; diff --git a/packages/react-dom/src/events/DOMTopLevelEventTypes.js b/packages/react-dom/src/events/DOMTopLevelEventTypes.js index 5e81961a2f4c4..5e192fb95adc1 100644 --- a/packages/react-dom/src/events/DOMTopLevelEventTypes.js +++ b/packages/react-dom/src/events/DOMTopLevelEventTypes.js @@ -7,74 +7,76 @@ * @flow */ -export const TOP_ABORT = 0; -export const TOP_ANIMATION_END = 1; -export const TOP_ANIMATION_ITERATION = 2; -export const TOP_ANIMATION_START = 3; -export const TOP_BLUR = 4; -export const TOP_CANCEL = 5; -export const TOP_CAN_PLAY = 6; -export const TOP_CAN_PLAY_THROUGH = 7; -export const TOP_CHANGE = 8; -export const TOP_CLICK = 9; -export const TOP_CLOSE = 10; -export const TOP_COMPOSITION_END = 11; -export const TOP_COMPOSITION_START = 12; -export const TOP_COMPOSITION_UPDATE = 13; -export const TOP_CONTEXT_MENU = 14; -export const TOP_COPY = 15; -export const TOP_CUT = 16; -export const TOP_DOUBLE_CLICK = 17; -export const TOP_DRAG = 18; -export const TOP_DRAG_END = 19; -export const TOP_DRAG_ENTER = 20; -export const TOP_DRAG_EXIT = 21; -export const TOP_DRAG_LEAVE = 22; -export const TOP_DRAG_OVER = 23; -export const TOP_DRAG_START = 24; -export const TOP_DROP = 25; -export const TOP_DURATION_CHANGE = 26; -export const TOP_EMPTIED = 27; -export const TOP_ENCRYPTED = 28; -export const TOP_ENDED = 29; -export const TOP_ERROR = 30; -export const TOP_FOCUS = 31; -export const TOP_INPUT = 32; -export const TOP_INVALID = 33; -export const TOP_KEY_DOWN = 34; -export const TOP_KEY_PRESS = 35; -export const TOP_KEY_UP = 36; -export const TOP_LOADED_DATA = 37; -export const TOP_LOAD = 38; -export const TOP_LOADED_METADATA = 39; -export const TOP_LOAD_START = 40; -export const TOP_MOUSE_DOWN = 41; -export const TOP_MOUSE_MOVE = 42; -export const TOP_MOUSE_OUT = 43; -export const TOP_MOUSE_OVER = 44; -export const TOP_MOUSE_UP = 45; -export const TOP_PASTE = 46; -export const TOP_PAUSE = 47; -export const TOP_PLAY = 48; -export const TOP_PLAYING = 49; -export const TOP_PROGRESS = 50; -export const TOP_RATE_CHANGE = 51; -export const TOP_RESET = 52; -export const TOP_SCROLL = 53; -export const TOP_SEEKED = 54; -export const TOP_SEEKING = 55; -export const TOP_SELECTION_CHANGE = 56; -export const TOP_STALLED = 57; -export const TOP_SUBMIT = 58; -export const TOP_SUSPEND = 59; -export const TOP_TEXT_INPUT = 60; -export const TOP_TIME_UPDATE = 61; -export const TOP_TOGGLE = 62; -export const TOP_TOUCH_CANCEL = 63; -export const TOP_TOUCH_END = 64; -export const TOP_TOUCH_MOVE = 65; -export const TOP_TOUCH_START = 66; -export const TOP_TRANSITION_END = 67; -export const TOP_VOLUME_CHANGE = 68; -export const TOP_WAITING = 69; -export const TOP_WHEEL = 70; +import type { TopLevelType } from 'events/TopLevelEventTypes' + +export const TOP_ABORT = ((0: any): TopLevelType); +export const TOP_ANIMATION_END = ((1: any): TopLevelType); +export const TOP_ANIMATION_ITERATION = ((2: any): TopLevelType); +export const TOP_ANIMATION_START = ((3: any): TopLevelType); +export const TOP_BLUR = ((4: any): TopLevelType); +export const TOP_CANCEL = ((5: any): TopLevelType); +export const TOP_CAN_PLAY = ((6: any): TopLevelType); +export const TOP_CAN_PLAY_THROUGH = ((7: any): TopLevelType); +export const TOP_CHANGE = ((8: any): TopLevelType); +export const TOP_CLICK = ((9: any): TopLevelType); +export const TOP_CLOSE = ((10: any): TopLevelType); +export const TOP_COMPOSITION_END = ((11: any): TopLevelType); +export const TOP_COMPOSITION_START = ((12: any): TopLevelType); +export const TOP_COMPOSITION_UPDATE = ((13: any): TopLevelType); +export const TOP_CONTEXT_MENU = ((14: any): TopLevelType); +export const TOP_COPY = ((15: any): TopLevelType); +export const TOP_CUT = ((16: any): TopLevelType); +export const TOP_DOUBLE_CLICK = ((17: any): TopLevelType); +export const TOP_DRAG = ((18: any): TopLevelType); +export const TOP_DRAG_END = ((19: any): TopLevelType); +export const TOP_DRAG_ENTER = ((20: any): TopLevelType); +export const TOP_DRAG_EXIT = ((21: any): TopLevelType); +export const TOP_DRAG_LEAVE = ((22: any): TopLevelType); +export const TOP_DRAG_OVER = ((23: any): TopLevelType); +export const TOP_DRAG_START = ((24: any): TopLevelType); +export const TOP_DROP = ((25: any): TopLevelType); +export const TOP_DURATION_CHANGE = ((26: any): TopLevelType); +export const TOP_EMPTIED = ((27: any): TopLevelType); +export const TOP_ENCRYPTED = ((28: any): TopLevelType); +export const TOP_ENDED = ((29: any): TopLevelType); +export const TOP_ERROR = ((30: any): TopLevelType); +export const TOP_FOCUS = ((31: any): TopLevelType); +export const TOP_INPUT = ((32: any): TopLevelType); +export const TOP_INVALID = ((33: any): TopLevelType); +export const TOP_KEY_DOWN = ((34: any): TopLevelType); +export const TOP_KEY_PRESS = ((35: any): TopLevelType); +export const TOP_KEY_UP = ((36: any): TopLevelType); +export const TOP_LOADED_DATA = ((37: any): TopLevelType); +export const TOP_LOAD = ((38: any): TopLevelType); +export const TOP_LOADED_METADATA = ((39: any): TopLevelType); +export const TOP_LOAD_START = ((40: any): TopLevelType); +export const TOP_MOUSE_DOWN = ((41: any): TopLevelType); +export const TOP_MOUSE_MOVE = ((42: any): TopLevelType); +export const TOP_MOUSE_OUT = ((43: any): TopLevelType); +export const TOP_MOUSE_OVER = ((44: any): TopLevelType); +export const TOP_MOUSE_UP = ((45: any): TopLevelType); +export const TOP_PASTE = ((46: any): TopLevelType); +export const TOP_PAUSE = ((47: any): TopLevelType); +export const TOP_PLAY = ((48: any): TopLevelType); +export const TOP_PLAYING = ((49: any): TopLevelType); +export const TOP_PROGRESS = ((50: any): TopLevelType); +export const TOP_RATE_CHANGE = ((51: any): TopLevelType); +export const TOP_RESET = ((52: any): TopLevelType); +export const TOP_SCROLL = ((53: any): TopLevelType); +export const TOP_SEEKED = ((54: any): TopLevelType); +export const TOP_SEEKING = ((55: any): TopLevelType); +export const TOP_SELECTION_CHANGE = ((56: any): TopLevelType); +export const TOP_STALLED = ((57: any): TopLevelType); +export const TOP_SUBMIT = ((58: any): TopLevelType); +export const TOP_SUSPEND = ((59: any): TopLevelType); +export const TOP_TEXT_INPUT = ((60: any): TopLevelType); +export const TOP_TIME_UPDATE = ((61: any): TopLevelType); +export const TOP_TOGGLE = ((62: any): TopLevelType); +export const TOP_TOUCH_CANCEL = ((63: any): TopLevelType); +export const TOP_TOUCH_END = ((64: any): TopLevelType); +export const TOP_TOUCH_MOVE = ((65: any): TopLevelType); +export const TOP_TOUCH_START = ((66: any): TopLevelType); +export const TOP_TRANSITION_END = ((67: any): TopLevelType); +export const TOP_VOLUME_CHANGE = ((68: any): TopLevelType); +export const TOP_WAITING = ((69: any): TopLevelType); +export const TOP_WHEEL = ((70: any): TopLevelType); diff --git a/packages/react-native-renderer/src/ReactNativeEventEmitter.js b/packages/react-native-renderer/src/ReactNativeEventEmitter.js index e43644a620826..6b61de63319bd 100644 --- a/packages/react-native-renderer/src/ReactNativeEventEmitter.js +++ b/packages/react-native-renderer/src/ReactNativeEventEmitter.js @@ -15,6 +15,7 @@ import warning from 'fbjs/lib/warning'; import {getInstanceFromNode} from './ReactNativeComponentTree'; import type {AnyNativeEvent} from 'events/PluginModuleType'; +import type {TopLevelType} from 'events/TopLevelEventTypes'; export {getListener, registrationNameModules as registrationNames}; @@ -88,7 +89,7 @@ const removeTouchesAtIndices = function( */ export function _receiveRootNodeIDEvent( rootNodeID: number, - topLevelType: string, + topLevelType: TopLevelType, nativeEventParam: ?AnyNativeEvent, ) { const nativeEvent = nativeEventParam || EMPTY_NATIVE_EVENT; @@ -114,7 +115,7 @@ export function _receiveRootNodeIDEvent( */ export function receiveEvent( rootNodeID: number, - topLevelType: string, + topLevelType: TopLevelType, nativeEventParam: AnyNativeEvent, ) { _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam); @@ -145,7 +146,7 @@ export function receiveEvent( * identifier 0, also abandoning traditional click handlers. */ export function receiveTouches( - eventTopLevelType: string, + eventTopLevelType: TopLevelType, touches: Array, changedIndices: Array, ) { diff --git a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js index 7b56d54d691c1..49ba3b0cd764d 100644 --- a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js +++ b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js @@ -9,16 +9,18 @@ import createResponderEventPlugin from 'events/createResponderEventPlugin'; +import type { TopLevelType } from 'events/TopLevelEventTypes' + const TopLevelTypes = { - topMouseDown: 'topMouseDown', - topMouseMove: 'topMouseMove', - topMouseUp: 'topMouseUp', - topScroll: 'topScroll', - topSelectionChange: 'topSelectionChange', - topTouchCancel: 'topTouchCancel', - topTouchEnd: 'topTouchEnd', - topTouchMove: 'topTouchMove', - topTouchStart: 'topTouchStart', + topMouseDown: (('topMouseDown': any): TopLevelType), + topMouseMove: (('topMouseMove': any): TopLevelType), + topMouseUp: (('topMouseUp': any): TopLevelType), + topScroll: (('topScroll': any): TopLevelType), + topSelectionChange: (('topSelectionChange': any): TopLevelType), + topTouchCancel: (('topTouchCancel': any): TopLevelType), + topTouchEnd: (('topTouchEnd': any): TopLevelType), + topTouchMove: (('topTouchMove': any): TopLevelType), + topTouchStart: (('topTouchStart': any): TopLevelType), }; const {ResponderEventPlugin} = createResponderEventPlugin(TopLevelTypes); From ec0b8811fe92c8fd4f62de0eb32b38f2ce407a2d Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 24 Apr 2018 03:15:39 +0200 Subject: [PATCH 30/45] Add missing semis --- packages/react-dom/src/events/DOMTopLevelEventTypes.js | 2 +- .../src/ReactNativeResponderEventPlugin.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-dom/src/events/DOMTopLevelEventTypes.js b/packages/react-dom/src/events/DOMTopLevelEventTypes.js index 5e192fb95adc1..e4707723a1b0f 100644 --- a/packages/react-dom/src/events/DOMTopLevelEventTypes.js +++ b/packages/react-dom/src/events/DOMTopLevelEventTypes.js @@ -7,7 +7,7 @@ * @flow */ -import type { TopLevelType } from 'events/TopLevelEventTypes' +import type { TopLevelType } from 'events/TopLevelEventTypes'; export const TOP_ABORT = ((0: any): TopLevelType); export const TOP_ANIMATION_END = ((1: any): TopLevelType); diff --git a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js index 49ba3b0cd764d..91f713c0808c4 100644 --- a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js +++ b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js @@ -9,7 +9,7 @@ import createResponderEventPlugin from 'events/createResponderEventPlugin'; -import type { TopLevelType } from 'events/TopLevelEventTypes' +import type { TopLevelType } from 'events/TopLevelEventTypes'; const TopLevelTypes = { topMouseDown: (('topMouseDown': any): TopLevelType), From 352dfbfc0741d6856a575687df826ba11cef7d1c Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 24 Apr 2018 19:44:35 +0200 Subject: [PATCH 31/45] Use raw event names as top level identifer --- packages/events/TopLevelEventTypes.js | 2 +- .../src/client/ReactDOMFiberComponent.js | 2 +- .../src/events/BrowserEventConstants.js | 145 -------------- .../src/events/DOMTopLevelEventTypes.js | 183 +++++++++++------- .../src/events/ReactBrowserEventEmitter.js | 2 +- .../src/events/ReactDOMEventListener.js | 2 +- .../src/ReactNativeResponderEventPlugin.js | 2 +- 7 files changed, 116 insertions(+), 222 deletions(-) delete mode 100644 packages/react-dom/src/events/BrowserEventConstants.js diff --git a/packages/events/TopLevelEventTypes.js b/packages/events/TopLevelEventTypes.js index c3c75fd09097d..fc5a97323ebf8 100644 --- a/packages/events/TopLevelEventTypes.js +++ b/packages/events/TopLevelEventTypes.js @@ -8,4 +8,4 @@ */ // eslint-disable-next-line no-undef -export opaque type TopLevelType = number | string; +export opaque type TopLevelType = string; diff --git a/packages/react-dom/src/client/ReactDOMFiberComponent.js b/packages/react-dom/src/client/ReactDOMFiberComponent.js index 9ceb06d700a43..43a0774b37e1a 100644 --- a/packages/react-dom/src/client/ReactDOMFiberComponent.js +++ b/packages/react-dom/src/client/ReactDOMFiberComponent.js @@ -30,7 +30,7 @@ import { TOP_TOGGLE, } from '../events/DOMTopLevelEventTypes'; import {listenTo, trapBubbledEvent} from '../events/ReactBrowserEventEmitter'; -import {mediaEventTypes} from '../events/BrowserEventConstants'; +import {mediaEventTypes} from '../events/DOMTopLevelEventTypes'; import * as CSSPropertyOperations from '../shared/CSSPropertyOperations'; import {Namespaces, getIntrinsicNamespace} from '../shared/DOMNamespaces'; import { diff --git a/packages/react-dom/src/events/BrowserEventConstants.js b/packages/react-dom/src/events/BrowserEventConstants.js deleted file mode 100644 index 3949b5c4c5b3a..0000000000000 --- a/packages/react-dom/src/events/BrowserEventConstants.js +++ /dev/null @@ -1,145 +0,0 @@ -/** - * 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. - * - * @flow - */ - -import type {TopLevelType} from 'events/TopLevelEventTypes'; -import invariant from 'fbjs/lib/invariant'; - -import * as DOMTopLevelEventTypes from './DOMTopLevelEventTypes'; -import getVendorPrefixedEventName from './getVendorPrefixedEventName'; - -/** - * Small helper function to create a map using the Map constructor arguments. - * This is needed because IE11 does not implement that constructor. - */ -function makeMap(values: Array<[K, V]>): Map { - const map: Map = new Map(); - values.forEach(([k, v]) => { - map.set(k, v); - }); - return map; -} - -/** - * Types of raw signals from the browser caught at the top level. - * - * For events like 'submit' or audio/video events which don't consistently - * bubble (which we trap at a lower node than `document`), binding - * at `document` would cause duplicate events so we don't include them here. - */ -export const topLevelTypes: Map = makeMap([ - [ - DOMTopLevelEventTypes.TOP_ANIMATION_END, - getVendorPrefixedEventName('animationend'), - ], - [ - DOMTopLevelEventTypes.TOP_ANIMATION_ITERATION, - getVendorPrefixedEventName('animationiteration'), - ], - [ - DOMTopLevelEventTypes.TOP_ANIMATION_START, - getVendorPrefixedEventName('animationstart'), - ], - [DOMTopLevelEventTypes.TOP_BLUR, 'blur'], - [DOMTopLevelEventTypes.TOP_CANCEL, 'cancel'], - [DOMTopLevelEventTypes.TOP_CHANGE, 'change'], - [DOMTopLevelEventTypes.TOP_CLICK, 'click'], - [DOMTopLevelEventTypes.TOP_CLOSE, 'close'], - [DOMTopLevelEventTypes.TOP_COMPOSITION_END, 'compositionend'], - [DOMTopLevelEventTypes.TOP_COMPOSITION_START, 'compositionstart'], - [DOMTopLevelEventTypes.TOP_COMPOSITION_UPDATE, 'compositionupdate'], - [DOMTopLevelEventTypes.TOP_CONTEXT_MENU, 'contextmenu'], - [DOMTopLevelEventTypes.TOP_COPY, 'copy'], - [DOMTopLevelEventTypes.TOP_CUT, 'cut'], - [DOMTopLevelEventTypes.TOP_DOUBLE_CLICK, 'dblclick'], - [DOMTopLevelEventTypes.TOP_DRAG, 'drag'], - [DOMTopLevelEventTypes.TOP_DRAG_END, 'dragend'], - [DOMTopLevelEventTypes.TOP_DRAG_ENTER, 'dragenter'], - [DOMTopLevelEventTypes.TOP_DRAG_EXIT, 'dragexit'], - [DOMTopLevelEventTypes.TOP_DRAG_LEAVE, 'dragleave'], - [DOMTopLevelEventTypes.TOP_DRAG_OVER, 'dragover'], - [DOMTopLevelEventTypes.TOP_DRAG_START, 'dragstart'], - [DOMTopLevelEventTypes.TOP_DROP, 'drop'], - [DOMTopLevelEventTypes.TOP_FOCUS, 'focus'], - [DOMTopLevelEventTypes.TOP_KEY_DOWN, 'keydown'], - [DOMTopLevelEventTypes.TOP_KEY_PRESS, 'keypress'], - [DOMTopLevelEventTypes.TOP_KEY_UP, 'keyup'], - [DOMTopLevelEventTypes.TOP_LOAD, 'load'], - [DOMTopLevelEventTypes.TOP_LOAD_START, 'loadstart'], - [DOMTopLevelEventTypes.TOP_MOUSE_DOWN, 'mousedown'], - [DOMTopLevelEventTypes.TOP_MOUSE_MOVE, 'mousemove'], - [DOMTopLevelEventTypes.TOP_MOUSE_OUT, 'mouseout'], - [DOMTopLevelEventTypes.TOP_MOUSE_OVER, 'mouseover'], - [DOMTopLevelEventTypes.TOP_MOUSE_UP, 'mouseup'], - [DOMTopLevelEventTypes.TOP_PASTE, 'paste'], - [DOMTopLevelEventTypes.TOP_SCROLL, 'scroll'], - [DOMTopLevelEventTypes.TOP_SELECTION_CHANGE, 'selectionchange'], - [DOMTopLevelEventTypes.TOP_TEXT_INPUT, 'textInput'], - [DOMTopLevelEventTypes.TOP_TOGGLE, 'toggle'], - [DOMTopLevelEventTypes.TOP_TOUCH_CANCEL, 'touchcancel'], - [DOMTopLevelEventTypes.TOP_TOUCH_END, 'touchend'], - [DOMTopLevelEventTypes.TOP_TOUCH_MOVE, 'touchmove'], - [DOMTopLevelEventTypes.TOP_TOUCH_START, 'touchstart'], - [ - DOMTopLevelEventTypes.TOP_TRANSITION_END, - getVendorPrefixedEventName('transitionend'), - ], - [DOMTopLevelEventTypes.TOP_WHEEL, 'wheel'], -]); - -// There are so many media events, it makes sense to just -// maintain a list of them. Note these aren't technically -// "top-level" since they don't bubble. We should come up -// with a better naming convention if we come to refactoring -// the event system. -export const mediaEventTypes: Map = makeMap([ - [DOMTopLevelEventTypes.TOP_ABORT, 'abort'], - [DOMTopLevelEventTypes.TOP_CAN_PLAY, 'canplay'], - [DOMTopLevelEventTypes.TOP_CAN_PLAY_THROUGH, 'canplaythrough'], - [DOMTopLevelEventTypes.TOP_DURATION_CHANGE, 'durationchange'], - [DOMTopLevelEventTypes.TOP_EMPTIED, 'emptied'], - [DOMTopLevelEventTypes.TOP_ENCRYPTED, 'encrypted'], - [DOMTopLevelEventTypes.TOP_ENDED, 'ended'], - [DOMTopLevelEventTypes.TOP_ERROR, 'error'], - [DOMTopLevelEventTypes.TOP_LOADED_DATA, 'loadeddata'], - [DOMTopLevelEventTypes.TOP_LOADED_METADATA, 'loadedmetadata'], - [DOMTopLevelEventTypes.TOP_LOAD_START, 'loadstart'], - [DOMTopLevelEventTypes.TOP_PAUSE, 'pause'], - [DOMTopLevelEventTypes.TOP_PLAY, 'play'], - [DOMTopLevelEventTypes.TOP_PLAYING, 'playing'], - [DOMTopLevelEventTypes.TOP_PROGRESS, 'progress'], - [DOMTopLevelEventTypes.TOP_RATE_CHANGE, 'ratechange'], - [DOMTopLevelEventTypes.TOP_SEEKED, 'seeked'], - [DOMTopLevelEventTypes.TOP_SEEKING, 'seeking'], - [DOMTopLevelEventTypes.TOP_STALLED, 'stalled'], - [DOMTopLevelEventTypes.TOP_SUSPEND, 'suspend'], - [DOMTopLevelEventTypes.TOP_TIME_UPDATE, 'timeupdate'], - [DOMTopLevelEventTypes.TOP_VOLUME_CHANGE, 'volumechange'], - [DOMTopLevelEventTypes.TOP_WAITING, 'waiting'], -]); - -const nonTopEventTypes: Map = makeMap([ - [DOMTopLevelEventTypes.TOP_INPUT, 'input'], - [DOMTopLevelEventTypes.TOP_INVALID, 'invalid'], - [DOMTopLevelEventTypes.TOP_RESET, 'reset'], - [DOMTopLevelEventTypes.TOP_SUBMIT, 'submit'], -]); - -export function getRawEventName(topLevelType: TopLevelType): string { - const eventName = - topLevelTypes.get(topLevelType) || - mediaEventTypes.get(topLevelType) || - nonTopEventTypes.get(topLevelType); - - invariant( - eventName, - 'BrowserEventConstants: Could not look up raw event name of topLevelType: %s.', - topLevelType, - ); - return eventName; -} diff --git a/packages/react-dom/src/events/DOMTopLevelEventTypes.js b/packages/react-dom/src/events/DOMTopLevelEventTypes.js index e4707723a1b0f..e586a9cd00c35 100644 --- a/packages/react-dom/src/events/DOMTopLevelEventTypes.js +++ b/packages/react-dom/src/events/DOMTopLevelEventTypes.js @@ -7,76 +7,115 @@ * @flow */ -import type { TopLevelType } from 'events/TopLevelEventTypes'; +import type {TopLevelType} from 'events/TopLevelEventTypes'; +import getVendorPrefixedEventName from './getVendorPrefixedEventName'; -export const TOP_ABORT = ((0: any): TopLevelType); -export const TOP_ANIMATION_END = ((1: any): TopLevelType); -export const TOP_ANIMATION_ITERATION = ((2: any): TopLevelType); -export const TOP_ANIMATION_START = ((3: any): TopLevelType); -export const TOP_BLUR = ((4: any): TopLevelType); -export const TOP_CANCEL = ((5: any): TopLevelType); -export const TOP_CAN_PLAY = ((6: any): TopLevelType); -export const TOP_CAN_PLAY_THROUGH = ((7: any): TopLevelType); -export const TOP_CHANGE = ((8: any): TopLevelType); -export const TOP_CLICK = ((9: any): TopLevelType); -export const TOP_CLOSE = ((10: any): TopLevelType); -export const TOP_COMPOSITION_END = ((11: any): TopLevelType); -export const TOP_COMPOSITION_START = ((12: any): TopLevelType); -export const TOP_COMPOSITION_UPDATE = ((13: any): TopLevelType); -export const TOP_CONTEXT_MENU = ((14: any): TopLevelType); -export const TOP_COPY = ((15: any): TopLevelType); -export const TOP_CUT = ((16: any): TopLevelType); -export const TOP_DOUBLE_CLICK = ((17: any): TopLevelType); -export const TOP_DRAG = ((18: any): TopLevelType); -export const TOP_DRAG_END = ((19: any): TopLevelType); -export const TOP_DRAG_ENTER = ((20: any): TopLevelType); -export const TOP_DRAG_EXIT = ((21: any): TopLevelType); -export const TOP_DRAG_LEAVE = ((22: any): TopLevelType); -export const TOP_DRAG_OVER = ((23: any): TopLevelType); -export const TOP_DRAG_START = ((24: any): TopLevelType); -export const TOP_DROP = ((25: any): TopLevelType); -export const TOP_DURATION_CHANGE = ((26: any): TopLevelType); -export const TOP_EMPTIED = ((27: any): TopLevelType); -export const TOP_ENCRYPTED = ((28: any): TopLevelType); -export const TOP_ENDED = ((29: any): TopLevelType); -export const TOP_ERROR = ((30: any): TopLevelType); -export const TOP_FOCUS = ((31: any): TopLevelType); -export const TOP_INPUT = ((32: any): TopLevelType); -export const TOP_INVALID = ((33: any): TopLevelType); -export const TOP_KEY_DOWN = ((34: any): TopLevelType); -export const TOP_KEY_PRESS = ((35: any): TopLevelType); -export const TOP_KEY_UP = ((36: any): TopLevelType); -export const TOP_LOADED_DATA = ((37: any): TopLevelType); -export const TOP_LOAD = ((38: any): TopLevelType); -export const TOP_LOADED_METADATA = ((39: any): TopLevelType); -export const TOP_LOAD_START = ((40: any): TopLevelType); -export const TOP_MOUSE_DOWN = ((41: any): TopLevelType); -export const TOP_MOUSE_MOVE = ((42: any): TopLevelType); -export const TOP_MOUSE_OUT = ((43: any): TopLevelType); -export const TOP_MOUSE_OVER = ((44: any): TopLevelType); -export const TOP_MOUSE_UP = ((45: any): TopLevelType); -export const TOP_PASTE = ((46: any): TopLevelType); -export const TOP_PAUSE = ((47: any): TopLevelType); -export const TOP_PLAY = ((48: any): TopLevelType); -export const TOP_PLAYING = ((49: any): TopLevelType); -export const TOP_PROGRESS = ((50: any): TopLevelType); -export const TOP_RATE_CHANGE = ((51: any): TopLevelType); -export const TOP_RESET = ((52: any): TopLevelType); -export const TOP_SCROLL = ((53: any): TopLevelType); -export const TOP_SEEKED = ((54: any): TopLevelType); -export const TOP_SEEKING = ((55: any): TopLevelType); -export const TOP_SELECTION_CHANGE = ((56: any): TopLevelType); -export const TOP_STALLED = ((57: any): TopLevelType); -export const TOP_SUBMIT = ((58: any): TopLevelType); -export const TOP_SUSPEND = ((59: any): TopLevelType); -export const TOP_TEXT_INPUT = ((60: any): TopLevelType); -export const TOP_TIME_UPDATE = ((61: any): TopLevelType); -export const TOP_TOGGLE = ((62: any): TopLevelType); -export const TOP_TOUCH_CANCEL = ((63: any): TopLevelType); -export const TOP_TOUCH_END = ((64: any): TopLevelType); -export const TOP_TOUCH_MOVE = ((65: any): TopLevelType); -export const TOP_TOUCH_START = ((66: any): TopLevelType); -export const TOP_TRANSITION_END = ((67: any): TopLevelType); -export const TOP_VOLUME_CHANGE = ((68: any): TopLevelType); -export const TOP_WAITING = ((69: any): TopLevelType); -export const TOP_WHEEL = ((70: any): TopLevelType); +export const TOP_ABORT = (('abort': any): TopLevelType); +export const TOP_ANIMATION_END = ((getVendorPrefixedEventName( + 'animationend', +): any): TopLevelType); +export const TOP_ANIMATION_ITERATION = ((getVendorPrefixedEventName( + 'animationiteration', +): any): TopLevelType); +export const TOP_ANIMATION_START = ((getVendorPrefixedEventName( + 'animationstart', +): any): TopLevelType); +export const TOP_BLUR = (('blur': any): TopLevelType); +export const TOP_CAN_PLAY = (('canplay': any): TopLevelType); +export const TOP_CAN_PLAY_THROUGH = (('canplaythrough': any): TopLevelType); +export const TOP_CANCEL = (('cancel': any): TopLevelType); +export const TOP_CHANGE = (('change': any): TopLevelType); +export const TOP_CLICK = (('click': any): TopLevelType); +export const TOP_CLOSE = (('close': any): TopLevelType); +export const TOP_COMPOSITION_END = (('compositionend': any): TopLevelType); +export const TOP_COMPOSITION_START = (('compositionstart': any): TopLevelType); +export const TOP_COMPOSITION_UPDATE = (('compositionupdate': any): TopLevelType); +export const TOP_CONTEXT_MENU = (('contextmenu': any): TopLevelType); +export const TOP_COPY = (('copy': any): TopLevelType); +export const TOP_CUT = (('cut': any): TopLevelType); +export const TOP_DOUBLE_CLICK = (('dblclick': any): TopLevelType); +export const TOP_DRAG = (('drag': any): TopLevelType); +export const TOP_DRAG_END = (('dragend': any): TopLevelType); +export const TOP_DRAG_ENTER = (('dragenter': any): TopLevelType); +export const TOP_DRAG_EXIT = (('dragexit': any): TopLevelType); +export const TOP_DRAG_LEAVE = (('dragleave': any): TopLevelType); +export const TOP_DRAG_OVER = (('dragover': any): TopLevelType); +export const TOP_DRAG_START = (('dragstart': any): TopLevelType); +export const TOP_DROP = (('drop': any): TopLevelType); +export const TOP_DURATION_CHANGE = (('durationchange': any): TopLevelType); +export const TOP_EMPTIED = (('emptied': any): TopLevelType); +export const TOP_ENCRYPTED = (('encrypted': any): TopLevelType); +export const TOP_ENDED = (('ended': any): TopLevelType); +export const TOP_ERROR = (('error': any): TopLevelType); +export const TOP_FOCUS = (('focus': any): TopLevelType); +export const TOP_INPUT = (('input': any): TopLevelType); +export const TOP_INVALID = (('invalid': any): TopLevelType); +export const TOP_KEY_DOWN = (('keydown': any): TopLevelType); +export const TOP_KEY_PRESS = (('keypress': any): TopLevelType); +export const TOP_KEY_UP = (('keyup': any): TopLevelType); +export const TOP_LOAD = (('load': any): TopLevelType); +export const TOP_LOAD_START = (('loadstart': any): TopLevelType); +export const TOP_LOADED_DATA = (('loadeddata': any): TopLevelType); +export const TOP_LOADED_METADATA = (('loadedmetadata': any): TopLevelType); +export const TOP_MOUSE_DOWN = (('mousedown': any): TopLevelType); +export const TOP_MOUSE_MOVE = (('mousemove': any): TopLevelType); +export const TOP_MOUSE_OUT = (('mouseout': any): TopLevelType); +export const TOP_MOUSE_OVER = (('mouseover': any): TopLevelType); +export const TOP_MOUSE_UP = (('mouseup': any): TopLevelType); +export const TOP_PASTE = (('paste': any): TopLevelType); +export const TOP_PAUSE = (('pause': any): TopLevelType); +export const TOP_PLAY = (('play': any): TopLevelType); +export const TOP_PLAYING = (('playing': any): TopLevelType); +export const TOP_PROGRESS = (('progress': any): TopLevelType); +export const TOP_RATE_CHANGE = (('ratechange': any): TopLevelType); +export const TOP_RESET = (('reset': any): TopLevelType); +export const TOP_SCROLL = (('scroll': any): TopLevelType); +export const TOP_SEEKED = (('seeked': any): TopLevelType); +export const TOP_SEEKING = (('seeking': any): TopLevelType); +export const TOP_SELECTION_CHANGE = (('selectionchange': any): TopLevelType); +export const TOP_STALLED = (('stalled': any): TopLevelType); +export const TOP_SUBMIT = (('submit': any): TopLevelType); +export const TOP_SUSPEND = (('suspend': any): TopLevelType); +export const TOP_TEXT_INPUT = (('textInput': any): TopLevelType); +export const TOP_TIME_UPDATE = (('timeupdate': any): TopLevelType); +export const TOP_TOGGLE = (('toggle': any): TopLevelType); +export const TOP_TOUCH_CANCEL = (('touchcancel': any): TopLevelType); +export const TOP_TOUCH_END = (('touchend': any): TopLevelType); +export const TOP_TOUCH_MOVE = (('touchmove': any): TopLevelType); +export const TOP_TOUCH_START = (('touchstart': any): TopLevelType); +export const TOP_TRANSITION_END = ((getVendorPrefixedEventName( + 'transitionend', +): any): TopLevelType); +export const TOP_VOLUME_CHANGE = (('volumechange': any): TopLevelType); +export const TOP_WAITING = (('waiting': any): TopLevelType); +export const TOP_WHEEL = (('wheel': any): TopLevelType); + +export const mediaEventTypes = [ + TOP_ABORT, + TOP_CAN_PLAY, + TOP_CAN_PLAY_THROUGH, + TOP_DURATION_CHANGE, + TOP_EMPTIED, + TOP_ENCRYPTED, + TOP_ENDED, + TOP_ERROR, + TOP_LOADED_DATA, + TOP_LOADED_METADATA, + TOP_LOAD_START, + TOP_PAUSE, + TOP_PLAY, + TOP_PLAYING, + TOP_PROGRESS, + TOP_RATE_CHANGE, + TOP_SEEKED, + TOP_SEEKING, + TOP_STALLED, + TOP_SUSPEND, + TOP_TIME_UPDATE, + TOP_VOLUME_CHANGE, + TOP_WAITING, +]; + +export function getRawEventName(topLevelType: TopLevelType): string { + return (topLevelType: any); +} diff --git a/packages/react-dom/src/events/ReactBrowserEventEmitter.js b/packages/react-dom/src/events/ReactBrowserEventEmitter.js index ef5f31e136e41..5c8a0aaacb841 100644 --- a/packages/react-dom/src/events/ReactBrowserEventEmitter.js +++ b/packages/react-dom/src/events/ReactBrowserEventEmitter.js @@ -20,7 +20,7 @@ import { trapCapturedEvent, } from './ReactDOMEventListener'; import isEventSupported from './isEventSupported'; -import {getRawEventName} from './BrowserEventConstants'; +import {getRawEventName} from './DOMTopLevelEventTypes'; /** * Summary of `ReactBrowserEventEmitter` event handling: diff --git a/packages/react-dom/src/events/ReactDOMEventListener.js b/packages/react-dom/src/events/ReactDOMEventListener.js index fd0cf0580652f..0455212eaf8a4 100644 --- a/packages/react-dom/src/events/ReactDOMEventListener.js +++ b/packages/react-dom/src/events/ReactDOMEventListener.js @@ -14,7 +14,7 @@ import {addEventBubbleListener, addEventCaptureListener} from './EventListener'; import getEventTarget from './getEventTarget'; import {getClosestInstanceFromNode} from '../client/ReactDOMComponentTree'; import SimpleEventPlugin from './SimpleEventPlugin'; -import {getRawEventName} from './BrowserEventConstants'; +import {getRawEventName} from './DOMTopLevelEventTypes'; const {isInteractiveTopLevelEventType} = SimpleEventPlugin; diff --git a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js index 91f713c0808c4..332b5d44c6801 100644 --- a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js +++ b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js @@ -9,7 +9,7 @@ import createResponderEventPlugin from 'events/createResponderEventPlugin'; -import type { TopLevelType } from 'events/TopLevelEventTypes'; +import type {TopLevelType} from 'events/TopLevelEventTypes'; const TopLevelTypes = { topMouseDown: (('topMouseDown': any): TopLevelType), From ac6e3e2e3e1e928a43ecd72e9cdef68488f1dbe5 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 25 Apr 2018 01:02:57 +0200 Subject: [PATCH 32/45] Upgrade baylon This is required for parsing opaque flow types in our CI tests. --- package.json | 2 +- yarn.lock | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 01f0a2781fef9..fe3a5b91f6482 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "babel-plugin-transform-regenerator": "^6.26.0", "babel-preset-react": "^6.5.0", "babel-traverse": "^6.9.0", - "babylon": "6.15.0", + "babylon": "6.18.0", "bundle-collapser": "^1.1.1", "chalk": "^1.1.3", "cli-table": "^0.3.1", diff --git a/yarn.lock b/yarn.lock index 0c9feb48b69b4..6b98132b9de31 100644 --- a/yarn.lock +++ b/yarn.lock @@ -985,9 +985,9 @@ babel@^5.4.7: slash "^1.0.0" source-map "^0.5.0" -babylon@6.15.0, babylon@^6.11.0: - version "6.15.0" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.15.0.tgz#ba65cfa1a80e1759b0e89fb562e27dccae70348e" +babylon@6.18.0, babylon@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" babylon@7.0.0-beta.36: version "7.0.0-beta.36" @@ -997,14 +997,14 @@ babylon@^5.8.38: version "5.8.38" resolved "https://registry.yarnpkg.com/babylon/-/babylon-5.8.38.tgz#ec9b120b11bf6ccd4173a18bf217e60b79859ffd" +babylon@^6.11.0: + version "6.15.0" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.15.0.tgz#ba65cfa1a80e1759b0e89fb562e27dccae70348e" + babylon@^6.15.0: version "6.17.0" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.0.tgz#37da948878488b9c4e3c4038893fa3314b3fc932" -babylon@^6.18.0: - version "6.18.0" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" - balanced-match@^0.4.1: version "0.4.2" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" From 4a7bf074b8b2d6f7fb5a12db44b9ca793ef0ab3f Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 25 Apr 2018 01:21:39 +0200 Subject: [PATCH 33/45] Clean up flow types --- packages/events/TopLevelEventTypes.js | 15 +- .../src/events/DOMTopLevelEventTypes.js | 228 ++++++++++++------ .../src/ReactNativeResponderEventPlugin.js | 20 +- 3 files changed, 173 insertions(+), 90 deletions(-) diff --git a/packages/events/TopLevelEventTypes.js b/packages/events/TopLevelEventTypes.js index fc5a97323ebf8..0985f9e543fe0 100644 --- a/packages/events/TopLevelEventTypes.js +++ b/packages/events/TopLevelEventTypes.js @@ -7,5 +7,16 @@ * @flow */ -// eslint-disable-next-line no-undef -export opaque type TopLevelType = string; +import type {DOMTopLevelEventType} from 'react-dom/src/events/DOMTopLevelEventTypes'; + +export type TopLevelType = + | DOMTopLevelEventType + | 'topMouseDown' + | 'topMouseMove' + | 'topMouseUp' + | 'topScroll' + | 'topSelectionChange' + | 'topTouchCancel' + | 'topTouchEnd' + | 'topTouchMove' + | 'topTouchStart' diff --git a/packages/react-dom/src/events/DOMTopLevelEventTypes.js b/packages/react-dom/src/events/DOMTopLevelEventTypes.js index e586a9cd00c35..61421c08a6e25 100644 --- a/packages/react-dom/src/events/DOMTopLevelEventTypes.js +++ b/packages/react-dom/src/events/DOMTopLevelEventTypes.js @@ -10,87 +10,161 @@ import type {TopLevelType} from 'events/TopLevelEventTypes'; import getVendorPrefixedEventName from './getVendorPrefixedEventName'; -export const TOP_ABORT = (('abort': any): TopLevelType); -export const TOP_ANIMATION_END = ((getVendorPrefixedEventName( +// eslint-disable-next-line no-undef +export opaque type DOMTopLevelEventType = + | 'abort' + | 'animationend' + | 'animationiteration' + | 'animationstart' + | 'blur' + | 'canplay' + | 'canplaythrough' + | 'cancel' + | 'change' + | 'click' + | 'close' + | 'compositionend' + | 'compositionstart' + | 'compositionupdate' + | 'contextmenu' + | 'copy' + | 'cut' + | 'dblclick' + | 'drag' + | 'dragend' + | 'dragenter' + | 'dragexit' + | 'dragleave' + | 'dragover' + | 'dragstart' + | 'drop' + | 'durationchange' + | 'emptied' + | 'encrypted' + | 'ended' + | 'error' + | 'focus' + | 'input' + | 'invalid' + | 'keydown' + | 'keypress' + | 'keyup' + | 'load' + | 'loadstart' + | 'loadeddata' + | 'loadedmetadata' + | 'mousedown' + | 'mousemove' + | 'mouseout' + | 'mouseover' + | 'mouseup' + | 'paste' + | 'pause' + | 'play' + | 'playing' + | 'progress' + | 'ratechange' + | 'reset' + | 'scroll' + | 'seeked' + | 'seeking' + | 'selectionchange' + | 'stalled' + | 'submit' + | 'suspend' + | 'textInput' + | 'timeupdate' + | 'toggle' + | 'touchcancel' + | 'touchend' + | 'touchmove' + | 'touchstart' + | 'transitionend' + | 'volumechange' + | 'waiting' + | 'wheel'; + +export const TOP_ABORT: TopLevelType = 'abort'; +export const TOP_ANIMATION_END: TopLevelType = getVendorPrefixedEventName( 'animationend', -): any): TopLevelType); -export const TOP_ANIMATION_ITERATION = ((getVendorPrefixedEventName( +); +export const TOP_ANIMATION_ITERATION: TopLevelType = getVendorPrefixedEventName( 'animationiteration', -): any): TopLevelType); -export const TOP_ANIMATION_START = ((getVendorPrefixedEventName( +); +export const TOP_ANIMATION_START: TopLevelType = getVendorPrefixedEventName( 'animationstart', -): any): TopLevelType); -export const TOP_BLUR = (('blur': any): TopLevelType); -export const TOP_CAN_PLAY = (('canplay': any): TopLevelType); -export const TOP_CAN_PLAY_THROUGH = (('canplaythrough': any): TopLevelType); -export const TOP_CANCEL = (('cancel': any): TopLevelType); -export const TOP_CHANGE = (('change': any): TopLevelType); -export const TOP_CLICK = (('click': any): TopLevelType); -export const TOP_CLOSE = (('close': any): TopLevelType); -export const TOP_COMPOSITION_END = (('compositionend': any): TopLevelType); -export const TOP_COMPOSITION_START = (('compositionstart': any): TopLevelType); -export const TOP_COMPOSITION_UPDATE = (('compositionupdate': any): TopLevelType); -export const TOP_CONTEXT_MENU = (('contextmenu': any): TopLevelType); -export const TOP_COPY = (('copy': any): TopLevelType); -export const TOP_CUT = (('cut': any): TopLevelType); -export const TOP_DOUBLE_CLICK = (('dblclick': any): TopLevelType); -export const TOP_DRAG = (('drag': any): TopLevelType); -export const TOP_DRAG_END = (('dragend': any): TopLevelType); -export const TOP_DRAG_ENTER = (('dragenter': any): TopLevelType); -export const TOP_DRAG_EXIT = (('dragexit': any): TopLevelType); -export const TOP_DRAG_LEAVE = (('dragleave': any): TopLevelType); -export const TOP_DRAG_OVER = (('dragover': any): TopLevelType); -export const TOP_DRAG_START = (('dragstart': any): TopLevelType); -export const TOP_DROP = (('drop': any): TopLevelType); -export const TOP_DURATION_CHANGE = (('durationchange': any): TopLevelType); -export const TOP_EMPTIED = (('emptied': any): TopLevelType); -export const TOP_ENCRYPTED = (('encrypted': any): TopLevelType); -export const TOP_ENDED = (('ended': any): TopLevelType); -export const TOP_ERROR = (('error': any): TopLevelType); -export const TOP_FOCUS = (('focus': any): TopLevelType); -export const TOP_INPUT = (('input': any): TopLevelType); -export const TOP_INVALID = (('invalid': any): TopLevelType); -export const TOP_KEY_DOWN = (('keydown': any): TopLevelType); -export const TOP_KEY_PRESS = (('keypress': any): TopLevelType); -export const TOP_KEY_UP = (('keyup': any): TopLevelType); -export const TOP_LOAD = (('load': any): TopLevelType); -export const TOP_LOAD_START = (('loadstart': any): TopLevelType); -export const TOP_LOADED_DATA = (('loadeddata': any): TopLevelType); -export const TOP_LOADED_METADATA = (('loadedmetadata': any): TopLevelType); -export const TOP_MOUSE_DOWN = (('mousedown': any): TopLevelType); -export const TOP_MOUSE_MOVE = (('mousemove': any): TopLevelType); -export const TOP_MOUSE_OUT = (('mouseout': any): TopLevelType); -export const TOP_MOUSE_OVER = (('mouseover': any): TopLevelType); -export const TOP_MOUSE_UP = (('mouseup': any): TopLevelType); -export const TOP_PASTE = (('paste': any): TopLevelType); -export const TOP_PAUSE = (('pause': any): TopLevelType); -export const TOP_PLAY = (('play': any): TopLevelType); -export const TOP_PLAYING = (('playing': any): TopLevelType); -export const TOP_PROGRESS = (('progress': any): TopLevelType); -export const TOP_RATE_CHANGE = (('ratechange': any): TopLevelType); -export const TOP_RESET = (('reset': any): TopLevelType); -export const TOP_SCROLL = (('scroll': any): TopLevelType); -export const TOP_SEEKED = (('seeked': any): TopLevelType); -export const TOP_SEEKING = (('seeking': any): TopLevelType); -export const TOP_SELECTION_CHANGE = (('selectionchange': any): TopLevelType); -export const TOP_STALLED = (('stalled': any): TopLevelType); -export const TOP_SUBMIT = (('submit': any): TopLevelType); -export const TOP_SUSPEND = (('suspend': any): TopLevelType); -export const TOP_TEXT_INPUT = (('textInput': any): TopLevelType); -export const TOP_TIME_UPDATE = (('timeupdate': any): TopLevelType); -export const TOP_TOGGLE = (('toggle': any): TopLevelType); -export const TOP_TOUCH_CANCEL = (('touchcancel': any): TopLevelType); -export const TOP_TOUCH_END = (('touchend': any): TopLevelType); -export const TOP_TOUCH_MOVE = (('touchmove': any): TopLevelType); -export const TOP_TOUCH_START = (('touchstart': any): TopLevelType); -export const TOP_TRANSITION_END = ((getVendorPrefixedEventName( +); +export const TOP_BLUR: TopLevelType = 'blur'; +export const TOP_CAN_PLAY: TopLevelType = 'canplay'; +export const TOP_CAN_PLAY_THROUGH: TopLevelType = 'canplaythrough'; +export const TOP_CANCEL: TopLevelType = 'cancel'; +export const TOP_CHANGE: TopLevelType = 'change'; +export const TOP_CLICK: TopLevelType = 'click'; +export const TOP_CLOSE: TopLevelType = 'close'; +export const TOP_COMPOSITION_END: TopLevelType = 'compositionend'; +export const TOP_COMPOSITION_START: TopLevelType = 'compositionstart'; +export const TOP_COMPOSITION_UPDATE: TopLevelType = 'compositionupdate'; +export const TOP_CONTEXT_MENU: TopLevelType = 'contextmenu'; +export const TOP_COPY: TopLevelType = 'copy'; +export const TOP_CUT: TopLevelType = 'cut'; +export const TOP_DOUBLE_CLICK: TopLevelType = 'dblclick'; +export const TOP_DRAG: TopLevelType = 'drag'; +export const TOP_DRAG_END: TopLevelType = 'dragend'; +export const TOP_DRAG_ENTER: TopLevelType = 'dragenter'; +export const TOP_DRAG_EXIT: TopLevelType = 'dragexit'; +export const TOP_DRAG_LEAVE: TopLevelType = 'dragleave'; +export const TOP_DRAG_OVER: TopLevelType = 'dragover'; +export const TOP_DRAG_START: TopLevelType = 'dragstart'; +export const TOP_DROP: TopLevelType = 'drop'; +export const TOP_DURATION_CHANGE: TopLevelType = 'durationchange'; +export const TOP_EMPTIED: TopLevelType = 'emptied'; +export const TOP_ENCRYPTED: TopLevelType = 'encrypted'; +export const TOP_ENDED: TopLevelType = 'ended'; +export const TOP_ERROR: TopLevelType = 'error'; +export const TOP_FOCUS: TopLevelType = 'focus'; +export const TOP_INPUT: TopLevelType = 'input'; +export const TOP_INVALID: TopLevelType = 'invalid'; +export const TOP_KEY_DOWN: TopLevelType = 'keydown'; +export const TOP_KEY_PRESS: TopLevelType = 'keypress'; +export const TOP_KEY_UP: TopLevelType = 'keyup'; +export const TOP_LOAD: TopLevelType = 'load'; +export const TOP_LOAD_START: TopLevelType = 'loadstart'; +export const TOP_LOADED_DATA: TopLevelType = 'loadeddata'; +export const TOP_LOADED_METADATA: TopLevelType = 'loadedmetadata'; +export const TOP_MOUSE_DOWN: TopLevelType = 'mousedown'; +export const TOP_MOUSE_MOVE: TopLevelType = 'mousemove'; +export const TOP_MOUSE_OUT: TopLevelType = 'mouseout'; +export const TOP_MOUSE_OVER: TopLevelType = 'mouseover'; +export const TOP_MOUSE_UP: TopLevelType = 'mouseup'; +export const TOP_PASTE: TopLevelType = 'paste'; +export const TOP_PAUSE: TopLevelType = 'pause'; +export const TOP_PLAY: TopLevelType = 'play'; +export const TOP_PLAYING: TopLevelType = 'playing'; +export const TOP_PROGRESS: TopLevelType = 'progress'; +export const TOP_RATE_CHANGE: TopLevelType = 'ratechange'; +export const TOP_RESET: TopLevelType = 'reset'; +export const TOP_SCROLL: TopLevelType = 'scroll'; +export const TOP_SEEKED: TopLevelType = 'seeked'; +export const TOP_SEEKING: TopLevelType = 'seeking'; +export const TOP_SELECTION_CHANGE: TopLevelType = 'selectionchange'; +export const TOP_STALLED: TopLevelType = 'stalled'; +export const TOP_SUBMIT: TopLevelType = 'submit'; +export const TOP_SUSPEND: TopLevelType = 'suspend'; +export const TOP_TEXT_INPUT: TopLevelType = 'textInput'; +export const TOP_TIME_UPDATE: TopLevelType = 'timeupdate'; +export const TOP_TOGGLE: TopLevelType = 'toggle'; +export const TOP_TOUCH_CANCEL: TopLevelType = 'touchcancel'; +export const TOP_TOUCH_END: TopLevelType = 'touchend'; +export const TOP_TOUCH_MOVE: TopLevelType = 'touchmove'; +export const TOP_TOUCH_START: TopLevelType = 'touchstart'; +export const TOP_TRANSITION_END: TopLevelType = getVendorPrefixedEventName( 'transitionend', -): any): TopLevelType); -export const TOP_VOLUME_CHANGE = (('volumechange': any): TopLevelType); -export const TOP_WAITING = (('waiting': any): TopLevelType); -export const TOP_WHEEL = (('wheel': any): TopLevelType); +); +export const TOP_VOLUME_CHANGE: TopLevelType = 'volumechange'; +export const TOP_WAITING: TopLevelType = 'waiting'; +export const TOP_WHEEL: TopLevelType = 'wheel'; -export const mediaEventTypes = [ +export const mediaEventTypes: Array = [ TOP_ABORT, TOP_CAN_PLAY, TOP_CAN_PLAY_THROUGH, @@ -117,5 +191,5 @@ export const mediaEventTypes = [ ]; export function getRawEventName(topLevelType: TopLevelType): string { - return (topLevelType: any); + return topLevelType; } diff --git a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js index 332b5d44c6801..7b56d54d691c1 100644 --- a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js +++ b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js @@ -9,18 +9,16 @@ import createResponderEventPlugin from 'events/createResponderEventPlugin'; -import type {TopLevelType} from 'events/TopLevelEventTypes'; - const TopLevelTypes = { - topMouseDown: (('topMouseDown': any): TopLevelType), - topMouseMove: (('topMouseMove': any): TopLevelType), - topMouseUp: (('topMouseUp': any): TopLevelType), - topScroll: (('topScroll': any): TopLevelType), - topSelectionChange: (('topSelectionChange': any): TopLevelType), - topTouchCancel: (('topTouchCancel': any): TopLevelType), - topTouchEnd: (('topTouchEnd': any): TopLevelType), - topTouchMove: (('topTouchMove': any): TopLevelType), - topTouchStart: (('topTouchStart': any): TopLevelType), + topMouseDown: 'topMouseDown', + topMouseMove: 'topMouseMove', + topMouseUp: 'topMouseUp', + topScroll: 'topScroll', + topSelectionChange: 'topSelectionChange', + topTouchCancel: 'topTouchCancel', + topTouchEnd: 'topTouchEnd', + topTouchMove: 'topTouchMove', + topTouchStart: 'topTouchStart', }; const {ResponderEventPlugin} = createResponderEventPlugin(TopLevelTypes); From 3ebd35957add71e2e5923b3cf730003cc1a1814d Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 25 Apr 2018 01:24:13 +0200 Subject: [PATCH 34/45] Revert Map changes of ReactBrowserEventEmitter --- .../src/events/ReactBrowserEventEmitter.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/react-dom/src/events/ReactBrowserEventEmitter.js b/packages/react-dom/src/events/ReactBrowserEventEmitter.js index 5c8a0aaacb841..a8fd4495e35d6 100644 --- a/packages/react-dom/src/events/ReactBrowserEventEmitter.js +++ b/packages/react-dom/src/events/ReactBrowserEventEmitter.js @@ -91,7 +91,7 @@ function getListeningForDocument(mountAt) { // directly. if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) { mountAt[topListenersIDKey] = reactTopListenersCounter++; - alreadyListeningTo[mountAt[topListenersIDKey]] = new Map(); + alreadyListeningTo[mountAt[topListenersIDKey]] = {}; } return alreadyListeningTo[mountAt[topListenersIDKey]]; } @@ -124,7 +124,7 @@ export function listenTo(registrationName, contentDocumentHandle) { for (let i = 0; i < dependencies.length; i++) { const dependency = dependencies[i]; - if (!isListening.get(dependency)) { + if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) { if (dependency === TOP_SCROLL) { trapCapturedEvent(TOP_SCROLL, mountAt); } else if (dependency === TOP_FOCUS || dependency === TOP_BLUR) { @@ -132,23 +132,23 @@ export function listenTo(registrationName, contentDocumentHandle) { trapCapturedEvent(TOP_BLUR, mountAt); // to make sure blur and focus event listeners are only attached once - isListening.set(TOP_BLUR, true); - isListening.set(TOP_FOCUS, true); + isListening[TOP_BLUR] = true; + isListening[TOP_FOCUS] = true; } else if (dependency === TOP_CANCEL) { if (isEventSupported('cancel', true)) { trapCapturedEvent(TOP_CANCEL, mountAt); } - isListening.set(TOP_CANCEL, true); + isListening[TOP_CANCEL] = true; } else if (dependency === TOP_CLOSE) { if (isEventSupported('close', true)) { trapCapturedEvent(TOP_CLOSE, mountAt); } - isListening.set(TOP_CLOSE, true); + isListening[TOP_CLOSE] = true; } else if (getRawEventName(dependency)) { trapBubbledEvent(dependency, mountAt); } - isListening.set(dependency, true); + isListening[dependency] = true; } } } @@ -158,7 +158,7 @@ export function isListeningToAllDependencies(registrationName, mountAt) { const dependencies = registrationNameDependencies[registrationName]; for (let i = 0; i < dependencies.length; i++) { const dependency = dependencies[i]; - if (!isListening.get(dependency)) { + if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) { return false; } } From 6095b0f687d69feb8cee1bb06174df05f9592c4c Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 25 Apr 2018 01:27:56 +0200 Subject: [PATCH 35/45] Upgrade babel-* packages Apparently local unit tests also have issues with parsing JavaScript modules that contain opaque types (not sure why I didn't notice earlier!?). --- yarn.lock | 1527 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 1072 insertions(+), 455 deletions(-) diff --git a/yarn.lock b/yarn.lock index 6b98132b9de31..8a235cc4418b4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,13 +2,11 @@ # yarn lockfile v1 -"@babel/code-frame@7.0.0-beta.36": - version "7.0.0-beta.36" - resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.36.tgz#2349d7ec04b3a06945ae173280ef8579b63728e4" +"@babel/code-frame@7.0.0-beta.44": + version "7.0.0-beta.44" + resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz#2a02643368de80916162be70865c97774f3adbd9" dependencies: - chalk "^2.0.0" - esutils "^2.0.2" - js-tokens "^3.0.0" + "@babel/highlight" "7.0.0-beta.44" "@babel/code-frame@^7.0.0-beta.35": version "7.0.0-beta.38" @@ -18,45 +16,71 @@ esutils "^2.0.2" js-tokens "^3.0.0" -"@babel/helper-function-name@7.0.0-beta.36": - version "7.0.0-beta.36" - resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.36.tgz#366e3bc35147721b69009f803907c4d53212e88d" +"@babel/generator@7.0.0-beta.44": + version "7.0.0-beta.44" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.0.0-beta.44.tgz#c7e67b9b5284afcf69b309b50d7d37f3e5033d42" + dependencies: + "@babel/types" "7.0.0-beta.44" + jsesc "^2.5.1" + lodash "^4.2.0" + source-map "^0.5.0" + trim-right "^1.0.1" + +"@babel/helper-function-name@7.0.0-beta.44": + version "7.0.0-beta.44" + resolved "https://registry.yarnpkg.com/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.44.tgz#e18552aaae2231100a6e485e03854bc3532d44dd" + dependencies: + "@babel/helper-get-function-arity" "7.0.0-beta.44" + "@babel/template" "7.0.0-beta.44" + "@babel/types" "7.0.0-beta.44" + +"@babel/helper-get-function-arity@7.0.0-beta.44": + version "7.0.0-beta.44" + resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.44.tgz#d03ca6dd2b9f7b0b1e6b32c56c72836140db3a15" + dependencies: + "@babel/types" "7.0.0-beta.44" + +"@babel/helper-split-export-declaration@7.0.0-beta.44": + version "7.0.0-beta.44" + resolved "https://registry.yarnpkg.com/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0-beta.44.tgz#c0b351735e0fbcb3822c8ad8db4e583b05ebd9dc" dependencies: - "@babel/helper-get-function-arity" "7.0.0-beta.36" - "@babel/template" "7.0.0-beta.36" - "@babel/types" "7.0.0-beta.36" + "@babel/types" "7.0.0-beta.44" -"@babel/helper-get-function-arity@7.0.0-beta.36": - version "7.0.0-beta.36" - resolved "https://registry.yarnpkg.com/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.36.tgz#f5383bac9a96b274828b10d98900e84ee43e32b8" +"@babel/highlight@7.0.0-beta.44": + version "7.0.0-beta.44" + resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0-beta.44.tgz#18c94ce543916a80553edcdcf681890b200747d5" dependencies: - "@babel/types" "7.0.0-beta.36" + chalk "^2.0.0" + esutils "^2.0.2" + js-tokens "^3.0.0" -"@babel/template@7.0.0-beta.36": - version "7.0.0-beta.36" - resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0-beta.36.tgz#02e903de5d68bd7899bce3c5b5447e59529abb00" +"@babel/template@7.0.0-beta.44": + version "7.0.0-beta.44" + resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.0.0-beta.44.tgz#f8832f4fdcee5d59bf515e595fc5106c529b394f" dependencies: - "@babel/code-frame" "7.0.0-beta.36" - "@babel/types" "7.0.0-beta.36" - babylon "7.0.0-beta.36" + "@babel/code-frame" "7.0.0-beta.44" + "@babel/types" "7.0.0-beta.44" + babylon "7.0.0-beta.44" lodash "^4.2.0" -"@babel/traverse@7.0.0-beta.36": - version "7.0.0-beta.36" - resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.0.0-beta.36.tgz#1dc6f8750e89b6b979de5fe44aa993b1a2192261" +"@babel/traverse@7.0.0-beta.44": + version "7.0.0-beta.44" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.0.0-beta.44.tgz#a970a2c45477ad18017e2e465a0606feee0d2966" dependencies: - "@babel/code-frame" "7.0.0-beta.36" - "@babel/helper-function-name" "7.0.0-beta.36" - "@babel/types" "7.0.0-beta.36" - babylon "7.0.0-beta.36" - debug "^3.0.1" + "@babel/code-frame" "7.0.0-beta.44" + "@babel/generator" "7.0.0-beta.44" + "@babel/helper-function-name" "7.0.0-beta.44" + "@babel/helper-split-export-declaration" "7.0.0-beta.44" + "@babel/types" "7.0.0-beta.44" + babylon "7.0.0-beta.44" + debug "^3.1.0" globals "^11.1.0" invariant "^2.2.0" lodash "^4.2.0" -"@babel/types@7.0.0-beta.36": - version "7.0.0-beta.36" - resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0-beta.36.tgz#64f2004353de42adb72f9ebb4665fc35b5499d23" +"@babel/types@7.0.0-beta.44": + version "7.0.0-beta.44" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0-beta.44.tgz#6b1b164591f77dec0a0342aca995f2d046b3a757" dependencies: esutils "^2.0.2" lodash "^4.2.0" @@ -78,8 +102,8 @@ abab@^1.0.3: resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.3.tgz#b81de5f7274ec4e756d797cd834f303642724e5d" abbrev@1: - version "1.1.0" - resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.0.tgz#d0554c2256636e2f56e7c2e5ad183f859428d81f" + version "1.1.1" + resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" acorn-globals@^4.0.0: version "4.1.0" @@ -123,13 +147,6 @@ ajv-keywords@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762" -ajv@^4.9.1: - version "4.11.7" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.7.tgz#8655a5d86d0824985cc471a1d913fb6729a0ec48" - dependencies: - co "^4.6.0" - json-stable-stringify "^1.0.1" - ajv@^5.1.0, ajv@^5.2.3, ajv@^5.3.0: version "5.5.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" @@ -173,11 +190,11 @@ ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" -ansi-styles@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.1.0.tgz#09c202d5c917ec23188caa5c9cb9179cd9547750" +ansi-styles@^3.1.0, ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" dependencies: - color-convert "^1.0.0" + color-convert "^1.9.0" ansi-styles@^3.2.0: version "3.2.0" @@ -186,11 +203,11 @@ ansi-styles@^3.2.0: color-convert "^1.9.0" anymatch@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.0.tgz#a3e52fa39168c825ff57b0248126ce5a8ff95507" + version "1.3.2" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-1.3.2.tgz#553dcb8f91e3c889845dfdba34c77721b90b9d7a" dependencies: - arrify "^1.0.0" micromatch "^2.1.5" + normalize-path "^2.0.0" append-transform@^0.4.0: version "0.4.0" @@ -199,8 +216,8 @@ append-transform@^0.4.0: default-require-extensions "^1.0.0" aproba@^1.0.3: - version "1.1.1" - resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.1.1.tgz#95d3600f07710aa0e9298c726ad5ecf2eacbabab" + version "1.2.0" + resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" are-we-there-yet@~1.1.2: version "1.1.4" @@ -221,9 +238,17 @@ arr-diff@^2.0.0: dependencies: arr-flatten "^1.0.1" -arr-flatten@^1.0.1: - version "1.0.3" - resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.0.3.tgz#a274ed85ac08849b6bd7847c4580745dc51adfb1" +arr-diff@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" + +arr-flatten@^1.0.1, arr-flatten@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" + +arr-union@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" array-differ@^1.0.0: version "1.0.0" @@ -247,6 +272,10 @@ array-unique@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53" +array-unique@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" + array.prototype.find@2.0.4, array.prototype.find@^2.0.1: version "2.0.4" resolved "https://registry.yarnpkg.com/array.prototype.find/-/array.prototype.find-2.0.4.tgz#556a5c5362c08648323ddaeb9de9d14bc1864c90" @@ -278,6 +307,10 @@ assert-plus@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-0.2.0.tgz#d74e1b87e7affc0db8aadb7021f3fe48101ab234" +assign-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" + ast-traverse@~0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/ast-traverse/-/ast-traverse-0.1.1.tgz#69cf2b8386f19dcda1bb1e05d68fe359d8897de6" @@ -312,6 +345,10 @@ asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" +atob@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.0.tgz#ab2b150e51d7b122b9efc8d7340c06b6c41076bc" + aws-sign2@~0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.6.0.tgz#14342dd38dbcc94d0e5b87d763cd63612c0e794f" @@ -320,40 +357,36 @@ aws-sign2@~0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" -aws4@^1.2.1, aws4@^1.6.0: +aws4@^1.2.1: + version "1.7.0" + resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.7.0.tgz#d4d0e9b9dbfca77bf08eeb0a8a471550fe39e289" + +aws4@^1.6.0: version "1.6.0" resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e" babel-cli@^6.6.5: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-cli/-/babel-cli-6.24.1.tgz#207cd705bba61489b2ea41b5312341cf6aca2283" + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-cli/-/babel-cli-6.26.0.tgz#502ab54874d7db88ad00b887a06383ce03d002f1" dependencies: - babel-core "^6.24.1" - babel-polyfill "^6.23.0" - babel-register "^6.24.1" - babel-runtime "^6.22.0" - commander "^2.8.1" - convert-source-map "^1.1.0" + babel-core "^6.26.0" + babel-polyfill "^6.26.0" + babel-register "^6.26.0" + babel-runtime "^6.26.0" + commander "^2.11.0" + convert-source-map "^1.5.0" fs-readdir-recursive "^1.0.0" - glob "^7.0.0" - lodash "^4.2.0" - output-file-sync "^1.1.0" - path-is-absolute "^1.0.0" + glob "^7.1.2" + lodash "^4.17.4" + output-file-sync "^1.1.2" + path-is-absolute "^1.0.1" slash "^1.0.0" - source-map "^0.5.0" - v8flags "^2.0.10" + source-map "^0.5.6" + v8flags "^2.1.1" optionalDependencies: chokidar "^1.6.1" -babel-code-frame@^6.22.0: - version "6.22.0" - resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.22.0.tgz#027620bee567a88c32561574e7fd0801d33118e4" - dependencies: - chalk "^1.1.0" - esutils "^2.0.2" - js-tokens "^3.0.0" - -babel-code-frame@^6.26.0: +babel-code-frame@^6.22.0, babel-code-frame@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" dependencies: @@ -412,52 +445,52 @@ babel-core@^5.6.21: trim-right "^1.0.0" try-resolve "^1.0.0" -babel-core@^6.0.0, babel-core@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.24.1.tgz#8c428564dce1e1f41fb337ec34f4c3b022b5ad83" +babel-core@^6.0.0, babel-core@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.26.0.tgz#af32f78b31a6fcef119c87b0fd8d9753f03a0bb8" dependencies: - babel-code-frame "^6.22.0" - babel-generator "^6.24.1" + babel-code-frame "^6.26.0" + babel-generator "^6.26.0" babel-helpers "^6.24.1" babel-messages "^6.23.0" - babel-register "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - babylon "^6.11.0" - convert-source-map "^1.1.0" - debug "^2.1.1" - json5 "^0.5.0" - lodash "^4.2.0" - minimatch "^3.0.2" - path-is-absolute "^1.0.0" - private "^0.1.6" + babel-register "^6.26.0" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + convert-source-map "^1.5.0" + debug "^2.6.8" + json5 "^0.5.1" + lodash "^4.17.4" + minimatch "^3.0.4" + path-is-absolute "^1.0.1" + private "^0.1.7" slash "^1.0.0" - source-map "^0.5.0" + source-map "^0.5.6" babel-eslint@^8.0.0: - version "8.2.1" - resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-8.2.1.tgz#136888f3c109edc65376c23ebf494f36a3e03951" + version "8.2.3" + resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-8.2.3.tgz#1a2e6681cc9bc4473c32899e59915e19cd6733cf" dependencies: - "@babel/code-frame" "7.0.0-beta.36" - "@babel/traverse" "7.0.0-beta.36" - "@babel/types" "7.0.0-beta.36" - babylon "7.0.0-beta.36" + "@babel/code-frame" "7.0.0-beta.44" + "@babel/traverse" "7.0.0-beta.44" + "@babel/types" "7.0.0-beta.44" + babylon "7.0.0-beta.44" eslint-scope "~3.7.1" eslint-visitor-keys "^1.0.0" -babel-generator@^6.18.0, babel-generator@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.24.1.tgz#e715f486c58ded25649d888944d52aa07c5d9497" +babel-generator@^6.18.0, babel-generator@^6.26.0: + version "6.26.1" + resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.1.tgz#1844408d3b8f0d35a404ea7ac180f087a601bd90" dependencies: babel-messages "^6.23.0" - babel-runtime "^6.22.0" - babel-types "^6.24.1" + babel-runtime "^6.26.0" + babel-types "^6.26.0" detect-indent "^4.0.0" jsesc "^1.3.0" - lodash "^4.2.0" - source-map "^0.5.0" + lodash "^4.17.4" + source-map "^0.5.7" trim-right "^1.0.1" babel-helper-builder-react-jsx@^6.24.1: @@ -546,11 +579,11 @@ babel-helpers@^6.24.1: babel-template "^6.24.1" babel-jest@^22.0.6: - version "22.0.6" - resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-22.0.6.tgz#807a2a5f5fad7789c57174a955cd14b11045299f" + version "22.4.3" + resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-22.4.3.tgz#4b7a0b6041691bbd422ab49b3b73654a49a6627a" dependencies: babel-plugin-istanbul "^4.1.5" - babel-preset-jest "^22.0.6" + babel-preset-jest "^22.4.3" babel-messages@^6.23.0: version "6.23.0" @@ -587,16 +620,17 @@ babel-plugin-inline-environment-variables@^1.0.1: resolved "https://registry.yarnpkg.com/babel-plugin-inline-environment-variables/-/babel-plugin-inline-environment-variables-1.0.1.tgz#1f58ce91207ad6a826a8bf645fafe68ff5fe3ffe" babel-plugin-istanbul@^4.1.5: - version "4.1.5" - resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.5.tgz#6760cdd977f411d3e175bb064f2bc327d99b2b6e" + version "4.1.6" + resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-4.1.6.tgz#36c59b2192efce81c5b378321b74175add1c9a45" dependencies: + babel-plugin-syntax-object-rest-spread "^6.13.0" find-up "^2.1.0" - istanbul-lib-instrument "^1.7.5" - test-exclude "^4.1.1" + istanbul-lib-instrument "^1.10.1" + test-exclude "^4.2.1" -babel-plugin-jest-hoist@^22.0.6: - version "22.0.6" - resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-22.0.6.tgz#551269ded350a15d6585da35d16d449df30d66c4" +babel-plugin-jest-hoist@^22.4.3: + version "22.4.3" + resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-22.4.3.tgz#7d8bcccadc2667f96a0dcc6afe1891875ee6c14a" babel-plugin-jscript@^1.0.4: version "1.0.4" @@ -690,14 +724,14 @@ babel-plugin-transform-es2015-block-scoped-functions@^6.5.0: babel-runtime "^6.22.0" babel-plugin-transform-es2015-block-scoping@^6.23.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.24.1.tgz#76c295dc3a4741b1665adfd3167215dcff32a576" + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-block-scoping/-/babel-plugin-transform-es2015-block-scoping-6.26.0.tgz#d70f5299c1308d05c12f463813b0a09e73b1895f" dependencies: - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - lodash "^4.2.0" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + lodash "^4.17.4" babel-plugin-transform-es2015-classes@^6.5.2: version "6.24.1" @@ -739,13 +773,13 @@ babel-plugin-transform-es2015-literals@^6.5.0: babel-runtime "^6.22.0" babel-plugin-transform-es2015-modules-commonjs@^6.5.2: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.24.1.tgz#d3e310b40ef664a36622200097c6d440298f2bfe" + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-es2015-modules-commonjs/-/babel-plugin-transform-es2015-modules-commonjs-6.26.0.tgz#0d8394029b7dc6abe1a97ef181e00758dd2e5d8a" dependencies: babel-plugin-transform-strict-mode "^6.24.1" - babel-runtime "^6.22.0" - babel-template "^6.24.1" - babel-types "^6.24.1" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-types "^6.26.0" babel-plugin-transform-es2015-object-super@^6.5.0: version "6.24.1" @@ -803,20 +837,13 @@ babel-plugin-transform-flow-strip-types@^6.22.0: babel-plugin-syntax-flow "^6.18.0" babel-runtime "^6.22.0" -babel-plugin-transform-object-rest-spread@^6.20.2: +babel-plugin-transform-object-rest-spread@^6.20.2, babel-plugin-transform-object-rest-spread@^6.6.5: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.26.0.tgz#0f36692d50fef6b7e2d4b3ac1478137a963b7b06" dependencies: babel-plugin-syntax-object-rest-spread "^6.8.0" babel-runtime "^6.26.0" -babel-plugin-transform-object-rest-spread@^6.6.5: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-plugin-transform-object-rest-spread/-/babel-plugin-transform-object-rest-spread-6.23.0.tgz#875d6bc9be761c58a2ae3feee5dc4895d8c7f921" - dependencies: - babel-plugin-syntax-object-rest-spread "^6.8.0" - babel-runtime "^6.22.0" - babel-plugin-transform-react-display-name@^6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-react-display-name/-/babel-plugin-transform-react-display-name-6.23.0.tgz#4398910c358441dc4cef18787264d0412ed36b37" @@ -868,13 +895,13 @@ babel-plugin-undefined-to-void@^1.1.6: version "1.1.6" resolved "https://registry.yarnpkg.com/babel-plugin-undefined-to-void/-/babel-plugin-undefined-to-void-1.1.6.tgz#7f578ef8b78dfae6003385d8417a61eda06e2f81" -babel-polyfill@^6.23.0: - version "6.23.0" - resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.23.0.tgz#8364ca62df8eafb830499f699177466c3b03499d" +babel-polyfill@^6.23.0, babel-polyfill@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-polyfill/-/babel-polyfill-6.26.0.tgz#379937abc67d7895970adc621f284cd966cf2153" dependencies: - babel-runtime "^6.22.0" - core-js "^2.4.0" - regenerator-runtime "^0.10.0" + babel-runtime "^6.26.0" + core-js "^2.5.0" + regenerator-runtime "^0.10.5" babel-preset-flow@^6.23.0: version "6.23.0" @@ -882,11 +909,11 @@ babel-preset-flow@^6.23.0: dependencies: babel-plugin-transform-flow-strip-types "^6.22.0" -babel-preset-jest@^22.0.6: - version "22.0.6" - resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-22.0.6.tgz#d13202533db9495c98663044d9f51b273d3984c8" +babel-preset-jest@^22.4.3: + version "22.4.3" + resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-22.4.3.tgz#e92eef9813b7026ab4ca675799f37419b5a44156" dependencies: - babel-plugin-jest-hoist "^22.0.6" + babel-plugin-jest-hoist "^22.4.3" babel-plugin-syntax-object-rest-spread "^6.13.0" babel-preset-react@^6.5.0: @@ -900,66 +927,57 @@ babel-preset-react@^6.5.0: babel-plugin-transform-react-jsx-source "^6.22.0" babel-preset-flow "^6.23.0" -babel-register@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.24.1.tgz#7e10e13a2f71065bdfad5a1787ba45bca6ded75f" +babel-register@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.26.0.tgz#6ed021173e2fcb486d7acb45c6009a856f647071" dependencies: - babel-core "^6.24.1" - babel-runtime "^6.22.0" - core-js "^2.4.0" + babel-core "^6.26.0" + babel-runtime "^6.26.0" + core-js "^2.5.0" home-or-tmp "^2.0.0" - lodash "^4.2.0" + lodash "^4.17.4" mkdirp "^0.5.1" - source-map-support "^0.4.2" + source-map-support "^0.4.15" -babel-runtime@6.23.0, babel-runtime@^6.22.0: +babel-runtime@6.23.0: version "6.23.0" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.23.0.tgz#0a9489f144de70efb3ce4300accdb329e2fc543b" dependencies: core-js "^2.4.0" regenerator-runtime "^0.10.0" -babel-runtime@^6.18.0, babel-runtime@^6.26.0: +babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" dependencies: core-js "^2.4.0" regenerator-runtime "^0.11.0" -babel-template@^6.16.0, babel-template@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.24.1.tgz#04ae514f1f93b3a2537f2a0f60a5a45fb8308333" +babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02" dependencies: - babel-runtime "^6.22.0" - babel-traverse "^6.24.1" - babel-types "^6.24.1" - babylon "^6.11.0" - lodash "^4.2.0" + babel-runtime "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + lodash "^4.17.4" -babel-traverse@^6.18.0, babel-traverse@^6.24.1, babel-traverse@^6.9.0: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.24.1.tgz#ab36673fd356f9a0948659e7b338d5feadb31695" +babel-traverse@^6.18.0, babel-traverse@^6.24.1, babel-traverse@^6.26.0, babel-traverse@^6.9.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" dependencies: - babel-code-frame "^6.22.0" + babel-code-frame "^6.26.0" babel-messages "^6.23.0" - babel-runtime "^6.22.0" - babel-types "^6.24.1" - babylon "^6.15.0" - debug "^2.2.0" - globals "^9.0.0" - invariant "^2.2.0" - lodash "^4.2.0" - -babel-types@^6.18.0, babel-types@^6.24.1: - version "6.24.1" - resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.24.1.tgz#a136879dc15b3606bda0d90c1fc74304c2ff0975" - dependencies: - babel-runtime "^6.22.0" - esutils "^2.0.2" - lodash "^4.2.0" - to-fast-properties "^1.0.1" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + debug "^2.6.8" + globals "^9.18.0" + invariant "^2.2.2" + lodash "^4.17.4" -babel-types@^6.19.0: +babel-types@^6.18.0, babel-types@^6.19.0, babel-types@^6.24.1, babel-types@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" dependencies: @@ -989,30 +1007,30 @@ babylon@6.18.0, babylon@^6.18.0: version "6.18.0" resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" -babylon@7.0.0-beta.36: - version "7.0.0-beta.36" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.36.tgz#3a3683ba6a9a1e02b0aa507c8e63435e39305b9e" +babylon@7.0.0-beta.44: + version "7.0.0-beta.44" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-7.0.0-beta.44.tgz#89159e15e6e30c5096e22d738d8c0af8a0e8ca1d" babylon@^5.8.38: version "5.8.38" resolved "https://registry.yarnpkg.com/babylon/-/babylon-5.8.38.tgz#ec9b120b11bf6ccd4173a18bf217e60b79859ffd" -babylon@^6.11.0: - version "6.15.0" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.15.0.tgz#ba65cfa1a80e1759b0e89fb562e27dccae70348e" - -babylon@^6.15.0: - version "6.17.0" - resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.17.0.tgz#37da948878488b9c4e3c4038893fa3314b3fc932" - -balanced-match@^0.4.1: - version "0.4.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-0.4.2.tgz#cb3f3e3c732dc0f01ee70b403f302e61d7709838" - balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" +base@^0.11.1: + version "0.11.2" + resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f" + dependencies: + cache-base "^1.0.1" + class-utils "^0.3.5" + component-emitter "^1.2.1" + define-property "^1.0.0" + isobject "^3.0.1" + mixin-deep "^1.2.0" + pascalcase "^0.1.1" + bcrypt-pbkdf@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.1.tgz#63bc5dcb61331b92bc05fd528953c33462a06f8d" @@ -1024,8 +1042,8 @@ beeper@^1.0.0: resolved "https://registry.yarnpkg.com/beeper/-/beeper-1.1.1.tgz#e6d5ea8c5dad001304a70b22638447f69cb2f809" binary-extensions@^1.0.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.8.0.tgz#48ec8d16df4377eae5fa5884682480af4d95c774" + version "1.11.0" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.11.0.tgz#46aa1751fb6a2f93ee5e689bb1087d4b14c6c205" bl@^1.0.0: version "1.2.1" @@ -1062,10 +1080,10 @@ boom@5.x.x: hoek "4.x.x" brace-expansion@^1.0.0: - version "1.1.7" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.7.tgz#3effc3c50e000531fb720eaff80f0ae8ef23cf59" + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" dependencies: - balanced-match "^0.4.1" + balanced-match "^1.0.0" concat-map "0.0.1" brace-expansion@^1.1.7: @@ -1083,6 +1101,21 @@ braces@^1.8.2: preserve "^0.2.0" repeat-element "^1.1.2" +braces@^2.3.1: + version "2.3.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" + dependencies: + arr-flatten "^1.1.0" + array-unique "^0.3.2" + extend-shallow "^2.0.1" + fill-range "^4.0.0" + isobject "^3.0.1" + repeat-element "^1.1.2" + snapdragon "^0.8.1" + snapdragon-node "^2.0.1" + split-string "^3.0.2" + to-regex "^3.0.1" + breakable@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/breakable/-/breakable-1.0.0.tgz#784a797915a38ead27bad456b5572cb4bbaa78c1" @@ -1141,6 +1174,20 @@ bundle-collapser@^1.1.1: minimist "^1.1.1" through2 "^2.0.0" +cache-base@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2" + dependencies: + collection-visit "^1.0.0" + component-emitter "^1.2.1" + get-value "^2.0.6" + has-value "^1.0.0" + isobject "^3.0.1" + set-value "^2.0.0" + to-object-path "^0.3.0" + union-value "^1.0.0" + unset-value "^1.0.0" + caller-path@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f" @@ -1182,7 +1229,7 @@ center-align@^0.1.1: align-text "^0.1.3" lazy-cache "^1.0.3" -chalk@*, chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3: +chalk@*, chalk@^1.0.0, chalk@^1.1.1, chalk@^1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" dependencies: @@ -1192,13 +1239,13 @@ chalk@*, chalk@^1.0.0, chalk@^1.1.0, chalk@^1.1.1, chalk@^1.1.3: strip-ansi "^3.0.0" supports-color "^2.0.0" -chalk@^2.0.0, chalk@^2.1.0, chalk@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba" +chalk@^2.0.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.0.tgz#a060a297a6b57e15b61ca63ce84995daa0fe6e52" dependencies: - ansi-styles "^3.1.0" + ansi-styles "^3.2.1" escape-string-regexp "^1.0.5" - supports-color "^4.0.0" + supports-color "^5.3.0" chalk@^2.0.1: version "2.0.1" @@ -1208,11 +1255,19 @@ chalk@^2.0.1: escape-string-regexp "^1.0.5" supports-color "^4.0.0" +chalk@^2.1.0, chalk@^2.3.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba" + dependencies: + ansi-styles "^3.1.0" + escape-string-regexp "^1.0.5" + supports-color "^4.0.0" + chardet@^0.4.0: version "0.4.2" resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" -chokidar@^1.0.0, chokidar@^1.6.1: +chokidar@^1.0.0: version "1.6.1" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.6.1.tgz#2f4447ab5e96e50fb3d789fd90d4c72e0e4c70c2" dependencies: @@ -1227,6 +1282,21 @@ chokidar@^1.0.0, chokidar@^1.6.1: optionalDependencies: fsevents "^1.0.0" +chokidar@^1.6.1: + version "1.7.0" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468" + dependencies: + anymatch "^1.3.0" + async-each "^1.0.0" + glob-parent "^2.0.0" + inherits "^2.0.1" + is-binary-path "^1.0.0" + is-glob "^2.0.0" + path-is-absolute "^1.0.0" + readdirp "^2.0.0" + optionalDependencies: + fsevents "^1.0.0" + chownr@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.0.1.tgz#e2a75042a9551908bebd25b8523d5f9769d79181" @@ -1239,6 +1309,15 @@ circular-json@^0.3.1: version "0.3.1" resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.1.tgz#be8b36aefccde8b3ca7aa2d6afc07a37242c0d2d" +class-utils@^0.3.5: + version "0.3.6" + resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" + dependencies: + arr-union "^3.1.0" + define-property "^0.2.5" + isobject "^3.0.0" + static-extend "^0.1.1" + cli-cursor@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5" @@ -1319,15 +1398,22 @@ coffee-script@^1.8.0: version "1.12.5" resolved "https://registry.yarnpkg.com/coffee-script/-/coffee-script-1.12.5.tgz#809f4585419112bbfe46a073ad7543af18c27346" -color-convert@^1.0.0, color-convert@^1.9.0: +collection-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" + dependencies: + map-visit "^1.0.0" + object-visit "^1.0.0" + +color-convert@^1.9.0: version "1.9.0" resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.0.tgz#1accf97dd739b983bf994d56fec8f95853641b7a" dependencies: color-name "^1.1.1" color-name@^1.1.1: - version "1.1.2" - resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.2.tgz#5c8ab72b64bd2215d617ae9559ebb148475cf98d" + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" colors@1.0.3: version "1.0.3" @@ -1347,16 +1433,20 @@ combine-source-map@~0.6.1: source-map "~0.4.2" combined-stream@^1.0.5, combined-stream@~1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.5.tgz#938370a57b4a51dea2c77c15d5c5fdf895164009" + version "1.0.6" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818" dependencies: delayed-stream "~1.0.0" +commander@^2.11.0: + version "2.15.1" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.15.1.tgz#df46e867d0fc2aec66a34662b406a9ccafff5b0f" + commander@^2.12.2: version "2.12.2" resolved "https://registry.yarnpkg.com/commander/-/commander-2.12.2.tgz#0f5946c427ed9ec0d91a46bb9def53e54650e555" -commander@^2.5.0, commander@^2.6.0, commander@^2.8.1, commander@^2.9.0: +commander@^2.5.0, commander@^2.6.0, commander@^2.9.0: version "2.9.0" resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" dependencies: @@ -1376,6 +1466,10 @@ commoner@~0.10.3: q "^1.1.2" recast "^0.11.17" +component-emitter@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" + concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" @@ -1404,7 +1498,11 @@ content-type-parser@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/content-type-parser/-/content-type-parser-1.0.1.tgz#c3e56988c53c65127fb46d4032a3a900246fdc94" -convert-source-map@^1.1.0, convert-source-map@^1.4.0: +convert-source-map@^1.1.0, convert-source-map@^1.5.0: + version "1.5.1" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.1.tgz#b8278097b9bc229365de5c62cf5fcaed8b5599e5" + +convert-source-map@^1.4.0: version "1.5.0" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.5.0.tgz#9acd70851c6d5dfdd93d9282e5edf94a03ff46b5" @@ -1412,15 +1510,23 @@ convert-source-map@~1.1.0: version "1.1.3" resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.1.3.tgz#4829c877e9fe49b3161f3bf3673888e204699860" +copy-descriptor@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" + core-js@^1.0.0: version "1.2.7" resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" -core-js@^2.2.1, core-js@^2.4.0: +core-js@^2.2.1: version "2.4.1" resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.4.1.tgz#4de911e667b0eae9124e34254b53aea6fc618d3e" -core-util-is@~1.0.0: +core-js@^2.4.0, core-js@^2.5.0: + version "2.5.5" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.5.tgz#b14dde936c640c0579a6b50cabcc132dd6127e3b" + +core-util-is@1.0.2, core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -1553,11 +1659,11 @@ dateformat@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/dateformat/-/dateformat-2.0.0.tgz#2743e3abb5c3fc2462e527dca445e04e9f4dee17" -debug@^2.1.1, debug@^2.2.0: - version "2.6.6" - resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.6.tgz#a9fa6fbe9ca43cf1e79f73b75c0189cbb7d6db5a" +debug@^2.1.1, debug@^2.1.2, debug@^2.2.0, debug@^2.3.3, debug@^2.6.8: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" dependencies: - ms "0.7.3" + ms "2.0.0" debug@^2.6.3: version "2.6.8" @@ -1565,7 +1671,7 @@ debug@^2.6.3: dependencies: ms "2.0.0" -debug@^3.0.1, debug@^3.1.0: +debug@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" dependencies: @@ -1575,9 +1681,13 @@ decamelize@^1.0.0, decamelize@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" +decode-uri-component@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" + deep-extend@~0.4.0: - version "0.4.1" - resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.1.tgz#efe4113d08085f4e6f9687759810f807469e2253" + version "0.4.2" + resolved "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.4.2.tgz#48b699c27e334bf89f10892be432f6e4c7d34a7f" deep-is@~0.1.3: version "0.1.3" @@ -1596,6 +1706,25 @@ define-properties@^1.1.2: foreach "^2.0.5" object-keys "^1.0.8" +define-property@^0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" + dependencies: + is-descriptor "^0.1.0" + +define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6" + dependencies: + is-descriptor "^1.0.0" + +define-property@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d" + dependencies: + is-descriptor "^1.0.2" + isobject "^3.0.1" + defined@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/defined/-/defined-1.0.0.tgz#c98d9bcef75674188e110969151199e39b1fa693" @@ -1663,6 +1792,10 @@ detect-indent@^4.0.0: dependencies: repeating "^2.0.0" +detect-libc@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/detect-libc/-/detect-libc-1.0.3.tgz#fa137c4bd698edf55cd5cd02ac559f91a4c4ba9b" + detect-newline@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-2.1.0.tgz#f41f1c10be4b00e87b5f13da680759f2c5bfd3e2" @@ -1984,20 +2117,15 @@ esquery@^1.0.0: estraverse "^4.0.0" esrecurse@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.1.0.tgz#4713b6536adf7f2ac4f327d559e7756bff648220" + version "4.2.1" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.1.tgz#007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf" dependencies: - estraverse "~4.1.0" - object-assign "^4.0.1" + estraverse "^4.1.0" -estraverse@^4.0.0, estraverse@^4.1.1, estraverse@^4.2.0: +estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13" -estraverse@~4.1.0: - version "4.1.1" - resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.1.1.tgz#f6caca728933a850ef90661d0e17982ba47111a2" - estree-walker@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/estree-walker/-/estree-walker-0.2.1.tgz#bdafe8095383d8414d5dc2ecf4c9173b6db9412e" @@ -2045,6 +2173,18 @@ expand-brackets@^0.1.4: dependencies: is-posix-bracket "^0.1.0" +expand-brackets@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" + dependencies: + debug "^2.3.3" + define-property "^0.2.5" + extend-shallow "^2.0.1" + posix-character-classes "^0.1.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + expand-range@^1.8.1: version "1.8.2" resolved "https://registry.yarnpkg.com/expand-range/-/expand-range-1.8.2.tgz#a299effd335fe2721ebae8e257ec79644fc85337" @@ -2074,6 +2214,13 @@ extend-shallow@^2.0.1: dependencies: is-extendable "^0.1.0" +extend-shallow@^3.0.0, extend-shallow@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8" + dependencies: + assign-symbols "^1.0.0" + is-extendable "^1.0.1" + extend@^3.0.0, extend@~3.0.0, extend@~3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444" @@ -2092,6 +2239,19 @@ extglob@^0.3.1: dependencies: is-extglob "^1.0.0" +extglob@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" + dependencies: + array-unique "^0.3.2" + define-property "^1.0.0" + expand-brackets "^2.1.4" + extend-shallow "^2.0.1" + fragment-cache "^0.2.1" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + extract-banner@0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/extract-banner/-/extract-banner-0.1.2.tgz#61d1ed5cce3acdadb35f4323910b420364241a7f" @@ -2099,9 +2259,13 @@ extract-banner@0.1.2: strip-bom-string "^0.1.2" strip-use-strict "^0.1.0" -extsprintf@1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.0.2.tgz#e1080e0658e300b06294990cc70e1502235fd550" +extsprintf@1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.3.0.tgz#96918440e3041a7a414f8c52e3c574eb3c3e1e05" + +extsprintf@^1.2.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/extsprintf/-/extsprintf-1.4.0.tgz#e2689f8f356fad62cca65a3a91c5df5f9551692f" falafel@^1.2.0: version "1.2.0" @@ -2187,8 +2351,8 @@ file-entry-cache@^2.0.0: object-assign "^4.0.1" filename-regex@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.0.tgz#996e3e80479b98b9897f15a8a58b3d084e926775" + version "2.0.1" + resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" fileset@^2.0.2: version "2.0.3" @@ -2211,6 +2375,15 @@ fill-range@^2.1.0: repeat-element "^1.1.2" repeat-string "^1.5.2" +fill-range@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" + dependencies: + extend-shallow "^2.0.1" + is-number "^3.0.0" + repeat-string "^1.6.1" + to-regex-range "^2.1.0" + find-file-up@^0.1.2: version "0.1.3" resolved "https://registry.yarnpkg.com/find-file-up/-/find-file-up-0.1.3.tgz#cf68091bcf9f300a40da411b37da5cce5a2fbea0" @@ -2277,7 +2450,7 @@ flow-coverage-report@^0.4.0: terminal-table "0.0.12" yargs "8.0.1" -for-in@^1.0.1: +for-in@^1.0.1, for-in@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" @@ -2311,28 +2484,40 @@ form-data@~2.3.1: combined-stream "^1.0.5" mime-types "^2.1.12" +fragment-cache@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" + dependencies: + map-cache "^0.2.2" + fs-exists-sync@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/fs-exists-sync/-/fs-exists-sync-0.1.0.tgz#982d6893af918e72d08dec9e8673ff2b5a8d6add" +fs-minipass@^1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d" + dependencies: + minipass "^2.2.1" + fs-readdir-recursive@^0.1.0: version "0.1.2" resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-0.1.2.tgz#315b4fb8c1ca5b8c47defef319d073dad3568059" fs-readdir-recursive@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.0.0.tgz#8cd1745c8b4f8a29c8caec392476921ba195f560" + version "1.1.0" + resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27" fs.realpath@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" fsevents@^1.0.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.1.1.tgz#f19fd28f43eeaf761680e519a203c4d0b3d31aff" + version "1.2.2" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.2.tgz#4f598f0f69b273188ef4a62ca4e9e08ace314bbf" dependencies: - nan "^2.3.0" - node-pre-gyp "^0.6.29" + nan "^2.9.2" + node-pre-gyp "^0.9.0" fsevents@^1.1.1: version "1.1.2" @@ -2370,7 +2555,7 @@ functional-red-black-tree@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327" -gauge@~2.7.1: +gauge@~2.7.3: version "2.7.4" resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7" dependencies: @@ -2409,6 +2594,10 @@ get-stream@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" +get-value@^2.0.3, get-value@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" + getpass@^0.1.1: version "0.1.7" resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" @@ -2473,7 +2662,7 @@ glob-stream@^6.1.0: to-absolute-glob "^2.0.0" unique-stream "^2.0.2" -glob@7.1.1, glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1: +glob@7.1.1, glob@^7.0.3, glob@^7.1.1: version "7.1.1" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.1.tgz#805211df04faaf1c63a3600306cdf5ade50b2ec8" dependencies: @@ -2504,7 +2693,7 @@ glob@^6.0.4: once "^1.3.0" path-is-absolute "^1.0.0" -glob@^7.1.2: +glob@^7.0.5, glob@^7.1.2: version "7.1.2" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15" dependencies: @@ -2531,17 +2720,21 @@ global-prefix@^0.1.4: is-windows "^0.2.0" which "^1.2.12" -globals@^11.0.1, globals@^11.1.0: +globals@^11.0.1: version "11.1.0" resolved "https://registry.yarnpkg.com/globals/-/globals-11.1.0.tgz#632644457f5f0e3ae711807183700ebf2e4633e4" +globals@^11.1.0: + version "11.4.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-11.4.0.tgz#b85c793349561c16076a3c13549238a27945f1bc" + globals@^6.4.0: version "6.4.1" resolved "https://registry.yarnpkg.com/globals/-/globals-6.4.1.tgz#8498032b3b6d1cc81eebc5f79690d8fe29fabf4f" -globals@^9.0.0: - version "9.17.0" - resolved "https://registry.yarnpkg.com/globals/-/globals-9.17.0.tgz#0c0ca696d9b9bb694d2e5470bd37777caad50286" +globals@^9.18.0: + version "9.18.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" globby@^5.0.0: version "5.0.0" @@ -2632,10 +2825,6 @@ handlebars@^4.0.3: optionalDependencies: uglify-js "^2.6" -har-schema@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e" - har-schema@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-2.0.0.tgz#a94c2224ebcac04782a0d9035521f24735b7ec92" @@ -2649,13 +2838,6 @@ har-validator@~2.0.6: is-my-json-valid "^2.12.4" pinkie-promise "^2.0.0" -har-validator@~4.2.1: - version "4.2.1" - resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a" - dependencies: - ajv "^4.9.1" - har-schema "^1.0.5" - har-validator@~5.0.3: version "5.0.3" resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-5.0.3.tgz#ba402c266194f15956ef15e0fcf242993f6a7dfd" @@ -2677,6 +2859,10 @@ has-flag@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-2.0.0.tgz#e8207af1cc7b30d446cc70b734b5e8be18f88d51" +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + has-gulplog@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/has-gulplog/-/has-gulplog-0.1.0.tgz#6414c82913697da51590397dafb12f22967811ce" @@ -2687,6 +2873,33 @@ has-unicode@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/has-unicode/-/has-unicode-2.0.1.tgz#e0e6fe6a28cf51138855e086d1691e771de2a8b9" +has-value@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" + dependencies: + get-value "^2.0.3" + has-values "^0.1.4" + isobject "^2.0.0" + +has-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177" + dependencies: + get-value "^2.0.6" + has-values "^1.0.0" + isobject "^3.0.0" + +has-values@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771" + +has-values@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f" + dependencies: + is-number "^3.0.0" + kind-of "^4.0.0" + has@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/has/-/has-1.0.1.tgz#8461733f538b0837c9361e39a9ab9e9704dc2f28" @@ -2740,8 +2953,8 @@ homedir-polyfill@^1.0.0: parse-passwd "^1.0.0" hosted-git-info@^2.1.4: - version "2.4.2" - resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.4.2.tgz#0076b9f46a270506ddbaaea56496897460612a67" + version "2.6.0" + resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.6.0.tgz#23235b29ab230c576aab0d4f13fc046b0b038222" html-encoding-sniffer@^1.0.1: version "1.0.1" @@ -2784,15 +2997,21 @@ iconv-lite@^0.4.17: version "0.4.19" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b" +iconv-lite@^0.4.4, iconv-lite@~0.4.13: + version "0.4.21" + resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.21.tgz#c47f8733d02171189ebc4a400f3218d348094798" + dependencies: + safer-buffer "^2.1.0" + iconv-lite@^0.4.5: version "0.4.16" resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.16.tgz#65de3beeb39e2960d67f049f1634ffcbcde9014b" -iconv-lite@~0.4.13: - version "0.4.21" - resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.21.tgz#c47f8733d02171189ebc4a400f3218d348094798" +ignore-walk@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/ignore-walk/-/ignore-walk-3.0.1.tgz#a83e62e7d272ac0e3b551aaa82831a19b69f82f8" dependencies: - safer-buffer "^2.1.0" + minimatch "^3.0.4" ignore@^3.3.3: version "3.3.7" @@ -2813,14 +3032,10 @@ inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@~2.0.0, inherits@~2.0.1, version "2.0.3" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" -ini@^1.3.4: +ini@^1.3.4, ini@~1.3.0: version "1.3.5" resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" -ini@~1.3.0: - version "1.3.4" - resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.4.tgz#0537cb79daf59b59a1a517dff706c86ec039162e" - inline-source-map@~0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/inline-source-map/-/inline-source-map-0.5.0.tgz#4a4c5dd8e4fb5e9b3cda60c822dfadcaee66e0af" @@ -2846,9 +3061,9 @@ inquirer@^3.0.6: strip-ansi "^4.0.0" through "^2.3.6" -invariant@^2.2.0: - version "2.2.2" - resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360" +invariant@^2.2.0, invariant@^2.2.2: + version "2.2.4" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" dependencies: loose-envify "^1.0.0" @@ -2863,6 +3078,18 @@ is-absolute@^0.2.5: is-relative "^0.2.1" is-windows "^0.2.0" +is-accessor-descriptor@^0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" + dependencies: + kind-of "^3.0.2" + +is-accessor-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656" + dependencies: + kind-of "^6.0.0" + is-arrayish@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" @@ -2874,8 +3101,8 @@ is-binary-path@^1.0.0: binary-extensions "^1.0.0" is-buffer@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.5.tgz#1f3b26ef613b214b88cbca23cc6c01d87961eecc" + version "1.1.6" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" is-builtin-module@^1.0.0: version "1.0.0" @@ -2893,13 +3120,41 @@ is-ci@^1.0.10: dependencies: ci-info "^1.0.0" +is-data-descriptor@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" + dependencies: + kind-of "^3.0.2" + +is-data-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7" + dependencies: + kind-of "^6.0.0" + is-date-object@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.1.tgz#9aa20eb6aeebbff77fbd33e74ca01b33581d3a16" -is-dotfile@^1.0.0: +is-descriptor@^0.1.0: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" + dependencies: + is-accessor-descriptor "^0.1.6" + is-data-descriptor "^0.1.4" + kind-of "^5.0.0" + +is-descriptor@^1.0.0, is-descriptor@^1.0.2: version "1.0.2" - resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.2.tgz#2c132383f39199f8edc268ca01b9b007d205cc4d" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec" + dependencies: + is-accessor-descriptor "^1.0.0" + is-data-descriptor "^1.0.0" + kind-of "^6.0.2" + +is-dotfile@^1.0.0: + version "1.0.3" + resolved "https://registry.yarnpkg.com/is-dotfile/-/is-dotfile-1.0.3.tgz#a6a2f32ffd2dfb04f5ca25ecd0f6b83cf798a1e1" is-equal-shallow@^0.1.3: version "0.1.3" @@ -2911,6 +3166,12 @@ is-extendable@^0.1.0, is-extendable@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" +is-extendable@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" + dependencies: + is-plain-object "^2.0.4" + is-extglob@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-1.0.0.tgz#ac468177c4943405a092fc8f29760c6ffc6206c0" @@ -2970,12 +3231,28 @@ is-negated-glob@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-negated-glob/-/is-negated-glob-1.0.0.tgz#6910bca5da8c95e784b5751b976cf5a10fee36d2" -is-number@^2.0.2, is-number@^2.1.0: +is-number@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-2.1.0.tgz#01fcbbb393463a548f2f466cce16dece49db908f" dependencies: kind-of "^3.0.2" +is-number@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + dependencies: + kind-of "^3.0.2" + +is-number@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-4.0.0.tgz#0026e37f5454d73e356dfe6564699867c6a7f0ff" + +is-odd@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-odd/-/is-odd-2.0.0.tgz#7646624671fd7ea558ccd9a2795182f2958f1b24" + dependencies: + is-number "^4.0.0" + is-path-cwd@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d" @@ -2992,6 +3269,12 @@ is-path-inside@^1.0.0: dependencies: path-is-inside "^1.0.1" +is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" + dependencies: + isobject "^3.0.1" + is-posix-bracket@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4" @@ -3056,6 +3339,10 @@ is-windows@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.1.tgz#310db70f742d259a16a369202b51af84233310d9" +is-windows@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" + isarray@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" @@ -3074,6 +3361,10 @@ isobject@^2.0.0: dependencies: isarray "1.0.0" +isobject@^3.0.0, isobject@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" + isomorphic-fetch@^2.1.1: version "2.2.1" resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9" @@ -3101,9 +3392,9 @@ istanbul-api@^1.1.14: mkdirp "^0.5.1" once "^1.4.0" -istanbul-lib-coverage@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.1.tgz#73bfb998885299415c93d38a3e9adf784a77a9da" +istanbul-lib-coverage@^1.1.1, istanbul-lib-coverage@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.2.0.tgz#f7d8f2e42b97e37fe796114cb0f9d68b5e3a4341" istanbul-lib-hook@^1.1.0: version "1.1.0" @@ -3111,7 +3402,19 @@ istanbul-lib-hook@^1.1.0: dependencies: append-transform "^0.4.0" -istanbul-lib-instrument@^1.7.5, istanbul-lib-instrument@^1.8.0, istanbul-lib-instrument@^1.9.1: +istanbul-lib-instrument@^1.10.1: + version "1.10.1" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.10.1.tgz#724b4b6caceba8692d3f1f9d0727e279c401af7b" + dependencies: + babel-generator "^6.18.0" + babel-template "^6.16.0" + babel-traverse "^6.18.0" + babel-types "^6.18.0" + babylon "^6.18.0" + istanbul-lib-coverage "^1.2.0" + semver "^5.3.0" + +istanbul-lib-instrument@^1.8.0, istanbul-lib-instrument@^1.9.1: version "1.9.1" resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.9.1.tgz#250b30b3531e5d3251299fdd64b0b2c9db6b558e" dependencies: @@ -3423,12 +3726,6 @@ jest@^22.0.6: dependencies: jest-cli "^22.0.6" -jodid25519@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/jodid25519/-/jodid25519-1.0.2.tgz#06d4912255093419477d425633606e0e90782967" - dependencies: - jsbn "~0.1.0" - js-tokens@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-1.0.1.tgz#cc435a5c8b94ad15acb7983140fc80182c89aeae" @@ -3495,6 +3792,10 @@ jsesc@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" +jsesc@^2.5.1: + version "2.5.1" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-2.5.1.tgz#e421a2a8e20d6b0819df28908f782526b96dd1fe" + jsesc@~0.5.0: version "0.5.0" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-0.5.0.tgz#e7dee66e35d6fc16f710fe91d5cf69f70f08911d" @@ -3533,7 +3834,7 @@ json5@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/json5/-/json5-0.4.0.tgz#054352e4c4c80c86c0923877d449de176a732c8d" -json5@^0.5.0, json5@^0.5.1: +json5@^0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" @@ -3550,24 +3851,38 @@ jsonpointer@^4.0.0, jsonpointer@^4.0.1: resolved "https://registry.yarnpkg.com/jsonpointer/-/jsonpointer-4.0.1.tgz#4fd92cb34e0e9db3c89c8622ecf51f9b978c6cb9" jsprim@^1.2.2: - version "1.4.0" - resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.0.tgz#a3b87e40298d8c380552d8cc7628a0bb95a22918" + version "1.4.1" + resolved "https://registry.yarnpkg.com/jsprim/-/jsprim-1.4.1.tgz#313e66bc1e5cc06e438bc1b7499c2e5c56acb6a2" dependencies: assert-plus "1.0.0" - extsprintf "1.0.2" + extsprintf "1.3.0" json-schema "0.2.3" - verror "1.3.6" + verror "1.10.0" jsx-ast-utils@^1.3.4: version "1.4.1" resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-1.4.1.tgz#3867213e8dd79bf1e8f2300c0cfc1efb182c0df1" -kind-of@^3.0.2: - version "3.2.0" - resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.0.tgz#b58abe4d5c044ad33726a8c1525b48cf891bff07" +kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + dependencies: + is-buffer "^1.1.5" + +kind-of@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" dependencies: is-buffer "^1.1.5" +kind-of@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" + +kind-of@^6.0.0, kind-of@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051" + lazy-cache@^1.0.3: version "1.0.4" resolved "https://registry.yarnpkg.com/lazy-cache/-/lazy-cache-1.0.4.tgz#a1d78fc3a50474cb80845d3b3b6e1da49a446e8e" @@ -3748,10 +4063,14 @@ lodash@^3.10.0, lodash@^3.2.0, lodash@^3.9.3: version "3.10.1" resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" -lodash@^4.13.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0: +lodash@^4.13.1, lodash@^4.14.0, lodash@^4.15.0, lodash@^4.17.4, lodash@^4.3.0: version "4.17.4" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae" +lodash@^4.2.0: + version "4.17.10" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7" + log-driver@1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/log-driver/-/log-driver-1.2.5.tgz#7ae4ec257302fd790d557cb10c97100d857b0056" @@ -3798,6 +4117,16 @@ makeerror@1.0.x: dependencies: tmpl "1.0.x" +map-cache@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" + +map-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f" + dependencies: + object-visit "^1.0.0" + mem@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/mem/-/mem-1.1.0.tgz#5edd52b485ca1d900fe64895505399a0dfa45f76" @@ -3832,19 +4161,37 @@ micromatch@^2.1.5, micromatch@^2.3.11: parse-glob "^3.0.4" regex-cache "^0.4.2" -mime-db@~1.27.0: - version "1.27.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.27.0.tgz#820f572296bbd20ec25ed55e5b5de869e5436eb1" +micromatch@^3.1.8: + version "3.1.10" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + braces "^2.3.1" + define-property "^2.0.2" + extend-shallow "^3.0.2" + extglob "^2.0.4" + fragment-cache "^0.2.1" + kind-of "^6.0.2" + nanomatch "^1.2.9" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.2" mime-db@~1.30.0: version "1.30.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.30.0.tgz#74c643da2dd9d6a45399963465b26d5ca7d71f01" +mime-db@~1.33.0: + version "1.33.0" + resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.33.0.tgz#a3492050a5cb9b63450541e39d9788d2272783db" + mime-types@^2.1.12, mime-types@~2.1.7: - version "2.1.15" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.15.tgz#a4ebf5064094569237b8cf70046776d09fc92aed" + version "2.1.18" + resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.18.tgz#6f323f60a83d11146f831ff11fd66e2fe5503bb8" dependencies: - mime-db "~1.27.0" + mime-db "~1.33.0" mime-types@~2.1.17: version "2.1.17" @@ -3856,13 +4203,13 @@ mimic-fn@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18" -"minimatch@2 || 3", minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.3: +"minimatch@2 || 3", minimatch@^3.0.3: version "3.0.3" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.3.tgz#2a4e4090b96b2db06a9d7df01055a62a77c9b774" dependencies: brace-expansion "^1.0.0" -minimatch@3.0.4, minimatch@^3.0.4: +minimatch@3.0.4, minimatch@^3.0.0, minimatch@^3.0.2, minimatch@^3.0.4: version "3.0.4" resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" dependencies: @@ -3882,16 +4229,32 @@ minimist@1.2.0, minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" +minipass@^2.2.1, minipass@^2.2.4: + version "2.2.4" + resolved "https://registry.yarnpkg.com/minipass/-/minipass-2.2.4.tgz#03c824d84551ec38a8d1bb5bc350a5a30a354a40" + dependencies: + safe-buffer "^5.1.1" + yallist "^3.0.0" + +minizlib@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-1.1.0.tgz#11e13658ce46bc3a70a267aac58359d1e0c29ceb" + dependencies: + minipass "^2.2.1" + +mixin-deep@^1.2.0: + version "1.3.1" + resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe" + dependencies: + for-in "^1.0.2" + is-extendable "^1.0.1" + mkdirp@0.5.1, "mkdirp@>=0.5 0", mkdirp@^0.5.0, mkdirp@^0.5.1: version "0.5.1" resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.1.tgz#30057438eac6cf7f8c4767f38648d6697d75c903" dependencies: minimist "0.0.8" -ms@0.7.3: - version "0.7.3" - resolved "https://registry.yarnpkg.com/ms/-/ms-0.7.3.tgz#708155a5e44e33f5fd0fc53e81d0d40a91be1fff" - ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" @@ -3906,9 +4269,26 @@ mute-stream@0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab" -nan@^2.3.0: - version "2.6.2" - resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" +nan@^2.3.0, nan@^2.9.2: + version "2.10.0" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.10.0.tgz#96d0cd610ebd58d4b4de9cc0c6828cda99c7548f" + +nanomatch@^1.2.9: + version "1.2.9" + resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.9.tgz#879f7150cb2dab7a471259066c104eee6e0fa7c2" + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + define-property "^2.0.2" + extend-shallow "^3.0.2" + fragment-cache "^0.2.1" + is-odd "^2.0.0" + is-windows "^1.0.2" + kind-of "^6.0.2" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" natural-compare@^1.4.0: version "1.4.0" @@ -3918,6 +4298,14 @@ ncp@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ncp/-/ncp-2.0.0.tgz#195a21d6c46e361d2fb1281ba38b91e9df7bdbb3" +needle@^2.2.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/needle/-/needle-2.2.0.tgz#f14efc69cee1024b72c8b21c7bdf94a731dc12fa" + dependencies: + debug "^2.1.2" + iconv-lite "^0.4.4" + sax "^1.2.4" + node-cleanup@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/node-cleanup/-/node-cleanup-2.1.2.tgz#7ac19abd297e09a7f72a71545d951b517e4dde2c" @@ -3942,9 +4330,9 @@ node-notifier@^5.1.2: shellwords "^0.1.0" which "^1.2.12" -node-pre-gyp@^0.6.29: - version "0.6.34" - resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.34.tgz#94ad1c798a11d7fc67381b50d47f8cc18d9799f7" +node-pre-gyp@^0.6.36: + version "0.6.36" + resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.36.tgz#db604112cb74e0d477554e9b505b17abddfab786" dependencies: mkdirp "^0.5.1" nopt "^4.0.1" @@ -3956,19 +4344,20 @@ node-pre-gyp@^0.6.29: tar "^2.2.1" tar-pack "^3.4.0" -node-pre-gyp@^0.6.36: - version "0.6.36" - resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.6.36.tgz#db604112cb74e0d477554e9b505b17abddfab786" +node-pre-gyp@^0.9.0: + version "0.9.1" + resolved "https://registry.yarnpkg.com/node-pre-gyp/-/node-pre-gyp-0.9.1.tgz#f11c07516dd92f87199dbc7e1838eab7cd56c9e0" dependencies: + detect-libc "^1.0.2" mkdirp "^0.5.1" + needle "^2.2.0" nopt "^4.0.1" + npm-packlist "^1.1.6" npmlog "^4.0.2" rc "^1.1.7" - request "^2.81.0" rimraf "^2.6.1" semver "^5.3.0" - tar "^2.2.1" - tar-pack "^3.4.0" + tar "^4" nopt@^4.0.1: version "4.0.1" @@ -3978,20 +4367,31 @@ nopt@^4.0.1: osenv "^0.1.4" normalize-package-data@^2.3.2: - version "2.3.8" - resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.3.8.tgz#d819eda2a9dedbd1ffa563ea4071d936782295bb" + version "2.4.0" + resolved "https://registry.yarnpkg.com/normalize-package-data/-/normalize-package-data-2.4.0.tgz#12f95a307d58352075a04907b84ac8be98ac012f" dependencies: hosted-git-info "^2.1.4" is-builtin-module "^1.0.0" semver "2 || 3 || 4 || 5" validate-npm-package-license "^3.0.1" -normalize-path@^2.0.1: +normalize-path@^2.0.0, normalize-path@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" dependencies: remove-trailing-separator "^1.0.1" +npm-bundled@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/npm-bundled/-/npm-bundled-1.0.3.tgz#7e71703d973af3370a9591bafe3a63aca0be2308" + +npm-packlist@^1.1.6: + version "1.1.10" + resolved "https://registry.yarnpkg.com/npm-packlist/-/npm-packlist-1.1.10.tgz#1039db9e985727e464df066f4cf0ab6ef85c398a" + dependencies: + ignore-walk "^3.0.1" + npm-bundled "^1.0.1" + npm-run-path@^2.0.0: version "2.0.2" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" @@ -3999,12 +4399,12 @@ npm-run-path@^2.0.0: path-key "^2.0.0" npmlog@^4.0.2: - version "4.0.2" - resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.0.2.tgz#d03950e0e78ce1527ba26d2a7592e9348ac3e75f" + version "4.1.2" + resolved "https://registry.yarnpkg.com/npmlog/-/npmlog-4.1.2.tgz#08a7f2a8bf734604779a9efa4ad5cc717abb954b" dependencies: are-we-there-yet "~1.1.2" console-control-strings "~1.1.0" - gauge "~2.7.1" + gauge "~2.7.3" set-blocking "~2.0.0" number-is-nan@^1.0.0: @@ -4027,10 +4427,24 @@ object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1: version "4.1.1" resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" +object-copy@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" + dependencies: + copy-descriptor "^0.1.0" + define-property "^0.2.5" + kind-of "^3.0.3" + object-keys@^1.0.10, object-keys@^1.0.6, object-keys@^1.0.8: version "1.0.11" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.0.11.tgz#c54601778ad560f1142ce0e01bcca8b56d13426d" +object-visit@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" + dependencies: + isobject "^3.0.0" + object.assign@^4.0.4: version "4.0.4" resolved "https://registry.yarnpkg.com/object.assign/-/object.assign-4.0.4.tgz#b1c9cc044ef1b9fe63606fc141abbb32e14730cc" @@ -4053,6 +4467,12 @@ object.omit@^2.0.0: for-own "^0.1.4" is-extendable "^0.1.1" +object.pick@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" + dependencies: + isobject "^3.0.1" + once@^1.3.0, once@^1.3.1, once@^1.3.3, once@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" @@ -4123,13 +4543,13 @@ os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.1, os-tmpdir@~1.0.2: resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" osenv@^0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.4.tgz#42fe6d5953df06c8064be6f176c3d05aaaa34644" + version "0.1.5" + resolved "https://registry.yarnpkg.com/osenv/-/osenv-0.1.5.tgz#85cdfafaeb28e8677f416e287592b5f3f49ea410" dependencies: os-homedir "^1.0.0" os-tmpdir "^1.0.0" -output-file-sync@^1.1.0: +output-file-sync@^1.1.0, output-file-sync@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/output-file-sync/-/output-file-sync-1.1.2.tgz#d0a33eefe61a205facb90092e826598d5245ce76" dependencies: @@ -4142,8 +4562,10 @@ p-finally@^1.0.0: resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" p-limit@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.1.0.tgz#b07ff2d9a5d88bec806035895a2bab66a27988bc" + version "1.2.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.2.0.tgz#0e92b6bedcb59f022c13d0f1949dc82d15909f1c" + dependencies: + p-try "^1.0.0" p-locate@^2.0.0: version "2.0.0" @@ -4151,6 +4573,10 @@ p-locate@^2.0.0: dependencies: p-limit "^1.1.0" +p-try@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" + parse-diff@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/parse-diff/-/parse-diff-0.4.0.tgz#9ce35bcce8fc0b7c58f46d71113394fc0b4982dd" @@ -4199,6 +4625,10 @@ parse5@^3.0.2: dependencies: "@types/node" "*" +pascalcase@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" + path-dirname@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" @@ -4217,7 +4647,7 @@ path-exists@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" -path-is-absolute@^1.0.0: +path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" @@ -4247,10 +4677,6 @@ path-type@^2.0.0: dependencies: pify "^2.0.0" -performance-now@^0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5" - performance-now@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b" @@ -4285,6 +4711,10 @@ pn@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb" +posix-character-classes@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" + prelude-ls@~1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" @@ -4315,7 +4745,11 @@ pretty-format@^22.1.0: ansi-regex "^3.0.0" ansi-styles "^3.2.0" -private@^0.1.6, private@~0.1.5: +private@^0.1.6, private@^0.1.7: + version "0.1.8" + resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" + +private@~0.1.5: version "0.1.7" resolved "https://registry.yarnpkg.com/private/-/private-0.1.7.tgz#68ce5e8a1ef0a23bb570cc28537b5332aba63ef1" @@ -4323,6 +4757,10 @@ process-nextick-args@^1.0.6, process-nextick-args@~1.0.6: version "1.0.7" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3" +process-nextick-args@~2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa" + progress@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f" @@ -4395,10 +4833,6 @@ qs@~6.3.0: version "6.3.2" resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.2.tgz#e75bd5f6e268122a2a0e0bda630b2550c166502c" -qs@~6.4.0: - version "6.4.0" - resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233" - qs@~6.5.1: version "6.5.1" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8" @@ -4410,15 +4844,15 @@ random-seed@^0.3.0: json-stringify-safe "^5.0.1" randomatic@^1.1.3: - version "1.1.6" - resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.6.tgz#110dcabff397e9dcff7c0789ccc0a49adf1ec5bb" + version "1.1.7" + resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.7.tgz#c7abe9cc8b87c0baa876b19fde83fd464797e38c" dependencies: - is-number "^2.0.2" - kind-of "^3.0.2" + is-number "^3.0.0" + kind-of "^4.0.0" rc@^1.1.7: - version "1.2.1" - resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.1.tgz#2e03e8e42ee450b8cb3dce65be1bf8974e1dfd95" + version "1.2.6" + resolved "https://registry.yarnpkg.com/rc/-/rc-1.2.6.tgz#eb18989c6d4f4f162c399f79ddd29f3835568092" dependencies: deep-extend "~0.4.0" ini "~1.3.0" @@ -4486,7 +4920,7 @@ read-pkg@^2.0.0: isarray "0.0.1" string_decoder "~0.10.x" -readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5: +readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.1.5: version "2.2.9" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.2.9.tgz#cf78ec6f4a6d1eb43d26488cac97f042e74b7fc8" dependencies: @@ -4498,6 +4932,18 @@ readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable string_decoder "~1.0.0" util-deprecate "~1.0.1" +readable-stream@^2.0.2, readable-stream@^2.0.6, readable-stream@^2.1.4: + version "2.3.6" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + readable-stream@^2.0.5, readable-stream@^2.2.2: version "2.3.3" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.3.tgz#368f2512d79f9d46fdfc71349ae7878bbc1eb95c" @@ -4562,9 +5008,9 @@ regenerate@^1.2.1: version "1.3.2" resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.2.tgz#d1941c67bad437e1be76433add5b385f95b19260" -regenerator-runtime@^0.10.0: - version "0.10.4" - resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.4.tgz#74cb6598d3ba2eb18694e968a40e2b3b4df9cf93" +regenerator-runtime@^0.10.0, regenerator-runtime@^0.10.5: + version "0.10.5" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.10.5.tgz#336c3efc1220adcedda2c9fab67b5a7955a33658" regenerator-runtime@^0.11.0: version "0.11.0" @@ -4590,11 +5036,17 @@ regenerator@0.8.40: through "~2.3.8" regex-cache@^0.4.2: - version "0.4.3" - resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.3.tgz#9b1a6c35d4d0dfcef5711ae651e8e9d3d7114145" + version "0.4.4" + resolved "https://registry.yarnpkg.com/regex-cache/-/regex-cache-0.4.4.tgz#75bdc58a2a1496cec48a12835bc54c8d562336dd" dependencies: is-equal-shallow "^0.1.3" - is-primitive "^2.0.0" + +regex-not@^1.0.0, regex-not@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" + dependencies: + extend-shallow "^3.0.2" + safe-regex "^1.1.0" regexpu@^1.3.0: version "1.3.0" @@ -4617,14 +5069,14 @@ regjsparser@^0.1.4: jsesc "~0.5.0" remove-trailing-separator@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.0.1.tgz#615ebb96af559552d4bf4057c8436d486ab63cc4" + version "1.1.0" + resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" repeat-element@^1.1.2: version "1.1.2" resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.2.tgz#ef089a178d1483baae4d93eb98b4f9e4e11d990a" -repeat-string@^1.5.2: +repeat-string@^1.5.2, repeat-string@^1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" @@ -4688,31 +5140,31 @@ request@2.79.0: uuid "^3.0.0" request@^2.81.0: - version "2.81.0" - resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0" + version "2.85.0" + resolved "https://registry.yarnpkg.com/request/-/request-2.85.0.tgz#5a03615a47c61420b3eb99b7dba204f83603e1fa" dependencies: - aws-sign2 "~0.6.0" - aws4 "^1.2.1" + aws-sign2 "~0.7.0" + aws4 "^1.6.0" caseless "~0.12.0" combined-stream "~1.0.5" - extend "~3.0.0" + extend "~3.0.1" forever-agent "~0.6.1" - form-data "~2.1.1" - har-validator "~4.2.1" - hawk "~3.1.3" - http-signature "~1.1.0" + form-data "~2.3.1" + har-validator "~5.0.3" + hawk "~6.0.2" + http-signature "~1.2.0" is-typedarray "~1.0.0" isstream "~0.1.2" json-stringify-safe "~5.0.1" - mime-types "~2.1.7" - oauth-sign "~0.8.1" - performance-now "^0.2.0" - qs "~6.4.0" - safe-buffer "^5.0.1" - stringstream "~0.0.4" - tough-cookie "~2.3.0" + mime-types "~2.1.17" + oauth-sign "~0.8.2" + performance-now "^2.1.0" + qs "~6.5.1" + safe-buffer "^5.1.1" + stringstream "~0.0.5" + tough-cookie "~2.3.3" tunnel-agent "^0.6.0" - uuid "^3.0.0" + uuid "^3.1.0" request@^2.83.0: version "2.83.0" @@ -4771,6 +5223,10 @@ resolve-from@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" +resolve-url@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" + resolve@1.1.7: version "1.1.7" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" @@ -4794,6 +5250,10 @@ restore-cursor@^2.0.0: onetime "^2.0.0" signal-exit "^3.0.2" +ret@~0.1.10: + version "0.1.15" + resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" + rfc6902@^2.2.2: version "2.2.2" resolved "https://registry.yarnpkg.com/rfc6902/-/rfc6902-2.2.2.tgz#518a4e9caac1688f3d94c9df2fdcdb6ce21f29be" @@ -4804,15 +5264,15 @@ right-align@^0.1.1: dependencies: align-text "^0.1.1" -rimraf@2, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.6.1: - version "2.6.1" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" +rimraf@2, rimraf@^2.5.1, rimraf@^2.5.4: + version "2.6.2" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" dependencies: glob "^7.0.5" -rimraf@^2.5.4: - version "2.6.2" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36" +rimraf@^2.2.8, rimraf@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.1.tgz#c2338ec643df7a1b7fe5c54fa86f57428a55f33d" dependencies: glob "^7.0.5" @@ -4921,14 +5381,16 @@ rxjs@^5.5.6: dependencies: symbol-observable "1.0.1" -safe-buffer@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.0.1.tgz#d263ca54696cd8a306b5ca6551e92de57918fbe7" - -safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: +safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" +safe-regex@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" + dependencies: + ret "~0.1.10" + safer-buffer@^2.1.0: version "2.1.2" resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" @@ -4951,14 +5413,18 @@ sax@^1.2.1: version "1.2.2" resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.2.tgz#fd8631a23bc7826bef5d871bdb87378c95647828" -"semver@2 || 3 || 4 || 5", semver@^5.1.0, semver@^5.3.0: - version "5.3.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" +sax@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9" -semver@^5.5.0: +"semver@2 || 3 || 4 || 5", semver@^5.3.0, semver@^5.5.0: version "5.5.0" resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab" +semver@^5.1.0: + version "5.3.0" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.3.0.tgz#9b2ce5d3de02d17c6012ad326aa6b4d0cf54f94f" + set-blocking@^2.0.0, set-blocking@~2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" @@ -4967,6 +5433,24 @@ set-immediate-shim@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/set-immediate-shim/-/set-immediate-shim-1.0.1.tgz#4b2b1b27eb808a9f8dcc481a58e5e56f599f3f61" +set-value@^0.4.3: + version "0.4.3" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-0.4.3.tgz#7db08f9d3d22dc7f78e53af3c3bf4666ecdfccf1" + dependencies: + extend-shallow "^2.0.1" + is-extendable "^0.1.1" + is-plain-object "^2.0.1" + to-object-path "^0.3.0" + +set-value@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.0.tgz#71ae4a88f0feefbbf52d1ea604f3fb315ebb6274" + dependencies: + extend-shallow "^2.0.1" + is-extendable "^0.1.1" + is-plain-object "^2.0.3" + split-string "^3.0.1" + setimmediate@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" @@ -5007,6 +5491,33 @@ slice-ansi@1.0.0: dependencies: is-fullwidth-code-point "^2.0.0" +snapdragon-node@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" + dependencies: + define-property "^1.0.0" + isobject "^3.0.0" + snapdragon-util "^3.0.1" + +snapdragon-util@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2" + dependencies: + kind-of "^3.2.0" + +snapdragon@^0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.2.tgz#64922e7c565b0e14204ba1aa7d6964278d25182d" + dependencies: + base "^0.11.1" + debug "^2.2.0" + define-property "^0.2.5" + extend-shallow "^2.0.1" + map-cache "^0.2.2" + source-map "^0.5.6" + source-map-resolve "^0.5.0" + use "^3.1.0" + sntp@1.x.x: version "1.0.9" resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198" @@ -5023,15 +5534,25 @@ source-list-map@~0.1.7: version "0.1.8" resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-0.1.8.tgz#c550b2ab5427f6b3f21f5afead88c4f5587b2106" +source-map-resolve@^0.5.0: + version "0.5.1" + resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.1.tgz#7ad0f593f2281598e854df80f19aae4b92d7a11a" + dependencies: + atob "^2.0.0" + decode-uri-component "^0.2.0" + resolve-url "^0.2.1" + source-map-url "^0.4.0" + urix "^0.1.0" + source-map-support@^0.2.10: version "0.2.10" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.2.10.tgz#ea5a3900a1c1cb25096a0ae8cc5c2b4b10ded3dc" dependencies: source-map "0.1.32" -source-map-support@^0.4.2: - version "0.4.14" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.14.tgz#9d4463772598b86271b4f523f6c1f4e02a7d6aef" +source-map-support@^0.4.15: + version "0.4.18" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f" dependencies: source-map "^0.5.6" @@ -5041,6 +5562,10 @@ source-map-support@^0.5.0: dependencies: source-map "^0.6.0" +source-map-url@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" + source-map@0.1.32: version "0.1.32" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.1.32.tgz#c8b6c167797ba4740a8ea33252162ff08591b266" @@ -5053,7 +5578,11 @@ source-map@^0.4.4, source-map@~0.4.0, source-map@~0.4.1, source-map@~0.4.2: dependencies: amdefine ">=0.0.4" -source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@~0.5.0, source-map@~0.5.1: +source-map@^0.5.0, source-map@^0.5.6, source-map@^0.5.7, source-map@~0.5.6: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + +source-map@^0.5.3, source-map@~0.5.0, source-map@~0.5.1: version "0.5.6" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.6.tgz#75ce38f52bf0733c5a7f0c118d81334a2bb5f412" @@ -5061,10 +5590,6 @@ source-map@^0.6.0: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" -source-map@~0.5.6: - version "0.5.7" - resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" - sparkles@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/sparkles/-/sparkles-1.0.0.tgz#1acbbfb592436d10bbe8f785b7cc6f82815012c3" @@ -5076,27 +5601,41 @@ spawn-sync@^1.0.15: concat-stream "^1.4.7" os-shim "^0.1.2" -spdx-correct@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40" +spdx-correct@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-3.0.0.tgz#05a5b4d7153a195bc92c3c425b69f3b2a9524c82" dependencies: - spdx-license-ids "^1.0.2" + spdx-expression-parse "^3.0.0" + spdx-license-ids "^3.0.0" -spdx-expression-parse@~1.0.0: - version "1.0.4" - resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-1.0.4.tgz#9bdf2f20e1f40ed447fbe273266191fced51626c" +spdx-exceptions@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz#2c7ae61056c714a5b9b9b2b2af7d311ef5c78fe9" -spdx-license-ids@^1.0.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-1.2.2.tgz#c9df7a3424594ade6bd11900d596696dc06bac57" +spdx-expression-parse@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz#99e119b7a5da00e05491c9fa338b7904823b41d0" + dependencies: + spdx-exceptions "^2.1.0" + spdx-license-ids "^3.0.0" + +spdx-license-ids@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz#7a7cd28470cc6d3a1cfe6d66886f6bc430d3ac87" + +split-string@^3.0.1, split-string@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" + dependencies: + extend-shallow "^3.0.0" sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" sshpk@^1.7.0: - version "1.13.0" - resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.13.0.tgz#ff2a3e4fd04497555fed97b39a0fd82fafb3a33c" + version "1.14.1" + resolved "https://registry.yarnpkg.com/sshpk/-/sshpk-1.14.1.tgz#130f5975eddad963f1d56f92b9ac6c51fa9f83eb" dependencies: asn1 "~0.2.3" assert-plus "^1.0.0" @@ -5105,7 +5644,6 @@ sshpk@^1.7.0: optionalDependencies: bcrypt-pbkdf "^1.0.0" ecc-jsbn "~0.1.1" - jodid25519 "^1.0.0" jsbn "~0.1.0" tweetnacl "~0.14.0" @@ -5117,6 +5655,13 @@ stack-utils@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/stack-utils/-/stack-utils-1.0.1.tgz#d4f33ab54e8e38778b0ca5cfd3b3afb12db68620" +static-extend@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" + dependencies: + define-property "^0.2.5" + object-copy "^0.1.0" + stealthy-require@^1.1.0: version "1.1.1" resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b" @@ -5158,18 +5703,18 @@ string_decoder@~0.10.x: version "0.10.31" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-0.10.31.tgz#62e203bc41766c6c28c9fc84301dab1c5310fa94" -string_decoder@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.0.tgz#f06f41157b664d86069f84bdbdc9b0d8ab281667" - dependencies: - buffer-shims "~1.0.0" - -string_decoder@~1.0.3: +string_decoder@~1.0.0, string_decoder@~1.0.3: version "1.0.3" resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.0.3.tgz#0fc67d7c141825de94282dd536bec6b9bce860ab" dependencies: safe-buffer "~5.1.0" +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + dependencies: + safe-buffer "~5.1.0" + stringmap@~0.2.2: version "0.2.2" resolved "https://registry.yarnpkg.com/stringmap/-/stringmap-0.2.2.tgz#556c137b258f942b8776f5b2ef582aa069d7d1b1" @@ -5231,8 +5776,8 @@ supports-color@^3.1.2: has-flag "^1.0.0" supports-color@^4.0.0: - version "4.2.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.2.0.tgz#ad986dc7eb2315d009b4d77c8169c2231a684037" + version "4.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-4.5.0.tgz#be7a0de484dec5c5cddf8b3d59125044912f635b" dependencies: has-flag "^2.0.0" @@ -5242,6 +5787,12 @@ supports-color@^5.0.0: dependencies: has-flag "^2.0.0" +supports-color@^5.3.0: + version "5.4.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.4.0.tgz#1c6b337402c2137605efe19f10fec390f6faab54" + dependencies: + has-flag "^3.0.0" + supports-hyperlinks@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/supports-hyperlinks/-/supports-hyperlinks-1.0.1.tgz#71daedf36cc1060ac5100c351bb3da48c29c0ef7" @@ -5278,8 +5829,8 @@ tar-fs@^1.8.1: tar-stream "^1.1.2" tar-pack@^3.4.0: - version "3.4.0" - resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.4.0.tgz#23be2d7f671a8339376cbdb0b8fe3fdebf317984" + version "3.4.1" + resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.4.1.tgz#e1dbc03a9b9d3ba07e896ad027317eb679a10a1f" dependencies: debug "^2.2.0" fstream "^1.0.10" @@ -5307,6 +5858,18 @@ tar@^2.2.1: fstream "^1.0.2" inherits "2" +tar@^4: + version "4.4.1" + resolved "https://registry.yarnpkg.com/tar/-/tar-4.4.1.tgz#b25d5a8470c976fd7a9a8a350f42c59e9fa81749" + dependencies: + chownr "^1.0.1" + fs-minipass "^1.2.5" + minipass "^2.2.4" + minizlib "^1.1.0" + mkdirp "^0.5.0" + safe-buffer "^5.1.1" + yallist "^3.0.2" + targz@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/targz/-/targz-1.0.1.tgz#8f76a523694cdedfbb5d60a4076ff6eeecc5398f" @@ -5327,12 +5890,12 @@ terminal-table@0.0.12: colors "^1.0.3" eastasianwidth "^0.1.0" -test-exclude@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-4.1.1.tgz#4d84964b0966b0087ecc334a2ce002d3d9341e26" +test-exclude@^4.2.1: + version "4.2.1" + resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-4.2.1.tgz#dfa222f03480bca69207ca728b37d74b45f724fa" dependencies: arrify "^1.0.1" - micromatch "^2.3.11" + micromatch "^3.1.8" object-assign "^4.1.0" read-pkg-up "^1.0.1" require-main-filename "^1.0.1" @@ -5402,7 +5965,7 @@ to-absolute-glob@^2.0.0: is-absolute "^0.2.5" is-negated-glob "^1.0.0" -to-fast-properties@^1.0.0, to-fast-properties@^1.0.1: +to-fast-properties@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.2.tgz#f3f5c0c3ba7299a7ef99427e44633257ade43320" @@ -5414,6 +5977,28 @@ to-fast-properties@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" +to-object-path@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" + dependencies: + kind-of "^3.0.2" + +to-regex-range@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" + dependencies: + is-number "^3.0.0" + repeat-string "^1.6.1" + +to-regex@^3.0.1, to-regex@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce" + dependencies: + define-property "^2.0.2" + extend-shallow "^3.0.2" + regex-not "^1.0.2" + safe-regex "^1.1.0" + tough-cookie@>=2.3.3, tough-cookie@^2.3.3, tough-cookie@~2.3.3: version "2.3.3" resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.3.tgz#0b618a5565b6dea90bf3425d04d55edc475a7561" @@ -5421,8 +6006,8 @@ tough-cookie@>=2.3.3, tough-cookie@^2.3.3, tough-cookie@~2.3.3: punycode "^1.4.1" tough-cookie@~2.3.0: - version "2.3.2" - resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.2.tgz#f081f76e4c85720e6c37a5faced737150d84072a" + version "2.3.4" + resolved "https://registry.yarnpkg.com/tough-cookie/-/tough-cookie-2.3.4.tgz#ec60cee38ac675063ffc97a5c18970578ee83655" dependencies: punycode "^1.4.1" @@ -5505,6 +6090,15 @@ unc-path-regex@^0.1.0: version "0.1.2" resolved "https://registry.yarnpkg.com/unc-path-regex/-/unc-path-regex-0.1.2.tgz#e73dd3d7b0d7c5ed86fbac6b0ae7d8c6a69d50fa" +union-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4" + dependencies: + arr-union "^3.1.0" + get-value "^2.0.6" + is-extendable "^0.1.1" + set-value "^0.4.3" + unique-stream@^2.0.2: version "2.2.1" resolved "https://registry.yarnpkg.com/unique-stream/-/unique-stream-2.2.1.tgz#5aa003cfbe94c5ff866c4e7d668bb1c4dbadb369" @@ -5512,10 +6106,27 @@ unique-stream@^2.0.2: json-stable-stringify "^1.0.0" through2-filter "^2.0.0" +unset-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" + dependencies: + has-value "^0.3.1" + isobject "^3.0.0" + +urix@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" + url-template@^2.0.8: version "2.0.8" resolved "https://registry.yarnpkg.com/url-template/-/url-template-2.0.8.tgz#fc565a3cccbff7730c775f5641f9555791439f21" +use@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/use/-/use-3.1.0.tgz#14716bf03fdfefd03040aef58d8b4b85f3a7c544" + dependencies: + kind-of "^6.0.2" + user-home@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/user-home/-/user-home-1.1.1.tgz#2b5be23a32b63a7c9deb8d0f28d485724a3df190" @@ -5532,31 +6143,33 @@ util.promisify@^1.0.0: object.getownpropertydescriptors "^2.0.3" uuid@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" + version "3.2.1" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14" uuid@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" -v8flags@^2.0.10: +v8flags@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/v8flags/-/v8flags-2.1.1.tgz#aab1a1fa30d45f88dd321148875ac02c0b55e5b4" dependencies: user-home "^1.1.1" validate-npm-package-license@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.1.tgz#2804babe712ad3379459acfbe24746ab2c303fbc" + version "3.0.3" + resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz#81643bcbef1bdfecd4623793dc4648948ba98338" dependencies: - spdx-correct "~1.0.0" - spdx-expression-parse "~1.0.0" + spdx-correct "^3.0.0" + spdx-expression-parse "^3.0.0" -verror@1.3.6: - version "1.3.6" - resolved "https://registry.yarnpkg.com/verror/-/verror-1.3.6.tgz#cff5df12946d297d2baaefaa2689e25be01c005c" +verror@1.10.0: + version "1.10.0" + resolved "https://registry.yarnpkg.com/verror/-/verror-1.10.0.tgz#3a105ca17053af55d6e270c1f8288682e18da400" dependencies: - extsprintf "1.0.2" + assert-plus "^1.0.0" + core-util-is "1.0.2" + extsprintf "^1.2.0" vinyl@^0.5.0: version "0.5.3" @@ -5649,10 +6262,10 @@ which@^1.2.9: isexe "^2.0.0" wide-align@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.0.tgz#40edde802a71fea1f070da3e62dcda2e7add96ad" + version "1.1.2" + resolved "https://registry.yarnpkg.com/wide-align/-/wide-align-1.1.2.tgz#571e0f1b0604636ebc0dfc21b0339bbe31341710" dependencies: - string-width "^1.0.1" + string-width "^1.0.2" window-size@0.1.0: version "0.1.0" @@ -5719,6 +6332,10 @@ yallist@^2.0.0, yallist@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52" +yallist@^3.0.0, yallist@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9" + yargs-parser@^2.4.1: version "2.4.1" resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-2.4.1.tgz#85568de3cf150ff49fa51825f03a8c880ddcc5c4" From bb057bc423a258d13c9741f4bdb9d0e14a674d53 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 25 Apr 2018 01:56:48 +0200 Subject: [PATCH 36/45] Revert Map changes of SimpleEventPlugin --- .../react-dom/src/events/SimpleEventPlugin.js | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/react-dom/src/events/SimpleEventPlugin.js b/packages/react-dom/src/events/SimpleEventPlugin.js index e9a108dcf2a9f..f916ff39f13e1 100644 --- a/packages/react-dom/src/events/SimpleEventPlugin.js +++ b/packages/react-dom/src/events/SimpleEventPlugin.js @@ -123,17 +123,14 @@ const nonInteractiveEventTypeNames: Array = [ ]; const eventTypes: EventTypes = {}; -const topLevelEventsToDispatchConfig: Map< - TopLevelType, - DispatchConfig, -> = new Map(); +const topLevelEventsToDispatchConfig: { + [key: TopLevelTypes]: DispatchConfig, +} = {}; function addEventTypeNameToConfig( - eventTuple: EventTuple, + [topEvent, event]: EventTuple, isInteractive: boolean, ) { - const topEvent = eventTuple[0]; - const event = eventTuple[1]; const capitalizedEvent = event[0].toUpperCase() + event.slice(1); const onEvent = 'on' + capitalizedEvent; @@ -146,7 +143,7 @@ function addEventTypeNameToConfig( isInteractive, }; eventTypes[event] = type; - topLevelEventsToDispatchConfig.set(topEvent, type); + topLevelEventsToDispatchConfig[topEvent] = type; } interactiveEventTypeNames.forEach(eventTuple => { @@ -195,7 +192,7 @@ const SimpleEventPlugin: PluginModule = { eventTypes: eventTypes, isInteractiveTopLevelEventType(topLevelType: TopLevelType): boolean { - const config = topLevelEventsToDispatchConfig.get(topLevelType); + const config = topLevelEventsToDispatchConfig[topLevelType]; return config !== undefined && config.isInteractive === true; }, @@ -205,7 +202,7 @@ const SimpleEventPlugin: PluginModule = { nativeEvent: MouseEvent, nativeEventTarget: EventTarget, ): null | ReactSyntheticEvent { - const dispatchConfig = topLevelEventsToDispatchConfig.get(topLevelType); + const dispatchConfig = topLevelEventsToDispatchConfig[topLevelType]; if (!dispatchConfig) { return null; } From 6800d01121ea7ab8cb7776dd698f79239ecaa5d9 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 25 Apr 2018 01:58:25 +0200 Subject: [PATCH 37/45] Clean up ReactTestUtils --- .../src/test-utils/ReactTestUtils.js | 51 +++++++++---------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/packages/react-dom/src/test-utils/ReactTestUtils.js b/packages/react-dom/src/test-utils/ReactTestUtils.js index c974b8ed8ae3e..d9948291b3cf0 100644 --- a/packages/react-dom/src/test-utils/ReactTestUtils.js +++ b/packages/react-dom/src/test-utils/ReactTestUtils.js @@ -454,10 +454,13 @@ function makeNativeSimulator(eventType, topLevelType) { } [ + [DOMTopLevelEventTypes.TOP_ABORT, 'abort'], [DOMTopLevelEventTypes.TOP_ANIMATION_END, 'animationEnd'], [DOMTopLevelEventTypes.TOP_ANIMATION_ITERATION, 'animationIteration'], [DOMTopLevelEventTypes.TOP_ANIMATION_START, 'animationStart'], [DOMTopLevelEventTypes.TOP_BLUR, 'blur'], + [DOMTopLevelEventTypes.TOP_CAN_PLAY_THROUGH, 'canPlayThrough'], + [DOMTopLevelEventTypes.TOP_CAN_PLAY, 'canPlay'], [DOMTopLevelEventTypes.TOP_CANCEL, 'cancel'], [DOMTopLevelEventTypes.TOP_CHANGE, 'change'], [DOMTopLevelEventTypes.TOP_CLICK, 'click'], @@ -469,64 +472,58 @@ function makeNativeSimulator(eventType, topLevelType) { [DOMTopLevelEventTypes.TOP_COPY, 'copy'], [DOMTopLevelEventTypes.TOP_CUT, 'cut'], [DOMTopLevelEventTypes.TOP_DOUBLE_CLICK, 'doubleClick'], - [DOMTopLevelEventTypes.TOP_DRAG, 'drag'], [DOMTopLevelEventTypes.TOP_DRAG_END, 'dragEnd'], [DOMTopLevelEventTypes.TOP_DRAG_ENTER, 'dragEnter'], [DOMTopLevelEventTypes.TOP_DRAG_EXIT, 'dragExit'], [DOMTopLevelEventTypes.TOP_DRAG_LEAVE, 'dragLeave'], [DOMTopLevelEventTypes.TOP_DRAG_OVER, 'dragOver'], [DOMTopLevelEventTypes.TOP_DRAG_START, 'dragStart'], + [DOMTopLevelEventTypes.TOP_DRAG, 'drag'], [DOMTopLevelEventTypes.TOP_DROP, 'drop'], + [DOMTopLevelEventTypes.TOP_DURATION_CHANGE, 'durationChange'], + [DOMTopLevelEventTypes.TOP_EMPTIED, 'emptied'], + [DOMTopLevelEventTypes.TOP_ENCRYPTED, 'encrypted'], + [DOMTopLevelEventTypes.TOP_ENDED, 'ended'], + [DOMTopLevelEventTypes.TOP_ERROR, 'error'], [DOMTopLevelEventTypes.TOP_FOCUS, 'focus'], [DOMTopLevelEventTypes.TOP_INPUT, 'input'], [DOMTopLevelEventTypes.TOP_KEY_DOWN, 'keyDown'], [DOMTopLevelEventTypes.TOP_KEY_PRESS, 'keyPress'], [DOMTopLevelEventTypes.TOP_KEY_UP, 'keyUp'], - [DOMTopLevelEventTypes.TOP_LOAD, 'load'], [DOMTopLevelEventTypes.TOP_LOAD_START, 'loadStart'], + [DOMTopLevelEventTypes.TOP_LOAD_START, 'loadStart'], + [DOMTopLevelEventTypes.TOP_LOAD, 'load'], + [DOMTopLevelEventTypes.TOP_LOADED_DATA, 'loadedData'], + [DOMTopLevelEventTypes.TOP_LOADED_METADATA, 'loadedMetadata'], [DOMTopLevelEventTypes.TOP_MOUSE_DOWN, 'mouseDown'], [DOMTopLevelEventTypes.TOP_MOUSE_MOVE, 'mouseMove'], [DOMTopLevelEventTypes.TOP_MOUSE_OUT, 'mouseOut'], [DOMTopLevelEventTypes.TOP_MOUSE_OVER, 'mouseOver'], [DOMTopLevelEventTypes.TOP_MOUSE_UP, 'mouseUp'], [DOMTopLevelEventTypes.TOP_PASTE, 'paste'], - [DOMTopLevelEventTypes.TOP_SCROLL, 'scroll'], - [DOMTopLevelEventTypes.TOP_SELECTION_CHANGE, 'selectionChange'], - [DOMTopLevelEventTypes.TOP_TEXT_INPUT, 'textInput'], - [DOMTopLevelEventTypes.TOP_TOGGLE, 'toggle'], - [DOMTopLevelEventTypes.TOP_TOUCH_CANCEL, 'touchCancel'], - [DOMTopLevelEventTypes.TOP_TOUCH_END, 'touchEnd'], - [DOMTopLevelEventTypes.TOP_TOUCH_MOVE, 'touchMove'], - [DOMTopLevelEventTypes.TOP_TOUCH_START, 'touchStart'], - [DOMTopLevelEventTypes.TOP_TRANSITION_END, 'transitionEnd'], - [DOMTopLevelEventTypes.TOP_WHEEL, 'wheel'], - [DOMTopLevelEventTypes.TOP_ABORT, 'abort'], - [DOMTopLevelEventTypes.TOP_CAN_PLAY, 'canPlay'], - [DOMTopLevelEventTypes.TOP_CAN_PLAY_THROUGH, 'canPlayThrough'], - [DOMTopLevelEventTypes.TOP_DURATION_CHANGE, 'durationChange'], - [DOMTopLevelEventTypes.TOP_EMPTIED, 'emptied'], - [DOMTopLevelEventTypes.TOP_ENCRYPTED, 'encrypted'], - [DOMTopLevelEventTypes.TOP_ENDED, 'ended'], - [DOMTopLevelEventTypes.TOP_ERROR, 'error'], - [DOMTopLevelEventTypes.TOP_LOADED_DATA, 'loadedData'], - [DOMTopLevelEventTypes.TOP_LOADED_METADATA, 'loadedMetadata'], - [DOMTopLevelEventTypes.TOP_LOAD_START, 'loadStart'], [DOMTopLevelEventTypes.TOP_PAUSE, 'pause'], [DOMTopLevelEventTypes.TOP_PLAY, 'play'], [DOMTopLevelEventTypes.TOP_PLAYING, 'playing'], [DOMTopLevelEventTypes.TOP_PROGRESS, 'progress'], [DOMTopLevelEventTypes.TOP_RATE_CHANGE, 'rateChange'], + [DOMTopLevelEventTypes.TOP_SCROLL, 'scroll'], [DOMTopLevelEventTypes.TOP_SEEKED, 'seeked'], [DOMTopLevelEventTypes.TOP_SEEKING, 'seeking'], + [DOMTopLevelEventTypes.TOP_SELECTION_CHANGE, 'selectionChange'], [DOMTopLevelEventTypes.TOP_STALLED, 'stalled'], [DOMTopLevelEventTypes.TOP_SUSPEND, 'suspend'], + [DOMTopLevelEventTypes.TOP_TEXT_INPUT, 'textInput'], [DOMTopLevelEventTypes.TOP_TIME_UPDATE, 'timeUpdate'], + [DOMTopLevelEventTypes.TOP_TOGGLE, 'toggle'], + [DOMTopLevelEventTypes.TOP_TOUCH_CANCEL, 'touchCancel'], + [DOMTopLevelEventTypes.TOP_TOUCH_END, 'touchEnd'], + [DOMTopLevelEventTypes.TOP_TOUCH_MOVE, 'touchMove'], + [DOMTopLevelEventTypes.TOP_TOUCH_START, 'touchStart'], + [DOMTopLevelEventTypes.TOP_TRANSITION_END, 'transitionEnd'], [DOMTopLevelEventTypes.TOP_VOLUME_CHANGE, 'volumeChange'], [DOMTopLevelEventTypes.TOP_WAITING, 'waiting'], -].forEach(function(tuple) { - const topLevelType = tuple[0]; - const eventType = tuple[1]; - + [DOMTopLevelEventTypes.TOP_WHEEL, 'wheel'], +].forEach(([topLevelType, eventType]) => { /** * @param {!Element|ReactDOMComponent} domComponentOrNode * @param {?Event} nativeEventData Fake native event to use in SyntheticEvent. From 4d76b154a69ee45750df8be2c75e0a8af252d200 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 25 Apr 2018 01:58:31 +0200 Subject: [PATCH 38/45] Add missing semi --- packages/events/TopLevelEventTypes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/events/TopLevelEventTypes.js b/packages/events/TopLevelEventTypes.js index 0985f9e543fe0..36f5f65a1037a 100644 --- a/packages/events/TopLevelEventTypes.js +++ b/packages/events/TopLevelEventTypes.js @@ -19,4 +19,4 @@ export type TopLevelType = | 'topTouchCancel' | 'topTouchEnd' | 'topTouchMove' - | 'topTouchStart' + | 'topTouchStart'; From af02875c73e85300495d986c66488cd5a30b5470 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Wed, 25 Apr 2018 02:13:07 +0200 Subject: [PATCH 39/45] Fix Flow issue --- packages/react-dom/src/events/SimpleEventPlugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dom/src/events/SimpleEventPlugin.js b/packages/react-dom/src/events/SimpleEventPlugin.js index f916ff39f13e1..ffaeb423ee793 100644 --- a/packages/react-dom/src/events/SimpleEventPlugin.js +++ b/packages/react-dom/src/events/SimpleEventPlugin.js @@ -124,7 +124,7 @@ const nonInteractiveEventTypeNames: Array = [ const eventTypes: EventTypes = {}; const topLevelEventsToDispatchConfig: { - [key: TopLevelTypes]: DispatchConfig, + [key: TopLevelType]: DispatchConfig, } = {}; function addEventTypeNameToConfig( From c1f6b3820fbd4a83c6da4cb89611a23d5ea29135 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Thu, 26 Apr 2018 00:18:38 +0200 Subject: [PATCH 40/45] Make TopLevelType clearer --- packages/events/TopLevelEventTypes.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/events/TopLevelEventTypes.js b/packages/events/TopLevelEventTypes.js index 36f5f65a1037a..f9d4722abb8c1 100644 --- a/packages/events/TopLevelEventTypes.js +++ b/packages/events/TopLevelEventTypes.js @@ -9,8 +9,7 @@ import type {DOMTopLevelEventType} from 'react-dom/src/events/DOMTopLevelEventTypes'; -export type TopLevelType = - | DOMTopLevelEventType +type RNTopLevelEventType = | 'topMouseDown' | 'topMouseMove' | 'topMouseUp' @@ -20,3 +19,5 @@ export type TopLevelType = | 'topTouchEnd' | 'topTouchMove' | 'topTouchStart'; + +export type TopLevelType = DOMTopLevelEventType | RNTopLevelEventType; From 0cb8fad57b1099b035ee58c60208477e26f9124d Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Thu, 26 Apr 2018 00:39:43 +0200 Subject: [PATCH 41/45] Favor for loops --- .../react-dom/src/client/ReactDOMFiberComponent.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/react-dom/src/client/ReactDOMFiberComponent.js b/packages/react-dom/src/client/ReactDOMFiberComponent.js index 43a0774b37e1a..4c3c7a9c1dd39 100644 --- a/packages/react-dom/src/client/ReactDOMFiberComponent.js +++ b/packages/react-dom/src/client/ReactDOMFiberComponent.js @@ -454,9 +454,9 @@ export function setInitialProperties( case 'video': case 'audio': // Create listener for each media event - mediaEventTypes.forEach((_value, topEventName) => { - trapBubbledEvent(topEventName, domElement); - }); + for (let i = 0; i < mediaEventTypes.length; i++) { + trapBubbledEvent(mediaEventTypes[i], domElement); + } props = rawProps; break; case 'source': @@ -840,9 +840,9 @@ export function diffHydratedProperties( case 'video': case 'audio': // Create listener for each media event - mediaEventTypes.forEach((_value, topEventName) => { - trapBubbledEvent(topEventName, domElement); - }); + for (let i = 0; i < mediaEventTypes.length; i++) { + trapBubbledEvent(mediaEventTypes[i], domElement); + } break; case 'source': trapBubbledEvent(TOP_ERROR, domElement); From df7f91d15b4c8169fef972b9a9dd33084d04ae9a Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Thu, 26 Apr 2018 00:40:07 +0200 Subject: [PATCH 42/45] Explain the new DOMTopLevelEventTypes concept --- packages/react-dom/src/events/DOMTopLevelEventTypes.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/react-dom/src/events/DOMTopLevelEventTypes.js b/packages/react-dom/src/events/DOMTopLevelEventTypes.js index 61421c08a6e25..79f13057f9ef9 100644 --- a/packages/react-dom/src/events/DOMTopLevelEventTypes.js +++ b/packages/react-dom/src/events/DOMTopLevelEventTypes.js @@ -10,6 +10,16 @@ import type {TopLevelType} from 'events/TopLevelEventTypes'; import getVendorPrefixedEventName from './getVendorPrefixedEventName'; +/** + * To identify top level events in react-dom, we use constants defined by this + * module. Those are completely opaque to every other module but we rely on them + * being the raw DOM event names inside this module. This allows us to build a + * very efficient mapping from top level identifiers to the raw event type. + * + * The use of an `opaque` flow type makes sure that we can only access the value + * of a constant in this module. + */ + // eslint-disable-next-line no-undef export opaque type DOMTopLevelEventType = | 'abort' From 15c2723d9b02570e9890c654a428dce02ea6e558 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Fri, 4 May 2018 20:56:01 +0100 Subject: [PATCH 43/45] Use static injection for Responder plugin types --- packages/events/ResponderEventPlugin.js | 605 +++++++++++++++ .../events/ResponderTopLevelEventTypes.js | 31 + ...Store.js => ResponderTouchHistoryStore.js} | 76 +- .../ResponderEventPlugin-test.internal.js | 31 +- packages/events/createResponderEventPlugin.js | 696 ------------------ .../forks/ResponderTopLevelEventTypes.dom.js | 41 ++ .../src/events/DOMEventPluginUtils.js | 31 - .../src/events/DOMResponderEventPlugin.js | 42 -- .../react-dom/src/events/TapEventPlugin.js | 13 +- .../ReactDOMUnstableNativeDependencies.js | 6 +- .../src/ReactNativeInjectionShared.js | 6 +- .../src/ReactNativeResponderEventPlugin.js | 26 - .../ReactNativeEvents-test.internal.js | 9 +- scripts/rollup/forks.js | 8 + 14 files changed, 749 insertions(+), 872 deletions(-) create mode 100644 packages/events/ResponderEventPlugin.js create mode 100644 packages/events/ResponderTopLevelEventTypes.js rename packages/events/{createResponderTouchHistoryStore.js => ResponderTouchHistoryStore.js} (76%) delete mode 100644 packages/events/createResponderEventPlugin.js create mode 100644 packages/events/forks/ResponderTopLevelEventTypes.dom.js delete mode 100644 packages/react-dom/src/events/DOMEventPluginUtils.js delete mode 100644 packages/react-dom/src/events/DOMResponderEventPlugin.js delete mode 100644 packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js diff --git a/packages/events/ResponderEventPlugin.js b/packages/events/ResponderEventPlugin.js new file mode 100644 index 0000000000000..7859b19fd4bc8 --- /dev/null +++ b/packages/events/ResponderEventPlugin.js @@ -0,0 +1,605 @@ +/** + * 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. + */ + +import {getLowestCommonAncestor, isAncestor} from 'shared/ReactTreeTraversal'; + +import { + executeDirectDispatch, + hasDispatches, + executeDispatchesInOrderStopAtTrue, + getInstanceFromNode, +} from './EventPluginUtils'; +import { + accumulateDirectDispatches, + accumulateTwoPhaseDispatches, + accumulateTwoPhaseDispatchesSkipTarget, +} from './EventPropagators'; +import ResponderSyntheticEvent from './ResponderSyntheticEvent'; +import ResponderTouchHistoryStore from './ResponderTouchHistoryStore'; +import accumulate from './accumulate'; +import { + TOP_SCROLL, + TOP_SELECTION_CHANGE, + TOP_TOUCH_CANCEL, + isStartish, + isMoveish, + isEndish, + startDependencies, + moveDependencies, + endDependencies, +} from './ResponderTopLevelEventTypes'; + +/** + * Instance of element that should respond to touch/move types of interactions, + * as indicated explicitly by relevant callbacks. + */ +let responderInst = null; + +/** + * Count of current touches. A textInput should become responder iff the + * selection changes while there is a touch on the screen. + */ +let trackedTouchCount = 0; + +const changeResponder = function(nextResponderInst, blockHostResponder) { + const oldResponderInst = responderInst; + responderInst = nextResponderInst; + if (ResponderEventPlugin.GlobalResponderHandler !== null) { + ResponderEventPlugin.GlobalResponderHandler.onChange( + oldResponderInst, + nextResponderInst, + blockHostResponder, + ); + } +}; + +const eventTypes = { + /** + * On a `touchStart`/`mouseDown`, is it desired that this element become the + * responder? + */ + startShouldSetResponder: { + phasedRegistrationNames: { + bubbled: 'onStartShouldSetResponder', + captured: 'onStartShouldSetResponderCapture', + }, + dependencies: startDependencies, + }, + + /** + * On a `scroll`, is it desired that this element become the responder? This + * is usually not needed, but should be used to retroactively infer that a + * `touchStart` had occurred during momentum scroll. During a momentum scroll, + * a touch start will be immediately followed by a scroll event if the view is + * currently scrolling. + * + * TODO: This shouldn't bubble. + */ + scrollShouldSetResponder: { + phasedRegistrationNames: { + bubbled: 'onScrollShouldSetResponder', + captured: 'onScrollShouldSetResponderCapture', + }, + dependencies: [TOP_SCROLL], + }, + + /** + * On text selection change, should this element become the responder? This + * is needed for text inputs or other views with native selection, so the + * JS view can claim the responder. + * + * TODO: This shouldn't bubble. + */ + selectionChangeShouldSetResponder: { + phasedRegistrationNames: { + bubbled: 'onSelectionChangeShouldSetResponder', + captured: 'onSelectionChangeShouldSetResponderCapture', + }, + dependencies: [TOP_SELECTION_CHANGE], + }, + + /** + * On a `touchMove`/`mouseMove`, is it desired that this element become the + * responder? + */ + moveShouldSetResponder: { + phasedRegistrationNames: { + bubbled: 'onMoveShouldSetResponder', + captured: 'onMoveShouldSetResponderCapture', + }, + dependencies: moveDependencies, + }, + + /** + * Direct responder events dispatched directly to responder. Do not bubble. + */ + responderStart: { + registrationName: 'onResponderStart', + dependencies: startDependencies, + }, + responderMove: { + registrationName: 'onResponderMove', + dependencies: moveDependencies, + }, + responderEnd: { + registrationName: 'onResponderEnd', + dependencies: endDependencies, + }, + responderRelease: { + registrationName: 'onResponderRelease', + dependencies: [], + }, + responderTerminationRequest: { + registrationName: 'onResponderTerminationRequest', + dependencies: [], + }, + responderGrant: { + registrationName: 'onResponderGrant', + dependencies: [], + }, + responderReject: { + registrationName: 'onResponderReject', + dependencies: [], + }, + responderTerminate: { + registrationName: 'onResponderTerminate', + dependencies: [], + }, +}; + +/** + * + * Responder System: + * ---------------- + * + * - A global, solitary "interaction lock" on a view. + * - If a node becomes the responder, it should convey visual feedback + * immediately to indicate so, either by highlighting or moving accordingly. + * - To be the responder means, that touches are exclusively important to that + * responder view, and no other view. + * - While touches are still occurring, the responder lock can be transferred to + * a new view, but only to increasingly "higher" views (meaning ancestors of + * the current responder). + * + * Responder being granted: + * ------------------------ + * + * - Touch starts, moves, and scrolls can cause an ID to become the responder. + * - We capture/bubble `startShouldSetResponder`/`moveShouldSetResponder` to + * the "appropriate place". + * - If nothing is currently the responder, the "appropriate place" is the + * initiating event's `targetID`. + * - If something *is* already the responder, the "appropriate place" is the + * first common ancestor of the event target and the current `responderInst`. + * - Some negotiation happens: See the timing diagram below. + * - Scrolled views automatically become responder. The reasoning is that a + * platform scroll view that isn't built on top of the responder system has + * began scrolling, and the active responder must now be notified that the + * interaction is no longer locked to it - the system has taken over. + * + * - Responder being released: + * As soon as no more touches that *started* inside of descendants of the + * *current* responderInst, an `onResponderRelease` event is dispatched to the + * current responder, and the responder lock is released. + * + * TODO: + * - on "end", a callback hook for `onResponderEndShouldRemainResponder` that + * determines if the responder lock should remain. + * - If a view shouldn't "remain" the responder, any active touches should by + * default be considered "dead" and do not influence future negotiations or + * bubble paths. It should be as if those touches do not exist. + * -- For multitouch: Usually a translate-z will choose to "remain" responder + * after one out of many touches ended. For translate-y, usually the view + * doesn't wish to "remain" responder after one of many touches end. + * - Consider building this on top of a `stopPropagation` model similar to + * `W3C` events. + * - Ensure that `onResponderTerminate` is called on touch cancels, whether or + * not `onResponderTerminationRequest` returns `true` or `false`. + * + */ + +/* Negotiation Performed + +-----------------------+ + / \ +Process low level events to + Current Responder + wantsResponderID +determine who to perform negot-| (if any exists at all) | +iation/transition | Otherwise just pass through| +-------------------------------+----------------------------+------------------+ +Bubble to find first ID | | +to return true:wantsResponderID| | + | | + +-------------+ | | + | onTouchStart| | | + +------+------+ none | | + | return| | ++-----------v-------------+true| +------------------------+ | +|onStartShouldSetResponder|----->|onResponderStart (cur) |<-----------+ ++-----------+-------------+ | +------------------------+ | | + | | | +--------+-------+ + | returned true for| false:REJECT +-------->|onResponderReject + | wantsResponderID | | | +----------------+ + | (now attempt | +------------------+-----+ | + | handoff) | | onResponder | | + +------------------->| TerminationRequest| | + | +------------------+-----+ | + | | | +----------------+ + | true:GRANT +-------->|onResponderGrant| + | | +--------+-------+ + | +------------------------+ | | + | | onResponderTerminate |<-----------+ + | +------------------+-----+ | + | | | +----------------+ + | +-------->|onResponderStart| + | | +----------------+ +Bubble to find first ID | | +to return true:wantsResponderID| | + | | + +-------------+ | | + | onTouchMove | | | + +------+------+ none | | + | return| | ++-----------v-------------+true| +------------------------+ | +|onMoveShouldSetResponder |----->|onResponderMove (cur) |<-----------+ ++-----------+-------------+ | +------------------------+ | | + | | | +--------+-------+ + | returned true for| false:REJECT +-------->|onResponderRejec| + | wantsResponderID | | | +----------------+ + | (now attempt | +------------------+-----+ | + | handoff) | | onResponder | | + +------------------->| TerminationRequest| | + | +------------------+-----+ | + | | | +----------------+ + | true:GRANT +-------->|onResponderGrant| + | | +--------+-------+ + | +------------------------+ | | + | | onResponderTerminate |<-----------+ + | +------------------+-----+ | + | | | +----------------+ + | +-------->|onResponderMove | + | | +----------------+ + | | + | | + Some active touch started| | + inside current responder | +------------------------+ | + +------------------------->| onResponderEnd | | + | | +------------------------+ | + +---+---------+ | | + | onTouchEnd | | | + +---+---------+ | | + | | +------------------------+ | + +------------------------->| onResponderEnd | | + No active touches started| +-----------+------------+ | + inside current responder | | | + | v | + | +------------------------+ | + | | onResponderRelease | | + | +------------------------+ | + | | + + + */ + +/** + * A note about event ordering in the `EventPluginHub`. + * + * Suppose plugins are injected in the following order: + * + * `[R, S, C]` + * + * To help illustrate the example, assume `S` is `SimpleEventPlugin` (for + * `onClick` etc) and `R` is `ResponderEventPlugin`. + * + * "Deferred-Dispatched Events": + * + * - The current event plugin system will traverse the list of injected plugins, + * in order, and extract events by collecting the plugin's return value of + * `extractEvents()`. + * - These events that are returned from `extractEvents` are "deferred + * dispatched events". + * - When returned from `extractEvents`, deferred-dispatched events contain an + * "accumulation" of deferred dispatches. + * - These deferred dispatches are accumulated/collected before they are + * returned, but processed at a later time by the `EventPluginHub` (hence the + * name deferred). + * + * In the process of returning their deferred-dispatched events, event plugins + * themselves can dispatch events on-demand without returning them from + * `extractEvents`. Plugins might want to do this, so that they can use event + * dispatching as a tool that helps them decide which events should be extracted + * in the first place. + * + * "On-Demand-Dispatched Events": + * + * - On-demand-dispatched events are not returned from `extractEvents`. + * - On-demand-dispatched events are dispatched during the process of returning + * the deferred-dispatched events. + * - They should not have side effects. + * - They should be avoided, and/or eventually be replaced with another + * abstraction that allows event plugins to perform multiple "rounds" of event + * extraction. + * + * Therefore, the sequence of event dispatches becomes: + * + * - `R`s on-demand events (if any) (dispatched by `R` on-demand) + * - `S`s on-demand events (if any) (dispatched by `S` on-demand) + * - `C`s on-demand events (if any) (dispatched by `C` on-demand) + * - `R`s extracted events (if any) (dispatched by `EventPluginHub`) + * - `S`s extracted events (if any) (dispatched by `EventPluginHub`) + * - `C`s extracted events (if any) (dispatched by `EventPluginHub`) + * + * In the case of `ResponderEventPlugin`: If the `startShouldSetResponder` + * on-demand dispatch returns `true` (and some other details are satisfied) the + * `onResponderGrant` deferred dispatched event is returned from + * `extractEvents`. The sequence of dispatch executions in this case + * will appear as follows: + * + * - `startShouldSetResponder` (`ResponderEventPlugin` dispatches on-demand) + * - `touchStartCapture` (`EventPluginHub` dispatches as usual) + * - `touchStart` (`EventPluginHub` dispatches as usual) + * - `responderGrant/Reject` (`EventPluginHub` dispatches as usual) + */ + +function setResponderAndExtractTransfer( + topLevelType, + targetInst, + nativeEvent, + nativeEventTarget, +) { + const shouldSetEventType = isStartish(topLevelType) + ? eventTypes.startShouldSetResponder + : isMoveish(topLevelType) + ? eventTypes.moveShouldSetResponder + : topLevelType === TOP_SELECTION_CHANGE + ? eventTypes.selectionChangeShouldSetResponder + : eventTypes.scrollShouldSetResponder; + + // TODO: stop one short of the current responder. + const bubbleShouldSetFrom = !responderInst + ? targetInst + : getLowestCommonAncestor(responderInst, targetInst); + + // When capturing/bubbling the "shouldSet" event, we want to skip the target + // (deepest ID) if it happens to be the current responder. The reasoning: + // It's strange to get an `onMoveShouldSetResponder` when you're *already* + // the responder. + const skipOverBubbleShouldSetFrom = bubbleShouldSetFrom === responderInst; + const shouldSetEvent = ResponderSyntheticEvent.getPooled( + shouldSetEventType, + bubbleShouldSetFrom, + nativeEvent, + nativeEventTarget, + ); + shouldSetEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; + if (skipOverBubbleShouldSetFrom) { + accumulateTwoPhaseDispatchesSkipTarget(shouldSetEvent); + } else { + accumulateTwoPhaseDispatches(shouldSetEvent); + } + const wantsResponderInst = executeDispatchesInOrderStopAtTrue(shouldSetEvent); + if (!shouldSetEvent.isPersistent()) { + shouldSetEvent.constructor.release(shouldSetEvent); + } + + if (!wantsResponderInst || wantsResponderInst === responderInst) { + return null; + } + let extracted; + const grantEvent = ResponderSyntheticEvent.getPooled( + eventTypes.responderGrant, + wantsResponderInst, + nativeEvent, + nativeEventTarget, + ); + grantEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; + + accumulateDirectDispatches(grantEvent); + const blockHostResponder = executeDirectDispatch(grantEvent) === true; + if (responderInst) { + const terminationRequestEvent = ResponderSyntheticEvent.getPooled( + eventTypes.responderTerminationRequest, + responderInst, + nativeEvent, + nativeEventTarget, + ); + terminationRequestEvent.touchHistory = + ResponderTouchHistoryStore.touchHistory; + accumulateDirectDispatches(terminationRequestEvent); + const shouldSwitch = + !hasDispatches(terminationRequestEvent) || + executeDirectDispatch(terminationRequestEvent); + if (!terminationRequestEvent.isPersistent()) { + terminationRequestEvent.constructor.release(terminationRequestEvent); + } + + if (shouldSwitch) { + const terminateEvent = ResponderSyntheticEvent.getPooled( + eventTypes.responderTerminate, + responderInst, + nativeEvent, + nativeEventTarget, + ); + terminateEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; + accumulateDirectDispatches(terminateEvent); + extracted = accumulate(extracted, [grantEvent, terminateEvent]); + changeResponder(wantsResponderInst, blockHostResponder); + } else { + const rejectEvent = ResponderSyntheticEvent.getPooled( + eventTypes.responderReject, + wantsResponderInst, + nativeEvent, + nativeEventTarget, + ); + rejectEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; + accumulateDirectDispatches(rejectEvent); + extracted = accumulate(extracted, rejectEvent); + } + } else { + extracted = accumulate(extracted, grantEvent); + changeResponder(wantsResponderInst, blockHostResponder); + } + return extracted; +} + +/** + * A transfer is a negotiation between a currently set responder and the next + * element to claim responder status. Any start event could trigger a transfer + * of responderInst. Any move event could trigger a transfer. + * + * @param {string} topLevelType Record from `BrowserEventConstants`. + * @return {boolean} True if a transfer of responder could possibly occur. + */ +function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) { + return ( + topLevelInst && + // 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 === TOP_SCROLL && !nativeEvent.responderIgnoreScroll) || + (trackedTouchCount > 0 && topLevelType === TOP_SELECTION_CHANGE) || + isStartish(topLevelType) || + isMoveish(topLevelType)) + ); +} + +/** + * Returns whether or not this touch end event makes it such that there are no + * longer any touches that started inside of the current `responderInst`. + * + * @param {NativeEvent} nativeEvent Native touch end event. + * @return {boolean} Whether or not this touch end event ends the responder. + */ +function noResponderTouches(nativeEvent) { + const touches = nativeEvent.touches; + if (!touches || touches.length === 0) { + return true; + } + for (let i = 0; i < touches.length; i++) { + const activeTouch = touches[i]; + const target = activeTouch.target; + if (target !== null && target !== undefined && target !== 0) { + // Is the original touch location inside of the current responder? + const targetInst = getInstanceFromNode(target); + if (isAncestor(responderInst, targetInst)) { + return false; + } + } + } + return true; +} + +const ResponderEventPlugin = { + /* For unit testing only */ + _getResponder: function() { + return responderInst; + }, + + eventTypes: eventTypes, + + /** + * We must be resilient to `targetInst` being `null` on `touchMove` or + * `touchEnd`. On certain platforms, this means that a native scroll has + * assumed control and the original touch targets are destroyed. + */ + extractEvents: function( + topLevelType, + targetInst, + nativeEvent, + nativeEventTarget, + ) { + if (isStartish(topLevelType)) { + trackedTouchCount += 1; + } else if (isEndish(topLevelType)) { + if (trackedTouchCount >= 0) { + trackedTouchCount -= 1; + } else { + console.error( + 'Ended a touch event which was not counted in `trackedTouchCount`.', + ); + return null; + } + } + + ResponderTouchHistoryStore.recordTouchTrack(topLevelType, nativeEvent); + + let extracted = canTriggerTransfer(topLevelType, targetInst, nativeEvent) + ? setResponderAndExtractTransfer( + topLevelType, + targetInst, + nativeEvent, + nativeEventTarget, + ) + : null; + // Responder may or may not have transferred on a new touch start/move. + // Regardless, whoever is the responder after any potential transfer, we + // direct all touch start/move/ends to them in the form of + // `onResponderMove/Start/End`. These will be called for *every* additional + // finger that move/start/end, dispatched directly to whoever is the + // current responder at that moment, until the responder is "released". + // + // These multiple individual change touch events are are always bookended + // by `onResponderGrant`, and one of + // (`onResponderRelease/onResponderTerminate`). + const isResponderTouchStart = responderInst && isStartish(topLevelType); + const isResponderTouchMove = responderInst && isMoveish(topLevelType); + const isResponderTouchEnd = responderInst && isEndish(topLevelType); + const incrementalTouch = isResponderTouchStart + ? eventTypes.responderStart + : isResponderTouchMove + ? eventTypes.responderMove + : isResponderTouchEnd ? eventTypes.responderEnd : null; + + if (incrementalTouch) { + const gesture = ResponderSyntheticEvent.getPooled( + incrementalTouch, + responderInst, + nativeEvent, + nativeEventTarget, + ); + gesture.touchHistory = ResponderTouchHistoryStore.touchHistory; + accumulateDirectDispatches(gesture); + extracted = accumulate(extracted, gesture); + } + + const isResponderTerminate = + responderInst && topLevelType === TOP_TOUCH_CANCEL; + const isResponderRelease = + responderInst && + !isResponderTerminate && + isEndish(topLevelType) && + noResponderTouches(nativeEvent); + const finalTouch = isResponderTerminate + ? eventTypes.responderTerminate + : isResponderRelease ? eventTypes.responderRelease : null; + if (finalTouch) { + const finalEvent = ResponderSyntheticEvent.getPooled( + finalTouch, + responderInst, + nativeEvent, + nativeEventTarget, + ); + finalEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; + accumulateDirectDispatches(finalEvent); + extracted = accumulate(extracted, finalEvent); + changeResponder(null); + } + + return extracted; + }, + + GlobalResponderHandler: null, + + injection: { + /** + * @param {{onChange: (ReactID, ReactID) => void} GlobalResponderHandler + * Object that handles any change in responder. Use this to inject + * integration with an existing touch handling system etc. + */ + injectGlobalResponderHandler(GlobalResponderHandler) { + ResponderEventPlugin.GlobalResponderHandler = GlobalResponderHandler; + }, + }, +}; + +export default ResponderEventPlugin; diff --git a/packages/events/ResponderTopLevelEventTypes.js b/packages/events/ResponderTopLevelEventTypes.js new file mode 100644 index 0000000000000..54ad053a66464 --- /dev/null +++ b/packages/events/ResponderTopLevelEventTypes.js @@ -0,0 +1,31 @@ +/** + * 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. + * + * @flow + */ + +export const TOP_TOUCH_START = 'topTouchStart'; +export const TOP_TOUCH_MOVE = 'topTouchMove'; +export const TOP_TOUCH_END = 'topTouchEnd'; +export const TOP_TOUCH_CANCEL = 'topTouchCancel'; +export const TOP_SCROLL = 'topScroll'; +export const TOP_SELECTION_CHANGE = 'topSelectionChange'; + +export function isStartish(topLevelType: mixed): boolean { + return topLevelType === TOP_TOUCH_START; +} + +export function isMoveish(topLevelType: mixed): boolean { + return topLevelType === TOP_TOUCH_MOVE; +} + +export function isEndish(topLevelType: mixed): boolean { + return topLevelType === TOP_TOUCH_END || topLevelType === TOP_TOUCH_CANCEL; +} + +export const startDependencies = [TOP_TOUCH_START]; +export const moveDependencies = [TOP_TOUCH_MOVE]; +export const endDependencies = [TOP_TOUCH_CANCEL, TOP_TOUCH_END]; diff --git a/packages/events/createResponderTouchHistoryStore.js b/packages/events/ResponderTouchHistoryStore.js similarity index 76% rename from packages/events/createResponderTouchHistoryStore.js rename to packages/events/ResponderTouchHistoryStore.js index 442a0d4ac0a15..807a5a08d9912 100644 --- a/packages/events/createResponderTouchHistoryStore.js +++ b/packages/events/ResponderTouchHistoryStore.js @@ -10,7 +10,7 @@ import invariant from 'fbjs/lib/invariant'; import warning from 'fbjs/lib/warning'; -import type {TopLevelType} from './TopLevelEventTypes'; +import {isStartish, isMoveish, isEndish} from './ResponderTopLevelEventTypes'; /** * Tracks the position and time of each active touch by `touch.identifier`. We @@ -176,50 +176,40 @@ function printTouchBank(): string { return printed; } -export default function createResponderTouchHistoryStore( - isStartish: (topLevelType: TopLevelType) => boolean, - isMoveish: (topLevelType: TopLevelType) => boolean, - isEndish: (topLevelType: TopLevelType) => boolean, -) { - const ResponderTouchHistoryStore = { - recordTouchTrack( - topLevelType: TopLevelType, - nativeEvent: TouchEvent, - ): void { - if (isMoveish(topLevelType)) { - nativeEvent.changedTouches.forEach(recordTouchMove); - } else if (isStartish(topLevelType)) { - nativeEvent.changedTouches.forEach(recordTouchStart); - touchHistory.numberActiveTouches = nativeEvent.touches.length; - if (touchHistory.numberActiveTouches === 1) { - touchHistory.indexOfSingleActiveTouch = - nativeEvent.touches[0].identifier; - } - } else if (isEndish(topLevelType)) { - nativeEvent.changedTouches.forEach(recordTouchEnd); - touchHistory.numberActiveTouches = nativeEvent.touches.length; - if (touchHistory.numberActiveTouches === 1) { - for (let i = 0; i < touchBank.length; i++) { - const touchTrackToCheck = touchBank[i]; - if (touchTrackToCheck != null && touchTrackToCheck.touchActive) { - touchHistory.indexOfSingleActiveTouch = i; - break; - } - } - if (__DEV__) { - const activeRecord = - touchBank[touchHistory.indexOfSingleActiveTouch]; - warning( - activeRecord != null && activeRecord.touchActive, - 'Cannot find single active touch.', - ); +const ResponderTouchHistoryStore = { + recordTouchTrack(topLevelType: string, nativeEvent: TouchEvent): void { + if (isMoveish(topLevelType)) { + nativeEvent.changedTouches.forEach(recordTouchMove); + } else if (isStartish(topLevelType)) { + nativeEvent.changedTouches.forEach(recordTouchStart); + touchHistory.numberActiveTouches = nativeEvent.touches.length; + if (touchHistory.numberActiveTouches === 1) { + touchHistory.indexOfSingleActiveTouch = + nativeEvent.touches[0].identifier; + } + } else if (isEndish(topLevelType)) { + nativeEvent.changedTouches.forEach(recordTouchEnd); + touchHistory.numberActiveTouches = nativeEvent.touches.length; + if (touchHistory.numberActiveTouches === 1) { + for (let i = 0; i < touchBank.length; i++) { + const touchTrackToCheck = touchBank[i]; + if (touchTrackToCheck != null && touchTrackToCheck.touchActive) { + touchHistory.indexOfSingleActiveTouch = i; + break; } } + if (__DEV__) { + const activeRecord = touchBank[touchHistory.indexOfSingleActiveTouch]; + warning( + activeRecord != null && activeRecord.touchActive, + 'Cannot find single active touch.', + ); + } } - }, + } + }, - touchHistory, - }; + touchHistory, +}; - return ResponderTouchHistoryStore; -} +export default ResponderTouchHistoryStore; diff --git a/packages/events/__tests__/ResponderEventPlugin-test.internal.js b/packages/events/__tests__/ResponderEventPlugin-test.internal.js index 6afce41635c47..d583126f0b1bc 100644 --- a/packages/events/__tests__/ResponderEventPlugin-test.internal.js +++ b/packages/events/__tests__/ResponderEventPlugin-test.internal.js @@ -11,17 +11,6 @@ const {HostComponent} = require('shared/ReactTypeOfWork'); -// To test this module against public API, we'll use the DOM version of -// ResponderEventPlugin for these tests. This version will require the -// DOM specific top event IDs. -const { - TOP_SCROLL, - TOP_TOUCH_CANCEL, - TOP_TOUCH_END, - TOP_TOUCH_MOVE, - TOP_TOUCH_START, -} = require('react-dom/src/events/DOMTopLevelEventTypes'); - let EventPluginHub; let ResponderEventPlugin; @@ -77,13 +66,13 @@ const _touchConfig = function( const allTouchObjects = allTouchHandles.map(touch); const changedTouchObjects = subsequence(allTouchObjects, changedIndices); const activeTouchObjects = - topType === TOP_TOUCH_START + topType === 'topTouchStart' ? allTouchObjects - : topType === TOP_TOUCH_MOVE + : topType === 'topTouchMove' ? allTouchObjects - : topType === TOP_TOUCH_END + : topType === 'topTouchEnd' ? antiSubsequence(allTouchObjects, changedIndices) - : topType === TOP_TOUCH_CANCEL + : topType === 'topTouchCancel' ? antiSubsequence(allTouchObjects, changedIndices) : null; @@ -118,7 +107,7 @@ const _touchConfig = function( */ const startConfig = function(nodeHandle, allTouchHandles, changedIndices) { return _touchConfig( - TOP_TOUCH_START, + 'topTouchStart', nodeHandle, allTouchHandles, changedIndices, @@ -131,7 +120,7 @@ const startConfig = function(nodeHandle, allTouchHandles, changedIndices) { */ const moveConfig = function(nodeHandle, allTouchHandles, changedIndices) { return _touchConfig( - TOP_TOUCH_MOVE, + 'topTouchMove', nodeHandle, allTouchHandles, changedIndices, @@ -144,7 +133,7 @@ const moveConfig = function(nodeHandle, allTouchHandles, changedIndices) { */ const endConfig = function(nodeHandle, allTouchHandles, changedIndices) { return _touchConfig( - TOP_TOUCH_END, + 'topTouchEnd', nodeHandle, allTouchHandles, changedIndices, @@ -1303,7 +1292,7 @@ describe('ResponderEventPlugin', () => { config.responderReject.parent = {order: 5}; run(config, three, { - topLevelType: TOP_SCROLL, + topLevelType: 'topScroll', targetInst: getInstanceFromNode(three.parent), nativeEvent: {}, }); @@ -1330,7 +1319,7 @@ describe('ResponderEventPlugin', () => { config.responderTerminate.child = {order: 5}; run(config, three, { - topLevelType: TOP_SCROLL, + topLevelType: 'topScroll', targetInst: getInstanceFromNode(three.parent), nativeEvent: {}, }); @@ -1368,7 +1357,7 @@ describe('ResponderEventPlugin', () => { config.responderTerminate.child = {order: 1}; const nativeEvent = _touchConfig( - TOP_TOUCH_CANCEL, + 'topTouchCancel', three.child, [three.child], [0], diff --git a/packages/events/createResponderEventPlugin.js b/packages/events/createResponderEventPlugin.js deleted file mode 100644 index 0a3f0c2184c4b..0000000000000 --- a/packages/events/createResponderEventPlugin.js +++ /dev/null @@ -1,696 +0,0 @@ -/** - * 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. - * - * @flow - */ - -import {getLowestCommonAncestor, isAncestor} from 'shared/ReactTreeTraversal'; - -import { - executeDirectDispatch, - hasDispatches, - executeDispatchesInOrderStopAtTrue, - getInstanceFromNode, -} from './EventPluginUtils'; -import { - accumulateDirectDispatches, - accumulateTwoPhaseDispatches, - accumulateTwoPhaseDispatchesSkipTarget, -} from './EventPropagators'; -import ResponderSyntheticEvent from './ResponderSyntheticEvent'; -import accumulate from './accumulate'; -import createResponderTouchHistoryStore from './createResponderTouchHistoryStore'; - -import type {TopLevelType} from './TopLevelEventTypes'; -import type {AnyNativeEvent} from './PluginModuleType'; -import type {Fiber} from 'react-reconciler/src/ReactFiber'; - -/** - * - * Responder System: - * ---------------- - * - * - A global, solitary "interaction lock" on a view. - * - If a node becomes the responder, it should convey visual feedback - * immediately to indicate so, either by highlighting or moving accordingly. - * - To be the responder means, that touches are exclusively important to that - * responder view, and no other view. - * - While touches are still occurring, the responder lock can be transferred to - * a new view, but only to increasingly "higher" views (meaning ancestors of - * the current responder). - * - * Responder being granted: - * ------------------------ - * - * - Touch starts, moves, and scrolls can cause an ID to become the responder. - * - We capture/bubble `startShouldSetResponder`/`moveShouldSetResponder` to - * the "appropriate place". - * - If nothing is currently the responder, the "appropriate place" is the - * initiating event's `targetID`. - * - If something *is* already the responder, the "appropriate place" is the - * first common ancestor of the event target and the current `responderInst`. - * - Some negotiation happens: See the timing diagram below. - * - Scrolled views automatically become responder. The reasoning is that a - * platform scroll view that isn't built on top of the responder system has - * began scrolling, and the active responder must now be notified that the - * interaction is no longer locked to it - the system has taken over. - * - * - Responder being released: - * As soon as no more touches that *started* inside of descendants of the - * *current* responderInst, an `onResponderRelease` event is dispatched to the - * current responder, and the responder lock is released. - * - * TODO: - * - on "end", a callback hook for `onResponderEndShouldRemainResponder` that - * determines if the responder lock should remain. - * - If a view shouldn't "remain" the responder, any active touches should by - * default be considered "dead" and do not influence future negotiations or - * bubble paths. It should be as if those touches do not exist. - * -- For multitouch: Usually a translate-z will choose to "remain" responder - * after one out of many touches ended. For translate-y, usually the view - * doesn't wish to "remain" responder after one of many touches end. - * - Consider building this on top of a `stopPropagation` model similar to - * `W3C` events. - * - Ensure that `onResponderTerminate` is called on touch cancels, whether or - * not `onResponderTerminationRequest` returns `true` or `false`. - * - */ - -/* Negotiation Performed - +-----------------------+ - / \ -Process low level events to + Current Responder + wantsResponderID -determine who to perform negot-| (if any exists at all) | -iation/transition | Otherwise just pass through| --------------------------------+----------------------------+------------------+ -Bubble to find first ID | | -to return true:wantsResponderID| | - | | - +-------------+ | | - | onTouchStart| | | - +------+------+ none | | - | return| | -+-----------v-------------+true| +------------------------+ | -|onStartShouldSetResponder|----->|onResponderStart (cur) |<-----------+ -+-----------+-------------+ | +------------------------+ | | - | | | +--------+-------+ - | returned true for| false:REJECT +-------->|onResponderReject - | wantsResponderID | | | +----------------+ - | (now attempt | +------------------+-----+ | - | handoff) | | onResponder | | - +------------------->| TerminationRequest| | - | +------------------+-----+ | - | | | +----------------+ - | true:GRANT +-------->|onResponderGrant| - | | +--------+-------+ - | +------------------------+ | | - | | onResponderTerminate |<-----------+ - | +------------------+-----+ | - | | | +----------------+ - | +-------->|onResponderStart| - | | +----------------+ -Bubble to find first ID | | -to return true:wantsResponderID| | - | | - +-------------+ | | - | onTouchMove | | | - +------+------+ none | | - | return| | -+-----------v-------------+true| +------------------------+ | -|onMoveShouldSetResponder |----->|onResponderMove (cur) |<-----------+ -+-----------+-------------+ | +------------------------+ | | - | | | +--------+-------+ - | returned true for| false:REJECT +-------->|onResponderRejec| - | wantsResponderID | | | +----------------+ - | (now attempt | +------------------+-----+ | - | handoff) | | onResponder | | - +------------------->| TerminationRequest| | - | +------------------+-----+ | - | | | +----------------+ - | true:GRANT +-------->|onResponderGrant| - | | +--------+-------+ - | +------------------------+ | | - | | onResponderTerminate |<-----------+ - | +------------------+-----+ | - | | | +----------------+ - | +-------->|onResponderMove | - | | +----------------+ - | | - | | - Some active touch started| | - inside current responder | +------------------------+ | - +------------------------->| onResponderEnd | | - | | +------------------------+ | - +---+---------+ | | - | onTouchEnd | | | - +---+---------+ | | - | | +------------------------+ | - +------------------------->| onResponderEnd | | - No active touches started| +-----------+------------+ | - inside current responder | | | - | v | - | +------------------------+ | - | | onResponderRelease | | - | +------------------------+ | - | | - + + */ - -/** - * A note about event ordering in the `EventPluginHub`. - * - * Suppose plugins are injected in the following order: - * - * `[R, S, C]` - * - * To help illustrate the example, assume `S` is `SimpleEventPlugin` (for - * `onClick` etc) and `R` is `ResponderEventPlugin`. - * - * "Deferred-Dispatched Events": - * - * - The current event plugin system will traverse the list of injected plugins, - * in order, and extract events by collecting the plugin's return value of - * `extractEvents()`. - * - These events that are returned from `extractEvents` are "deferred - * dispatched events". - * - When returned from `extractEvents`, deferred-dispatched events contain an - * "accumulation" of deferred dispatches. - * - These deferred dispatches are accumulated/collected before they are - * returned, but processed at a later time by the `EventPluginHub` (hence the - * name deferred). - * - * In the process of returning their deferred-dispatched events, event plugins - * themselves can dispatch events on-demand without returning them from - * `extractEvents`. Plugins might want to do this, so that they can use event - * dispatching as a tool that helps them decide which events should be extracted - * in the first place. - * - * "On-Demand-Dispatched Events": - * - * - On-demand-dispatched events are not returned from `extractEvents`. - * - On-demand-dispatched events are dispatched during the process of returning - * the deferred-dispatched events. - * - They should not have side effects. - * - They should be avoided, and/or eventually be replaced with another - * abstraction that allows event plugins to perform multiple "rounds" of event - * extraction. - * - * Therefore, the sequence of event dispatches becomes: - * - * - `R`s on-demand events (if any) (dispatched by `R` on-demand) - * - `S`s on-demand events (if any) (dispatched by `S` on-demand) - * - `C`s on-demand events (if any) (dispatched by `C` on-demand) - * - `R`s extracted events (if any) (dispatched by `EventPluginHub`) - * - `S`s extracted events (if any) (dispatched by `EventPluginHub`) - * - `C`s extracted events (if any) (dispatched by `EventPluginHub`) - * - * In the case of `ResponderEventPlugin`: If the `startShouldSetResponder` - * on-demand dispatch returns `true` (and some other details are satisfied) the - * `onResponderGrant` deferred dispatched event is returned from - * `extractEvents`. The sequence of dispatch executions in this case - * will appear as follows: - * - * - `startShouldSetResponder` (`ResponderEventPlugin` dispatches on-demand) - * - `touchStartCapture` (`EventPluginHub` dispatches as usual) - * - `touchStart` (`EventPluginHub` dispatches as usual) - * - `responderGrant/Reject` (`EventPluginHub` dispatches as usual) - */ - -type GlobalResponderHandlerType = { - onChange: (from: any, to: any, blockNativeResponder: any) => void, -}; - -type GlobalInteractionHandlerType = { - onChange: (numberActiveTouches: number) => void, -}; - -export default function createResponderEventPlugin(TopLevelTypes: { - topMouseDown: TopLevelType, - topMouseMove: TopLevelType, - topMouseUp: TopLevelType, - topScroll: TopLevelType, - topSelectionChange: TopLevelType, - topTouchCancel: TopLevelType, - topTouchEnd: TopLevelType, - topTouchMove: TopLevelType, - topTouchStart: TopLevelType, -}) { - function isStartish(topLevelType) { - return ( - topLevelType === TopLevelTypes.topMouseDown || - topLevelType === TopLevelTypes.topTouchStart - ); - } - - function isMoveish(topLevelType) { - return ( - topLevelType === TopLevelTypes.topMouseMove || - topLevelType === TopLevelTypes.topTouchMove - ); - } - - function isEndish(topLevelType) { - return ( - topLevelType === TopLevelTypes.topMouseUp || - topLevelType === TopLevelTypes.topTouchEnd || - topLevelType === TopLevelTypes.topTouchCancel - ); - } - - const ResponderTouchHistoryStore = createResponderTouchHistoryStore( - isStartish, - isMoveish, - isEndish, - ); - - /** - * Instance of element that should respond to touch/move types of interactions, - * as indicated explicitly by relevant callbacks. - */ - let responderInst = null; - - /** - * Count of current touches. A textInput should become responder iff the - * selection changes while there is a touch on the screen. - */ - let trackedTouchCount = 0; - - /** - * Last reported number of active touches. - */ - let previousActiveTouches = 0; - - const changeResponder = function(nextResponderInst, blockHostResponder) { - const oldResponderInst = responderInst; - responderInst = nextResponderInst; - if (ResponderEventPlugin.GlobalResponderHandler !== null) { - ResponderEventPlugin.GlobalResponderHandler.onChange( - oldResponderInst, - nextResponderInst, - blockHostResponder, - ); - } - }; - - const startDependencies = [ - TopLevelTypes.topTouchStart, - TopLevelTypes.topMouseDown, - ]; - const moveDependencies = [ - TopLevelTypes.topTouchMove, - TopLevelTypes.topMouseMove, - ]; - const endDependencies = [ - TopLevelTypes.topTouchCancel, - TopLevelTypes.topTouchEnd, - TopLevelTypes.topMouseUp, - ]; - - const eventTypes = { - /** - * On a `touchStart`/`mouseDown`, is it desired that this element become the - * responder? - */ - startShouldSetResponder: { - phasedRegistrationNames: { - bubbled: 'onStartShouldSetResponder', - captured: 'onStartShouldSetResponderCapture', - }, - dependencies: startDependencies, - }, - - /** - * On a `scroll`, is it desired that this element become the responder? This - * is usually not needed, but should be used to retroactively infer that a - * `touchStart` had occurred during momentum scroll. During a momentum scroll, - * a touch start will be immediately followed by a scroll event if the view is - * currently scrolling. - * - * TODO: This shouldn't bubble. - */ - scrollShouldSetResponder: { - phasedRegistrationNames: { - bubbled: 'onScrollShouldSetResponder', - captured: 'onScrollShouldSetResponderCapture', - }, - dependencies: [TopLevelTypes.topScroll], - }, - - /** - * On text selection change, should this element become the responder? This - * is needed for text inputs or other views with native selection, so the - * JS view can claim the responder. - * - * TODO: This shouldn't bubble. - */ - selectionChangeShouldSetResponder: { - phasedRegistrationNames: { - bubbled: 'onSelectionChangeShouldSetResponder', - captured: 'onSelectionChangeShouldSetResponderCapture', - }, - dependencies: [TopLevelTypes.topSelectionChange], - }, - - /** - * On a `touchMove`/`mouseMove`, is it desired that this element become the - * responder? - */ - moveShouldSetResponder: { - phasedRegistrationNames: { - bubbled: 'onMoveShouldSetResponder', - captured: 'onMoveShouldSetResponderCapture', - }, - dependencies: moveDependencies, - }, - - /** - * Direct responder events dispatched directly to responder. Do not bubble. - */ - responderStart: { - registrationName: 'onResponderStart', - dependencies: startDependencies, - }, - responderMove: { - registrationName: 'onResponderMove', - dependencies: moveDependencies, - }, - responderEnd: { - registrationName: 'onResponderEnd', - dependencies: endDependencies, - }, - responderRelease: { - registrationName: 'onResponderRelease', - dependencies: [], - }, - responderTerminationRequest: { - registrationName: 'onResponderTerminationRequest', - dependencies: [], - }, - responderGrant: {registrationName: 'onResponderGrant', dependencies: []}, - responderReject: {registrationName: 'onResponderReject', dependencies: []}, - responderTerminate: { - registrationName: 'onResponderTerminate', - dependencies: [], - }, - }; - - function setResponderAndExtractTransfer( - topLevelType: TopLevelType, - targetInst: Fiber, - nativeEvent: AnyNativeEvent, - nativeEventTarget: EventTarget, - ) { - const shouldSetEventType = isStartish(topLevelType) - ? eventTypes.startShouldSetResponder - : isMoveish(topLevelType) - ? eventTypes.moveShouldSetResponder - : topLevelType === TopLevelTypes.topSelectionChange - ? eventTypes.selectionChangeShouldSetResponder - : eventTypes.scrollShouldSetResponder; - - // TODO: stop one short of the current responder. - const bubbleShouldSetFrom = !responderInst - ? targetInst - : getLowestCommonAncestor(responderInst, targetInst); - - // When capturing/bubbling the "shouldSet" event, we want to skip the target - // (deepest ID) if it happens to be the current responder. The reasoning: - // It's strange to get an `onMoveShouldSetResponder` when you're *already* - // the responder. - const skipOverBubbleShouldSetFrom = bubbleShouldSetFrom === responderInst; - const shouldSetEvent = ResponderSyntheticEvent.getPooled( - shouldSetEventType, - bubbleShouldSetFrom, - nativeEvent, - nativeEventTarget, - ); - shouldSetEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; - if (skipOverBubbleShouldSetFrom) { - accumulateTwoPhaseDispatchesSkipTarget(shouldSetEvent); - } else { - accumulateTwoPhaseDispatches(shouldSetEvent); - } - const wantsResponderInst = executeDispatchesInOrderStopAtTrue( - shouldSetEvent, - ); - if (!shouldSetEvent.isPersistent()) { - shouldSetEvent.constructor.release(shouldSetEvent); - } - - if (!wantsResponderInst || wantsResponderInst === responderInst) { - return null; - } - let extracted; - const grantEvent = ResponderSyntheticEvent.getPooled( - eventTypes.responderGrant, - wantsResponderInst, - nativeEvent, - nativeEventTarget, - ); - grantEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; - - accumulateDirectDispatches(grantEvent); - const blockHostResponder = executeDirectDispatch(grantEvent) === true; - if (responderInst) { - const terminationRequestEvent = ResponderSyntheticEvent.getPooled( - eventTypes.responderTerminationRequest, - responderInst, - nativeEvent, - nativeEventTarget, - ); - terminationRequestEvent.touchHistory = - ResponderTouchHistoryStore.touchHistory; - accumulateDirectDispatches(terminationRequestEvent); - const shouldSwitch = - !hasDispatches(terminationRequestEvent) || - executeDirectDispatch(terminationRequestEvent); - if (!terminationRequestEvent.isPersistent()) { - terminationRequestEvent.constructor.release(terminationRequestEvent); - } - - if (shouldSwitch) { - const terminateEvent = ResponderSyntheticEvent.getPooled( - eventTypes.responderTerminate, - responderInst, - nativeEvent, - nativeEventTarget, - ); - terminateEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; - accumulateDirectDispatches(terminateEvent); - extracted = accumulate(extracted, [grantEvent, terminateEvent]); - changeResponder(wantsResponderInst, blockHostResponder); - } else { - const rejectEvent = ResponderSyntheticEvent.getPooled( - eventTypes.responderReject, - wantsResponderInst, - nativeEvent, - nativeEventTarget, - ); - rejectEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; - accumulateDirectDispatches(rejectEvent); - extracted = accumulate(extracted, rejectEvent); - } - } else { - extracted = accumulate(extracted, grantEvent); - changeResponder(wantsResponderInst, blockHostResponder); - } - return extracted; - } - - /** - * A transfer is a negotiation between a currently set responder and the next - * element to claim responder status. Any start event could trigger a transfer - * of responderInst. Any move event could trigger a transfer. - * - * @param {number} topLevelType Number from `TopLevelEventTypes`. - * @return {boolean} True if a transfer of responder could possibly occur. - */ - function canTriggerTransfer(topLevelType, topLevelInst, nativeEvent) { - return ( - topLevelInst && - // 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 === TopLevelTypes.topScroll && - !nativeEvent.responderIgnoreScroll) || - (trackedTouchCount > 0 && - topLevelType === TopLevelTypes.topSelectionChange) || - isStartish(topLevelType) || - isMoveish(topLevelType)) - ); - } - - /** - * Returns whether or not this touch end event makes it such that there are no - * longer any touches that started inside of the current `responderInst`. - * - * @param {NativeEvent} nativeEvent Native touch end event. - * @return {boolean} Whether or not this touch end event ends the responder. - */ - function noResponderTouches(nativeEvent: any) { - const touches = nativeEvent.touches; - if (!touches || touches.length === 0) { - return true; - } - for (let i = 0; i < touches.length; i++) { - const activeTouch = touches[i]; - const target = activeTouch.target; - if (target !== null && target !== undefined && target !== 0) { - // Is the original touch location inside of the current responder? - const targetInst = getInstanceFromNode(target); - if (isAncestor(responderInst, targetInst)) { - return false; - } - } - } - return true; - } - - const ResponderEventPlugin = { - /* For unit testing only */ - _getResponder: function() { - return responderInst; - }, - - eventTypes: eventTypes, - - /** - * We must be resilient to `targetInst` being `null` on `touchMove` or - * `touchEnd`. On certain platforms, this means that a native scroll has - * assumed control and the original touch targets are destroyed. - */ - extractEvents: function( - topLevelType: TopLevelType, - targetInst: Fiber, - nativeEvent: AnyNativeEvent, - nativeEventTarget: EventTarget, - ): any { - if (isStartish(topLevelType)) { - trackedTouchCount += 1; - } else if (isEndish(topLevelType)) { - if (trackedTouchCount >= 0) { - trackedTouchCount -= 1; - } else { - console.error( - 'Ended a touch event which was not counted in `trackedTouchCount`.', - ); - return null; - } - } - - ResponderTouchHistoryStore.recordTouchTrack( - topLevelType, - (nativeEvent: any), - ); - - let extracted = canTriggerTransfer(topLevelType, targetInst, nativeEvent) - ? setResponderAndExtractTransfer( - topLevelType, - targetInst, - nativeEvent, - nativeEventTarget, - ) - : null; - // Responder may or may not have transferred on a new touch start/move. - // Regardless, whoever is the responder after any potential transfer, we - // direct all touch start/move/ends to them in the form of - // `onResponderMove/Start/End`. These will be called for *every* additional - // finger that move/start/end, dispatched directly to whoever is the - // current responder at that moment, until the responder is "released". - // - // These multiple individual change touch events are are always bookended - // by `onResponderGrant`, and one of - // (`onResponderRelease/onResponderTerminate`). - const isResponderTouchStart = responderInst && isStartish(topLevelType); - const isResponderTouchMove = responderInst && isMoveish(topLevelType); - const isResponderTouchEnd = responderInst && isEndish(topLevelType); - const incrementalTouch = isResponderTouchStart - ? eventTypes.responderStart - : isResponderTouchMove - ? eventTypes.responderMove - : isResponderTouchEnd ? eventTypes.responderEnd : null; - - if (incrementalTouch) { - const gesture = ResponderSyntheticEvent.getPooled( - incrementalTouch, - responderInst, - nativeEvent, - nativeEventTarget, - ); - gesture.touchHistory = ResponderTouchHistoryStore.touchHistory; - accumulateDirectDispatches(gesture); - extracted = accumulate(extracted, gesture); - } - - const isResponderTerminate = - responderInst && topLevelType === TopLevelTypes.topTouchCancel; - const isResponderRelease = - responderInst && - !isResponderTerminate && - isEndish(topLevelType) && - noResponderTouches(nativeEvent); - const finalTouch = isResponderTerminate - ? eventTypes.responderTerminate - : isResponderRelease ? eventTypes.responderRelease : null; - if (finalTouch) { - const finalEvent = ResponderSyntheticEvent.getPooled( - finalTouch, - responderInst, - nativeEvent, - nativeEventTarget, - ); - finalEvent.touchHistory = ResponderTouchHistoryStore.touchHistory; - accumulateDirectDispatches(finalEvent); - extracted = accumulate(extracted, finalEvent); - changeResponder(null); - } - - const numberActiveTouches = - ResponderTouchHistoryStore.touchHistory.numberActiveTouches; - if ( - ResponderEventPlugin.GlobalInteractionHandler && - numberActiveTouches !== previousActiveTouches - ) { - ResponderEventPlugin.GlobalInteractionHandler.onChange( - numberActiveTouches, - ); - } - previousActiveTouches = numberActiveTouches; - - return extracted; - }, - - GlobalResponderHandler: (null: null | GlobalResponderHandlerType), - GlobalInteractionHandler: (null: null | GlobalInteractionHandlerType), - - injection: { - /** - * @param {{onChange: (ReactID, ReactID) => void} GlobalResponderHandler - * Object that handles any change in responder. Use this to inject - * integration with an existing touch handling system etc. - */ - injectGlobalResponderHandler: function( - GlobalResponderHandler: GlobalResponderHandlerType, - ) { - ResponderEventPlugin.GlobalResponderHandler = GlobalResponderHandler; - }, - - /** - * @param {{onChange: (numberActiveTouches) => void} GlobalInteractionHandler - * Object that handles any change in the number of active touches. - */ - injectGlobalInteractionHandler: function( - GlobalInteractionHandler: GlobalInteractionHandlerType, - ) { - ResponderEventPlugin.GlobalInteractionHandler = GlobalInteractionHandler; - }, - }, - }; - - return { - ResponderEventPlugin, - ResponderTouchHistoryStore, - }; -} diff --git a/packages/events/forks/ResponderTopLevelEventTypes.dom.js b/packages/events/forks/ResponderTopLevelEventTypes.dom.js new file mode 100644 index 0000000000000..5e009dc56cd78 --- /dev/null +++ b/packages/events/forks/ResponderTopLevelEventTypes.dom.js @@ -0,0 +1,41 @@ +/** + * 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. + * + * @flow + */ + +// Note: ideally these would be imported from DOMTopLevelEventTypes, +// but our build system currently doesn't let us do that from a fork. + +export const TOP_TOUCH_START = 'touchstart'; +export const TOP_TOUCH_MOVE = 'touchmove'; +export const TOP_TOUCH_END = 'touchend'; +export const TOP_TOUCH_CANCEL = 'touchcancel'; +export const TOP_SCROLL = 'scroll'; +export const TOP_SELECTION_CHANGE = 'selectionchange'; +export const TOP_MOUSE_DOWN = 'mousedown'; +export const TOP_MOUSE_MOVE = 'mousemove'; +export const TOP_MOUSE_UP = 'mouseup'; + +export function isStartish(topLevelType: mixed): boolean { + return topLevelType === TOP_TOUCH_START || topLevelType === TOP_MOUSE_DOWN; +} + +export function isMoveish(topLevelType: mixed): boolean { + return topLevelType === TOP_TOUCH_MOVE || topLevelType === TOP_MOUSE_MOVE; +} + +export function isEndish(topLevelType: mixed): boolean { + return ( + topLevelType === TOP_TOUCH_END || + topLevelType === TOP_TOUCH_CANCEL || + topLevelType === TOP_MOUSE_UP + ); +} + +export const startDependencies = [TOP_TOUCH_START, TOP_MOUSE_DOWN]; +export const moveDependencies = [TOP_TOUCH_MOVE, TOP_MOUSE_MOVE]; +export const endDependencies = [TOP_TOUCH_CANCEL, TOP_TOUCH_END, TOP_MOUSE_UP]; diff --git a/packages/react-dom/src/events/DOMEventPluginUtils.js b/packages/react-dom/src/events/DOMEventPluginUtils.js deleted file mode 100644 index a03ac1099d459..0000000000000 --- a/packages/react-dom/src/events/DOMEventPluginUtils.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * 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. - */ - -import { - TOP_MOUSE_DOWN, - TOP_MOUSE_MOVE, - TOP_MOUSE_UP, - TOP_TOUCH_CANCEL, - TOP_TOUCH_END, - TOP_TOUCH_MOVE, - TOP_TOUCH_START, -} from './DOMTopLevelEventTypes'; - -export function isEndish(topLevelType) { - return ( - topLevelType === TOP_MOUSE_UP || - topLevelType === TOP_TOUCH_END || - topLevelType === TOP_TOUCH_CANCEL - ); -} - -export function isMoveish(topLevelType) { - return topLevelType === TOP_MOUSE_MOVE || topLevelType === TOP_TOUCH_MOVE; -} -export function isStartish(topLevelType) { - return topLevelType === TOP_MOUSE_DOWN || topLevelType === TOP_TOUCH_START; -} diff --git a/packages/react-dom/src/events/DOMResponderEventPlugin.js b/packages/react-dom/src/events/DOMResponderEventPlugin.js deleted file mode 100644 index 39bd63e8a8953..0000000000000 --- a/packages/react-dom/src/events/DOMResponderEventPlugin.js +++ /dev/null @@ -1,42 +0,0 @@ -/** - * 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. - * - * @flow - */ - -import createResponderEventPlugin from 'events/createResponderEventPlugin'; - -import { - TOP_MOUSE_DOWN, - TOP_MOUSE_MOVE, - TOP_MOUSE_UP, - TOP_SCROLL, - TOP_SELECTION_CHANGE, - TOP_TOUCH_CANCEL, - TOP_TOUCH_END, - TOP_TOUCH_MOVE, - TOP_TOUCH_START, -} from './DOMTopLevelEventTypes'; - -const TopLevelTypes = { - topMouseDown: TOP_MOUSE_DOWN, - topMouseMove: TOP_MOUSE_MOVE, - topMouseUp: TOP_MOUSE_UP, - topScroll: TOP_SCROLL, - topSelectionChange: TOP_SELECTION_CHANGE, - topTouchCancel: TOP_TOUCH_CANCEL, - topTouchEnd: TOP_TOUCH_END, - topTouchMove: TOP_TOUCH_MOVE, - topTouchStart: TOP_TOUCH_START, -}; - -const { - ResponderEventPlugin, - ResponderTouchHistoryStore, -} = createResponderEventPlugin(TopLevelTypes); - -export default ResponderEventPlugin; -export {ResponderTouchHistoryStore}; diff --git a/packages/react-dom/src/events/TapEventPlugin.js b/packages/react-dom/src/events/TapEventPlugin.js index cc36d19e57ff1..772e5d405fab2 100644 --- a/packages/react-dom/src/events/TapEventPlugin.js +++ b/packages/react-dom/src/events/TapEventPlugin.js @@ -20,9 +20,20 @@ import { TOP_TOUCH_MOVE, TOP_TOUCH_START, } from './DOMTopLevelEventTypes'; -import {isStartish, isEndish} from './DOMEventPluginUtils'; import SyntheticUIEvent from './SyntheticUIEvent'; +function isStartish(topLevelType) { + return topLevelType === TOP_MOUSE_DOWN || topLevelType === TOP_TOUCH_START; +} + +function isEndish(topLevelType) { + return ( + topLevelType === TOP_MOUSE_UP || + topLevelType === TOP_TOUCH_END || + topLevelType === TOP_TOUCH_CANCEL + ); +} + /** * We are extending the Flow 'Touch' declaration to enable using bracket * notation to access properties. diff --git a/packages/react-dom/src/unstable-native-dependencies/ReactDOMUnstableNativeDependencies.js b/packages/react-dom/src/unstable-native-dependencies/ReactDOMUnstableNativeDependencies.js index 2d637f3697f61..763a4f38d0683 100644 --- a/packages/react-dom/src/unstable-native-dependencies/ReactDOMUnstableNativeDependencies.js +++ b/packages/react-dom/src/unstable-native-dependencies/ReactDOMUnstableNativeDependencies.js @@ -7,10 +7,8 @@ import ReactDOM from 'react-dom'; import * as EventPluginUtils from 'events/EventPluginUtils'; - -import ResponderEventPlugin, { - ResponderTouchHistoryStore, -} from '../events/DOMResponderEventPlugin'; +import ResponderEventPlugin from 'events/ResponderEventPlugin'; +import ResponderTouchHistoryStore from 'events/ResponderTouchHistoryStore'; // This is used by react-native-web. export const injectComponentTree = diff --git a/packages/react-native-renderer/src/ReactNativeInjectionShared.js b/packages/react-native-renderer/src/ReactNativeInjectionShared.js index d9766488339ef..cc35fdebe961a 100644 --- a/packages/react-native-renderer/src/ReactNativeInjectionShared.js +++ b/packages/react-native-renderer/src/ReactNativeInjectionShared.js @@ -18,9 +18,9 @@ import 'InitializeCore'; import * as EventPluginHub from 'events/EventPluginHub'; import * as EventPluginUtils from 'events/EventPluginUtils'; +import ResponderEventPlugin from 'events/ResponderEventPlugin'; import ReactNativeBridgeEventPlugin from './ReactNativeBridgeEventPlugin'; -import ReactNativeResponderEventPlugin from './ReactNativeResponderEventPlugin'; import * as ReactNativeComponentTree from './ReactNativeComponentTree'; import ReactNativeEventPluginOrder from './ReactNativeEventPluginOrder'; import ReactNativeGlobalResponderHandler from './ReactNativeGlobalResponderHandler'; @@ -31,7 +31,7 @@ import ReactNativeGlobalResponderHandler from './ReactNativeGlobalResponderHandl EventPluginHub.injection.injectEventPluginOrder(ReactNativeEventPluginOrder); EventPluginUtils.injection.injectComponentTree(ReactNativeComponentTree); -ReactNativeResponderEventPlugin.injection.injectGlobalResponderHandler( +ResponderEventPlugin.injection.injectGlobalResponderHandler( ReactNativeGlobalResponderHandler, ); @@ -40,6 +40,6 @@ ReactNativeResponderEventPlugin.injection.injectGlobalResponderHandler( * them). */ EventPluginHub.injection.injectEventPluginsByName({ - ResponderEventPlugin: ReactNativeResponderEventPlugin, + ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: ReactNativeBridgeEventPlugin, }); diff --git a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js b/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js deleted file mode 100644 index 7b56d54d691c1..0000000000000 --- a/packages/react-native-renderer/src/ReactNativeResponderEventPlugin.js +++ /dev/null @@ -1,26 +0,0 @@ -/** - * 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. - * - * @flow - */ - -import createResponderEventPlugin from 'events/createResponderEventPlugin'; - -const TopLevelTypes = { - topMouseDown: 'topMouseDown', - topMouseMove: 'topMouseMove', - topMouseUp: 'topMouseUp', - topScroll: 'topScroll', - topSelectionChange: 'topSelectionChange', - topTouchCancel: 'topTouchCancel', - topTouchEnd: 'topTouchEnd', - topTouchMove: 'topTouchMove', - topTouchStart: 'topTouchStart', -}; - -const {ResponderEventPlugin} = createResponderEventPlugin(TopLevelTypes); - -export default ResponderEventPlugin; diff --git a/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js b/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js index 05e3a34d81152..07fbe1692aa6a 100644 --- a/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js +++ b/packages/react-native-renderer/src/__tests__/ReactNativeEvents-test.internal.js @@ -14,7 +14,7 @@ let PropTypes; let RCTEventEmitter; let React; let ReactNative; -let ReactNativeResponderEventPlugin; +let ResponderEventPlugin; let UIManager; let createReactNativeComponentClass; @@ -67,8 +67,7 @@ beforeEach(() => { RCTEventEmitter = require('RCTEventEmitter'); React = require('react'); ReactNative = require('react-native-renderer'); - ReactNativeResponderEventPlugin = require('../ReactNativeResponderEventPlugin') - .default; + ResponderEventPlugin = require('events/ResponderEventPlugin').default; UIManager = require('UIManager'); createReactNativeComponentClass = require('ReactNativeViewConfigRegistry') .register; @@ -245,7 +244,7 @@ it('handles when a responder is unmounted while a touch sequence is in progress' } function getResponderId() { - const responder = ReactNativeResponderEventPlugin._getResponder(); + const responder = ResponderEventPlugin._getResponder(); if (responder === null) { return null; } @@ -335,7 +334,7 @@ it('handles events without target', () => { } function getResponderId() { - const responder = ReactNativeResponderEventPlugin._getResponder(); + const responder = ResponderEventPlugin._getResponder(); if (responder === null) { return null; } diff --git a/scripts/rollup/forks.js b/scripts/rollup/forks.js index 97f73879ea0d4..9bcd0cce94f2c 100644 --- a/scripts/rollup/forks.js +++ b/scripts/rollup/forks.js @@ -142,6 +142,14 @@ const forks = Object.freeze({ return null; } }, + + // React DOM uses different top level event names and supports mouse events. + 'events/ResponderTopLevelEventTypes': (bundleType, entry) => { + if (entry === 'react-dom' || entry.startsWith('react-dom/')) { + return 'events/forks/ResponderTopLevelEventTypes.dom.js'; + } + return null; + }, }); module.exports = forks; From 4b2ca6bc1f3ac925a35f33640b84a26a33d1dcc2 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Tue, 8 May 2018 01:43:50 +0200 Subject: [PATCH 44/45] Remove null check and rely on flow checks --- .../react-dom/src/events/EventListener.js | 4 +-- .../src/events/ReactBrowserEventEmitter.js | 20 +++++++---- .../src/events/ReactDOMEventListener.js | 33 ++++++++++++++++--- .../react-dom/src/events/SimpleEventPlugin.js | 4 ++- 4 files changed, 46 insertions(+), 15 deletions(-) diff --git a/packages/react-dom/src/events/EventListener.js b/packages/react-dom/src/events/EventListener.js index e87c3886eb8ef..8bec245b13fb7 100644 --- a/packages/react-dom/src/events/EventListener.js +++ b/packages/react-dom/src/events/EventListener.js @@ -8,7 +8,7 @@ */ export function addEventBubbleListener( - element: Element, + element: Document | Element, eventType: string, listener: Function, ): void { @@ -16,7 +16,7 @@ export function addEventBubbleListener( } export function addEventCaptureListener( - element: Element, + element: Document | Element, eventType: string, listener: Function, ): void { diff --git a/packages/react-dom/src/events/ReactBrowserEventEmitter.js b/packages/react-dom/src/events/ReactBrowserEventEmitter.js index a8fd4495e35d6..0a2742a654eec 100644 --- a/packages/react-dom/src/events/ReactBrowserEventEmitter.js +++ b/packages/react-dom/src/events/ReactBrowserEventEmitter.js @@ -3,6 +3,8 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. + * + * @flow */ import {registrationNameDependencies} from 'events/EventPluginRegistry'; @@ -20,7 +22,6 @@ import { trapCapturedEvent, } from './ReactDOMEventListener'; import isEventSupported from './isEventSupported'; -import {getRawEventName} from './DOMTopLevelEventTypes'; /** * Summary of `ReactBrowserEventEmitter` event handling: @@ -86,7 +87,7 @@ let reactTopListenersCounter = 0; */ const topListenersIDKey = '_reactListenersID' + ('' + Math.random()).slice(2); -function getListeningForDocument(mountAt) { +function getListeningForDocument(mountAt: any) { // In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty` // directly. if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) { @@ -115,10 +116,12 @@ function getListeningForDocument(mountAt) { * they bubble to document. * * @param {string} registrationName Name of listener (e.g. `onClick`). - * @param {object} contentDocumentHandle Document which owns the container + * @param {object} mountAt Container where to mount the listener */ -export function listenTo(registrationName, contentDocumentHandle) { - const mountAt = contentDocumentHandle; +export function listenTo( + registrationName: string, + mountAt: Document | Element, +) { const isListening = getListeningForDocument(mountAt); const dependencies = registrationNameDependencies[registrationName]; @@ -144,7 +147,7 @@ export function listenTo(registrationName, contentDocumentHandle) { trapCapturedEvent(TOP_CLOSE, mountAt); } isListening[TOP_CLOSE] = true; - } else if (getRawEventName(dependency)) { + } else { trapBubbledEvent(dependency, mountAt); } @@ -153,7 +156,10 @@ export function listenTo(registrationName, contentDocumentHandle) { } } -export function isListeningToAllDependencies(registrationName, mountAt) { +export function isListeningToAllDependencies( + registrationName: string, + mountAt: Document | Element, +) { const isListening = getListeningForDocument(mountAt); const dependencies = registrationNameDependencies[registrationName]; for (let i = 0; i < dependencies.length; i++) { diff --git a/packages/react-dom/src/events/ReactDOMEventListener.js b/packages/react-dom/src/events/ReactDOMEventListener.js index 0455212eaf8a4..0125a8437b41d 100644 --- a/packages/react-dom/src/events/ReactDOMEventListener.js +++ b/packages/react-dom/src/events/ReactDOMEventListener.js @@ -3,12 +3,17 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. + * + * @flow */ import {batchedUpdates, interactiveUpdates} from 'events/ReactGenericBatching'; import {runExtractedEventsInBatch} from 'events/EventPluginHub'; import {isFiberMounted} from 'react-reconciler/reflection'; import {HostRoot} from 'shared/ReactTypeOfWork'; +import type {AnyNativeEvent} from 'events/PluginModuleType'; +import type {TopLevelType} from 'events/TopLevelEventTypes'; +import type {Fiber} from 'react-reconciler/src/ReactFiber'; import {addEventBubbleListener, addEventCaptureListener} from './EventListener'; import getEventTarget from './getEventTarget'; @@ -41,7 +46,16 @@ function findRootContainerNode(inst) { } // Used to store ancestor hierarchy in top level callback -function getTopLevelCallbackBookKeeping(topLevelType, nativeEvent, targetInst) { +function getTopLevelCallbackBookKeeping( + topLevelType, + nativeEvent, + targetInst, +): { + topLevelType: ?TopLevelType, + nativeEvent: ?AnyNativeEvent, + targetInst: Fiber, + ancestors: Array, +} { if (callbackBookkeepingPool.length) { const instance = callbackBookkeepingPool.pop(); instance.topLevelType = topLevelType; @@ -102,7 +116,7 @@ function handleTopLevel(bookKeeping) { // TODO: can we stop exporting these? export let _enabled = true; -export function setEnabled(enabled) { +export function setEnabled(enabled: ?boolean) { _enabled = !!enabled; } @@ -119,7 +133,10 @@ export function isEnabled() { * remove the listener. * @internal */ -export function trapBubbledEvent(topLevelType, element) { +export function trapBubbledEvent( + topLevelType: TopLevelType, + element: Document | Element, +) { if (!element) { return null; } @@ -144,7 +161,10 @@ export function trapBubbledEvent(topLevelType, element) { * remove the listener. * @internal */ -export function trapCapturedEvent(topLevelType, element) { +export function trapCapturedEvent( + topLevelType: TopLevelType, + element: Document | Element, +) { if (!element) { return null; } @@ -164,7 +184,10 @@ function dispatchInteractiveEvent(topLevelType, nativeEvent) { interactiveUpdates(dispatchEvent, topLevelType, nativeEvent); } -export function dispatchEvent(topLevelType, nativeEvent) { +export function dispatchEvent( + topLevelType: TopLevelType, + nativeEvent: AnyNativeEvent, +) { if (!_enabled) { return; } diff --git a/packages/react-dom/src/events/SimpleEventPlugin.js b/packages/react-dom/src/events/SimpleEventPlugin.js index ffaeb423ee793..6da1d244c9673 100644 --- a/packages/react-dom/src/events/SimpleEventPlugin.js +++ b/packages/react-dom/src/events/SimpleEventPlugin.js @@ -188,7 +188,9 @@ const knownHTMLTopLevelTypes: Array = [ DOMTopLevelEventTypes.TOP_WAITING, ]; -const SimpleEventPlugin: PluginModule = { +const SimpleEventPlugin: PluginModule & { + isInteractiveTopLevelEventType: (topLevelType: TopLevelType) => boolean, +} = { eventTypes: eventTypes, isInteractiveTopLevelEventType(topLevelType: TopLevelType): boolean { From e19f37ba9a267798716b0d4af281f25066aea345 Mon Sep 17 00:00:00 2001 From: Philipp Spiess Date: Sat, 12 May 2018 00:37:31 +0200 Subject: [PATCH 45/45] Add missing ResponderEventPlugin dependencies --- packages/events/ResponderEventPlugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/events/ResponderEventPlugin.js b/packages/events/ResponderEventPlugin.js index 7859b19fd4bc8..dc14523fff455 100644 --- a/packages/events/ResponderEventPlugin.js +++ b/packages/events/ResponderEventPlugin.js @@ -131,7 +131,7 @@ const eventTypes = { }, responderRelease: { registrationName: 'onResponderRelease', - dependencies: [], + dependencies: endDependencies, }, responderTerminationRequest: { registrationName: 'onResponderTerminationRequest',