mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Updates from Tue 17 Mar
- [ReactNative] Remove pushNotification prop from renderApplication | Eric Vicenti - [react_native] Stub VibrationIOS on Android | Andy Street - [ReactNative] Simplify and test interpolators | Christopher Chedeau - [ReactNative] Increase timeout for obj-c tests | Christopher Chedeau - [ReactNative] Updated RKText to new UIManager system | Nick Lockwood - [ReactNative] Unforked RCTShadowView, moved RKTextView into FBReactKitTextModule | Nick Lockwood - [ReactKit] Remove NativeModulesDeprecated | Spencer Ahrens - [ReactNative] Allow single callbacks in NativeModules | Spencer Ahrens - [ReactNative] s/RK/RCT in OSS | Spencer Ahrens - [ReactNative] Cleanup StyleSheet API | Christopher Chedeau - [RCTVibration] Basic Vibration API | Christopher Chedeau - [React Native] Prevent crash in redbox code with two thrown errors | Ben Alpert - [ReactNative] unbreak Android | Andrew Rasmussen
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
/**
|
||||
* Copyright 2004-present Facebook. All Rights Reserved.
|
||||
*
|
||||
* @providesModule NativeModulesDeprecated
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var RemoteModulesDeprecated = 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];
|
||||
});
|
||||
|
||||
module.exports = RemoteModulesDeprecated;
|
||||
@@ -5,8 +5,8 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var RKPOPAnimationManager = require('NativeModulesDeprecated').RKPOPAnimationManager;
|
||||
if (!RKPOPAnimationManager) {
|
||||
var RCTPOPAnimationManager = require('NativeModules').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'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Copyright 2004-present Facebook. All Rights Reserved.
|
||||
*
|
||||
* @providesModule RCTAlertManager
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var { RCTAlertManager } = require('NativeModules');
|
||||
|
||||
module.exports = RCTAlertManager;
|
||||
@@ -1,10 +0,0 @@
|
||||
/**
|
||||
* Copyright 2004-present Facebook. All Rights Reserved.
|
||||
*
|
||||
* @providesModule RKAlertManager
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var RKAlertManager = require('NativeModulesDeprecated').RKAlertManager;
|
||||
|
||||
module.exports = RKAlertManager;
|
||||
@@ -22,33 +22,6 @@ var MethodTypes = keyMirror({
|
||||
*/
|
||||
var BatchedBridgeFactory = {
|
||||
MethodTypes: MethodTypes,
|
||||
/**
|
||||
* @deprecated: Remove callsites and delete this method.
|
||||
*
|
||||
* @param {MessageQueue} messageQueue Message queue that has been created with
|
||||
* the `moduleConfig` (among others perhaps).
|
||||
* @param {object} moduleConfig Configuration of module names/method
|
||||
* names to callback types.
|
||||
* @return {object} Remote representation of configured module.
|
||||
*/
|
||||
_createDeprecatedBridgedModule: function(messageQueue, moduleConfig, moduleName) {
|
||||
var remoteModule = mapObject(moduleConfig.methods, function(methodConfig, memberName) {
|
||||
return methodConfig.type === MethodTypes.local ? null : function() {
|
||||
var lastArg = arguments.length ? arguments[arguments.length - 1] : null;
|
||||
var hasCB =
|
||||
typeof lastArg == 'function';
|
||||
var args = slice.call(arguments, 0, arguments.length - (hasCB ? 1 : 0));
|
||||
var cb = hasCB ? lastArg : null;
|
||||
return messageQueue.callDeprecated(moduleName, memberName, args, cb);
|
||||
};
|
||||
});
|
||||
for (var constName in moduleConfig.constants) {
|
||||
warning(!remoteModule[constName], 'saw constant and method named %s', constName);
|
||||
remoteModule[constName] = moduleConfig.constants[constName];
|
||||
}
|
||||
return remoteModule;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {MessageQueue} messageQueue Message queue that has been created with
|
||||
* the `moduleConfig` (among others perhaps).
|
||||
@@ -63,14 +36,14 @@ var BatchedBridgeFactory = {
|
||||
var secondLastArg = arguments.length > 1 ? arguments[arguments.length - 2] : null;
|
||||
var hasSuccCB = typeof lastArg === 'function';
|
||||
var hasErrorCB = typeof secondLastArg === 'function';
|
||||
var hasCBs = hasSuccCB;
|
||||
invariant(
|
||||
(hasSuccCB && hasErrorCB) || (!hasSuccCB && !hasErrorCB),
|
||||
'You must supply error callbacks and success callbacks or neither'
|
||||
hasErrorCB && invariant(
|
||||
hasSuccCB,
|
||||
'Cannot have a non-function arg after a function arg.'
|
||||
);
|
||||
var args = slice.call(arguments, 0, arguments.length - (hasCBs ? 2 : 0));
|
||||
var onSucc = hasCBs ? lastArg : null;
|
||||
var onFail = hasCBs ? secondLastArg : null;
|
||||
var numCBs = (hasSuccCB ? 1 : 0) + (hasErrorCB ? 1 : 0);
|
||||
var args = slice.call(arguments, 0, arguments.length - numCBs);
|
||||
var onSucc = hasSuccCB ? lastArg : null;
|
||||
var onFail = hasErrorCB ? secondLastArg : null;
|
||||
return messageQueue.call(moduleName, memberName, args, onFail, onSucc);
|
||||
};
|
||||
});
|
||||
@@ -92,8 +65,6 @@ var BatchedBridgeFactory = {
|
||||
invokeCallbackAndReturnFlushedQueue:
|
||||
messageQueue.invokeCallbackAndReturnFlushedQueue.bind(messageQueue),
|
||||
flushedQueue: messageQueue.flushedQueue.bind(messageQueue),
|
||||
// These deprecated modules do not accept an error callback.
|
||||
RemoteModulesDeprecated: mapObject(modulesConfig, this._createDeprecatedBridgedModule.bind(this, messageQueue)),
|
||||
RemoteModules: mapObject(modulesConfig, this._createBridgedModule.bind(this, messageQueue)),
|
||||
setLoggingEnabled: messageQueue.setLoggingEnabled.bind(messageQueue),
|
||||
getLoggedOutgoingItems: messageQueue.getLoggedOutgoingItems.bind(messageQueue),
|
||||
|
||||
Reference in New Issue
Block a user