react-native-windows 0.66.16 → 0.66.19

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 (59) hide show
  1. package/CHANGELOG.json +58 -1
  2. package/CHANGELOG.md +30 -4
  3. package/Chakra/ChakraHelpers.cpp +0 -1
  4. package/Libraries/Network/RCTNetworkingWinShared.js +7 -0
  5. package/Microsoft.ReactNative/Base/CoreNativeModules.cpp +2 -3
  6. package/Microsoft.ReactNative/Modules/CreateModules.cpp +3 -3
  7. package/Microsoft.ReactNative/packages.config +1 -1
  8. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.cpp +9 -13
  9. package/Microsoft.ReactNative.Cxx/JSI/NodeApiJsiRuntime.h +4 -0
  10. package/Microsoft.ReactNative.Cxx/NativeModules.h +2 -2
  11. package/Mso/src/dispatchQueue/threadPoolScheduler_win.cpp +96 -4
  12. package/PropertySheets/JSEngine.props +1 -1
  13. package/Scripts/OfficeReact.Win32.nuspec +1 -1
  14. package/Shared/BaseScriptStoreImpl.cpp +1 -1
  15. package/Shared/CppRuntimeOptions.h +50 -0
  16. package/Shared/CreateModules.h +20 -1
  17. package/Shared/InspectorPackagerConnection.cpp +7 -5
  18. package/Shared/InspectorPackagerConnection.h +2 -2
  19. package/Shared/JSI/ChakraApi.cpp +0 -1
  20. package/Shared/JSI/ChakraRuntime.cpp +0 -1
  21. package/Shared/JSI/NapiJsiV8RuntimeHolder.h +1 -1
  22. package/Shared/Modules/BlobModule.cpp +376 -0
  23. package/Shared/Modules/BlobModule.h +153 -0
  24. package/Shared/Modules/CxxModuleUtilities.cpp +19 -0
  25. package/Shared/Modules/CxxModuleUtilities.h +23 -0
  26. package/Shared/Modules/FileReaderModule.cpp +156 -0
  27. package/Shared/Modules/FileReaderModule.h +54 -0
  28. package/Shared/Modules/HttpModule.cpp +201 -0
  29. package/Shared/Modules/HttpModule.h +60 -0
  30. package/Shared/Modules/IBlobPersistor.h +30 -0
  31. package/Shared/Modules/IHttpModuleProxy.h +30 -0
  32. package/Shared/Modules/IRequestBodyHandler.h +52 -0
  33. package/Shared/Modules/IResponseHandler.h +27 -0
  34. package/Shared/Modules/IUriHandler.h +37 -0
  35. package/Shared/Modules/IWebSocketModuleContentHandler.h +26 -0
  36. package/Shared/Modules/IWebSocketModuleProxy.h +22 -0
  37. package/Shared/Modules/NetworkingModule.cpp +1 -1
  38. package/Shared/Modules/WebSocketModule.cpp +97 -23
  39. package/Shared/Modules/WebSocketModule.h +35 -6
  40. package/Shared/Networking/IHttpResource.h +101 -0
  41. package/Shared/{IWebSocketResource.h → Networking/IWebSocketResource.h} +3 -3
  42. package/Shared/Networking/OriginPolicy.h +15 -0
  43. package/Shared/Networking/OriginPolicyHttpFilter.cpp +747 -0
  44. package/Shared/Networking/OriginPolicyHttpFilter.h +112 -0
  45. package/Shared/Networking/WinRTHttpResource.cpp +465 -0
  46. package/Shared/Networking/WinRTHttpResource.h +86 -0
  47. package/Shared/Networking/WinRTTypes.h +33 -0
  48. package/Shared/{WinRTWebSocketResource.cpp → Networking/WinRTWebSocketResource.cpp} +31 -22
  49. package/Shared/{WinRTWebSocketResource.h → Networking/WinRTWebSocketResource.h} +3 -3
  50. package/Shared/OInstance.cpp +44 -4
  51. package/Shared/OInstance.h +8 -4
  52. package/Shared/RuntimeOptions.cpp +93 -15
  53. package/Shared/RuntimeOptions.h +22 -9
  54. package/Shared/Shared.vcxitems +28 -4
  55. package/Shared/Shared.vcxitems.filters +93 -12
  56. package/Shared/Utils/WinRTConversions.cpp +22 -0
  57. package/Shared/Utils/WinRTConversions.h +15 -0
  58. package/package.json +1 -1
  59. package/Shared/IHttpResource.h +0 -34
package/CHANGELOG.json CHANGED
@@ -2,7 +2,64 @@
2
2
  "name": "react-native-windows",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 04 Apr 2022 15:12:52 GMT",
