mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-01 22:41:28 +08:00
Remove the experimental concept of whitelisted modules
Reviewed By: dcaspi Differential Revision: D6124036 fbshipit-source-id: af3771ce2204b3695f79265d5aade7e321e12a3e
This commit is contained in:
committed by
Facebook Github Bot
parent
fe792f5878
commit
55f75dfd65
@@ -246,17 +246,7 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
||||
|
||||
- (NSArray *)configForModuleName:(NSString *)moduleName
|
||||
{
|
||||
RCTModuleData *moduleData = _moduleDataByName[moduleName];
|
||||
if (moduleData) {
|
||||
#if RCT_DEV
|
||||
if ([self.delegate respondsToSelector:@selector(whitelistedModulesForBridge:)]) {
|
||||
NSArray *whitelisted = [self.delegate whitelistedModulesForBridge:self];
|
||||
RCTAssert(!whitelisted || [whitelisted containsObject:[moduleData moduleClass]],
|
||||
@"Required config for %@, which was not whitelisted", moduleName);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return moduleData.config;
|
||||
return _moduleDataByName[moduleName].config;
|
||||
}
|
||||
|
||||
- (void)initModulesWithDispatchGroup:(dispatch_group_t)dispatchGroup
|
||||
@@ -399,11 +389,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
||||
{
|
||||
RCT_PROFILE_BEGIN_EVENT(0, @"-[RCTBatchedBridge prepareModulesWithDispatch]", nil);
|
||||
|
||||
NSArray<Class> *whitelistedModules = nil;
|
||||
if ([self.delegate respondsToSelector:@selector(whitelistedModulesForBridge:)]) {
|
||||
whitelistedModules = [self.delegate whitelistedModulesForBridge:self];
|
||||
}
|
||||
|
||||
BOOL initializeImmediately = NO;
|
||||
if (dispatchGroup == NULL) {
|
||||
// If no dispatchGroup is passed in, we must prepare everything immediately.
|
||||
@@ -414,10 +399,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
||||
|
||||
// Set up modules that require main thread init or constants export
|
||||
for (RCTModuleData *moduleData in _moduleDataByID) {
|
||||
if (whitelistedModules && ![whitelistedModules containsObject:[moduleData moduleClass]]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (moduleData.requiresMainQueueSetup || moduleData.hasConstantsToExport) {
|
||||
// Modules that need to be set up on the main thread cannot be initialized
|
||||
// lazily when required without doing a dispatch_sync to the main thread,
|
||||
@@ -450,12 +431,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithBundleURL:(__unused NSURL *)bundleUR
|
||||
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
||||
}
|
||||
|
||||
- (void)whitelistedModulesDidChange
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
[self prepareModulesWithDispatchGroup:NULL];
|
||||
}
|
||||
|
||||
- (void)setUpExecutor
|
||||
{
|
||||
[_javaScriptExecutor setUp];
|
||||
|
||||
@@ -161,17 +161,6 @@ RCT_EXTERN NSString *RCTBridgeModuleNameForClass(Class bridgeModuleClass);
|
||||
*/
|
||||
- (BOOL)moduleIsInitialized:(Class)moduleClass;
|
||||
|
||||
/**
|
||||
* Call when your delegate's `whitelistedModulesForBridge:` value has changed.
|
||||
* In response to this, the bridge will immediately instantiate any (whitelisted)
|
||||
* native modules that require main thread initialization. Modules that do not require
|
||||
* main thread initialization will still be created lazily.
|
||||
*
|
||||
* This method must be called on the main thread, as any pending native modules
|
||||
* will be initialized immediately.
|
||||
*/
|
||||
- (void)whitelistedModulesDidChange;
|
||||
|
||||
/**
|
||||
* All registered bridge module classes.
|
||||
*/
|
||||
|
||||
@@ -252,11 +252,6 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
return [self.batchedBridge moduleIsInitialized:moduleClass];
|
||||
}
|
||||
|
||||
- (void)whitelistedModulesDidChange
|
||||
{
|
||||
[self.batchedBridge whitelistedModulesDidChange];
|
||||
}
|
||||
|
||||
- (void)reload
|
||||
{
|
||||
#if RCT_ENABLE_INSPECTOR
|
||||
|
||||
@@ -40,20 +40,6 @@
|
||||
*/
|
||||
- (NSArray<id<RCTBridgeModule>> *)extraModulesForBridge:(RCTBridge *)bridge;
|
||||
|
||||
/**
|
||||
* Customize how bridge native modules are initialized.
|
||||
*
|
||||
* By default all modules are created lazily except those that have constants to export
|
||||
* or require main thread initialization. If you want to limit the set of native
|
||||
* modules that this should be considered for, implement this method.
|
||||
*
|
||||
* Return nil to whitelist all modules found. Modules passed in extraModulesForBridge:
|
||||
* are automatically whitelisted.
|
||||
*
|
||||
* @experimental
|
||||
*/
|
||||
- (NSArray<Class> *)whitelistedModulesForBridge:(RCTBridge *)bridge;
|
||||
|
||||
/**
|
||||
* Configure whether the JSCExecutor created should use the system JSC API or
|
||||
* alternative hooks provided. When returning YES from this method, you must have
|
||||
|
||||
@@ -522,17 +522,7 @@ struct RCTInstanceCallback : public InstanceCallback {
|
||||
|
||||
- (NSArray *)configForModuleName:(NSString *)moduleName
|
||||
{
|
||||
RCTModuleData *moduleData = _moduleDataByName[moduleName];
|
||||
if (moduleData) {
|
||||
#if RCT_DEV
|
||||
if ([self.delegate respondsToSelector:@selector(whitelistedModulesForBridge:)]) {
|
||||
NSArray *whitelisted = [self.delegate whitelistedModulesForBridge:self];
|
||||
RCTAssert(!whitelisted || [whitelisted containsObject:[moduleData moduleClass]],
|
||||
@"Required config for %@, which was not whitelisted", moduleName);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return moduleData.config;
|
||||
return _moduleDataByName[moduleName].config;
|
||||
}
|
||||
|
||||
- (NSArray<RCTModuleData *> *)registerModulesForClasses:(NSArray<Class> *)moduleClasses
|
||||
@@ -695,11 +685,6 @@ struct RCTInstanceCallback : public InstanceCallback {
|
||||
{
|
||||
RCT_PROFILE_BEGIN_EVENT(0, @"-[RCTBatchedBridge prepareModulesWithDispatch]", nil);
|
||||
|
||||
NSArray<Class> *whitelistedModules = nil;
|
||||
if ([self.delegate respondsToSelector:@selector(whitelistedModulesForBridge:)]) {
|
||||
whitelistedModules = [self.delegate whitelistedModulesForBridge:self];
|
||||
}
|
||||
|
||||
BOOL initializeImmediately = NO;
|
||||
if (dispatchGroup == NULL) {
|
||||
// If no dispatchGroup is passed in, we must prepare everything immediately.
|
||||
@@ -712,10 +697,6 @@ struct RCTInstanceCallback : public InstanceCallback {
|
||||
[_performanceLogger setValue:0 forTag:RCTPLNativeModuleMainThread];
|
||||
|
||||
for (RCTModuleData *moduleData in _moduleDataByID) {
|
||||
if (whitelistedModules && ![whitelistedModules containsObject:[moduleData moduleClass]]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (moduleData.requiresMainQueueSetup) {
|
||||
// Modules that need to be set up on the main thread cannot be initialized
|
||||
// lazily when required without doing a dispatch_sync to the main thread,
|
||||
@@ -747,12 +728,6 @@ struct RCTInstanceCallback : public InstanceCallback {
|
||||
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
|
||||
}
|
||||
|
||||
- (void)whitelistedModulesDidChange
|
||||
{
|
||||
RCTAssertMainQueue();
|
||||
[self _prepareModulesWithDispatchGroup:NULL];
|
||||
}
|
||||
|
||||
- (void)registerModuleForFrameUpdates:(id<RCTBridgeModule>)module
|
||||
withModuleData:(RCTModuleData *)moduleData
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user