mirror of
https://github.com/status-im/react-native.git
synced 2025-01-31 11:44:55 +00:00
Merge pull request #1478 from tadeuzagallo/Update_Mon_1_Jun
Update mon 1 jun
This commit is contained in:
commit
2deff61bde
@ -74,7 +74,9 @@ var AppRegistry = {
|
|||||||
);
|
);
|
||||||
invariant(
|
invariant(
|
||||||
runnables[appKey] && runnables[appKey].run,
|
runnables[appKey] && runnables[appKey].run,
|
||||||
'Application ' + appKey + ' has not been registered.'
|
'Application ' + appKey + ' has not been registered. This ' +
|
||||||
|
'is either due to a require() error during initialization ' +
|
||||||
|
'or failure to call AppRegistry.registerComponent.'
|
||||||
);
|
);
|
||||||
runnables[appKey].run(appParameters);
|
runnables[appKey].run(appParameters);
|
||||||
},
|
},
|
||||||
|
@ -60,14 +60,10 @@ var JSTimers = {
|
|||||||
var freeIndex = JSTimers._getFreeIndex();
|
var freeIndex = JSTimers._getFreeIndex();
|
||||||
JSTimersExecution.timerIDs[freeIndex] = newID;
|
JSTimersExecution.timerIDs[freeIndex] = newID;
|
||||||
JSTimersExecution.callbacks[freeIndex] = function() {
|
JSTimersExecution.callbacks[freeIndex] = function() {
|
||||||
var startTime = Date.now();
|
return func.apply(undefined, args);
|
||||||
var ret = func.apply(undefined, args);
|
|
||||||
var endTime = Date.now();
|
|
||||||
RCTTiming.createTimer(newID, Math.max(0, duration - (endTime - startTime)), endTime, false);
|
|
||||||
return ret;
|
|
||||||
};
|
};
|
||||||
JSTimersExecution.types[freeIndex] = JSTimersExecution.Type.setInterval;
|
JSTimersExecution.types[freeIndex] = JSTimersExecution.Type.setInterval;
|
||||||
RCTTiming.createTimer(newID, duration, Date.now(), /** recurring */ false);
|
RCTTiming.createTimer(newID, duration, Date.now(), /** recurring */ true);
|
||||||
return newID;
|
return newID;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ var createReactNativeComponentClass = function(
|
|||||||
};
|
};
|
||||||
Constructor.displayName = viewConfig.uiViewClassName;
|
Constructor.displayName = viewConfig.uiViewClassName;
|
||||||
Constructor.prototype = new ReactNativeBaseComponent(viewConfig);
|
Constructor.prototype = new ReactNativeBaseComponent(viewConfig);
|
||||||
|
Constructor.prototype.constructor = Constructor;
|
||||||
|
|
||||||
return Constructor;
|
return Constructor;
|
||||||
};
|
};
|
||||||
|
@ -66,7 +66,6 @@
|
|||||||
{
|
{
|
||||||
RCTJavaScriptContext *_context;
|
RCTJavaScriptContext *_context;
|
||||||
NSThread *_javaScriptThread;
|
NSThread *_javaScriptThread;
|
||||||
JSValueRef _undefined;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -238,9 +237,6 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError)
|
|||||||
JSContextGroupRelease(group);
|
JSContextGroupRelease(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Constant value used for comparison
|
|
||||||
_undefined = JSValueMakeUndefined(ctx);
|
|
||||||
|
|
||||||
strongSelf->_context = [[RCTJavaScriptContext alloc] initWithJSContext:ctx];
|
strongSelf->_context = [[RCTJavaScriptContext alloc] initWithJSContext:ctx];
|
||||||
[strongSelf _addNativeHook:RCTNativeLoggingHook withName:"nativeLoggingHook"];
|
[strongSelf _addNativeHook:RCTNativeLoggingHook withName:"nativeLoggingHook"];
|
||||||
[strongSelf _addNativeHook:RCTNoop withName:"noop"];
|
[strongSelf _addNativeHook:RCTNoop withName:"noop"];
|
||||||
@ -312,7 +308,7 @@ static NSError *RCTNSErrorFromJSError(JSContextRef context, JSValueRef jsError)
|
|||||||
JSValueRef requireJSRef = JSObjectGetProperty(contextJSRef, globalObjectJSRef, requireNameJSStringRef, &errorJSRef);
|
JSValueRef requireJSRef = JSObjectGetProperty(contextJSRef, globalObjectJSRef, requireNameJSStringRef, &errorJSRef);
|
||||||
JSStringRelease(requireNameJSStringRef);
|
JSStringRelease(requireNameJSStringRef);
|
||||||
|
|
||||||
if (requireJSRef != NULL && requireJSRef != _undefined && errorJSRef == NULL) {
|
if (requireJSRef != NULL && !JSValueIsUndefined(contextJSRef, requireJSRef) && errorJSRef == NULL) {
|
||||||
|
|
||||||
// get module
|
// get module
|
||||||
JSStringRef moduleNameJSStringRef = JSStringCreateWithCFString((__bridge CFStringRef)name);
|
JSStringRef moduleNameJSStringRef = JSStringCreateWithCFString((__bridge CFStringRef)name);
|
||||||
|
@ -48,17 +48,16 @@ RCT_EXPORT_MODULE()
|
|||||||
for (NSString *name in @[UIApplicationDidBecomeActiveNotification,
|
for (NSString *name in @[UIApplicationDidBecomeActiveNotification,
|
||||||
UIApplicationDidEnterBackgroundNotification,
|
UIApplicationDidEnterBackgroundNotification,
|
||||||
UIApplicationDidFinishLaunchingNotification]) {
|
UIApplicationDidFinishLaunchingNotification]) {
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
selector:@selector(handleAppStateDidChange)
|
selector:@selector(handleAppStateDidChange)
|
||||||
name:name
|
name:name
|
||||||
object:nil];
|
object:nil];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
||||||
selector:@selector(handleMemoryWarning)
|
|
||||||
name:UIApplicationDidReceiveMemoryWarningNotification
|
|
||||||
object:nil];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(handleMemoryWarning)
|
||||||
|
name:UIApplicationDidReceiveMemoryWarningNotification
|
||||||
|
object:nil];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,8 @@ static UIViewAnimationCurve UIViewAnimationCurveFromRCTAnimationType(RCTAnimatio
|
|||||||
NSMutableDictionary *_defaultViews; // Main thread only
|
NSMutableDictionary *_defaultViews; // Main thread only
|
||||||
NSDictionary *_viewManagers;
|
NSDictionary *_viewManagers;
|
||||||
NSDictionary *_viewConfigs;
|
NSDictionary *_viewConfigs;
|
||||||
NSUInteger _rootTag;
|
|
||||||
|
NSMutableSet *_bridgeTransactionListeners;
|
||||||
}
|
}
|
||||||
|
|
||||||
@synthesize bridge = _bridge;
|
@synthesize bridge = _bridge;
|
||||||
@ -263,7 +264,8 @@ static NSDictionary *RCTViewConfigForModule(Class managerClass, NSString *viewNa
|
|||||||
// Internal resources
|
// Internal resources
|
||||||
_pendingUIBlocks = [[NSMutableArray alloc] init];
|
_pendingUIBlocks = [[NSMutableArray alloc] init];
|
||||||
_rootViewTags = [[NSMutableSet alloc] init];
|
_rootViewTags = [[NSMutableSet alloc] init];
|
||||||
_rootTag = 1;
|
|
||||||
|
_bridgeTransactionListeners = [[NSMutableSet alloc] init];
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -287,6 +289,7 @@ static NSDictionary *RCTViewConfigForModule(Class managerClass, NSString *viewNa
|
|||||||
_rootViewTags = nil;
|
_rootViewTags = nil;
|
||||||
_shadowViewRegistry = nil;
|
_shadowViewRegistry = nil;
|
||||||
_viewRegistry = nil;
|
_viewRegistry = nil;
|
||||||
|
_bridgeTransactionListeners = nil;
|
||||||
_bridge = nil;
|
_bridge = nil;
|
||||||
|
|
||||||
[_pendingUIBlocksLock lock];
|
[_pendingUIBlocksLock lock];
|
||||||
@ -397,6 +400,10 @@ static NSDictionary *RCTViewConfigForModule(Class managerClass, NSString *viewNa
|
|||||||
[(id<RCTInvalidating>)subview invalidate];
|
[(id<RCTInvalidating>)subview invalidate];
|
||||||
}
|
}
|
||||||
registry[subview.reactTag] = nil;
|
registry[subview.reactTag] = nil;
|
||||||
|
|
||||||
|
if (registry == _viewRegistry) {
|
||||||
|
[_bridgeTransactionListeners removeObject:subview];
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -482,7 +489,6 @@ static NSDictionary *RCTViewConfigForModule(Class managerClass, NSString *viewNa
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Perform layout (possibly animated)
|
// Perform layout (possibly animated)
|
||||||
NSNumber *rootViewTag = rootShadowView.reactTag;
|
|
||||||
return ^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
return ^(RCTUIManager *uiManager, RCTSparseArray *viewRegistry) {
|
||||||
RCTResponseSenderBlock callback = self->_layoutAnimation.callback;
|
RCTResponseSenderBlock callback = self->_layoutAnimation.callback;
|
||||||
__block NSInteger completionsCalled = 0;
|
__block NSInteger completionsCalled = 0;
|
||||||
@ -547,17 +553,11 @@ static NSDictionary *RCTViewConfigForModule(Class managerClass, NSString *viewNa
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enumerate all active (attached to a parent) views and call
|
* TODO(tadeu): Remove it once and for all
|
||||||
* reactBridgeDidFinishTransaction on them if they implement it.
|
|
||||||
* TODO: this is quite inefficient. If this was handled via the
|
|
||||||
* ViewManager instead, it could be done more efficiently.
|
|
||||||
*/
|
*/
|
||||||
UIView *rootView = _viewRegistry[rootViewTag];
|
for (id<RCTViewNodeProtocol> node in _bridgeTransactionListeners) {
|
||||||
RCTTraverseViewNodes(rootView, ^(id<RCTViewNodeProtocol> view) {
|
[node reactBridgeDidFinishTransaction];
|
||||||
if ([view respondsToSelector:@selector(reactBridgeDidFinishTransaction)]) {
|
}
|
||||||
[view reactBridgeDidFinishTransaction];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -844,6 +844,10 @@ RCT_EXPORT_METHOD(createView:(NSNumber *)reactTag
|
|||||||
view.layer.allowsGroupOpacity = YES; // required for touch handling
|
view.layer.allowsGroupOpacity = YES; // required for touch handling
|
||||||
}
|
}
|
||||||
RCTSetViewProps(props, view, uiManager->_defaultViews[viewName], manager);
|
RCTSetViewProps(props, view, uiManager->_defaultViews[viewName], manager);
|
||||||
|
|
||||||
|
if ([view respondsToSelector:@selector(reactBridgeDidFinishTransaction)]) {
|
||||||
|
[uiManager->_bridgeTransactionListeners addObject:view];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
viewRegistry[reactTag] = view;
|
viewRegistry[reactTag] = view;
|
||||||
}];
|
}];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user