react-native-windows 0.73.0-preview.3 → 0.73.0-preview.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/Directory.Build.props +2 -2
  2. package/Libraries/Animated/nodes/AnimatedStyle.js +1 -1
  3. package/Libraries/Core/ReactNativeVersion.js +1 -1
  4. package/Microsoft.ReactNative/JSDispatcherWriter.cpp +18 -11
  5. package/Microsoft.ReactNative/JSDispatcherWriter.h +1 -0
  6. package/Microsoft.ReactNative/ReactHost/MsoReactContext.cpp +37 -1
  7. package/Microsoft.ReactNative/ReactHost/React.h +3 -0
  8. package/Microsoft.ReactNative/ReactHost/ReactHost.cpp +16 -0
  9. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +19 -3
  10. package/Microsoft.ReactNative/TurboModulesProvider.cpp +92 -40
  11. package/Microsoft.ReactNative/packages.lock.json +3 -3
  12. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +1 -0
  13. package/Microsoft.ReactNative.Managed/packages.lock.json +67 -3
  14. package/Microsoft.ReactNative.Managed.CodeGen/Microsoft.ReactNative.Managed.CodeGen.csproj +2 -1
  15. package/PropertySheets/External/Microsoft.ReactNative.Composition.Common.props +8 -0
  16. package/PropertySheets/Generated/PackageVersion.g.props +2 -2
  17. package/PropertySheets/JSEngine.props +4 -3
  18. package/PropertySheets/React.Cpp.props +1 -0
  19. package/ReactCommon/ReactCommon.vcxproj +4 -4
  20. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/uimanager/UIManagerBinding.cpp +30 -34
  21. package/Shared/HermesRuntimeHolder.cpp +11 -11
  22. package/Shared/InspectorPackagerConnection.cpp +58 -57
  23. package/Shared/InspectorPackagerConnection.h +4 -3
  24. package/Shared/JSI/V8RuntimeHolder.cpp +1 -1
  25. package/Shared/Networking/DefaultBlobResource.cpp +8 -4
  26. package/Shared/Networking/WinRTHttpResource.cpp +1 -1
  27. package/Shared/OInstance.cpp +19 -1
  28. package/Shared/SafeLoadLibrary.cpp +44 -8
  29. package/Shared/SafeLoadLibrary.h +5 -1
  30. package/Shared/Shared.vcxitems +4 -0
  31. package/Shared/Shared.vcxitems.filters +16 -11
  32. package/Shared/V8JSIRuntimeHolder.cpp +71 -0
  33. package/Shared/V8JSIRuntimeHolder.h +56 -0
  34. package/fmt/cgmanifest.json +1 -1
  35. package/metro.config.js +1 -1
  36. package/package.json +13 -13
  37. package/templates/cpp-app/windows/ExperimentalFeatures.props +0 -1
  38. package/templates/old/generateWrapper.js +3 -3
  39. package/templates/old/uwp-cpp-lib/template.config.js +1 -1
@@ -56,6 +56,7 @@
56
56
  <PreprocessorDefinitions Condition="'$(EnableDevServerHBCBundles)'=='true'">ENABLE_DEVSERVER_HBCBUNDLES;%(PreprocessorDefinitions)</PreprocessorDefinitions>
57
57
  <PreprocessorDefinitions Condition="'$(UseV8)'=='true'">USE_V8;%(PreprocessorDefinitions)</PreprocessorDefinitions>
58
58
  <PreprocessorDefinitions Condition="'$(UseFabric)'=='true'">USE_FABRIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
59
+ <PreprocessorDefinitions>JSI_VERSION=10;%(PreprocessorDefinitions)</PreprocessorDefinitions>
59
60
  </ClCompile>
60
61
  </ItemDefinitionGroup>
61
62
 
@@ -106,7 +106,7 @@
106
106
  <ClInclude Include="$(ReactNativeDir)\ReactCommon\cxxreact\SystraceSection.h" />
