@samitouri / QOS-React / commits / bb44feb05d

Try to fix Flow circular dependency

Dan Abramov committed May 15, 2018 at 13:55 UTC bb44feb05dd258c4b4868f6c3f11bf0a2f491564
3 files changed +84 -83
packages/react-dom/src/events/DOMTopLevelEventTypes.js
+73 -74
@@ -7,7 +7,6 @@
7 * @flow
8 */
9
10 -import type {TopLevelType} from 'events/TopLevelEventTypes';
10 import getVendorPrefixedEventName from './getVendorPrefixedEventName';
11
12 /**
@@ -94,87 +93,87 @@ export opaque type DOMTopLevelEventType =
93 | 'waiting'
94 | 'wheel';
95
97 -export const TOP_ABORT: TopLevelType = 'abort';
98 -export const TOP_ANIMATION_END: TopLevelType = getVendorPrefixedEventName(
96 +export const TOP_ABORT: DOMTopLevelEventType = 'abort';
97 +export const TOP_ANIMATION_END: DOMTopLevelEventType = getVendorPrefixedEventName(
98 'animationend',
99 );
101 -export const TOP_ANIMATION_ITERATION: TopLevelType = getVendorPrefixedEventName(
100 +export const TOP_ANIMATION_ITERATION: DOMTopLevelEventType = getVendorPrefixedEventName(
101 'animationiteration',
102 );
104 -export const TOP_ANIMATION_START: TopLevelType = getVendorPrefixedEventName(
103 +export const TOP_ANIMATION_START: DOMTopLevelEventType = getVendorPrefixedEventName(
104 'animationstart',
105 );
107 -export const TOP_BLUR: TopLevelType = 'blur';
108 -export const TOP_CAN_PLAY: TopLevelType = 'canplay';
109 -export const TOP_CAN_PLAY_THROUGH: TopLevelType = 'canplaythrough';
110 -export const TOP_CANCEL: TopLevelType = 'cancel';
111 -export const TOP_CHANGE: TopLevelType = 'change';
112 -export const TOP_CLICK: TopLevelType = 'click';
113 -export const TOP_CLOSE: TopLevelType = 'close';
114 -export const TOP_COMPOSITION_END: TopLevelType = 'compositionend';
115 -export const TOP_COMPOSITION_START: TopLevelType = 'compositionstart';
116 -export const TOP_COMPOSITION_UPDATE: TopLevelType = 'compositionupdate';
117 -export const TOP_CONTEXT_MENU: TopLevelType = 'contextmenu';
118 -export const TOP_COPY: TopLevelType = 'copy';
119 -export const TOP_CUT: TopLevelType = 'cut';
120 -export const TOP_DOUBLE_CLICK: TopLevelType = 'dblclick';
121 -export const TOP_DRAG: TopLevelType = 'drag';
122 -export const TOP_DRAG_END: TopLevelType = 'dragend';
123 -export const TOP_DRAG_ENTER: TopLevelType = 'dragenter';
124 -export const TOP_DRAG_EXIT: TopLevelType = 'dragexit';
125 -export const TOP_DRAG_LEAVE: TopLevelType = 'dragleave';
126 -export const TOP_DRAG_OVER: TopLevelType = 'dragover';
127 -export const TOP_DRAG_START: TopLevelType = 'dragstart';
128 -export const TOP_DROP: TopLevelType = 'drop';
129 -export const TOP_DURATION_CHANGE: TopLevelType = 'durationchange';
130 -export const TOP_EMPTIED: TopLevelType = 'emptied';
131 -export const TOP_ENCRYPTED: TopLevelType = 'encrypted';
132 -export const TOP_ENDED: TopLevelType = 'ended';
133 -export const TOP_ERROR: TopLevelType = 'error';
134 -export const TOP_FOCUS: TopLevelType = 'focus';
135 -export const TOP_INPUT: TopLevelType = 'input';
136 -export const TOP_INVALID: TopLevelType = 'invalid';
137 -export const TOP_KEY_DOWN: TopLevelType = 'keydown';
138 -export const TOP_KEY_PRESS: TopLevelType = 'keypress';
139 -export const TOP_KEY_UP: TopLevelType = 'keyup';
140 -export const TOP_LOAD: TopLevelType = 'load';
141 -export const TOP_LOAD_START: TopLevelType = 'loadstart';
142 -export const TOP_LOADED_DATA: TopLevelType = 'loadeddata';
143 -export const TOP_LOADED_METADATA: TopLevelType = 'loadedmetadata';
144 -export const TOP_MOUSE_DOWN: TopLevelType = 'mousedown';
145 -export const TOP_MOUSE_MOVE: TopLevelType = 'mousemove';
146 -export const TOP_MOUSE_OUT: TopLevelType = 'mouseout';
147 -export const TOP_MOUSE_OVER: TopLevelType = 'mouseover';
148 -export const TOP_MOUSE_UP: TopLevelType = 'mouseup';
149 -export const TOP_PASTE: TopLevelType = 'paste';
150 -export const TOP_PAUSE: TopLevelType = 'pause';
151 -export const TOP_PLAY: TopLevelType = 'play';
152 -export const TOP_PLAYING: TopLevelType = 'playing';
153 -export const TOP_PROGRESS: TopLevelType = 'progress';
154 -export const TOP_RATE_CHANGE: TopLevelType = 'ratechange';
155 -export const TOP_RESET: TopLevelType = 'reset';
156 -export const TOP_SCROLL: TopLevelType = 'scroll';
157 -export const TOP_SEEKED: TopLevelType = 'seeked';
158 -export const TOP_SEEKING: TopLevelType = 'seeking';
159 -export const TOP_SELECTION_CHANGE: TopLevelType = 'selectionchange';
160 -export const TOP_STALLED: TopLevelType = 'stalled';
161 -export const TOP_SUBMIT: TopLevelType = 'submit';
162 -export const TOP_SUSPEND: TopLevelType = 'suspend';
163 -export const TOP_TEXT_INPUT: TopLevelType = 'textInput';
164 -export const TOP_TIME_UPDATE: TopLevelType = 'timeupdate';
165 -export const TOP_TOGGLE: TopLevelType = 'toggle';
166 -export const TOP_TOUCH_CANCEL: TopLevelType = 'touchcancel';
167 -export const TOP_TOUCH_END: TopLevelType = 'touchend';
168 -export const TOP_TOUCH_MOVE: TopLevelType = 'touchmove';
169 -export const TOP_TOUCH_START: TopLevelType = 'touchstart';
170 -export const TOP_TRANSITION_END: TopLevelType = getVendorPrefixedEventName(
106 +export const TOP_BLUR: DOMTopLevelEventType = 'blur';
107 +export const TOP_CAN_PLAY: DOMTopLevelEventType = 'canplay';
108 +export const TOP_CAN_PLAY_THROUGH: DOMTopLevelEventType = 'canplaythrough';
109 +export const TOP_CANCEL: DOMTopLevelEventType = 'cancel';
110 +export const TOP_CHANGE: DOMTopLevelEventType = 'change';
111 +export const TOP_CLICK: DOMTopLevelEventType = 'click';
112 +export const TOP_CLOSE: DOMTopLevelEventType = 'close';
113 +export const TOP_COMPOSITION_END: DOMTopLevelEventType = 'compositionend';
114 +export const TOP_COMPOSITION_START: DOMTopLevelEventType = 'compositionstart';
115 +export const TOP_COMPOSITION_UPDATE: DOMTopLevelEventType = 'compositionupdate';
116 +export const TOP_CONTEXT_MENU: DOMTopLevelEventType = 'contextmenu';
117 +export const TOP_COPY: DOMTopLevelEventType = 'copy';
118 +export const TOP_CUT: DOMTopLevelEventType = 'cut';
119 +export const TOP_DOUBLE_CLICK: DOMTopLevelEventType = 'dblclick';
120 +export const TOP_DRAG: DOMTopLevelEventType = 'drag';
121 +export const TOP_DRAG_END: DOMTopLevelEventType = 'dragend';
122 +export const TOP_DRAG_ENTER: DOMTopLevelEventType = 'dragenter';
123 +export const TOP_DRAG_EXIT: DOMTopLevelEventType = 'dragexit';
124 +export const TOP_DRAG_LEAVE: DOMTopLevelEventType = 'dragleave';
125 +export const TOP_DRAG_OVER: DOMTopLevelEventType = 'dragover';
126 +export const TOP_DRAG_START: DOMTopLevelEventType = 'dragstart';
127 +export const TOP_DROP: DOMTopLevelEventType = 'drop';
128 +export const TOP_DURATION_CHANGE: DOMTopLevelEventType = 'durationchange';
129 +export const TOP_EMPTIED: DOMTopLevelEventType = 'emptied';
130 +export const TOP_ENCRYPTED: DOMTopLevelEventType = 'encrypted';
131 +export const TOP_ENDED: DOMTopLevelEventType = 'ended';
132 +export const TOP_ERROR: DOMTopLevelEventType = 'error';
133 +export const TOP_FOCUS: DOMTopLevelEventType = 'focus';
134 +export const TOP_INPUT: DOMTopLevelEventType = 'input';
135 +export const TOP_INVALID: DOMTopLevelEventType = 'invalid';
136 +export const TOP_KEY_DOWN: DOMTopLevelEventType = 'keydown';
137 +export const TOP_KEY_PRESS: DOMTopLevelEventType = 'keypress';
138 +export const TOP_KEY_UP: DOMTopLevelEventType = 'keyup';
139 +export const TOP_LOAD: DOMTopLevelEventType = 'load';
140 +export const TOP_LOAD_START: DOMTopLevelEventType = 'loadstart';
141 +export const TOP_LOADED_DATA: DOMTopLevelEventType = 'loadeddata';
142 +export const TOP_LOADED_METADATA: DOMTopLevelEventType = 'loadedmetadata';
143 +export const TOP_MOUSE_DOWN: DOMTopLevelEventType = 'mousedown';
144 +export const TOP_MOUSE_MOVE: DOMTopLevelEventType = 'mousemove';
145 +export const TOP_MOUSE_OUT: DOMTopLevelEventType = 'mouseout';
146 +export const TOP_MOUSE_OVER: DOMTopLevelEventType = 'mouseover';
147 +export const TOP_MOUSE_UP: DOMTopLevelEventType = 'mouseup';
148 +export const TOP_PASTE: DOMTopLevelEventType = 'paste';
149 +export const TOP_PAUSE: DOMTopLevelEventType = 'pause';
150 +export const TOP_PLAY: DOMTopLevelEventType = 'play';
151 +export const TOP_PLAYING: DOMTopLevelEventType = 'playing';
152 +export const TOP_PROGRESS: DOMTopLevelEventType = 'progress';
153 +export const TOP_RATE_CHANGE: DOMTopLevelEventType = 'ratechange';
154 +export const TOP_RESET: DOMTopLevelEventType = 'reset';
155 +export const TOP_SCROLL: DOMTopLevelEventType = 'scroll';
156 +export const TOP_SEEKED: DOMTopLevelEventType = 'seeked';
157 +export const TOP_SEEKING: DOMTopLevelEventType = 'seeking';
158 +export const TOP_SELECTION_CHANGE: DOMTopLevelEventType = 'selectionchange';
159 +export const TOP_STALLED: DOMTopLevelEventType = 'stalled';
160 +export const TOP_SUBMIT: DOMTopLevelEventType = 'submit';
161 +export const TOP_SUSPEND: DOMTopLevelEventType = 'suspend';
162 +export const TOP_TEXT_INPUT: DOMTopLevelEventType = 'textInput';
163 +export const TOP_TIME_UPDATE: DOMTopLevelEventType = 'timeupdate';
164 +export const TOP_TOGGLE: DOMTopLevelEventType = 'toggle';
165 +export const TOP_TOUCH_CANCEL: DOMTopLevelEventType = 'touchcancel';
166 +export const TOP_TOUCH_END: DOMTopLevelEventType = 'touchend';
167 +export const TOP_TOUCH_MOVE: DOMTopLevelEventType = 'touchmove';
168 +export const TOP_TOUCH_START: DOMTopLevelEventType = 'touchstart';
169 +export const TOP_TRANSITION_END: DOMTopLevelEventType = getVendorPrefixedEventName(
170 'transitionend',
171 );
173 -export const TOP_VOLUME_CHANGE: TopLevelType = 'volumechange';
174 -export const TOP_WAITING: TopLevelType = 'waiting';
175 -export const TOP_WHEEL: TopLevelType = 'wheel';
172 +export const TOP_VOLUME_CHANGE: DOMTopLevelEventType = 'volumechange';
173 +export const TOP_WAITING: DOMTopLevelEventType = 'waiting';
174 +export const TOP_WHEEL: DOMTopLevelEventType = 'wheel';
175
177 -export const mediaEventTypes: Array<TopLevelType> = [
176 +export const mediaEventTypes: Array<DOMTopLevelEventType> = [
177 TOP_ABORT,
178 TOP_CAN_PLAY,
179 TOP_CAN_PLAY_THROUGH,
@@ -200,6 +199,6 @@ export const mediaEventTypes: Array<TopLevelType> = [
199 TOP_WAITING,
200 ];
201
203 -export function getRawEventName(topLevelType: TopLevelType): string {
202 +export function getRawEventName(topLevelType: DOMTopLevelEventType): string {
203 return topLevelType;
204 }
packages/react-dom/src/events/ReactDOMEventListener.js
+8 -7
@@ -7,13 +7,14 @@
7 * @flow
8 */
9
10 +import type {AnyNativeEvent} from 'events/PluginModuleType';
11 +import type {Fiber} from 'react-reconciler/src/ReactFiber';
12 +import type {DOMTopLevelEventType} from './DOMTopLevelEventTypes';
13 +
14 import {batchedUpdates, interactiveUpdates} from 'events/ReactGenericBatching';
15 import {runExtractedEventsInBatch} from 'events/EventPluginHub';
16 import {isFiberMounted} from 'react-reconciler/reflection';
17 import {HostRoot} from 'shared/ReactTypeOfWork';
14 -import type {AnyNativeEvent} from 'events/PluginModuleType';
15 -import type {TopLevelType} from 'events/TopLevelEventTypes';
16 -import type {Fiber} from 'react-reconciler/src/ReactFiber';
18
19 import {addEventBubbleListener, addEventCaptureListener} from './EventListener';
20 import getEventTarget from './getEventTarget';
@@ -51,7 +52,7 @@ function getTopLevelCallbackBookKeeping(
52 nativeEvent,
53 targetInst,
54 ): {
54 - topLevelType: ?TopLevelType,
55 + topLevelType: ?DOMTopLevelEventType,
56 nativeEvent: ?AnyNativeEvent,
57 targetInst: Fiber,
58 ancestors: Array<Fiber>,
@@ -134,7 +135,7 @@ export function isEnabled() {
135 * @internal
136 */
137 export function trapBubbledEvent(
137 - topLevelType: TopLevelType,
138 + topLevelType: DOMTopLevelEventType,
139 element: Document | Element,
140 ) {
141 if (!element) {
@@ -162,7 +163,7 @@ export function trapBubbledEvent(
163 * @internal
164 */
165 export function trapCapturedEvent(
165 - topLevelType: TopLevelType,
166 + topLevelType: DOMTopLevelEventType,
167 element: Document | Element,
168 ) {
169 if (!element) {
@@ -185,7 +186,7 @@ function dispatchInteractiveEvent(topLevelType, nativeEvent) {
186 }
187
188 export function dispatchEvent(
188 - topLevelType: TopLevelType,
189 + topLevelType: DOMTopLevelEventType,
190 nativeEvent: AnyNativeEvent,
191 ) {
192 if (!_enabled) {
packages/react-dom/src/events/SimpleEventPlugin.js
+3 -2
@@ -8,6 +8,7 @@
8 */
9
10 import type {TopLevelType} from 'events/TopLevelEventTypes';
11 +import type {DOMTopLevelEventType} from './DOMTopLevelEventTypes';
12 import type {
13 DispatchConfig,
14 ReactSyntheticEvent,
@@ -51,7 +52,7 @@ import getEventCharCode from './getEventCharCode';
52 * [TOP_ABORT, { sameConfig }],
53 * ]);
54 */
54 -type EventTuple = [TopLevelType, string];
55 +type EventTuple = [DOMTopLevelEventType, string];
56 const interactiveEventTypeNames: Array<EventTuple> = [
57 [DOMTopLevelEventTypes.TOP_BLUR, 'blur'],
58 [DOMTopLevelEventTypes.TOP_CANCEL, 'cancel'],
@@ -154,7 +155,7 @@ nonInteractiveEventTypeNames.forEach(eventTuple => {
155 });
156
157 // Only used in DEV for exhaustiveness validation.
157 -const knownHTMLTopLevelTypes: Array<TopLevelType> = [
158 +const knownHTMLTopLevelTypes: Array<DOMTopLevelEventType> = [
159 DOMTopLevelEventTypes.TOP_ABORT,
160 DOMTopLevelEventTypes.TOP_CANCEL,
161 DOMTopLevelEventTypes.TOP_CAN_PLAY,