Skip to content

Commit e0bf4cb

Browse files
authored
Updated jsinspector include path to match upstream (#12499)
* updated path to match upstream fork * Change files * fix snapshot * updated jsinspector references
1 parent 248eac0 commit e0bf4cb

File tree

6 files changed

+83
-74
lines changed

6 files changed

+83
-74
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "updated path to match upstream fork",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/e2e-test-app-fabric/test/__snapshots__/TextInputComponentTest.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3657,7 +3657,7 @@ exports[`TextInput Tests TextInputs can have caretHidden 1`] = `
36573657
{
36583658
"Brush": {
36593659
"Brush Type": "ColorBrush",
3660-
"Color": "rgba(0, 0, 0, 255)",
3660+
"Color": "rgba(0, 0, 0, 228)",
36613661
},
36623662
"Offset": [
36633663
0,
@@ -6690,4 +6690,4 @@ exports[`TextInput Tests Uncontrolled TextInput 1`] = `
66906690
"Visual Type": "SpriteVisual",
66916691
},
66926692
}
6693-
`;
6693+
`;

vnext/ReactCommon/ReactCommon.vcxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
<ClInclude Include="$(ReactNativeDir)\ReactCommon\cxxreact\SystraceSection.h" />
107107
<ClInclude Include="$(ReactNativeDir)\ReactCommon\jsiexecutor\jsireact\JSIExecutor.h" />
108108
<ClInclude Include="$(ReactNativeDir)\ReactCommon\jsiexecutor\jsireact\JSINativeModules.h" />
109-
<ClInclude Include="$(ReactNativeDir)\ReactCommon\jsinspector\InspectorInterfaces.h" />
109+
<ClInclude Include="$(ReactNativeDir)\ReactCommon\jsinspector-modern\InspectorInterfaces.h" />
110110
<ClInclude Include="$(ReactNativeDir)\ReactCommon\logger\react_native_log.h" />
111111
<ClInclude Include="$(YogaDir)\yoga\YGEnums.h" />
112112
<ClInclude Include="$(YogaDir)\yoga\YGMacros.h" />
@@ -128,7 +128,7 @@
128128
<ClCompile Include="$(ReactNativeDir)\ReactCommon\jsi\jsi\JSIDynamic.cpp" />
129129
<ClCompile Include="$(ReactNativeDir)\ReactCommon\jsiexecutor\jsireact\JSIExecutor.cpp" />
130130
<ClCompile Include="$(ReactNativeDir)\ReactCommon\jsiexecutor\jsireact\JSINativeModules.cpp" />
131-
<ClCompile Include="$(ReactNativeDir)\ReactCommon\jsinspector\InspectorInterfaces.cpp" />
131+
<ClCompile Include="$(ReactNativeDir)\ReactCommon\jsinspector-modern\InspectorInterfaces.cpp" />
132132
<ClCompile Include="$(ReactNativeDir)\ReactCommon\logger\react_native_log.cpp" />
133133
<CLCompile Include="$(ReactNativeDir)\ReactCommon\reactperflogger\reactperflogger\BridgeNativeModulePerfLogger.cpp" />
134134
<ClCompile Include="$(YogaDir)\yoga\YGEnums.cpp" />

vnext/Shared/HermesRuntimeHolder.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <NodeApiJsiRuntime.h>
1111
#include <crash/verifyElseCrash.h>
1212
#include <cxxreact/SystraceSection.h>
13-
#include <jsinspector/InspectorInterfaces.h>
13+
#include <jsinspector-modern/InspectorInterfaces.h>
1414
#include <mutex>
1515
#include "SafeLoadLibrary.h"
1616

@@ -230,10 +230,10 @@ class HermesScriptCache {
230230
std::shared_ptr<facebook::jsi::PreparedScriptStore> scriptStore_;
231231
};
232232

