[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() \
|
2016-07-07 19:36:56 +00:00
|
|
|
RCTAssert(![NSStringFromClass([self->_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;
|
2016-08-05 18:19:11 +00:00
|
|
|
NSDictionary<NSString *, RCTModuleData *> *_moduleDataByName;
|
2015-11-25 11:09:00 +00:00
|
|
|
NSArray<RCTModuleData *> *_moduleDataByID;
|
|
|
|
NSArray<Class> *_moduleClassesByID;
|
2016-08-05 18:19:11 +00:00
|
|
|
NSUInteger _modulesInitializedOnMainQueue;
|
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-07-22 16:50:48 +00:00
|
|
|
@synthesize performanceLogger = _performanceLogger;
|
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);
|
|
|
|
|
2016-07-12 12:51:56 +00:00
|
|
|
if (self = [super initWithDelegate:bridge.delegate
|
|
|
|
bundleURL:bridge.bundleURL
|
|
|
|
moduleProvider:bridge.moduleProvider
|
|
|
|
launchOptions:bridge.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
|
|
|
_parentBridge = bridge;
|
|
|
|
|
2016-08-31 23:08:55 +00:00
|
|
|
RCTLogInfo(@"Initializing %@ (parent: %@, executor: %@)", self, bridge, [self executorClass]);
|
|
|
|
|
2016-07-22 16:50:48 +00:00
|
|
|
_performanceLogger = [RCTPerformanceLogger new];
|
|
|
|
[_performanceLogger markStartForTag:RCTPLBridgeStartup];
|
|
|
|
[_performanceLogger markStartForTag:RCTPLTTI];
|
|
|
|
|
[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 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;
|
|
|
|
}
|
|
|
|
|
2016-07-12 12:51:56 +00:00
|
|
|
RCT_NOT_IMPLEMENTED(- (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)delegate
|
|
|
|
bundleURL:(NSURL *)bundleURL
|
|
|
|
moduleProvider:(RCTBridgeModuleProviderBlock)block
|
|
|
|
launchOptions:(NSDictionary *)launchOptions)
|
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (void)start
|
|
|
|
{
|
2016-08-05 18:19:11 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(0, @"-[RCTBatchedBridge setUp]", nil);
|
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
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;
|
2016-07-12 12:51:56 +00:00
|
|
|
[self loadSource:^(NSError *error, NSData *source, __unused int64_t sourceLength) {
|
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
|
|
|
|
2016-07-07 14:20:03 +00:00
|
|
|
RCTPerformanceLogger *performanceLogger = self->_performanceLogger;
|
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-07-07 14:20:03 +00:00
|
|
|
[performanceLogger markStartForTag:RCTPLJSCExecutorSetup];
|
2015-11-25 11:09:00 +00:00
|
|
|
[weakSelf setUpExecutor];
|
2016-07-07 14:20:03 +00:00
|
|
|
[performanceLogger markStopForTag: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) {
|
2016-08-05 18:19:11 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(0, @"-[RCTBatchedBridge moduleConfig", nil);
|
2016-07-07 14:20:03 +00:00
|
|
|
[performanceLogger markStartForTag:RCTPLNativeModulePrepareConfig];
|
2015-08-07 13:42:34 +00:00
|
|
|
config = [weakSelf moduleConfig];
|
2016-07-07 14:20:03 +00:00
|
|
|
[performanceLogger markStopForTag:RCTPLNativeModulePrepareConfig];
|
2016-09-05 18:11:37 +00:00
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
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.
|
2016-07-07 14:20:03 +00:00
|
|
|
[performanceLogger markStartForTag:RCTPLNativeModuleInjectConfig];
|
2015-09-04 10:19:30 +00:00
|
|
|
[weakSelf injectJSONConfiguration:config onComplete:^(NSError *error) {
|
2016-07-07 14:20:03 +00:00
|
|
|
[performanceLogger markStopForTag: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
|
|
|
}
|
|
|
|
});
|
2016-08-05 18:19:11 +00:00
|
|
|
|
2016-09-05 18:11:37 +00:00
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
[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
|
|
|
{
|
2016-07-07 14:20:03 +00:00
|
|
|
[_performanceLogger markStartForTag:RCTPLScriptDownload];
|
2015-11-27 16:36:00 +00:00
|
|
|
|
2016-07-07 14:20:03 +00:00
|
|
|
RCTPerformanceLogger *performanceLogger = _performanceLogger;
|
|
|
|
RCTSourceLoadBlock onSourceLoad = ^(NSError *error, NSData *source, int64_t sourceLength) {
|
|
|
|
[performanceLogger markStopForTag:RCTPLScriptDownload];
|
|
|
|
[performanceLogger setValue:sourceLength forTag:RCTPLBundleSize];
|
|
|
|
_onSourceLoad(error, source, sourceLength);
|
2015-08-21 18:33:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if ([self.delegate respondsToSelector:@selector(loadSourceForBridge:withBlock:)]) {
|
|
|
|
[self.delegate loadSourceForBridge:_parentBridge withBlock:onSourceLoad];
|
2016-07-11 20:16:09 +00:00
|
|
|
} else {
|
|
|
|
RCTAssert(self.bundleURL, @"bundleURL must be non-nil when not implementing loadSourceForBridge");
|
|
|
|
|
2016-07-07 14:20:03 +00:00
|
|
|
[RCTJavaScriptLoader loadBundleAtURL:self.bundleURL onComplete:^(NSError *error, NSData *source, int64_t sourceLength) {
|
2016-05-25 17:17:36 +00:00
|
|
|
if (error && [self.delegate respondsToSelector:@selector(fallbackSourceURLForBridge:)]) {
|
2016-07-07 19:36:56 +00:00
|
|
|
NSURL *fallbackURL = [self.delegate fallbackSourceURLForBridge:self->_parentBridge];
|
2016-05-25 17:17:36 +00:00
|
|
|
if (fallbackURL && ![fallbackURL isEqual:self.bundleURL]) {
|
|
|
|
RCTLogError(@"Failed to load bundle(%@) with error:(%@)", self.bundleURL, error.localizedDescription);
|
|
|
|
self.bundleURL = fallbackURL;
|
|
|
|
[RCTJavaScriptLoader loadBundleAtURL:self.bundleURL onComplete:onSourceLoad];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2016-07-07 14:20:03 +00:00
|
|
|
onSourceLoad(error, source, sourceLength);
|
2016-05-25 17:17:36 +00:00
|
|
|
}];
|
2015-08-21 18:33:04 +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-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) {
|
2016-08-05 18:19:11 +00:00
|
|
|
#if RCT_DEV
|
|
|
|
if ([self.delegate respondsToSelector:@selector(whitelistedModulesForBridge:)]) {
|
|
|
|
NSArray *whitelisted = [self.delegate whitelistedModulesForBridge:self];
|
|
|
|
RCTAssert(!whitelisted || [whitelisted containsObject:[moduleData moduleClass]],
|
|
|
|
@"Required config for %@, which was not whitelisted", moduleName);
|
|
|
|
}
|
|
|
|
#endif
|
2015-12-10 12:27:45 +00:00
|
|
|
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
|
|
|
{
|
2016-08-05 18:19:11 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(0, @"-[RCTBatchedBridge initModules]", nil);
|
2016-07-07 14:20:03 +00:00
|
|
|
[_performanceLogger markStartForTag: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-08-29 19:07:28 +00:00
|
|
|
static dispatch_once_t onceToken;
|
|
|
|
dispatch_once(&onceToken, ^{
|
|
|
|
if (RCT_DEBUG && !RCTRunningInTestEnvironment()) {
|
|
|
|
// Check for unexported modules
|
|
|
|
Class *classes;
|
|
|
|
unsigned int classCount;
|
2016-03-03 10:20:20 +00:00
|
|
|
classes = objc_copyClassList(&classCount);
|
2015-11-25 11:09:00 +00:00
|
|
|
|
2016-08-29 19:07:28 +00:00
|
|
|
NSMutableSet *moduleClasses = [NSMutableSet new];
|
|
|
|
[moduleClasses addObjectsFromArray:RCTGetModuleClasses()];
|
|
|
|
[moduleClasses addObjectsFromArray:[extraModules valueForKeyPath:@"class"]];
|
2016-03-03 10:20:20 +00:00
|
|
|
|
2016-08-29 19:07:28 +00:00
|
|
|
for (unsigned int i = 0; i < classCount; i++)
|
2016-03-03 10:20:20 +00:00
|
|
|
{
|
2016-08-29 19:07:28 +00:00
|
|
|
Class cls = classes[i];
|
|
|
|
Class superclass = cls;
|
|
|
|
while (superclass)
|
2016-03-03 10:20:20 +00:00
|
|
|
{
|
2016-08-29 19:07:28 +00:00
|
|
|
if (class_conformsToProtocol(superclass, @protocol(RCTBridgeModule)))
|
|
|
|
{
|
|
|
|
if (![moduleClasses containsObject:cls] &&
|
|
|
|
![cls respondsToSelector:@selector(moduleName)]) {
|
|
|
|
RCTLogWarn(@"Class %@ was not exported. Did you forget to use "
|
|
|
|
"RCT_EXPORT_MODULE()?", cls);
|
|
|
|
}
|
|
|
|
break;
|
2016-03-03 10:20:20 +00:00
|
|
|
}
|
2016-08-29 19:07:28 +00:00
|
|
|
superclass = class_getSuperclass(superclass);
|
2015-11-25 11:09:00 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-08-29 19:07:28 +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
|
2016-08-05 18:19:11 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(0, @"extraModules", nil);
|
2016-03-03 10:20:20 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2016-09-05 18:11:37 +00:00
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
2016-04-27 16:08:51 +00:00
|
|
|
|
|
|
|
// 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]
|
2016-08-05 18:19:11 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(0, @"JavaScriptExecutor", nil);
|
2016-04-27 16:08:51 +00:00
|
|
|
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
|
|
|
}
|
2016-09-05 18:11:37 +00:00
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
2016-03-03 10:20:20 +00:00
|
|
|
|
|
|
|
// Set up moduleData for automatically-exported modules
|
2016-08-05 18:19:11 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(0, @"ModuleData", nil);
|
2016-03-03 10:20:20 +00:00
|
|
|
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];
|
2016-09-05 18:11:37 +00:00
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
[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
|
2016-08-05 18:19:11 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(0, @"extraModules", nil);
|
2015-11-25 11:09:00 +00:00
|
|
|
for (RCTModuleData *moduleData in _moduleDataByID) {
|
2016-04-27 16:08:51 +00:00
|
|
|
if (moduleData.hasInstance &&
|
2016-06-06 14:57:55 +00:00
|
|
|
(!moduleData.requiresMainQueueSetup || RCTIsMainQueue())) {
|
2016-04-27 16:08:51 +00:00
|
|
|
// 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
|
|
|
}
|
2016-09-05 18:11:37 +00:00
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
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;
|
|
|
|
|
2016-08-05 18:19:11 +00:00
|
|
|
[self prepareModulesWithDispatchGroup:dispatchGroup];
|
|
|
|
|
|
|
|
[_performanceLogger markStopForTag:RCTPLNativeModuleInit];
|
2016-09-05 18:11:37 +00:00
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
2016-08-05 18:19:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)prepareModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup
|
|
|
|
{
|
|
|
|
RCT_PROFILE_BEGIN_EVENT(0, @"-[RCTBatchedBridge prepareModulesWithDispatch]", nil);
|
|
|
|
|
|
|
|
NSArray<Class> *whitelistedModules = nil;
|
|
|
|
if ([self.delegate respondsToSelector:@selector(whitelistedModulesForBridge:)]) {
|
|
|
|
whitelistedModules = [self.delegate whitelistedModulesForBridge:self];
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL initializeImmediately = NO;
|
|
|
|
if (dispatchGroup == NULL) {
|
|
|
|
// If no dispatchGroup is passed in, we must prepare everything immediately.
|
|
|
|
// We better be on the right thread too.
|
|
|
|
RCTAssertMainQueue();
|
|
|
|
initializeImmediately = YES;
|
|
|
|
} else if ([self.delegate respondsToSelector:@selector(shouldBridgeInitializeNativeModulesSynchronously:)]) {
|
|
|
|
initializeImmediately = [self.delegate shouldBridgeInitializeNativeModulesSynchronously:self];
|
|
|
|
}
|
|
|
|
|
2016-03-07 17:30:20 +00:00
|
|
|
// Set up modules that require main thread init or constants export
|
2016-07-07 14:20:03 +00:00
|
|
|
[_performanceLogger setValue:0 forTag:RCTPLNativeModuleMainThread];
|
2016-03-07 17:30:20 +00:00
|
|
|
for (RCTModuleData *moduleData in _moduleDataByID) {
|
2016-08-05 18:19:11 +00:00
|
|
|
if (whitelistedModules && ![whitelistedModules containsObject:[moduleData moduleClass]]) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-06-06 14:57:55 +00:00
|
|
|
if (moduleData.requiresMainQueueSetup || 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.
|
2016-08-05 18:19:11 +00:00
|
|
|
dispatch_block_t block = ^{
|
|
|
|
if (self.valid) {
|
|
|
|
[self->_performanceLogger appendStartForTag:RCTPLNativeModuleMainThread];
|
|
|
|
(void)[moduleData instance];
|
|
|
|
[moduleData gatherConstants];
|
|
|
|
[self->_performanceLogger appendStopForTag:RCTPLNativeModuleMainThread];
|
2016-03-03 10:20:20 +00:00
|
|
|
}
|
2016-08-05 18:19:11 +00:00
|
|
|
};
|
2016-07-07 14:20:03 +00:00
|
|
|
|
2016-08-05 18:19:11 +00:00
|
|
|
if (initializeImmediately && RCTIsMainQueue()) {
|
|
|
|
block();
|
|
|
|
} else {
|
|
|
|
// We've already checked that dispatchGroup is non-null, but this satisifies the
|
|
|
|
// Xcode analyzer
|
|
|
|
if (dispatchGroup) {
|
|
|
|
dispatch_group_async(dispatchGroup, dispatch_get_main_queue(), block);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_modulesInitializedOnMainQueue++;
|
2016-02-29 17:47:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-05 18:19:11 +00:00
|
|
|
[_performanceLogger setValue:_modulesInitializedOnMainQueue forTag:RCTPLNativeModuleMainThreadUsesCount];
|
2016-09-05 18:11:37 +00:00
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
2016-08-05 18:19:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)whitelistedModulesDidChange
|
|
|
|
{
|
|
|
|
RCTAssertMainQueue();
|
|
|
|
[self prepareModulesWithDispatchGroup:NULL];
|
[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-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-07-07 19:36:56 +00:00
|
|
|
if (!self->_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
|
2016-07-07 19:36:56 +00:00
|
|
|
NSRunLoop *targetRunLoop = [self->_javaScriptExecutor isKindOfClass:[RCTJSCExecutor class]] ? [NSRunLoop currentRunLoop] : [NSRunLoop mainRunLoop];
|
|
|
|
[self->_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
|
|
|
|
2016-07-11 20:15:59 +00:00
|
|
|
// Perform the notification on the main thread, so we can't run into
|
2015-08-21 18:33:04 +00:00
|
|
|
// timing issues with RCTRootView
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
2015-12-15 13:42:45 +00:00
|
|
|
[[NSNotificationCenter defaultCenter]
|
|
|
|
postNotificationName:RCTJavaScriptDidLoadNotification
|
2016-07-07 19:36:56 +00:00
|
|
|
object:self->_parentBridge userInfo:@{@"bridge": self}];
|
2015-08-21 18:33:04 +00:00
|
|
|
});
|
2016-07-11 20:15:59 +00:00
|
|
|
|
2016-07-11 20:16:09 +00:00
|
|
|
[self _flushPendingCalls];
|
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;
|
2016-08-02 18:06:19 +00:00
|
|
|
[self enqueueJSCall:@"HMRClient"
|
|
|
|
method:@"enable"
|
|
|
|
args:@[@"ios", path, host, RCTNullIfNil(port)]
|
|
|
|
completion:NULL];
|
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
|
|
|
|
2016-07-11 20:16:09 +00:00
|
|
|
- (void)_flushPendingCalls
|
2015-10-14 16:48:00 +00:00
|
|
|
{
|
2016-07-11 20:16:09 +00:00
|
|
|
RCTAssertJSThread();
|
2016-07-07 14:20:03 +00:00
|
|
|
[_performanceLogger markStopForTag:RCTPLBridgeStartup];
|
2016-07-11 20:15:59 +00:00
|
|
|
|
2016-07-11 20:16:10 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(0, @"Processing pendingCalls", @{ @"count": @(_pendingCalls.count) });
|
2016-07-11 20:16:09 +00:00
|
|
|
_loading = NO;
|
2016-07-11 20:16:10 +00:00
|
|
|
NSArray *pendingCalls = _pendingCalls;
|
|
|
|
_pendingCalls = nil;
|
|
|
|
for (dispatch_block_t call in pendingCalls) {
|
2016-07-11 20:16:09 +00:00
|
|
|
call();
|
|
|
|
}
|
2016-09-05 18:11:37 +00:00
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
2015-10-14 16:48:00 +00:00
|
|
|
}
|
|
|
|
|
2015-09-04 10:19:30 +00:00
|
|
|
- (void)stopLoadingWithError:(NSError *)error
|
|
|
|
{
|
2016-06-06 14:57:55 +00:00
|
|
|
RCTAssertMainQueue();
|
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
|
|
|
|
{
|
2016-06-06 14:57:55 +00:00
|
|
|
RCTAssertMainQueue();
|
[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) {
|
2016-07-18 14:12:19 +00:00
|
|
|
RCTProfileBeginFlowEvent();
|
|
|
|
RCTAssert(_javaScriptExecutor != nil, @"Need JS executor to schedule JS work");
|
|
|
|
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
|
|
|
RCTProfileEndFlowEvent();
|
|
|
|
|
2016-08-05 18:19:11 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(0, @"-[RCTBatchedBridge dispatchBlock", @{ @"loading": @(self.loading) });
|
2016-07-18 14:12:19 +00:00
|
|
|
|
2016-08-05 18:19:11 +00:00
|
|
|
if (self.loading) {
|
|
|
|
RCTAssert(self->_pendingCalls != nil, @"Can't add pending call, bridge is no longer loading");
|
|
|
|
[self->_pendingCalls addObject:block];
|
2016-07-18 14:12:19 +00:00
|
|
|
} else {
|
|
|
|
block();
|
|
|
|
}
|
2016-08-05 18:19:11 +00:00
|
|
|
|
2016-09-05 18:11:37 +00:00
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
2016-07-18 14:12:19 +00:00
|
|
|
}];
|
2015-11-25 11:09:00 +00:00
|
|
|
} 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;
|
|
|
|
}
|
|
|
|
|
2016-06-06 14:57:55 +00:00
|
|
|
RCTAssertMainQueue();
|
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(), ^{
|
2016-07-07 19:36:56 +00:00
|
|
|
[self->_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
|
|
|
[self->_displayLink invalidate];
|
|
|
|
self->_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
|
|
|
|
2016-07-07 19:36:56 +00:00
|
|
|
[self->_javaScriptExecutor invalidate];
|
|
|
|
self->_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
|
|
|
|
2016-07-07 19:36:56 +00:00
|
|
|
self->_moduleDataByName = nil;
|
|
|
|
self->_moduleDataByID = nil;
|
|
|
|
self->_moduleClassesByID = nil;
|
|
|
|
self->_pendingCalls = nil;
|
2015-07-22 17:54:45 +00:00
|
|
|
|
2016-07-07 19:36:56 +00:00
|
|
|
if (self->_flowIDMap != NULL) {
|
|
|
|
CFRelease(self->_flowIDMap);
|
2016-02-08 15:06:52 +00:00
|
|
|
}
|
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]) {
|
2016-08-02 18:06:19 +00:00
|
|
|
[self enqueueJSCall:@"RCTLog"
|
|
|
|
method:@"logIfNoNativeHook"
|
|
|
|
args:@[level, message]
|
|
|
|
completion:NULL];
|
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.
|
|
|
|
*/
|
2016-07-18 14:12:22 +00:00
|
|
|
- (void)enqueueJSCall:(NSString *)module method:(NSString *)method args:(NSArray *)args completion:(dispatch_block_t)completion
|
[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
|
|
|
/**
|
|
|
|
* AnyThread
|
|
|
|
*/
|
2016-07-18 14:12:19 +00:00
|
|
|
if (!_valid) {
|
|
|
|
return;
|
|
|
|
}
|
2016-02-03 15:10:52 +00:00
|
|
|
|
2016-08-05 18:19:11 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[RCTBatchedBridge enqueueJSCall:]", nil);
|
2016-07-18 14:12:19 +00:00
|
|
|
__weak __typeof(self) weakSelf = self;
|
|
|
|
[self dispatchBlock:^{
|
|
|
|
[weakSelf _actuallyInvokeAndProcessModule:module method:method arguments:args ?: @[]];
|
2016-07-18 14:12:22 +00:00
|
|
|
if (completion) {
|
|
|
|
completion();
|
|
|
|
}
|
2016-07-18 14:12:19 +00:00
|
|
|
} queue:RCTJSThread];
|
2016-09-05 18:11:37 +00:00
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
2015-12-08 23:57:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called by RCTModuleMethod from any thread.
|
|
|
|
*/
|
|
|
|
- (void)enqueueCallback:(NSNumber *)cbID args:(NSArray *)args
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* AnyThread
|
|
|
|
*/
|
2016-07-18 14:12:19 +00:00
|
|
|
if (!_valid) {
|
|
|
|
return;
|
|
|
|
}
|
2015-12-08 23:57:34 +00:00
|
|
|
|
2016-07-18 14:12:19 +00:00
|
|
|
__weak __typeof(self) weakSelf = self;
|
|
|
|
[self dispatchBlock:^{
|
|
|
|
[weakSelf _actuallyInvokeCallback:cbID arguments:args];
|
|
|
|
} queue:RCTJSThread];
|
[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();
|
2016-07-07 20:31:24 +00:00
|
|
|
[_javaScriptExecutor executeAsyncBlockOnJavaScriptQueue:^{
|
2015-12-08 23:57:34 +00:00
|
|
|
[self _actuallyInvokeAndProcessModule:@"JSTimersExecution"
|
|
|
|
method:@"callTimers"
|
|
|
|
arguments:@[@[timer]]];
|
2016-07-07 20:31:24 +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)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);
|
2016-07-07 19:36:56 +00:00
|
|
|
[self->_javaScriptExecutor flushedQueue:^(id json, NSError *error)
|
2015-08-20 06:36:11 +00:00
|
|
|
{
|
2016-09-05 18:11:37 +00:00
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"js_call,init");
|
2015-10-19 15:02:50 +00:00
|
|
|
[self handleBuffer:json batchEnded:YES];
|
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-08-05 18:19:11 +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-08-05 18:19:11 +00:00
|
|
|
__weak __typeof(self) weakSelf = self;
|
2016-04-20 16:12:18 +00:00
|
|
|
[_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) {
|
2016-07-07 19:36:56 +00:00
|
|
|
RCTModuleData *moduleData = self->_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();
|
|
|
|
|
2015-09-01 09:18:14 +00:00
|
|
|
NSOrderedSet *calls = [buckets objectForKey:queue];
|
2016-09-05 18:11:37 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(RCTProfileTagAlways, @"-[RCTBatchedBridge handleBuffer:]", (@{
|
|
|
|
@"calls": @(calls.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
|
|
|
@autoreleasepool {
|
|
|
|
for (NSNumber *indexObj in calls) {
|
|
|
|
NSUInteger index = indexObj.unsignedIntegerValue;
|
2016-08-02 06:51:28 +00:00
|
|
|
#if RCT_PROFILE
|
2016-07-07 19:36:56 +00:00
|
|
|
if (RCT_DEV && callID != -1 && self->_flowIDMap != NULL && RCTProfileIsProfiling()) {
|
2016-03-30 15:07:23 +00:00
|
|
|
[self.flowIDMapLock lock];
|
2016-07-07 19:36:56 +00:00
|
|
|
int64_t newFlowID = (int64_t)CFDictionaryGetValue(self->_flowIDMap, (const void *)(self->_flowID + index));
|
2016-02-08 15:06:52 +00:00
|
|
|
_RCTProfileEndFlowEvent(@(newFlowID));
|
2016-07-07 19:36:56 +00:00
|
|
|
CFDictionaryRemoveValue(self->_flowIDMap, (const void *)(self->_flowID + index));
|
2016-03-30 15:07:23 +00:00
|
|
|
[self.flowIDMapLock unlock];
|
2016-02-08 15:06:52 +00:00
|
|
|
}
|
2016-08-02 06:51:28 +00:00
|
|
|
#endif
|
2016-09-05 14:32:20 +00:00
|
|
|
[self callNativeModule:[moduleIDs[index] integerValue]
|
|
|
|
method:[methodIDs[index] integerValue]
|
|
|
|
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-09-05 18:11:37 +00:00
|
|
|
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"objc_call,dispatch_async");
|
2015-09-01 09:18:14 +00:00
|
|
|
};
|
|
|
|
|
2016-07-18 14:12:19 +00:00
|
|
|
[self dispatchBlock:block queue: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
|
|
|
}
|
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) {
|
2016-08-05 18:19:11 +00:00
|
|
|
if (moduleData.hasInstance && 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) {
|
2016-08-05 18:19:11 +00:00
|
|
|
if (moduleData.hasInstance && 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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-05 14:32:20 +00:00
|
|
|
- (id)callNativeModule:(NSUInteger)moduleID
|
|
|
|
method:(NSUInteger)methodID
|
|
|
|
params:(NSArray *)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
|
|
|
{
|
2016-03-03 10:20:20 +00:00
|
|
|
if (!_valid) {
|
2016-09-05 14:32:20 +00:00
|
|
|
return 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-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 {
|
2016-09-05 14:32:20 +00:00
|
|
|
return [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));
|
2016-09-05 14:32:20 +00:00
|
|
|
return nil;
|
2015-11-05 20:19:56 +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
|
|
|
}
|
|
|
|
|
|
|
|
- (void)startProfiling
|
|
|
|
{
|
2016-06-06 14:57:55 +00:00
|
|
|
RCTAssertMainQueue();
|
[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 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
|
|
|
{
|
2016-06-06 14:57:55 +00:00
|
|
|
RCTAssertMainQueue();
|
[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 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
|