Updates from Fri Feb 13

- [ReactNative] Fix throttle warning and warn in callback instead of render | Christopher Chedeau
- [react-packager][streamline oss] Remove react-page-middleware | Amjad Masad
- [ReactNative] Turn on perf measurement around a group feed load | Jing Chen
- Implemented Layout animations | Nick Lockwood
- [ReactNative] Revert D1815137 - avoid dropping touch start on missing target | Eric Vicenti
- Moved RKPOPAnimationManager into FBReactKitComponents | Nick Lockwood
- Extracted RKAnimationManager | Nick Lockwood
This commit is contained in:
Spencer Ahrens
2015-02-18 17:39:09 -08:00
parent 472c287cd3
commit ef842c285b
24 changed files with 1344 additions and 237 deletions

View File

@@ -0,0 +1,11 @@
// Copyright 2004-present Facebook. All Rights Reserved.
#import <Foundation/Foundation.h>
typedef NS_ENUM(NSInteger, RCTAnimationType) {
RCTAnimationTypeSpring = 0,
RCTAnimationTypeLinear,
RCTAnimationTypeEaseIn,
RCTAnimationTypeEaseOut,
RCTAnimationTypeEaseInEaseOut,
};

View File

@@ -240,15 +240,15 @@ static NSDictionary *RCTRemoteModulesConfig()
NSMutableDictionary *methods = [NSMutableDictionary dictionaryWithCapacity:rawMethods.count];
[rawMethods enumerateObjectsUsingBlock:^(RCTModuleMethod *method, NSUInteger methodID, BOOL *stop) {
methods[method.JSMethodName] = @{
@"methodID": @(methodID),
@"type": @"remote",
};
@"methodID": @(methodID),
@"type": @"remote",
};
}];
NSDictionary *module = @{
@"moduleID": @(remoteModules.count),
@"methods": methods
};
@"moduleID": @(remoteModules.count),
@"methods": methods
};
Class cls = RCTBridgeModuleClasses()[moduleName];
if (RCTClassOverridesClassMethod(cls, @selector(constantsToExport))) {
@@ -302,10 +302,10 @@ static NSDictionary *RCTLocalModulesConfig()
// Add globally used methods
[JSMethods addObjectsFromArray:@[
@"Bundler.runApplication",
@"RCTEventEmitter.receiveEvent",
@"RCTEventEmitter.receiveTouches",
]];
@"Bundler.runApplication",
@"RCTEventEmitter.receiveEvent",
@"RCTEventEmitter.receiveTouches",
]];
// NOTE: these methods are currently unused in the OSS project
// @"Dimensions.set",
@@ -331,9 +331,9 @@ static NSDictionary *RCTLocalModulesConfig()
NSDictionary *module = localModules[moduleName];
if (!module) {
module = @{
@"moduleID": @(localModules.count),
@"methods": [[NSMutableDictionary alloc] init]
};
@"moduleID": @(localModules.count),
@"methods": [[NSMutableDictionary alloc] init]
};
localModules[moduleName] = module;
}
@@ -342,9 +342,9 @@ static NSDictionary *RCTLocalModulesConfig()
NSMutableDictionary *methods = module[@"methods"];
if (!methods[methodName]) {
methods[methodName] = @{
@"methodID": @(methods.count),
@"type": @"local"
};
@"methodID": @(methods.count),
@"type": @"local"
};
}
// Add module and method lookup
@@ -386,9 +386,9 @@ static id<RCTJavaScriptExecutor> _latestJSExecutor;
// Inject module data into JS context
NSString *configJSON = RCTJSONStringify(@{
@"remoteModuleConfig": RCTRemoteModulesConfig(),
@"localModulesConfig": RCTLocalModulesConfig()
}, NULL);
@"remoteModuleConfig": RCTRemoteModulesConfig(),
@"localModulesConfig": RCTLocalModulesConfig()
}, NULL);
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
[_javaScriptExecutor injectJSONText:configJSON asGlobalObjectNamed:@"__fbBatchedBridgeConfig" callback:^(id err) {
dispatch_semaphore_signal(semaphore);

View File

@@ -5,6 +5,7 @@
#import "Layout.h"
#import "RCTPointerEvents.h"
#import "RCTAnimationType.h"
/**
* This class provides a collection of conversion functions for mapping
@@ -64,6 +65,7 @@
+ (css_wrap_type_t)css_wrap_type_t:(id)json;
+ (RCTPointerEvents)RCTPointerEvents:(id)json;
+ (RCTAnimationType)RCTAnimationType:(id)json;
@end

View File

@@ -20,7 +20,7 @@ NSString *const RCTBoldFontWeight = @"bold";
return code; \
} \
@catch (__unused NSException *e) { \
RCTLogMustFix(@"JSON value '%@' of type '%@' cannot be converted to '%s'", \
RCTLogError(@"JSON value '%@' of type '%@' cannot be converted to '%s'", \
json, [json class], #type); \
json = nil; \
return code; \
@@ -45,15 +45,15 @@ RCT_CONVERTER_CUSTOM(type, name, [json getter])
if ([[mapping allValues] containsObject:json] || [json getter] == default) { \
return [json getter]; \
} \
RCTLogMustFix(@"Invalid %s '%@'. should be one of: %@", #type, json, [mapping allValues]); \
RCTLogError(@"Invalid %s '%@'. should be one of: %@", #type, json, [mapping allValues]); \
return default; \
} \
if (![json isKindOfClass:[NSString class]]) { \
RCTLogMustFix(@"Expected NSNumber or NSString for %s, received %@: %@", #type, [json class], json); \
RCTLogError(@"Expected NSNumber or NSString for %s, received %@: %@", #type, [json class], json); \
} \
id value = mapping[json]; \
if(!value && [json description].length > 0) { \
RCTLogMustFix(@"Invalid %s '%@'. should be one of: %@", #type, json, [mapping allKeys]); \
RCTLogError(@"Invalid %s '%@'. should be one of: %@", #type, json, [mapping allKeys]); \
} \
return value ? [value getter] : default; \
}
@@ -72,7 +72,7 @@ RCT_CONVERTER_CUSTOM(type, name, [json getter])
type result; \
if ([json isKindOfClass:[NSArray class]]) { \
if ([json count] != count) { \
RCTLogMustFix(@"Expected array with count %zd, but count is %zd: %@", count, [json count], json); \
RCTLogError(@"Expected array with count %zd, but count is %zd: %@", count, [json count], json); \
} else { \
for (NSUInteger i = 0; i < count; i++) { \
((CGFloat *)&result)[i] = [json[i] doubleValue]; \
@@ -80,7 +80,7 @@ RCT_CONVERTER_CUSTOM(type, name, [json getter])
} \
} else { \
if (![json isKindOfClass:[NSDictionary class]]) { \
RCTLogMustFix(@"Expected NSArray or NSDictionary for %s, received %@: %@", #type, [json class], json); \
RCTLogError(@"Expected NSArray or NSDictionary for %s, received %@: %@", #type, [json class], json); \
} else { \
for (NSUInteger i = 0; i < count; i++) { \
((CGFloat *)&result)[i] = [json[fields[i]] doubleValue]; \
@@ -90,7 +90,7 @@ RCT_CONVERTER_CUSTOM(type, name, [json getter])
return result; \
} \
@catch (__unused NSException *e) { \
RCTLogMustFix(@"JSON value '%@' cannot be converted to '%s'", json, #type); \
RCTLogError(@"JSON value '%@' cannot be converted to '%s'", json, #type); \
type result; \
return result; \
} \
@@ -111,7 +111,7 @@ RCT_CONVERTER_CUSTOM(NSUInteger, NSUInteger, [json unsignedIntegerValue])
+ (NSURL *)NSURL:(id)json
{
if (![json isKindOfClass:[NSString class]]) {
RCTLogMustFix(@"Expected NSString for NSURL, received %@: %@", [json class], json);
RCTLogError(@"Expected NSString for NSURL, received %@: %@", [json class], json);
return nil;
}
@@ -376,10 +376,10 @@ RCT_STRUCT_CONVERTER(CGAffineTransform, (@[@"a", @"b", @"c", @"d", @"tx", @"ty"]
} else if ([colorString hasPrefix:@"rgb("]) {
sscanf([colorString UTF8String], "rgb(%zd,%zd,%zd)", &red, &green, &blue);
} else {
RCTLogMustFix(@"Unrecognized color format '%@', must be one of #hex|rgba|rgb", colorString);
RCTLogError(@"Unrecognized color format '%@', must be one of #hex|rgba|rgb", colorString);
}
if (red == -1 || green == -1 || blue == -1 || alpha > 1.0 || alpha < 0.0) {
RCTLogMustFix(@"Invalid color string '%@'", colorString);
RCTLogError(@"Invalid color string '%@'", colorString);
} else {
color = [UIColor colorWithRed:red / 255.0 green:green / 255.0 blue:blue / 255.0 alpha:alpha];
}
@@ -388,7 +388,7 @@ RCT_STRUCT_CONVERTER(CGAffineTransform, (@[@"a", @"b", @"c", @"d", @"tx", @"ty"]
if ([json count] < 3 || [json count] > 4) {
RCTLogMustFix(@"Expected array with count 3 or 4, but count is %zd: %@", [json count], json);
RCTLogError(@"Expected array with count 3 or 4, but count is %zd: %@", [json count], json);
} else {
@@ -409,7 +409,7 @@ RCT_STRUCT_CONVERTER(CGAffineTransform, (@[@"a", @"b", @"c", @"d", @"tx", @"ty"]
} else if (json && ![json isKindOfClass:[NSNull class]]) {
RCTLogMustFix(@"Expected NSArray, NSDictionary or NSString for UIColor, received %@: %@", [json class], json);
RCTLogError(@"Expected NSArray, NSDictionary or NSString for UIColor, received %@: %@", [json class], json);
}
// Default color
@@ -509,7 +509,7 @@ RCT_STRUCT_CONVERTER(CGAffineTransform, (@[@"a", @"b", @"c", @"d", @"tx", @"ty"]
+ (UIImage *)UIImage:(id)json
{
if (![json isKindOfClass:[NSString class]]) {
RCTLogMustFix(@"Expected NSString for UIImage, received %@: %@", [json class], json);
RCTLogError(@"Expected NSString for UIImage, received %@: %@", [json class], json);
return nil;
}
@@ -657,6 +657,14 @@ RCT_ENUM_CONVERTER(RCTPointerEvents, (@{
@"boxnone": @(RCTPointerEventsBoxNone)
}), RCTPointerEventsUnspecified, integerValue)
RCT_ENUM_CONVERTER(RCTAnimationType, (@{
@"spring": @(RCTAnimationTypeSpring),
@"linear": @(RCTAnimationTypeLinear),
@"easeIn": @(RCTAnimationTypeEaseIn),
@"easeOut": @(RCTAnimationTypeEaseOut),
@"easeInEaseOut": @(RCTAnimationTypeEaseInEaseOut),
}), RCTAnimationTypeEaseInEaseOut, integerValue)
@end
static NSString *RCTGuessTypeEncoding(id target, NSString *key, id value, NSString *encoding)
@@ -832,6 +840,9 @@ BOOL RCTSetProperty(id target, NSString *keypath, id value)
@"extAlignment": ^(id val) {
return [RCTConvert NSTextAlignment:val];
},
@"ointerEvents": ^(id val) {
return [RCTConvert RCTPointerEvents:val];
},
};
});
for (NSString *subkey in converters) {