mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-29 04:35:36 +08:00
Upgraded dev menu
This commit is contained in:
@@ -78,7 +78,7 @@ var TabBarExample = React.createClass({
|
|||||||
this.setState({
|
this.setState({
|
||||||
selectedTab: 'greenTab',
|
selectedTab: 'greenTab',
|
||||||
presses: this.state.presses + 1
|
presses: this.state.presses + 1
|
||||||
});
|
});
|
||||||
}}>
|
}}>
|
||||||
{this._renderContent('#21551C', 'Green Tab')}
|
{this._renderContent('#21551C', 'Green Tab')}
|
||||||
</TabBarIOS.Item>
|
</TabBarIOS.Item>
|
||||||
|
|||||||
@@ -582,7 +582,7 @@ var TextInput = React.createClass({
|
|||||||
var counter = event.nativeEvent.eventCounter;
|
var counter = event.nativeEvent.eventCounter;
|
||||||
if (counter > this.state.mostRecentEventCounter) {
|
if (counter > this.state.mostRecentEventCounter) {
|
||||||
this.setState({mostRecentEventCounter: counter});
|
this.setState({mostRecentEventCounter: counter});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -964,18 +964,13 @@ static id<RCTJavaScriptExecutor> _latestJSExecutor;
|
|||||||
__weak RCTBridge *weakSelf = self;
|
__weak RCTBridge *weakSelf = self;
|
||||||
RCTKeyCommands *commands = [RCTKeyCommands sharedInstance];
|
RCTKeyCommands *commands = [RCTKeyCommands sharedInstance];
|
||||||
|
|
||||||
// Workaround around the first cmd+R not working: http://openradar.appspot.com/19613391
|
|
||||||
// You can register just the cmd key and do nothing. This will trigger the bug and cmd+R
|
|
||||||
// will work like a charm!
|
|
||||||
[commands registerKeyCommandWithInput:@""
|
|
||||||
modifierFlags:UIKeyModifierCommand
|
|
||||||
action:NULL];
|
|
||||||
// reload in current mode
|
// reload in current mode
|
||||||
[commands registerKeyCommandWithInput:@"r"
|
[commands registerKeyCommandWithInput:@"r"
|
||||||
modifierFlags:UIKeyModifierCommand
|
modifierFlags:UIKeyModifierCommand
|
||||||
action:^(UIKeyCommand *command) {
|
action:^(UIKeyCommand *command) {
|
||||||
[weakSelf reload];
|
[weakSelf reload];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,15 +36,16 @@
|
|||||||
@property (nonatomic, assign) BOOL liveReloadEnabled;
|
@property (nonatomic, assign) BOOL liveReloadEnabled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The time between checks for code changes. Defaults to 1 second.
|
* Manually show the dev menu (can be called from JS).
|
||||||
*/
|
|
||||||
@property (nonatomic, assign) NSTimeInterval liveReloadPeriod;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Manually show the dev menu.
|
|
||||||
*/
|
*/
|
||||||
- (void)show;
|
- (void)show;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manually reload the application. Equivalent to calling [bridge reload]
|
||||||
|
* directly, but can be called from JS.
|
||||||
|
*/
|
||||||
|
- (void)reload;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -28,6 +28,7 @@
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
static NSString *const RCTShowDevMenuNotification = @"RCTShowDevMenuNotification";
|
static NSString *const RCTShowDevMenuNotification = @"RCTShowDevMenuNotification";
|
||||||
|
static NSString *const RCTDevMenuSettingsKey = @"RCTDevMenu";
|
||||||
|
|
||||||
@implementation UIWindow (RCTDevMenu)
|
@implementation UIWindow (RCTDevMenu)
|
||||||
|
|
||||||
@@ -40,14 +41,20 @@ static NSString *const RCTShowDevMenuNotification = @"RCTShowDevMenuNotification
|
|||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface RCTDevMenu () <RCTBridgeModule, RCTInvalidating, UIActionSheetDelegate>
|
@interface RCTDevMenu () <RCTBridgeModule, UIActionSheetDelegate>
|
||||||
|
|
||||||
|
@property (nonatomic, strong) Class executorClass;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation RCTDevMenu
|
@implementation RCTDevMenu
|
||||||
{
|
{
|
||||||
NSTimer *_updateTimer;
|
|
||||||
UIActionSheet *_actionSheet;
|
UIActionSheet *_actionSheet;
|
||||||
|
NSUserDefaults *_defaults;
|
||||||
|
NSMutableDictionary *_settings;
|
||||||
|
NSURLSessionDataTask *_updateTask;
|
||||||
|
NSURL *_liveReloadURL;
|
||||||
|
BOOL _jsLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
@synthesize bridge = _bridge;
|
@synthesize bridge = _bridge;
|
||||||
@@ -66,31 +73,43 @@ RCT_EXPORT_MODULE()
|
|||||||
{
|
{
|
||||||
if ((self = [super init])) {
|
if ((self = [super init])) {
|
||||||
|
|
||||||
_shakeToShow = YES;
|
_defaults = [NSUserDefaults standardUserDefaults];
|
||||||
_liveReloadPeriod = 1.0; // 1 second
|
[self updateSettings];
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
|
||||||
selector:@selector(showOnShake)
|
NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
|
||||||
name:RCTShowDevMenuNotification
|
|
||||||
object:nil];
|
[notificationCenter addObserver:self
|
||||||
|
selector:@selector(showOnShake)
|
||||||
|
name:RCTShowDevMenuNotification
|
||||||
|
object:nil];
|
||||||
|
|
||||||
|
[notificationCenter addObserver:self
|
||||||
|
selector:@selector(updateSettings)
|
||||||
|
name:NSUserDefaultsDidChangeNotification
|
||||||
|
object:nil];
|
||||||
|
|
||||||
|
[notificationCenter addObserver:self
|
||||||
|
selector:@selector(jsLoaded)
|
||||||
|
name:RCTJavaScriptDidLoadNotification
|
||||||
|
object:nil];
|
||||||
|
|
||||||
#if TARGET_IPHONE_SIMULATOR
|
#if TARGET_IPHONE_SIMULATOR
|
||||||
|
|
||||||
__weak RCTDevMenu *weakSelf = self;
|
__weak RCTDevMenu *weakSelf = self;
|
||||||
RCTKeyCommands *commands = [RCTKeyCommands sharedInstance];
|
RCTKeyCommands *commands = [RCTKeyCommands sharedInstance];
|
||||||
|
|
||||||
// Workaround around the first cmd+D not working: http://openradar.appspot.com/19613391
|
// toggle debug menu
|
||||||
// You can register just the cmd key and do nothing. This will trigger the bug and cmd+R
|
|
||||||
// will work like a charm!
|
|
||||||
[commands registerKeyCommandWithInput:@""
|
|
||||||
modifierFlags:UIKeyModifierCommand
|
|
||||||
action:NULL];
|
|
||||||
|
|
||||||
// reload in debug mode
|
|
||||||
[commands registerKeyCommandWithInput:@"d"
|
[commands registerKeyCommandWithInput:@"d"
|
||||||
modifierFlags:UIKeyModifierCommand
|
modifierFlags:UIKeyModifierCommand
|
||||||
action:^(UIKeyCommand *command) {
|
action:^(UIKeyCommand *command) {
|
||||||
__strong RCTDevMenu *strongSelf = weakSelf;
|
[weakSelf toggle];
|
||||||
[strongSelf show];
|
}];
|
||||||
|
|
||||||
|
// reload in normal mode
|
||||||
|
[commands registerKeyCommandWithInput:@"n"
|
||||||
|
modifierFlags:UIKeyModifierCommand
|
||||||
|
action:^(UIKeyCommand *command) {
|
||||||
|
weakSelf.executorClass = Nil;
|
||||||
}];
|
}];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -98,11 +117,58 @@ RCT_EXPORT_MODULE()
|
|||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)updateSettings
|
||||||
|
{
|
||||||
|
_settings = [NSMutableDictionary dictionaryWithDictionary:[_defaults objectForKey:RCTDevMenuSettingsKey]];
|
||||||
|
|
||||||
|
self.shakeToShow = [_settings[@"shakeToShow"] ?: @YES boolValue];
|
||||||
|
self.profilingEnabled = [_settings[@"profilingEnabled"] ?: @NO boolValue];
|
||||||
|
self.liveReloadEnabled = [_settings[@"liveReloadEnabled"] ?: @NO boolValue];
|
||||||
|
self.executorClass = NSClassFromString(_settings[@"executorClass"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)jsLoaded
|
||||||
|
{
|
||||||
|
_jsLoaded = YES;
|
||||||
|
|
||||||
|
// Check if live reloading is available
|
||||||
|
_liveReloadURL = nil;
|
||||||
|
RCTSourceCode *sourceCodeModule = _bridge.modules[RCTBridgeModuleNameForClass([RCTSourceCode class])];
|
||||||
|
if (!sourceCodeModule.scriptURL) {
|
||||||
|
if (!sourceCodeModule) {
|
||||||
|
RCTLogWarn(@"RCTSourceCode module not found");
|
||||||
|
} else {
|
||||||
|
RCTLogWarn(@"RCTSourceCode module scriptURL has not been set");
|
||||||
|
}
|
||||||
|
} else if (![sourceCodeModule.scriptURL isFileURL]) {
|
||||||
|
// Live reloading is disabled when running from bundled JS file
|
||||||
|
_liveReloadURL = [[NSURL alloc] initWithString:@"/onchange" relativeToURL:sourceCodeModule.scriptURL];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hit these setters again after bridge has finished loading
|
||||||
|
self.profilingEnabled = _profilingEnabled;
|
||||||
|
self.liveReloadEnabled = _liveReloadEnabled;
|
||||||
|
self.executorClass = _executorClass;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)dealloc
|
- (void)dealloc
|
||||||
{
|
{
|
||||||
|
[_updateTask cancel];
|
||||||
|
[_actionSheet dismissWithClickedButtonIndex:_actionSheet.cancelButtonIndex animated:YES];
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
[[NSNotificationCenter defaultCenter] removeObserver:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)updateSetting:(NSString *)name value:(id)value
|
||||||
|
{
|
||||||
|
if (value) {
|
||||||
|
_settings[name] = value;
|
||||||
|
} else {
|
||||||
|
[_settings removeObjectForKey:name];
|
||||||
|
}
|
||||||
|
[_defaults setObject:_settings forKey:RCTDevMenuSettingsKey];
|
||||||
|
[_defaults synchronize];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)showOnShake
|
- (void)showOnShake
|
||||||
{
|
{
|
||||||
if (_shakeToShow) {
|
if (_shakeToShow) {
|
||||||
@@ -110,48 +176,73 @@ RCT_EXPORT_MODULE()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)show
|
- (void)toggle
|
||||||
{
|
{
|
||||||
if (_actionSheet) {
|
if (_actionSheet) {
|
||||||
|
[_actionSheet dismissWithClickedButtonIndex:_actionSheet.cancelButtonIndex animated:YES];
|
||||||
|
_actionSheet = nil;
|
||||||
|
} else {
|
||||||
|
[self show];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RCT_EXPORT_METHOD(show)
|
||||||
|
{
|
||||||
|
if (_actionSheet || !_bridge) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *debugTitleChrome = _bridge.executorClass && _bridge.executorClass == NSClassFromString(@"RCTWebSocketExecutor") ? @"Disable Chrome Debugging" : @"Enable Chrome Debugging";
|
NSString *debugTitleChrome = _executorClass && _executorClass == NSClassFromString(@"RCTWebSocketExecutor") ? @"Disable Chrome Debugging" : @"Debug in Chrome";
|
||||||
NSString *debugTitleSafari = _bridge.executorClass && _bridge.executorClass == NSClassFromString(@"RCTWebViewExecutor") ? @"Disable Safari Debugging" : @"Enable Safari Debugging";
|
NSString *debugTitleSafari = _executorClass && _executorClass == NSClassFromString(@"RCTWebViewExecutor") ? @"Disable Safari Debugging" : @"Debug in Safari";
|
||||||
NSString *liveReloadTitle = _liveReloadEnabled ? @"Disable Live Reload" : @"Enable Live Reload";
|
|
||||||
NSString *profilingTitle = RCTProfileIsProfiling() ? @"Stop Profiling" : @"Start Profiling";
|
|
||||||
|
|
||||||
UIActionSheet *actionSheet =
|
UIActionSheet *actionSheet =
|
||||||
[[UIActionSheet alloc] initWithTitle:@"React Native: Development"
|
[[UIActionSheet alloc] initWithTitle:@"React Native: Development"
|
||||||
delegate:self
|
delegate:self
|
||||||
cancelButtonTitle:@"Cancel"
|
cancelButtonTitle:nil
|
||||||
destructiveButtonTitle:nil
|
destructiveButtonTitle:nil
|
||||||
otherButtonTitles:@"Reload", debugTitleChrome, debugTitleSafari, liveReloadTitle, profilingTitle, nil];
|
otherButtonTitles:@"Reload", debugTitleChrome, debugTitleSafari, nil];
|
||||||
|
|
||||||
|
if (_liveReloadURL) {
|
||||||
|
|
||||||
|
NSString *liveReloadTitle = _liveReloadEnabled ? @"Disable Live Reload" : @"Enable Live Reload";
|
||||||
|
NSString *profilingTitle = RCTProfileIsProfiling() ? @"Stop Profiling" : @"Start Profiling";
|
||||||
|
|
||||||
|
[actionSheet addButtonWithTitle:liveReloadTitle];
|
||||||
|
[actionSheet addButtonWithTitle:profilingTitle];
|
||||||
|
}
|
||||||
|
|
||||||
|
[actionSheet addButtonWithTitle:@"Cancel"];
|
||||||
|
actionSheet.cancelButtonIndex = [actionSheet numberOfButtons] - 1;
|
||||||
|
|
||||||
actionSheet.actionSheetStyle = UIBarStyleBlack;
|
actionSheet.actionSheetStyle = UIBarStyleBlack;
|
||||||
[actionSheet showInView:[UIApplication sharedApplication].keyWindow.rootViewController.view];
|
[actionSheet showInView:[UIApplication sharedApplication].keyWindow.rootViewController.view];
|
||||||
_actionSheet = actionSheet;
|
_actionSheet = actionSheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RCT_EXPORT_METHOD(reload)
|
||||||
|
{
|
||||||
|
_jsLoaded = NO;
|
||||||
|
_liveReloadURL = nil;
|
||||||
|
[_bridge reload];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
|
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
|
||||||
{
|
{
|
||||||
_actionSheet = nil;
|
_actionSheet = nil;
|
||||||
|
|
||||||
switch (buttonIndex) {
|
switch (buttonIndex) {
|
||||||
case 0: {
|
case 0: {
|
||||||
[_bridge reload];
|
[self reload];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: {
|
case 1: {
|
||||||
Class cls = NSClassFromString(@"RCTWebSocketExecutor");
|
Class cls = NSClassFromString(@"RCTWebSocketExecutor");
|
||||||
_bridge.executorClass = (_bridge.executorClass != cls) ? cls : nil;
|
self.executorClass = (_executorClass == cls) ? Nil : cls;
|
||||||
[_bridge reload];
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: {
|
case 2: {
|
||||||
Class cls = NSClassFromString(@"RCTWebViewExecutor");
|
Class cls = NSClassFromString(@"RCTWebViewExecutor");
|
||||||
_bridge.executorClass = (_bridge.executorClass != cls) ? cls : Nil;
|
self.executorClass = (_executorClass == cls) ? Nil : cls;
|
||||||
[_bridge reload];
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 3: {
|
case 3: {
|
||||||
@@ -167,89 +258,110 @@ RCT_EXPORT_MODULE()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setShakeToShow:(BOOL)shakeToShow
|
||||||
|
{
|
||||||
|
if (_shakeToShow != shakeToShow) {
|
||||||
|
_shakeToShow = shakeToShow;
|
||||||
|
[self updateSetting:@"shakeToShow" value: @(_shakeToShow)];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setProfilingEnabled:(BOOL)enabled
|
- (void)setProfilingEnabled:(BOOL)enabled
|
||||||
{
|
{
|
||||||
if (_profilingEnabled == enabled) {
|
if (_profilingEnabled != enabled) {
|
||||||
return;
|
_profilingEnabled = enabled;
|
||||||
|
[self updateSetting:@"profilingEnabled" value: @(_profilingEnabled)];
|
||||||
}
|
}
|
||||||
|
|
||||||
_profilingEnabled = enabled;
|
if (_liveReloadURL && enabled != RCTProfileIsProfiling()) {
|
||||||
if (RCTProfileIsProfiling()) {
|
if (enabled) {
|
||||||
[_bridge stopProfiling];
|
[_bridge startProfiling];
|
||||||
} else {
|
} else {
|
||||||
[_bridge startProfiling];
|
[_bridge stopProfiling];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setLiveReloadEnabled:(BOOL)enabled
|
- (void)setLiveReloadEnabled:(BOOL)enabled
|
||||||
{
|
{
|
||||||
if (_liveReloadEnabled == enabled) {
|
if (_liveReloadEnabled != enabled) {
|
||||||
|
_liveReloadEnabled = enabled;
|
||||||
|
[self updateSetting:@"liveReloadEnabled" value: @(_liveReloadEnabled)];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_liveReloadEnabled) {
|
||||||
|
[self checkForUpdates];
|
||||||
|
} else {
|
||||||
|
[_updateTask cancel];
|
||||||
|
_updateTask = nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setExecutorClass:(Class)executorClass
|
||||||
|
{
|
||||||
|
if (_executorClass != executorClass) {
|
||||||
|
_executorClass = executorClass;
|
||||||
|
[self updateSetting:@"executorClass" value: NSStringFromClass(executorClass)];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_bridge.executorClass != executorClass) {
|
||||||
|
|
||||||
|
// TODO (6929129): we can remove this special case test once we have better
|
||||||
|
// support for custom executors in the dev menu. But right now this is
|
||||||
|
// needed to prevent overriding a custom executor with the default if a
|
||||||
|
// custom executor has been set directly on the bridge
|
||||||
|
if (executorClass == Nil &&
|
||||||
|
(_bridge.executorClass != NSClassFromString(@"RCTWebSocketExecutor") &&
|
||||||
|
_bridge.executorClass != NSClassFromString(@"RCTWebViewExecutor"))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_bridge.executorClass = executorClass;
|
||||||
|
[self reload];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)checkForUpdates
|
||||||
|
{
|
||||||
|
if (!_jsLoaded || !_liveReloadEnabled || !_liveReloadURL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_liveReloadEnabled = enabled;
|
if (_updateTask) {
|
||||||
if (_liveReloadEnabled) {
|
[_updateTask cancel];
|
||||||
|
_updateTask = nil;
|
||||||
_updateTimer = [NSTimer scheduledTimerWithTimeInterval:_liveReloadPeriod
|
return;
|
||||||
target:self
|
|
||||||
selector:@selector(pollForUpdates)
|
|
||||||
userInfo:nil
|
|
||||||
repeats:YES];
|
|
||||||
} else {
|
|
||||||
|
|
||||||
[_updateTimer invalidate];
|
|
||||||
_updateTimer = nil;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)setLiveReloadPeriod:(NSTimeInterval)liveReloadPeriod
|
|
||||||
{
|
|
||||||
_liveReloadPeriod = liveReloadPeriod;
|
|
||||||
if (_liveReloadEnabled) {
|
|
||||||
self.liveReloadEnabled = NO;
|
|
||||||
self.liveReloadEnabled = YES;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)pollForUpdates
|
|
||||||
{
|
|
||||||
RCTSourceCode *sourceCodeModule = _bridge.modules[RCTBridgeModuleNameForClass([RCTSourceCode class])];
|
|
||||||
if (!sourceCodeModule) {
|
|
||||||
RCTLogError(@"RCTSourceCode module not found");
|
|
||||||
self.liveReloadEnabled = NO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
NSURL *longPollURL = [[NSURL alloc] initWithString:@"/onchange" relativeToURL:sourceCodeModule.scriptURL];
|
__weak RCTDevMenu *weakSelf = self;
|
||||||
[NSURLConnection sendAsynchronousRequest:[NSURLRequest requestWithURL:longPollURL]
|
_updateTask = [[NSURLSession sharedSession] dataTaskWithURL:_liveReloadURL completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
|
||||||
queue:[[NSOperationQueue alloc] init]
|
|
||||||
completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
|
|
||||||
|
|
||||||
NSHTTPURLResponse *HTTPResponse = (NSHTTPURLResponse *)response;
|
dispatch_async(dispatch_get_main_queue(), ^{
|
||||||
if (_liveReloadEnabled && HTTPResponse.statusCode == 205) {
|
__strong RCTDevMenu *strongSelf = weakSelf;
|
||||||
[_bridge reload];
|
if (strongSelf && strongSelf->_liveReloadEnabled) {
|
||||||
}
|
NSHTTPURLResponse *HTTPResponse = (NSHTTPURLResponse *)response;
|
||||||
}];
|
if (!error && HTTPResponse.statusCode == 205) {
|
||||||
}
|
[strongSelf reload];
|
||||||
|
} else {
|
||||||
|
strongSelf->_updateTask = nil;
|
||||||
|
[strongSelf checkForUpdates];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
- (BOOL)isValid
|
}];
|
||||||
{
|
|
||||||
return !_liveReloadEnabled || _updateTimer != nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (void)invalidate
|
[_updateTask resume];
|
||||||
{
|
|
||||||
[_actionSheet dismissWithClickedButtonIndex:_actionSheet.cancelButtonIndex animated:YES];
|
|
||||||
[_updateTimer invalidate];
|
|
||||||
_updateTimer = nil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#else // Unvailable
|
#else // Unavailable when not in dev mode
|
||||||
|
|
||||||
@implementation RCTDevMenu
|
@implementation RCTDevMenu
|
||||||
|
|
||||||
- (void)show {}
|
- (void)show {}
|
||||||
|
- (void)reload {}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,17 @@ static RCTKeyCommands *RKKeyCommandsSharedInstance = nil;
|
|||||||
{
|
{
|
||||||
RCTAssertMainThread();
|
RCTAssertMainThread();
|
||||||
|
|
||||||
|
if (input.length && flags) {
|
||||||
|
|
||||||
|
// Workaround around the first cmd not working: http://openradar.appspot.com/19613391
|
||||||
|
// You can register just the cmd key and do nothing. This ensures that
|
||||||
|
// command-key modified commands will work first time.
|
||||||
|
|
||||||
|
[self registerKeyCommandWithInput:@""
|
||||||
|
modifierFlags:flags
|
||||||
|
action:nil];
|
||||||
|
}
|
||||||
|
|
||||||
UIKeyCommand *command = [UIKeyCommand keyCommandWithInput:input
|
UIKeyCommand *command = [UIKeyCommand keyCommandWithInput:input
|
||||||
modifierFlags:flags
|
modifierFlags:flags
|
||||||
action:@selector(RCT_handleKeyCommand:)];
|
action:@selector(RCT_handleKeyCommand:)];
|
||||||
|
|||||||
@@ -91,7 +91,7 @@
|
|||||||
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
|
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
|
||||||
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
|
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
|
||||||
|
|
||||||
[NSURLConnection sendAsynchronousRequest:request queue:[[NSOperationQueue alloc] init] completionHandler:nil];
|
[[[NSURLSession sharedSession] dataTaskWithRequest:request] resume];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)showErrorMessage:(NSString *)message withStack:(NSArray *)stack showIfHidden:(BOOL)shouldShow
|
- (void)showErrorMessage:(NSString *)message withStack:(NSArray *)stack showIfHidden:(BOOL)shouldShow
|
||||||
|
|||||||
@@ -582,6 +582,7 @@
|
|||||||
GCC_DYNAMIC_NO_PIC = NO;
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
GCC_OPTIMIZATION_LEVEL = 0;
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||||
|
"DEBUG=1",
|
||||||
"RCT_DEBUG=1",
|
"RCT_DEBUG=1",
|
||||||
"RCT_DEV=1",
|
"RCT_DEV=1",
|
||||||
"RCT_NSASSERT=1",
|
"RCT_NSASSERT=1",
|
||||||
|
|||||||
Reference in New Issue
Block a user