Add RCTDevSettings module
Summary:
This decouples non-UI logic from RCTDevMenu into a new module RCTDevSettings.
**Motivation**: This allows developers to change dev settings without depending on the built-in dev menu, e.g. if they want to introduce their own UI, or have other devtools logic that doesn't depend on an action sheet.
It also introduces the RCTDevSettingsDataSource protocol for storing dev tools preferences. This could allow a developer to implement alternative behaviors, e.g. loading the settings from some other config, changing settings based on the user, deciding not to persist some settings, or something else.
The included data source implementation, RCTDevSettingsUserDefaultsDataSource, uses NSUserDefaults and is backwards compatible with the older implementation, so **no workflows or dependent code will break, and old saved settings will persist.**
The RCTDevMenu interface has not changed and is therefore also backwards-compatible, though
some methods are now deprecated.
In order to ensure that RCTDevSettings
Closes https://github.com/facebook/react-native/pull/11613
Reviewed By: mmmulani
Differential Revision: D4571773
Pulled By: javache
fbshipit-source-id: 25555d0a6eaa81f694343e079ed02439e5845fbc
2017-02-24 14:50:29 +00:00
|
|
|
/**
|
|
|
|
* 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 <React/RCTBridge.h>
|
2017-05-05 15:32:15 +00:00
|
|
|
#import <React/RCTDefines.h>
|
|
|
|
|
|
|
|
@protocol RCTPackagerClientMethod;
|
Add RCTDevSettings module
Summary:
This decouples non-UI logic from RCTDevMenu into a new module RCTDevSettings.
**Motivation**: This allows developers to change dev settings without depending on the built-in dev menu, e.g. if they want to introduce their own UI, or have other devtools logic that doesn't depend on an action sheet.
It also introduces the RCTDevSettingsDataSource protocol for storing dev tools preferences. This could allow a developer to implement alternative behaviors, e.g. loading the settings from some other config, changing settings based on the user, deciding not to persist some settings, or something else.
The included data source implementation, RCTDevSettingsUserDefaultsDataSource, uses NSUserDefaults and is backwards compatible with the older implementation, so **no workflows or dependent code will break, and old saved settings will persist.**
The RCTDevMenu interface has not changed and is therefore also backwards-compatible, though
some methods are now deprecated.
In order to ensure that RCTDevSettings
Closes https://github.com/facebook/react-native/pull/11613
Reviewed By: mmmulani
Differential Revision: D4571773
Pulled By: javache
fbshipit-source-id: 25555d0a6eaa81f694343e079ed02439e5845fbc
2017-02-24 14:50:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* An abstraction for a key-value store to manage RCTDevSettings behavior.
|
|
|
|
* The default implementation persists settings using NSUserDefaults.
|
|
|
|
*/
|
|
|
|
@protocol RCTDevSettingsDataSource <NSObject>
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the setting with the given key to the given value.
|
|
|
|
* How the data source's state changes depends on the implementation.
|
|
|
|
*/
|
|
|
|
- (void)updateSettingWithValue:(id)value forKey:(NSString *)key;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the value for the setting with the given key.
|
|
|
|
*/
|
|
|
|
- (id)settingForKey:(NSString *)key;
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface RCTDevSettings : NSObject
|
|
|
|
|
|
|
|
- (instancetype)initWithDataSource:(id<RCTDevSettingsDataSource>)dataSource;
|
|
|
|
|
|
|
|
@property (nonatomic, readonly) BOOL isHotLoadingAvailable;
|
|
|
|
@property (nonatomic, readonly) BOOL isLiveReloadAvailable;
|
|
|
|
@property (nonatomic, readonly) BOOL isRemoteDebuggingAvailable;
|
2017-12-05 14:27:32 +00:00
|
|
|
@property (nonatomic, readonly) BOOL isNuclideDebuggingAvailable;
|
Add RCTDevSettings module
Summary:
This decouples non-UI logic from RCTDevMenu into a new module RCTDevSettings.
**Motivation**: This allows developers to change dev settings without depending on the built-in dev menu, e.g. if they want to introduce their own UI, or have other devtools logic that doesn't depend on an action sheet.
It also introduces the RCTDevSettingsDataSource protocol for storing dev tools preferences. This could allow a developer to implement alternative behaviors, e.g. loading the settings from some other config, changing settings based on the user, deciding not to persist some settings, or something else.
The included data source implementation, RCTDevSettingsUserDefaultsDataSource, uses NSUserDefaults and is backwards compatible with the older implementation, so **no workflows or dependent code will break, and old saved settings will persist.**
The RCTDevMenu interface has not changed and is therefore also backwards-compatible, though
some methods are now deprecated.
In order to ensure that RCTDevSettings
Closes https://github.com/facebook/react-native/pull/11613
Reviewed By: mmmulani
Differential Revision: D4571773
Pulled By: javache
fbshipit-source-id: 25555d0a6eaa81f694343e079ed02439e5845fbc
2017-02-24 14:50:29 +00:00
|
|
|
@property (nonatomic, readonly) BOOL isJSCSamplingProfilerAvailable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the bridge is connected to a remote JS executor.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, assign) BOOL isDebuggingRemotely;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Whether shaking will show RCTDevMenu. The menu is enabled by default if RCT_DEV=1, but
|
|
|
|
* you may wish to disable it so that you can provide your own shake handler.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, assign) BOOL isShakeToShowDevMenuEnabled;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether performance profiling is enabled.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, assign, setter=setProfilingEnabled:) BOOL isProfilingEnabled;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether automatic polling for JS code changes is enabled. Only applicable when
|
|
|
|
* running the app from a server.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, assign, setter=setLiveReloadEnabled:) BOOL isLiveReloadEnabled;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether hot loading is enabled.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, assign, setter=setHotLoadingEnabled:) BOOL isHotLoadingEnabled;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggle the element inspector.
|
|
|
|
*/
|
|
|
|
- (void)toggleElementInspector;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggle JSC's sampling profiler.
|
|
|
|
*/
|
|
|
|
- (void)toggleJSCSamplingProfiler;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables starting of profiling sampler on launch
|
|
|
|
*/
|
|
|
|
@property (nonatomic, assign) BOOL startSamplingProfilerOnLaunch;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the element inspector is visible.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, readonly) BOOL isElementInspectorShown;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the performance monitor is visible.
|
|
|
|
*/
|
|
|
|
@property (nonatomic, assign) BOOL isPerfMonitorShown;
|
|
|
|
|
2017-05-05 15:32:15 +00:00
|
|
|
#if RCT_DEV
|
2017-11-21 02:12:13 +00:00
|
|
|
- (void)addHandler:(id<RCTPackagerClientMethod>)handler forPackagerMethod:(NSString *)name __deprecated_msg("Use RCTPackagerConnection directly instead");
|
2017-05-05 15:32:15 +00:00
|
|
|
#endif
|
|
|
|
|
Add RCTDevSettings module
Summary:
This decouples non-UI logic from RCTDevMenu into a new module RCTDevSettings.
**Motivation**: This allows developers to change dev settings without depending on the built-in dev menu, e.g. if they want to introduce their own UI, or have other devtools logic that doesn't depend on an action sheet.
It also introduces the RCTDevSettingsDataSource protocol for storing dev tools preferences. This could allow a developer to implement alternative behaviors, e.g. loading the settings from some other config, changing settings based on the user, deciding not to persist some settings, or something else.
The included data source implementation, RCTDevSettingsUserDefaultsDataSource, uses NSUserDefaults and is backwards compatible with the older implementation, so **no workflows or dependent code will break, and old saved settings will persist.**
The RCTDevMenu interface has not changed and is therefore also backwards-compatible, though
some methods are now deprecated.
In order to ensure that RCTDevSettings
Closes https://github.com/facebook/react-native/pull/11613
Reviewed By: mmmulani
Differential Revision: D4571773
Pulled By: javache
fbshipit-source-id: 25555d0a6eaa81f694343e079ed02439e5845fbc
2017-02-24 14:50:29 +00:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface RCTBridge (RCTDevSettings)
|
|
|
|
|
|
|
|
@property (nonatomic, readonly) RCTDevSettings *devSettings;
|
|
|
|
|
|
|
|
@end
|