Skip to content

Commit

Permalink
Move some files out of /shared and rename to upper case (#18363)
Browse files Browse the repository at this point in the history
* Rename lower case isomorphic default exports modules to upper case named exports

We're somewhat inconsistent here between e.g. ReactLazy and memo.

Let's pick one.

This also moves the responder, fundamental, scope creators from shared
since they're isomorphic and same as the other creators.

* Move some files that are specific to the react-reconciler from shared

Individual renderers are allowed to deep require into the reconciler.

* Move files specific to react-dom from shared

react-interactions is right now dom specific (it wasn't before) so we can
type check it together with other dom stuff. Avoids the need for
a shared ReactDOMTypes to be checked by RN for example.

* Move ReactWorkTags to the reconciler

* Move createPortal to export from reconciler

Otherwise Noop can't access it since it's not allowed deep requires.
  • Loading branch information
sebmarkbage committed Mar 21, 2020
1 parent a600408 commit c5d2fc7
Show file tree
Hide file tree
Showing 92 changed files with 153 additions and 139 deletions.
2 changes: 1 addition & 1 deletion packages/legacy-events/EventPropagators.js
Expand Up @@ -12,7 +12,7 @@ import type {ReactSyntheticEvent} from 'legacy-events/ReactSyntheticEventType';

import getListener from 'legacy-events/getListener';

import {traverseEnterLeave} from 'shared/ReactTreeTraversal';
import {traverseEnterLeave} from 'react-reconciler/src/ReactTreeTraversal';
import accumulateInto from './accumulateInto';
import forEachAccumulated from './forEachAccumulated';

Expand Down
2 changes: 1 addition & 1 deletion packages/legacy-events/ResponderEventPlugin.js
Expand Up @@ -10,7 +10,7 @@ import {
isAncestor,
getParentInstance,
traverseTwoPhase,
} from 'shared/ReactTreeTraversal';
} from 'react-reconciler/src/ReactTreeTraversal';

import {
executeDirectDispatch,
Expand Down
Expand Up @@ -9,7 +9,7 @@

'use strict';

const {HostComponent} = require('shared/ReactWorkTags');
const {HostComponent} = require('react-reconciler/src/ReactWorkTags');
const {PLUGIN_EVENT_SYSTEM} = require('legacy-events/EventSystemFlags');

let EventBatching;
Expand Down Expand Up @@ -1378,7 +1378,7 @@ describe('ResponderEventPlugin', () => {
// ResponderEventPlugin uses `getLowestCommonAncestor`
const React = require('react');
const ReactTestUtils = require('react-dom/test-utils');
const ReactTreeTraversal = require('shared/ReactTreeTraversal');
const ReactTreeTraversal = require('react-reconciler/src/ReactTreeTraversal');
const ReactDOMComponentTree = require('../../react-dom/src/client/ReactDOMComponentTree');

class ChildComponent extends React.Component {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-art/src/ReactART.js
Expand Up @@ -7,7 +7,7 @@

import * as React from 'react';
import ReactVersion from 'shared/ReactVersion';
import {LegacyRoot} from 'shared/ReactRootTags';
import {LegacyRoot} from 'react-reconciler/src/ReactRootTags';
import {
createContainer,
updateContainer,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-art/src/ReactARTHostConfig.js
Expand Up @@ -241,8 +241,8 @@ function applyTextProps(instance, props, prevProps = {}) {
}
}

export * from 'shared/HostConfigWithNoPersistence';
export * from 'shared/HostConfigWithNoHydration';
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoPersistence';
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoHydration';

export function appendInitialChild(parentInstance, child) {
if (typeof child === 'string') {
Expand Down
2 changes: 1 addition & 1 deletion packages/react-debug-tools/src/ReactDebugHooks.js
Expand Up @@ -29,7 +29,7 @@ import {
ContextProvider,
ForwardRef,
Block,
} from 'shared/ReactWorkTags';
} from 'react-reconciler/src/ReactWorkTags';

type CurrentDispatcherRef = typeof ReactSharedInternals.ReactCurrentDispatcher;

Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOM.js
Expand Up @@ -37,7 +37,7 @@ import {
attemptContinuousHydration,
attemptHydrationAtCurrentPriority,
} from 'react-reconciler/src/ReactFiberReconciler';
import {createPortal as createPortalImpl} from 'shared/ReactPortal';
import {createPortal as createPortalImpl} from 'react-reconciler/src/ReactPortal';
import {canUseDOM} from 'shared/ExecutionEnvironment';
import {setBatchingImplementation} from 'legacy-events/ReactGenericBatching';
import {
Expand Down
6 changes: 5 additions & 1 deletion packages/react-dom/src/client/ReactDOMComponent.js
Expand Up @@ -9,7 +9,6 @@

import {registrationNameModules} from 'legacy-events/EventPluginRegistry';
import {canUseDOM} from 'shared/ExecutionEnvironment';
import endsWith from 'shared/endsWith';
import invariant from 'shared/invariant';
import {setListenToResponderEventTypes} from '../events/DeprecatedDOMEventResponderSystem';

Expand Down Expand Up @@ -1327,6 +1326,11 @@ export function restoreControlledState(
}
}

function endsWith(subject: string, search: string): boolean {
const length = subject.length;
return subject.substring(length - search.length, length) === search;
}

export function listenToEventResponderEventTypes(
eventTypes: Array<string>,
document: Document,
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/client/ReactDOMComponentTree.js
Expand Up @@ -15,14 +15,14 @@ import type {
SuspenseInstance,
Props,
} from './ReactDOMHostConfig';
import type {ReactDOMListener} from 'shared/ReactDOMTypes';
import type {ReactDOMListener} from '../shared/ReactDOMTypes';

import {
HostComponent,
HostText,
HostRoot,
SuspenseComponent,
} from 'shared/ReactWorkTags';
} from 'react-reconciler/src/ReactWorkTags';
import invariant from 'shared/invariant';

import {getParentSuspenseInstance} from './ReactDOMHostConfig';
Expand Down
6 changes: 3 additions & 3 deletions packages/react-dom/src/client/ReactDOMHostConfig.js
Expand Up @@ -55,7 +55,7 @@ import type {
ReactDOMListener,
ReactDOMListenerEvent,
ReactDOMListenerMap,
} from 'shared/ReactDOMTypes';
} from '../shared/ReactDOMTypes';
import {
mountEventResponder,
unmountEventResponder,
Expand All @@ -69,7 +69,7 @@ import {
enableFundamentalAPI,
enableUseEventAPI,
} from 'shared/ReactFeatureFlags';
import {HostComponent} from 'shared/ReactWorkTags';
import {HostComponent} from 'react-reconciler/src/ReactWorkTags';
import {
RESPONDER_EVENT_SYSTEM,
IS_PASSIVE,
Expand Down Expand Up @@ -171,7 +171,7 @@ function shouldAutoFocusHostComponent(type: string, props: Props): boolean {
return false;
}

export * from 'shared/HostConfigWithNoPersistence';
export * from 'react-reconciler/src/ReactFiberHostConfigWithNoPersistence';

export function getRootHostContext(
rootContainerInstance: Container,
Expand Down
8 changes: 6 additions & 2 deletions packages/react-dom/src/client/ReactDOMRoot.js
Expand Up @@ -8,7 +8,7 @@
*/

import type {Container} from './ReactDOMHostConfig';
import type {RootTag} from 'shared/ReactRootTags';
import type {RootTag} from 'react-reconciler/src/ReactRootTags';
import type {ReactNodeList} from 'shared/ReactTypes';
// TODO: This type is shared between the reconciler and ReactDOM, but will
// eventually be lifted out to the renderer.
Expand Down Expand Up @@ -50,7 +50,11 @@ import {
updateContainer,
} from 'react-reconciler/src/ReactFiberReconciler';
import invariant from 'shared/invariant';
import {BlockingRoot, ConcurrentRoot, LegacyRoot} from 'shared/ReactRootTags';
import {
BlockingRoot,
ConcurrentRoot,
LegacyRoot,
} from 'react-reconciler/src/ReactRootTags';

function ReactDOMRoot(container: Container, options: void | RootOptions) {
this._internalRoot = createRootImpl(container, ConcurrentRoot, options);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOMUseEvent.js
Expand Up @@ -12,7 +12,7 @@ import type {EventPriority} from 'shared/ReactTypes';
import type {
ReactDOMListenerEvent,
ReactDOMListenerMap,
} from 'shared/ReactDOMTypes';
} from '../shared/ReactDOMTypes';

import ReactSharedInternals from 'shared/ReactSharedInternals';
import invariant from 'shared/invariant';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/events/ChangeEventPlugin.js
Expand Up @@ -9,7 +9,7 @@ import {runEventsInBatch} from 'legacy-events/EventBatching';
import {enqueueStateRestore} from 'legacy-events/ReactControlledComponent';
import {batchedUpdates} from 'legacy-events/ReactGenericBatching';
import SyntheticEvent from 'legacy-events/SyntheticEvent';
import isTextInputElement from 'shared/isTextInputElement';
import isTextInputElement from './isTextInputElement';
import {canUseDOM} from 'shared/ExecutionEnvironment';

import {
Expand Down
6 changes: 5 additions & 1 deletion packages/react-dom/src/events/DOMLegacyEventPluginSystem.js
Expand Up @@ -16,7 +16,11 @@ import type {PluginModule} from 'legacy-events/PluginModuleType';
import type {ReactSyntheticEvent} from 'legacy-events/ReactSyntheticEventType';
import type {TopLevelType} from 'legacy-events/TopLevelEventTypes';

import {HostRoot, HostComponent, HostText} from 'shared/ReactWorkTags';
import {
HostRoot,
HostComponent,
HostText,
} from 'react-reconciler/src/ReactWorkTags';
import {IS_FIRST_ANCESTOR} from 'legacy-events/EventSystemFlags';
import {batchedEventUpdates} from 'legacy-events/ReactGenericBatching';
import {runEventsInBatch} from 'legacy-events/EventBatching';
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/events/DOMModernPluginEventSystem.js
Expand Up @@ -21,7 +21,7 @@ import type {
ReactSyntheticEvent,
CustomDispatchConfig,
} from 'legacy-events/ReactSyntheticEventType';
import type {ReactDOMListener} from 'shared/ReactDOMTypes';
import type {ReactDOMListener} from '../shared/ReactDOMTypes';

import {registrationNameDependencies} from 'legacy-events/EventPluginRegistry';
import {batchedEventUpdates} from 'legacy-events/ReactGenericBatching';
Expand All @@ -33,7 +33,7 @@ import {
IS_TARGET_EVENT_ONLY,
} from 'legacy-events/EventSystemFlags';

import {HostRoot, HostPortal} from 'shared/ReactWorkTags';
import {HostRoot, HostPortal} from 'react-reconciler/src/ReactWorkTags';

import {
addTrappedEventListener,
Expand Down
Expand Up @@ -12,14 +12,18 @@ import {
PASSIVE_NOT_SUPPORTED,
} from 'legacy-events/EventSystemFlags';
import type {AnyNativeEvent} from 'legacy-events/PluginModuleType';
import {HostComponent, ScopeComponent, HostPortal} from 'shared/ReactWorkTags';
import {
HostComponent,
ScopeComponent,
HostPortal,
} from 'react-reconciler/src/ReactWorkTags';
import type {EventPriority} from 'shared/ReactTypes';
import type {
ReactDOMEventResponder,
ReactDOMEventResponderInstance,
ReactDOMResponderContext,
ReactDOMResponderEvent,
} from 'shared/ReactDOMTypes';
} from '../shared/ReactDOMTypes';
import type {DOMTopLevelEventType} from 'legacy-events/TopLevelEventTypes';
import {
batchedEventUpdates,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/events/EnterLeaveEventPlugin.js
Expand Up @@ -20,7 +20,7 @@ import {
getClosestInstanceFromNode,
getNodeFromInstance,
} from '../client/ReactDOMComponentTree';
import {HostComponent, HostText} from 'shared/ReactWorkTags';
import {HostComponent, HostText} from 'react-reconciler/src/ReactWorkTags';
import {getNearestMountedFiber} from 'react-reconciler/src/ReactFiberTreeReflection';
import {enableModernEventSystem} from 'shared/ReactFeatureFlags';

Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/events/ReactDOMEventListener.js
Expand Up @@ -34,7 +34,7 @@ import {
getContainerFromFiber,
getSuspenseInstanceFromFiber,
} from 'react-reconciler/src/ReactFiberTreeReflection';
import {HostRoot, SuspenseComponent} from 'shared/ReactWorkTags';
import {HostRoot, SuspenseComponent} from 'react-reconciler/src/ReactWorkTags';
import {
type EventSystemFlags,
PLUGIN_EVENT_SYSTEM,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/events/ReactDOMEventReplaying.js
Expand Up @@ -40,7 +40,7 @@ import {
getClosestInstanceFromNode,
} from '../client/ReactDOMComponentTree';
import {unsafeCastDOMTopLevelTypeToString} from 'legacy-events/TopLevelEventTypes';
import {HostRoot, SuspenseComponent} from 'shared/ReactWorkTags';
import {HostRoot, SuspenseComponent} from 'react-reconciler/src/ReactWorkTags';

let attemptSynchronousHydration: (fiber: Object) => void;

Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/events/SelectEventPlugin.js
Expand Up @@ -7,7 +7,7 @@

import {canUseDOM} from 'shared/ExecutionEnvironment';
import SyntheticEvent from 'legacy-events/SyntheticEvent';
import isTextInputElement from 'shared/isTextInputElement';
import isTextInputElement from './isTextInputElement';
import shallowEqual from 'shared/shallowEqual';

import {
Expand Down
Expand Up @@ -11,7 +11,7 @@ import type {DOMTopLevelEventType} from 'legacy-events/TopLevelEventTypes';
import type {EventSystemFlags} from 'legacy-events/EventSystemFlags';
import type {ReactSyntheticEvent} from 'legacy-events/ReactSyntheticEventType';

import {HostComponent} from 'shared/ReactWorkTags';
import {HostComponent} from 'react-reconciler/src/ReactWorkTags';
import {enableUseEventAPI} from 'shared/ReactFeatureFlags';

import getListener from 'legacy-events/getListener';
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/react-dom/src/server/ReactPartialRendererHooks.js
Expand Up @@ -20,7 +20,7 @@ import type {
ReactEventResponderListener,
} from 'shared/ReactTypes';
import type {SuspenseConfig} from 'react-reconciler/src/ReactFiberSuspenseConfig';
import type {ReactDOMListenerMap} from 'shared/ReactDOMTypes';
import type {ReactDOMListenerMap} from '../shared/ReactDOMTypes';

import {validateContextBounds} from './ReactPartialRendererContext';

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions packages/react-dom/src/test-utils/ReactTestUtils.js
Expand Up @@ -14,7 +14,7 @@ import {
FunctionComponent,
HostComponent,
HostText,
} from 'shared/ReactWorkTags';
} from 'react-reconciler/src/ReactWorkTags';
import SyntheticEvent from 'legacy-events/SyntheticEvent';
import invariant from 'shared/invariant';
import {ELEMENT_NODE} from '../shared/HTMLNodeType';
Expand All @@ -23,7 +23,7 @@ import {PLUGIN_EVENT_SYSTEM} from 'legacy-events/EventSystemFlags';
import act from './ReactTestUtilsAct';
import forEachAccumulated from 'legacy-events/forEachAccumulated';
import accumulateInto from 'legacy-events/accumulateInto';
import {traverseTwoPhase} from 'shared/ReactTreeTraversal';
import {traverseTwoPhase} from 'react-reconciler/src/ReactTreeTraversal';

const {findDOMNode} = ReactDOM;
// Keep in sync with ReactDOMUnstableNativeDependencies.js
Expand Down
2 changes: 1 addition & 1 deletion packages/react-interactions/events/src/dom/ContextMenu.js
Expand Up @@ -11,7 +11,7 @@ import type {
ReactDOMResponderEvent,
ReactDOMResponderContext,
PointerType,
} from 'shared/ReactDOMTypes';
} from 'react-dom/src/shared/ReactDOMTypes';
import type {ReactEventResponderListener} from 'shared/ReactTypes';

import * as React from 'react';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-interactions/events/src/dom/Focus.js
Expand Up @@ -11,7 +11,7 @@ import type {
ReactDOMResponderEvent,
ReactDOMResponderContext,
PointerType,
} from 'shared/ReactDOMTypes';
} from 'react-dom/src/shared/ReactDOMTypes';
import type {ReactEventResponderListener} from 'shared/ReactTypes';

import * as React from 'react';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-interactions/events/src/dom/Hover.js
Expand Up @@ -11,7 +11,7 @@ import type {
ReactDOMResponderEvent,
ReactDOMResponderContext,
PointerType,
} from 'shared/ReactDOMTypes';
} from 'react-dom/src/shared/ReactDOMTypes';
import type {ReactEventResponderListener} from 'shared/ReactTypes';

import * as React from 'react';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-interactions/events/src/dom/Input.js
Expand Up @@ -10,7 +10,7 @@
import type {
ReactDOMResponderEvent,
ReactDOMResponderContext,
} from 'shared/ReactDOMTypes';
} from 'react-dom/src/shared/ReactDOMTypes';

import * as React from 'react';
import {DiscreteEvent} from 'shared/ReactTypes';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-interactions/events/src/dom/Keyboard.js
Expand Up @@ -10,7 +10,7 @@
import type {
ReactDOMResponderEvent,
ReactDOMResponderContext,
} from 'shared/ReactDOMTypes';
} from 'react-dom/src/shared/ReactDOMTypes';
import type {ReactEventResponderListener} from 'shared/ReactTypes';

import * as React from 'react';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-interactions/events/src/dom/Press.js
Expand Up @@ -7,7 +7,7 @@
* @flow
*/

import type {PointerType} from 'shared/ReactDOMTypes';
import type {PointerType} from 'react-dom/src/shared/ReactDOMTypes';

import * as React from 'react';
import {useTap} from 'react-interactions/events/tap';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-interactions/events/src/dom/PressLegacy.js
Expand Up @@ -11,7 +11,7 @@ import type {
ReactDOMResponderEvent,
ReactDOMResponderContext,
PointerType,
} from 'shared/ReactDOMTypes';
} from 'react-dom/src/shared/ReactDOMTypes';
import type {
EventPriority,
ReactEventResponderListener,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-interactions/events/src/dom/Tap.js
Expand Up @@ -11,7 +11,7 @@ import type {
ReactDOMResponderContext,
ReactDOMResponderEvent,
PointerType,
} from 'shared/ReactDOMTypes';
} from 'react-dom/src/shared/ReactDOMTypes';
import type {ReactEventResponderListener} from 'shared/ReactTypes';

import * as React from 'react';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-interactions/events/src/dom/shared/index.js
Expand Up @@ -13,7 +13,7 @@ import {DiscreteEvent, UserBlockingEvent} from 'shared/ReactTypes';
import type {
ReactDOMResponderContext,
ReactDOMResponderEvent,
} from 'shared/ReactDOMTypes';
} from 'react-dom/src/shared/ReactDOMTypes';

export const hasPointerEvents =
typeof window !== 'undefined' && window.PointerEvent !== undefined;
Expand Down

0 comments on commit c5d2fc7

Please sign in to comment.