Skip to content

Commit 7d197df

Browse files
committed
Wire up Fusebox InspectorPackagerConnection
Using the same inspector thread initialized in ReactNativeHost, this change wires up the InspectorPackagerConnectionDelegate to use when initializatng the InspectorPackagerConnection from ReactCommon and conditionally sets it for Hermes direct debugging when the appropriate feature flag is set.
1 parent 0b83a21 commit 7d197df

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

vnext/ReactCommon/ReactCommon.vcxproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
<ClInclude Include="$(ReactNativeDir)\ReactCommon\jsiexecutor\jsireact\JSINativeModules.h" />
112112
<ClInclude Include="$(ReactNativeDir)\ReactCommon\jsinspector-modern\InspectorFlags.h" />
113113
<ClInclude Include="$(ReactNativeDir)\ReactCommon\jsinspector-modern\InspectorInterfaces.h" />
114+
<ClInclude Include="$(ReactNativeDir)\ReactCommon\jsinspector-modern\InspectorPackagerConnection.h" />
114115
<ClInclude Include="$(ReactNativeDir)\ReactCommon\logger\react_native_log.h" />
115116
<ClInclude Include="$(YogaDir)\yoga\YGEnums.h" />
116117
<ClInclude Include="$(YogaDir)\yoga\YGMacros.h" />
@@ -134,6 +135,7 @@
134135
<ClCompile Include="$(ReactNativeDir)\ReactCommon\jsiexecutor\jsireact\JSINativeModules.cpp" />
135136
<ClCompile Include="$(ReactNativeDir)\ReactCommon\jsinspector-modern\InspectorFlags.cpp" />
136137
<ClCompile Include="$(ReactNativeDir)\ReactCommon\jsinspector-modern\InspectorInterfaces.cpp" />
138+
<ClCompile Include="$(ReactNativeDir)\ReactCommon\jsinspector-modern\InspectorPackagerConnection.cpp" />
137139
<ClCompile Include="$(ReactNativeDir)\ReactCommon\logger\react_native_log.cpp" />
138140
<CLCompile Include="$(ReactNativeDir)\ReactCommon\reactperflogger\reactperflogger\BridgeNativeModulePerfLogger.cpp" />
139141
<ClCompile Include="$(YogaDir)\yoga\YGConfig.cpp" />

vnext/Shared/DevSupportManager.cpp

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@
99
#include <Shared/DevSettings.h>
1010

1111
#include <Executors/WebSocketJSExecutor.h>
12+
#include "FuseboxInspectorPackagerConnectionDelegate.h"
1213
#include "PackagerConnection.h"
1314

1415
#include "Unicode.h"
1516
#include "Utilities.h"
1617

1718
#include <Utils/CppWinrtLessExceptions.h>
19+
#include <jsinspector-modern/InspectorFlags.h>
1820
#include <winrt/Windows.Foundation.h>
1921
#include <winrt/Windows.Security.Cryptography.Core.h>
2022
#include <winrt/Windows.Security.Cryptography.h>
@@ -273,12 +275,10 @@ void DevSupportManager::EnsureHermesInspector(
273275
[[maybe_unused]] const uint16_t packagerPort,
274276
[[maybe_unused]] const std::string &bundleAppId) noexcept {
275277
static std::once_flag once;
276-
std::call_once(once, [this, &packagerHost, packagerPort, &jsBundleName]() {
277-
// TODO: should we use the bundleAppId as the app param if available?
278-
278+
std::call_once(once, [this, &packagerHost, packagerPort, &bundleAppId]() {
279279
std::string packageName{bundleAppId};
280-
if (packageName == "") {
281-
std::string packageName("RNW");
280+
if (packageName.empty()) {
281+
packageName = "RNW";
282282
wchar_t fullName[PACKAGE_FULL_NAME_MAX_LENGTH]{};
283283
UINT32 size = ARRAYSIZE(fullName);
284284
if (SUCCEEDED(GetCurrentPackageFullName(&size, fullName))) {
@@ -294,11 +294,20 @@ void DevSupportManager::EnsureHermesInspector(
294294
}
295295

296296
const auto deviceId = GetDeviceId(packageName);
297-
m_inspectorPackagerConnection = std::make_shared<InspectorPackagerConnection>(
298-
facebook::react::DevServerHelper::get_InspectorDeviceUrl(
299-
packagerHost, packagerPort, deviceName, packageName, deviceId),
300-
m_BundleStatusProvider);
301-
m_inspectorPackagerConnection->connectAsync();
297+
auto inspectorUrl = facebook::react::DevServerHelper::get_InspectorDeviceUrl(
298+
packagerHost, packagerPort, deviceName, packageName, deviceId);
299+
auto &inspectorFlags = jsinspector_modern::InspectorFlags::getInstance();
300+
if (inspectorFlags.getEnableCxxInspectorPackagerConnection()) {
301+
m_fuseboxInspectorPackagerConnection = std::make_unique<jsinspector_modern::InspectorPackagerConnection>(
302+
inspectorUrl,
303+
packageName,
304+
std::make_unique<Microsoft::ReactNative::FuseboxInspectorPackagerConnectionDelegate>());
305+
m_fuseboxInspectorPackagerConnection->connect();
306+
} else {
307+
m_inspectorPackagerConnection =
308+
std::make_shared<InspectorPackagerConnection>(std::move(inspectorUrl), m_BundleStatusProvider);
309+
m_inspectorPackagerConnection->connectAsync();
310+
}
302311
});
303312
}
304313

vnext/Shared/DevSupportManager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <string>
1616

1717
#include <InspectorPackagerConnection.h>
18+
#include <jsinspector-modern/InspectorPackagerConnection.h>
1819

1920
namespace facebook {
2021
namespace react {
@@ -59,6 +60,8 @@ class DevSupportManager final : public facebook::react::IDevSupportManager {
5960
std::atomic_bool m_cancellation_token;
6061

6162
std::shared_ptr<InspectorPackagerConnection> m_inspectorPackagerConnection;
63+
std::unique_ptr<facebook::react::jsinspector_modern::InspectorPackagerConnection>
64+
m_fuseboxInspectorPackagerConnection;
6265

6366
struct BundleStatusProvider : public InspectorPackagerConnection::IBundleStatusProvider {
6467
virtual InspectorPackagerConnection::BundleStatus getBundleStatus() {

vnext/Shared/IDevSupportManager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#pragma once
55

66
#include <cxxreact/JSExecutor.h>
7+
#include <dispatchQueue/dispatchQueue.h>
78
#include <functional>
89
#include <memory>
910
#include <string>

0 commit comments

Comments
 (0)