react-native-macos/Libraries/Utilities
Janic Duplessis cc068b0551 Export the DevSettings module, add `addMenuItem` method (#25848)
Summary:
I wanted to configure the RN dev menu without having to write native code. This is pretty useful in a greenfield app since it avoids having to write a custom native module for both platforms (and might enable the feature for expo too).

This ended up a bit more involved than planned since callbacks can only be called once. I needed to convert the `DevSettings` module to a `NativeEventEmitter` and use events when buttons are clicked. This means creating a JS wrapper for it. Currently it does not export all methods, they can be added in follow ups as needed.

## Changelog

[General] [Added] - Export the DevSettings module, add `addMenuItem` method
Pull Request resolved: https://github.com/facebook/react-native/pull/25848

Test Plan:
Tested in an app using the following code.

```js
if (__DEV__) {
 DevSettings.addMenuItem('Show Dev Screen', () => {
    dispatchNavigationAction(
      NavigationActions.navigate({
        routeName: 'dev',
      }),
    );
  });
}
```

Added an example in RN tester

![devmenu](https://user-images.githubusercontent.com/2677334/62000297-71624680-b0a1-11e9-8403-bc95c4747f0c.gif)

Differential Revision: D17394916

Pulled By: cpojer

fbshipit-source-id: f9d2c548b09821c594189d1436a27b97cf5a5737
2019-09-17 06:38:10 -07:00
..
__mocks__ Migrate "Libraries" from Haste to standard path-based requires (sans vendor & renderers) (#24749) 2019-05-08 08:48:59 -07:00
__tests__ Add tests for codegenNativeComponent 2019-08-07 06:00:23 -07:00
differ xplat/js/react-native-github 2019-08-09 10:11:15 -07:00
Appearance.js Handle empty string returned from NativeAppearance.getColorScheme() 2019-09-03 12:11:15 -07:00
BackHandler.android.js Add spec for NativeDeviceEventManager (#24914) 2019-05-20 18:05:54 -07:00
BackHandler.ios.js Migrate "Libraries" from Haste to standard path-based requires (sans vendor & renderers) (#24749) 2019-05-08 08:48:59 -07:00
DevSettings.js Export the DevSettings module, add `addMenuItem` method (#25848) 2019-09-17 06:38:10 -07:00
DeviceInfo.js Add spec for DeviceInfo module 2019-05-29 16:37:15 -07:00
Dimensions.js Fix Dimensions for ComponentScript 2019-08-01 18:25:57 -07:00
GlobalPerformanceLogger.js Manual fixes for xplat/js/react-native-github 2019-08-09 10:11:15 -07:00
HMRClient.js Fall back to `JSON.stringify` in `console.log` if Symbol is unavailable 2019-07-25 15:32:06 -07:00
HMRClientProdShim.js Use HMRClient to send console logs to Metro 2019-07-24 08:11:34 -07:00
JSDevSupportModule.js add spec for JSDevSupport (#24905) 2019-05-22 03:27:54 -07:00
LoadingView.android.js Add a loading bar when loading split bundles 2019-07-18 03:06:49 -07:00
LoadingView.ios.js Add a loading bar when loading split bundles 2019-07-18 03:06:49 -07:00
LoadingView.js Add a loading bar when loading split bundles 2019-07-18 03:06:49 -07:00
MatrixMath.js Use `invariant` instead of `fbjs/lib/invariant` 2018-12-03 00:07:02 -08:00
NativeAppearance.js Add Appearance native module 2019-08-30 17:07:57 -07:00
NativeDevLoadingView.js xplat/js/react-native-github 2019-08-09 10:11:15 -07:00
NativeDeviceInfo.js xplat/js/react-native-github 2019-08-09 10:11:15 -07:00
NativeJSDevSupport.js xplat/js/react-native-github 2019-08-09 10:11:15 -07:00
NativePlatformConstantsAndroid.js xplat/js/react-native-github 2019-08-09 10:11:15 -07:00
NativePlatformConstantsIOS.js xplat/js/react-native-github 2019-08-09 10:11:15 -07:00
PerformanceLoggerContext.js Migrate "Libraries" from Haste to standard path-based requires (sans vendor & renderers) (#24749) 2019-05-08 08:48:59 -07:00
PixelRatio.js Migrate "Libraries" from Haste to standard path-based requires (sans vendor & renderers) (#24749) 2019-05-08 08:48:59 -07:00
Platform.android.js Final fixes and seal xplat/js/react-native-github 2019-08-23 08:45:11 -07:00
Platform.ios.js xplat/js/react-native-github 2019-08-09 10:11:15 -07:00
PolyfillFunctions.js Migrate "Libraries" from Haste to standard path-based requires (sans vendor & renderers) (#24749) 2019-05-08 08:48:59 -07:00
RCTLog.js Use `invariant` instead of `fbjs/lib/invariant` 2018-12-03 00:07:02 -08:00
ReactNativeTestTools.js xplat/js/react-native-github 2019-08-09 10:11:15 -07:00
SceneTracker.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
binaryToBase64.js xplat/js/react-native-github 2019-08-09 10:11:15 -07:00
buildStyleInterpolator.js Remove var in Libraries/Utilities/buildStyleInterpolator.js (#22112) 2018-11-04 11:03:09 -08:00
clamp.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
codegenNativeCommands.js Add runtime behavior to codegenNativeCommands 2019-08-01 15:05:57 -07:00
codegenNativeComponent.js Manual fixes for xplat/js/react-native-github 2019-08-09 10:11:15 -07:00
createPerformanceLogger.js Fix typos (#25770) 2019-07-23 03:23:11 -07:00
deepFreezeAndThrowOnMutationInDev.js Remove var in Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js (#22126) 2018-11-05 16:15:54 -08:00
defineLazyObjectProperty.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
deprecatedPropType.js Migrate "Libraries" from Haste to standard path-based requires (sans vendor & renderers) (#24749) 2019-05-08 08:48:59 -07:00
dismissKeyboard.js Migrate "Libraries" from Haste to standard path-based requires (sans vendor & renderers) (#24749) 2019-05-08 08:48:59 -07:00
groupByEveryN.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
infoLog.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
logError.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
mapWithSeparator.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
mergeIntoFast.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
registerGeneratedViewConfig.js Add paperComponentName and paperComponentNameDeprecated 2019-06-19 09:56:04 -07:00
setAndForwardRef.js Manual fixes for xplat/js/react-native-github 2019-08-09 10:11:15 -07:00
stringifySafe.js add support for stringifying error object messages to stringifySafe (#25723) 2019-07-23 02:46:19 -07:00
truncate.js Update copyright headers to yearless format 2018-09-11 15:33:07 -07:00
useColorScheme.js useColorScheme hook (#26143) 2019-08-31 11:22:43 -07:00
useWindowDimensions.js Fix useWindowDimensions firing continuously after dims change (#26008) 2019-08-23 13:50:56 -07:00
verifyComponentAttributeEquivalence.js Clean-up $TEMPORARY$object in xplat/js/react-native-github 2019-08-21 09:58:24 -07:00
warnOnce.js Introduce generic `warnOnce` function for warning messages (#22109) 2019-02-05 02:24:59 -08:00