Skip to content

Commit

Permalink
[standards] Rewrite imports in RNTester to use standard paths
Browse files Browse the repository at this point in the history
See #24316 for the motivation. This commit rewrites the imports in the RNTester project.

Test Plan: Run RNTester and verify that it loads without any issues. Tap through each screen to ensure the JS modules load (that is, were bundled) correctly.
  • Loading branch information
ide committed Apr 4, 2019
1 parent e67aa42 commit dd3aae8
Show file tree
Hide file tree
Showing 47 changed files with 150 additions and 131 deletions.
4 changes: 2 additions & 2 deletions RNTester/NativeModuleExample/NativeScreenshotManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

'use strict';

import type {TurboModule} from 'RCTExport';
import * as TurboModuleRegistry from 'TurboModuleRegistry';
import type {TurboModule} from '../../Libraries/TurboModule/RCTExport';
import * as TurboModuleRegistry from '../../Libraries/TurboModule/TurboModuleRegistry';

export interface Spec extends TurboModule {
+getConstants: () => {||};
Expand Down
8 changes: 4 additions & 4 deletions RNTester/RCTTest/RCTSnapshotNativeComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

'use strict';

import type {SyntheticEvent} from 'CoreEventTypes';
import type {ViewProps} from 'ViewPropTypes';
import type {NativeComponent} from 'ReactNative';
import type {SyntheticEvent} from '../../Libraries/Types/CoreEventTypes';
import type {ViewProps} from '../../Libraries/Components/View/ViewPropTypes';
import type {NativeComponent} from '../../Libraries/Renderer/shims/ReactNative';

type SnapshotReadyEvent = SyntheticEvent<
$ReadOnly<{
Expand All @@ -28,7 +28,7 @@ type NativeProps = $ReadOnly<{|

type SnapshotViewNativeType = Class<NativeComponent<NativeProps>>;

const requireNativeComponent = require('requireNativeComponent');
const requireNativeComponent = require('../../Libraries/ReactNative/requireNativeComponent');

module.exports = ((requireNativeComponent(
'RCTSnapshot',
Expand Down
2 changes: 1 addition & 1 deletion RNTester/js/AnimatedGratuitousApp/AnExApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const React = require('react');
const ReactNative = require('react-native');
const {Animated, LayoutAnimation, PanResponder, StyleSheet, View} = ReactNative;

const AnExSet = require('AnExSet');
const AnExSet = require('./AnExSet');

const CIRCLE_SIZE = 80;
const CIRCLE_MARGIN = 18;
Expand Down
2 changes: 1 addition & 1 deletion RNTester/js/AssetScaledImageExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const React = require('react');
const ReactNative = require('react-native');
const {Image, StyleSheet, View, ScrollView} = ReactNative;

import type {PhotoIdentifier} from 'CameraRoll';
import type {PhotoIdentifier} from '../../Libraries/CameraRoll/CameraRoll';

type Props = $ReadOnly<{|
asset: PhotoIdentifier,
Expand Down
5 changes: 4 additions & 1 deletion RNTester/js/CameraRollExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ const CameraRollView = require('./CameraRollView');

const AssetScaledImageExampleView = require('./AssetScaledImageExample');

import type {PhotoIdentifier, GroupTypes} from 'CameraRoll';
import type {
PhotoIdentifier,
GroupTypes,
} from '../../Libraries/CameraRoll/CameraRoll';

type Props = $ReadOnly<{|
navigator?: ?Array<
Expand Down
6 changes: 3 additions & 3 deletions RNTester/js/CameraRollView.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ const {
View,
} = ReactNative;

const groupByEveryN = require('groupByEveryN');
const logError = require('logError');
const groupByEveryN = require('../../Libraries/Utilities/groupByEveryN');
const logError = require('../../Libraries/Utilities/logError');

import type {
PhotoIdentifier,
PhotoIdentifiersPage,
GetPhotosParams,
} from 'CameraRoll';
} from '../../Libraries/CameraRoll/CameraRoll';

type Props = $ReadOnly<{|
/**
Expand Down
4 changes: 2 additions & 2 deletions RNTester/js/FlatListExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

import type {Item} from './ListExampleShared';

const Alert = require('Alert');
const Alert = require('../../Libraries/Alert/Alert');
const React = require('react');
const ReactNative = require('react-native');
const {Animated, StyleSheet, View} = ReactNative;

const RNTesterPage = require('./RNTesterPage');

const infoLog = require('infoLog');
const infoLog = require('../../Libraries/Utilities/infoLog');

const {
FooterComponent,
Expand Down
2 changes: 1 addition & 1 deletion RNTester/js/ImageCapInsetsExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
const React = require('react');
const ReactNative = require('react-native');

const nativeImageSource = require('nativeImageSource');
const nativeImageSource = require('../../Libraries/Image/nativeImageSource');
const {Image, StyleSheet, Text, View} = ReactNative;

type Props = $ReadOnly<{||}>;
Expand Down
2 changes: 1 addition & 1 deletion RNTester/js/InputAccessoryViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

'use strict';

const React = require('React');
const React = require('react');
const ReactNative = require('react-native');
const {
Alert,
Expand Down
2 changes: 1 addition & 1 deletion RNTester/js/KeyboardAvoidingViewExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

'use strict';

const React = require('React');
const React = require('react');
const ReactNative = require('react-native');
const {
KeyboardAvoidingView,
Expand Down
5 changes: 4 additions & 1 deletion RNTester/js/LayoutEventsExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ const React = require('react');
const ReactNative = require('react-native');
const {Image, LayoutAnimation, StyleSheet, Text, View} = ReactNative;

import type {ViewLayout, ViewLayoutEvent} from 'ViewPropTypes';
import type {
ViewLayout,
ViewLayoutEvent,
} from '../../Libraries/Components/View/ViewPropTypes';

type Props = $ReadOnly<{||}>;
type State = {
Expand Down
2 changes: 1 addition & 1 deletion RNTester/js/MultiColumnExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const {FlatList, StyleSheet, Text, View, Alert} = ReactNative;

const RNTesterPage = require('./RNTesterPage');

const infoLog = require('infoLog');
const infoLog = require('../../Libraries/Utilities/infoLog');

const {
FooterComponent,
Expand Down
24 changes: 14 additions & 10 deletions RNTester/js/NativeAnimationsExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class LoopExample extends React.Component<{}, $FlowFixMeState> {
}
}

const RNTesterSettingSwitchRow = require('RNTesterSettingSwitchRow');
const RNTesterSettingSwitchRow = require('./RNTesterSettingSwitchRow');
class InternalSettings extends React.Component<
{},
{busyTime: number | string, filteredStall: number},
Expand Down Expand Up @@ -188,16 +188,20 @@ class InternalSettings extends React.Component<
initialValue={false}
label="Track JS Stalls"
onEnable={() => {
require('JSEventLoopWatchdog').install({thresholdMS: 25});
this.setState({busyTime: '<none>'});
require('JSEventLoopWatchdog').addHandler({
onStall: ({busyTime}) =>
this.setState(state => ({
busyTime,
filteredStall:
(state.filteredStall || 0) * 0.97 + busyTime * 0.03,
})),
require('../../Libraries/Interaction/JSEventLoopWatchdog').install({
thresholdMS: 25,
});
this.setState({busyTime: '<none>'});
require('../../Libraries/Interaction/JSEventLoopWatchdog').addHandler(
{
onStall: ({busyTime}) =>
this.setState(state => ({
busyTime,
filteredStall:
(state.filteredStall || 0) * 0.97 + busyTime * 0.03,
})),
},
);
}}
onDisable={() => {
console.warn('Cannot disable yet....');
Expand Down
2 changes: 1 addition & 1 deletion RNTester/js/OrientationChangeExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const React = require('react');
const ReactNative = require('react-native');
const {DeviceEventEmitter, Text, View} = ReactNative;

import type EmitterSubscription from 'EmitterSubscription';
import type EmitterSubscription from '../../Libraries/vendor/emitter/EmitterSubscription';

class OrientationChangeExample extends React.Component<{}, $FlowFixMeState> {
_orientationSubscription: EmitterSubscription;
Expand Down
7 changes: 5 additions & 2 deletions RNTester/js/PanResponderExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ const React = require('react');
const ReactNative = require('react-native');
const {PanResponder, StyleSheet, View} = ReactNative;

import type {PanResponderInstance, GestureState} from 'PanResponder';
import type {PressEvent} from 'CoreEventTypes';
import type {
PanResponderInstance,
GestureState,
} from '../../Libraries/Interaction/PanResponder';
import type {PressEvent} from '../../Libraries/Types/CoreEventTypes';

type CircleStyles = {
backgroundColor?: string,
Expand Down
2 changes: 1 addition & 1 deletion RNTester/js/PickerExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

const React = require('react');
const ReactNative = require('react-native');
const StyleSheet = require('StyleSheet');
const StyleSheet = require('../../Libraries/StyleSheet/StyleSheet');

const {Picker, Text} = ReactNative;

Expand Down
10 changes: 5 additions & 5 deletions RNTester/js/ProgressBarAndroidExample.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

'use strict';

const ProgressBar = require('ProgressBarAndroid');
const React = require('React');
const RNTesterBlock = require('RNTesterBlock');
const RNTesterPage = require('RNTesterPage');
const ProgressBar = require('../../Libraries/Components/ProgressBarAndroid/ProgressBarAndroid');
const React = require('react');
const RNTesterBlock = require('./RNTesterBlock');
const RNTesterPage = require('./RNTesterPage');

import type {ProgressBarAndroidProps} from 'ProgressBarAndroid';
import type {ProgressBarAndroidProps} from '../../Libraries/Components/ProgressBarAndroid/ProgressBarAndroid';

type MovingBarProps = $ReadOnly<{|
...$Diff<
Expand Down
38 changes: 22 additions & 16 deletions RNTester/js/PushNotificationIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,27 +86,33 @@ class NotificationExample extends React.Component<{}> {
}

_sendNotification() {
require('RCTDeviceEventEmitter').emit('remoteNotificationReceived', {
remote: true,
aps: {
alert: 'Sample notification',
badge: '+1',
sound: 'default',
category: 'REACT_NATIVE',
'content-available': 1,
require('../../Libraries/EventEmitter/RCTDeviceEventEmitter').emit(
'remoteNotificationReceived',
{
remote: true,
aps: {
alert: 'Sample notification',
badge: '+1',
sound: 'default',
category: 'REACT_NATIVE',
'content-available': 1,
},
},
});
);
}

_sendLocalNotification() {
require('RCTDeviceEventEmitter').emit('localNotificationReceived', {
aps: {
alert: 'Sample local notification',
badge: '+1',
sound: 'default',
category: 'REACT_NATIVE',
require('../../Libraries/EventEmitter/RCTDeviceEventEmitter').emit(
'localNotificationReceived',
{
aps: {
alert: 'Sample local notification',
badge: '+1',
sound: 'default',
category: 'REACT_NATIVE',
},
},
});
);
}

_onRegistered(deviceToken) {
Expand Down
2 changes: 1 addition & 1 deletion RNTester/js/RCTRootViewIOSExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const React = require('react');
const ReactNative = require('react-native');
const {StyleSheet, Text, View} = ReactNative;

const requireNativeComponent = require('requireNativeComponent');
const requireNativeComponent = require('../../Libraries/ReactNative/requireNativeComponent');

class AppPropertiesUpdateExample extends React.Component<{}> {
render() {
Expand Down
24 changes: 12 additions & 12 deletions RNTester/js/RNTesterApp.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,28 @@

'use strict';

const AppRegistry = require('AppRegistry');
const AsyncStorage = require('AsyncStorage');
const BackHandler = require('BackHandler');
const Dimensions = require('Dimensions');
const DrawerLayoutAndroid = require('DrawerLayoutAndroid');
const Linking = require('Linking');
const AppRegistry = require('../../Libraries/ReactNative/AppRegistry');
const AsyncStorage = require('../../Libraries/Storage/AsyncStorage');
const BackHandler = require('../../Libraries/Utilities/BackHandler');
const Dimensions = require('../../Libraries/Utilities/Dimensions');
const DrawerLayoutAndroid = require('../../Libraries/Components/DrawerAndroid/DrawerLayoutAndroid');
const Linking = require('../../Libraries/Linking/Linking');
const React = require('react');
const StatusBar = require('StatusBar');
const StyleSheet = require('StyleSheet');
const ToolbarAndroid = require('ToolbarAndroid');
const StatusBar = require('../../Libraries/Components/StatusBar/StatusBar');
const StyleSheet = require('../../Libraries/StyleSheet/StyleSheet');
const ToolbarAndroid = require('../../Libraries/Components/ToolbarAndroid/ToolbarAndroid');
const RNTesterActions = require('./RNTesterActions');
const RNTesterExampleContainer = require('./RNTesterExampleContainer');
const RNTesterExampleList = require('./RNTesterExampleList');
/* $FlowFixMe(>=0.78.0 site=react_native_android_fb) This issue was found when
* making Flow check .android.js files. */
const RNTesterList = require('./RNTesterList');
const RNTesterNavigationReducer = require('./RNTesterNavigationReducer');
const UIManager = require('UIManager');
const UIManager = require('../../Libraries/ReactNative/UIManager');
const URIActionMap = require('./URIActionMap');
const View = require('View');
const View = require('../../Libraries/Components/View/View');

const nativeImageSource = require('nativeImageSource');
const nativeImageSource = require('../../Libraries/Image/nativeImageSource');

import type {RNTesterNavigationState} from './RNTesterNavigationReducer';

Expand Down
10 changes: 5 additions & 5 deletions RNTester/js/RNTesterApp.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@

'use strict';

require('InitializeCore');
const AsyncStorage = require('AsyncStorage');
const BackHandler = require('BackHandler');
const Linking = require('Linking');
require('../../Libraries/Core/InitializeCore');
const AsyncStorage = require('../../Libraries/Storage/AsyncStorage');
const BackHandler = require('../../Libraries/Utilities/BackHandler');
const Linking = require('../../Libraries/Linking/Linking');
const React = require('react');
const ReactNative = require('react-native');
const RNTesterActions = require('./RNTesterActions');
Expand All @@ -34,7 +34,7 @@ const {
YellowBox,
} = ReactNative;

import type {RNTesterExample} from 'RNTesterTypes';
import type {RNTesterExample} from './Shared/RNTesterTypes';
import type {RNTesterAction} from './RNTesterActions';
import type {RNTesterNavigationState} from './RNTesterNavigationReducer';

Expand Down
2 changes: 1 addition & 1 deletion RNTester/js/RNTesterButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
const React = require('react');
const {StyleSheet, Text, TouchableHighlight} = require('react-native');

import type {PressEvent} from 'CoreEventTypes';
import type {PressEvent} from '../../Libraries/Types/CoreEventTypes';

type Props = $ReadOnly<{|
children?: React.Node,
Expand Down
6 changes: 3 additions & 3 deletions RNTester/js/RNTesterExampleFilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
'use strict';

const React = require('react');
const StyleSheet = require('StyleSheet');
const TextInput = require('TextInput');
const View = require('View');
const StyleSheet = require('../../Libraries/StyleSheet/StyleSheet');
const TextInput = require('../../Libraries/Components/TextInput/TextInput');
const View = require('../../Libraries/Components/View/View');

type Props = {
filter: Function,
Expand Down
Loading

0 comments on commit dd3aae8

Please sign in to comment.