107
107
  <ClInclude Include="$(ReactNativeDir)\ReactCommon\jsiexecutor\jsireact\JSIExecutor.h" />
108
108
  <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" />
110
110
  <ClInclude Include="$(ReactNativeDir)\ReactCommon\logger\react_native_log.h" />
111
111
  <ClInclude Include="$(YogaDir)\yoga\YGEnums.h" />
112
112
  <ClInclude Include="$(YogaDir)\yoga\YGMacros.h" />
@@ -128,7 +128,7 @@
128
128
  <ClCompile Include="$(ReactNativeDir)\ReactCommon\jsi\jsi\JSIDynamic.cpp" />
129
129
  <ClCompile Include="$(ReactNativeDir)\ReactCommon\jsiexecutor\jsireact\JSIExecutor.cpp" />
130
130
  <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" />
132
132
  <ClCompile Include="$(ReactNativeDir)\ReactCommon\logger\react_native_log.cpp" />
133
133
  <CLCompile Include="$(ReactNativeDir)\ReactCommon\reactperflogger\reactperflogger\BridgeNativeModulePerfLogger.cpp" />
134
134
  <ClCompile Include="$(YogaDir)\yoga\YGEnums.cpp" />
@@ -241,8 +241,8 @@
241
241
  <!-- Reenable this task if we need to temporarily replace any folly files for fixes, while we wait for PRs to land in folly -->
242
242
  <Target Name="ApplyReactCommonTemporaryPatch" BeforeTargets="PrepareForBuild" DependsOnTargets="UnzipNodeApiJsi">
243
243
  <ItemGroup>
244
- <NodeApiJsiFiles Include="$([MSBuild]::NormalizePath($(NodeApiJsiDir)..))\jsi\**\*.*" />
245
- </ItemGroup>
244
+ <NodeApiJsiFiles Include="$([MSBuild]::NormalizePath($(NodeApiJsiDir)))\jsi\**\*.*" />
245
+ </ItemGroup>
246
246
  <Copy DestinationFiles="@(NodeApiJsiFiles->'$(ReactNativeDir)\ReactCommon\jsi\%(RecursiveDir)%(Filename)%(Extension)')" SourceFiles="@(NodeApiJsiFiles)" />
247
247
  <Copy DestinationFiles="@(TemporaryReactCommonPatchFiles->'$(ReactNativeDir)\ReactCommon\%(RecursiveDir)%(Filename)%(Extension)')" SourceFiles="@(TemporaryReactCommonPatchFiles)" />
248
248
  </Target>
@@ -650,10 +650,10 @@ jsi::Value UIManagerBinding::get(
650
650
 
651
651
  onSuccessFunction.call(
652
652
  runtime,
653
- {jsi::Value{runtime, (double)frame.origin.x},
654
- jsi::Value{runtime, (double)frame.origin.y},
655
- jsi::Value{runtime, (double)frame.size.width},
656
- jsi::Value{runtime, (double)frame.size.height}});
653
+ {jsi::Value{(double)frame.origin.x},
654
+ jsi::Value{(double)frame.origin.y},
655
+ jsi::Value{(double)frame.size.width},
656
+ jsi::Value{(double)frame.size.height}});
657
657
  return jsi::Value::undefined();
658
658
  });
659
659
  }
@@ -695,12 +695,12 @@ jsi::Value UIManagerBinding::get(
695
695
  auto frame = layoutMetrics.frame;
696
696
  onSuccessFunction.call(
697
697
  runtime,
698
- {jsi::Value{runtime, (double)originRelativeToParent.x},
699
- jsi::Value{runtime, (double)originRelativeToParent.y},
700
- jsi::Value{runtime, (double)frame.size.width},
701
- jsi::Value{runtime, (double)frame.size.height},
702
- jsi::Value{runtime, (double)frame.origin.x},
703
- jsi::Value{runtime, (double)frame.origin.y}});
698
+ {jsi::Value{(double)originRelativeToParent.x},
699
+ jsi::Value{(double)originRelativeToParent.y},
700
+ jsi::Value{(double)frame.size.width},
701
+ jsi::Value{(double)frame.size.height},
702
+ jsi::Value{(double)frame.origin.x},
703
+ jsi::Value{(double)frame.origin.y}});
704
704
  return jsi::Value::undefined();
