2015-12-15 13:39:30 +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 "RCTBridge.h"
|
|
|
|
|
|
|
|
@class RCTModuleData;
|
|
|
|
|
|
|
|
@interface RCTBridge ()
|
|
|
|
|
2016-02-08 15:06:52 +00:00
|
|
|
// Used for the profiler flow events between JS and native
|
|
|
|
@property (nonatomic, assign) int64_t flowID;
|
|
|
|
@property (nonatomic, assign) CFMutableDictionaryRef flowIDMap;
|
|
|
|
|
2015-12-15 13:39:30 +00:00
|
|
|
+ (instancetype)currentBridge;
|
|
|
|
+ (void)setCurrentBridge:(RCTBridge *)bridge;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Bridge setup code - creates an instance of RCTBachedBridge. Exposed for
|
|
|
|
* test only
|
|
|
|
*/
|
|
|
|
- (void)setUp;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This method is used to invoke a callback that was registered in the
|
|
|
|
* JavaScript application context. Safe to call from any thread.
|
|
|
|
*/
|
|
|
|
- (void)enqueueCallback:(NSNumber *)cbID args:(NSArray *)args;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This property is mostly used on the main thread, but may be touched from
|
|
|
|
* a background thread if the RCTBridge happens to deallocate on a background
|
|
|
|
* thread. Therefore, we want all writes to it to be seen atomically.
|
|
|
|
*/
|
|
|
|
@property (atomic, strong) RCTBridge *batchedBridge;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The block that creates the modules' instances to be added to the bridge.
|
|
|
|
* Exposed for the RCTBatchedBridge
|
|
|
|
*/
|
|
|
|
@property (nonatomic, copy, readonly) RCTBridgeModuleProviderBlock moduleProvider;
|
|
|
|
|
2016-01-04 18:39:07 +00:00
|
|
|
/**
|
|
|
|
* Used by RCTDevMenu to override the `hot` param of the current bundleURL.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, strong, readwrite) NSURL *bundleURL;
|
|
|
|
|
2015-12-15 13:39:30 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface RCTBridge (RCTBatchedBridge)
|
|
|
|
|
2016-03-01 17:44:05 +00:00
|
|
|
/**
|
|
|
|
* Used for unit testing, to detect when executor has been invalidated.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, weak, readonly) id<RCTJavaScriptExecutor> javaScriptExecutor;
|
|
|
|
|
2016-01-05 17:04:08 +00:00
|
|
|
/**
|
|
|
|
* Used by RCTModuleData to register the module for frame updates after it is
|
|
|
|
* lazily initialized.
|
|
|
|
*/
|
|
|
|
- (void)registerModuleForFrameUpdates:(id<RCTBridgeModule>)module
|
|
|
|
withModuleData:(RCTModuleData *)moduleData;
|
2015-12-15 13:39:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Dispatch work to a module's queue - this is also suports the fake RCTJSThread
|
|
|
|
* queue. Exposed for the RCTProfiler
|
|
|
|
*/
|
|
|
|
- (void)dispatchBlock:(dispatch_block_t)block queue:(dispatch_queue_t)queue;
|
|
|
|
|
2016-01-06 13:57:25 +00:00
|
|
|
/**
|
|
|
|
* Get the module data for a given module name. Used by UIManager to implement
|
|
|
|
* the `dispatchViewManagerCommand` method.
|
|
|
|
*/
|
|
|
|
- (RCTModuleData *)moduleDataForName:(NSString *)moduleName;
|
|
|
|
|
2015-12-15 13:39:30 +00:00
|
|
|
/**
|
|
|
|
* Systrace profiler toggling methods exposed for the RCTDevMenu
|
|
|
|
*/
|
|
|
|
- (void)startProfiling;
|
|
|
|
- (void)stopProfiling:(void (^)(NSData *))callback;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Executes native calls sent by JavaScript. Exposed for testing purposes only
|
|
|
|
*/
|
|
|
|
- (void)handleBuffer:(NSArray<NSArray *> *)buffer;
|
|
|
|
|
|
|
|
/**
|
2015-12-16 10:49:27 +00:00
|
|
|
* Exposed for the RCTJSCExecutor for sending native methods called from
|
2015-12-15 13:39:30 +00:00
|
|
|
* JavaScript in the middle of a batch.
|
|
|
|
*/
|
|
|
|
- (void)handleBuffer:(NSArray<NSArray *> *)buffer batchEnded:(BOOL)hasEnded;
|
|
|
|
|
|
|
|
/**
|
2015-12-16 10:49:27 +00:00
|
|
|
* Exposed for the RCTJSCExecutor for lazily loading native modules
|
2015-12-15 13:39:30 +00:00
|
|
|
*/
|
|
|
|
- (NSArray *)configForModuleName:(NSString *)moduleName;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Hook exposed for RCTLog to send logs to JavaScript when not running in JSC
|
|
|
|
*/
|
|
|
|
- (void)logMessage:(NSString *)message level:(NSString *)level;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allow super fast, one time, timers to skip the queue and be directly executed
|
|
|
|
*/
|
|
|
|
- (void)_immediatelyCallTimer:(NSNumber *)timer;
|
|
|
|
|
|
|
|
@end
|