diff --git a/React/Base/RCTBundleURLProvider.h b/React/Base/RCTBundleURLProvider.h index 1192f973790702..26fbbd059ea6cf 100644 --- a/React/Base/RCTBundleURLProvider.h +++ b/React/Base/RCTBundleURLProvider.h @@ -12,7 +12,7 @@ RCT_EXTERN NSString *const RCTBundleURLProviderUpdatedNotification; RCT_EXTERN const NSUInteger kRCTBundleURLProviderDefaultPort; -#if RCT_DEV_MENU +#if RCT_DEV_MENU | RCT_PACKAGER_LOADING_FUNCTIONALITY /** * Allow/disallow accessing the packager server for various runtime scenario. * For instance, if a test run should never access the packager, disable it diff --git a/React/Base/RCTBundleURLProvider.mm b/React/Base/RCTBundleURLProvider.mm index d819e1b99d3ce8..eea970452f7a6d 100644 --- a/React/Base/RCTBundleURLProvider.mm +++ b/React/Base/RCTBundleURLProvider.mm @@ -15,7 +15,7 @@ const NSUInteger kRCTBundleURLProviderDefaultPort = RCT_METRO_PORT; -#if RCT_DEV_MENU +#if RCT_DEV_MENU | RCT_PACKAGER_LOADING_FUNCTIONALITY static BOOL kRCTAllowPackagerAccess = YES; void RCTBundleURLProviderAllowPackagerServerAccess(BOOL allowed) { @@ -150,7 +150,7 @@ - (NSString *)packagerServerHost - (NSString *)packagerServerHostPort { -#if RCT_DEV_MENU +#if RCT_DEV_MENU | RCT_PACKAGER_LOADING_FUNCTIONALITY if (!kRCTAllowPackagerAccess) { RCTLogInfo(@"Packager server access is disabled in this environment"); return nil; diff --git a/React/Base/RCTDefines.h b/React/Base/RCTDefines.h index b416f71a6353cf..4b9517eeabc28e 100644 --- a/React/Base/RCTDefines.h +++ b/React/Base/RCTDefines.h @@ -54,6 +54,15 @@ #define RCT_DEV_MENU RCT_DEV #endif +/** + * Controls for the core packgaer loading functionality + * By default, this inherits from RCT_DEV_MENU but it also gives the capability to + * enable the packager functionality without the rest of the dev tools from RCT_DEV_MENU + */ +#ifndef RCT_ENABLE_LOADING_FROM_PACKAGER +#define RCT_ENABLE_LOADING_FROM_PACKAGER RCT_DEV_MENU +#endif + #ifndef RCT_ENABLE_INSPECTOR #if RCT_DEV && __has_include() #define RCT_ENABLE_INSPECTOR 1 @@ -62,11 +71,11 @@ #endif #endif -#ifndef ENABLE_PACKAGER_CONNECTION +#ifndef RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION #if RCT_DEV && (__has_include("RCTPackagerConnection.h") || __has_include()) -#define ENABLE_PACKAGER_CONNECTION 1 +#define RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION 1 #else -#define ENABLE_PACKAGER_CONNECTION 0 +#define RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION 0 #endif #endif diff --git a/React/CoreModules/RCTDevSettings.mm b/React/CoreModules/RCTDevSettings.mm index 9bba3d8d993a54..47258efe70667f 100644 --- a/React/CoreModules/RCTDevSettings.mm +++ b/React/CoreModules/RCTDevSettings.mm @@ -32,7 +32,7 @@ static NSString *const kRCTDevSettingsUserDefaultsKey = @"RCTDevMenu"; -#if ENABLE_PACKAGER_CONNECTION +#if RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION #import #import #endif @@ -114,14 +114,14 @@ - (void)_reloadWithDefaults:(NSDictionary *)defaultValues @end -#if ENABLE_PACKAGER_CONNECTION +#if RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION static RCTHandlerToken reloadToken; static std::atomic numInitializedModules{0}; #endif @interface RCTDevSettings () { BOOL _isJSLoaded; -#if ENABLE_PACKAGER_CONNECTION +#if RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION RCTHandlerToken _bridgeExecutorOverrideToken; #endif } @@ -174,7 +174,7 @@ - (instancetype)initWithDataSource:(id)dataSource - (void)initialize { -#if ENABLE_PACKAGER_CONNECTION +#if RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION if (self.bridge) { RCTBridge *__weak weakBridge = self.bridge; _bridgeExecutorOverrideToken = [[RCTPackagerConnection sharedPackagerConnection] @@ -227,7 +227,7 @@ - (dispatch_queue_t)methodQueue - (void)invalidate { [super invalidate]; -#if ENABLE_PACKAGER_CONNECTION +#if RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION if (self.bridge) { [[RCTPackagerConnection sharedPackagerConnection] removeHandler:_bridgeExecutorOverrideToken]; } @@ -440,7 +440,7 @@ - (void)setExecutorClass:(Class)executorClass - (void)addHandler:(id)handler forPackagerMethod:(NSString *)name { -#if ENABLE_PACKAGER_CONNECTION +#if RCT_DEV_SETTINGS_ENABLE_PACKAGER_CONNECTION [[RCTPackagerConnection sharedPackagerConnection] addHandler:handler forMethod:name]; #endif } diff --git a/React/CoreModules/RCTDevSplitBundleLoader.mm b/React/CoreModules/RCTDevSplitBundleLoader.mm index 4afc2ee4fd7415..fc7b2df23eb14f 100644 --- a/React/CoreModules/RCTDevSplitBundleLoader.mm +++ b/React/CoreModules/RCTDevSplitBundleLoader.mm @@ -22,7 +22,7 @@ @interface RCTDevSplitBundleLoader () @end -#if RCT_DEV_MENU +#if RCT_DEV_MENU | RCT_PACKAGER_LOADING_FUNCTIONALITY @implementation RCTDevSplitBundleLoader diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index fcf3ede83acdff..77bae805a7f782 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -1130,7 +1130,7 @@ - (void)executeSourceCode:(NSData *)sourceCode sync:(BOOL)sync [self.devSettings setupHMRClientWithBundleURL:self.bundleURL]; } -#if RCT_DEV_MENU +#if RCT_DEV_MENU | RCT_PACKAGER_LOADING_FUNCTIONALITY - (void)loadAndExecuteSplitBundleURL:(NSURL *)bundleURL onError:(RCTLoadAndExecuteErrorBlock)onError onComplete:(dispatch_block_t)onComplete