5
+ "date": "Tue, 24 May 2022 21:08:42 GMT",
6
+ "tag": "react-native-windows_v0.66.19",
7
+ "version": "0.66.19",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "comment": "Implement Blob module (#9352)",
12
+ "author": "julio@rochsquadron.net",
13
+ "commit": "4b1eb4196ab7be2e266da754637a00a252f3745f",
14
+ "package": "react-native-windows"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Mon, 02 May 2022 15:10:52 GMT",
21
+ "tag": "react-native-windows_v0.66.18",
22
+ "version": "0.66.18",
23
+ "comments": {
24
+ "patch": [
25
+ {
26
+ "comment": "Fix clang-check errors in NativeModules.h",
27
+ "author": "53799235+ZihanChen-MSFT@users.noreply.github.com",
28
+ "commit": "94d54d33e317332fa9145129d228a8e323f9b948",
29
+ "package": "react-native-windows"
30
+ },
31
+ {
32
+ "comment": "Handle abrupt WebSocket connection interruption (#9829)",
33
+ "author": "julio.rocha@microsoft.com",
34
+ "commit": "e2571e1d39d3fef4d4ad328a1662ab7f30fec633",
35
+ "package": "react-native-windows"
36
+ }
37
+ ]
38
+ }
39
+ },
40
+ {
41
+ "date": "Mon, 25 Apr 2022 15:09:39 GMT",
42
+ "tag": "react-native-windows_v0.66.17",
43
+ "version": "0.66.17",
44
+ "comments": {
45
+ "patch": [
46
+ {
47
+ "comment": "Fix JSI for Node-API and update V8 to 0.65.11",
48
+ "author": "vmorozov@microsoft.com",
49
+ "commit": "3e1da9e94cba42c622cf68baecbd57d7e8a6971d",
50
+ "package": "react-native-windows"
51
+ },
52
+ {
53
+ "comment": "Fix Sequential DispatchQueue deadlock on shutdown",
54
+ "author": "vmorozov@microsoft.com",
55
+ "commit": "9ace3b51d407cccf120c2ad0a23c66d12a173a7f",
56
+ "package": "react-native-windows"
57
+ }
58
+ ]
59
+ }
60
+ },
61
+ {
62
+ "date": "Mon, 04 Apr 2022 15:13:07 GMT",
6
63
  "tag": "react-native-windows_v0.66.16",
7
64
  "version": "0.66.16",
8
65
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,17 +1,43 @@
1
1
  # Change Log - react-native-windows
2
2
 
3
- This log was last generated on Mon, 04 Apr 2022 15:12:52 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 24 May 2022 21:08:42 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## 0.66.16
7
+ ## 0.66.19
8
8
 
9
- Mon, 04 Apr 2022 15:12:52 GMT
9
+ Tue, 24 May 2022 21:08:42 GMT
10
10
 
11
11
  ### Patches
12
12
 
13
- - MustBeNoExceptVoidFunctor should depend on the template type parameter to avoid being evaluated too early (#9609) (asklar@microsoft.com)
13
+ - Implement Blob module (#9352) (julio@rochsquadron.net)
14
14
 
15
+ ## 0.66.18
16
+
17
+ Mon, 02 May 2022 15:10:52 GMT
18
+
19
+ ### Patches
20
+
21
+ - Fix clang-check errors in NativeModules.h (53799235+ZihanChen-MSFT@users.noreply.github.com)
22
+ - Handle abrupt WebSocket connection interruption (#9829) (julio.rocha@microsoft.com)
23
+
24
+ ## 0.66.17
25
+
26
+ Mon, 25 Apr 2022 15:09:39 GMT
27
+
28
+ ### Patches
29
+
30
+ - Fix JSI for Node-API and update V8 to 0.65.11 (vmorozov@microsoft.com)
31
+ - Fix Sequential DispatchQueue deadlock on shutdown (vmorozov@microsoft.com)
32
+
33
+ ## 0.66.16
34
+
35
+ Mon, 04 Apr 2022 15:13:07 GMT
36
+
37
+ ### Patches
38
+
39
+ - MustBeNoExceptVoidFunctor should depend on the template type parameter to avoid being evaluated too early (#9609) (asklar@microsoft.com)
40
+
15
41
  ## 0.66.15
16
42
 
17
43
  Mon, 14 Mar 2022 15:13:42 GMT
@@ -3,7 +3,6 @@
3
3
 
4
4
  #include "pch.h"
5
5
 
6
- #include <RuntimeOptions.h>
7
6
  #include "ChakraHelpers.h"
8
7
  #include "ChakraUtils.h"
9
8
  #include "ChakraValue.h"
@@ -61,6 +61,11 @@ type RCTNetworkingEventDefinitions = $ReadOnly<{
61
61
  ],
62
62
  }>;
63
63
 
64
+ let _requestId = 1;
65
+ function generateRequestId(): number {
66
+ return _requestId++;
67
+ }
68
+
64
69
  const RCTNetworking = {
65
70
  addListener<K: $Keys<RCTNetworkingEventDefinitions>>(
66
71
  eventType: K,
@@ -82,11 +87,13 @@ const RCTNetworking = {
82
87
  callback: (requestId: number) => void,
83
88
  withCredentials: boolean,
84
89
  ) {
90
+ const requestId = generateRequestId();
85
91
  const body = convertRequestBody(data);
86
92
  RCTNetworkingNative.sendRequest(
87
93
  {
88
94
  method,
89
95
  url,
96
+ requestId,
90
97
  data: {...body, trackingName},
91
98
  headers,
92
99
  responseType,
@@ -14,7 +14,6 @@
14
14
  #include <Modules/ImageViewManagerModule.h>
15
15
  #include <Modules/LinkingManagerModule.h>
16
16
  #include <Modules/NativeUIManager.h>
17
- #include <Modules/NetworkingModule.h>
18
17
  #include <Modules/PaperUIManagerModule.h>
19
18
  #include <Threading/MessageQueueThreadFactory.h>
20
19
 
@@ -51,8 +50,8 @@ std::vector<facebook::react::NativeModuleDescription> GetCoreModules(
51
50
  std::vector<facebook::react::NativeModuleDescription> modules;
52
51
 
53
52
  modules.emplace_back(
54
- Microsoft::React::NetworkingModule::Name,
55
- []() { return std::make_unique<Microsoft::React::NetworkingModule>(); },
53
+ "Networking",
54
+ [props = context->Properties()]() { return Microsoft::React::CreateHttpModule(props); },
56
55
  jsMessageQueue);
57
56
 
58
57
  modules.emplace_back(
@@ -2,10 +2,10 @@
2
2
  // Licensed under the MIT License.
3
3
 
4
4
  #include <CreateModules.h>
5
+ #include <Networking/WinRTWebSocketResource.h>
5
6
  #include <QuirkSettings.h>
6
7
  #include <React.h>
7
8
  #include <ReactPropertyBag.h>
8
- #include <WinRTWebSocketResource.h>
9
9
 
10
10
  // React Native
11
11
  #include <cxxreact/CxxModule.h>
@@ -17,11 +17,11 @@ using winrt::Microsoft::ReactNative::ReactPropertyBag;
17
17
  using winrt::Microsoft::ReactNative::ReactPropertyId;
18
18
  using winrt::Microsoft::ReactNative::implementation::QuirkSettings;
19
19
 
20
- namespace Microsoft::React {
20
+ namespace Microsoft::React::Networking {
21
21
 
22
22
  std::shared_ptr<IWebSocketResource> IWebSocketResource::Make() {
23
23
  std::vector<winrt::Windows::Security::Cryptography::Certificates::ChainValidationResult> certExceptions;
24
24
  return std::make_shared<WinRTWebSocketResource>(std::move(certExceptions));
25
25
  }
26
26
 
27
- } // namespace Microsoft::React
27
+ } // namespace Microsoft::React::Networking
@@ -8,5 +8,5 @@
8
8
  <package id="Microsoft.Windows.CppWinRT" version="2.0.210312.4" targetFramework="native" />
9
9
  <package id="Microsoft.WinUI" version="3.0.0-preview4.210210.4" targetFramework="native" />
10
10
  <package id="ReactNative.Hermes.Windows" version="0.9.0-ms.4" targetFramework="native" />
11
- <!-- package id="ReactNative.V8Jsi.Windows.UWP" version="0.65.5" targetFramework="native" / -->
11
+ <!-- package id="ReactNative.V8Jsi.Windows.UWP" version="0.65.11" targetFramework="native" / -->
12
12
  </packages>
@@ -190,7 +190,7 @@ struct NapiJsiRuntime : facebook::jsi::Runtime {
190
190
  facebook::jsi::Function createFunctionFromHostFunction(
191
191
  const facebook::jsi::PropNameID &name,
192
192
  unsigned int paramCount,
193
- facebook::jsi::HostFunctionType type) override;
193
+ facebook::jsi::HostFunctionType func) override;
194
194
  facebook::jsi::Value call(
195
195
  const facebook::jsi::Function &func,
196
196
  const facebook::jsi::Value &jsThis,
@@ -475,7 +475,7 @@ struct NapiJsiRuntime : facebook::jsi::Runtime {
475
475
  void SetProperty(napi_value object, napi_value propertyId, napi_value value, napi_property_attributes attrs) const;
476
476
  napi_value CreateArray(size_t length) const;
477
477
  void SetElement(napi_value array, uint32_t index, napi_value value) const;
478
- static napi_value JsiHostFunctionCallback(napi_env env, napi_callback_info info) noexcept;
478
+ static napi_value __cdecl JsiHostFunctionCallback(napi_env env, napi_callback_info info) noexcept;
479
479
  napi_value CreateExternalFunction(napi_value name, int32_t paramCount, napi_callback callback, void *callbackData);
480
480
  napi_value CreateExternalObject(void *data, napi_finalize finalizeCallback) const;
481
481
  template <typename T>
@@ -1702,7 +1702,7 @@ void NapiJsiRuntime::SetElement(napi_value array, uint32_t index, napi_value val
1702
1702
  }
1703
1703
 
1704
1704
  // The NAPI external function callback used for the JSI host function implementation.
1705
- /*static*/ napi_value NapiJsiRuntime::JsiHostFunctionCallback(napi_env env, napi_callback_info info) noexcept {
1705
+ /*static*/ napi_value __cdecl NapiJsiRuntime::JsiHostFunctionCallback(napi_env env, napi_callback_info info) noexcept {
1706
1706
  HostFunctionWrapper *hostFuncWrapper{};
1707
1707
  size_t argc{};
1708
1708
  CHECK_NAPI_ELSE_CRASH(
@@ -1750,15 +1750,11 @@ napi_value NapiJsiRuntime::CreateExternalObject(void *data, napi_finalize finali
1750
1750
  // Wraps up std::unique_ptr as an external object.
1751
1751
  template <typename T>
1752
1752
  napi_value NapiJsiRuntime::CreateExternalObject(unique_ptr<T> &&data) const {
1753
- napi_value object =
1754
- CreateExternalObject(data.get(), [](napi_env /*env*/, void *dataToDestroy, void * /*finalizerHint*/) {
1755
- // We wrap dataToDestroy in a unique_ptr to avoid calling delete explicitly.
1756
- if (std::is_array<T>::value) {
1757
- delete[] static_cast<T *>(dataToDestroy);
1758
- } else {
1759
- delete static_cast<T *>(dataToDestroy);
1760
- }
1761
- });
1753
+ napi_finalize finalize = [](napi_env /*env*/, void *dataToDestroy, void * /*finalizerHint*/) {
1754
+ // We wrap dataToDestroy in a unique_ptr to avoid calling delete explicitly.
1755
+ unique_ptr<T> dataDeleter{static_cast<T *>(dataToDestroy)};
1756
+ };
1757
+ napi_value object = CreateExternalObject(data.get(), finalize);
1762
1758
 
1763
1759
  // We only call data.release() after the CreateExternalObject succeeds.
1764
1760
  // Otherwise, when CreateExternalObject fails and an exception is thrown,
@@ -1807,7 +1803,7 @@ napi_value NapiJsiRuntime::GetHostObjectProxyHandler() {
1807
1803
  // Sets Proxy trap method as a pointer to NapiJsiRuntime instance method.
1808
1804
  template <napi_value (NapiJsiRuntime::*trapMethod)(span<napi_value>), size_t argCount>
1809
1805
  void NapiJsiRuntime::SetProxyTrap(napi_value handler, napi_value propertyName) {
1810
- auto proxyTrap = [](napi_env env, napi_callback_info info) noexcept {
1806
+ napi_callback proxyTrap = [](napi_env env, napi_callback_info info) noexcept {
1811
1807
  NapiJsiRuntime *runtime{};
1812
1808
  napi_value args[argCount]{};
1813
1809
  size_t actualArgCount{argCount};
@@ -2,6 +2,8 @@
2
2
  // Licensed under the MIT License.
3
3
 
4
4
  #pragma once
5
+ #ifndef MICROSOFT_REACTNATIVE_JSI_NODEAPIJSIRUNTIME
6
+ #define MICROSOFT_REACTNATIVE_JSI_NODEAPIJSIRUNTIME
5
7
 
6
8
  // JSI
7
9
  #include <js_native_ext_api.h>
@@ -19,3 +21,5 @@ namespace Microsoft::JSI {
19
21
  std::unique_ptr<facebook::jsi::Runtime> __cdecl MakeNodeApiJsiRuntime(napi_env env) noexcept;
20
22
 
21
23
  } // namespace Microsoft::JSI
24
+
25
+ #endif // MICROSOFT_REACTNATIVE_JSI_NODEAPIJSIRUNTIME
@@ -1011,7 +1011,7 @@ template <class TModule, int I, class TMethodSpec>
1011
1011
  struct ReactMethodVerifier {
1012
1012
  static constexpr bool Verify() noexcept {
1013
1013
  ReactMethodVerifier verifier{};
1014
- ReactMemberInfoIterator<TModule>{}.GetMemberInfo<I>(verifier);
1014
+ ReactMemberInfoIterator<TModule>{}.template GetMemberInfo<I>(verifier);
1015
1015
  return verifier.m_result;
1016
1016
  }
1017
1017
 
@@ -1029,7 +1029,7 @@ template <class TModule, int I, class TMethodSpec>
1029
1029
  struct ReactSyncMethodVerifier {
1030
1030
  static constexpr bool Verify() noexcept {
1031
1031
  ReactSyncMethodVerifier verifier{};
1032
- ReactMemberInfoIterator<TModule>{}.GetMemberInfo<I>(verifier);
1032
+ ReactMemberInfoIterator<TModule>{}.template GetMemberInfo<I>(verifier);
1033
1033
  return verifier.m_result;
1034
1034
  }
1035
1035
 
@@ -1,6 +1,7 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
3
 
4
+ #include <utility>
4
5
  #include "dispatchQueue/dispatchQueue.h"
5
6
  #include "queueService.h"
6
7
 
@@ -29,6 +30,13 @@ struct ThreadPoolSchedulerWin : Mso::UnknownObject<IDispatchQueueScheduler> {
29
30
  void Shutdown() noexcept override;
30
31
  void AwaitTermination() noexcept override;
31
32
 
33
+ public: // Used by test APIs
34
+ static void EnableThreadPoolWorkTracking(bool enable) noexcept;
35
+ static void WaitForThreadPoolWorkCompletion() noexcept;
36
+
37
+ private: // Used by test APIs
38
+ static void TrackThreadPoolWork(const std::shared_ptr<TP_WORK> &work) noexcept;
39
+
32
40
  private:
33
41
  struct ThreadAccessGuard {
34
42
  ThreadAccessGuard(ThreadPoolSchedulerWin *scheduler) noexcept;
@@ -42,12 +50,29 @@ struct ThreadPoolSchedulerWin : Mso::UnknownObject<IDispatchQueueScheduler> {
42
50
  };
43
51
 
44
52
  private:
45
- std::unique_ptr<TP_WORK, ThreadPoolWorkDeleter> m_threadPoolWork;
53
+ std::shared_ptr<TP_WORK> m_threadPoolWork;
46
54
  Mso::WeakPtr<IDispatchQueueService> m_queue;
47
55
  const uint32_t m_maxThreads{1};
48
56
  std::atomic<uint32_t> m_usedThreads{0};
49
57
 
50
58
  constexpr static uint32_t MaxConcurrentThreads{64};
59
+
60
+ private:
61
+ static std::mutex s_threadPoolWorkMutex;
62
+ static bool s_enableThreadPoolWorkTracking;
63
+ static std::vector<std::shared_ptr<TP_WORK>> s_trackedThreadPoolWork;
64
+ };
65
+
66
+ // Track the ThreadPoolSchedulerWin instance used by current thread.
67
+ // We use it to avoid a deadlock on queue shutdown.
68
+ struct ThreadPoolSchedulerWinContext {
69
+ ThreadPoolSchedulerWinContext(ThreadPoolSchedulerWin *scheduler) noexcept;
70
+ ~ThreadPoolSchedulerWinContext() noexcept;
71
+ static ThreadPoolSchedulerWin *CurrentScheduler() noexcept;
72
+
73
+ private:
74
+ static thread_local ThreadPoolSchedulerWin *tls_scheduler;
75
+ ThreadPoolSchedulerWin *m_prevScheduler{nullptr};
51
76
  };
52
77
 
53
78
  //=============================================================================
@@ -64,9 +89,15 @@ void ThreadPoolWorkDeleter::operator()(TP_WORK *tpWork) noexcept {
64
89
  // ThreadPoolSchedulerWin implementation
65
90
  //=============================================================================
66
91
 
92
+ std::mutex ThreadPoolSchedulerWin::s_threadPoolWorkMutex;
93
+ bool ThreadPoolSchedulerWin::s_enableThreadPoolWorkTracking{false};
94
+ std::vector<std::shared_ptr<TP_WORK>> ThreadPoolSchedulerWin::s_trackedThreadPoolWork;
95
+
67
96
  ThreadPoolSchedulerWin::ThreadPoolSchedulerWin(uint32_t maxThreads) noexcept
68
- : m_threadPoolWork{::CreateThreadpoolWork(WorkCallback, this, nullptr)},
69
- m_maxThreads{maxThreads == 0 ? MaxConcurrentThreads : maxThreads} {}
97
+ : m_threadPoolWork{::CreateThreadpoolWork(WorkCallback, this, nullptr), ThreadPoolWorkDeleter{}},
98
+ m_maxThreads{maxThreads == 0 ? MaxConcurrentThreads : maxThreads} {
99
+ TrackThreadPoolWork(m_threadPoolWork);
100
+ }
70
101
 
71
102
  ThreadPoolSchedulerWin::~ThreadPoolSchedulerWin() noexcept {
72
103
  AwaitTermination();
@@ -78,6 +109,7 @@ ThreadPoolSchedulerWin::~ThreadPoolSchedulerWin() noexcept {
78
109
  _Inout_ PTP_WORK /*work*/) {
79
110
  // The ThreadPoolSchedulerWin is alive here because m_threadPoolWork must be completed before it is destroyed.
80
111
  ThreadPoolSchedulerWin *self = static_cast<ThreadPoolSchedulerWin *>(context);
112
+ ThreadPoolSchedulerWinContext schedulerContext(self);
81
113
 
82
114
  if (auto queue = self->m_queue.GetStrongPtr()) {
83
115
  auto endTime = std::chrono::steady_clock::now() + 100ms;
@@ -129,7 +161,38 @@ void ThreadPoolSchedulerWin::Shutdown() noexcept {
129
161
  }
130
162
 
131
163
  void ThreadPoolSchedulerWin::AwaitTermination() noexcept {
132
- ::WaitForThreadpoolWorkCallbacks(m_threadPoolWork.get(), false);
164
+ // Avoid deadlock when the dispatch queue and ThreadPoolSchedulerWin are released from inside of a task.
165
+ if (ThreadPoolSchedulerWinContext::CurrentScheduler() != this) {
166
+ ::WaitForThreadpoolWorkCallbacks(m_threadPoolWork.get(), false);
167
+ }
168
+ }
169
+
170
+ void ThreadPoolSchedulerWin::EnableThreadPoolWorkTracking(bool enable) noexcept {
171
+ std::vector<std::shared_ptr<TP_WORK>> tpWorkToStopTracking;
172
+ {
173
+ std::scoped_lock lock{s_threadPoolWorkMutex};
174
+ s_enableThreadPoolWorkTracking = enable;
175
+ // Reset all previously tracked work
176
+ tpWorkToStopTracking = std::move(s_trackedThreadPoolWork);
177
+ }
178
+ }
179
+
180
+ void ThreadPoolSchedulerWin::WaitForThreadPoolWorkCompletion() noexcept {
181
+ std::vector<std::shared_ptr<TP_WORK>> tpWorkToTrack;
182
+ {
183
+ std::scoped_lock lock{s_threadPoolWorkMutex};
184
+ tpWorkToTrack = std::move(s_trackedThreadPoolWork);
185
+ }
186
+ for (std::shared_ptr<TP_WORK> &tpWork : tpWorkToTrack) {
187
+ ::WaitForThreadpoolWorkCallbacks(tpWork.get(), false);
188
+ }
189
+ }
190
+
191
+ void ThreadPoolSchedulerWin::TrackThreadPoolWork(const std::shared_ptr<TP_WORK> &tpWork) noexcept {
192
+ std::scoped_lock lock{s_threadPoolWorkMutex};
193
+ if (s_enableThreadPoolWorkTracking) {
194
+ s_trackedThreadPoolWork.push_back(tpWork);
195
+ }
133
196
  }
134
197
 
135
198
  //=============================================================================
@@ -151,6 +214,23 @@ ThreadPoolSchedulerWin::ThreadAccessGuard::~ThreadAccessGuard() noexcept {
151
214
  return tls_scheduler == scheduler;
152
215
  }
153
216
 
217
+ //=============================================================================
218
+ // ThreadPoolSchedulerWinContext implementation
219
+ //=============================================================================
220
+
221
+ thread_local ThreadPoolSchedulerWin *ThreadPoolSchedulerWinContext::tls_scheduler{nullptr};
222
+
223
+ ThreadPoolSchedulerWinContext::ThreadPoolSchedulerWinContext(ThreadPoolSchedulerWin *scheduler) noexcept
224
+ : m_prevScheduler(std::exchange(tls_scheduler, scheduler)) {}
225
+
226
+ ThreadPoolSchedulerWinContext::~ThreadPoolSchedulerWinContext() noexcept {
227
+ std::exchange(tls_scheduler, m_prevScheduler);
228
+ }
229
+
230
+ ThreadPoolSchedulerWin *ThreadPoolSchedulerWinContext::CurrentScheduler() noexcept {
231
+ return tls_scheduler;
232
+ }
233
+
154
234
  //=============================================================================
155
235
  // DispatchQueueStatic::MakeThreadPoolScheduler implementation
156
236
  //=============================================================================
@@ -160,4 +240,16 @@ ThreadPoolSchedulerWin::ThreadAccessGuard::~ThreadAccessGuard() noexcept {
160
240
  return Mso::Make<ThreadPoolSchedulerWin, IDispatchQueueScheduler>(maxThreads);
161
241
  }
162
242
 
243
+ //=============================================================================
244
+ // Test specific functions
245
+ //=============================================================================
246
+
247
+ void Test_ThreadPoolSchedulerWin_EnableThreadPoolWorkTracking(bool enable) noexcept {
248
+ ThreadPoolSchedulerWin::EnableThreadPoolWorkTracking(enable);
249
+ }
250
+
251
+ void Test_ThreadPoolSchedulerWin_WaitForThreadPoolWorkCompletion() noexcept {
252
+ ThreadPoolSchedulerWin::WaitForThreadPoolWorkCompletion();
253
+ }
254
+
163
255
  } // namespace Mso
@@ -16,7 +16,7 @@
16
16
  <EnableDevServerHBCBundles Condition="'$(EnableDevServerHBCBundles)' == ''">false</EnableDevServerHBCBundles>
17
17
 
18
18
  <UseV8 Condition="'$(UseV8)' == ''">false</UseV8>
19
- <V8Version Condition="'$(V8Version)' == ''">0.65.5</V8Version>
19
+ <V8Version Condition="'$(V8Version)' == ''">0.65.11</V8Version>
20
20
  <V8PackageName>ReactNative.V8Jsi.Windows</V8PackageName>
21
21
  <V8PackageName Condition="'$(V8AppPlatform)' != 'win32'">$(V8PackageName).UWP</V8PackageName>
22
22
  <V8Package>$(SolutionDir)packages\$(V8PackageName).$(V8Version)</V8Package>
@@ -50,13 +50,13 @@
50
50
  <file src="$nugetroot$\inc\Shared\IReactRootView.h" target="inc"/>
51
51
  <file src="$nugetroot$\inc\Shared\IRedBoxHandler.h" target="inc"/>
52
52
  <file src="$nugetroot$\inc\Shared\IUIManager.h" target="inc"/>
53
- <file src="$nugetroot$\inc\Shared\IWebSocketResource.h" target="inc"/>
54
53
  <file src="$nugetroot$\inc\Shared\JSBigAbiString.h" target="inc"/>
55
54
  <file src="$nugetroot$\inc\Shared\LayoutAnimation.h" target="inc"/>
56
55
  <file src="$nugetroot$\inc\Shared\Logging.h" target="inc"/>
57
56
  <file src="$nugetroot$\inc\Shared\MemoryMappedBuffer.h" target="inc"/>
58
57
  <file src="$nugetroot$\inc\Shared\Modules\I18nModule.h" target="inc"/>
59
58
  <file src="$nugetroot$\inc\Shared\NativeModuleProvider.h" target="inc"/>
59
+ <file src="$nugetroot$\inc\Shared\Networking\IWebSocketResource.h" target="inc"/>
60
60
  <file src="$nugetroot$\inc\Shared\RuntimeOptions.h" target="inc"/>
61
61
  <file src="$nugetroot$\inc\ReactWin32\ShadowNode.h" target="inc"/>
62
62
  <file src="$nugetroot$\inc\Shared\Tracing.h" target="inc"/>
@@ -6,7 +6,7 @@
6
6
  #include "BaseScriptStoreImpl.h"
7
7
  #include "MemoryMappedBuffer.h"
8
8
 
9
- #include <RuntimeOptions.h>
9
+ #include <CppRuntimeOptions.h>
10
10
 
11
11
  // C++/WinRT
12
12
  #include <winrt/base.h>
@@ -0,0 +1,50 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #pragma once
5
+
6
+ #include <string>
7
+
8
+ namespace Microsoft::React {
9
+
10
+ /// <summary>
11
+ /// Sets a global boolean value identified by an arbitrary string.
12
+ /// </summary>
13
+ /// <param name="name">Global key</param>
14
+ void __cdecl SetRuntimeOptionBool(std::string &&name, bool value) noexcept;
15
+
16
+ /// <summary>
17
+ /// Sets a global signed integer value identified by an arbitrary string.
18
+ /// </summary>
19
+ /// <param name="name">Global boolean key</param>
20
+ void __cdecl SetRuntimeOptionInt(std::string &&name, std::int32_t value) noexcept;
21
+
22
+ /// <summary>
23
+ /// Sets a global string value identified by an arbitrary string.
24
+ /// </summary>
25
+ /// <param name="name">Global string key</param>
26
+ /// <param name="value">String value to store</param>
27
+ void __cdecl SetRuntimeOptionString(std::string &&name, std::string &&value) noexcept;
28
+
29
+ /// <summary>
30
+ /// Retrieves a global boolean value for the given key.
31
+ /// </summary>
32
+ /// <param name="name">Global boolean key</param>
33
+ /// <returns>Value stored for the given key, or false if the entry doesn't exist (default)</returns>
34
+ const bool __cdecl GetRuntimeOptionBool(const std::string &name) noexcept;
35
+
36
+ /// <summary>
37
+ /// Retrieves a global boolean value for the given key.
38
+ /// </summary>
39
+ /// <param name="name">Global key</param>
40
+ /// <returns>Value stored for the given key, or 0 if the entry doesn't exist (default)</returns>
41
+ const std::int32_t __cdecl GetRuntimeOptionInt(const std::string &name) noexcept;
42
+
43
+ /// <summary>
44
+ /// Retrieves a global string value for the given key.
45
+ /// </summary>
46
+ /// <param name="name">Global key</param>
47
+ /// <returns>Value stored for the given key, or an empty string if the entry doesn't exist (default)</returns>
48
+ const std::string __cdecl GetRuntimeOptionString(const std::string &name) noexcept;
49
+
50
+ } // namespace Microsoft::React
@@ -3,9 +3,14 @@
3
3
 
4
4
  #pragma once
5
5
 
6
+ // React Native
6
7
  #include <cxxreact/CxxModule.h>
7
8
  #include <smartPtr/cntPtr.h>
8
9
 
10
+ // Windows API
11
+ #include <winrt/Windows.Foundation.h>
12
+
13
+ // Standard Library
9
14
  #include <memory>
10
15
 
11
16
  // Forward declarations. Desktop projects can not access <React.h>
@@ -32,6 +37,20 @@ extern std::unique_ptr<facebook::xplat::module::CxxModule> CreateAsyncStorageMod
32
37
 
33
38
  namespace Microsoft::React {
34
39
 
35
- extern std::unique_ptr<facebook::xplat::module::CxxModule> CreateWebSocketModule() noexcept;
40
+ extern const char *GetHttpModuleName() noexcept;
41
+ extern std::unique_ptr<facebook::xplat::module::CxxModule> CreateHttpModule(
42
+ winrt::Windows::Foundation::IInspectable const &inspectableProperties) noexcept;
43
+
44
+ extern const char *GetWebSocketModuleName() noexcept;
45
+ extern std::unique_ptr<facebook::xplat::module::CxxModule> CreateWebSocketModule(
46
+ winrt::Windows::Foundation::IInspectable const &inspectableProperties) noexcept;
47
+
48
+ extern const char *GetBlobModuleName() noexcept;
49
+ extern std::unique_ptr<facebook::xplat::module::CxxModule> CreateBlobModule(
50
+ winrt::Windows::Foundation::IInspectable const &inspectableProperties) noexcept;
51
+
52
+ extern const char *GetFileReaderModuleName() noexcept;
53
+ extern std::unique_ptr<facebook::xplat::module::CxxModule> CreateFileReaderModule(
54
+ winrt::Windows::Foundation::IInspectable const &inspectableProperties) noexcept;
36
55
 
37
56
  } // namespace Microsoft::React
@@ -196,7 +196,8 @@ InspectorPackagerConnection::InspectorPackagerConnection(
196
196
  winrt::fire_and_forget InspectorPackagerConnection::disconnectAsync() {
197
197
  co_await winrt::resume_background();
198
198
  std::string reason("Explicit close");
199
- m_packagerWebSocketConnection->Close(Microsoft::React::WinRTWebSocketResource::CloseCode::GoingAway, reason);
199
+ m_packagerWebSocketConnection->Close(
200
+ Microsoft::React::Networking::WinRTWebSocketResource::CloseCode::GoingAway, reason);
200
201
  co_return;
201
202
  }
202
203
 
@@ -204,9 +205,10 @@ winrt::fire_and_forget InspectorPackagerConnection::connectAsync() {
204
205
  co_await winrt::resume_background();
205
206
 
206
207
  std::vector<winrt::Windows::Security::Cryptography::Certificates::ChainValidationResult> certExceptions;
207
- m_packagerWebSocketConnection = std::make_shared<Microsoft::React::WinRTWebSocketResource>(std::move(certExceptions));
208
+ m_packagerWebSocketConnection =
209
+ std::make_shared<Microsoft::React::Networking::WinRTWebSocketResource>(std::move(certExceptions));
208
210
 
209
- m_packagerWebSocketConnection->SetOnError([](const Microsoft::React::IWebSocketResource::Error &err) {
211
+ m_packagerWebSocketConnection->SetOnError([](const Microsoft::React::Networking::IWebSocketResource::Error &err) {
210
212
  facebook::react::tracing::error(err.Message.c_str());
211
213
  });
212
214
 
@@ -267,8 +269,8 @@ winrt::fire_and_forget InspectorPackagerConnection::connectAsync() {
267
269
  }
268
270
  });
269
271
 
270
- Microsoft::React::IWebSocketResource::Protocols protocols;
271
- Microsoft::React::IWebSocketResource::Options options;
272
+ Microsoft::React::Networking::IWebSocketResource::Protocols protocols;
273
+ Microsoft::React::Networking::IWebSocketResource::Options options;
272
274
  m_packagerWebSocketConnection->Connect(std::string{m_url}, protocols, options);
273
275
 
274
276
  co_return;
@@ -4,7 +4,7 @@
4
4
  #pragma once
5
5
 
6
6
  #include <InspectorProxy.h>
7
- #include <WinRTWebSocketResource.h>
7
+ #include <Networking/WinRTWebSocketResource.h>
8
8
  #include <jsinspector/InspectorInterfaces.h>
9
9
 
10
10
  namespace Microsoft::ReactNative {
@@ -42,7 +42,7 @@ class InspectorPackagerConnection final : public std::enable_shared_from_this<In
42
42
  void sendMessageToVM(int64_t pageId, std::string &&message);
43
43
 
44
44
  std::unordered_map<int64_t, std::unique_ptr<facebook::react::ILocalConnection>> m_localConnections;
45
- std::shared_ptr<Microsoft::React::WinRTWebSocketResource> m_packagerWebSocketConnection;
45
+ std::shared_ptr<Microsoft::React::Networking::WinRTWebSocketResource> m_packagerWebSocketConnection;
46
46
  std::shared_ptr<IBundleStatusProvider> m_bundleStatusProvider;
47
47
  std::string m_url;
48
48
  };
@@ -3,7 +3,6 @@
3
3
 
4
4
  #include "ChakraApi.h"
5
5
 
6
- #include <RuntimeOptions.h>
7
6
  #include <sstream>
8
7
  #include <utility>
9
8
  #include "Unicode.h"
@@ -4,7 +4,6 @@
4
4
  #include "ChakraRuntime.h"
5
5
  #include "ChakraRuntimeFactory.h"
6
6
 
7
- #include <RuntimeOptions.h>
8
7
  #include "Unicode.h"
9
8
  #include "Utilities.h"
10
9
 
@@ -22,7 +22,7 @@ class NapiJsiV8RuntimeHolder : public Microsoft::JSI::RuntimeHolderLazyInit {
22
22
  std::unique_ptr<facebook::jsi::PreparedScriptStore> &&preparedScriptStore) noexcept;
23
23
 
24
24
  private:
25
- static void ScheduleTaskCallback(
25
+ static void __cdecl ScheduleTaskCallback(
26
26
  napi_env env,
27
27
  napi_ext_task_callback taskCb,
28
28
  void *taskData,