Replace private bridge categories with private header
Summary: public A lot of the core modules have to use private methods in the bridge, specially since the `RCTBatchedBridge` interface is never exposed. That was leading to a lot of different private bridge categories spread across different modules, which makes harder to identify which modules are affected by private API changes. Replace all the categories with a single private header. Reviewed By: nicklockwood Differential Revision: D2757564 fb-gh-sync-id: 793158b9082d542b74a6094ed0db4d5dc3a88f78
This commit is contained in:
parent
03a0e4ee2b
commit
2d61dfd9c1
|
@ -16,6 +16,7 @@
|
|||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTBridge+Private.h"
|
||||
#import "RCTContextExecutor.h"
|
||||
#import "RCTModuleMethod.h"
|
||||
#import "RCTRootView.h"
|
||||
|
@ -29,12 +30,6 @@ while ((CONDITION) && [timeout timeIntervalSinceNow] > 0) { \
|
|||
} \
|
||||
_Pragma("clang diagnostic pop")
|
||||
|
||||
@interface RCTBridge (RCTAllocationTests)
|
||||
|
||||
@property (nonatomic, weak) RCTBridge *batchedBridge;
|
||||
|
||||
@end
|
||||
|
||||
@interface RCTJavaScriptContext : NSObject
|
||||
|
||||
@property (nonatomic, assign, readonly) JSGlobalContextRef ctx;
|
||||
|
|
|
@ -16,19 +16,11 @@
|
|||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTBridge+Private.h"
|
||||
#import "RCTBridgeModule.h"
|
||||
#import "RCTJavaScriptExecutor.h"
|
||||
#import "RCTUtils.h"
|
||||
|
||||
@interface RCTBridge (Testing)
|
||||
|
||||
@property (nonatomic, strong, readonly) RCTBridge *batchedBridge;
|
||||
|
||||
- (void)handleBuffer:(id)buffer;
|
||||
- (void)setUp;
|
||||
|
||||
@end
|
||||
|
||||
@interface TestExecutor : NSObject <RCTJavaScriptExecutor>
|
||||
|
||||
@property (nonatomic, readonly, copy) NSMutableDictionary<NSString *, id> *injectedStuff;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTBridge+Private.h"
|
||||
#import "RCTBridgeMethod.h"
|
||||
#import "RCTConvert.h"
|
||||
#import "RCTContextExecutor.h"
|
||||
|
@ -42,15 +43,6 @@ typedef NS_ENUM(NSUInteger, RCTBridgeFields) {
|
|||
|
||||
RCT_EXTERN NSArray<Class> *RCTGetModuleClasses(void);
|
||||
|
||||
@interface RCTBridge ()
|
||||
|
||||
+ (instancetype)currentBridge;
|
||||
+ (void)setCurrentBridge:(RCTBridge *)bridge;
|
||||
|
||||
@property (nonatomic, copy, readonly) RCTBridgeModuleProviderBlock moduleProvider;
|
||||
|
||||
@end
|
||||
|
||||
@interface RCTBatchedBridge : RCTBridge
|
||||
|
||||
@property (nonatomic, weak) RCTBridge *parentBridge;
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
/**
|
||||
* 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 ()
|
||||
|
||||
+ (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;
|
||||
|
||||
@end
|
||||
|
||||
@interface RCTBridge (RCTBatchedBridge)
|
||||
|
||||
- (void)registerModuleForFrameUpdates:(RCTModuleData *)moduleData;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Exposed for the RCTContextExecutor for sending native methods called from
|
||||
* JavaScript in the middle of a batch.
|
||||
*/
|
||||
- (void)handleBuffer:(NSArray<NSArray *> *)buffer batchEnded:(BOOL)hasEnded;
|
||||
|
||||
/**
|
||||
* Exposed for the RCTContextExecutor for lazily loading native modules
|
||||
*/
|
||||
- (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
|
|
@ -7,7 +7,7 @@
|
|||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTBridge+Private.h"
|
||||
|
||||
#import <objc/runtime.h>
|
||||
|
||||
|
@ -24,8 +24,6 @@ NSString *const RCTJavaScriptDidLoadNotification = @"RCTJavaScriptDidLoadNotific
|
|||
NSString *const RCTJavaScriptDidFailToLoadNotification = @"RCTJavaScriptDidFailToLoadNotification";
|
||||
NSString *const RCTDidCreateNativeModules = @"RCTDidCreateNativeModules";
|
||||
|
||||
@class RCTBatchedBridge;
|
||||
|
||||
@interface RCTBatchedBridge : RCTBridge <RCTInvalidating>
|
||||
|
||||
@property (nonatomic, weak) RCTBridge *parentBridge;
|
||||
|
@ -34,17 +32,6 @@ NSString *const RCTDidCreateNativeModules = @"RCTDidCreateNativeModules";
|
|||
|
||||
@end
|
||||
|
||||
@interface RCTBridge ()
|
||||
|
||||
// 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) RCTBatchedBridge *batchedBridge;
|
||||
|
||||
@property (nonatomic, copy, readonly) RCTBridgeModuleProviderBlock moduleProvider;
|
||||
|
||||
@end
|
||||
|
||||
static NSMutableArray<Class> *RCTModuleClasses;
|
||||
NSArray<Class> *RCTGetModuleClasses(void);
|
||||
NSArray<Class> *RCTGetModuleClasses(void)
|
||||
|
@ -294,7 +281,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
|
||||
- (void)invalidate
|
||||
{
|
||||
RCTBatchedBridge *batchedBridge = self.batchedBridge;
|
||||
RCTBatchedBridge *batchedBridge = (RCTBatchedBridge *)self.batchedBridge;
|
||||
self.batchedBridge = nil;
|
||||
|
||||
if (batchedBridge) {
|
||||
|
@ -304,20 +291,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
}
|
||||
}
|
||||
|
||||
- (void)logMessage:(NSString *)message level:(NSString *)level
|
||||
{
|
||||
[self.batchedBridge logMessage:message level:level];
|
||||
}
|
||||
|
||||
|
||||
#define RCT_INNER_BRIDGE_ONLY(...) \
|
||||
- (void)__VA_ARGS__ \
|
||||
{ \
|
||||
NSString *errorMessage = [NSString stringWithFormat:@"Called method \"%@\" on top level bridge. \
|
||||
This method should oly be called from bridge instance in a bridge module", @(__func__)]; \
|
||||
RCTFatal(RCTErrorWithMessage(errorMessage)); \
|
||||
}
|
||||
|
||||
- (void)enqueueJSCall:(NSString *)moduleDotMethod args:(NSArray *)args
|
||||
{
|
||||
[self.batchedBridge enqueueJSCall:moduleDotMethod args:args];
|
||||
|
|
|
@ -13,16 +13,10 @@
|
|||
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTBridge+Private.h"
|
||||
#import "RCTDefines.h"
|
||||
#import "RCTRedBox.h"
|
||||
|
||||
@interface RCTBridge ()
|
||||
|
||||
+ (RCTBridge *)currentBridge;
|
||||
- (void)logMessage:(NSString *)message level:(NSString *)level;
|
||||
|
||||
@end
|
||||
|
||||
static NSString *const RCTLogFunctionStack = @"RCTLogFunctionStack";
|
||||
|
||||
const char *RCTLogLevels[] = {
|
||||
|
|
|
@ -10,16 +10,11 @@
|
|||
#import "RCTModuleData.h"
|
||||
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTBridge+Private.h"
|
||||
#import "RCTModuleMethod.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTUtils.h"
|
||||
|
||||
@interface RCTBridge (Private)
|
||||
|
||||
- (void)registerModuleForFrameUpdates:(RCTModuleData *)moduleData;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTModuleData
|
||||
{
|
||||
NSString *_queueName;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTBridge+Private.h"
|
||||
#import "RCTConvert.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTParserUtils.h"
|
||||
|
@ -36,16 +37,6 @@ typedef BOOL (^RCTArgumentBlock)(RCTBridge *, NSUInteger, id);
|
|||
|
||||
@end
|
||||
|
||||
@interface RCTBridge (RCTModuleMethod)
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTModuleMethod
|
||||
{
|
||||
Class _moduleClass;
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#import <objc/runtime.h>
|
||||
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTBridge+Private.h"
|
||||
#import "RCTEventDispatcher.h"
|
||||
#import "RCTKeyCommands.h"
|
||||
#import "RCTLog.h"
|
||||
|
@ -28,12 +28,6 @@
|
|||
|
||||
NSString *const RCTContentDidAppearNotification = @"RCTContentDidAppearNotification";
|
||||
|
||||
@interface RCTBridge (RCTRootView)
|
||||
|
||||
@property (nonatomic, weak, readonly) RCTBridge *batchedBridge;
|
||||
|
||||
@end
|
||||
|
||||
@interface RCTUIManager (RCTRootView)
|
||||
|
||||
- (NSNumber *)allocateRootTag;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#import <UIKit/UIDevice.h>
|
||||
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTBridge+Private.h"
|
||||
#import "RCTDefines.h"
|
||||
#import "RCTDevMenu.h"
|
||||
#import "RCTLog.h"
|
||||
|
@ -83,14 +84,6 @@ RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
|||
|
||||
@end
|
||||
|
||||
// Private bridge interface
|
||||
@interface RCTBridge (RCTContextExecutor)
|
||||
|
||||
- (void)handleBuffer:(NSArray<NSArray *> *)buffer batchEnded:(BOOL)hasEnded;
|
||||
- (NSArray *)configForModuleName:(NSString *)moduleName;
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTContextExecutor
|
||||
{
|
||||
RCTJavaScriptContext *_context;
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#import "RCTDevMenu.h"
|
||||
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTBridge+Private.h"
|
||||
#import "RCTDefines.h"
|
||||
#import "RCTEventDispatcher.h"
|
||||
#import "RCTKeyCommands.h"
|
||||
|
@ -22,13 +22,6 @@
|
|||
|
||||
#if RCT_DEV
|
||||
|
||||
@interface RCTBridge (Profiling)
|
||||
|
||||
- (void)startProfiling;
|
||||
- (void)stopProfiling:(void (^)(NSData *))callback;
|
||||
|
||||
@end
|
||||
|
||||
static NSString *const RCTShowDevMenuNotification = @"RCTShowDevMenuNotification";
|
||||
static NSString *const RCTDevMenuSettingsKey = @"RCTDevMenu";
|
||||
|
||||
|
|
|
@ -11,18 +11,10 @@
|
|||
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTBridge+Private.h"
|
||||
#import "RCTLog.h"
|
||||
#import "RCTUtils.h"
|
||||
|
||||
@interface RCTBridge (Private)
|
||||
|
||||
/**
|
||||
* Allow super fast, one time, timers to skip the queue and be directly executed
|
||||
*/
|
||||
- (void)_immediatelyCallTimer:(NSNumber *)timer;
|
||||
|
||||
@end
|
||||
|
||||
@interface RCTTimer : NSObject
|
||||
|
||||
@property (nonatomic, strong, readonly) NSDate *target;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#import "RCTAssert.h"
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTBridge+Private.h"
|
||||
#import "RCTComponentData.h"
|
||||
#import "RCTDefines.h"
|
||||
#import "RCTLog.h"
|
||||
|
@ -32,13 +33,6 @@ NSString *const RCTProfileDidEndProfiling = @"RCTProfileDidEndProfiling";
|
|||
|
||||
#if RCT_DEV
|
||||
|
||||
@interface RCTBridge ()
|
||||
|
||||
- (void)dispatchBlock:(dispatch_block_t)block
|
||||
queue:(dispatch_queue_t)queue;
|
||||
|
||||
@end
|
||||
|
||||
#pragma mark - Constants
|
||||
|
||||
NSString const *RCTProfileTraceEvents = @"traceEvents";
|
||||
|
|
|
@ -221,6 +221,7 @@
|
|||
1450FF831BCFF28A00208362 /* RCTProfileTrampoline-arm64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = "RCTProfileTrampoline-arm64.S"; sourceTree = "<group>"; };
|
||||
1450FF851BCFF28A00208362 /* RCTProfileTrampoline-x86_64.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = "RCTProfileTrampoline-x86_64.S"; sourceTree = "<group>"; };
|
||||
1482F9E61B55B927000ADFF3 /* RCTBridgeDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RCTBridgeDelegate.h; sourceTree = "<group>"; };
|
||||
14A43DB81C1F849600794BC8 /* RCTBridge+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RCTBridge+Private.h"; sourceTree = "<group>"; };
|
||||
14BF717F1C04793D00C97D0C /* RCTProfileTrampoline-i386.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; path = "RCTProfileTrampoline-i386.S"; sourceTree = "<group>"; };
|
||||
14BF71811C04795500C97D0C /* RCTMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTMacros.h; sourceTree = "<group>"; };
|
||||
14C2CA6F1B3AC63800E6CBB2 /* RCTModuleMethod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTModuleMethod.h; sourceTree = "<group>"; };
|
||||
|
@ -538,6 +539,7 @@
|
|||
83CBBA501A601E3B00E9B192 /* RCTUtils.m */,
|
||||
13BB3D001BECD54500932C10 /* RCTImageSource.h */,
|
||||
13BB3D011BECD54500932C10 /* RCTImageSource.m */,
|
||||
14A43DB81C1F849600794BC8 /* RCTBridge+Private.h */,
|
||||
);
|
||||
path = Base;
|
||||
sourceTree = "<group>";
|
||||
|
|
Loading…
Reference in New Issue