705
705
  });
706
706
  }
@@ -736,10 +736,10 @@ jsi::Value UIManagerBinding::get(
736
736
  auto frame = layoutMetrics.frame;
737
737
  onSuccessFunction.call(
738
738
  runtime,
739
- {jsi::Value{runtime, (double)frame.origin.x},
740
- jsi::Value{runtime, (double)frame.origin.y},
741
- jsi::Value{runtime, (double)frame.size.width},
742
- jsi::Value{runtime, (double)frame.size.height}});
739
+ {jsi::Value{(double)frame.origin.x},
740
+ jsi::Value{(double)frame.origin.y},
741
+ jsi::Value{(double)frame.size.width},
742
+ jsi::Value{(double)frame.size.height}});
743
743
  return jsi::Value::undefined();
744
744
  });
745
745
  }
@@ -886,10 +886,10 @@ jsi::Value UIManagerBinding::get(
886
886
  auto frame = layoutMetrics.frame;
887
887
  return jsi::Array::createWithElements(
888
888
  runtime,
889
- jsi::Value{runtime, (double)frame.origin.x},
890
- jsi::Value{runtime, (double)frame.origin.y},
891
- jsi::Value{runtime, (double)frame.size.width},
892
- jsi::Value{runtime, (double)frame.size.height});
889
+ jsi::Value{(double)frame.origin.x},
890
+ jsi::Value{(double)frame.origin.y},
891
+ jsi::Value{(double)frame.size.width},
892
+ jsi::Value{(double)frame.size.height});
893
893
  });
894
894
  }
895
895
 
@@ -1150,8 +1150,8 @@ jsi::Value UIManagerBinding::get(
1150
1150
  return jsi::Array::createWithElements(
1151
1151
  runtime,
1152
1152
  (*newestParentOfShadowNode).getInstanceHandle(runtime),
1153
- jsi::Value{runtime, (double)offsetTop},
1154
- jsi::Value{runtime, (double)offsetLeft});
1153
+ jsi::Value{(double)offsetTop},
1154
+ jsi::Value{(double)offsetLeft});
1155
1155
  });
1156
1156
  }
1157
1157
 
@@ -1217,12 +1217,8 @@ jsi::Value UIManagerBinding::get(
1217
1217
 
1218
1218
  return jsi::Array::createWithElements(
1219
1219
  runtime,
1220
- jsi::Value{
1221
- runtime,
1222
- scrollPosition.x == 0 ? 0 : (double)-scrollPosition.x},
1223
- jsi::Value{
1224
- runtime,
1225
- scrollPosition.y == 0 ? 0 : (double)-scrollPosition.y});
1220
+ jsi::Value{scrollPosition.x == 0 ? 0 : (double)-scrollPosition.x},
1221
+ jsi::Value{scrollPosition.y == 0 ? 0 : (double)-scrollPosition.y});
1226
1222
  });
1227
1223
  }
1228
1224
 
@@ -1291,8 +1287,8 @@ jsi::Value UIManagerBinding::get(
1291
1287
 
1292
1288
  return jsi::Array::createWithElements(
1293
1289
  runtime,
1294
- jsi::Value{runtime, std::round(scrollSize.width)},
1295
- jsi::Value{runtime, std::round(scrollSize.height)});
1290
+ jsi::Value{(double)std::round(scrollSize.width)},
1291
+ jsi::Value{(double)std::round(scrollSize.height)});
1296
1292
  });
1297
1293
  }
1298
1294
 
