Skip to content

Commit c88a1cd

Browse files
committed
Updates from Wed Feb 18
- [reactnative] s/SpinnerIOS/ActivityIndicatorIOS/ | Dan Witte - [react-packager] Add a non-persistent mode for static builds | Amjad Masad - [React Native] Fix stored file rejection when initializing cache | Alex Akers - [React Native] Consolidate network requests in image downloader | Alex Akers - [React Native] Update RCTCache | Alex Akers - Converted all low-hanging RKBridgeModules in FBReactKit to RCTBridgeModules | Nick Lockwood
1 parent 89db1a6 commit c88a1cd

File tree

22 files changed

+427
-269
lines changed

22 files changed

+427
-269
lines changed

Examples/Movies/SearchScreen.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var {
99
ListView,
1010
ListViewDataSource,
1111
ScrollView,
12-
SpinnerIOS,
12+
ActivityIndicatorIOS,
1313
StyleSheet,
1414
Text,
1515
TextInput,
@@ -215,7 +215,7 @@ var SearchScreen = React.createClass({
215215
if (!this.hasMore() || !this.state.isLoadingTail) {
216216
return <View style={styles.scrollSpinner} />;
217217
}
218-
return <SpinnerIOS style={styles.scrollSpinner} />;
218+
return <ActivityIndicatorIOS style={styles.scrollSpinner} />;
219219
},
220220

221221
renderRow: function(movie: Object) {
@@ -290,7 +290,7 @@ var SearchBar = React.createClass({
290290
onFocus={this.props.onFocus}
291291
style={styles.searchBarInput}
292292
/>
293-
<SpinnerIOS
293+
<ActivityIndicatorIOS
294294
animating={this.props.isLoading}
295295
style={styles.spinner}
296296
/>

Examples/UIExplorer/SpinnerExample.js renamed to Examples/UIExplorer/ActivityIndicatorExample.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
/**
22
* Copyright 2004-present Facebook. All Rights Reserved.
33
*
4-
* @providesModule SpinnerExample
4+
* @providesModule ActivityIndicatorExample
55
*/
66
'use strict';
77

88
var React = require('react-native');
99
var {
10-
SpinnerIOS,
10+
ActivityIndicatorIOS,
1111
StyleSheet,
1212
TimerMixin,
1313
View,
1414
} = React;
1515

16-
var ToggleAnimatingSpinner = React.createClass({
16+
var ToggleAnimatingActivityIndicator = React.createClass({
1717
mixins: [TimerMixin],
1818

1919
getInitialState: function() {
@@ -38,25 +38,25 @@ var ToggleAnimatingSpinner = React.createClass({
3838

3939
render: function() {
4040
return (
41-
<SpinnerIOS
41+
<ActivityIndicatorIOS
4242
animating={this.state.animating}
4343
style={[styles.centering, {height: 80}]}
44-
size={SpinnerIOS.size.large}
44+
size={ActivityIndicatorIOS.size.large}
4545
/>
4646
);
4747
}
4848
});
4949

5050
exports.framework = 'React';
51-
exports.title = '<SpinnerIOS>';
51+
exports.title = '<ActivityIndicatorIOS>';
5252
exports.description = 'Animated loading indicators.';
5353

5454
exports.examples = [
5555
{
5656
title: 'Default (small, white)',
5757
render: function() {
5858
return (
59-
<SpinnerIOS
59+
<ActivityIndicatorIOS
6060
style={[styles.centering, styles.gray, {height: 40}]}
6161
color="white"
6262
/>
@@ -68,10 +68,10 @@ exports.examples = [
6868
render: function() {
6969
return (
7070
<View>
71-
<SpinnerIOS
71+
<ActivityIndicatorIOS
7272
style={[styles.centering, {height: 40}]}
7373
/>
74-
<SpinnerIOS
74+
<ActivityIndicatorIOS
7575
style={[styles.centering, {backgroundColor: '#eeeeee', height: 40}]}
7676
/>
7777
</View>
@@ -83,10 +83,10 @@ exports.examples = [
8383
render: function() {
8484
return (
8585
<View style={styles.horizontal}>
86-
<SpinnerIOS color="#0000ff" />
87-
<SpinnerIOS color="#aa00aa" />
88-
<SpinnerIOS color="#aa3300" />
89-
<SpinnerIOS color="#00aa00" />
86+
<ActivityIndicatorIOS color="#0000ff" />
87+
<ActivityIndicatorIOS color="#aa00aa" />
88+
<ActivityIndicatorIOS color="#aa3300" />
89+
<ActivityIndicatorIOS color="#00aa00" />
9090
</View>
9191
);
9292
}
@@ -95,10 +95,10 @@ exports.examples = [
9595
title: 'Large',
9696
render: function() {
9797
return (
98-
<SpinnerIOS
98+
<ActivityIndicatorIOS
9999
style={[styles.centering, styles.gray, {height: 80}]}
100100
color="white"
101-
size={SpinnerIOS.size.large}
101+
size={ActivityIndicatorIOS.size.large}
102102
/>
103103
);
104104
}
@@ -108,20 +108,20 @@ exports.examples = [
108108
render: function() {
109109
return (
110110
<View style={styles.horizontal}>
111-
<SpinnerIOS
112-
size={SpinnerIOS.size.large}
111+
<ActivityIndicatorIOS
112+
size={ActivityIndicatorIOS.size.large}
113113
color="#0000ff"
114114
/>
115-
<SpinnerIOS
116-
size={SpinnerIOS.size.large}
115+
<ActivityIndicatorIOS
116+
size={ActivityIndicatorIOS.size.large}
117117
color="#aa00aa"
118118
/>
119-
<SpinnerIOS
120-
size={SpinnerIOS.size.large}
119+
<ActivityIndicatorIOS
120+
size={ActivityIndicatorIOS.size.large}
121121
color="#aa3300"
122122
/>
123-
<SpinnerIOS
124-
size={SpinnerIOS.size.large}
123+
<ActivityIndicatorIOS
124+
size={ActivityIndicatorIOS.size.large}
125125
color="#00aa00"
126126
/>
127127
</View>
@@ -131,7 +131,7 @@ exports.examples = [
131131
{
132132
title: 'Start/stop',
133133
render: function() {
134-
return <ToggleAnimatingSpinner />;
134+
return <ToggleAnimatingActivityIndicator />;
135135
}
136136
},
137137
];

Examples/UIExplorer/UIExplorerList.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var EXAMPLES = [
2929
require('./StatusBarIOSExample'),
3030
require('./PointerEventsExample'),
3131
require('./TouchableExample'),
32-
require('./SpinnerExample'),
32+
require('./ActivityIndicatorExample'),
3333
require('./ScrollViewExample'),
3434
];
3535

Libraries/Components/SpinnerIOS/SpinnerIOS.ios.js renamed to Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Copyright 2004-present Facebook. All Rights Reserved.
33
*
4-
* @providesModule SpinnerIOS
4+
* @providesModule ActivityIndicatorIOS
55
*/
66
'use strict';
77

@@ -25,7 +25,7 @@ var SpinnerSize = keyMirror({
2525

2626
var GRAY = '#999999';
2727

28-
var SpinnerIOS = React.createClass({
28+
var ActivityIndicatorIOS = React.createClass({
2929
mixins: [NativeMethodsMixin],
3030

3131
propTypes: {
@@ -39,8 +39,8 @@ var SpinnerIOS = React.createClass({
3939
color: PropTypes.string,
4040
/**
4141
* The size of the spinner, must be one of:
42-
* - SpinnerIOS.size.large
43-
* - SpinnerIOS.size.small (default)
42+
* - ActivityIndicatorIOS.size.large
43+
* - ActivityIndicatorIOS.size.small (default)
4444
*/
4545
size: PropTypes.oneOf([SpinnerSize.large, SpinnerSize.small]),
4646
},
@@ -101,4 +101,4 @@ var UIActivityIndicatorView = createReactIOSNativeComponentClass({
101101
uiViewClassName: 'UIActivityIndicatorView',
102102
});
103103

104-
module.exports = SpinnerIOS;
104+
module.exports = ActivityIndicatorIOS;

Libraries/react-native/react-native-interface.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ declare module "react-native" {
1111
declare var NavigatorItemIOS: ReactClass<any, any, any>;
1212
declare var PixelRatio: ReactClass<any, any, any>;
1313
declare var ScrollView: ReactClass<any, any, any>;
14-
declare var SpinnerIOS: ReactClass<any, any, any>;
14+
declare var ActivityIndicatorIOS: ReactClass<any, any, any>;
1515
declare var StyleSheet: ReactClass<any, any, any>;
1616
declare var Text: ReactClass<any, any, any>;
1717
declare var TextInput: ReactClass<any, any, any>;

Libraries/react-native/react-native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ var ReactNative = {
1616
NavigatorIOS: require('NavigatorIOS'),
1717
PixelRatio: require('PixelRatio'),
1818
ScrollView: require('ScrollView'),
19-
SpinnerIOS: require('SpinnerIOS'),
19+
ActivityIndicatorIOS: require('ActivityIndicatorIOS'),
2020
StatusBarIOS: require('StatusBarIOS'),
2121
StyleSheet: require('StyleSheet'),
2222
Text: require('Text'),

ReactKit/Base/RCTBridge.m

Lines changed: 39 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,9 @@ - (NSString *)description
235235
RCTRemoteModulesByID = [[NSMutableDictionary alloc] init];
236236

237237
remoteModules = [[NSMutableDictionary alloc] init];
238-
[RCTExportedMethodsByModule() enumerateKeysAndObjectsUsingBlock:^(NSString *moduleName, NSArray *rawMethods, BOOL *stop) {
239-
238+
[RCTBridgeModuleClasses() enumerateKeysAndObjectsUsingBlock:^(NSString *moduleName, Class moduleClass, BOOL *stop) {
239+
240+
NSArray *rawMethods = RCTExportedMethodsByModule()[moduleName];
240241
NSMutableDictionary *methods = [NSMutableDictionary dictionaryWithCapacity:rawMethods.count];
241242
[rawMethods enumerateObjectsUsingBlock:^(RCTModuleMethod *method, NSUInteger methodID, BOOL *stop) {
242243
methods[method.JSMethodName] = @{
@@ -249,13 +250,15 @@ - (NSString *)description
249250
@"moduleID": @(remoteModules.count),
250251
@"methods": methods
251252
};
252-
253-
Class cls = RCTBridgeModuleClasses()[moduleName];
254-
if (RCTClassOverridesClassMethod(cls, @selector(constantsToExport))) {
255-
module = [module mutableCopy];
256-
((NSMutableDictionary *)module)[@"constants"] = [cls constantsToExport];
253+
254+
if (RCTClassOverridesClassMethod(moduleClass, @selector(constantsToExport))) {
255+
NSDictionary *constants = [moduleClass constantsToExport];
256+
if (constants.count) {
257+
module = [module mutableCopy];
258+
((NSMutableDictionary *)module)[@"constants"] = constants;
259+
}
257260
}
258-
remoteModules[moduleName] = module;
261+
remoteModules[moduleName] = [module copy];
259262

260263
// Add module lookup
261264
RCTRemoteModulesByID[module[@"moduleID"]] = moduleName;
@@ -303,13 +306,13 @@ - (NSString *)description
303306
// Add globally used methods
304307
[JSMethods addObjectsFromArray:@[
305308
@"Bundler.runApplication",
309+
@"RCTDeviceEventEmitter.emit",
306310
@"RCTEventEmitter.receiveEvent",
307311
@"RCTEventEmitter.receiveTouches",
308312
]];
309313

310314
// NOTE: these methods are currently unused in the OSS project
311315
// @"Dimensions.set",
312-
// @"RCTDeviceEventEmitter.emit",
313316
// @"RCTNativeAppEventEmitter.emit",
314317
// @"ReactIOS.unmountComponentAtNodeAndRemoveContainer",
315318

@@ -376,10 +379,15 @@ - (instancetype)initWithJavaScriptExecutor:(id<RCTJavaScriptExecutor>)javaScript
376379
_moduleInstances = [[NSMutableDictionary alloc] init];
377380
[RCTBridgeModuleClasses() enumerateKeysAndObjectsUsingBlock:^(NSString *moduleName, Class moduleClass, BOOL *stop) {
378381
if (_moduleInstances[moduleName] == nil) {
382+
id<RCTBridgeModule> moduleInstance;
379383
if ([moduleClass instancesRespondToSelector:@selector(initWithBridge:)]) {
380-
_moduleInstances[moduleName] = [[moduleClass alloc] initWithBridge:self];
384+
moduleInstance = [[moduleClass alloc] initWithBridge:self];
381385
} else {
382-
_moduleInstances[moduleName] = [[moduleClass alloc] init];
386+
moduleInstance = [[moduleClass alloc] init];
387+
}
388+
if (moduleInstance) {
389+
// If nil, the module doesn't support auto-instantiation
390+
_moduleInstances[moduleName] = moduleInstance;
383391
}
384392
}
385393
}];
@@ -522,22 +530,22 @@ - (void)_handleBuffer:(id)buffer
522530
}
523531

524532
if (![buffer isKindOfClass:[NSArray class]]) {
525-
RCTLogMustFix(@"Buffer must be an instance of NSArray, got %@", NSStringFromClass([buffer class]));
533+
RCTLogError(@"Buffer must be an instance of NSArray, got %@", NSStringFromClass([buffer class]));
526534
return;
527535
}
528536

529537
NSArray *requestsArray = (NSArray *)buffer;
530538
NSUInteger bufferRowCount = [requestsArray count];
531539
NSUInteger expectedFieldsCount = RCTBridgeFieldResponseReturnValues + 1;
532540
if (bufferRowCount != expectedFieldsCount) {
533-
RCTLogMustFix(@"Must pass all fields to buffer - expected %zd, saw %zd", expectedFieldsCount, bufferRowCount);
541+
RCTLogError(@"Must pass all fields to buffer - expected %zd, saw %zd", expectedFieldsCount, bufferRowCount);
534542
return;
535543
}
536544

537545
for (NSUInteger fieldIndex = RCTBridgeFieldRequestModuleIDs; fieldIndex <= RCTBridgeFieldParamss; fieldIndex++) {
538546
id field = [requestsArray objectAtIndex:fieldIndex];
539547
if (![field isKindOfClass:[NSArray class]]) {
540-
RCTLogMustFix(@"Field at index %zd in buffer must be an instance of NSArray, got %@", fieldIndex, NSStringFromClass([field class]));
548+
RCTLogError(@"Field at index %zd in buffer must be an instance of NSArray, got %@", fieldIndex, NSStringFromClass([field class]));
541549
return;
542550
}
543551
}
@@ -549,7 +557,7 @@ - (void)_handleBuffer:(id)buffer
549557
NSUInteger numRequests = [moduleIDs count];
550558
BOOL allSame = numRequests == [methodIDs count] && numRequests == [paramsArrays count];
551559
if (!allSame) {
552-
RCTLogMustFix(@"Invalid data message - all must be length: %zd", numRequests);
560+
RCTLogError(@"Invalid data message - all must be length: %zd", numRequests);
553561
return;
554562
}
555563

@@ -578,30 +586,30 @@ - (BOOL)_handleRequestNumber:(NSUInteger)i
578586
params:(NSArray *)params
579587
{
580588
if (![params isKindOfClass:[NSArray class]]) {
581-
RCTLogMustFix(@"Invalid module/method/params tuple for request #%zd", i);
589+
RCTLogError(@"Invalid module/method/params tuple for request #%zd", i);
582590
return NO;
583591
}
584592

585593
NSString *moduleName = RCTRemoteModulesByID[moduleID];
586594
if (!moduleName) {
587-
RCTLogMustFix(@"Unknown moduleID: %@", moduleID);
595+
RCTLogError(@"Unknown moduleID: %@", moduleID);
588596
return NO;
589597
}
590598

591599
NSArray *methods = RCTExportedMethodsByModule()[moduleName];
592600
if (methodID >= methods.count) {
593-
RCTLogMustFix(@"Unknown methodID: %zd for module: %@", methodID, moduleName);
601+
RCTLogError(@"Unknown methodID: %zd for module: %@", methodID, moduleName);
594602
return NO;
595603
}
596604

597605
RCTModuleMethod *method = methods[methodID];
598606
NSUInteger methodArity = method.arity;
599607
if (params.count != methodArity) {
600-
RCTLogMustFix(@"Expected %tu arguments but got %tu invoking %@.%@",
601-
methodArity,
602-
params.count,
603-
moduleName,
604-
method.JSMethodName);
608+
RCTLogError(@"Expected %tu arguments but got %tu invoking %@.%@",
609+
methodArity,
610+
params.count,
611+
moduleName,
612+
method.JSMethodName);
605613
return NO;
606614
}
607615

@@ -663,13 +671,13 @@ - (BOOL)_handleRequestNumber:(NSUInteger)i
663671
// TODO: it seems like an error if the param doesn't respond
664672
// so we should probably surface that error rather than failing silently
665673
#define CASE(_value, _type, _selector) \
666-
case _value: \
667-
if ([param respondsToSelector:@selector(_selector)]) { \
668-
_type value = [param _selector]; \
669-
[invocation setArgument:&value atIndex:argIdx]; \
670-
shouldSet = NO; \
671-
} \
672-
break;
674+
case _value: \
675+
if ([param respondsToSelector:@selector(_selector)]) { \
676+
_type value = [param _selector]; \
677+
[invocation setArgument:&value atIndex:argIdx]; \
678+
shouldSet = NO; \
679+
} \
680+
break;
673681

674682
CASE('c', char, charValue)
675683
CASE('C', unsigned char, unsignedCharValue)
@@ -698,7 +706,7 @@ - (BOOL)_handleRequestNumber:(NSUInteger)i
698706
[invocation invoke];
699707
}
700708
@catch (NSException *exception) {
701-
RCTLogMustFix(@"Exception thrown while invoking %@ on target %@ with params %@: %@", method.JSMethodName, target, params, exception);
709+
RCTLogError(@"Exception thrown while invoking %@ on target %@ with params %@: %@", method.JSMethodName, target, params, exception);
702710
}
703711
});
704712

0 commit comments

Comments
 (0)