diff --git a/change/react-native-windows-2019-10-17-19-03-55-developermenu.json b/change/react-native-windows-2019-10-17-19-03-55-developermenu.json new file mode 100644 index 00000000000..bea77769f85 --- /dev/null +++ b/change/react-native-windows-2019-10-17-19-03-55-developermenu.json @@ -0,0 +1,9 @@ +{ + "type": "prerelease", + "comment": "add developer menu property", + "packageName": "react-native-windows", + "email": "kmelmon@microsoft.com", + "commit": "5d42737bfacccb3f90dcde8af3b4a104d26f840d", + "date": "2019-10-18T02:03:55.336Z", + "file": "D:\\rnw2\\change\\react-native-windows-2019-10-17-19-03-55-developermenu.json" +} \ No newline at end of file diff --git a/packages/E2ETest/windows/ReactUWPTestApp/ReactTestPage.xaml.cs b/packages/E2ETest/windows/ReactUWPTestApp/ReactTestPage.xaml.cs index a5ebd08035a..c12af39b76d 100644 --- a/packages/E2ETest/windows/ReactUWPTestApp/ReactTestPage.xaml.cs +++ b/packages/E2ETest/windows/ReactUWPTestApp/ReactTestPage.xaml.cs @@ -35,6 +35,7 @@ private void LoadReact() settings.UseWebDebugger = true; settings.UseLiveReload = true; #endif + settings.EnableDeveloperMenu = false; var instance = Instance.Create(JSFileName); instance.Start(settings); diff --git a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/MainReactNativeHost.cs b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/MainReactNativeHost.cs index f80636309e9..5df964dcf65 100644 --- a/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/MainReactNativeHost.cs +++ b/packages/microsoft-reactnative-sampleapps/windows/SampleAppCS/MainReactNativeHost.cs @@ -15,6 +15,13 @@ public MainReactNativeHost() this.InstanceSettings.UseWebDebugger = false; // Disabled temporarily because of issue #2877 this.InstanceSettings.UseLiveReload = true; // true by default in debug builds already this.InstanceSettings.UseJsi = true; + +#if DEBUG + this.InstanceSettings.EnableDeveloperMenu = true; +#else + this.InstanceSettings.EnableDeveloperMenu = false; +#endif + } protected override string MainComponentName => "SampleApp"; diff --git a/packages/playground/windows/playground/HostingPane.xaml.cpp b/packages/playground/windows/playground/HostingPane.xaml.cpp index 321220ea461..d7e93ce4eec 100644 --- a/packages/playground/windows/playground/HostingPane.xaml.cpp +++ b/packages/playground/windows/playground/HostingPane.xaml.cpp @@ -227,6 +227,7 @@ std::shared_ptr HostingPane::getInstance() { react::uwp::ReactInstanceSettings settings; settings.UseWebDebugger = x_UseWebDebuggerCheckBox->IsChecked->Value; settings.UseLiveReload = x_UseLiveReloadCheckBox->IsChecked->Value; + settings.EnableDeveloperMenu = true; settings.LoggingCallback = [](facebook::react::RCTLogLevel logLevel, const char *message) { OutputDebugStringA("In LoggingCallback"); diff --git a/vnext/Microsoft.ReactNative/ReactInstanceCreator.cpp b/vnext/Microsoft.ReactNative/ReactInstanceCreator.cpp index 1e83696b37f..be36c5f4726 100644 --- a/vnext/Microsoft.ReactNative/ReactInstanceCreator.cpp +++ b/vnext/Microsoft.ReactNative/ReactInstanceCreator.cpp @@ -58,7 +58,8 @@ ReactInstanceCreator::getInstance() { settings.ByteCodeFileUri = to_string(m_instanceSettings.ByteCodeFileUri()); settings.DebugBundlePath = to_string(m_instanceSettings.DebugBundlePath()); settings.DebugHost = to_string(m_instanceSettings.DebugHost()); - settings.EnableByteCodeCacheing = m_instanceSettings.EnableByteCodeCaching(); + settings.EnableByteCodeCaching = m_instanceSettings.EnableByteCodeCaching(); + settings.EnableDeveloperMenu = m_instanceSettings.EnableDeveloperMenu(); settings.EnableJITCompilation = m_instanceSettings.EnableJITCompilation(); settings.UseDirectDebugger = m_instanceSettings.UseDirectDebugger(); settings.UseJsi = m_instanceSettings.UseJsi(); diff --git a/vnext/Microsoft.ReactNative/ReactInstanceSettings.h b/vnext/Microsoft.ReactNative/ReactInstanceSettings.h index 2edf2882f9f..63268b21959 100644 --- a/vnext/Microsoft.ReactNative/ReactInstanceSettings.h +++ b/vnext/Microsoft.ReactNative/ReactInstanceSettings.h @@ -48,6 +48,13 @@ struct ReactInstanceSettings : ReactInstanceSettingsT { m_enableByteCodeCaching = value; } + bool EnableDeveloperMenu() { + return m_enableDeveloperMenu; + } + void EnableDeveloperMenu(bool value) { + m_enableDeveloperMenu = value; + } + hstring ByteCodeFileUri() { return m_byteCodeFileUri; } @@ -87,6 +94,7 @@ struct ReactInstanceSettings : ReactInstanceSettingsT { bool m_useWebDebugger{FALSE}; bool m_useLiveReload{FALSE}; #endif + bool m_enableDeveloperMenu{FALSE}; bool m_useDirectDebugger{FALSE}; bool m_useJsi{TRUE}; bool m_enableJITCompilation{TRUE}; diff --git a/vnext/Microsoft.ReactNative/ReactInstanceSettings.idl b/vnext/Microsoft.ReactNative/ReactInstanceSettings.idl index a55e6607f77..d2d7893a8b0 100644 --- a/vnext/Microsoft.ReactNative/ReactInstanceSettings.idl +++ b/vnext/Microsoft.ReactNative/ReactInstanceSettings.idl @@ -14,6 +14,7 @@ namespace Microsoft.ReactNative Boolean UseJsi { get; set; }; Boolean EnableJITCompilation { get; set; }; Boolean EnableByteCodeCaching { get; set; }; + Boolean EnableDeveloperMenu { get; set; }; String ByteCodeFileUri { get; set; }; String DebugHost { get; set; }; diff --git a/vnext/ReactUWP/ABI/Instance_rt.cpp b/vnext/ReactUWP/ABI/Instance_rt.cpp index cd8a6ee396b..8881e9098f0 100644 --- a/vnext/ReactUWP/ABI/Instance_rt.cpp +++ b/vnext/ReactUWP/ABI/Instance_rt.cpp @@ -76,6 +76,7 @@ std::shared_ptr<::react::uwp::IReactInstance> Instance::getInstance() { ::react::uwp::ReactInstanceSettings innerSettings; innerSettings.UseLiveReload = m_settings.UseLiveReload; innerSettings.UseWebDebugger = m_settings.UseWebDebugger; + innerSettings.EnableDeveloperMenu = m_settings.EnableDeveloperMenu; m_instance->Start(m_instance, innerSettings); m_instance->loadBundle(std::string(m_jsBundleName)); } @@ -104,6 +105,7 @@ HRESULT Instance::Start(ABI::react::uwp::InstanceSettings settings) { m_settings.UseLiveReload = settings.UseLiveReload; m_settings.UseWebDebugger = settings.UseWebDebugger; + m_settings.EnableDeveloperMenu = settings.EnableDeveloperMenu; getInstance(); return S_OK; diff --git a/vnext/ReactUWP/ABI/idl/Instance.idl b/vnext/ReactUWP/ABI/idl/Instance.idl index 1fec828cb88..edc3240e5ca 100644 --- a/vnext/ReactUWP/ABI/idl/Instance.idl +++ b/vnext/ReactUWP/ABI/idl/Instance.idl @@ -18,6 +18,7 @@ namespace react{ { boolean UseWebDebugger; boolean UseLiveReload; + boolean EnableDeveloperMenu; }; [version(VERSION)] diff --git a/vnext/ReactUWP/Base/UwpReactInstance.cpp b/vnext/ReactUWP/Base/UwpReactInstance.cpp index 8cbf3e28ab7..1ff1ca057b0 100644 --- a/vnext/ReactUWP/Base/UwpReactInstance.cpp +++ b/vnext/ReactUWP/Base/UwpReactInstance.cpp @@ -430,8 +430,7 @@ void UwpReactInstance::Start( std::move(scriptStore), std::move(preparedScriptStore)); #else - if (settings.EnableByteCodeCacheing || - !settings.ByteCodeFileUri.empty()) { + if (settings.EnableByteCodeCaching || !settings.ByteCodeFileUri.empty()) { scriptStore = std::make_unique(); preparedScriptStore = std::make_unique( winrt::to_hstring(settings.ByteCodeFileUri)); diff --git a/vnext/ReactUWP/Views/ReactControl.cpp b/vnext/ReactUWP/Views/ReactControl.cpp index ec636225289..e6475858088 100644 --- a/vnext/ReactUWP/Views/ReactControl.cpp +++ b/vnext/ReactUWP/Views/ReactControl.cpp @@ -223,11 +223,9 @@ void ReactControl::AttachRoot() noexcept { m_reactInstance->AttachMeasuredRootView(m_pParent, std::move(initialProps)); m_isAttached = true; -#ifdef DEBUG - // TODO: Enable this in retail builds via a new API - // https://github.com/microsoft/react-native-windows/issues/2870 - InitializeDeveloperMenu(); -#endif + if (m_reactInstance->GetReactInstanceSettings().EnableDeveloperMenu) { + InitializeDeveloperMenu(); + } } void ReactControl::DetachRoot() noexcept { diff --git a/vnext/include/ReactUWP/IReactInstance.h b/vnext/include/ReactUWP/IReactInstance.h index 3823c68af29..ef060bb1f0d 100644 --- a/vnext/include/ReactUWP/IReactInstance.h +++ b/vnext/include/ReactUWP/IReactInstance.h @@ -34,7 +34,8 @@ struct ReactInstanceSettings { bool UseDirectDebugger{false}; bool UseJsi{true}; bool EnableJITCompilation{true}; - bool EnableByteCodeCacheing{false}; + bool EnableByteCodeCaching{false}; + bool EnableDeveloperMenu{false}; std::string ByteCodeFileUri; std::string DebugHost; diff --git a/vnext/local-cli/generator-windows/templates/cpp/src/MainPage.cpp b/vnext/local-cli/generator-windows/templates/cpp/src/MainPage.cpp index a899d96e7ef..de73dad1f16 100644 --- a/vnext/local-cli/generator-windows/templates/cpp/src/MainPage.cpp +++ b/vnext/local-cli/generator-windows/templates/cpp/src/MainPage.cpp @@ -35,6 +35,12 @@ namespace winrt::<%=ns%>::implementation settings.UseWebDebugger = true; #endif +#ifdef NDEBUG + settings.EnableDeveloperMenu = false; +#else + settings.EnableDeveloperMenu = true; +#endif + auto instance = Instance::Create(winrt::hstring(JSFILENAME)); instance.Start(settings); diff --git a/vnext/local-cli/generator-windows/templates/cs/src/MainPage.xaml.cs b/vnext/local-cli/generator-windows/templates/cs/src/MainPage.xaml.cs index 15f92e14b34..b9c398f44ed 100644 --- a/vnext/local-cli/generator-windows/templates/cs/src/MainPage.xaml.cs +++ b/vnext/local-cli/generator-windows/templates/cs/src/MainPage.xaml.cs @@ -49,6 +49,12 @@ private void LoadReact() settings.UseLiveReload = true; #endif +#if NDEBUG + settings.EnableDeveloperMenu = false; +#else + settings.EnableDeveloperMenu = true; +#endif + var instance = Instance.Create(JSFILENAME); //instantiate sample module for registering callbacks for live reload, JS error handling etc.,