[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#import <Foundation/Foundation.h>
|
|
|
|
|
|
|
|
#import "RCTAssert.h"
|
|
|
|
#import "RCTBridge.h"
|
2015-12-15 13:39:30 +00:00
|
|
|
#import "RCTBridge+Private.h"
|
2015-11-03 22:45:46 +00:00
|
|
|
#import "RCTBridgeMethod.h"
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
#import "RCTConvert.h"
|
2016-03-30 02:51:51 +00:00
|
|
|
#import "RCTDisplayLink.h"
|
2015-12-16 10:49:27 +00:00
|
|
|
#import "RCTJSCExecutor.h"
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
#import "RCTJavaScriptLoader.h"
|
|
|
|
#import "RCTLog.h"
|
|
|
|
#import "RCTModuleData.h"
|
|
|
|
#import "RCTPerformanceLogger.h"
|
|
|
|
#import "RCTProfile.h"
|
|
|
|
#import "RCTSourceCode.h"
|
|
|
|
#import "RCTUtils.h"
|
2016-04-20 16:12:18 +00:00
|
|
|
#import "RCTRedBox.h"
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
|
|
|
#define RCTAssertJSThread() \
|
2015-12-16 10:49:27 +00:00
|
|
|
RCTAssert(![NSStringFromClass([_javaScriptExecutor class]) isEqualToString:@"RCTJSCExecutor"] || \
|
2016-04-01 14:01:51 +00:00
|
|
|
[[[NSThread currentThread] name] isEqualToString:RCTJSCThreadName], \
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
@"This method must be called on JS thread")
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Must be kept in sync with `MessageQueue.js`.
|
|
|
|
*/
|
|
|
|
typedef NS_ENUM(NSUInteger, RCTBridgeFields) {
|
|
|
|
RCTBridgeFieldRequestModuleIDs = 0,
|
|
|
|
RCTBridgeFieldMethodIDs,
|
2016-02-08 15:06:52 +00:00
|
|
|
RCTBridgeFieldParams,
|
|
|
|
RCTBridgeFieldCallID,
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
};
|
|
|
|
|
2015-11-03 22:45:46 +00:00
|
|
|
RCT_EXTERN NSArray<Class> *RCTGetModuleClasses(void);
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
|
|
|
@implementation RCTBatchedBridge
|
|
|
|
{
|
2015-10-19 15:02:50 +00:00
|
|
|
BOOL _wasBatchActive;
|
2015-12-08 23:57:34 +00:00
|
|
|
NSMutableArray<dispatch_block_t> *_pendingCalls;
|
2015-11-25 11:09:00 +00:00
|
|
|
NSMutableDictionary<NSString *, RCTModuleData *> *_moduleDataByName;
|
|
|
|
NSArray<RCTModuleData *> *_moduleDataByID;
|
|
|
|
NSArray<Class> *_moduleClassesByID;
|
2016-03-30 02:51:51 +00:00
|
|
|
RCTDisplayLink *_displayLink;
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
|
2016-02-08 15:06:52 +00:00
|
|
|
@synthesize flowID = _flowID;
|
|
|
|
@synthesize flowIDMap = _flowIDMap;
|
2016-03-30 15:07:23 +00:00
|
|
|
@synthesize flowIDMapLock = _flowIDMapLock;
|
2016-03-03 10:20:20 +00:00
|
|
|
@synthesize loading = _loading;
|
|
|
|
@synthesize valid = _valid;
|
2016-02-08 15:06:52 +00:00
|
|
|
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
- (instancetype)initWithParentBridge:(RCTBridge *)bridge
|
|
|
|
{
|
|
|
|
RCTAssertParam(bridge);
|
|
|
|
|
|
|
|
if ((self = [super initWithBundleURL:bridge.bundleURL
|
|
|
|
moduleProvider:bridge.moduleProvider
|
|
|
|
launchOptions:bridge.launchOptions])) {
|
|
|
|
|
|
|
|
_parentBridge = bridge;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set Initial State
|
|
|
|
*/
|
|
|
|
_valid = YES;
|
|
|
|
_loading = YES;
|
2015-10-14 16:48:00 +00:00
|
|
|
_pendingCalls = [NSMutableArray new];
|
2016-03-30 02:51:51 +00:00
|
|
|
_displayLink = [RCTDisplayLink new];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-19 12:27:43 +00:00
|
|
|
[RCTBridge setCurrentBridge:self];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-12-15 13:42:45 +00:00
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:RCTJavaScriptWillStartLoadingNotification
|
|
|
|
object:_parentBridge userInfo:@{@"bridge": self}];
|
2015-07-22 17:54:45 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
[self start];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (void)start
|
|
|
|
{
|
|
|
|
dispatch_queue_t bridgeQueue = dispatch_queue_create("com.facebook.react.RCTBridgeQueue", DISPATCH_QUEUE_CONCURRENT);
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-21 18:33:04 +00:00
|
|
|
dispatch_group_t initModulesAndLoadSource = dispatch_group_create();
|
2015-11-25 11:09:00 +00:00
|
|
|
|
|
|
|
// Asynchronously load source code
|
2015-08-07 13:42:34 +00:00
|
|
|
dispatch_group_enter(initModulesAndLoadSource);
|
2015-09-04 10:19:30 +00:00
|
|
|
__weak RCTBatchedBridge *weakSelf = self;
|
2015-10-16 15:10:25 +00:00
|
|
|
__block NSData *sourceCode;
|
|
|
|
[self loadSource:^(NSError *error, NSData *source) {
|
2015-09-04 10:19:30 +00:00
|
|
|
if (error) {
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[weakSelf stopLoadingWithError:error];
|
|
|
|
});
|
|
|
|
}
|
2015-09-11 13:35:25 +00:00
|
|
|
|
2015-08-21 18:33:04 +00:00
|
|
|
sourceCode = source;
|
2015-08-07 13:42:34 +00:00
|
|
|
dispatch_group_leave(initModulesAndLoadSource);
|
|
|
|
}];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-12-10 12:27:45 +00:00
|
|
|
// Synchronously initialize all native modules that cannot be loaded lazily
|
2016-03-03 10:20:20 +00:00
|
|
|
[self initModulesWithDispatchGroup:initModulesAndLoadSource];
|
2015-11-25 11:09:00 +00:00
|
|
|
|
2015-08-21 18:33:04 +00:00
|
|
|
__block NSString *config;
|
2015-08-07 13:42:34 +00:00
|
|
|
dispatch_group_enter(initModulesAndLoadSource);
|
|
|
|
dispatch_async(bridgeQueue, ^{
|
|
|
|
dispatch_group_t setupJSExecutorAndModuleConfig = dispatch_group_create();
|
2015-11-25 11:09:00 +00:00
|
|
|
|
|
|
|
// Asynchronously initialize the JS executor
|
2015-08-07 13:42:34 +00:00
|
|
|
dispatch_group_async(setupJSExecutorAndModuleConfig, bridgeQueue, ^{
|
2016-03-15 12:40:09 +00:00
|
|
|
RCTPerformanceLoggerStart(RCTPLJSCExecutorSetup);
|
2015-11-25 11:09:00 +00:00
|
|
|
[weakSelf setUpExecutor];
|
2016-03-15 12:40:09 +00:00
|
|
|
RCTPerformanceLoggerEnd(RCTPLJSCExecutorSetup);
|
2015-08-07 13:42:34 +00:00
|
|
|
});
|
2015-07-28 12:58:01 +00:00
|
|
|
|
2015-11-25 11:09:00 +00:00
|
|
|
// Asynchronously gather the module config
|
2015-08-07 13:42:34 +00:00
|
|
|
dispatch_group_async(setupJSExecutorAndModuleConfig, bridgeQueue, ^{
|
2016-03-03 10:20:20 +00:00
|
|
|
if (weakSelf.valid) {
|
2015-10-08 15:41:55 +00:00
|
|
|
RCTPerformanceLoggerStart(RCTPLNativeModulePrepareConfig);
|
2015-08-07 13:42:34 +00:00
|
|
|
config = [weakSelf moduleConfig];
|
2015-10-08 15:41:55 +00:00
|
|
|
RCTPerformanceLoggerEnd(RCTPLNativeModulePrepareConfig);
|
2015-08-07 13:42:34 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
dispatch_group_notify(setupJSExecutorAndModuleConfig, bridgeQueue, ^{
|
2015-11-25 11:09:00 +00:00
|
|
|
// We're not waiting for this to complete to leave dispatch group, since
|
|
|
|
// injectJSONConfiguration and executeSourceCode will schedule operations
|
|
|
|
// on the same queue anyway.
|
2015-10-05 17:53:33 +00:00
|
|
|
RCTPerformanceLoggerStart(RCTPLNativeModuleInjectConfig);
|
2015-09-04 10:19:30 +00:00
|
|
|
[weakSelf injectJSONConfiguration:config onComplete:^(NSError *error) {
|
2015-10-05 17:53:33 +00:00
|
|
|
RCTPerformanceLoggerEnd(RCTPLNativeModuleInjectConfig);
|
2015-09-04 10:19:30 +00:00
|
|
|
if (error) {
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[weakSelf stopLoadingWithError:error];
|
|
|
|
});
|
|
|
|
}
|
2015-08-21 18:33:04 +00:00
|
|
|
}];
|
2015-08-07 13:42:34 +00:00
|
|
|
dispatch_group_leave(initModulesAndLoadSource);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2016-03-22 16:32:50 +00:00
|
|
|
dispatch_group_notify(initModulesAndLoadSource, bridgeQueue, ^{
|
2015-09-04 10:19:30 +00:00
|
|
|
RCTBatchedBridge *strongSelf = weakSelf;
|
|
|
|
if (sourceCode && strongSelf.loading) {
|
2016-01-06 17:02:55 +00:00
|
|
|
[strongSelf executeSourceCode:sourceCode];
|
2015-08-07 13:42:34 +00:00
|
|
|
}
|
|
|
|
});
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (void)loadSource:(RCTSourceLoadBlock)_onSourceLoad
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
{
|
2015-08-21 18:33:04 +00:00
|
|
|
RCTPerformanceLoggerStart(RCTPLScriptDownload);
|
2015-11-27 16:36:00 +00:00
|
|
|
|
2015-10-16 15:10:25 +00:00
|
|
|
RCTSourceLoadBlock onSourceLoad = ^(NSError *error, NSData *source) {
|
2015-08-21 18:33:04 +00:00
|
|
|
RCTPerformanceLoggerEnd(RCTPLScriptDownload);
|
2015-09-11 14:11:23 +00:00
|
|
|
|
2015-08-21 18:33:04 +00:00
|
|
|
_onSourceLoad(error, source);
|
|
|
|
};
|
|
|
|
|
|
|
|
if ([self.delegate respondsToSelector:@selector(loadSourceForBridge:withBlock:)]) {
|
|
|
|
[self.delegate loadSourceForBridge:_parentBridge withBlock:onSourceLoad];
|
|
|
|
} else if (self.bundleURL) {
|
|
|
|
[RCTJavaScriptLoader loadBundleAtURL:self.bundleURL onComplete:onSourceLoad];
|
|
|
|
} else {
|
|
|
|
// Allow testing without a script
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
2015-10-14 16:48:00 +00:00
|
|
|
[self didFinishLoading];
|
2015-12-15 13:42:45 +00:00
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:RCTJavaScriptDidLoadNotification
|
|
|
|
object:_parentBridge userInfo:@{@"bridge": self}];
|
2015-08-21 18:33:04 +00:00
|
|
|
});
|
|
|
|
onSourceLoad(nil, nil);
|
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
|
2015-11-25 11:09:00 +00:00
|
|
|
- (NSArray<Class> *)moduleClasses
|
|
|
|
{
|
2016-03-03 10:20:20 +00:00
|
|
|
if (RCT_DEBUG && _valid && _moduleClassesByID == nil) {
|
2015-11-25 11:09:00 +00:00
|
|
|
RCTLogError(@"Bridge modules have not yet been initialized. You may be "
|
|
|
|
"trying to access a module too early in the startup procedure.");
|
|
|
|
}
|
|
|
|
return _moduleClassesByID;
|
|
|
|
}
|
|
|
|
|
2016-01-06 13:57:25 +00:00
|
|
|
/**
|
|
|
|
* Used by RCTUIManager
|
|
|
|
*/
|
|
|
|
- (RCTModuleData *)moduleDataForName:(NSString *)moduleName
|
|
|
|
{
|
|
|
|
return _moduleDataByName[moduleName];
|
|
|
|
}
|
|
|
|
|
2015-11-25 11:09:00 +00:00
|
|
|
- (id)moduleForName:(NSString *)moduleName
|
|
|
|
{
|
2016-03-03 10:20:20 +00:00
|
|
|
return _moduleDataByName[moduleName].instance;
|
2015-11-25 11:09:00 +00:00
|
|
|
}
|
|
|
|
|
2016-03-07 17:30:20 +00:00
|
|
|
- (BOOL)moduleIsInitialized:(Class)moduleClass
|
|
|
|
{
|
|
|
|
return _moduleDataByName[RCTBridgeModuleNameForClass(moduleClass)].hasInstance;
|
|
|
|
}
|
|
|
|
|
2015-12-10 12:27:45 +00:00
|
|
|
- (NSArray *)configForModuleName:(NSString *)moduleName
|
|
|
|
{
|
|
|
|
RCTModuleData *moduleData = _moduleDataByName[moduleName];
|
|
|
|
if (!moduleData) {
|
|
|
|
moduleData = _moduleDataByName[[@"RCT" stringByAppendingString:moduleName]];
|
|
|
|
}
|
|
|
|
if (moduleData) {
|
|
|
|
return moduleData.config;
|
|
|
|
}
|
|
|
|
return (id)kCFNull;
|
|
|
|
}
|
|
|
|
|
2016-03-03 10:20:20 +00:00
|
|
|
- (void)initModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
{
|
2015-08-21 18:33:04 +00:00
|
|
|
RCTPerformanceLoggerStart(RCTPLNativeModuleInit);
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-11-03 22:45:46 +00:00
|
|
|
NSArray<id<RCTBridgeModule>> *extraModules = nil;
|
2015-07-28 22:48:46 +00:00
|
|
|
if (self.delegate) {
|
|
|
|
if ([self.delegate respondsToSelector:@selector(extraModulesForBridge:)]) {
|
|
|
|
extraModules = [self.delegate extraModulesForBridge:_parentBridge];
|
|
|
|
}
|
|
|
|
} else if (self.moduleProvider) {
|
|
|
|
extraModules = self.moduleProvider();
|
|
|
|
}
|
|
|
|
|
2016-03-03 10:20:20 +00:00
|
|
|
if (RCT_DEBUG && !RCTRunningInTestEnvironment()) {
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2016-03-03 10:20:20 +00:00
|
|
|
// Check for unexported modules
|
|
|
|
static Class *classes;
|
|
|
|
static unsigned int classCount;
|
|
|
|
static dispatch_once_t onceToken;
|
|
|
|
dispatch_once(&onceToken, ^{
|
|
|
|
classes = objc_copyClassList(&classCount);
|
|
|
|
});
|
2015-11-25 11:09:00 +00:00
|
|
|
|
2016-03-03 10:20:20 +00:00
|
|
|
NSMutableSet *moduleClasses = [NSMutableSet new];
|
|
|
|
[moduleClasses addObjectsFromArray:RCTGetModuleClasses()];
|
|
|
|
[moduleClasses addObjectsFromArray:[extraModules valueForKeyPath:@"class"]];
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < classCount; i++)
|
|
|
|
{
|
|
|
|
Class cls = classes[i];
|
|
|
|
Class superclass = cls;
|
|
|
|
while (superclass)
|
|
|
|
{
|
|
|
|
if (class_conformsToProtocol(superclass, @protocol(RCTBridgeModule)))
|
|
|
|
{
|
Added native event emitter
Summary:
This is a solution for the problem I raised in https://www.facebook.com/groups/react.native.community/permalink/768218933313687/
I've added a new native base class, `RCTEventEmitter` as well as an equivalent JS class/module `NativeEventEmitter` (RCTEventEmitter.js and EventEmitter.js were taken already).
Instead of arbitrary modules sending events via `bridge.eventDispatcher`, the idea is that any module that sends events should now subclass `RCTEventEmitter`, and provide an equivalent JS module that subclasses `NativeEventEmitter`.
JS code that wants to observe the events should now observe it via the specific JS module rather than via `RCTDeviceEventEmitter` directly. e.g. to observer a keyboard event, instead of writing:
const RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
RCTDeviceEventEmitter.addListener('keyboardWillShow', (event) => { ... });
You'd now write:
const Keyboard = require('Keyboard');
Keyboard.addListener('keyboardWillShow', (event) => { ... });
Within a component, you can also use the `Subscribable.Mixin` as you would previously, but instead of:
this.addListenerOn(RCTDeviceEventEmitter, 'keyboardWillShow', ...);
Write:
this.addListenerOn(Keyboard, 'keyboardWillShow', ...);
This approach allows the native `RCTKeyboardObserver` module to be created lazily the first time a listener is added, and to stop sending events when the last listener is removed. It also allows us to validate that the event strings being observed and omitted match the supported events for that module.
As a proof-of-concept, I've converted the `RCTStatusBarManager` and `RCTKeyboardObserver` modules to use the new system. I'll convert the rest in a follow up diff.
For now, the new `NativeEventEmitter` JS module wraps the `RCTDeviceEventEmitter` JS module, and just uses the native `RCTEventEmitter` module for bookkeeping. This allows for full backwards compatibility (code that is observing the event via `RCTDeviceEventEmitter` instead of the specific module will still work as expected, albeit with a warning). Once all legacy calls have been removed, this could be refactored to something more elegant internally, whilst maintaining the same public interface.
Note: currently, all device events still share a single global namespace, since they're really all registered on the same emitter instance internally. We should move away from that as soon as possible because it's not intuitive and will likely lead to strange bugs if people add generic events such as "onChange" or "onError" to their modules (which is common practice for components, where it's not a problem).
Reviewed By: javache
Differential Revision: D3269966
fbshipit-source-id: 1412daba850cd373020e1086673ba38ef9193050
2016-05-11 13:26:53 +00:00
|
|
|
if (![moduleClasses containsObject:cls] &&
|
|
|
|
![cls respondsToSelector:@selector(moduleName)]) {
|
2016-03-03 10:20:20 +00:00
|
|
|
RCTLogWarn(@"Class %@ was not exported. Did you forget to use "
|
|
|
|
"RCT_EXPORT_MODULE()?", cls);
|
|
|
|
}
|
|
|
|
break;
|
2015-11-25 11:09:00 +00:00
|
|
|
}
|
2016-03-03 10:20:20 +00:00
|
|
|
superclass = class_getSuperclass(superclass);
|
2015-11-25 11:09:00 +00:00
|
|
|
}
|
|
|
|
}
|
2016-03-03 10:20:20 +00:00
|
|
|
}
|
2015-11-25 11:09:00 +00:00
|
|
|
|
2016-03-03 10:20:20 +00:00
|
|
|
NSMutableArray<Class> *moduleClassesByID = [NSMutableArray new];
|
|
|
|
NSMutableArray<RCTModuleData *> *moduleDataByID = [NSMutableArray new];
|
|
|
|
NSMutableDictionary<NSString *, RCTModuleData *> *moduleDataByName = [NSMutableDictionary new];
|
|
|
|
|
|
|
|
// Set up moduleData for pre-initialized module instances
|
|
|
|
for (id<RCTBridgeModule> module in extraModules) {
|
|
|
|
Class moduleClass = [module class];
|
|
|
|
NSString *moduleName = RCTBridgeModuleNameForClass(moduleClass);
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2016-03-03 10:20:20 +00:00
|
|
|
if (RCT_DEBUG) {
|
|
|
|
// Check for name collisions between preregistered modules
|
|
|
|
RCTModuleData *moduleData = moduleDataByName[moduleName];
|
|
|
|
if (moduleData) {
|
|
|
|
RCTLogError(@"Attempted to register RCTBridgeModule class %@ for the "
|
|
|
|
"name '%@', but name was already registered by class %@",
|
|
|
|
moduleClass, moduleName, moduleData.moduleClass);
|
|
|
|
continue;
|
2015-11-25 11:09:00 +00:00
|
|
|
}
|
|
|
|
}
|
2016-03-03 10:20:20 +00:00
|
|
|
|
|
|
|
// Instantiate moduleData container
|
|
|
|
RCTModuleData *moduleData = [[RCTModuleData alloc] initWithModuleInstance:module
|
|
|
|
bridge:self];
|
|
|
|
moduleDataByName[moduleName] = moduleData;
|
|
|
|
[moduleClassesByID addObject:moduleClass];
|
|
|
|
[moduleDataByID addObject:moduleData];
|
2016-04-27 16:08:51 +00:00
|
|
|
|
|
|
|
// Set executor instance
|
|
|
|
if (moduleClass == self.executorClass) {
|
|
|
|
_javaScriptExecutor = (id<RCTJavaScriptExecutor>)module;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// The executor is a bridge module, but we want it to be instantiated before
|
|
|
|
// any other module has access to the bridge, in case they need the JS thread.
|
2016-05-04 14:06:09 +00:00
|
|
|
// TODO: once we have more fine-grained control of init (t11106126) we can
|
2016-04-27 16:08:51 +00:00
|
|
|
// probably just replace this with [self moduleForClass:self.executorClass]
|
|
|
|
if (!_javaScriptExecutor) {
|
|
|
|
id<RCTJavaScriptExecutor> executorModule = [self.executorClass new];
|
|
|
|
RCTModuleData *moduleData = [[RCTModuleData alloc] initWithModuleInstance:executorModule
|
|
|
|
bridge:self];
|
|
|
|
moduleDataByName[moduleData.name] = moduleData;
|
|
|
|
[moduleClassesByID addObject:self.executorClass];
|
|
|
|
[moduleDataByID addObject:moduleData];
|
|
|
|
|
|
|
|
// NOTE: _javaScriptExecutor is a weak reference
|
|
|
|
_javaScriptExecutor = executorModule;
|
2016-03-03 10:20:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set up moduleData for automatically-exported modules
|
|
|
|
for (Class moduleClass in RCTGetModuleClasses()) {
|
|
|
|
NSString *moduleName = RCTBridgeModuleNameForClass(moduleClass);
|
|
|
|
|
|
|
|
// Check for module name collisions
|
|
|
|
RCTModuleData *moduleData = moduleDataByName[moduleName];
|
2015-11-25 11:09:00 +00:00
|
|
|
if (moduleData) {
|
2016-03-03 10:20:20 +00:00
|
|
|
if (moduleData.hasInstance) {
|
|
|
|
// Existing module was preregistered, so it takes precedence
|
|
|
|
continue;
|
|
|
|
} else if ([moduleClass new] == nil) {
|
|
|
|
// The new module returned nil from init, so use the old module
|
|
|
|
continue;
|
|
|
|
} else if ([moduleData.moduleClass new] != nil) {
|
|
|
|
// Both modules were non-nil, so it's unclear which should take precedence
|
|
|
|
RCTLogError(@"Attempted to register RCTBridgeModule class %@ for the "
|
|
|
|
"name '%@', but name was already registered by class %@",
|
|
|
|
moduleClass, moduleName, moduleData.moduleClass);
|
|
|
|
}
|
2015-11-25 11:09:00 +00:00
|
|
|
}
|
2016-03-15 12:40:09 +00:00
|
|
|
|
2016-03-03 10:20:20 +00:00
|
|
|
// Instantiate moduleData (TODO: can we defer this until config generation?)
|
|
|
|
moduleData = [[RCTModuleData alloc] initWithModuleClass:moduleClass
|
|
|
|
bridge:self];
|
|
|
|
moduleDataByName[moduleName] = moduleData;
|
|
|
|
[moduleClassesByID addObject:moduleClass];
|
|
|
|
[moduleDataByID addObject:moduleData];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Store modules
|
2015-11-25 11:09:00 +00:00
|
|
|
_moduleDataByID = [moduleDataByID copy];
|
|
|
|
_moduleDataByName = [moduleDataByName copy];
|
2016-03-03 10:20:20 +00:00
|
|
|
_moduleClassesByID = [moduleClassesByID copy];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2016-04-27 16:08:51 +00:00
|
|
|
// Synchronously set up the pre-initialized modules
|
2015-11-25 11:09:00 +00:00
|
|
|
for (RCTModuleData *moduleData in _moduleDataByID) {
|
2016-04-27 16:08:51 +00:00
|
|
|
if (moduleData.hasInstance &&
|
|
|
|
(!moduleData.requiresMainThreadSetup || [NSThread isMainThread])) {
|
|
|
|
// Modules that were pre-initialized should ideally be set up before
|
|
|
|
// bridge init has finished, otherwise the caller may try to access the
|
|
|
|
// module directly rather than via `[bridge moduleForClass:]`, which won't
|
|
|
|
// trigger the lazy initialization process. If the module cannot safely be
|
|
|
|
// set up on the current thread, it will instead be async dispatched
|
|
|
|
// to the main thread to be set up in the loop below.
|
2016-03-03 10:20:20 +00:00
|
|
|
(void)[moduleData instance];
|
2016-01-04 14:23:51 +00:00
|
|
|
}
|
2016-03-07 17:30:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// From this point on, RCTDidInitializeModuleNotification notifications will
|
|
|
|
// be sent the first time a module is accessed.
|
|
|
|
_moduleSetupComplete = YES;
|
|
|
|
|
|
|
|
// Set up modules that require main thread init or constants export
|
2016-03-15 12:40:09 +00:00
|
|
|
RCTPerformanceLoggerSet(RCTPLNativeModuleMainThread, 0);
|
2016-03-16 16:46:55 +00:00
|
|
|
NSUInteger modulesOnMainThreadCount = 0;
|
2016-03-07 17:30:20 +00:00
|
|
|
for (RCTModuleData *moduleData in _moduleDataByID) {
|
|
|
|
__weak RCTBatchedBridge *weakSelf = self;
|
2016-04-27 16:08:51 +00:00
|
|
|
if (moduleData.requiresMainThreadSetup || moduleData.hasConstantsToExport) {
|
2016-03-03 10:20:20 +00:00
|
|
|
// 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
|
2016-04-27 16:08:51 +00:00
|
|
|
// modules on the main thread in parallel with loading the JS code, so
|
2016-03-03 10:20:20 +00:00
|
|
|
// they will already be available before they are ever required.
|
|
|
|
dispatch_group_async(dispatchGroup, dispatch_get_main_queue(), ^{
|
|
|
|
if (weakSelf.valid) {
|
2016-03-15 12:40:09 +00:00
|
|
|
RCTPerformanceLoggerAppendStart(RCTPLNativeModuleMainThread);
|
2016-03-03 10:20:20 +00:00
|
|
|
(void)[moduleData instance];
|
|
|
|
[moduleData gatherConstants];
|
2016-03-15 12:40:09 +00:00
|
|
|
RCTPerformanceLoggerAppendEnd(RCTPLNativeModuleMainThread);
|
2016-03-03 10:20:20 +00:00
|
|
|
}
|
|
|
|
});
|
2016-03-16 16:46:55 +00:00
|
|
|
modulesOnMainThreadCount++;
|
2016-02-29 17:47:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-05 17:53:33 +00:00
|
|
|
RCTPerformanceLoggerEnd(RCTPLNativeModuleInit);
|
2016-03-16 16:46:55 +00:00
|
|
|
RCTPerformanceLoggerSet(RCTPLNativeModuleMainThreadUsesCount, modulesOnMainThreadCount);
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
|
2015-11-25 11:09:00 +00:00
|
|
|
- (void)setUpExecutor
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
{
|
2015-08-07 13:42:34 +00:00
|
|
|
[_javaScriptExecutor setUp];
|
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2016-01-05 17:04:08 +00:00
|
|
|
- (void)registerModuleForFrameUpdates:(id<RCTBridgeModule>)module
|
|
|
|
withModuleData:(RCTModuleData *)moduleData
|
2015-12-10 12:27:45 +00:00
|
|
|
{
|
2016-03-30 02:51:51 +00:00
|
|
|
[_displayLink registerModuleForFrameUpdates:module withModuleData:moduleData];
|
2015-12-10 12:27:45 +00:00
|
|
|
}
|
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (NSString *)moduleConfig
|
|
|
|
{
|
2015-11-03 22:45:46 +00:00
|
|
|
NSMutableArray<NSArray *> *config = [NSMutableArray new];
|
2015-07-27 15:51:28 +00:00
|
|
|
for (RCTModuleData *moduleData in _moduleDataByID) {
|
2015-12-16 10:49:27 +00:00
|
|
|
if (self.executorClass == [RCTJSCExecutor class]) {
|
2015-12-10 12:27:45 +00:00
|
|
|
[config addObject:@[moduleData.name]];
|
|
|
|
} else {
|
|
|
|
[config addObject:RCTNullIfNil(moduleData.config)];
|
2015-08-07 13:42:34 +00:00
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
2015-08-07 13:42:34 +00:00
|
|
|
|
|
|
|
return RCTJSONStringify(@{
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
@"remoteModuleConfig": config,
|
|
|
|
}, NULL);
|
2015-08-07 13:42:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)injectJSONConfiguration:(NSString *)configJSON
|
|
|
|
onComplete:(void (^)(NSError *))onComplete
|
|
|
|
{
|
2016-03-03 10:20:20 +00:00
|
|
|
if (!_valid) {
|
2015-08-07 13:42:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
[_javaScriptExecutor injectJSONText:configJSON
|
2015-07-17 16:05:26 +00:00
|
|
|
asGlobalObjectNamed:@"__fbBatchedBridgeConfig"
|
2015-09-04 10:19:30 +00:00
|
|
|
callback:onComplete];
|
2015-08-07 13:42:34 +00:00
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-10-16 15:10:25 +00:00
|
|
|
- (void)executeSourceCode:(NSData *)sourceCode
|
2015-08-07 13:42:34 +00:00
|
|
|
{
|
2016-03-03 10:20:20 +00:00
|
|
|
if (!_valid || !_javaScriptExecutor) {
|
2015-08-07 13:42:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-25 11:09:00 +00:00
|
|
|
RCTSourceCode *sourceCodeModule = [self moduleForClass:[RCTSourceCode class]];
|
2015-08-08 09:58:30 +00:00
|
|
|
sourceCodeModule.scriptURL = self.bundleURL;
|
2015-10-16 15:10:25 +00:00
|
|
|
sourceCodeModule.scriptData = sourceCode;
|
2015-08-07 13:42:34 +00:00
|
|
|
|
2015-08-08 09:58:30 +00:00
|
|
|
[self enqueueApplicationScript:sourceCode url:self.bundleURL onComplete:^(NSError *loadError) {
|
2016-03-03 10:20:20 +00:00
|
|
|
if (!_valid) {
|
2015-09-24 09:42:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
if (loadError) {
|
2015-09-04 10:19:30 +00:00
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[self stopLoadingWithError:loadError];
|
|
|
|
});
|
2015-08-07 13:42:34 +00:00
|
|
|
return;
|
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-21 18:33:04 +00:00
|
|
|
// Register the display link to start sending js calls after everything is setup
|
2015-12-16 10:49:27 +00:00
|
|
|
NSRunLoop *targetRunLoop = [_javaScriptExecutor isKindOfClass:[RCTJSCExecutor class]] ? [NSRunLoop currentRunLoop] : [NSRunLoop mainRunLoop];
|
2016-03-30 02:51:51 +00:00
|
|
|
[_displayLink addToRunLoop:targetRunLoop];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-21 18:33:04 +00:00
|
|
|
// Perform the state update and notification on the main thread, so we can't run into
|
|
|
|
// timing issues with RCTRootView
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
2015-10-14 16:48:00 +00:00
|
|
|
[self didFinishLoading];
|
2015-12-15 13:42:45 +00:00
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:RCTJavaScriptDidLoadNotification
|
|
|
|
object:_parentBridge userInfo:@{@"bridge": self}];
|
2015-08-21 18:33:04 +00:00
|
|
|
});
|
2015-08-07 13:42:34 +00:00
|
|
|
}];
|
2016-01-04 18:39:07 +00:00
|
|
|
|
|
|
|
#if RCT_DEV
|
|
|
|
|
2016-05-12 10:29:48 +00:00
|
|
|
if ([RCTGetURLQueryParam(self.bundleURL, @"hot") boolValue]) {
|
2016-01-04 18:39:07 +00:00
|
|
|
NSString *path = [self.bundleURL.path substringFromIndex:1]; // strip initial slash
|
2016-02-12 16:09:43 +00:00
|
|
|
NSString *host = self.bundleURL.host;
|
|
|
|
NSNumber *port = self.bundleURL.port;
|
|
|
|
[self enqueueJSCall:@"HMRClient.enable" args:@[@"ios", path, host, RCTNullIfNil(port)]];
|
2016-01-04 18:39:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-10-14 16:48:00 +00:00
|
|
|
- (void)didFinishLoading
|
|
|
|
{
|
2016-04-01 14:24:40 +00:00
|
|
|
RCTPerformanceLoggerEnd(RCTPLBridgeStartup);
|
2015-10-14 16:48:00 +00:00
|
|
|
_loading = NO;
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
2015-12-08 23:57:34 +00:00
|
|
|
for (dispatch_block_t call in _pendingCalls) {
|
|
|
|
call();
|
2015-10-14 16:48:00 +00:00
|
|
|
}
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2015-09-04 10:19:30 +00:00
|
|
|
- (void)stopLoadingWithError:(NSError *)error
|
|
|
|
{
|
|
|
|
RCTAssertMainThread();
|
2015-09-11 13:35:25 +00:00
|
|
|
|
2016-03-03 10:20:20 +00:00
|
|
|
if (!_valid || !_loading) {
|
2015-09-04 10:19:30 +00:00
|
|
|
return;
|
|
|
|
}
|
2015-09-11 13:35:25 +00:00
|
|
|
|
2015-09-04 10:19:30 +00:00
|
|
|
_loading = NO;
|
2016-01-19 22:34:22 +00:00
|
|
|
[_javaScriptExecutor invalidate];
|
2015-09-11 13:35:25 +00:00
|
|
|
|
2015-12-15 13:42:45 +00:00
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:RCTJavaScriptDidFailToLoadNotification
|
|
|
|
object:_parentBridge userInfo:@{@"bridge": self, @"error": error}];
|
|
|
|
|
2016-04-20 16:12:18 +00:00
|
|
|
if ([error userInfo][RCTJSStackTraceKey]) {
|
|
|
|
[self.redBox showErrorMessage:[error localizedDescription]
|
|
|
|
withStack:[error userInfo][RCTJSStackTraceKey]];
|
|
|
|
}
|
2015-11-05 20:19:56 +00:00
|
|
|
RCTFatal(error);
|
2015-09-04 10:19:30 +00:00
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-24 10:14:33 +00:00
|
|
|
RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleURL
|
2015-08-07 13:42:34 +00:00
|
|
|
moduleProvider:(__unused RCTBridgeModuleProviderBlock)block
|
|
|
|
launchOptions:(__unused NSDictionary *)launchOptions)
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
/**
|
|
|
|
* Prevent super from calling setUp (that'd create another batchedBridge)
|
|
|
|
*/
|
|
|
|
- (void)setUp {}
|
|
|
|
- (void)bindKeys {}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (void)reload
|
|
|
|
{
|
|
|
|
[_parentBridge reload];
|
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (Class)executorClass
|
|
|
|
{
|
2015-12-16 10:49:27 +00:00
|
|
|
return _parentBridge.executorClass ?: [RCTJSCExecutor class];
|
2015-08-07 13:42:34 +00:00
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (void)setExecutorClass:(Class)executorClass
|
|
|
|
{
|
|
|
|
RCTAssertMainThread();
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
_parentBridge.executorClass = executorClass;
|
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (NSURL *)bundleURL
|
|
|
|
{
|
|
|
|
return _parentBridge.bundleURL;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setBundleURL:(NSURL *)bundleURL
|
|
|
|
{
|
|
|
|
_parentBridge.bundleURL = bundleURL;
|
|
|
|
}
|
2015-07-14 23:11:42 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (id<RCTBridgeDelegate>)delegate
|
|
|
|
{
|
|
|
|
return _parentBridge.delegate;
|
|
|
|
}
|
2015-07-14 23:11:42 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (BOOL)isLoading
|
|
|
|
{
|
|
|
|
return _loading;
|
|
|
|
}
|
2015-07-28 22:48:46 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (BOOL)isValid
|
|
|
|
{
|
|
|
|
return _valid;
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
|
2015-11-25 11:09:00 +00:00
|
|
|
- (void)dispatchBlock:(dispatch_block_t)block
|
|
|
|
queue:(dispatch_queue_t)queue
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
{
|
2015-11-25 11:09:00 +00:00
|
|
|
if (queue == RCTJSThread) {
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:block];
|
|
|
|
} else if (queue) {
|
|
|
|
dispatch_async(queue, block);
|
2015-08-26 16:28:14 +00:00
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - RCTInvalidating
|
|
|
|
|
|
|
|
- (void)invalidate
|
|
|
|
{
|
2016-03-03 10:20:20 +00:00
|
|
|
if (!_valid) {
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RCTAssertMainThread();
|
2016-01-06 17:02:55 +00:00
|
|
|
RCTAssert(_javaScriptExecutor != nil, @"Can't complete invalidation without a JS executor");
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-21 18:33:04 +00:00
|
|
|
_loading = NO;
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
_valid = NO;
|
2015-08-19 12:27:43 +00:00
|
|
|
if ([RCTBridge currentBridge] == self) {
|
|
|
|
[RCTBridge setCurrentBridge:nil];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
|
2015-07-20 09:34:11 +00:00
|
|
|
// Invalidate modules
|
|
|
|
dispatch_group_t group = dispatch_group_create();
|
2016-04-14 01:26:56 +00:00
|
|
|
for (RCTModuleData *moduleData in _moduleDataByID) {
|
|
|
|
// Be careful when grabbing an instance here, we don't want to instantiate
|
|
|
|
// any modules just to invalidate them.
|
|
|
|
id<RCTBridgeModule> instance = nil;
|
|
|
|
if ([moduleData hasInstance]) {
|
|
|
|
instance = moduleData.instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (instance == _javaScriptExecutor) {
|
2015-07-20 09:34:11 +00:00
|
|
|
continue;
|
|
|
|
}
|
2015-07-08 07:28:54 +00:00
|
|
|
|
2016-04-14 01:26:56 +00:00
|
|
|
if ([instance respondsToSelector:@selector(invalidate)]) {
|
2015-11-25 11:09:00 +00:00
|
|
|
dispatch_group_enter(group);
|
|
|
|
[self dispatchBlock:^{
|
2016-04-14 01:26:56 +00:00
|
|
|
[(id<RCTInvalidating>)instance invalidate];
|
2015-11-25 11:09:00 +00:00
|
|
|
dispatch_group_leave(group);
|
|
|
|
} queue:moduleData.methodQueue];
|
2015-07-20 09:34:11 +00:00
|
|
|
}
|
2015-11-25 11:09:00 +00:00
|
|
|
[moduleData invalidate];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
2015-07-22 17:54:45 +00:00
|
|
|
|
2015-07-20 09:34:11 +00:00
|
|
|
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
2016-03-30 02:51:51 +00:00
|
|
|
[_displayLink invalidate];
|
|
|
|
_displayLink = nil;
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-07-20 09:34:11 +00:00
|
|
|
[_javaScriptExecutor invalidate];
|
|
|
|
_javaScriptExecutor = nil;
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-07-22 17:54:45 +00:00
|
|
|
if (RCTProfileIsProfiling()) {
|
|
|
|
RCTProfileUnhookModules(self);
|
|
|
|
}
|
2016-01-06 17:02:55 +00:00
|
|
|
|
2015-11-25 11:09:00 +00:00
|
|
|
_moduleDataByName = nil;
|
2015-07-27 15:51:28 +00:00
|
|
|
_moduleDataByID = nil;
|
2015-11-25 11:09:00 +00:00
|
|
|
_moduleClassesByID = nil;
|
2016-01-06 17:02:55 +00:00
|
|
|
_pendingCalls = nil;
|
2015-07-22 17:54:45 +00:00
|
|
|
|
2016-02-08 15:06:52 +00:00
|
|
|
if (_flowIDMap != NULL) {
|
|
|
|
CFRelease(_flowIDMap);
|
|
|
|
}
|
2015-07-22 17:54:45 +00:00
|
|
|
}];
|
2015-07-20 09:34:11 +00:00
|
|
|
});
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
|
2015-08-19 12:27:43 +00:00
|
|
|
- (void)logMessage:(NSString *)message level:(NSString *)level
|
|
|
|
{
|
2015-12-23 21:31:44 +00:00
|
|
|
if (RCT_DEBUG && [_javaScriptExecutor isValid]) {
|
2015-12-08 23:57:34 +00:00
|
|
|
[self enqueueJSCall:@"RCTLog.logIfNoNativeHook"
|
|
|
|
args:@[level, message]];
|
2015-08-19 12:27:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
#pragma mark - RCTBridge methods
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Public. Can be invoked from any thread.
|
|
|
|
*/
|
|
|
|
- (void)enqueueJSCall:(NSString *)moduleDotMethod args:(NSArray *)args
|
|
|
|
{
|
2015-12-08 23:57:34 +00:00
|
|
|
/**
|
|
|
|
* AnyThread
|
|
|
|
*/
|
|
|
|
|
2016-05-14 00:14:59 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[RCTBatchedBridge enqueueJSCall:]", nil);
|
2016-02-03 15:10:52 +00:00
|
|
|
|
2015-11-03 22:45:46 +00:00
|
|
|
NSArray<NSString *> *ids = [moduleDotMethod componentsSeparatedByString:@"."];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-12-08 23:57:34 +00:00
|
|
|
NSString *module = ids[0];
|
|
|
|
NSString *method = ids[1];
|
|
|
|
|
|
|
|
RCTProfileBeginFlowEvent();
|
|
|
|
|
|
|
|
__weak RCTBatchedBridge *weakSelf = self;
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
|
|
|
RCTProfileEndFlowEvent();
|
|
|
|
|
|
|
|
RCTBatchedBridge *strongSelf = weakSelf;
|
|
|
|
if (!strongSelf || !strongSelf.valid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strongSelf.loading) {
|
|
|
|
dispatch_block_t pendingCall = ^{
|
|
|
|
[weakSelf _actuallyInvokeAndProcessModule:module method:method arguments:args ?: @[]];
|
|
|
|
};
|
|
|
|
[strongSelf->_pendingCalls addObject:pendingCall];
|
|
|
|
} else {
|
|
|
|
[strongSelf _actuallyInvokeAndProcessModule:module method:method arguments:args ?: @[]];
|
|
|
|
}
|
|
|
|
}];
|
2016-02-03 15:10:52 +00:00
|
|
|
|
2016-05-14 00:14:59 +00:00
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"", nil);
|
2015-12-08 23:57:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called by RCTModuleMethod from any thread.
|
|
|
|
*/
|
|
|
|
- (void)enqueueCallback:(NSNumber *)cbID args:(NSArray *)args
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* AnyThread
|
|
|
|
*/
|
|
|
|
|
|
|
|
RCTProfileBeginFlowEvent();
|
|
|
|
|
|
|
|
__weak RCTBatchedBridge *weakSelf = self;
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
|
|
|
RCTProfileEndFlowEvent();
|
|
|
|
|
|
|
|
RCTBatchedBridge *strongSelf = weakSelf;
|
|
|
|
if (!strongSelf || !strongSelf.valid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (strongSelf.loading) {
|
|
|
|
dispatch_block_t pendingCall = ^{
|
|
|
|
[weakSelf _actuallyInvokeCallback:cbID arguments:args ?: @[]];
|
|
|
|
};
|
|
|
|
[strongSelf->_pendingCalls addObject:pendingCall];
|
|
|
|
} else {
|
|
|
|
[strongSelf _actuallyInvokeCallback:cbID arguments:args];
|
|
|
|
}
|
|
|
|
}];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Private hack to support `setTimeout(fn, 0)`
|
|
|
|
*/
|
|
|
|
- (void)_immediatelyCallTimer:(NSNumber *)timer
|
|
|
|
{
|
|
|
|
RCTAssertJSThread();
|
|
|
|
|
|
|
|
dispatch_block_t block = ^{
|
2015-12-08 23:57:34 +00:00
|
|
|
[self _actuallyInvokeAndProcessModule:@"JSTimersExecution"
|
|
|
|
method:@"callTimers"
|
|
|
|
arguments:@[@[timer]]];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if ([_javaScriptExecutor respondsToSelector:@selector(executeAsyncBlockOnJavaScriptQueue:)]) {
|
|
|
|
[_javaScriptExecutor executeAsyncBlockOnJavaScriptQueue:block];
|
|
|
|
} else {
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:block];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-16 15:10:25 +00:00
|
|
|
- (void)enqueueApplicationScript:(NSData *)script
|
2015-08-20 06:36:11 +00:00
|
|
|
url:(NSURL *)url
|
|
|
|
onComplete:(RCTJavaScriptCompleteBlock)onComplete
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
{
|
|
|
|
RCTAssert(onComplete != nil, @"onComplete block passed in should be non-nil");
|
|
|
|
|
|
|
|
RCTProfileBeginFlowEvent();
|
|
|
|
[_javaScriptExecutor executeApplicationScript:script sourceURL:url onComplete:^(NSError *scriptLoadError) {
|
|
|
|
RCTProfileEndFlowEvent();
|
|
|
|
RCTAssertJSThread();
|
|
|
|
|
|
|
|
if (scriptLoadError) {
|
|
|
|
onComplete(scriptLoadError);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-05-14 00:14:59 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"FetchApplicationScriptCallbacks", nil);
|
2015-12-08 23:57:34 +00:00
|
|
|
[_javaScriptExecutor flushedQueue:^(id json, NSError *error)
|
2015-08-20 06:36:11 +00:00
|
|
|
{
|
2016-05-14 00:14:59 +00:00
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call,init", @{
|
2015-08-20 06:36:11 +00:00
|
|
|
@"json": RCTNullIfNil(json),
|
|
|
|
@"error": RCTNullIfNil(error),
|
|
|
|
});
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-10-19 15:02:50 +00:00
|
|
|
[self handleBuffer:json batchEnded:YES];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-20 06:36:11 +00:00
|
|
|
onComplete(error);
|
|
|
|
}];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Payload Generation
|
|
|
|
|
2015-12-08 23:57:34 +00:00
|
|
|
- (void)_actuallyInvokeAndProcessModule:(NSString *)module
|
|
|
|
method:(NSString *)method
|
|
|
|
arguments:(NSArray *)args
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
{
|
2015-12-08 23:57:34 +00:00
|
|
|
RCTAssertJSThread();
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2016-04-20 16:12:18 +00:00
|
|
|
__weak typeof(self) weakSelf = self;
|
2015-12-08 23:57:34 +00:00
|
|
|
[_javaScriptExecutor callFunctionOnModule:module
|
|
|
|
method:method
|
|
|
|
arguments:args
|
2016-04-20 16:12:18 +00:00
|
|
|
callback:^(id json, NSError *error) {
|
|
|
|
[weakSelf _processResponse:json error:error];
|
|
|
|
}];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
|
2015-12-08 23:57:34 +00:00
|
|
|
- (void)_actuallyInvokeCallback:(NSNumber *)cbID
|
|
|
|
arguments:(NSArray *)args
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
{
|
|
|
|
RCTAssertJSThread();
|
|
|
|
|
2016-04-20 16:12:18 +00:00
|
|
|
__weak typeof(self) weakSelf = self;
|
|
|
|
[_javaScriptExecutor invokeCallbackID:cbID
|
|
|
|
arguments:args
|
|
|
|
callback:^(id json, NSError *error) {
|
|
|
|
[weakSelf _processResponse:json error:error];
|
|
|
|
}];
|
|
|
|
}
|
2015-07-14 23:11:42 +00:00
|
|
|
|
2016-04-20 16:12:18 +00:00
|
|
|
- (void)_processResponse:(id)json error:(NSError *)error
|
|
|
|
{
|
|
|
|
if (error) {
|
|
|
|
if ([error userInfo][RCTJSStackTraceKey]) {
|
|
|
|
[self.redBox showErrorMessage:[error localizedDescription]
|
|
|
|
withStack:[error userInfo][RCTJSStackTraceKey]];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
2016-04-20 16:12:18 +00:00
|
|
|
RCTFatal(error);
|
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2016-04-20 16:12:18 +00:00
|
|
|
if (!_valid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
[self handleBuffer:json batchEnded:YES];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Payload Processing
|
|
|
|
|
2015-10-19 15:02:50 +00:00
|
|
|
- (void)handleBuffer:(id)buffer batchEnded:(BOOL)batchEnded
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
{
|
|
|
|
RCTAssertJSThread();
|
|
|
|
|
2015-10-19 15:02:50 +00:00
|
|
|
if (buffer != nil && buffer != (id)kCFNull) {
|
|
|
|
_wasBatchActive = YES;
|
|
|
|
[self handleBuffer:buffer];
|
2015-12-02 13:12:17 +00:00
|
|
|
[self partialBatchDidFlush];
|
2015-10-19 15:02:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (batchEnded) {
|
|
|
|
if (_wasBatchActive) {
|
|
|
|
[self batchDidComplete];
|
|
|
|
}
|
|
|
|
|
|
|
|
_wasBatchActive = NO;
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
2015-10-19 15:02:50 +00:00
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2016-01-04 10:15:19 +00:00
|
|
|
- (void)handleBuffer:(NSArray *)buffer
|
2015-10-19 15:02:50 +00:00
|
|
|
{
|
2016-01-04 10:15:19 +00:00
|
|
|
NSArray *requestsArray = [RCTConvert NSArray:buffer];
|
2016-02-08 15:06:52 +00:00
|
|
|
|
|
|
|
if (RCT_DEBUG && requestsArray.count <= RCTBridgeFieldParams) {
|
2015-11-03 22:45:46 +00:00
|
|
|
RCTLogError(@"Buffer should contain at least %tu sub-arrays. Only found %tu",
|
2016-02-08 15:06:52 +00:00
|
|
|
RCTBridgeFieldParams + 1, requestsArray.count);
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-04 10:15:19 +00:00
|
|
|
NSArray<NSNumber *> *moduleIDs = [RCTConvert NSNumberArray:requestsArray[RCTBridgeFieldRequestModuleIDs]];
|
|
|
|
NSArray<NSNumber *> *methodIDs = [RCTConvert NSNumberArray:requestsArray[RCTBridgeFieldMethodIDs]];
|
2016-02-08 15:06:52 +00:00
|
|
|
NSArray<NSArray *> *paramsArrays = [RCTConvert NSArrayArray:requestsArray[RCTBridgeFieldParams]];
|
|
|
|
|
|
|
|
int64_t callID = -1;
|
|
|
|
|
|
|
|
if (requestsArray.count > 3) {
|
|
|
|
callID = [requestsArray[RCTBridgeFieldCallID] longLongValue];
|
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-11-03 22:45:46 +00:00
|
|
|
if (RCT_DEBUG && (moduleIDs.count != methodIDs.count || moduleIDs.count != paramsArrays.count)) {
|
|
|
|
RCTLogError(@"Invalid data message - all must be length: %zd", moduleIDs.count);
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-07-27 15:51:28 +00:00
|
|
|
NSMapTable *buckets = [[NSMapTable alloc] initWithKeyOptions:NSPointerFunctionsStrongMemory
|
|
|
|
valueOptions:NSPointerFunctionsStrongMemory
|
2015-11-25 11:09:00 +00:00
|
|
|
capacity:_moduleDataByName.count];
|
2015-11-03 22:45:46 +00:00
|
|
|
|
|
|
|
[moduleIDs enumerateObjectsUsingBlock:^(NSNumber *moduleID, NSUInteger i, __unused BOOL *stop) {
|
|
|
|
RCTModuleData *moduleData = _moduleDataByID[moduleID.integerValue];
|
2015-11-25 11:09:00 +00:00
|
|
|
dispatch_queue_t queue = moduleData.methodQueue;
|
2015-11-03 22:45:46 +00:00
|
|
|
NSMutableOrderedSet<NSNumber *> *set = [buckets objectForKey:queue];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
if (!set) {
|
2015-08-17 14:35:34 +00:00
|
|
|
set = [NSMutableOrderedSet new];
|
2015-09-01 09:18:14 +00:00
|
|
|
[buckets setObject:set forKey:queue];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
[set addObject:@(i)];
|
2015-11-03 22:45:46 +00:00
|
|
|
}];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-11-03 22:45:46 +00:00
|
|
|
for (dispatch_queue_t queue in buckets) {
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
RCTProfileBeginFlowEvent();
|
|
|
|
|
2015-09-01 09:18:14 +00:00
|
|
|
dispatch_block_t block = ^{
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
RCTProfileEndFlowEvent();
|
2016-05-14 00:14:59 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[RCTBatchedBridge handleBuffer:]", nil);
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-09-01 09:18:14 +00:00
|
|
|
NSOrderedSet *calls = [buckets objectForKey:queue];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
@autoreleasepool {
|
|
|
|
for (NSNumber *indexObj in calls) {
|
|
|
|
NSUInteger index = indexObj.unsignedIntegerValue;
|
2016-03-30 15:07:23 +00:00
|
|
|
if (RCT_DEV && callID != -1 && _flowIDMap != NULL && RCTProfileIsProfiling()) {
|
|
|
|
[self.flowIDMapLock lock];
|
2016-02-08 15:06:52 +00:00
|
|
|
int64_t newFlowID = (int64_t)CFDictionaryGetValue(_flowIDMap, (const void *)(_flowID + index));
|
|
|
|
_RCTProfileEndFlowEvent(@(newFlowID));
|
|
|
|
CFDictionaryRemoveValue(_flowIDMap, (const void *)(_flowID + index));
|
2016-03-30 15:07:23 +00:00
|
|
|
[self.flowIDMapLock unlock];
|
2016-02-08 15:06:52 +00:00
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
[self _handleRequestNumber:index
|
|
|
|
moduleID:[moduleIDs[index] integerValue]
|
|
|
|
methodID:[methodIDs[index] integerValue]
|
2015-07-14 23:16:21 +00:00
|
|
|
params:paramsArrays[index]];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
}
|
2015-07-27 15:51:28 +00:00
|
|
|
|
2016-05-14 00:14:59 +00:00
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"objc_call,dispatch_async", @{
|
2015-08-20 06:36:11 +00:00
|
|
|
@"calls": @(calls.count),
|
|
|
|
});
|
2015-09-01 09:18:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (queue == RCTJSThread) {
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:block];
|
|
|
|
} else if (queue) {
|
|
|
|
dispatch_async(queue, block);
|
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
2016-02-08 15:06:52 +00:00
|
|
|
|
|
|
|
_flowID = callID;
|
2015-10-19 15:02:50 +00:00
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-12-02 13:12:17 +00:00
|
|
|
- (void)partialBatchDidFlush
|
|
|
|
{
|
|
|
|
for (RCTModuleData *moduleData in _moduleDataByID) {
|
2015-12-03 11:19:45 +00:00
|
|
|
if (moduleData.implementsPartialBatchDidFlush) {
|
2015-12-02 13:12:17 +00:00
|
|
|
[self dispatchBlock:^{
|
|
|
|
[moduleData.instance partialBatchDidFlush];
|
|
|
|
} queue:moduleData.methodQueue];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-19 15:02:50 +00:00
|
|
|
- (void)batchDidComplete
|
|
|
|
{
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
// TODO: batchDidComplete is only used by RCTUIManager - can we eliminate this special case?
|
2015-07-27 15:51:28 +00:00
|
|
|
for (RCTModuleData *moduleData in _moduleDataByID) {
|
2015-12-03 11:19:45 +00:00
|
|
|
if (moduleData.implementsBatchDidComplete) {
|
2015-11-25 11:09:00 +00:00
|
|
|
[self dispatchBlock:^{
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
[moduleData.instance batchDidComplete];
|
2015-11-25 11:09:00 +00:00
|
|
|
} queue:moduleData.methodQueue];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)_handleRequestNumber:(NSUInteger)i
|
|
|
|
moduleID:(NSUInteger)moduleID
|
|
|
|
methodID:(NSUInteger)methodID
|
|
|
|
params:(NSArray *)params
|
|
|
|
{
|
2016-03-03 10:20:20 +00:00
|
|
|
if (!_valid) {
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RCT_DEBUG && ![params isKindOfClass:[NSArray class]]) {
|
|
|
|
RCTLogError(@"Invalid module/method/params tuple for request #%zd", i);
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2015-07-27 15:51:28 +00:00
|
|
|
RCTModuleData *moduleData = _moduleDataByID[moduleID];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
if (RCT_DEBUG && !moduleData) {
|
|
|
|
RCTLogError(@"No module found for id '%zd'", moduleID);
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2015-09-18 22:01:21 +00:00
|
|
|
id<RCTBridgeMethod> method = moduleData.methods[methodID];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
if (RCT_DEBUG && !method) {
|
|
|
|
RCTLogError(@"Unknown methodID: %zd for module: %zd (%@)", methodID, moduleID, moduleData.name);
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
@try {
|
2015-07-14 23:16:21 +00:00
|
|
|
[method invokeWithBridge:self module:moduleData.instance arguments:params];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
@catch (NSException *exception) {
|
2015-11-05 20:19:56 +00:00
|
|
|
// Pass on JS exceptions
|
2015-11-23 22:47:36 +00:00
|
|
|
if ([exception.name hasPrefix:RCTFatalExceptionName]) {
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
@throw exception;
|
|
|
|
}
|
|
|
|
|
2015-11-05 20:19:56 +00:00
|
|
|
NSString *message = [NSString stringWithFormat:
|
2015-11-24 20:10:48 +00:00
|
|
|
@"Exception '%@' was thrown while invoking %@ on target %@ with params %@",
|
|
|
|
exception, method.JSMethodName, moduleData.name, params];
|
2015-11-05 20:19:56 +00:00
|
|
|
RCTFatal(RCTErrorWithMessage(message));
|
|
|
|
}
|
2015-09-18 22:01:21 +00:00
|
|
|
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)startProfiling
|
|
|
|
{
|
|
|
|
RCTAssertMainThread();
|
|
|
|
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
|
|
|
RCTProfileInit(self);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2015-10-12 16:42:21 +00:00
|
|
|
- (void)stopProfiling:(void (^)(NSData *))callback
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
{
|
|
|
|
RCTAssertMainThread();
|
|
|
|
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
2015-11-04 17:00:01 +00:00
|
|
|
RCTProfileEnd(self, ^(NSString *log) {
|
|
|
|
NSData *logData = [log dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
callback(logData);
|
|
|
|
});
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2015-12-11 14:54:56 +00:00
|
|
|
- (BOOL)isBatchActive
|
|
|
|
{
|
|
|
|
return _wasBatchActive;
|
|
|
|
}
|
|
|
|
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
@end
|