Skip to content

Commit

Permalink
Merge branch 'master' into create-animated-comp-error
Browse files Browse the repository at this point in the history
  • Loading branch information
janicduplessis authored Jul 17, 2017
2 parents 51c91c4 + 980d514 commit 5f55c4a
Show file tree
Hide file tree
Showing 30 changed files with 145 additions and 119 deletions.
3 changes: 3 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
; "node_modules/react-native" but in the source repo it is in the root
.*/Libraries/react-native/React.js

; Ignore polyfills
.*/Libraries/polyfills/.*

[include]

[libs]
Expand Down
3 changes: 3 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
docs/* @hramos
blog/* @hramos
Libraries/Animated/* @janicduplessis
Libraries/NativeAnimation/* @janicduplessis
ReactAndroid/src/main/java/com/facebook/react/animated/* @janicduplessis
website/* @hramos
website/showcase.json @hramos
package.json @hramos @ericnakagawa
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ install:
- nvm install 7
- rm -Rf "${TMPDIR}/jest_preprocess_cache"
- brew install yarn --ignore-dependencies
- brew install watchman
- yarn install

script:
Expand Down
3 changes: 3 additions & 0 deletions Libraries/CameraRoll/CameraRoll.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ const getPhotosReturnChecker = createStrictShapeTypeChecker({
height: PropTypes.number.isRequired,
width: PropTypes.number.isRequired,
isStored: PropTypes.bool,
// TODO (nivethavadivelu) Need to add changes to Android before
// setting it as required
playableDuration: PropTypes.number,
}).isRequired,
timestamp: PropTypes.number.isRequired,
location: createStrictShapeTypeChecker({
Expand Down
6 changes: 6 additions & 0 deletions Libraries/CameraRoll/RCTCameraRollManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ static void RCTResolvePromise(RCTPromiseResolveBlock resolve,
CLLocation *loc = [result valueForProperty:ALAssetPropertyLocation];
NSDate *date = [result valueForProperty:ALAssetPropertyDate];
NSString *filename = [result defaultRepresentation].filename;
int64_t duration = 0;
if ([[result valueForProperty:ALAssetPropertyType] isEqualToString:ALAssetTypeVideo]) {
duration = [[result valueForProperty:ALAssetPropertyDuration] intValue];
}

[assets addObject:@{
@"node": @{
@"type": [result valueForProperty:ALAssetPropertyType],
Expand All @@ -197,6 +202,7 @@ static void RCTResolvePromise(RCTPromiseResolveBlock resolve,
@"height": @(dimensions.height),
@"width": @(dimensions.width),
@"isStored": @YES,
@"playableDuration": @(duration),
},
@"timestamp": @(date.timeIntervalSince1970),
@"location": loc ? @{
Expand Down
6 changes: 0 additions & 6 deletions Libraries/Components/Touchable/TouchableOpacity.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ var TouchableOpacity = createReactClass({
* active. Defaults to 0.2.
*/
activeOpacity: PropTypes.number,
focusedOpacity: PropTypes.number,
/**
* Apple TV parallax effects
*/
Expand All @@ -73,7 +72,6 @@ var TouchableOpacity = createReactClass({
getDefaultProps: function() {
return {
activeOpacity: 0.2,
focusedOpacity: 0.7,
};
},

Expand Down Expand Up @@ -165,10 +163,6 @@ var TouchableOpacity = createReactClass({
);
},

_opacityFocused: function() {
this.setOpacityTo(this.props.focusedOpacity);
},

_getChildStyleOpacityWithDefault: function() {
var childStyle = flattenStyle(this.props.style) || {};
return childStyle.opacity == undefined ? 1 : childStyle.opacity;
Expand Down
3 changes: 2 additions & 1 deletion Libraries/Lists/SectionList.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ type OptionalProps<SectionT: SectionBase<any>> = {
/**
* Used to extract a unique key for a given item at the specified index. Key is used for caching
* and as the react key to track item re-ordering. The default extractor checks item.key, then
* falls back to using the index, like react does.
* falls back to using the index, like react does. Note that this sets keys for each item, but
* each overall section still needs its own key.
*/
keyExtractor: (item: Item, index: number) => string,
/**
Expand Down
2 changes: 2 additions & 0 deletions Libraries/polyfills/Array.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule Array.es6
* @polyfill
* @nolint
*/

/* eslint-disable */
Expand Down
2 changes: 2 additions & 0 deletions Libraries/polyfills/Array.prototype.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule Array.prototype.es6
* @polyfill
* @nolint
*/

/* eslint-disable */
Expand Down
2 changes: 2 additions & 0 deletions Libraries/polyfills/Number.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule Number.es6
* @polyfill
* @nolint
*/

/* eslint-disable strict */
Expand Down
2 changes: 2 additions & 0 deletions Libraries/polyfills/Object.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule Object.es6
* @polyfill
* @nolint
*/

/* eslint-disable strict */
Expand Down
2 changes: 2 additions & 0 deletions Libraries/polyfills/Object.es7.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule Object.es7
* @polyfill
* @nolint
*/

(function() {
Expand Down
2 changes: 2 additions & 0 deletions Libraries/polyfills/String.prototype.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule String.prototype.es6
* @polyfill
* @nolint
*/

/* eslint-disable strict, no-extend-native, no-bitwise */
Expand Down
2 changes: 2 additions & 0 deletions Libraries/polyfills/babelHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule babelHelpers
* @polyfill
* @nolint
*/

/* eslint-disable */
Expand Down
1 change: 1 addition & 0 deletions Libraries/polyfills/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule console
* @polyfill
* @nolint
*/
Expand Down
2 changes: 2 additions & 0 deletions Libraries/polyfills/error-guard.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule error-guard
* @polyfill
* @nolint
*/

/* eslint-disable strict */
Expand Down
15 changes: 1 addition & 14 deletions React/Base/RCTModuleData.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,27 +58,14 @@ typedef id<RCTBridgeModule>(^RCTBridgeModuleProvider)(void);

/**
* Returns YES if module instance must be created on the main thread.
* May be overriden by "allowOffMainQueueRegistration".
*/
@property (nonatomic, assign, readonly) BOOL requiresMainQueueSetup;
@property (nonatomic, assign) BOOL requiresMainQueueSetup;

/**
* Returns YES if module has constants to export.
* May be overriden by "allowOffMainQueueRegistration".
*/
@property (nonatomic, assign, readonly) BOOL hasConstantsToExport;

/**
* If set to YES, it will force both setup and constants export process
* to explicitly happen off the main queue.
* Overrides "requiresMainQueueSetup" & "hasConstantsToExport"
* Defaults to NO.
*
* @experimental
*/

@property (nonatomic, assign) BOOL allowOffMainQueueRegistration;

/**
* Returns the current module instance. Note that this will init the instance
* if it has not already been created. To check if the module instance exists
Expand Down
17 changes: 9 additions & 8 deletions React/Base/RCTModuleData.mm
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,15 @@ - (void)setUp
objectInitMethod = [NSObject instanceMethodForSelector:@selector(init)];
});

// If a module overrides `init` then we must assume that it expects to be
// initialized on the main thread, because it may need to access UIKit.
_requiresMainQueueSetup = !_instance &&
[_moduleClass instanceMethodForSelector:@selector(init)] != objectInitMethod;

// If a module overrides `constantsToExport` then we must assume that it
// must be called on the main thread, because it may need to access UIKit.
_hasConstantsToExport = [_moduleClass instancesRespondToSelector:@selector(constantsToExport)];

// If a module overrides `init` then we must assume that it expects to be
// initialized on the main thread, because it may need to access UIKit.
const BOOL hasCustomInit = !_instance && [_moduleClass instanceMethodForSelector:@selector(init)] != objectInitMethod;

_requiresMainQueueSetup = _hasConstantsToExport || hasCustomInit;
}

- (instancetype)initWithModuleClass:(Class)moduleClass
Expand Down Expand Up @@ -101,7 +102,7 @@ - (void)setUpInstanceAndBridge

if (!_setupComplete && _bridge.valid) {
if (!_instance) {
if (RCT_DEBUG && _requiresMainQueueSetup && !_allowOffMainQueueRegistration) {
if (RCT_DEBUG && _requiresMainQueueSetup) {
RCTAssertMainQueue();
}
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"[RCTModuleData setUpInstanceAndBridge] Create module", nil);
Expand Down Expand Up @@ -222,7 +223,7 @@ - (BOOL)hasInstance
{
if (!_setupComplete) {
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, ([NSString stringWithFormat:@"[RCTModuleData instanceForClass:%@]", _moduleClass]), nil);
if (_requiresMainQueueSetup && !_allowOffMainQueueRegistration) {
if (_requiresMainQueueSetup) {
// The chances of deadlock here are low, because module init very rarely
// calls out to other threads, however we can't control when a module might
// get accessed by client code during bridge setup, and a very low risk of
Expand Down Expand Up @@ -295,7 +296,7 @@ - (void)gatherConstants
if (_hasConstantsToExport && !_constantsToExport) {
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, ([NSString stringWithFormat:@"[RCTModuleData gatherConstants] %@", _moduleClass]), nil);
(void)[self instance];
if (_allowOffMainQueueRegistration) {
if (!_requiresMainQueueSetup) {
_constantsToExport = [_instance constantsToExport] ?: @{};
} else {
if (!RCTIsMainQueue()) {
Expand Down
3 changes: 2 additions & 1 deletion React/CxxBridge/RCTCxxBridge.mm
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ - (void)start
[self.delegate shouldBridgeUseCustomJSC:self];
// The arg is a cache dir. It's not used with standard JSC.
executorFactory.reset(new JSCExecutorFactory(folly::dynamic::object
("OwnerIdentity", "ReactNative")
("UseCustomJSC", (bool)useCustomJSC)
#if RCT_PROFILE
("StartSamplingProfilerOnInit", (bool)self.devSettings.startSamplingProfilerOnLaunch)
Expand Down Expand Up @@ -650,7 +651,7 @@ - (void)_prepareModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup
continue;
}

if (moduleData.requiresMainQueueSetup || moduleData.hasConstantsToExport) {
if (moduleData.requiresMainQueueSetup) {
// Modules that need to be set up on the main thread cannot be initialized
// lazily when required without doing a dispatch_sync to the main thread,
// which can result in deadlock. To avoid this, we initialize all of these
Expand Down
29 changes: 2 additions & 27 deletions React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#import "RCTRootShadowView.h"
#import "RCTRootViewInternal.h"
#import "RCTScrollableProtocol.h"
#import "RCTShadowView+Hierarchy.h"
#import "RCTShadowView.h"
#import "RCTUIManagerObserverCoordinator.h"
#import "RCTUtils.h"
Expand Down Expand Up @@ -1462,7 +1463,7 @@ - (void)rootViewForReactTag:(NSNumber *)reactTag withCompletion:(void (^)(UIView
}

dispatch_async(RCTGetUIManagerQueue(), ^{
NSNumber *rootTag = [self _rootTagForReactTag:reactTag];
NSNumber *rootTag = [self shadowViewForReactTag:reactTag].rootView.reactTag;
dispatch_async(dispatch_get_main_queue(), ^{
UIView *rootView = nil;
if (rootTag != nil) {
Expand All @@ -1473,32 +1474,6 @@ - (void)rootViewForReactTag:(NSNumber *)reactTag withCompletion:(void (^)(UIView
});
}

- (NSNumber *)_rootTagForReactTag:(NSNumber *)reactTag
{
RCTAssert(!RCTIsMainQueue(), @"Should be called on shadow queue");

if (reactTag == nil) {
return nil;
}

if (RCTIsReactRootView(reactTag)) {
return reactTag;
}

NSNumber *rootTag = nil;
RCTShadowView *shadowView = _shadowViewRegistry[reactTag];
while (shadowView) {
RCTShadowView *parent = [shadowView reactSuperview];
if (!parent && RCTIsReactRootView(shadowView.reactTag)) {
rootTag = shadowView.reactTag;
break;
}
shadowView = parent;
}

return rootTag;
}

static UIView *_jsResponder;

+ (UIView *)JSResponder
Expand Down
Loading

0 comments on commit 5f55c4a

Please sign in to comment.