[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-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"
|
|
|
|
#import "RCTContextExecutor.h"
|
|
|
|
#import "RCTFrameUpdate.h"
|
|
|
|
#import "RCTJavaScriptLoader.h"
|
|
|
|
#import "RCTLog.h"
|
|
|
|
#import "RCTModuleData.h"
|
2015-07-27 15:51:28 +00:00
|
|
|
#import "RCTModuleMap.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 "RCTPerformanceLogger.h"
|
|
|
|
#import "RCTProfile.h"
|
|
|
|
#import "RCTSourceCode.h"
|
|
|
|
#import "RCTSparseArray.h"
|
|
|
|
#import "RCTUtils.h"
|
|
|
|
|
|
|
|
#define RCTAssertJSThread() \
|
|
|
|
RCTAssert(![NSStringFromClass([_javaScriptExecutor class]) isEqualToString:@"RCTContextExecutor"] || \
|
|
|
|
[[[NSThread currentThread] name] isEqualToString:@"com.facebook.React.JavaScript"], \
|
|
|
|
@"This method must be called on JS thread")
|
|
|
|
|
|
|
|
NSString *const RCTEnqueueNotification = @"RCTEnqueueNotification";
|
|
|
|
NSString *const RCTDequeueNotification = @"RCTDequeueNotification";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Must be kept in sync with `MessageQueue.js`.
|
|
|
|
*/
|
|
|
|
typedef NS_ENUM(NSUInteger, RCTBridgeFields) {
|
|
|
|
RCTBridgeFieldRequestModuleIDs = 0,
|
|
|
|
RCTBridgeFieldMethodIDs,
|
|
|
|
RCTBridgeFieldParamss,
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
2015-08-19 12:27:43 +00:00
|
|
|
@interface RCTBridge ()
|
|
|
|
|
|
|
|
+ (instancetype)currentBridge;
|
|
|
|
+ (void)setCurrentBridge:(RCTBridge *)bridge;
|
|
|
|
|
|
|
|
@end
|
[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
|
|
|
|
|
|
|
@interface RCTBatchedBridge : RCTBridge
|
|
|
|
|
|
|
|
@property (nonatomic, weak) RCTBridge *parentBridge;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation RCTBatchedBridge
|
|
|
|
{
|
|
|
|
BOOL _loading;
|
2015-08-14 08:59:42 +00:00
|
|
|
BOOL _valid;
|
2015-10-19 15:02:50 +00:00
|
|
|
BOOL _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
|
|
|
__weak id<RCTJavaScriptExecutor> _javaScriptExecutor;
|
2015-11-03 22:45:46 +00:00
|
|
|
NSMutableArray<NSArray *> *_pendingCalls;
|
|
|
|
NSMutableArray<RCTModuleData *> *_moduleDataByID;
|
2015-07-27 15:51:28 +00:00
|
|
|
RCTModuleMap *_modulesByName;
|
[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
|
|
|
CADisplayLink *_jsDisplayLink;
|
2015-11-03 22:45:46 +00:00
|
|
|
NSMutableSet<RCTModuleData *> *_frameUpdateObservers;
|
[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
|
|
|
|
{
|
|
|
|
RCTAssertMainThread();
|
|
|
|
RCTAssertParam(bridge);
|
|
|
|
|
|
|
|
if ((self = [super initWithBundleURL:bridge.bundleURL
|
|
|
|
moduleProvider:bridge.moduleProvider
|
|
|
|
launchOptions:bridge.launchOptions])) {
|
|
|
|
|
|
|
|
_parentBridge = bridge;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set Initial State
|
|
|
|
*/
|
|
|
|
_valid = YES;
|
|
|
|
_loading = YES;
|
2015-10-14 16:48:00 +00:00
|
|
|
_pendingCalls = [NSMutableArray new];
|
2015-08-17 14:35:34 +00:00
|
|
|
_moduleDataByID = [NSMutableArray new];
|
|
|
|
_frameUpdateObservers = [NSMutableSet 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
|
|
|
_jsDisplayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(_jsThreadUpdate:)];
|
|
|
|
|
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-08-07 13:42:34 +00:00
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:RCTJavaScriptWillStartLoadingNotification
|
|
|
|
object:self
|
|
|
|
userInfo:@{ @"bridge": self }];
|
2015-07-22 17:54:45 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
[self start];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (void)start
|
|
|
|
{
|
|
|
|
dispatch_queue_t bridgeQueue = dispatch_queue_create("com.facebook.react.RCTBridgeQueue", DISPATCH_QUEUE_CONCURRENT);
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-21 18:33:04 +00:00
|
|
|
dispatch_group_t initModulesAndLoadSource = dispatch_group_create();
|
2015-08-07 13:42:34 +00:00
|
|
|
dispatch_group_enter(initModulesAndLoadSource);
|
2015-09-04 10:19:30 +00:00
|
|
|
__weak RCTBatchedBridge *weakSelf = self;
|
2015-10-16 15:10:25 +00:00
|
|
|
__block NSData *sourceCode;
|
|
|
|
[self loadSource:^(NSError *error, NSData *source) {
|
2015-09-04 10:19:30 +00:00
|
|
|
if (error) {
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[weakSelf stopLoadingWithError:error];
|
|
|
|
});
|
|
|
|
}
|
2015-09-11 13:35:25 +00:00
|
|
|
|
2015-08-21 18:33:04 +00:00
|
|
|
sourceCode = source;
|
2015-08-07 13:42:34 +00:00
|
|
|
dispatch_group_leave(initModulesAndLoadSource);
|
|
|
|
}];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-21 18:33:04 +00:00
|
|
|
// Synchronously initialize all native modules
|
2015-08-07 13:42:34 +00:00
|
|
|
[self initModules];
|
2015-07-28 12:58:01 +00:00
|
|
|
|
2015-08-21 18:33:04 +00:00
|
|
|
if (RCTProfileIsProfiling()) {
|
|
|
|
// Depends on moduleDataByID being loaded
|
|
|
|
RCTProfileHookModules(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
__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();
|
|
|
|
dispatch_group_async(setupJSExecutorAndModuleConfig, bridgeQueue, ^{
|
|
|
|
[weakSelf setupExecutor];
|
|
|
|
});
|
2015-07-28 12:58:01 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
dispatch_group_async(setupJSExecutorAndModuleConfig, bridgeQueue, ^{
|
|
|
|
if (weakSelf.isValid) {
|
2015-10-08 15:41:55 +00:00
|
|
|
RCTPerformanceLoggerStart(RCTPLNativeModulePrepareConfig);
|
2015-08-07 13:42:34 +00:00
|
|
|
config = [weakSelf moduleConfig];
|
2015-10-08 15:41:55 +00:00
|
|
|
RCTPerformanceLoggerEnd(RCTPLNativeModulePrepareConfig);
|
2015-08-07 13:42:34 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
dispatch_group_notify(setupJSExecutorAndModuleConfig, bridgeQueue, ^{
|
2015-08-21 18:33:04 +00:00
|
|
|
// We're not waiting for this complete to leave the dispatch group, since
|
|
|
|
// injectJSONConfiguration and executeSourceCode will schedule operations on the
|
|
|
|
// same queue anyway.
|
2015-10-05 17:53:33 +00:00
|
|
|
RCTPerformanceLoggerStart(RCTPLNativeModuleInjectConfig);
|
2015-09-04 10:19:30 +00:00
|
|
|
[weakSelf injectJSONConfiguration:config onComplete:^(NSError *error) {
|
2015-10-05 17:53:33 +00:00
|
|
|
RCTPerformanceLoggerEnd(RCTPLNativeModuleInjectConfig);
|
2015-09-04 10:19:30 +00:00
|
|
|
if (error) {
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[weakSelf stopLoadingWithError:error];
|
|
|
|
});
|
|
|
|
}
|
2015-08-21 18:33:04 +00:00
|
|
|
}];
|
2015-08-07 13:42:34 +00:00
|
|
|
dispatch_group_leave(initModulesAndLoadSource);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2015-09-04 10:19:30 +00:00
|
|
|
dispatch_group_notify(initModulesAndLoadSource, dispatch_get_main_queue(), ^{
|
|
|
|
RCTBatchedBridge *strongSelf = weakSelf;
|
|
|
|
if (sourceCode && strongSelf.loading) {
|
|
|
|
dispatch_async(bridgeQueue, ^{
|
|
|
|
[weakSelf executeSourceCode:sourceCode];
|
|
|
|
});
|
2015-08-07 13:42:34 +00:00
|
|
|
}
|
|
|
|
});
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (void)loadSource:(RCTSourceLoadBlock)_onSourceLoad
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
{
|
2015-08-21 18:33:04 +00:00
|
|
|
RCTPerformanceLoggerStart(RCTPLScriptDownload);
|
2015-11-08 18:19:26 +00:00
|
|
|
NSUInteger cookie = RCTProfileBeginAsyncEvent(0, @"JavaScript download", nil);
|
2015-08-21 18:33:04 +00:00
|
|
|
|
2015-10-16 15:10:25 +00:00
|
|
|
RCTSourceLoadBlock onSourceLoad = ^(NSError *error, NSData *source) {
|
2015-08-21 18:33:04 +00:00
|
|
|
RCTProfileEndAsyncEvent(0, @"init,download", cookie, @"JavaScript download", nil);
|
|
|
|
RCTPerformanceLoggerEnd(RCTPLScriptDownload);
|
2015-09-11 14:11:23 +00:00
|
|
|
|
|
|
|
// Only override the value of __DEV__ if running in debug mode, and if we
|
|
|
|
// haven't explicitly overridden the packager dev setting in the bundleURL
|
|
|
|
BOOL shouldOverrideDev = RCT_DEBUG && ([self.bundleURL isFileURL] ||
|
|
|
|
[self.bundleURL.absoluteString rangeOfString:@"dev="].location == NSNotFound);
|
|
|
|
|
|
|
|
// Force JS __DEV__ value to match RCT_DEBUG
|
|
|
|
if (shouldOverrideDev) {
|
2015-10-16 15:10:25 +00:00
|
|
|
NSString *sourceString = [[NSString alloc] initWithData:source encoding:NSUTF8StringEncoding];
|
2015-10-27 11:12:46 +00:00
|
|
|
NSRange range = [sourceString rangeOfString:@"\\b__DEV__\\s*?=\\s*?(!1|!0|false|true)"
|
|
|
|
options:NSRegularExpressionSearch];
|
|
|
|
|
2015-09-11 14:11:23 +00:00
|
|
|
RCTAssert(range.location != NSNotFound, @"It looks like the implementation"
|
|
|
|
"of __DEV__ has changed. Update -[RCTBatchedBridge loadSource:].");
|
2015-10-27 11:12:46 +00:00
|
|
|
|
|
|
|
NSString *valueString = [sourceString substringWithRange:range];
|
|
|
|
if ([valueString rangeOfString:@"!1"].length) {
|
|
|
|
valueString = [valueString stringByReplacingOccurrencesOfString:@"!1" withString:@"!0"];
|
|
|
|
} else if ([valueString rangeOfString:@"false"].length) {
|
|
|
|
valueString = [valueString stringByReplacingOccurrencesOfString:@"false" withString:@"true"];
|
2015-09-11 14:11:23 +00:00
|
|
|
}
|
2015-10-27 11:12:46 +00:00
|
|
|
source = [[sourceString stringByReplacingCharactersInRange:range withString:valueString]
|
|
|
|
dataUsingEncoding:NSUTF8StringEncoding];
|
2015-09-11 14:11:23 +00:00
|
|
|
}
|
|
|
|
|
2015-08-21 18:33:04 +00:00
|
|
|
_onSourceLoad(error, source);
|
|
|
|
};
|
|
|
|
|
|
|
|
if ([self.delegate respondsToSelector:@selector(loadSourceForBridge:withBlock:)]) {
|
|
|
|
[self.delegate loadSourceForBridge:_parentBridge withBlock:onSourceLoad];
|
|
|
|
} else if (self.bundleURL) {
|
|
|
|
[RCTJavaScriptLoader loadBundleAtURL:self.bundleURL onComplete:onSourceLoad];
|
|
|
|
} else {
|
|
|
|
// Allow testing without a script
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
2015-10-14 16:48:00 +00:00
|
|
|
[self didFinishLoading];
|
2015-08-21 18:33:04 +00:00
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:RCTJavaScriptDidLoadNotification
|
|
|
|
object:_parentBridge
|
|
|
|
userInfo:@{ @"bridge": self }];
|
|
|
|
});
|
|
|
|
onSourceLoad(nil, nil);
|
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (void)initModules
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
{
|
|
|
|
RCTAssertMainThread();
|
2015-08-21 18:33:04 +00:00
|
|
|
RCTPerformanceLoggerStart(RCTPLNativeModuleInit);
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
|
|
|
// Register passed-in module instances
|
2015-08-17 14:35:34 +00:00
|
|
|
NSMutableDictionary *preregisteredModules = [NSMutableDictionary new];
|
2015-07-28 22:48:46 +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();
|
|
|
|
}
|
|
|
|
|
|
|
|
for (id<RCTBridgeModule> module in extraModules) {
|
[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
|
|
|
preregisteredModules[RCTBridgeModuleNameForClass([module class])] = module;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Instantiate modules
|
2015-08-17 14:35:34 +00:00
|
|
|
_moduleDataByID = [NSMutableArray 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
|
|
|
NSMutableDictionary *modulesByName = [preregisteredModules mutableCopy];
|
|
|
|
for (Class moduleClass in RCTGetModuleClasses()) {
|
2015-11-03 16:52:15 +00:00
|
|
|
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
|
|
|
|
|
|
|
// Check if module instance has already been registered for this name
|
|
|
|
id<RCTBridgeModule> module = modulesByName[moduleName];
|
|
|
|
|
|
|
|
if (module) {
|
|
|
|
// Preregistered instances takes precedence, no questions asked
|
|
|
|
if (!preregisteredModules[moduleName]) {
|
|
|
|
// It's OK to have a name collision as long as the second instance is nil
|
2015-08-17 14:35:34 +00:00
|
|
|
RCTAssert([moduleClass new] == 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
|
|
|
@"Attempted to register RCTBridgeModule class %@ for the name "
|
|
|
|
"'%@', but name was already registered by class %@", moduleClass,
|
|
|
|
moduleName, [modulesByName[moduleName] class]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Module name hasn't been used before, so go ahead and instantiate
|
2015-08-17 14:35:34 +00:00
|
|
|
module = [moduleClass 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
|
|
|
}
|
|
|
|
if (module) {
|
|
|
|
modulesByName[moduleName] = module;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Store modules
|
2015-07-27 15:51:28 +00:00
|
|
|
_modulesByName = [[RCTModuleMap alloc] initWithDictionary:modulesByName];
|
[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
|
|
|
|
|
|
|
/**
|
|
|
|
* The executor is a bridge module, wait for it to be created and set it before
|
|
|
|
* any other module has access to the bridge
|
|
|
|
*/
|
|
|
|
_javaScriptExecutor = _modulesByName[RCTBridgeModuleNameForClass(self.executorClass)];
|
|
|
|
|
|
|
|
for (id<RCTBridgeModule> module in _modulesByName.allValues) {
|
2015-08-07 23:07:15 +00:00
|
|
|
// Bridge must be set before moduleData is set up, as methodQueue
|
|
|
|
// initialization requires it (View Managers get their queue by calling
|
|
|
|
// self.bridge.uiManager.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
|
|
|
if ([module respondsToSelector:@selector(setBridge:)]) {
|
|
|
|
module.bridge = self;
|
|
|
|
}
|
|
|
|
|
|
|
|
RCTModuleData *moduleData = [[RCTModuleData alloc] initWithExecutor:_javaScriptExecutor
|
2015-08-07 23:07:15 +00:00
|
|
|
moduleID:@(_moduleDataByID.count)
|
|
|
|
instance:module];
|
2015-07-27 15:51:28 +00:00
|
|
|
[_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
|
|
|
}
|
2015-07-01 00:08:28 +00:00
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:RCTDidCreateNativeModules
|
|
|
|
object:self];
|
2015-10-05 17:53:33 +00:00
|
|
|
RCTPerformanceLoggerEnd(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-08-07 13:42:34 +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
|
|
|
|
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-10-29 01:41:49 +00:00
|
|
|
[config addObject:moduleData.config];
|
2015-08-07 13:42:34 +00:00
|
|
|
if ([moduleData.instance conformsToProtocol:@protocol(RCTFrameUpdateObserver)]) {
|
|
|
|
[_frameUpdateObservers addObject:moduleData];
|
2015-09-29 12:26:01 +00:00
|
|
|
id<RCTFrameUpdateObserver> observer = (id<RCTFrameUpdateObserver>)moduleData.instance;
|
|
|
|
__weak typeof(self) weakSelf = self;
|
|
|
|
__weak typeof(_javaScriptExecutor) weakJavaScriptExecutor = _javaScriptExecutor;
|
|
|
|
observer.pauseCallback = ^{
|
|
|
|
[weakJavaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
|
|
|
[weakSelf updateJSDisplayLinkState];
|
|
|
|
}];
|
|
|
|
};
|
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
|
|
|
}
|
|
|
|
|
2015-09-29 12:26:01 +00:00
|
|
|
- (void)updateJSDisplayLinkState
|
|
|
|
{
|
|
|
|
RCTAssertJSThread();
|
|
|
|
|
2015-10-13 10:22:40 +00:00
|
|
|
BOOL pauseDisplayLink = YES;
|
|
|
|
for (RCTModuleData *moduleData in _frameUpdateObservers) {
|
|
|
|
id<RCTFrameUpdateObserver> observer = (id<RCTFrameUpdateObserver>)moduleData.instance;
|
|
|
|
if (!observer.paused) {
|
|
|
|
pauseDisplayLink = NO;
|
|
|
|
break;
|
2015-09-29 12:26:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
_jsDisplayLink.paused = pauseDisplayLink;
|
|
|
|
}
|
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (void)injectJSONConfiguration:(NSString *)configJSON
|
|
|
|
onComplete:(void (^)(NSError *))onComplete
|
|
|
|
{
|
2015-08-21 18:33:04 +00:00
|
|
|
if (!self.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
|
|
|
{
|
2015-08-21 18:33:04 +00:00
|
|
|
if (!self.valid || !_javaScriptExecutor) {
|
2015-08-07 13:42:34 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RCTSourceCode *sourceCodeModule = self.modules[RCTBridgeModuleNameForClass([RCTSourceCode class])];
|
2015-08-08 09:58:30 +00:00
|
|
|
sourceCodeModule.scriptURL = self.bundleURL;
|
2015-10-16 15:10:25 +00:00
|
|
|
sourceCodeModule.scriptData = sourceCode;
|
2015-08-07 13:42:34 +00:00
|
|
|
|
2015-08-08 09:58:30 +00:00
|
|
|
[self enqueueApplicationScript:sourceCode url:self.bundleURL onComplete:^(NSError *loadError) {
|
2015-09-24 09:42:39 +00:00
|
|
|
if (!self.isValid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
if (loadError) {
|
2015-09-04 10:19:30 +00:00
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
|
|
[self stopLoadingWithError:loadError];
|
|
|
|
});
|
2015-08-07 13:42:34 +00:00
|
|
|
return;
|
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-21 18:33:04 +00:00
|
|
|
// Register the display link to start sending js calls after everything is setup
|
2015-08-07 13:42:34 +00:00
|
|
|
NSRunLoop *targetRunLoop = [_javaScriptExecutor isKindOfClass:[RCTContextExecutor class]] ? [NSRunLoop currentRunLoop] : [NSRunLoop mainRunLoop];
|
|
|
|
[_jsDisplayLink addToRunLoop:targetRunLoop forMode:NSRunLoopCommonModes];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-21 18:33:04 +00:00
|
|
|
// Perform the state update and notification on the main thread, so we can't run into
|
|
|
|
// timing issues with RCTRootView
|
|
|
|
dispatch_async(dispatch_get_main_queue(), ^{
|
2015-10-14 16:48:00 +00:00
|
|
|
[self didFinishLoading];
|
2015-10-19 15:02:50 +00:00
|
|
|
|
2015-08-21 18:33:04 +00:00
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:RCTJavaScriptDidLoadNotification
|
|
|
|
object:_parentBridge
|
|
|
|
userInfo:@{ @"bridge": self }];
|
|
|
|
});
|
2015-08-07 13:42:34 +00:00
|
|
|
}];
|
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-10-14 16:48:00 +00:00
|
|
|
- (void)didFinishLoading
|
|
|
|
{
|
|
|
|
_loading = NO;
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
|
|
|
for (NSArray *call in _pendingCalls) {
|
|
|
|
[self _actuallyInvokeAndProcessModule:call[0]
|
|
|
|
method:call[1]
|
|
|
|
arguments:call[2]];
|
|
|
|
}
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2015-09-04 10:19:30 +00:00
|
|
|
- (void)stopLoadingWithError:(NSError *)error
|
|
|
|
{
|
|
|
|
RCTAssertMainThread();
|
2015-09-11 13:35:25 +00:00
|
|
|
|
2015-09-04 10:19:30 +00:00
|
|
|
if (!self.isValid || !self.loading) {
|
|
|
|
return;
|
|
|
|
}
|
2015-09-11 13:35:25 +00:00
|
|
|
|
2015-09-04 10:19:30 +00:00
|
|
|
_loading = NO;
|
2015-09-11 13:35:25 +00:00
|
|
|
|
2015-09-04 10:19:30 +00:00
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:RCTJavaScriptDidFailToLoadNotification
|
|
|
|
object:_parentBridge
|
2015-11-05 20:19:56 +00:00
|
|
|
userInfo:@{@"bridge": self, @"error": error}];
|
|
|
|
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
|
|
|
|
{
|
|
|
|
return _parentBridge.executorClass ?: [RCTContextExecutor class];
|
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (void)setExecutorClass:(Class)executorClass
|
|
|
|
{
|
|
|
|
RCTAssertMainThread();
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
_parentBridge.executorClass = executorClass;
|
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (NSURL *)bundleURL
|
|
|
|
{
|
|
|
|
return _parentBridge.bundleURL;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setBundleURL:(NSURL *)bundleURL
|
|
|
|
{
|
|
|
|
_parentBridge.bundleURL = bundleURL;
|
|
|
|
}
|
2015-07-14 23:11:42 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (id<RCTBridgeDelegate>)delegate
|
|
|
|
{
|
|
|
|
return _parentBridge.delegate;
|
|
|
|
}
|
2015-07-14 23:11:42 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (BOOL)isLoading
|
|
|
|
{
|
|
|
|
return _loading;
|
|
|
|
}
|
2015-07-28 22:48:46 +00:00
|
|
|
|
2015-08-07 13:42:34 +00:00
|
|
|
- (BOOL)isValid
|
|
|
|
{
|
|
|
|
return _valid;
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSDictionary *)modules
|
|
|
|
{
|
2015-08-26 16:28:14 +00:00
|
|
|
if (RCT_DEBUG && self.isValid && _modulesByName == nil) {
|
|
|
|
RCTLogError(@"Bridge modules have not yet been initialized. You may be "
|
|
|
|
"trying to access a module too early in the startup procedure.");
|
|
|
|
}
|
[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 _modulesByName;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - RCTInvalidating
|
|
|
|
|
|
|
|
- (void)invalidate
|
|
|
|
{
|
2015-08-21 18:33:04 +00:00
|
|
|
if (!self.valid) {
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RCTAssertMainThread();
|
|
|
|
|
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();
|
2015-07-27 15:51:28 +00:00
|
|
|
for (RCTModuleData *moduleData in _moduleDataByID) {
|
2015-07-20 09:34:11 +00:00
|
|
|
if (moduleData.instance == _javaScriptExecutor) {
|
|
|
|
continue;
|
|
|
|
}
|
2015-07-08 07:28:54 +00:00
|
|
|
|
2015-07-20 09:34:11 +00:00
|
|
|
if ([moduleData.instance respondsToSelector:@selector(invalidate)]) {
|
|
|
|
[moduleData dispatchBlock:^{
|
|
|
|
[(id<RCTInvalidating>)moduleData.instance invalidate];
|
|
|
|
} dispatchGroup:group];
|
|
|
|
}
|
|
|
|
moduleData.queue = 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
|
|
|
|
2015-07-20 09:34:11 +00:00
|
|
|
dispatch_group_notify(group, dispatch_get_main_queue(), ^{
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
|
|
|
[_jsDisplayLink invalidate];
|
|
|
|
_jsDisplayLink = nil;
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-07-20 09:34:11 +00:00
|
|
|
[_javaScriptExecutor invalidate];
|
|
|
|
_javaScriptExecutor = nil;
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-07-22 17:54:45 +00:00
|
|
|
if (RCTProfileIsProfiling()) {
|
|
|
|
RCTProfileUnhookModules(self);
|
|
|
|
}
|
2015-07-27 15:51:28 +00:00
|
|
|
_moduleDataByID = nil;
|
2015-07-22 17:54:45 +00:00
|
|
|
_modulesByName = nil;
|
|
|
|
_frameUpdateObservers = nil;
|
|
|
|
|
|
|
|
}];
|
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
|
|
|
|
{
|
|
|
|
if (RCT_DEBUG) {
|
|
|
|
[_javaScriptExecutor executeJSCall:@"RCTLog"
|
|
|
|
method:@"logIfNoNativeHook"
|
|
|
|
arguments:@[level, message]
|
|
|
|
callback:^(__unused id json, __unused NSError *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 - RCTBridge methods
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Public. Can be invoked from any thread.
|
|
|
|
*/
|
|
|
|
- (void)enqueueJSCall:(NSString *)moduleDotMethod args:(NSArray *)args
|
|
|
|
{
|
2015-11-03 22:45:46 +00:00
|
|
|
NSArray<NSString *> *ids = [moduleDotMethod componentsSeparatedByString:@"."];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
|
|
|
[self _invokeAndProcessModule:@"BatchedBridge"
|
|
|
|
method:@"callFunctionReturnFlushedQueue"
|
2015-07-14 23:16:21 +00:00
|
|
|
arguments:@[ids[0], ids[1], args ?: @[]]];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Private hack to support `setTimeout(fn, 0)`
|
|
|
|
*/
|
|
|
|
- (void)_immediatelyCallTimer:(NSNumber *)timer
|
|
|
|
{
|
|
|
|
RCTAssertJSThread();
|
|
|
|
|
|
|
|
dispatch_block_t block = ^{
|
|
|
|
[self _actuallyInvokeAndProcessModule:@"BatchedBridge"
|
|
|
|
method:@"callFunctionReturnFlushedQueue"
|
2015-07-14 23:16:21 +00:00
|
|
|
arguments:@[@"JSTimersExecution", @"callTimers", @[@[timer]]]];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if ([_javaScriptExecutor respondsToSelector:@selector(executeAsyncBlockOnJavaScriptQueue:)]) {
|
|
|
|
[_javaScriptExecutor executeAsyncBlockOnJavaScriptQueue:block];
|
|
|
|
} else {
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:block];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-16 15:10:25 +00:00
|
|
|
- (void)enqueueApplicationScript:(NSData *)script
|
2015-08-20 06:36:11 +00:00
|
|
|
url:(NSURL *)url
|
|
|
|
onComplete:(RCTJavaScriptCompleteBlock)onComplete
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
{
|
|
|
|
RCTAssert(onComplete != nil, @"onComplete block passed in should be non-nil");
|
|
|
|
|
|
|
|
RCTProfileBeginFlowEvent();
|
|
|
|
[_javaScriptExecutor executeApplicationScript:script sourceURL:url onComplete:^(NSError *scriptLoadError) {
|
|
|
|
RCTProfileEndFlowEvent();
|
|
|
|
RCTAssertJSThread();
|
|
|
|
|
|
|
|
if (scriptLoadError) {
|
|
|
|
onComplete(scriptLoadError);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-11-09 16:42:51 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(0, @"FetchApplicationScriptCallbacks", 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
|
|
|
[_javaScriptExecutor executeJSCall:@"BatchedBridge"
|
|
|
|
method:@"flushedQueue"
|
|
|
|
arguments:@[]
|
2015-08-20 06:36:11 +00:00
|
|
|
callback:^(id json, NSError *error)
|
|
|
|
{
|
2015-11-09 16:42:51 +00:00
|
|
|
RCT_PROFILE_END_EVENT(0, @"js_call,init", @{
|
2015-08-20 06:36:11 +00:00
|
|
|
@"json": RCTNullIfNil(json),
|
|
|
|
@"error": RCTNullIfNil(error),
|
|
|
|
});
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-10-19 15:02:50 +00:00
|
|
|
[self handleBuffer:json batchEnded:YES];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-08-20 06:36:11 +00:00
|
|
|
onComplete(error);
|
|
|
|
}];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Payload Generation
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called by enqueueJSCall from any thread, or from _immediatelyCallTimer,
|
|
|
|
* on the JS thread, but only in non-batched mode.
|
|
|
|
*/
|
2015-07-14 23:16:21 +00:00
|
|
|
- (void)_invokeAndProcessModule:(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
|
|
|
{
|
|
|
|
/**
|
|
|
|
* AnyThread
|
|
|
|
*/
|
|
|
|
|
|
|
|
RCTProfileBeginFlowEvent();
|
|
|
|
|
|
|
|
__weak RCTBatchedBridge *weakSelf = self;
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
|
|
|
RCTProfileEndFlowEvent();
|
|
|
|
|
|
|
|
RCTBatchedBridge *strongSelf = weakSelf;
|
2015-10-14 16:48:00 +00:00
|
|
|
if (!strongSelf || !strongSelf.valid) {
|
|
|
|
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-10-14 16:48:00 +00:00
|
|
|
if (strongSelf.loading) {
|
|
|
|
[strongSelf->_pendingCalls addObject:@[module, method, args]];
|
|
|
|
} else {
|
|
|
|
[strongSelf _actuallyInvokeAndProcessModule:module method:method arguments:args];
|
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2015-08-20 06:36:11 +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
|
|
|
{
|
|
|
|
RCTAssertJSThread();
|
|
|
|
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:RCTEnqueueNotification object:nil userInfo:nil];
|
|
|
|
|
2015-07-14 23:11:42 +00:00
|
|
|
RCTJavaScriptCallback processResponse = ^(id json, NSError *error) {
|
|
|
|
if (error) {
|
2015-11-05 20:19:56 +00:00
|
|
|
RCTFatal(error);
|
2015-07-14 23:11:42 +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
|
|
|
if (!self.isValid) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
[[NSNotificationCenter defaultCenter] postNotificationName:RCTDequeueNotification object:nil userInfo:nil];
|
2015-10-19 15:02:50 +00:00
|
|
|
[self handleBuffer:json batchEnded:YES];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
[_javaScriptExecutor executeJSCall:module
|
|
|
|
method:method
|
|
|
|
arguments:args
|
|
|
|
callback:processResponse];
|
|
|
|
}
|
|
|
|
|
|
|
|
#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];
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2015-11-03 22:45:46 +00:00
|
|
|
- (void)handleBuffer:(NSArray<NSArray *> *)buffer
|
2015-10-19 15:02:50 +00:00
|
|
|
{
|
2015-11-03 22:45:46 +00:00
|
|
|
NSArray<NSArray *> *requestsArray = [RCTConvert NSArrayArray:buffer];
|
[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 && requestsArray.count <= RCTBridgeFieldParamss) {
|
|
|
|
RCTLogError(@"Buffer should contain at least %tu sub-arrays. Only found %tu",
|
|
|
|
RCTBridgeFieldParamss + 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;
|
|
|
|
}
|
|
|
|
|
2015-11-03 22:45:46 +00:00
|
|
|
NSArray<NSNumber *> *moduleIDs = requestsArray[RCTBridgeFieldRequestModuleIDs];
|
|
|
|
NSArray<NSNumber *> *methodIDs = requestsArray[RCTBridgeFieldMethodIDs];
|
|
|
|
NSArray<NSArray *> *paramsArrays = requestsArray[RCTBridgeFieldParamss];
|
[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
|
|
|
|
capacity:_moduleDataByID.count];
|
2015-11-03 22:45:46 +00:00
|
|
|
|
|
|
|
[moduleIDs enumerateObjectsUsingBlock:^(NSNumber *moduleID, NSUInteger i, __unused BOOL *stop) {
|
|
|
|
RCTModuleData *moduleData = _moduleDataByID[moduleID.integerValue];
|
2015-07-27 15:51:28 +00:00
|
|
|
if (RCT_DEBUG) {
|
|
|
|
// verify that class has been registered
|
|
|
|
(void)_modulesByName[moduleData.name];
|
|
|
|
}
|
2015-11-03 22:45:46 +00:00
|
|
|
dispatch_queue_t queue = moduleData.queue;
|
|
|
|
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-11-06 15:22:47 +00:00
|
|
|
|
|
|
|
#if RCT_DEV
|
|
|
|
NSString *_threadName = RCTCurrentThreadName();
|
2015-11-09 16:42:51 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(0, _threadName, nil);
|
2015-11-06 15:22:47 +00:00
|
|
|
#endif
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
|
2015-09-01 09:18:14 +00:00
|
|
|
NSOrderedSet *calls = [buckets objectForKey:queue];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
@autoreleasepool {
|
|
|
|
for (NSNumber *indexObj in calls) {
|
|
|
|
NSUInteger index = indexObj.unsignedIntegerValue;
|
|
|
|
[self _handleRequestNumber:index
|
|
|
|
moduleID:[moduleIDs[index] integerValue]
|
|
|
|
methodID:[methodIDs[index] integerValue]
|
2015-07-14 23:16:21 +00:00
|
|
|
params:paramsArrays[index]];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
}
|
2015-07-27 15:51:28 +00:00
|
|
|
|
2015-11-09 16:42:51 +00:00
|
|
|
RCT_PROFILE_END_EVENT(0, @"objc_call,dispatch_async", @{
|
2015-08-20 06:36:11 +00:00
|
|
|
@"calls": @(calls.count),
|
|
|
|
});
|
2015-09-01 09:18:14 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (queue == RCTJSThread) {
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:block];
|
|
|
|
} else if (queue) {
|
|
|
|
dispatch_async(queue, block);
|
|
|
|
}
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
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-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) {
|
[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 ([moduleData.instance respondsToSelector:@selector(batchDidComplete)]) {
|
|
|
|
[moduleData dispatchBlock:^{
|
|
|
|
[moduleData.instance batchDidComplete];
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)_handleRequestNumber:(NSUInteger)i
|
|
|
|
moduleID:(NSUInteger)moduleID
|
|
|
|
methodID:(NSUInteger)methodID
|
|
|
|
params:(NSArray *)params
|
|
|
|
{
|
|
|
|
if (!self.isValid) {
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (RCT_DEBUG && ![params isKindOfClass:[NSArray class]]) {
|
|
|
|
RCTLogError(@"Invalid module/method/params tuple for request #%zd", i);
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2015-07-27 15:51:28 +00:00
|
|
|
RCTModuleData *moduleData = _moduleDataByID[moduleID];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
if (RCT_DEBUG && !moduleData) {
|
|
|
|
RCTLogError(@"No module found for id '%zd'", moduleID);
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2015-09-18 22:01:21 +00:00
|
|
|
id<RCTBridgeMethod> method = moduleData.methods[methodID];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
if (RCT_DEBUG && !method) {
|
|
|
|
RCTLogError(@"Unknown methodID: %zd for module: %zd (%@)", methodID, moduleID, moduleData.name);
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2015-11-09 16:42:51 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(0, [NSString stringWithFormat:@"[%@ %@]", moduleData.name, method.JSMethodName], nil);
|
2015-11-03 11:49:44 +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
|
|
|
@try {
|
2015-07-14 23:16:21 +00:00
|
|
|
[method invokeWithBridge:self module:moduleData.instance arguments:params];
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}
|
|
|
|
@catch (NSException *exception) {
|
2015-11-05 20:19:56 +00:00
|
|
|
// Pass on JS exceptions
|
2015-11-10 12:29:39 +00:00
|
|
|
if ([exception.name isEqualToString: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:
|
|
|
|
@"Exception thrown while invoking %@ on target %@ with params %@: %@",
|
|
|
|
method.JSMethodName, moduleData.name, params, exception];
|
|
|
|
RCTFatal(RCTErrorWithMessage(message));
|
|
|
|
}
|
2015-09-18 22:01:21 +00:00
|
|
|
|
2015-11-05 20:19:56 +00:00
|
|
|
if (RCTProfileIsProfiling()) {
|
|
|
|
NSMutableDictionary *args = [method.profileArgs mutableCopy];
|
|
|
|
args[@"method"] = method.JSMethodName;
|
|
|
|
args[@"args"] = RCTJSONStringify(RCTNullIfNil(params), NULL);
|
2015-11-09 16:42:51 +00:00
|
|
|
RCT_PROFILE_END_EVENT(0, @"objc_call", args);
|
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
|
|
|
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)_jsThreadUpdate:(CADisplayLink *)displayLink
|
|
|
|
{
|
|
|
|
RCTAssertJSThread();
|
2015-11-09 16:42:51 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(0, @"DispatchFrameUpdate", 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
|
|
|
|
|
|
|
RCTFrameUpdate *frameUpdate = [[RCTFrameUpdate alloc] initWithDisplayLink:displayLink];
|
|
|
|
for (RCTModuleData *moduleData in _frameUpdateObservers) {
|
|
|
|
id<RCTFrameUpdateObserver> observer = (id<RCTFrameUpdateObserver>)moduleData.instance;
|
2015-09-29 12:26:01 +00:00
|
|
|
if (!observer.paused) {
|
[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
|
|
|
RCT_IF_DEV(NSString *name = [NSString stringWithFormat:@"[%@ didUpdateFrame:%f]", observer, displayLink.timestamp];)
|
|
|
|
RCTProfileBeginFlowEvent();
|
|
|
|
|
|
|
|
[moduleData dispatchBlock:^{
|
|
|
|
RCTProfileEndFlowEvent();
|
2015-11-09 16:42:51 +00:00
|
|
|
RCT_PROFILE_BEGIN_EVENT(0, name, 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
|
|
|
[observer didUpdateFrame:frameUpdate];
|
2015-11-09 16:42:51 +00:00
|
|
|
RCT_PROFILE_END_EVENT(0, @"objc_call,fps", 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-10-13 10:22:40 +00:00
|
|
|
[self updateJSDisplayLinkState];
|
[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-13 10:22:40 +00:00
|
|
|
RCTProfileImmediateEvent(0, @"JS Thread Tick", 'g');
|
[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-09 16:42:51 +00:00
|
|
|
RCT_PROFILE_END_EVENT(0, @"objc_call", 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
|
|
|
}
|
|
|
|
|
|
|
|
- (void)startProfiling
|
|
|
|
{
|
|
|
|
RCTAssertMainThread();
|
|
|
|
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
|
|
|
RCTProfileInit(self);
|
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
2015-10-12 16:42:21 +00:00
|
|
|
- (void)stopProfiling:(void (^)(NSData *))callback
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
{
|
|
|
|
RCTAssertMainThread();
|
|
|
|
|
|
|
|
[_javaScriptExecutor executeBlockOnJavaScriptQueue:^{
|
2015-11-04 17:00:01 +00:00
|
|
|
RCTProfileEnd(self, ^(NSString *log) {
|
|
|
|
NSData *logData = [log dataUsingEncoding:NSUTF8StringEncoding];
|
|
|
|
callback(logData);
|
|
|
|
});
|
[ReactNative] Move module info from bridge to RCTModuleData
Summary:
@public
The info about bridge modules (such as id, name, queue, methods...) was spread
across arrays & dictionaries on the bridge, move it into a specific class.
It also removes a lot of information that was statically cached, and now have
the same lifecycle of the bridge.
Also moved RCTModuleMethod, RCTFrameUpdate and RCTBatchedBridge into it's own
files, for organization sake.
NOTE: This diff seems huge, but most of it was just moving code :)
Test Plan:
Tested UIExplorer & UIExplorer tests, Catalyst, MAdMan and Groups. Everything
looks fine.
2015-06-24 23:34:56 +00:00
|
|
|
}];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|