From b396de3cc8f70221a2d62a410c9eb27fea615e01 Mon Sep 17 00:00:00 2001 From: Spencer Ahrens Date: Tue, 17 Mar 2015 03:08:46 -0700 Subject: [PATCH] [ReactNative] s/RK/RCT in OSS --- Libraries/ActionSheetIOS/ActionSheetIOS.js | 2 +- Libraries/Animation/LayoutAnimation.js | 4 +- Libraries/AppState/AppState.js | 11 +-- Libraries/AppStateIOS/AppStateIOS.ios.js | 4 +- .../BatchedBridgedModules/NativeModules.js | 8 +- .../NativeModulesDeprecated.js | 12 +-- .../BatchedBridgedModules/POPAnimation.js | 92 +++++++++---------- .../RCTAlertManager.ios.js | 10 ++ .../RKAlertManager.ios.js | 10 -- Libraries/CameraRoll/CameraRoll.js | 6 +- .../ActivityIndicatorIOS.ios.js | 2 +- .../DatePicker/DatePickerIOS.ios.js | 16 ++-- Libraries/Components/ListView/ListView.js | 6 +- Libraries/Components/MapView/MapView.js | 4 +- .../Components/Navigation/NavigatorIOS.ios.js | 20 ++-- Libraries/Components/ScrollResponder.js | 14 +-- Libraries/Components/ScrollView/ScrollView.js | 6 +- Libraries/Components/Slider/Slider.js | 4 +- .../Components/StatusBar/StatusBarIOS.ios.js | 16 ++-- Libraries/Components/Subscribable.js | 2 +- .../Components/SwitchIOS/SwitchIOS.ios.js | 6 +- .../Components/TabBarIOS/TabBarIOS.ios.js | 6 +- .../Components/TabBarIOS/TabBarItemIOS.ios.js | 6 +- .../Components/TextInput/TextInput.ios.js | 24 ++--- .../Components/TextInput/TextInputState.js | 6 +- .../Touchable/TouchableHighlight.js | 2 +- Libraries/Components/View/View.js | 14 +-- .../Components/WebView/WebView.android.js | 14 +-- Libraries/Components/WebView/WebView.ios.js | 28 +++--- Libraries/Image/Image.ios.js | 10 +- .../InitializeJavaScriptAppEngine.js | 14 +-- .../System/JSTimers/JSTimers.js | 10 +- Libraries/Network/NetInfo.js | 6 +- Libraries/Network/XMLHttpRequest.ios.js | 4 +- Libraries/Picker/PickerIOS.android.js | 2 +- Libraries/Picker/PickerIOS.ios.js | 12 +-- Libraries/RKBackendNode/queryLayoutByID.js | 4 +- .../ReactIOS/IOSNativeBridgeEventPlugin.js | 6 +- Libraries/ReactIOS/NativeMethodsMixin.js | 16 ++-- .../ReactIOS/ReactIOSComponentEnvironment.js | 3 - Libraries/ReactIOS/ReactIOSDOMIDOperations.js | 6 +- .../ReactIOSGlobalResponderHandler.js | 6 +- Libraries/ReactIOS/ReactIOSMount.js | 8 +- Libraries/ReactIOS/ReactIOSNativeComponent.js | 8 +- Libraries/ReactIOS/ReactIOSTextComponent.js | 6 +- Libraries/ReactIOS/ReactIOSViewAttributes.js | 4 +- Libraries/Storage/AsyncStorage.ios.js | 28 +++--- Libraries/Text/Text.js | 4 +- Libraries/Utilities/Dimensions.js | 2 +- .../Utilities/nativeModulePrefixDuplicator.js | 25 +++++ 50 files changed, 276 insertions(+), 263 deletions(-) create mode 100644 Libraries/BatchedBridge/BatchedBridgedModules/RCTAlertManager.ios.js delete mode 100644 Libraries/BatchedBridge/BatchedBridgedModules/RKAlertManager.ios.js create mode 100644 Libraries/Utilities/nativeModulePrefixDuplicator.js diff --git a/Libraries/ActionSheetIOS/ActionSheetIOS.js b/Libraries/ActionSheetIOS/ActionSheetIOS.js index d4cc84a48..085e8d86b 100644 --- a/Libraries/ActionSheetIOS/ActionSheetIOS.js +++ b/Libraries/ActionSheetIOS/ActionSheetIOS.js @@ -6,7 +6,7 @@ 'use strict'; var invariant = require('invariant'); -var RCTActionSheetManager = require('NativeModulesDeprecated').RKActionSheetManager; +var RCTActionSheetManager = require('NativeModulesDeprecated').RCTActionSheetManager; var ActionSheetIOS = { showActionSheetWithOptions(options, callback) { diff --git a/Libraries/Animation/LayoutAnimation.js b/Libraries/Animation/LayoutAnimation.js index 5ce5648b3..a5adc567b 100644 --- a/Libraries/Animation/LayoutAnimation.js +++ b/Libraries/Animation/LayoutAnimation.js @@ -6,7 +6,7 @@ 'use strict'; var PropTypes = require('ReactPropTypes'); -var RKUIManager = require('NativeModules').RKUIManager; +var RCTUIManager = require('NativeModules').RCTUIManager; var createStrictShapeTypeChecker = require('createStrictShapeTypeChecker'); var keyMirror = require('keyMirror'); @@ -47,7 +47,7 @@ var configChecker = createStrictShapeTypeChecker({ var LayoutAnimation = { configureNext(config, onAnimationDidEnd, onError) { configChecker({config}, 'config', 'LayoutAnimation.configureNext'); - RKUIManager.configureNextLayoutAnimation(config, onAnimationDidEnd, onError); + RCTUIManager.configureNextLayoutAnimation(config, onAnimationDidEnd, onError); }, create(duration, type, creationProp) { return { diff --git a/Libraries/AppState/AppState.js b/Libraries/AppState/AppState.js index ca5a7e607..3b8b9350d 100644 --- a/Libraries/AppState/AppState.js +++ b/Libraries/AppState/AppState.js @@ -6,21 +6,16 @@ 'use strict'; var NativeModules = require('NativeModulesDeprecated'); -var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var RKAppState = NativeModules.RKAppState; -var RKReachability = NativeModules.RKReachability; -var Subscribable = require('Subscribable'); - -var keyMirror = require('keyMirror'); +var RCTAppState = NativeModules.RCTAppState; var AppState = { setApplicationIconBadgeNumber: function(number) { - RKAppState.setApplicationIconBadgeNumber(number); + RCTAppState.setApplicationIconBadgeNumber(number); }, getApplicationIconBadgeNumber: function(callback) { - RKAppState.getApplicationIconBadgeNumber(callback); + RCTAppState.getApplicationIconBadgeNumber(callback); }, }; diff --git a/Libraries/AppStateIOS/AppStateIOS.ios.js b/Libraries/AppStateIOS/AppStateIOS.ios.js index 8f03654b5..1f6bca95b 100644 --- a/Libraries/AppStateIOS/AppStateIOS.ios.js +++ b/Libraries/AppStateIOS/AppStateIOS.ios.js @@ -7,7 +7,7 @@ var NativeModules = require('NativeModules'); var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var RKAppState = NativeModules.RKAppState; +var RCTAppState = NativeModules.RCTAppState; var logError = require('logError'); @@ -45,7 +45,7 @@ RCTDeviceEventEmitter.addListener( } ); -RKAppState.getCurrentAppState( +RCTAppState.getCurrentAppState( (appStateData) => { AppStateIOS.currentState = appStateData.app_state; }, diff --git a/Libraries/BatchedBridge/BatchedBridgedModules/NativeModules.js b/Libraries/BatchedBridge/BatchedBridgedModules/NativeModules.js index 680528575..f8029f8b8 100644 --- a/Libraries/BatchedBridge/BatchedBridgedModules/NativeModules.js +++ b/Libraries/BatchedBridge/BatchedBridgedModules/NativeModules.js @@ -7,10 +7,8 @@ var NativeModules = require('BatchedBridge').RemoteModules; -// Dirty hack to support old (RK) and new (RCT) native module name conventions -Object.keys(NativeModules).forEach((moduleName) => { - var rkModuleName = moduleName.replace(/^RCT/, 'RK'); - NativeModules[rkModuleName] = NativeModules[moduleName]; -}); +var nativeModulePrefixDuplicator = require('nativeModulePrefixDuplicator'); + +nativeModulePrefixDuplicator(NativeModules); module.exports = NativeModules; diff --git a/Libraries/BatchedBridge/BatchedBridgedModules/NativeModulesDeprecated.js b/Libraries/BatchedBridge/BatchedBridgedModules/NativeModulesDeprecated.js index 2d83d6f9a..d019872cd 100644 --- a/Libraries/BatchedBridge/BatchedBridgedModules/NativeModulesDeprecated.js +++ b/Libraries/BatchedBridge/BatchedBridgedModules/NativeModulesDeprecated.js @@ -5,12 +5,10 @@ */ 'use strict'; -var RemoteModulesDeprecated = require('BatchedBridge').RemoteModulesDeprecated; +var NativeModulesDeprecated = require('BatchedBridge').RemoteModulesDeprecated; -// Dirty hack to support old (RK) and new (RCT) native module name conventions -Object.keys(RemoteModulesDeprecated).forEach((moduleName) => { - var rkModuleName = moduleName.replace(/^RCT/, 'RK'); - RemoteModulesDeprecated[rkModuleName] = RemoteModulesDeprecated[moduleName]; -}); +var nativeModulePrefixDuplicator = require('nativeModulePrefixDuplicator'); -module.exports = RemoteModulesDeprecated; +nativeModulePrefixDuplicator(NativeModulesDeprecated); + +module.exports = NativeModulesDeprecated; diff --git a/Libraries/BatchedBridge/BatchedBridgedModules/POPAnimation.js b/Libraries/BatchedBridge/BatchedBridgedModules/POPAnimation.js index 8ec0bd62f..0ace433a3 100644 --- a/Libraries/BatchedBridge/BatchedBridgedModules/POPAnimation.js +++ b/Libraries/BatchedBridge/BatchedBridgedModules/POPAnimation.js @@ -5,8 +5,8 @@ */ 'use strict'; -var RKPOPAnimationManager = require('NativeModulesDeprecated').RKPOPAnimationManager; -if (!RKPOPAnimationManager) { +var RCTPOPAnimationManager = require('NativeModulesDeprecated').RCTPOPAnimationManager; +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. module.exports = null; @@ -18,45 +18,45 @@ var getObjectValues = require('getObjectValues'); var invariant = require('invariant'); var merge = require('merge'); -var RKTypes = RKPOPAnimationManager.Types; -var RKProperties = RKPOPAnimationManager.Properties; +var RCTTypes = RCTPOPAnimationManager.Types; +var RCTProperties = RCTPOPAnimationManager.Properties; var Properties = { - bounds: RKProperties.bounds, - opacity: RKProperties.opacity, - position: RKProperties.position, - positionX: RKProperties.positionX, - positionY: RKProperties.positionY, - zPosition: RKProperties.zPosition, - rotation: RKProperties.rotation, - rotationX: RKProperties.rotationX, - rotationY: RKProperties.rotationY, - scaleX: RKProperties.scaleX, - scaleXY: RKProperties.scaleXY, - scaleY: RKProperties.scaleY, - shadowColor: RKProperties.shadowColor, - shadowOffset: RKProperties.shadowOffset, - shadowOpacity: RKProperties.shadowOpacity, - shadowRadius: RKProperties.shadowRadius, - size: RKProperties.size, - subscaleXY: RKProperties.subscaleXY, - subtranslationX: RKProperties.subtranslationX, - subtranslationXY: RKProperties.subtranslationXY, - subtranslationY: RKProperties.subtranslationY, - subtranslationZ: RKProperties.subtranslationZ, - translationX: RKProperties.translationX, - translationXY: RKProperties.translationXY, - translationY: RKProperties.translationY, - translationZ: RKProperties.translationZ, + bounds: RCTProperties.bounds, + opacity: RCTProperties.opacity, + position: RCTProperties.position, + positionX: RCTProperties.positionX, + positionY: RCTProperties.positionY, + zPosition: RCTProperties.zPosition, + rotation: RCTProperties.rotation, + rotationX: RCTProperties.rotationX, + rotationY: RCTProperties.rotationY, + scaleX: RCTProperties.scaleX, + scaleXY: RCTProperties.scaleXY, + scaleY: RCTProperties.scaleY, + shadowColor: RCTProperties.shadowColor, + shadowOffset: RCTProperties.shadowOffset, + shadowOpacity: RCTProperties.shadowOpacity, + shadowRadius: RCTProperties.shadowRadius, + size: RCTProperties.size, + subscaleXY: RCTProperties.subscaleXY, + subtranslationX: RCTProperties.subtranslationX, + subtranslationXY: RCTProperties.subtranslationXY, + subtranslationY: RCTProperties.subtranslationY, + subtranslationZ: RCTProperties.subtranslationZ, + translationX: RCTProperties.translationX, + translationXY: RCTProperties.translationXY, + translationY: RCTProperties.translationY, + translationZ: RCTProperties.translationZ, }; var Types = { - decay: RKTypes.decay, - easeIn: RKTypes.easeIn, - easeInEaseOut: RKTypes.easeInEaseOut, - easeOut: RKTypes.easeOut, - linear: RKTypes.linear, - spring: RKTypes.spring, + decay: RCTTypes.decay, + easeIn: RCTTypes.easeIn, + easeInEaseOut: RCTTypes.easeInEaseOut, + easeOut: RCTTypes.easeOut, + linear: RCTTypes.linear, + spring: RCTTypes.spring, }; var POPAnimation = { @@ -98,7 +98,7 @@ var POPAnimation = { ); } - RKPOPAnimationManager.createAnimationInternal(tag, typeName, attrs); + RCTPOPAnimationManager.createAnimationInternal(tag, typeName, attrs); return tag; }, @@ -127,35 +127,35 @@ var POPAnimation = { }, addAnimation: function(nodeHandle, anim, callback) { - RKPOPAnimationManager.addAnimation(nodeHandle, anim, callback); + RCTPOPAnimationManager.addAnimation(nodeHandle, anim, callback); }, removeAnimation: function(nodeHandle, anim) { - RKPOPAnimationManager.removeAnimation(nodeHandle, anim); + RCTPOPAnimationManager.removeAnimation(nodeHandle, anim); }, }; -// Make sure that we correctly propagate RKPOPAnimationManager constants +// Make sure that we correctly propagate RCTPOPAnimationManager constants // to POPAnimation if (__DEV__) { var allProperties = merge( - RKPOPAnimationManager.Properties, - RKPOPAnimationManager.Properties + RCTPOPAnimationManager.Properties, + RCTPOPAnimationManager.Properties ); for (var key in allProperties) { invariant( - POPAnimation.Properties[key] === RKPOPAnimationManager.Properties[key], + POPAnimation.Properties[key] === RCTPOPAnimationManager.Properties[key], 'POPAnimation doesn\'t copy property ' + key + ' correctly' ); } var allTypes = merge( - RKPOPAnimationManager.Types, - RKPOPAnimationManager.Types + RCTPOPAnimationManager.Types, + RCTPOPAnimationManager.Types ); for (var key in allTypes) { invariant( - POPAnimation.Types[key] === RKPOPAnimationManager.Types[key], + POPAnimation.Types[key] === RCTPOPAnimationManager.Types[key], 'POPAnimation doesn\'t copy type ' + key + ' correctly' ); } diff --git a/Libraries/BatchedBridge/BatchedBridgedModules/RCTAlertManager.ios.js b/Libraries/BatchedBridge/BatchedBridgedModules/RCTAlertManager.ios.js new file mode 100644 index 000000000..fca0aa8d8 --- /dev/null +++ b/Libraries/BatchedBridge/BatchedBridgedModules/RCTAlertManager.ios.js @@ -0,0 +1,10 @@ +/** + * Copyright 2004-present Facebook. All Rights Reserved. + * + * @providesModule RCTAlertManager + */ +'use strict'; + +var RCTAlertManager = require('NativeModulesDeprecated').RCTAlertManager; + +module.exports = RCTAlertManager; diff --git a/Libraries/BatchedBridge/BatchedBridgedModules/RKAlertManager.ios.js b/Libraries/BatchedBridge/BatchedBridgedModules/RKAlertManager.ios.js deleted file mode 100644 index 39d3cbc27..000000000 --- a/Libraries/BatchedBridge/BatchedBridgedModules/RKAlertManager.ios.js +++ /dev/null @@ -1,10 +0,0 @@ -/** - * Copyright 2004-present Facebook. All Rights Reserved. - * - * @providesModule RKAlertManager - */ -'use strict'; - -var RKAlertManager = require('NativeModulesDeprecated').RKAlertManager; - -module.exports = RKAlertManager; diff --git a/Libraries/CameraRoll/CameraRoll.js b/Libraries/CameraRoll/CameraRoll.js index 54295fc52..d97fa8ce2 100644 --- a/Libraries/CameraRoll/CameraRoll.js +++ b/Libraries/CameraRoll/CameraRoll.js @@ -6,7 +6,7 @@ 'use strict'; var ReactPropTypes = require('ReactPropTypes'); -var RKCameraRollManager = require('NativeModules').RKCameraRollManager; +var RCTCameraRollManager = require('NativeModules').RCTCameraRollManager; var createStrictShapeTypeChecker = require('createStrictShapeTypeChecker'); var deepFreezeAndThrowOnMutationInDev = @@ -98,7 +98,7 @@ class CameraRoll { typeof tag === 'string', 'CameraRoll.saveImageWithTag tag must be a valid string.' ); - RKCameraRollManager.saveImageWithTag( + RCTCameraRollManager.saveImageWithTag( tag, (imageTag) => { successCallback && successCallback(imageTag); @@ -140,7 +140,7 @@ class CameraRoll { callback(response); }; } - RKCameraRollManager.getPhotos(params, metaCallback, errorCallback); + RCTCameraRollManager.getPhotos(params, metaCallback, errorCallback); } } diff --git a/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js b/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js index df762c5ee..c494e031c 100644 --- a/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js +++ b/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js @@ -53,7 +53,7 @@ var ActivityIndicatorIOS = React.createClass({ render: function() { var style = styles.sizeSmall; - var NativeConstants = NativeModules.RKUIManager.UIActivityIndicatorView.Constants; + var NativeConstants = NativeModules.RCTUIManager.UIActivityIndicatorView.Constants; var activityIndicatorViewStyle = NativeConstants.StyleWhite; if (this.props.size === 'large') { style = styles.sizeLarge; diff --git a/Libraries/Components/DatePicker/DatePickerIOS.ios.js b/Libraries/Components/DatePicker/DatePickerIOS.ios.js index b4a6d5bb1..c45672d65 100644 --- a/Libraries/Components/DatePicker/DatePickerIOS.ios.js +++ b/Libraries/Components/DatePicker/DatePickerIOS.ios.js @@ -3,7 +3,7 @@ * * @providesModule DatePickerIOS * - * This is a controlled component version of RKDatePickerIOS + * This is a controlled component version of RCTDatePickerIOS */ 'use strict'; @@ -11,7 +11,7 @@ var NativeMethodsMixin = require('NativeMethodsMixin'); var PropTypes = require('ReactPropTypes'); var React = require('React'); var ReactIOSViewAttributes = require('ReactIOSViewAttributes'); -var RKDatePickerIOSConsts = require('NativeModules').RKUIManager.RCTDatePicker.Constants; +var RCTDatePickerIOSConsts = require('NativeModules').RCTUIManager.RCTDatePicker.Constants; var StyleSheet = require('StyleSheet'); var View = require('View'); @@ -65,7 +65,7 @@ var DatePickerIOS = React.createClass({ * * Valid modes on iOS are: 'date', 'time', 'datetime'. */ - mode: PropTypes.oneOf(Object.keys(RKDatePickerIOSConsts.DatePickerModes)), + mode: PropTypes.oneOf(Object.keys(RCTDatePickerIOSConsts.DatePickerModes)), /** * The interval at which minutes can be selected. @@ -111,7 +111,7 @@ var DatePickerIOS = React.createClass({ var props = this.props; return ( - + ); }, }); @@ -70,12 +70,12 @@ var NavigatorTransitionerIOS = React.createClass({ /** * Think of `` as simply a component that renders an - * `RKNavigator`, and moves the `RKNavigator`'s `requestedTopOfStack` pointer - * forward and backward. The `RKNavigator` interprets changes in + * `RCTNavigator`, and moves the `RCTNavigator`'s `requestedTopOfStack` pointer + * forward and backward. The `RCTNavigator` interprets changes in * `requestedTopOfStack` to be pushes and pops of children that are rendered. * `` always ensures that whenever the `requestedTopOfStack` * pointer is moved, that we've also rendered enough children so that the - * `RKNavigator` can carry out the push/pop with those children. + * `RCTNavigator` can carry out the push/pop with those children. * `` also removes children that will no longer be needed * (after the pop of a child has been fully completed/animated out). */ @@ -496,7 +496,7 @@ var NavigatorIOS = React.createClass({ return ( - - + ); }, diff --git a/Libraries/Components/ScrollResponder.js b/Libraries/Components/ScrollResponder.js index 4221722bd..3bec89bef 100644 --- a/Libraries/Components/ScrollResponder.js +++ b/Libraries/Components/ScrollResponder.js @@ -11,9 +11,9 @@ var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); var Subscribable = require('Subscribable'); var TextInputState = require('TextInputState'); -var RKUIManager = NativeModules.RKUIManager; -var RKUIManagerDeprecated = NativeModulesDeprecated.RKUIManager; -var RKScrollViewConsts = RKUIManager.RCTScrollView.Constants; +var RCTUIManager = NativeModules.RCTUIManager; +var RCTUIManagerDeprecated = NativeModulesDeprecated.RCTUIManager; +var RCTScrollViewConsts = RCTUIManager.RCTScrollView.Constants; var warning = require('warning'); @@ -99,7 +99,7 @@ var IS_ANIMATING_TOUCH_START_THRESHOLD_MS = 16; var ScrollResponderMixin = { mixins: [Subscribable.Mixin], - statics: RKScrollViewConsts, + statics: RCTScrollViewConsts, scrollResponderMixinGetInitialState: function() { return { isTouching: false, @@ -336,7 +336,7 @@ var ScrollResponderMixin = { * can also be used to quickly scroll to any element we want to focus */ scrollResponderScrollTo: function(offsetX, offsetY) { - RKUIManagerDeprecated.scrollTo(this.getNodeHandle(), offsetX, offsetY); + RCTUIManagerDeprecated.scrollTo(this.getNodeHandle(), offsetX, offsetY); }, /** @@ -344,7 +344,7 @@ var ScrollResponderMixin = { * @param {object} rect Should have shape {x, y, w, h} */ scrollResponderZoomTo: function(rect) { - RKUIManagerDeprecated.zoomToRect(this.getNodeHandle(), rect); + RCTUIManagerDeprecated.zoomToRect(this.getNodeHandle(), rect); }, /** @@ -354,7 +354,7 @@ var ScrollResponderMixin = { */ scrollResponderScrollNativeHandleToKeyboard: function(nodeHandle, additionalOffset) { this.additionalScrollOffset = additionalOffset || 0; - RKUIManager.measureLayout( + RCTUIManager.measureLayout( nodeHandle, this.getNodeHandle(), this.scrollResponderTextInputFocusError, diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index 4edfeda81..d0630b82d 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -8,12 +8,12 @@ var EdgeInsetsPropType = require('EdgeInsetsPropType'); var Platform = require('Platform'); var PointPropType = require('PointPropType'); -var RCTScrollView = require('NativeModules').RKUIManager.RCTScrollView; +var RCTScrollView = require('NativeModules').RCTUIManager.RCTScrollView; var RCTScrollViewConsts = RCTScrollView.Constants; var React = require('React'); var ReactIOSTagHandles = require('ReactIOSTagHandles'); var ReactIOSViewAttributes = require('ReactIOSViewAttributes'); -var RKUIManager = require('NativeModulesDeprecated').RKUIManager; +var RCTUIManager = require('NativeModulesDeprecated').RCTUIManager; var ScrollResponder = require('ScrollResponder'); var StyleSheet = require('StyleSheet'); var StyleSheetPropType = require('StyleSheetPropType'); @@ -182,7 +182,7 @@ var ScrollView = React.createClass({ }, scrollTo: function(destY, destX) { - RKUIManager.scrollTo( + RCTUIManager.scrollTo( this.getNodeHandle(), destX || 0, destY || 0 diff --git a/Libraries/Components/Slider/Slider.js b/Libraries/Components/Slider/Slider.js index 80f631c45..a0be43066 100644 --- a/Libraries/Components/Slider/Slider.js +++ b/Libraries/Components/Slider/Slider.js @@ -60,7 +60,7 @@ var Slider = React.createClass({ render: function() { return ( - resp.network_reachability, - * RKReachability.getCurrentReachability + * RCTReachability.getCurrentReachability * ); * * var myComponent = React.createClass({ diff --git a/Libraries/Components/SwitchIOS/SwitchIOS.ios.js b/Libraries/Components/SwitchIOS/SwitchIOS.ios.js index 391b4da3a..15c0af5aa 100644 --- a/Libraries/Components/SwitchIOS/SwitchIOS.ios.js +++ b/Libraries/Components/SwitchIOS/SwitchIOS.ios.js @@ -3,7 +3,7 @@ * * @providesModule SwitchIOS * - * This is a controlled component version of RKSwitch. + * This is a controlled component version of RCTSwitch. */ 'use strict'; @@ -80,7 +80,7 @@ var SwitchIOS = React.createClass({ render: function() { return ( - + {this.props.children} - + ); } }); @@ -31,6 +31,6 @@ var config = { validAttributes: ReactIOSViewAttributes.UIView, uiViewClassName: 'RCTTabBar', }; -var RKTabBar = createReactIOSNativeComponentClass(config); +var RCTTabBar = createReactIOSNativeComponentClass(config); module.exports = TabBarIOS; diff --git a/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js b/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js index 763be7438..70333d54e 100644 --- a/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js +++ b/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js @@ -58,7 +58,7 @@ var TabBarItemIOS = React.createClass({ } return ( - {tabContents} - + ); } }); @@ -80,7 +80,7 @@ var styles = StyleSheet.create({ } }); -var RKTabBarItem = createReactIOSNativeComponentClass({ +var RCTTabBarItem = createReactIOSNativeComponentClass({ validAttributes: merge(ReactIOSViewAttributes.UIView, { title: true, icon: true, diff --git a/Libraries/Components/TextInput/TextInput.ios.js b/Libraries/Components/TextInput/TextInput.ios.js index e04ed88ee..21ad49f53 100644 --- a/Libraries/Components/TextInput/TextInput.ios.js +++ b/Libraries/Components/TextInput/TextInput.ios.js @@ -8,7 +8,7 @@ var DocumentSelectionState = require('DocumentSelectionState'); var EventEmitter = require('EventEmitter'); var NativeMethodsMixin = require('NativeMethodsMixin'); -var RKUIManager = require('NativeModules').RKUIManager; +var RCTUIManager = require('NativeModules').RCTUIManager; var PropTypes = require('ReactPropTypes'); var React = require('React'); var ReactChildren = require('ReactChildren'); @@ -25,10 +25,10 @@ var getObjectValues = require('getObjectValues'); var invariant = require('invariant'); var merge = require('merge'); -var autoCapitalizeConsts = RKUIManager.UIText.AutocapitalizationType; -var clearButtonModeConsts = RKUIManager.UITextField.clearButtonMode; +var autoCapitalizeConsts = RCTUIManager.UIText.AutocapitalizationType; +var clearButtonModeConsts = RCTUIManager.UITextField.clearButtonMode; -var RKTextViewAttributes = merge(ReactIOSViewAttributes.UIView, { +var RCTTextViewAttributes = merge(ReactIOSViewAttributes.UIView, { autoCorrect: true, autoCapitalize: true, color: true, @@ -42,7 +42,7 @@ var RKTextViewAttributes = merge(ReactIOSViewAttributes.UIView, { text: true, }); -var RKTextFieldAttributes = merge(RKTextViewAttributes, { +var RCTTextFieldAttributes = merge(RCTTextViewAttributes, { caretHidden: true, enabled: true, clearButtonMode: true, @@ -198,7 +198,7 @@ var TextInput = React.createClass({ viewConfig: { uiViewClassName: 'RCTTextField', - validAttributes: RKTextFieldAttributes, + validAttributes: RCTTextFieldAttributes, }, isFocused: function() { @@ -309,7 +309,7 @@ var TextInput = React.createClass({ } } textContainer = - ; + return ; }, }); -var RKView = createReactIOSNativeComponentClass({ - validAttributes: ReactIOSViewAttributes.RKView, +var RCTView = createReactIOSNativeComponentClass({ + validAttributes: ReactIOSViewAttributes.RCTView, uiViewClassName: 'RCTView', }); -RKView.propTypes = View.propTypes; +RCTView.propTypes = View.propTypes; -var ViewToExport = RKView; +var ViewToExport = RCTView; if (__DEV__) { ViewToExport = View; } diff --git a/Libraries/Components/WebView/WebView.android.js b/Libraries/Components/WebView/WebView.android.js index 8190258ae..d153ebe92 100644 --- a/Libraries/Components/WebView/WebView.android.js +++ b/Libraries/Components/WebView/WebView.android.js @@ -16,9 +16,9 @@ var keyMirror = require('keyMirror'); var merge = require('merge'); var PropTypes = React.PropTypes; -var RKUIManager = require('NativeModules').RKUIManager; +var RCTUIManager = require('NativeModules').RCTUIManager; -var RK_WEBVIEW_REF = 'webview'; +var RCT_WEBVIEW_REF = 'webview'; var WebViewState = keyMirror({ IDLE: null, @@ -81,7 +81,7 @@ var WebView = React.createClass({ var webView = { var prettyStack = errorToString(e, map); - RKExceptionsManager.updateExceptionMessage(e.message, prettyStack); + RCTExceptionsManager.updateExceptionMessage(e.message, prettyStack); }) .then(null, error => { GLOBAL.console.error('#CLOWNTOWN (error while displaying error): ' + error.message); @@ -95,7 +95,7 @@ function setupRedBoxErrorHandler() { /** * Sets up a set of window environment wrappers that ensure that the * BatchedBridge is flushed after each tick. In both the case of the - * `UIWebView` based `RKJavaScriptCaller` and `RKContextCaller`, we + * `UIWebView` based `RCTJavaScriptCaller` and `RCTContextCaller`, we * implement our own custom timing bridge that should be immune to * unexplainably dropped timing signals. */ @@ -115,7 +115,7 @@ function setupTimers() { } function setupAlert() { - var RKAlertManager = require('RKAlertManager'); + var RCTAlertManager = require('RCTAlertManager'); if (!GLOBAL.alert) { GLOBAL.alert = function(text) { var alertOpts = { @@ -123,7 +123,7 @@ function setupAlert() { message: '' + text, buttons: [{'cancel': 'Okay'}], }; - RKAlertManager.alertWithArgs(alertOpts, null); + RCTAlertManager.alertWithArgs(alertOpts, null); }; } } diff --git a/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimers.js b/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimers.js index 13297ef00..1b25e00c1 100644 --- a/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimers.js +++ b/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimers.js @@ -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 RKTiming = require('NativeModules').RKTiming; +var RCTTiming = require('NativeModules').RCTTiming; var JSTimersExecution = require('JSTimersExecution'); /** @@ -43,7 +43,7 @@ var JSTimers = { return func.apply(undefined, args); }; JSTimersExecution.types[freeIndex] = JSTimersExecution.Type.setTimeout; - RKTiming.createTimer(newID, duration, Date.now(), /** recurring */ false); + RCTTiming.createTimer(newID, duration, Date.now(), /** recurring */ false); return newID; }, @@ -60,7 +60,7 @@ var JSTimers = { return func.apply(undefined, args); }; JSTimersExecution.types[freeIndex] = JSTimersExecution.Type.setInterval; - RKTiming.createTimer(newID, duration, Date.now(), /** recurring */ true); + RCTTiming.createTimer(newID, duration, Date.now(), /** recurring */ true); return newID; }, @@ -90,7 +90,7 @@ var JSTimers = { JSTimersExecution.timerIDs[freeIndex] = newID; JSTimersExecution.callbacks[freeIndex] = func; JSTimersExecution.types[freeIndex] = JSTimersExecution.Type.requestAnimationFrame; - RKTiming.createTimer(newID, 0, Date.now(), /** recurring */ false); + RCTTiming.createTimer(newID, 0, Date.now(), /** recurring */ false); return newID; }, @@ -126,7 +126,7 @@ var JSTimers = { if (index !== -1) { JSTimersExecution._clearIndex(index); if (JSTimersExecution.types[index] !== JSTimersExecution.Type.setImmediate) { - RKTiming.deleteTimer(timerID); + RCTTiming.deleteTimer(timerID); } } }, diff --git a/Libraries/Network/NetInfo.js b/Libraries/Network/NetInfo.js index 59c29cb07..671b064a2 100644 --- a/Libraries/Network/NetInfo.js +++ b/Libraries/Network/NetInfo.js @@ -8,7 +8,7 @@ var NativeModules = require('NativeModules'); var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var RKReachability = NativeModules.RKReachability; +var RCTReachability = NativeModules.RCTReachability; var DEVICE_REACHABILITY_EVENT = 'reachabilityDidChange'; @@ -49,7 +49,7 @@ type ChangeEventName = $Enum<{ var NetInfo = {}; -if (RKReachability) { +if (RCTReachability) { var _reachabilitySubscriptions = {}; NetInfo.reachabilityIOS = { @@ -78,7 +78,7 @@ if (RKReachability) { fetch: function(): Promise { return new Promise((resolve, reject) => { - RKReachability.getCurrentReachability( + RCTReachability.getCurrentReachability( (resp) => { resolve(resp.network_reachability); }, diff --git a/Libraries/Network/XMLHttpRequest.ios.js b/Libraries/Network/XMLHttpRequest.ios.js index 042cbe4b9..685bd1ff2 100644 --- a/Libraries/Network/XMLHttpRequest.ios.js +++ b/Libraries/Network/XMLHttpRequest.ios.js @@ -6,7 +6,7 @@ */ 'use strict'; -var RKDataManager = require('NativeModulesDeprecated').RKDataManager; +var RCTDataManager = require('NativeModulesDeprecated').RCTDataManager; var crc32 = require('crc32'); @@ -91,7 +91,7 @@ class XMLHttpRequest { } this._sent = true; - RKDataManager.queryData( + RCTDataManager.queryData( 'http', JSON.stringify({ method: this._method, diff --git a/Libraries/Picker/PickerIOS.android.js b/Libraries/Picker/PickerIOS.android.js index 72cc87a75..51103157a 100644 --- a/Libraries/Picker/PickerIOS.android.js +++ b/Libraries/Picker/PickerIOS.android.js @@ -3,7 +3,7 @@ * * @providesModule PickerIOS * - * This is a controlled component version of RKPickerIOS + * This is a controlled component version of RCTPickerIOS */ 'use strict'; diff --git a/Libraries/Picker/PickerIOS.ios.js b/Libraries/Picker/PickerIOS.ios.js index 04559a700..c2d1c2241 100644 --- a/Libraries/Picker/PickerIOS.ios.js +++ b/Libraries/Picker/PickerIOS.ios.js @@ -3,7 +3,7 @@ * * @providesModule PickerIOS * - * This is a controlled component version of RKPickerIOS + * This is a controlled component version of RCTPickerIOS */ 'use strict'; @@ -11,7 +11,7 @@ var NativeMethodsMixin = require('NativeMethodsMixin'); var React = require('React'); var ReactChildren = require('ReactChildren'); var ReactIOSViewAttributes = require('ReactIOSViewAttributes'); -var RKPickerIOSConsts = require('NativeModules').RKUIManager.RCTPicker.Constants; +var RCTPickerIOSConsts = require('NativeModules').RCTUIManager.RCTPicker.Constants; var StyleSheet = require('StyleSheet'); var View = require('View'); @@ -37,7 +37,7 @@ var PickerIOS = React.createClass({ this.setState(this._stateFromProps(nextProps)); }, - // Translate PickerIOS prop and children into stuff that RKPickerIOS understands. + // Translate PickerIOS prop and children into stuff that RCTPickerIOS understands. _stateFromProps: function(props) { var selectedIndex = 0; var items = []; @@ -53,7 +53,7 @@ var PickerIOS = React.createClass({ render: function() { return ( - void ): void { - RKAsyncStorage.multiGet([key], function(errors, result) { + RCTAsyncStorage.multiGet([key], function(errors, result) { // Unpack result to get value from [[key,value]] var value = (result && result[0] && result[0][1]) ? result[0][1] : null; callback((errors && convertError(errors[0])) || null, value); @@ -49,7 +49,7 @@ var AsyncStorage = { value: string, callback: ?(error: ?Error) => void ): void { - RKAsyncStorage.multiSet([[key,value]], function(errors) { + RCTAsyncStorage.multiSet([[key,value]], function(errors) { callback && callback((errors && convertError(errors[0])) || null); }); }, @@ -58,7 +58,7 @@ var AsyncStorage = { key: string, callback: ?(error: ?Error) => void ): void { - RKAsyncStorage.multiRemove([key], function(errors) { + RCTAsyncStorage.multiRemove([key], function(errors) { callback && callback((errors && convertError(errors[0])) || null); }); }, @@ -73,7 +73,7 @@ var AsyncStorage = { value: string, callback: ?(error: ?Error) => void ): void { - RKAsyncStorage.multiMerge([[key,value]], function(errors) { + RCTAsyncStorage.multiMerge([[key,value]], function(errors) { callback && callback((errors && convertError(errors[0])) || null); }); }, @@ -84,7 +84,7 @@ var AsyncStorage = { * own keys instead. */ clear: function(callback: ?(error: ?Error) => void) { - RKAsyncStorage.clear(function(error) { + RCTAsyncStorage.clear(function(error) { callback && callback(convertError(error)); }); }, @@ -93,7 +93,7 @@ var AsyncStorage = { * Gets *all* keys known to the system, for all callers, libraries, etc. */ getAllKeys: function(callback: (error: ?Error) => void) { - RKAsyncStorage.getAllKeys(function(error, keys) { + RCTAsyncStorage.getAllKeys(function(error, keys) { callback(convertError(error), keys); }); }, @@ -118,7 +118,7 @@ var AsyncStorage = { keys: Array, callback: (errors: ?Array, result: ?Array>) => void ): void { - RKAsyncStorage.multiGet(keys, function(errors, result) { + RCTAsyncStorage.multiGet(keys, function(errors, result) { callback( (errors && errors.map((error) => convertError(error))) || null, result @@ -136,7 +136,7 @@ var AsyncStorage = { keyValuePairs: Array>, callback: ?(errors: ?Array) => void ): void { - RKAsyncStorage.multiSet(keyValuePairs, function(errors) { + RCTAsyncStorage.multiSet(keyValuePairs, function(errors) { callback && callback( (errors && errors.map((error) => convertError(error))) || null ); @@ -150,7 +150,7 @@ var AsyncStorage = { keys: Array, callback: ?(errors: ?Array) => void ): void { - RKAsyncStorage.multiRemove(keys, function(errors) { + RCTAsyncStorage.multiRemove(keys, function(errors) { callback && callback( (errors && errors.map((error) => convertError(error))) || null ); @@ -167,7 +167,7 @@ var AsyncStorage = { keyValuePairs: Array>, callback: ?(errors: ?Array) => void ): void { - RKAsyncStorage.multiMerge(keyValuePairs, function(errors) { + RCTAsyncStorage.multiMerge(keyValuePairs, function(errors) { callback && callback( (errors && errors.map((error) => convertError(error))) || null ); @@ -176,7 +176,7 @@ var AsyncStorage = { }; // Not all native implementations support merge. -if (!RKAsyncStorage.multiMerge) { +if (!RCTAsyncStorage.multiMerge) { delete AsyncStorage.mergeItem; delete AsyncStorage.multiMerge; } diff --git a/Libraries/Text/Text.js b/Libraries/Text/Text.js index 6171ecbde..5d4efcd5c 100644 --- a/Libraries/Text/Text.js +++ b/Libraries/Text/Text.js @@ -184,12 +184,12 @@ var Text = React.createClass({ props.onResponderMove = this.handleResponderMove; props.onResponderRelease = this.handleResponderRelease; props.onResponderTerminate = this.handleResponderTerminate; - return ; + return ; }, }); var PRESS_RECT_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; -var RKText = createReactIOSNativeComponentClass(viewConfig); +var RCTText = createReactIOSNativeComponentClass(viewConfig); module.exports = Text; diff --git a/Libraries/Utilities/Dimensions.js b/Libraries/Utilities/Dimensions.js index 97e8d2d01..d33515799 100644 --- a/Libraries/Utilities/Dimensions.js +++ b/Libraries/Utilities/Dimensions.js @@ -9,7 +9,7 @@ var NativeModules = require('NativeModules'); var invariant = require('invariant'); -var dimensions = NativeModules.RKUIManager.Dimensions; +var dimensions = NativeModules.RCTUIManager.Dimensions; class Dimensions { /** diff --git a/Libraries/Utilities/nativeModulePrefixDuplicator.js b/Libraries/Utilities/nativeModulePrefixDuplicator.js new file mode 100644 index 000000000..fb2951612 --- /dev/null +++ b/Libraries/Utilities/nativeModulePrefixDuplicator.js @@ -0,0 +1,25 @@ +/** + * 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;