From 7f7bcaa8e96cb3ab6dfb318fa4170c18bf4a912d Mon Sep 17 00:00:00 2001 From: Eric Rozell Date: Mon, 29 Apr 2024 14:07:54 -0400 Subject: [PATCH] Example wiring up the inspector flag --- .../playground-win32/Playground-Win32.cpp | 1 + vnext/Microsoft.ReactNative/QuirkSettings.cpp | 20 +++++++++++++++++++ vnext/Microsoft.ReactNative/QuirkSettings.h | 2 ++ vnext/Microsoft.ReactNative/QuirkSettings.idl | 5 +++++ 4 files changed, 28 insertions(+) diff --git a/packages/playground/windows/playground-win32/Playground-Win32.cpp b/packages/playground/windows/playground-win32/Playground-Win32.cpp index a3c45b43f68..5e068ff2447 100644 --- a/packages/playground/windows/playground-win32/Playground-Win32.cpp +++ b/packages/playground/windows/playground-win32/Playground-Win32.cpp @@ -85,6 +85,7 @@ struct WindowData { winrt::Microsoft::ReactNative::ReactNativeHost Host() noexcept { if (!m_host) { + winrt::Microsoft::ReactNative::QuirkSettings::SetUseFusebox(true); m_host = winrt::Microsoft::ReactNative::ReactNativeHost(); m_host.InstanceSettings(InstanceSettings()); } diff --git a/vnext/Microsoft.ReactNative/QuirkSettings.cpp b/vnext/Microsoft.ReactNative/QuirkSettings.cpp index 81dddc80a82..9b434718fd2 100644 --- a/vnext/Microsoft.ReactNative/QuirkSettings.cpp +++ b/vnext/Microsoft.ReactNative/QuirkSettings.cpp @@ -9,10 +9,26 @@ #include "React.h" #include "ReactPropertyBag.h" +#include +#include + namespace winrt::Microsoft::ReactNative::implementation { QuirkSettings::QuirkSettings() noexcept {} + +class QuirkSettingsReactNativeFeatureFlags + : public facebook::react::ReactNativeFeatureFlagsDefaults { + public: + QuirkSettingsReactNativeFeatureFlags(bool enableModernCDPRegistry) : m_enableModernCDPRegistry(enableModernCDPRegistry) {} + + bool inspectorEnableModernCDPRegistry() override { + return m_enableModernCDPRegistry; + } + private: + bool m_enableModernCDPRegistry; +}; + winrt::Microsoft::ReactNative::ReactPropertyId MatchAndroidAndIOSStretchBehaviorProperty() noexcept { static winrt::Microsoft::ReactNative::ReactPropertyId propId{ L"ReactNative.QuirkSettings", L"MatchAndroidAndIOSyStretchBehavior"}; @@ -137,6 +153,10 @@ winrt::Microsoft::ReactNative::ReactPropertyId IsBridgelessProperty() noex ReactPropertyBag(settings.Properties()).Set(UseRuntimeSchedulerProperty(), value); } +/*static*/ void QuirkSettings::SetUseFusebox(bool value) noexcept { + facebook::react::ReactNativeFeatureFlags::override(std::make_unique(value)); +} + #pragma endregion IDL interface /*static*/ bool QuirkSettings::GetMatchAndroidAndIOSStretchBehavior(ReactPropertyBag properties) noexcept { diff --git a/vnext/Microsoft.ReactNative/QuirkSettings.h b/vnext/Microsoft.ReactNative/QuirkSettings.h index 0c5d73e94e4..75469a420d1 100644 --- a/vnext/Microsoft.ReactNative/QuirkSettings.h +++ b/vnext/Microsoft.ReactNative/QuirkSettings.h @@ -68,6 +68,8 @@ struct QuirkSettings : QuirkSettingsT { winrt::Microsoft::ReactNative::ReactInstanceSettings settings, bool value) noexcept; + static void SetUseFusebox(bool value) noexcept; + #pragma endregion Public API - part of IDL interface }; diff --git a/vnext/Microsoft.ReactNative/QuirkSettings.idl b/vnext/Microsoft.ReactNative/QuirkSettings.idl index a4ad798aced..ed398025afb 100644 --- a/vnext/Microsoft.ReactNative/QuirkSettings.idl +++ b/vnext/Microsoft.ReactNative/QuirkSettings.idl @@ -64,6 +64,11 @@ namespace Microsoft.ReactNative "By default `react-native-windows` will use the new RuntimeScheduler." "Setting this to false will revert the behavior to previous scheduling logic.") static void SetUseRuntimeScheduler(ReactInstanceSettings settings, Boolean value); + + DOC_STRING( + "By default `react-native-windows` uses the legacy inspector packager connection protocol." + "Setting this to true to enable the modern \"Fusebox\" debugging functionality.") + static void SetUseFusebox(Boolean value); } } // namespace Microsoft.ReactNative