2015-12-15 13:39:30 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) 2015-present, Facebook, Inc.
|
|
|
|
*
|
2018-02-17 02:24:55 +00:00
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2015-12-15 13:39:30 +00:00
|
|
|
*/
|
|
|
|
|
2017-11-21 02:12:13 +00:00
|
|
|
#import <JavaScriptCore/JavaScriptCore.h>
|
2017-02-17 13:47:28 +00:00
|
|
|
#import <JavaScriptCore/JSBase.h>
|
|
|
|
|
2016-11-23 15:47:52 +00:00
|
|
|
#import <React/RCTBridge.h>
|
2015-12-15 13:39:30 +00:00
|
|
|
|
|
|
|
@class RCTModuleData;
|
2016-07-18 14:12:19 +00:00
|
|
|
@protocol RCTJavaScriptExecutor;
|
2015-12-15 13:39:30 +00:00
|
|
|
|
2016-09-19 11:43:06 +00:00
|
|
|
RCT_EXTERN NSArray<Class> *RCTGetModuleClasses(void);
|
|
|
|
|
2017-02-17 13:47:28 +00:00
|
|
|
RCT_EXTERN __attribute__((weak)) void RCTFBQuickPerformanceLoggerConfigureHooks(JSGlobalContextRef ctx);
|
|
|
|
|
2016-09-19 11:43:06 +00:00
|
|
|
#if RCT_DEBUG
|
|
|
|
RCT_EXTERN void RCTVerifyAllModulesExported(NSArray *extraModules);
|
|
|
|
#endif
|
|
|
|
|
2018-08-18 16:32:47 +00:00
|
|
|
RCT_EXTERN void RCTRegisterModule(Class);
|
|
|
|
|
2015-12-15 13:39:30 +00:00
|
|
|
@interface RCTBridge ()
|
|
|
|
|
2016-07-12 12:51:56 +00:00
|
|
|
// Private designated initializer
|
|
|
|
- (instancetype)initWithDelegate:(id<RCTBridgeDelegate>)delegate
|
|
|
|
bundleURL:(NSURL *)bundleURL
|
2017-04-07 18:11:03 +00:00
|
|
|
moduleProvider:(RCTBridgeModuleListProvider)block
|
2016-07-12 12:51:56 +00:00
|
|
|
launchOptions:(NSDictionary *)launchOptions NS_DESIGNATED_INITIALIZER;
|
|
|
|
|
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;
|
2016-03-30 15:07:23 +00:00
|
|
|
@property (nonatomic, strong) NSLock *flowIDMapLock;
|
2016-02-08 15:06:52 +00:00
|
|
|
|
2017-09-05 21:47:06 +00:00
|
|
|
// Used by RCTDevMenu
|
|
|
|
@property (nonatomic, copy) NSString *bridgeDescription;
|
|
|
|
|
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.
|
2018-02-05 19:47:10 +00:00
|
|
|
* Exposed for RCTCxxBridge
|
2015-12-15 13:39:30 +00:00
|
|
|
*/
|
2017-04-07 18:11:03 +00:00
|
|
|
@property (nonatomic, copy, readonly) RCTBridgeModuleListProvider moduleProvider;
|
2015-12-15 13:39:30 +00:00
|
|
|
|
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
|
|
|
|
|
2018-02-05 19:47:10 +00:00
|
|
|
@interface RCTBridge (RCTCxxBridge)
|
2016-03-01 17:44:05 +00:00
|
|
|
|
2017-04-06 07:40:27 +00:00
|
|
|
/**
|
|
|
|
* Used by RCTModuleData
|
|
|
|
*/
|
|
|
|
|
|
|
|
@property (nonatomic, weak, readonly) RCTBridge *parentBridge;
|
|
|
|
|
2016-03-03 10:20:20 +00:00
|
|
|
/**
|
|
|
|
* Used by RCTModuleData
|
|
|
|
*/
|
|
|
|
@property (nonatomic, assign, readonly) BOOL moduleSetupComplete;
|
|
|
|
|
2016-09-26 23:01:40 +00:00
|
|
|
/**
|
|
|
|
* Called on the child bridge to run the executor and start loading.
|
|
|
|
*/
|
|
|
|
- (void)start;
|
|
|
|
|
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;
|
|
|
|
|
2017-08-11 13:16:55 +00:00
|
|
|
/**
|
|
|
|
* Registers additional classes with the ModuleRegistry.
|
|
|
|
*/
|
|
|
|
- (void)registerAdditionalModuleClasses:(NSArray<Class> *)newModules;
|
|
|
|
|
2015-12-15 13:39:30 +00:00
|
|
|
/**
|
|
|
|
* Systrace profiler toggling methods exposed for the RCTDevMenu
|
|
|
|
*/
|
|
|
|
- (void)startProfiling;
|
|
|
|
- (void)stopProfiling:(void (^)(NSData *))callback;
|
|
|
|
|
2016-09-05 14:32:20 +00:00
|
|
|
/**
|
|
|
|
* Synchronously call a specific native module's method and return the result
|
|
|
|
*/
|
|
|
|
- (id)callNativeModule:(NSUInteger)moduleID
|
|
|
|
method:(NSUInteger)methodID
|
|
|
|
params:(NSArray *)params;
|
|
|
|
|
2015-12-15 13:39:30 +00:00
|
|
|
/**
|
|
|
|
* 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
|
2016-04-01 13:52:59 +00:00
|
|
|
|
2017-11-21 02:12:13 +00:00
|
|
|
@interface RCTBridge (JavaScriptCore)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The raw JSGlobalContextRef used by the bridge.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, readonly, assign) JSGlobalContextRef jsContextRef;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2017-12-18 21:19:37 +00:00
|
|
|
@interface RCTBridge (Inspector)
|
|
|
|
|
|
|
|
@property (nonatomic, readonly, getter=isInspectable) BOOL inspectable;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
2018-02-05 19:47:10 +00:00
|
|
|
@interface RCTCxxBridge : RCTBridge
|
2016-04-01 13:52:59 +00:00
|
|
|
|
|
|
|
- (instancetype)initWithParentBridge:(RCTBridge *)bridge NS_DESIGNATED_INITIALIZER;
|
|
|
|
|
|
|
|
@end
|