@@ -1343,8 +1339,8 @@ jsi::Value UIManagerBinding::get(
1343
1339
 
1344
1340
  return jsi::Array::createWithElements(
1345
1341
  runtime,
1346
- jsi::Value{runtime, std::round(paddingFrame.size.width)},
1347
- jsi::Value{runtime, std::round(paddingFrame.size.height)});
1342
+ jsi::Value{(double)std::round(paddingFrame.size.width)},
1343
+ jsi::Value{(double)std::round(paddingFrame.size.height)});
1348
1344
  });
1349
1345
  }
1350
1346
 
@@ -1395,10 +1391,10 @@ jsi::Value UIManagerBinding::get(
1395
1391
 
1396
1392
  return jsi::Array::createWithElements(
1397
1393
  runtime,
1398
- jsi::Value{runtime, std::round(layoutMetrics.borderWidth.top)},
1399
- jsi::Value{runtime, std::round(layoutMetrics.borderWidth.right)},
1400
- jsi::Value{runtime, std::round(layoutMetrics.borderWidth.bottom)},
1401
- jsi::Value{runtime, std::round(layoutMetrics.borderWidth.left)});
1394
+ jsi::Value{(double)std::round(layoutMetrics.borderWidth.top)},
1395
+ jsi::Value{(double)std::round(layoutMetrics.borderWidth.right)},
1396
+ jsi::Value{(double)std::round(layoutMetrics.borderWidth.bottom)},
1397
+ jsi::Value{(double)std::round(layoutMetrics.borderWidth.left)});
1402
1398
  });
1403
1399
  }
1404
1400
 
@@ -10,7 +10,7 @@
10
10
  #include <NodeApiJsiRuntime.h>
11
11
  #include <crash/verifyElseCrash.h>
12
12
  #include <cxxreact/SystraceSection.h>
13
- #include <jsinspector/InspectorInterfaces.h>
13
+ #include <jsinspector-modern/InspectorInterfaces.h>
14
14
  #include <mutex>
15
15
  #include "SafeLoadLibrary.h"
16
16
 
@@ -38,7 +38,7 @@ void NAPI_CDECL removeInspectorPage(int32_t pageId) noexcept;
38
38
 
39
39
  class HermesFuncResolver : public IFuncResolver {
40
40
  public:
41
- HermesFuncResolver() : libHandle_(SafeLoadLibrary(L"hermes.dll")) {}
41
+ HermesFuncResolver() : libHandle_(LoadLibraryAsPeerFirst(L"hermes.dll")) {}
42
42
 
43
43
  FuncPtr getFuncPtr(const char *funcName) override {
44
44
  return reinterpret_cast<FuncPtr>(GetProcAddress(libHandle_, funcName));
@@ -230,10 +230,10 @@ class HermesScriptCache {
230
230
  std::shared_ptr<facebook::jsi::PreparedScriptStore> scriptStore_;
231
231
  };
232
232
 
233
- class HermesLocalConnection : public facebook::react::ILocalConnection {
233
+ class HermesLocalConnection : public facebook::react::jsinspector_modern::ILocalConnection {
234
234
  public:
235
235
  HermesLocalConnection(
236
- std::unique_ptr<facebook::react::IRemoteConnection> remoteConnection,
236
+ std::unique_ptr<facebook::react::jsinspector_modern::IRemoteConnection> remoteConnection,
237
237
  void *connectFunc) noexcept {
238
238
  CRASH_ON_ERROR(getHermesApi().hermes_create_local_connection(
239
239
  connectFunc,
@@ -259,15 +259,15 @@ class HermesLocalConnection : public facebook::react::ILocalConnection {
259
259
 
260
260
  private:
261
261
  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);
263
263
  }
264
264
 
265
265
  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();
267
267
  }
268
268
 
269
269
  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);
271
271
  }
272
272
 
273
273
  private:
@@ -275,18 +275,18 @@ class HermesLocalConnection : public facebook::react::ILocalConnection {
275
275
  };
276
276
 
277
277
  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(
279
279
  title,
280
280
  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) {
283
283
  HermesApi::Scope apiScope(hermesApi);
284
284
  return std::make_unique<HermesLocalConnection>(std::move(remoteConnection), connectFunc);
285
285
  });
286
286
  }
287
287
 
288
288
  void NAPI_CDECL removeInspectorPage(int32_t pageId) noexcept {
289
- facebook::react::getInspectorInstance().removePage(pageId);
289
+ facebook::react::jsinspector_modern::getInspectorInstance().removePage(pageId);
290
290
  }
291
291
 
292
292
  } // namespace