233-
class HermesLocalConnection : public facebook::react::ILocalConnection {
233+
class HermesLocalConnection : public facebook::react::jsinspector_modern::ILocalConnection {
234234
public:
235235
HermesLocalConnection(
236-
std::unique_ptr<facebook::react::IRemoteConnection> remoteConnection,
236+
std::unique_ptr<facebook::react::jsinspector_modern::IRemoteConnection> remoteConnection,
237237
void *connectFunc) noexcept {
238238
CRASH_ON_ERROR(getHermesApi().hermes_create_local_connection(
239239
connectFunc,
@@ -259,34 +259,34 @@ class HermesLocalConnection : public facebook::react::ILocalConnection {
259259

260260
private:
261261
static void NAPI_CDECL OnRemoteConnectionSendMessage(hermes_remote_connection remoteConnection, const char *message) {
262-
reinterpret_cast<facebook::react::IRemoteConnection *>(remoteConnection)->onMessage(message);
262+
reinterpret_cast<facebook::react::jsinspector_modern::IRemoteConnection *>(remoteConnection)->onMessage(message);
263263
}
264264

265265
static void NAPI_CDECL OnRemoteConnectionDisconnect(hermes_remote_connection remoteConnection) {
266-
reinterpret_cast<facebook::react::IRemoteConnection *>(remoteConnection)->onDisconnect();
266+
reinterpret_cast<facebook::react::jsinspector_modern::IRemoteConnection *>(remoteConnection)->onDisconnect();
267267
}
268268

269269
static void NAPI_CDECL OnRemoteConnectionDelete(void *remoteConnection, void * /*deleterData*/) {
270-
delete reinterpret_cast<facebook::react::IRemoteConnection *>(remoteConnection);
270+
delete reinterpret_cast<facebook::react::jsinspector_modern::IRemoteConnection *>(remoteConnection);
271271
}
272272

273273
private:
274274
hermes_local_connection localConnection_{};
275275
};
276276

277277
int32_t NAPI_CDECL addInspectorPage(const char *title, const char *vm, void *connectFunc) noexcept {
278-
return facebook::react::getInspectorInstance().addPage(
278+
return facebook::react::jsinspector_modern::getInspectorInstance().addPage(
279279
title,
280280
vm,
281-
[connectFunc,
282-
hermesApi = HermesApi::current()](std::unique_ptr<facebook::react::IRemoteConnection> remoteConnection) {
281+
[connectFunc, hermesApi = HermesApi::current()](
282+
std::unique_ptr<facebook::react::jsinspector_modern::IRemoteConnection> remoteConnection) {
283283
HermesApi::Scope apiScope(hermesApi);
284284
return std::make_unique<HermesLocalConnection>(std::move(remoteConnection), connectFunc);
285285
});
286286
}
287287

288288
void NAPI_CDECL removeInspectorPage(int32_t pageId) noexcept {
289-
facebook::react::getInspectorInstance().removePage(pageId);
289+
facebook::react::jsinspector_modern::getInspectorInstance().removePage(pageId);
290290
}
291291

292292
} // namespace

vnext/Shared/InspectorPackagerConnection.cpp

Lines changed: 58 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ struct InspectorProtocol {
7272
}
7373

7474
static folly::dynamic constructGetPagesResponsePayloadForPackager(
75-
const std::vector<facebook::react::InspectorPage> &pages,
75+
const std::vector<facebook::react::jsinspector_modern::InspectorPage> &pages,
7676
InspectorPackagerConnection::BundleStatus bundleStatus) {
7777
folly::dynamic payload = folly::dynamic::array;
78-
for (const facebook::react::InspectorPage &page : pages) {
78+
for (const facebook::react::jsinspector_modern::InspectorPage &page : pages) {
7979
folly::dynamic pageDyn = folly::dynamic::object;
8080
pageDyn["id"] = page.id;
8181
pageDyn["title"] = page.title;
@@ -167,62 +167,63 @@ winrt::fire_and_forget InspectorPackagerConnection::connectAsync() {
167167
m_packagerWebSocketConnection->SetOnConnect(
168168
[]() { facebook::react::tracing::log("Inspector: Websocket connection succeeded."); });
169169

170-
m_packagerWebSocketConnection->SetOnMessage([self = shared_from_this()](
171-
size_t /*length*/, const std::string &message, bool isBinary) {
172-
assert(!isBinary && "We don't expect any binary messages !");
173-
folly::dynamic messageDyn = folly::parseJson(message);
174-
175-
InspectorProtocol::EventType eventType = InspectorProtocol::getEventType(messageDyn);
176-
switch (eventType) {
177-
case InspectorProtocol::EventType::GetPages: {
178-
std::vector<facebook::react::InspectorPage> inspectorPages = facebook::react::getInspectorInstance().getPages();
179-
folly::dynamic response = InspectorProtocol::constructResponseForPackager(
180-
InspectorProtocol::EventType::GetPages,
181-
InspectorProtocol::constructGetPagesResponsePayloadForPackager(
182-
inspectorPages, self->m_bundleStatusProvider->getBundleStatus()));
183-
184-
std::string responsestr = folly::toJson(response);
185-
self->sendMessageToPackager(std::move(responsestr));
186-
break;
187-
}
188-
189-
case InspectorProtocol::EventType::WrappedEvent: {
190-
folly::dynamic payload = messageDyn[InspectorProtocol::Message_PAYLOAD];
191-
int32_t pageId = static_cast<int32_t>(payload[InspectorProtocol::Message_PAGEID].asInt());
192-
193-
if (self->m_localConnections.find(pageId) == self->m_localConnections.end()) {
194-
break;
195-
}
196-
197-
std::string wrappedEvent = payload[InspectorProtocol::Message_eventName_wrappedEvent].getString();
198-
self->sendMessageToVM(pageId, std::move(wrappedEvent));
199-
break;
200-
}
201-
202-
case InspectorProtocol::EventType::Connect: {
203-
folly::dynamic payload = messageDyn[InspectorProtocol::Message_PAYLOAD];
204-
int32_t pageId = static_cast<int32_t>(payload[InspectorProtocol::Message_PAGEID].asInt());
205-
206-
if (self->m_localConnections.find(pageId) != self->m_localConnections.end()) {
207-
break;
208-
}
209-
210-
self->m_localConnections[pageId] =
211-
facebook::react::getInspectorInstance().connect(pageId, std::make_unique<RemoteConnection>(pageId, *self));
212-
break;
213-
}
214-
215-
case InspectorProtocol::EventType::Disconnect: {
216-
folly::dynamic payload = messageDyn[InspectorProtocol::Message_PAYLOAD];
217-
int32_t pageId = static_cast<int32_t>(payload[InspectorProtocol::Message_PAGEID].asInt());
218-
if (self->m_localConnections.find(pageId) != self->m_localConnections.end()) {
219-
self->m_localConnections[pageId]->disconnect();
220-
self->m_localConnections.erase(pageId);
170+
m_packagerWebSocketConnection->SetOnMessage(
171+
[self = shared_from_this()](size_t /*length*/, const std::string &message, bool isBinary) {
172+
assert(!isBinary && "We don't expect any binary messages !");
173+
folly::dynamic messageDyn = folly::parseJson(message);
174+
175+
InspectorProtocol::EventType eventType = InspectorProtocol::getEventType(messageDyn);
176+
switch (eventType) {
177+
case InspectorProtocol::EventType::GetPages: {
178+
std::vector<facebook::react::jsinspector_modern::InspectorPage> inspectorPages =
179+
facebook::react::jsinspector_modern::getInspectorInstance().getPages();
180+
folly::dynamic response = InspectorProtocol::constructResponseForPackager(
181+
InspectorProtocol::EventType::GetPages,
182+
InspectorProtocol::constructGetPagesResponsePayloadForPackager(
183+
inspectorPages, self->m_bundleStatusProvider->getBundleStatus()));
184+
185+
std::string responsestr = folly::toJson(response);
186+
self->sendMessageToPackager(std::move(responsestr));
187+
break;
188+
}
189+
190+
case InspectorProtocol::EventType::WrappedEvent: {
191+
folly::dynamic payload = messageDyn[InspectorProtocol::Message_PAYLOAD];
192+
int32_t pageId = static_cast<int32_t>(payload[InspectorProtocol::Message_PAGEID].asInt());
193+
194+
if (self->m_localConnections.find(pageId) == self->m_localConnections.end()) {
195+
break;
196+
}
197+
198+
std::string wrappedEvent = payload[InspectorProtocol::Message_eventName_wrappedEvent].getString();
199+
self->sendMessageToVM(pageId, std::move(wrappedEvent));
200+
break;
201+
}
202+
203+
case InspectorProtocol::EventType::Connect: {
204+
folly::dynamic payload = messageDyn[InspectorProtocol::Message_PAYLOAD];
205+
int32_t pageId = static_cast<int32_t>(payload[InspectorProtocol::Message_PAGEID].asInt());
206+
207+
if (self->m_localConnections.find(pageId) != self->m_localConnections.end()) {
208+
break;
209+
}
210+
211+
self->m_localConnections[pageId] = facebook::react::jsinspector_modern::getInspectorInstance().connect(
212+
pageId, std::make_unique<RemoteConnection>(pageId, *self));
213+
break;
214+
}
215+
216+
case InspectorProtocol::EventType::Disconnect: {
217+
folly::dynamic payload = messageDyn[InspectorProtocol::Message_PAYLOAD];
218+
int32_t pageId = static_cast<int32_t>(payload[InspectorProtocol::Message_PAGEID].asInt());
219+
if (self->m_localConnections.find(pageId) != self->m_localConnections.end()) {
220+
self->m_localConnections[pageId]->disconnect();
221+
self->m_localConnections.erase(pageId);
222+
}
223+
break;
224+
}
221225
}
222-
break;
223-
}
224-
}
225-
});
226+
});
226227

227228
Microsoft::React::Networking::IWebSocketResource::Protocols protocols;
228229
Microsoft::React::Networking::IWebSocketResource::Options options;

vnext/Shared/InspectorPackagerConnection.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#pragma once
55

66
#include <Networking/WinRTWebSocketResource.h>
7-
#include <jsinspector/InspectorInterfaces.h>
7+
#include <jsinspector-modern/InspectorInterfaces.h>
88

99
namespace Microsoft::ReactNative {
1010

@@ -40,13 +40,14 @@ class InspectorPackagerConnection final : public std::enable_shared_from_this<In
4040
void sendMessageToVM(int32_t pageId, std::string &&message);
4141

4242
private:
43-
std::unordered_map<int32_t, std::unique_ptr<facebook::react::ILocalConnection>> m_localConnections;
43+
std::unordered_map<int32_t, std::unique_ptr<facebook::react::jsinspector_modern::ILocalConnection>>
44+
m_localConnections;
4445
std::shared_ptr<Microsoft::React::Networking::WinRTWebSocketResource> m_packagerWebSocketConnection;
4546
std::shared_ptr<IBundleStatusProvider> m_bundleStatusProvider;
4647
std::string m_url;
4748
};
4849

49-
class RemoteConnection final : public facebook::react::IRemoteConnection {
50+
class RemoteConnection final : public facebook::react::jsinspector_modern::IRemoteConnection {
5051
public:
5152
RemoteConnection(int32_t pageId, const InspectorPackagerConnection &packagerConnection);
5253
void onMessage(std::string message) override;

0 commit comments

Comments
 (0)