Skip to content

[react-native] Use path-based imports instead of Haste for the RN renderer #15604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/react-native-renderer/src/NativeMethodsMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import type {

import invariant from 'shared/invariant';
// Modules provided by RN:
import TextInputState from 'TextInputState';
import UIManager from 'UIManager';
import {
TextInputState,
UIManager,
} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';

import {create} from './ReactNativeAttributePayload';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

// Module provided by RN:
import UIManager from 'UIManager';
import {UIManager} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';

const ReactFabricGlobalResponderHandler = {
onChange: function(from: any, to: any, blockNativeResponder: boolean) {
Expand Down
25 changes: 15 additions & 10 deletions packages/react-native-renderer/src/ReactFabricHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,36 @@ import type {ReactEventComponentInstance} from 'shared/ReactTypes';

import {mountSafeCallback_NOT_REALLY_SAFE} from './NativeMethodsMixinUtils';
import {create, diff} from './ReactNativeAttributePayload';
import {get as getViewConfigForType} from 'ReactNativeViewConfigRegistry';

import deepFreezeAndThrowOnMutationInDev from 'deepFreezeAndThrowOnMutationInDev';
import invariant from 'shared/invariant';
import warningWithoutStack from 'shared/warningWithoutStack';

import {dispatchEvent} from './ReactFabricEventEmitter';

// Modules provided by RN:
import TextInputState from 'TextInputState';
import {
ReactNativeViewConfigRegistry,
TextInputState,
deepFreezeAndThrowOnMutationInDev,
} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';

const {
createNode,
cloneNode,
cloneNodeWithNewChildren,
cloneNodeWithNewChildrenAndProps,
cloneNodeWithNewProps,
createChildSet as createChildNodeSet,
appendChild as appendChildNode,
appendChildToSet as appendChildNodeToSet,
createChildSet: createChildNodeSet,
appendChild: appendChildNode,
appendChildToSet: appendChildNodeToSet,
completeRoot,
registerEventHandler,
measure as fabricMeasure,
measureInWindow as fabricMeasureInWindow,
measureLayout as fabricMeasureLayout,
} from 'FabricUIManager';
measure: fabricMeasure,
measureInWindow: fabricMeasureInWindow,
measureLayout: fabricMeasureLayout,
} = nativeFabricUIManager;

const {get: getViewConfigForType} = ReactNativeViewConfigRegistry;

// Counter for uniquely identifying views.
// % 10 === 1 means it is a rootTag.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
*/

// Modules provided by RN:
import deepDiffer from 'deepDiffer';
import flattenStyle from 'flattenStyle';
import {
deepDiffer,
flattenStyle,
} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';

import type {AttributeConfiguration} from './ReactNativeTypes';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,17 @@ import {
accumulateDirectDispatches,
} from 'events/EventPropagators';
import type {TopLevelType} from 'events/TopLevelEventTypes';
import {
import SyntheticEvent from 'events/SyntheticEvent';
import invariant from 'shared/invariant';

// Module provided by RN:
import {ReactNativeViewConfigRegistry} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';

const {
customBubblingEventTypes,
customDirectEventTypes,
eventTypes,
} from 'ReactNativeViewConfigRegistry';
import SyntheticEvent from 'events/SyntheticEvent';
import invariant from 'shared/invariant';
} = ReactNativeViewConfigRegistry;

const ReactNativeBridgeEventPlugin = {
eventTypes: eventTypes,
Expand Down
6 changes: 4 additions & 2 deletions packages/react-native-renderer/src/ReactNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@ import type {

import React from 'react';
// Modules provided by RN:
import TextInputState from 'TextInputState';
import UIManager from 'UIManager';
import {
TextInputState,
UIManager,
} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';

import {create} from './ReactNativeAttributePayload';
import {mountSafeCallback_NOT_REALLY_SAFE} from './NativeMethodsMixinUtils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import type {
import type {Instance} from './ReactNativeHostConfig';

// Modules provided by RN:
import TextInputState from 'TextInputState';
import UIManager from 'UIManager';
import {
TextInputState,
UIManager,
} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';

import {create} from './ReactNativeAttributePayload';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import getComponentName from 'shared/getComponentName';
import {HostComponent} from 'shared/ReactWorkTags';
import invariant from 'shared/invariant';
// Module provided by RN:
import UIManager from 'UIManager';
import {UIManager} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';

import {getClosestInstanceFromNode} from './ReactNativeComponentTree';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

// Module provided by RN:
import UIManager from 'UIManager';
import {UIManager} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';

const ReactNativeGlobalResponderHandler = {
onChange: function(from: any, to: any, blockNativeResponder: boolean) {
Expand Down
10 changes: 7 additions & 3 deletions packages/react-native-renderer/src/ReactNativeHostConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import type {ReactEventComponentInstance} from 'shared/ReactTypes';
import invariant from 'shared/invariant';

// Modules provided by RN:
import UIManager from 'UIManager';
import deepFreezeAndThrowOnMutationInDev from 'deepFreezeAndThrowOnMutationInDev';
import {
ReactNativeViewConfigRegistry,
UIManager,
deepFreezeAndThrowOnMutationInDev,
} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';

import {get as getViewConfigForType} from 'ReactNativeViewConfigRegistry';
import {create, diff} from './ReactNativeAttributePayload';
import {
precacheFiberNode,
Expand All @@ -25,6 +27,8 @@ import {
} from './ReactNativeComponentTree';
import ReactNativeFiberHostComponent from './ReactNativeFiberHostComponent';

const {get: getViewConfigForType} = ReactNativeViewConfigRegistry;

export type Type = string;
export type Props = Object;
export type Container = number;
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-renderer/src/ReactNativeInjection.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import ReactNativeGlobalResponderHandler from './ReactNativeGlobalResponderHandl
import ResponderEventPlugin from 'events/ResponderEventPlugin';

// Module provided by RN:
import RCTEventEmitter from 'RCTEventEmitter';
import {RCTEventEmitter} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';

/**
* Register the event emitter with the native bridge
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* TODO: require this in packager, not in React #10932517
*/
// Module provided by RN:
import 'InitializeCore';
import 'react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore';

import {injection as EventPluginHubInjection} from 'events/EventPluginHub';
import ResponderEventPlugin from 'events/ResponderEventPlugin';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native-renderer/src/ReactNativeRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
} from 'events/ReactGenericBatching';
import ReactVersion from 'shared/ReactVersion';
// Module provided by RN:
import UIManager from 'UIManager';
import {UIManager} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';

import NativeMethodsMixin from './NativeMethodsMixin';
import ReactNativeComponent from './ReactNativeComponent';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {warnForStyleProps} from './NativeMethodsMixinUtils';
import warningWithoutStack from 'shared/warningWithoutStack';

// Module provided by RN:
import UIManager from 'UIManager';
import {UIManager} from 'react-native/Libraries/ReactPrivate/ReactNativePrivateInterface';

export function setNativeProps(handle: any, nativeProps: Object): void {
if (handle._nativeTag == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,4 @@ const RCTFabricUIManager = {
}),
};

module.exports = RCTFabricUIManager;
global.nativeFabricUIManager = RCTFabricUIManager;
Original file line number Diff line number Diff line change
Expand Up @@ -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 strict
*/

'use strict';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
*/

module.exports = {
get BatchedBridge() {
return require('./BatchedBridge.js');
},
get ExceptionsManager() {
return require('./ExceptionsManager');
},
get Platform() {
return require('./Platform');
},
get RCTEventEmitter() {
return require('./RCTEventEmitter');
},
get ReactNativeViewConfigRegistry() {
return require('./ReactNativeViewConfigRegistry');
},
get TextInputState() {
return require('./TextInputState');
},
get UIManager() {
return require('./UIManager');
},
get deepDiffer() {
return require('./deepDiffer');
},
get deepFreezeAndThrowOnMutationInDev() {
return require('./deepFreezeAndThrowOnMutationInDev');
},
get flattenStyle() {
return require('./flattenStyle');
},
};
Loading