Skip to content

Commit

Permalink
Example wiring up the inspector flag
Browse files Browse the repository at this point in the history
  • Loading branch information
rozele committed Apr 29, 2024
1 parent f8da169 commit 7f7bcaa
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
20 changes: 20 additions & 0 deletions vnext/Microsoft.ReactNative/QuirkSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,26 @@
#include "React.h"
#include "ReactPropertyBag.h"

#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <react/featureflags/ReactNativeFeatureFlagsDefaults.h>

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<bool> MatchAndroidAndIOSStretchBehaviorProperty() noexcept {
static winrt::Microsoft::ReactNative::ReactPropertyId<bool> propId{
L"ReactNative.QuirkSettings", L"MatchAndroidAndIOSyStretchBehavior"};
Expand Down Expand Up @@ -137,6 +153,10 @@ winrt::Microsoft::ReactNative::ReactPropertyId<bool> IsBridgelessProperty() noex
ReactPropertyBag(settings.Properties()).Set(UseRuntimeSchedulerProperty(), value);
}

/*static*/ void QuirkSettings::SetUseFusebox(bool value) noexcept {
facebook::react::ReactNativeFeatureFlags::override(std::make_unique<QuirkSettingsReactNativeFeatureFlags>(value));
}

#pragma endregion IDL interface

/*static*/ bool QuirkSettings::GetMatchAndroidAndIOSStretchBehavior(ReactPropertyBag properties) noexcept {
Expand Down
2 changes: 2 additions & 0 deletions vnext/Microsoft.ReactNative/QuirkSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ struct QuirkSettings : QuirkSettingsT<QuirkSettings> {
winrt::Microsoft::ReactNative::ReactInstanceSettings settings,
bool value) noexcept;

static void SetUseFusebox(bool value) noexcept;

#pragma endregion Public API - part of IDL interface
};

Expand Down
5 changes: 5 additions & 0 deletions vnext/Microsoft.ReactNative/QuirkSettings.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 7f7bcaa

Please sign in to comment.