Removed unnecessary exportedConstants

Summary: The exportedConstants method incurrs a penalty at bridge startup time for every module that implements it. This diff removes exportedConstants from a few modules that don't really need to use it.

Reviewed By: majak

Differential Revision: D2982341

fb-gh-sync-id: be016187d7b731a073311daacfcf88a0402e1688
shipit-source-id: be016187d7b731a073311daacfcf88a0402e1688
This commit is contained in:
Nick Lockwood 2016-03-10 10:20:53 -08:00 коммит произвёл Facebook Github Bot 5
Родитель d71c05164c
Коммит 520ad05ba0
8 изменённых файлов: 47 добавлений и 96 удалений

Просмотреть файл

@ -16,8 +16,6 @@ const EdgeInsetsPropType = require('EdgeInsetsPropType');
const Image = require('Image');
const NativeMethodsMixin = require('NativeMethodsMixin');
const Platform = require('Platform');
const RCTMapConfig = require('UIManager').RCTMap;
const RCTMapConstants = RCTMapConfig && RCTMapConfig.Constants;
const React = require('React');
const StyleSheet = require('StyleSheet');
const View = require('View');
@ -310,6 +308,21 @@ const MapView = React.createClass({
active: React.PropTypes.bool,
},
statics: {
/**
* Standard iOS MapView pin color constants, to be used with the
* `annotation.tintColor` property. On iOS 8 and earlier these are the
* only supported values when using regular pins. On iOS 9 and later
* you are not obliged to use these, but they are useful for matching
* the standard iOS look and feel.
*/
PinColors: {
RED: '#ff3b30',
GREEN: '#4cd964',
PURPLE: '#c969e0',
},
},
render: function() {
let children = [], {annotations, overlays, followUserLocation} = this.props;
annotations = annotations && annotations.map((annotation: Object) => {
@ -491,20 +504,6 @@ const styles = StyleSheet.create({
},
});
/**
* Standard iOS MapView pin color constants, to be used with the
* `annotation.tintColor` property. On iOS 8 and earlier these are the
* only supported values when using regular pins. On iOS 9 and later
* you are not obliged to use these, but they are useful for matching
* the standard iOS look and feel.
*/
const PinColors = RCTMapConstants && RCTMapConstants.PinColors;
MapView.PinColors = PinColors && {
RED: PinColors.RED,
GREEN: PinColors.GREEN,
PURPLE: PinColors.PURPLE,
};
const RCTMap = requireNativeComponent('RCTMap', MapView, {
nativeOnly: {
onAnnotationDragStateChange: true,

Просмотреть файл

@ -134,8 +134,8 @@ var ScrollView = React.createClass({
* shortcuts `"normal"` and `"fast"` which match the underlying iOS settings
* for `UIScrollViewDecelerationRateNormal` and
* `UIScrollViewDecelerationRateFast` respectively.
* - Normal: 0.998 (the default)
* - Fast: 0.9
* - normal: 0.998 (the default)
* - fast: 0.99
* @platform ios
*/
decelerationRate: PropTypes.oneOfType([

Просмотреть файл

@ -10,18 +10,11 @@
*/
'use strict';
var ScrollViewConsts = require('UIManager').RCTScrollView.Constants;
function processDecelerationRate(decelerationRate) {
var ScrollViewDecelerationRateNormal = ScrollViewConsts && ScrollViewConsts.DecelerationRate.normal;
var ScrollViewDecelerationRateFast = ScrollViewConsts && ScrollViewConsts.DecelerationRate.fast;
if (typeof decelerationRate === 'string') {
if (decelerationRate === 'fast') {
return ScrollViewDecelerationRateFast;
} else if (decelerationRate === 'normal') {
return ScrollViewDecelerationRateNormal;
}
if (decelerationRate === 'normal') {
decelerationRate = 0.998;
} else if (decelerationRate === 'fast') {
decelerationRate = 0.99;
}
return decelerationRate;
}

Просмотреть файл

@ -39,16 +39,16 @@ var WebViewState = keyMirror({
ERROR: null,
});
var NavigationType = {
click: RCTWebViewManager.NavigationType.LinkClicked,
formsubmit: RCTWebViewManager.NavigationType.FormSubmitted,
backforward: RCTWebViewManager.NavigationType.BackForward,
reload: RCTWebViewManager.NavigationType.Reload,
formresubmit: RCTWebViewManager.NavigationType.FormResubmitted,
other: RCTWebViewManager.NavigationType.Other,
};
const NavigationType = keyMirror({
click: true,
formsubmit: true,
backforward: true,
reload: true,
formresubmit: true,
other: true,
});
var JSNavigationScheme = RCTWebViewManager.JSNavigationScheme;
const JSNavigationScheme = 'react-js-navigation';
type ErrorEvent = {
domain: any;
@ -179,8 +179,8 @@ var WebView = React.createClass({
* shortcuts `"normal"` and `"fast"` which match the underlying iOS settings
* for `UIScrollViewDecelerationRateNormal` and
* `UIScrollViewDecelerationRateFast` respectively.
* - Normal: 0.998
* - Fast: 0.9 (the default for iOS WebView)
* - normal: 0.998
* - fast: 0.99 (the default for iOS WebView)
* @platform ios
*/
decelerationRate: ScrollView.propTypes.decelerationRate,

Просмотреть файл

@ -106,35 +106,6 @@ RCT_CUSTOM_VIEW_PROPERTY(region, MKCoordinateRegion, RCTMap)
[view setRegion:json ? [RCTConvert MKCoordinateRegion:json] : defaultView.region animated:YES];
}
- (NSDictionary<NSString *, id> *)constantsToExport
{
NSString *red, *green, *purple;
#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_9_0
if (![MKPinAnnotationView respondsToSelector:@selector(redPinColor)]) {
red = RCTMapPinRed;
green = RCTMapPinGreen;
purple = RCTMapPinPurple;
} else
#endif
{
red = RCTColorToHexString([MKPinAnnotationView redPinColor].CGColor);
green = RCTColorToHexString([MKPinAnnotationView greenPinColor].CGColor);
purple = RCTColorToHexString([MKPinAnnotationView purplePinColor].CGColor);
}
return @{
@"PinColors": @{
@"RED": red,
@"GREEN": green,
@"PURPLE": purple,
}
};
}
#pragma mark MKMapViewDelegate
- (void)mapView:(RCTMap *)mapView didSelectAnnotationView:(MKAnnotationView *)view

Просмотреть файл

@ -74,16 +74,6 @@ RCT_EXPORT_VIEW_PROPERTY(snapToAlignment, NSString)
RCT_REMAP_VIEW_PROPERTY(contentOffset, scrollView.contentOffset, CGPoint)
RCT_EXPORT_VIEW_PROPERTY(onRefreshStart, RCTDirectEventBlock)
- (NSDictionary<NSString *, id> *)constantsToExport
{
return @{
@"DecelerationRate": @{
@"normal": @(UIScrollViewDecelerationRateNormal),
@"fast": @(UIScrollViewDecelerationRateFast),
},
};
}
RCT_EXPORT_METHOD(getContentSize:(nonnull NSNumber *)reactTag
callback:(RCTResponseSenderBlock)callback)
{

Просмотреть файл

@ -170,12 +170,25 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
{
BOOL isJSNavigation = [request.URL.scheme isEqualToString:RCTJSNavigationScheme];
static NSDictionary<NSNumber *, NSString *> *navigationTypes;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
navigationTypes = @{
@(UIWebViewNavigationTypeLinkClicked): @"click",
@(UIWebViewNavigationTypeFormSubmitted): @"formsubmit",
@(UIWebViewNavigationTypeBackForward): @"backforward",
@(UIWebViewNavigationTypeReload): @"reload",
@(UIWebViewNavigationTypeFormResubmitted): @"formresubmit",
@(UIWebViewNavigationTypeOther): @"other",
};
});
// skip this for the JS Navigation handler
if (!isJSNavigation && _onShouldStartLoadWithRequest) {
NSMutableDictionary<NSString *, id> *event = [self baseEvent];
[event addEntriesFromDictionary: @{
@"url": (request.URL).absoluteString,
@"navigationType": @(navigationType)
@"navigationType": navigationTypes[@(navigationType)]
}];
if (![self.delegate webView:self
shouldStartLoadForRequest:event
@ -191,7 +204,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:(NSCoder *)aDecoder)
NSMutableDictionary<NSString *, id> *event = [self baseEvent];
[event addEntriesFromDictionary: @{
@"url": (request.URL).absoluteString,
@"navigationType": @(navigationType)
@"navigationType": navigationTypes[@(navigationType)]
}];
_onLoadingStart(event);
}

Просмотреть файл

@ -47,21 +47,6 @@ RCT_EXPORT_VIEW_PROPERTY(onLoadingError, RCTDirectEventBlock)
RCT_EXPORT_VIEW_PROPERTY(onShouldStartLoadWithRequest, RCTDirectEventBlock)
RCT_REMAP_VIEW_PROPERTY(allowsInlineMediaPlayback, _webView.allowsInlineMediaPlayback, BOOL)
- (NSDictionary<NSString *, id> *)constantsToExport
{
return @{
@"JSNavigationScheme": RCTJSNavigationScheme,
@"NavigationType": @{
@"LinkClicked": @(UIWebViewNavigationTypeLinkClicked),
@"FormSubmitted": @(UIWebViewNavigationTypeFormSubmitted),
@"BackForward": @(UIWebViewNavigationTypeBackForward),
@"Reload": @(UIWebViewNavigationTypeReload),
@"FormResubmitted": @(UIWebViewNavigationTypeFormResubmitted),
@"Other": @(UIWebViewNavigationTypeOther)
},
};
}
RCT_EXPORT_METHOD(goBack:(nonnull NSNumber *)reactTag)
{
[self.bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, NSDictionary<NSNumber *, RCTWebView *> *viewRegistry) {