@@ -72,10 +72,10 @@ struct InspectorProtocol {
72
72
  }
73
73
 
74
74
  static folly::dynamic constructGetPagesResponsePayloadForPackager(
75
- const std::vector<facebook::react::InspectorPage> &pages,
75
+ const std::vector<facebook::react::jsinspector_modern::InspectorPage> &pages,
76
76
  InspectorPackagerConnection::BundleStatus bundleStatus) {
77
77
  folly::dynamic payload = folly::dynamic::array;
78
- for (const facebook::react::InspectorPage &page : pages) {
78
+ for (const facebook::react::jsinspector_modern::InspectorPage &page : pages) {
79
79
  folly::dynamic pageDyn = folly::dynamic::object;
80
80
  pageDyn["id"] = page.id;
81
81
  pageDyn["title"] = page.title;
@@ -167,62 +167,63 @@ winrt::fire_and_forget InspectorPackagerConnection::connectAsync() {
167
167
  m_packagerWebSocketConnection->SetOnConnect(
168
168
  []() { facebook::react::tracing::log("Inspector: Websocket connection succeeded."); });
169
169
 
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
+ }
221
225
  }
222
- break;
223
- }
224
- }
225
- });
226
+ });
226
227
 
227
228
  Microsoft::React::Networking::IWebSocketResource::Protocols protocols;
228
229
  Microsoft::React::Networking::IWebSocketResource::Options options;
@@ -4,7 +4,7 @@
4
4
  #pragma once
5
5
 
6
6
  #include <Networking/WinRTWebSocketResource.h>
7
- #include <jsinspector/InspectorInterfaces.h>
7
+ #include <jsinspector-modern/InspectorInterfaces.h>
8
8
 
9
9
  namespace Microsoft::ReactNative {
10
10
 
@@ -40,13 +40,14 @@ class InspectorPackagerConnection final : public std::enable_shared_from_this<In
40
40
  void sendMessageToVM(int32_t pageId, std::string &&message);
41
41
 
42
42
  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;
44
45
  std::shared_ptr<Microsoft::React::Networking::WinRTWebSocketResource> m_packagerWebSocketConnection;
45
46
  std::shared_ptr<IBundleStatusProvider> m_bundleStatusProvider;
46
47
  std::string m_url;
47
48
  };
48
49
 
