File tree 2 files changed +26
-8
lines changed
2 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 7
7
8
8
#import < Foundation/Foundation.h>
9
9
10
- #if defined(__cplusplus)
11
- extern " C" {
12
- #endif
13
-
14
- extern NSString *const RCTBundleURLProviderUpdatedNotification;
10
+ #import " RCTDefines.h"
15
11
16
- extern const NSUInteger kRCTBundleURLProviderDefaultPort ;
12
+ RCT_EXTERN NSString *const RCTBundleURLProviderUpdatedNotification;
13
+ RCT_EXTERN const NSUInteger kRCTBundleURLProviderDefaultPort ;
17
14
18
- #if defined(__cplusplus)
19
- }
15
+ #if RCT_DEV_MENU
16
+ /* *
17
+ * Allow/disallow accessing the packager server for various runtime scenario.
18
+ * For instance, if a test run should never access the packager, disable it
19
+ * by calling this function before initializing React Native (RCTBridge etc).
20
+ * By default the access is enabled.
21
+ */
22
+ RCT_EXTERN void RCTBundleURLProviderAllowPackagerServerAccess (BOOL allowed);
20
23
#endif
21
24
22
25
@interface RCTBundleURLProvider : NSObject
Original file line number Diff line number Diff line change 9
9
10
10
#import " RCTConvert.h"
11
11
#import " RCTDefines.h"
12
+ #import " RCTLog.h"
12
13
13
14
NSString *const RCTBundleURLProviderUpdatedNotification = @" RCTBundleURLProviderUpdatedNotification" ;
14
15
15
16
const NSUInteger kRCTBundleURLProviderDefaultPort = RCT_METRO_PORT;
16
17
18
+ #if RCT_DEV_MENU
19
+ static BOOL kRCTAllowPackagerAccess = YES ;
20
+ void RCTBundleURLProviderAllowPackagerServerAccess (BOOL allowed)
21
+ {
22
+ kRCTAllowPackagerAccess = allowed;
23
+ }
24
+ #endif
25
+
17
26
static NSString *const kRCTJsLocationKey = @" RCT_jsLocation" ;
18
27
static NSString *const kRCTEnableDevKey = @" RCT_enableDev" ;
19
28
static NSString *const kRCTEnableMinificationKey = @" RCT_enableMinification" ;
@@ -127,6 +136,12 @@ - (NSString *)packagerServerHost
127
136
128
137
- (NSString *)packagerServerHostPort
129
138
{
139
+ #if RCT_DEV_MENU
140
+ if (!kRCTAllowPackagerAccess ) {
141
+ RCTLogInfo (@" Packager server access is disabled in this environment" );
142
+ return nil ;
143
+ }
144
+ #endif
130
145
NSString *location = [self jsLocation ];
131
146
#if RCT_DEV_MENU
132
147
if ([location length ] && ![RCTBundleURLProvider isPackagerRunning: location]) {
You can’t perform that action at this time.
0 commit comments