[ReactNative] Strip prefixes from NativeModules keys

This commit is contained in:
Spencer Ahrens 2015-03-17 22:22:03 -07:00
parent 2991f583e0
commit 9086365faf
46 changed files with 75 additions and 75 deletions

View File

@ -3,7 +3,7 @@
*/
'use strict';
var RCTTestModule = require('NativeModules').RCTTestModule;
var RCTTestModule = require('NativeModules').TestModule;
var React = require('react-native');
var {
Text,

View File

@ -5,7 +5,7 @@
*/
'use strict';
var { RCTActionSheetManager } = require('NativeModules');
var RCTActionSheetManager = require('NativeModules').ActionSheetManager;
var invariant = require('invariant');

View File

@ -5,7 +5,7 @@
*/
'use strict';
var AdSupport = require('NativeModules').RCTAdSupport;
var AdSupport = require('NativeModules').AdSupport;
module.exports = {
getAdvertisingId: function(onSuccess, onFailure) {

View File

@ -6,7 +6,7 @@
*/
'use strict';
var { RCTAnimationManager } = require('NativeModules');
var RCTAnimationManager = require('NativeModules').AnimationManager;
var AnimationUtils = require('AnimationUtils');
type EasingFunction = (t: number) => number;

View File

@ -7,7 +7,7 @@
'use strict';
var AnimationUtils = require('AnimationUtils');
var { RCTAnimationManager } = require('NativeModules');
var RCTAnimationManager = require('NativeModules').AnimationManager;
var invariant = require('invariant');

View File

@ -6,7 +6,7 @@
'use strict';
var PropTypes = require('ReactPropTypes');
var RCTUIManager = require('NativeModules').RCTUIManager;
var RCTUIManager = require('NativeModules').UIManager;
var createStrictShapeTypeChecker = require('createStrictShapeTypeChecker');
var keyMirror = require('keyMirror');

View File

@ -6,7 +6,7 @@
'use strict';
var NativeModules = require('NativeModules');
var RCTAppState = NativeModules.RCTAppState;
var RCTAppState = NativeModules.AppState;
var AppState = {

View File

@ -7,7 +7,7 @@
var NativeModules = require('NativeModules');
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
var RCTAppState = NativeModules.RCTAppState;
var RCTAppState = NativeModules.AppState;
var logError = require('logError');

View File

@ -7,8 +7,8 @@
var NativeModules = require('BatchedBridge').RemoteModules;
var nativeModulePrefixDuplicator = require('nativeModulePrefixDuplicator');
var nativeModulePrefixNormalizer = require('nativeModulePrefixNormalizer');
nativeModulePrefixDuplicator(NativeModules);
nativeModulePrefixNormalizer(NativeModules);
module.exports = NativeModules;

View File

@ -5,7 +5,7 @@
*/
'use strict';
var RCTPOPAnimationManager = require('NativeModules').RCTPOPAnimationManager;
var RCTPOPAnimationManager = require('NativeModules').POPAnimationManager;
if (!RCTPOPAnimationManager) {
// POP animation isn't available in the OSS fork - this is a temporary
// workaround to enable its availability to be determined at runtime.

View File

@ -5,6 +5,6 @@
*/
'use strict';
var { RCTAlertManager } = require('NativeModules');
var RCTAlertManager = require('NativeModules').AlertManager;
module.exports = RCTAlertManager;

View File

@ -6,7 +6,7 @@
'use strict';
var ReactPropTypes = require('ReactPropTypes');
var RCTCameraRollManager = require('NativeModules').RCTCameraRollManager;
var RCTCameraRollManager = require('NativeModules').CameraRollManager;
var createStrictShapeTypeChecker = require('createStrictShapeTypeChecker');
var deepFreezeAndThrowOnMutationInDev =

View File

@ -56,7 +56,7 @@ var ActivityIndicatorIOS = React.createClass({
render: function() {
var style = styles.sizeSmall;
var NativeConstants = NativeModules.RCTUIManager.UIActivityIndicatorView.Constants;
var NativeConstants = NativeModules.UIManager.UIActivityIndicatorView.Constants;
var activityIndicatorViewStyle = NativeConstants.StyleWhite;
if (this.props.size === 'large') {
style = styles.sizeLarge;

View File

@ -11,7 +11,7 @@ var NativeMethodsMixin = require('NativeMethodsMixin');
var PropTypes = require('ReactPropTypes');
var React = require('React');
var ReactIOSViewAttributes = require('ReactIOSViewAttributes');
var RCTDatePickerIOSConsts = require('NativeModules').RCTUIManager.RCTDatePicker.Constants;
var RCTDatePickerIOSConsts = require('NativeModules').UIManager.RCTDatePicker.Constants;
var StyleSheet = require('StyleSheet');
var View = require('View');

View File

@ -7,7 +7,7 @@
var ListViewDataSource = require('ListViewDataSource');
var React = require('React');
var RCTUIManager = require('NativeModules').RCTUIManager;
var RCTUIManager = require('NativeModules').UIManager;
var ScrollView = require('ScrollView');
var ScrollResponder = require('ScrollResponder');
var StaticRenderer = require('StaticRenderer');

View File

@ -8,7 +8,7 @@
var EventEmitter = require('EventEmitter');
var React = require('React');
var ReactIOSViewAttributes = require('ReactIOSViewAttributes');
var { RCTNavigatorManager } = require('NativeModules');
var RCTNavigatorManager = require('NativeModules').NavigatorManager;
var StyleSheet = require('StyleSheet');
var StaticContainer = require('StaticContainer.react');
var View = require('View');

View File

@ -11,8 +11,8 @@ var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
var Subscribable = require('Subscribable');
var TextInputState = require('TextInputState');
var RCTUIManager = NativeModules.RCTUIManager;
var RCTUIManagerDeprecated = NativeModules.RCTUIManager;
var RCTUIManager = NativeModules.UIManager;
var RCTUIManagerDeprecated = NativeModules.UIManager;
var RCTScrollViewConsts = RCTUIManager.RCTScrollView.Constants;
var warning = require('warning');

View File

@ -8,12 +8,12 @@
var EdgeInsetsPropType = require('EdgeInsetsPropType');
var Platform = require('Platform');
var PointPropType = require('PointPropType');
var RCTScrollView = require('NativeModules').RCTUIManager.RCTScrollView;
var RCTScrollView = require('NativeModules').UIManager.RCTScrollView;
var RCTScrollViewConsts = RCTScrollView.Constants;
var React = require('React');
var ReactIOSTagHandles = require('ReactIOSTagHandles');
var ReactIOSViewAttributes = require('ReactIOSViewAttributes');
var RCTUIManager = require('NativeModules').RCTUIManager;
var RCTUIManager = require('NativeModules').UIManager;
var ScrollResponder = require('ScrollResponder');
var StyleSheet = require('StyleSheet');
var StyleSheetPropType = require('StyleSheetPropType');

View File

@ -6,7 +6,7 @@
*/
'use strict';
var { RCTStatusBarManager } = require('NativeModules');
var RCTStatusBarManager = require('NativeModules').StatusBarManager;
var StatusBarIOS = {

View File

@ -8,7 +8,7 @@
var DocumentSelectionState = require('DocumentSelectionState');
var EventEmitter = require('EventEmitter');
var NativeMethodsMixin = require('NativeMethodsMixin');
var RCTUIManager = require('NativeModules').RCTUIManager;
var RCTUIManager = require('NativeModules').UIManager;
var PropTypes = require('ReactPropTypes');
var React = require('React');
var ReactChildren = require('ReactChildren');

View File

@ -9,7 +9,7 @@
*/
'use strict';
var RCTUIManager = require('NativeModules').RCTUIManager;
var RCTUIManager = require('NativeModules').UIManager;
var TextInputState = {
/**

View File

@ -16,7 +16,7 @@ var keyMirror = require('keyMirror');
var merge = require('merge');
var PropTypes = React.PropTypes;
var RCTUIManager = require('NativeModules').RCTUIManager;
var RCTUIManager = require('NativeModules').UIManager;
var RCT_WEBVIEW_REF = 'webview';

View File

@ -17,7 +17,7 @@ var insetsDiffer = require('insetsDiffer');
var merge = require('merge');
var PropTypes = React.PropTypes;
var { RCTWebViewManager } = require('NativeModules');
var RCTWebViewManager = require('NativeModules').WebViewManager;
var RCT_WEBVIEW_REF = 'webview';

View File

@ -6,7 +6,7 @@
'use strict';
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
var RCTLocationObserver = require('NativeModules').RCTLocationObserver;
var RCTLocationObserver = require('NativeModules').LocationObserver;
var invariant = require('invariant');
var logError = require('logError');

View File

@ -114,7 +114,7 @@ var Image = React.createClass({
warning(RawImage === RCTStaticImage, 'tintColor style only supported on static images.');
}
var contentModes = NativeModules.RCTUIManager.UIView.ContentMode;
var contentModes = NativeModules.UIManager.UIView.ContentMode;
var resizeMode;
if (style.resizeMode === ImageResizeMode.stretch) {
resizeMode = contentModes.ScaleToFill;

View File

@ -60,7 +60,7 @@ function setupDocumentShim() {
var sourceMapPromise;
function handleErrorWithRedBox(e) {
var RCTExceptionsManager = require('NativeModules').RCTExceptionsManager;
var RCTExceptionsManager = require('NativeModules').ExceptionsManager;
var errorToString = require('errorToString');
var loadSourceMap = require('loadSourceMap');
@ -115,7 +115,7 @@ function setupTimers() {
}
function setupAlert() {
var { RCTAlertManager } = require('NativeModules');
var RCTAlertManager = require('NativeModules').AlertManager;
if (!GLOBAL.alert) {
GLOBAL.alert = function(text) {
var alertOpts = {

View File

@ -8,7 +8,7 @@
'use strict';
var Promise = require('Promise');
var RCTSourceCode = require('NativeModules').RCTSourceCode;
var RCTSourceCode = require('NativeModules').SourceCode;
var SourceMapConsumer = require('SourceMap').SourceMapConsumer;
var SourceMapURL = require('./source-map-url');

View File

@ -7,7 +7,7 @@
// Note that the module JSTimers is split into two in order to solve a cycle
// in dependencies. NativeModules > BatchedBridge > MessageQueue > JSTimersExecution
var RCTTiming = require('NativeModules').RCTTiming;
var RCTTiming = require('NativeModules').Timing;
var JSTimersExecution = require('JSTimersExecution');
/**

View File

@ -8,7 +8,7 @@
var NativeModules = require('NativeModules');
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
var RCTReachability = NativeModules.RCTReachability;
var RCTReachability = NativeModules.Reachability;
var DEVICE_REACHABILITY_EVENT = 'reachabilityDidChange';

View File

@ -6,7 +6,7 @@
*/
'use strict';
var RCTDataManager = require('NativeModules').RCTDataManager;
var RCTDataManager = require('NativeModules').DataManager;
var crc32 = require('crc32');

View File

@ -11,7 +11,7 @@ var NativeMethodsMixin = require('NativeMethodsMixin');
var React = require('React');
var ReactChildren = require('ReactChildren');
var ReactIOSViewAttributes = require('ReactIOSViewAttributes');
var RCTPickerIOSConsts = require('NativeModules').RCTUIManager.RCTPicker.Constants;
var RCTPickerIOSConsts = require('NativeModules').UIManager.RCTPicker.Constants;
var StyleSheet = require('StyleSheet');
var View = require('View');

View File

@ -6,7 +6,7 @@
'use strict';
var ReactIOSTagHandles = require('ReactIOSTagHandles');
var RCTUIManager = require('NativeModules').RCTUIManager;
var RCTUIManager = require('NativeModules').UIManager;
/**
* Queries the layout of a view. The layout does not reflect the element as

View File

@ -13,7 +13,7 @@ var SyntheticEvent = require('SyntheticEvent');
var merge = require('merge');
var warning = require('warning');
var RCTUIManager = NativeModules.RCTUIManager;
var RCTUIManager = NativeModules.UIManager;
var customBubblingEventTypes = RCTUIManager.customBubblingEventTypes;
var customDirectEventTypes = RCTUIManager.customDirectEventTypes;

View File

@ -7,8 +7,8 @@
var NativeModules = require('NativeModules');
var NativeModules = require('NativeModules');
var RCTPOPAnimationManager = NativeModules.RCTPOPAnimationManager;
var RCTUIManager = NativeModules.RCTUIManager;
var RCTPOPAnimationManager = NativeModules.POPAnimationManager;
var RCTUIManager = NativeModules.UIManager;
var TextInputState = require('TextInputState');
var flattenStyle = require('flattenStyle');

View File

@ -9,7 +9,7 @@
var ReactIOSTagHandles = require('ReactIOSTagHandles');
var ReactMultiChildUpdateTypes = require('ReactMultiChildUpdateTypes');
var RCTUIManager = require('NativeModules').RCTUIManager;
var RCTUIManager = require('NativeModules').UIManager;
var ReactPerf = require('ReactPerf');
/**

View File

@ -3,7 +3,7 @@
*/
'use strict';
var RCTUIManager = require('NativeModules').RCTUIManager;
var RCTUIManager = require('NativeModules').UIManager;
var ReactIOSTagHandles = require('ReactIOSTagHandles');
var ReactIOSGlobalResponderHandler = {

View File

@ -5,7 +5,7 @@
*/
'use strict';
var RCTUIManager = require('NativeModules').RCTUIManager;
var RCTUIManager = require('NativeModules').UIManager;
var ReactIOSTagHandles = require('ReactIOSTagHandles');
var ReactPerf = require('ReactPerf');

View File

@ -11,7 +11,7 @@ var ReactIOSEventEmitter = require('ReactIOSEventEmitter');
var ReactIOSStyleAttributes = require('ReactIOSStyleAttributes');
var ReactIOSTagHandles = require('ReactIOSTagHandles');
var ReactMultiChild = require('ReactMultiChild');
var RCTUIManager = require('NativeModules').RCTUIManager;
var RCTUIManager = require('NativeModules').UIManager;
var styleDiffer = require('styleDiffer');
var deepFreezeAndThrowOnMutationInDev = require('deepFreezeAndThrowOnMutationInDev');

View File

@ -7,7 +7,7 @@
'use strict';
var ReactIOSTagHandles = require('ReactIOSTagHandles');
var RCTUIManager = require('NativeModules').RCTUIManager;
var RCTUIManager = require('NativeModules').UIManager;
var assign = require('Object.assign');

View File

@ -7,8 +7,8 @@
'use strict';
var NativeModules = require('NativeModules');
var RCTAsyncLocalStorage = NativeModules.RCTAsyncLocalStorage;
var RCTAsyncRocksDBStorage = NativeModules.RCTAsyncRocksDBStorage;
var RCTAsyncLocalStorage = NativeModules.AsyncLocalStorage;
var RCTAsyncRocksDBStorage = NativeModules.AsyncRocksDBStorage;
// We use RocksDB if available.
var RCTAsyncStorage = RCTAsyncRocksDBStorage || RCTAsyncLocalStorage;

View File

@ -6,7 +6,7 @@
*/
'use strict';
var { RCTAlertManager } = require('NativeModules');
var RCTAlertManager = require('NativeModules').AlertManager;
var DEFAULT_BUTTON_TEXT = 'OK';
var DEFAULT_BUTTON = {

View File

@ -9,7 +9,7 @@ var NativeModules = require('NativeModules');
var invariant = require('invariant');
var dimensions = NativeModules.RCTUIManager.Dimensions;
var dimensions = NativeModules.UIManager.Dimensions;
class Dimensions {
/**

View File

@ -8,7 +8,7 @@
var NativeModules = require('NativeModules');
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
var RCTPushNotificationManager = NativeModules.RCTPushNotificationManager;
var RCTPushNotificationManager = NativeModules.PushNotificationManager;
if (RCTPushNotificationManager) {
var _initialNotification = RCTPushNotificationManager.initialNotification;
}

View File

@ -1,25 +0,0 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
*
* @providesModule nativeModulePrefixDuplicator
*/
'use strict';
// Dirty hack to support old (RK) and new (RCT) native module name conventions
function nativeModulePrefixDuplicator(modules) {
Object.keys(modules).forEach((moduleName) => {
var rkModuleName = moduleName.replace(/^RCT/, 'RK');
var rctModuleName = moduleName.replace(/^RK/, 'RCT');
if (rkModuleName !== rctModuleName) {
if (modules[rkModuleName] && modules[rctModuleName]) {
throw new Error(
'Module cannot be registered as both RCT and RK: ' + moduleName
);
}
modules[rkModuleName] = modules[moduleName];
modules[rctModuleName] = modules[moduleName];
}
});
}
module.exports = nativeModulePrefixDuplicator;

View File

@ -0,0 +1,24 @@
/**
* Copyright 2004-present Facebook. All Rights Reserved.
*
* @providesModule nativeModulePrefixNormalizer
*/
'use strict';
// Dirty hack to support old (RK) and new (RCT) native module name conventions
function nativeModulePrefixNormalizer(modules) {
Object.keys(modules).forEach((moduleName) => {
var strippedName = moduleName.replace(/^(RCT|RK)/, '');
if (modules['RCT' + strippedName] && modules['RK' + strippedName]) {
throw new Error(
'Module cannot be registered as both RCT and RK: ' + moduleName
);
}
if (strippedName !== moduleName) {
modules[strippedName] = modules[moduleName];
delete modules[moduleName];
}
});
}
module.exports = nativeModulePrefixNormalizer;

View File

@ -5,7 +5,8 @@
*/
'use strict';
var {RCTVibration} = require('NativeModules');
var RCTVibration = require('NativeModules').Vibration;
var invariant = require('invariant');
/**