49
- class RemoteConnection final : public facebook::react::IRemoteConnection {
50
+ class RemoteConnection final : public facebook::react::jsinspector_modern::IRemoteConnection {
50
51
  public:
51
52
  RemoteConnection(int32_t pageId, const InspectorPackagerConnection &packagerConnection);
52
53
  void onMessage(std::string message) override;
@@ -16,7 +16,7 @@ namespace {
16
16
 
17
17
  class V8FuncResolver : public IFuncResolver {
18
18
  public:
19
- V8FuncResolver() : libHandle_(SafeLoadLibrary(L"v8jsi.dll")) {}
19
+ V8FuncResolver() : libHandle_(LoadLibraryAsPeerFirst(L"v8jsi.dll")) {}
20
20
 
21
21
  FuncPtr getFuncPtr(const char *funcName) override {
22
22
  return reinterpret_cast<FuncPtr>(GetProcAddress(libHandle_, funcName));
@@ -140,15 +140,19 @@ void DefaultBlobResource::Release(string &&blobId) noexcept /*override*/ {
140
140
  void DefaultBlobResource::AddNetworkingHandler() noexcept /*override*/ {
141
141
  auto propId = msrn::ReactPropertyId<msrn::ReactNonAbiValue<weak_ptr<IHttpModuleProxy>>>{L"HttpModule.Proxy"};
142
142
 
143
+ bool handlerAdded = false;
143
144
  if (auto prop = m_propertyBag.Get(propId)) {
144
145
  if (auto httpHandler = prop.Value().lock()) {
145
146
  httpHandler->AddRequestBodyHandler(m_requestBodyHandler);
146
147
  httpHandler->AddResponseHandler(m_responseHandler);
148
+ handlerAdded = true;
147
149
  }
148
- } else {
149
- // #11439 - The absence of HttpModule.Proxy may be caused by a module initialization race condition.
150
- // Best-effort approach to set up the request/response handlers by exposing this interface to dependents
151
- // (i.e. IHttpResource).
150
+ }
151
+
152
+ // #11439 - The absence of HttpModule.Proxy may be caused by a module initialization race condition.
153
+ // Best-effort approach to set up the request/response handlers by exposing this interface to dependents
154
+ // (i.e. IHttpResource).
155
+ if (!handlerAdded) {
152
156
  auto propId = msrn::ReactPropertyId<msrn::ReactNonAbiValue<weak_ptr<IBlobResource>>>{L"Blob.Resource"};
153
157
  m_propertyBag.Set(propId, weak_ptr<IBlobResource>(shared_from_this()));
154
158
  }
@@ -545,7 +545,7 @@ WinRTHttpResource::PerformSendRequest(HttpMethod &&method, Uri &&rtUri, IInspect
545
545
  if (self->m_onComplete) {
546
546
  self->m_onComplete(reqArgs->RequestId);
547
547
  }
548
- co_return;
548
+ co_return self->UntrackResponse(reqArgs->RequestId);
549
549
  }
550
550
  }
551
551
 
@@ -52,6 +52,7 @@
52
52
 
53
53
  #if defined(USE_V8)
54
54
  #include <JSI/V8RuntimeHolder.h>
55
+ #include "V8JSIRuntimeHolder.h"
55
56
  #endif
56
57
  #include <ReactCommon/CallInvoker.h>
57
58
  #include <ReactCommon/TurboModuleBinding.h>
@@ -319,7 +320,24 @@ InstanceImpl::InstanceImpl(
319
320
  m_devSettings, m_jsThread, std::move(preparedScriptStore));
320
321
  break;
321
322
  }
322
- case JSIEngineOverride::V8:
323
+ case JSIEngineOverride::V8: {
324
+ #if defined(USE_V8)
325
+ std::shared_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore;
326
+
327
+ wchar_t tempPath[MAX_PATH];
328
+ if (GetTempPathW(MAX_PATH, tempPath)) {
329
+ preparedScriptStore =
330
+ std::make_shared<facebook::react::BasePreparedScriptStoreImpl>(winrt::to_string(tempPath));
331
+ }
332
+
333
+ m_devSettings->jsiRuntimeHolder = std::make_shared<facebook::react::V8JSIRuntimeHolder>(
334
+ m_devSettings, m_jsThread, nullptr, std::move(preparedScriptStore), /*multithreading*/ false);
335
+ break;
336
+ #else
337
+ assert(false); // V8 is not available in this build, fallthrough
338
+ [[fallthrough]];
339
+ #endif
340
+ }
323
341
  case JSIEngineOverride::V8NodeApi: {
324
342
  #if defined(USE_V8)
325
343
  std::shared_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore;
@@ -2,19 +2,22 @@
2
2
  // Licensed under the MIT License.
3
3
 
4
4
  #include "SafeLoadLibrary.h"
5
+ #include "PathCch.h"
6
+
7
+ EXTERN_C IMAGE_DOS_HEADER __ImageBase;
5
8
 
6
9
  namespace Microsoft::ReactNative {
7
10
 
8
11
  // Unsafe calls to LoadLibrary/LoadLibraryEx.
9
12
  // The default behavior of LoadLibrary, or LoadLibraryEx without flags, is to try and find the dependency by iterating
10
13
  // through a search order. This search order contains the current working directory. In the classic attack, a malicious
11
- // DLL is dropped in the likely - controllable current working directory.The malicious DLL has the same name as a
12
- // missing dependency or dependency that is not in the same directory as the executable.When the call to LoadLibrary is
13
- // reached, the malicious DLL is loaded preferentially, and code execution occurs.
14
+ // DLL is dropped in the likely - controllable current working directory. The malicious DLL has the same name as a
15
+ // missing dependency or dependency that is not in the same directory as the executable. When the call to LoadLibrary
16
+ // is reached, the malicious DLL is loaded preferentially, and code execution occurs.
14
17
  //
15
18
  // The SafeLoadLibrary is the preferred ways to manually load dependencies.
16
19
  // The API does not search the current working directory when resolving dependencies.
17
- // It is "borrowed" from Office Mso code.
20
+ // The implementation is "borrowed" from Office MsoSafeLoadLibrary.
18
21
 
19
22
  /**
20
23
  List of new flags that control where to search for DLLs. Requires KB2533623.
@@ -22,20 +25,53 @@ namespace Microsoft::ReactNative {
22
25
  const DWORD SafeLoadLibraryFlags = LOAD_LIBRARY_SEARCH_APPLICATION_DIR | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS |
23
26
  LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR | LOAD_LIBRARY_SEARCH_SYSTEM32 | LOAD_LIBRARY_SEARCH_USER_DIRS;
24
27
 
25
- HMODULE SafeLoadLibrary(const wchar_t *wzFileName, HANDLE hFile, DWORD dwFlags) noexcept {
28
+ HMODULE SafeLoadLibrary(const wchar_t *fileName, DWORD dwFlags) noexcept {
26
29
  // When calling LoadLibrary, OR in LOAD_LIBRARY_SEARCH_DEFAULT_DIRS which enables all of the
27
30
  // safe behaviors. Note that this flag is not compatible with LOAD_WITH_ALTERED_SEARCH_PATH.
31
+ #pragma push_macro("LoadLibraryExW")
32
+ #undef LoadLibraryExW
28
33
  HMODULE module =
29
- LoadLibraryExW(wzFileName, hFile, (dwFlags | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS) & ~LOAD_WITH_ALTERED_SEARCH_PATH);
34
+ ::LoadLibraryExW(fileName, 0, (dwFlags | LOAD_LIBRARY_SEARCH_DEFAULT_DIRS) & ~LOAD_WITH_ALTERED_SEARCH_PATH);
30
35
  if (module == nullptr && GetLastError() == ERROR_INVALID_PARAMETER) {
31
36
  // Could have failed with actual bad parameters or an unpatched OS without KB2533623.
32
- if (GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "AddDllDirectory") == nullptr) {
37
+ if (::GetProcAddress(::GetModuleHandleW(L"kernel32.dll"), "AddDllDirectory") == nullptr) {
33
38
  // Unpatched OS, remove all new flags.
34
- module = LoadLibraryExW(wzFileName, hFile, dwFlags & ~SafeLoadLibraryFlags);
39
+ module = ::LoadLibraryExW(fileName, 0, dwFlags & ~SafeLoadLibraryFlags);
35
40
  }
36
41
  }
42
+ #pragma pop_macro("LoadLibraryExW")
37
43
 
38
44
  return module;
39
45
  }
40
46
 
47
+ // Gets the full file name in the same directory as the current DLL.
48
+ // It returns nullptr if we cannot create the full file name.
49
+ wchar_t *GePeerFullFileName(const wchar_t *fileName, wchar_t *buffer, size_t bufferSize) {
50
+ size_t nameSize =
51
+ ::GetModuleFileNameW(reinterpret_cast<HINSTANCE>(&__ImageBase), buffer, static_cast<DWORD>(bufferSize));
52
+ if (nameSize == 0 || nameSize == bufferSize)
53
+ return nullptr;
54
+
55
+ if (::PathCchRemoveFileSpec(buffer, bufferSize) != S_OK)
56
+ return nullptr;
57
+ if (::PathCchCombineEx(buffer, bufferSize, buffer, fileName, PATHCCH_ALLOW_LONG_PATHS) != S_OK)
58
+ return nullptr;
59
+
60
+ return buffer;
61
+ }
62
+
63
+ HMODULE LoadLibraryAsPeerFirst(const wchar_t *fileName) noexcept {
64
+ HMODULE lib{nullptr};
65
+ constexpr size_t nameBufferSize = 4096;
66
+ wchar_t nameBuffer[nameBufferSize] = L"";
67
+
68
+ if (wchar_t *fullFileName = GePeerFullFileName(fileName, nameBuffer, nameBufferSize))
69
+ lib = SafeLoadLibrary(fullFileName);
70
+
71
+ if (!lib)
72
+ lib = SafeLoadLibrary(fileName);
73
+
74
+ return lib;
75
+ }
76
+
41
77
  } // namespace Microsoft::ReactNative
@@ -10,6 +10,10 @@
10
10
  namespace Microsoft::ReactNative {
11
11
 
12
12
  // Safe LoadLibraryEx wrapper that must be used instead of LoadLibrary.
13
- extern HMODULE SafeLoadLibrary(const wchar_t *wzFileName, HANDLE hFile = nullptr, DWORD dwFlags = 0) noexcept;
13
+ extern HMODULE SafeLoadLibrary(const wchar_t *fileName, DWORD flags = 0) noexcept;
14
+
15
+ // Try to load the dll from the same folder as the current DLL first,
16
+ // and if it is not found, then use the SafeLoadLibrary.
17
+ extern HMODULE LoadLibraryAsPeerFirst(const wchar_t *fileName) noexcept;
14
18
 
15
19
  } // namespace Microsoft::ReactNative
@@ -223,6 +223,9 @@
223
223
  <ClCompile Include="$(MSBuildThisFileDirectory)TurboModuleManager.cpp" />
224
224
  <ClCompile Include="$(MSBuildThisFileDirectory)Utils.cpp" />
225
225
  <ClCompile Include="$(MSBuildThisFileDirectory)Utils\WinRTConversions.cpp" />
226
+ <ClCompile Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.cpp">
227
+ <ExcludedFromBuild Condition="'$(UseV8)' != 'true'">true</ExcludedFromBuild>
228
+ </ClCompile>
226
229
  </ItemGroup>
227
230
  <ItemGroup>
228
231
  <ClInclude Include="$(MSBuildThisFileDirectory)..\codegen\react\components\rnwcore\EventEmitters.h" />
@@ -396,6 +399,7 @@
396
399
  <ClInclude Include="$(MSBuildThisFileDirectory)Utils.h" />
397
400
  <ClInclude Include="$(MSBuildThisFileDirectory)Utils\CppWinrtLessExceptions.h" />
398
401
  <ClInclude Include="$(MSBuildThisFileDirectory)Utils\WinRTConversions.h" />
402
+ <ClInclude Include="$(MSBuildThisFileDirectory)V8JSIRuntimeHolder.h" />
399
403
  <ClInclude Include="$(MSBuildThisFileDirectory)WebSocketJSExecutorFactory.h" />
400
404
  <ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Modules\DevSettingsModule.cpp" />
401
405
  <ClCompile Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\Modules\ReactRootViewTagGenerator.cpp" />