react-native-windows 0.69.6 → 0.69.8

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 (36) hide show
  1. package/Microsoft.ReactNative/Base/CoreNativeModules.cpp +25 -0
  2. package/Microsoft.ReactNative/JSDispatcherWriter.cpp +60 -22
  3. package/Microsoft.ReactNative/JSDispatcherWriter.h +5 -3
  4. package/Microsoft.ReactNative/Pch/pch.h +0 -1
  5. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +3 -1
  6. package/Microsoft.ReactNative/TurboModulesProvider.cpp +146 -84
  7. package/Microsoft.ReactNative/TurboModulesProvider.h +5 -0
  8. package/Microsoft.ReactNative/Views/ViewManagerBase.cpp +4 -2
  9. package/Microsoft.ReactNative.Cxx/JSI/LongLivedJsiValue.h +84 -0
  10. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems +1 -0
  11. package/Microsoft.ReactNative.Cxx/Microsoft.ReactNative.Cxx.vcxitems.filters +3 -0
  12. package/Microsoft.ReactNative.Managed/packages.lock.json +27 -2
  13. package/Mso/src/dispatchQueue/uiScheduler_winrt.cpp +6 -1
  14. package/PropertySheets/Generated/PackageVersion.g.props +2 -2
  15. package/Shared/InstanceManager.cpp +29 -0
  16. package/Shared/InstanceManager.h +14 -0
  17. package/Shared/Modules/BlobModule.cpp +4 -4
  18. package/Shared/Modules/BlobModule.h +1 -1
  19. package/Shared/Modules/FileReaderModule.cpp +2 -2
  20. package/Shared/Modules/HttpModule.cpp +4 -2
  21. package/Shared/Modules/IBlobPersistor.h +1 -1
  22. package/Shared/Networking/IHttpResource.h +2 -1
  23. package/Shared/Networking/IRedirectEventSource.h +18 -0
  24. package/Shared/Networking/IWinRTHttpRequestFactory.h +22 -0
  25. package/Shared/Networking/OriginPolicyHttpFilter.cpp +47 -15
  26. package/Shared/Networking/OriginPolicyHttpFilter.h +16 -3
  27. package/Shared/Networking/RedirectHttpFilter.cpp +283 -0
  28. package/Shared/Networking/RedirectHttpFilter.h +97 -0
  29. package/Shared/Networking/WinRTHttpResource.cpp +225 -140
  30. package/Shared/Networking/WinRTHttpResource.h +17 -4
  31. package/Shared/OInstance.cpp +23 -3
  32. package/Shared/OInstance.h +4 -13
  33. package/Shared/Shared.vcxitems +4 -0
  34. package/Shared/Shared.vcxitems.filters +12 -0
  35. package/Shared/Threading/BatchingQueueThread.cpp +18 -12
  36. package/package.json +5 -5
@@ -106,11 +106,13 @@ class OJSIExecutorFactory : public JSExecutorFactory {
106
106
  auto turboModuleManager = std::make_shared<TurboModuleManager>(turboModuleRegistry_, jsCallInvoker_);
107
107
 
108
108
  // TODO: The binding here should also add the proxys that convert cxxmodules into turbomodules
109
+ // [vmoroz] Note, that we must not use the RN TurboCxxModule.h code because it uses global LongLivedObjectCollection
110
+ // instance that prevents us from using multiple RN instance in the same process.
109
111
  auto binding = [turboModuleManager](const std::string &name) -> std::shared_ptr<TurboModule> {
110
112
  return turboModuleManager->getModule(name);
111
113
  };
112
114
 
113
- TurboModuleBinding::install(*runtimeHolder_->getRuntime(), std::function(binding));
115
+ TurboModuleBinding::install(*runtimeHolder_->getRuntime(), std::function(binding), longLivedObjectCollection_);
114
116
 
115
117
  // init TurboModule
116
118
  for (const auto &moduleName : turboModuleManager->getEagerInitModuleNames()) {
@@ -132,17 +134,20 @@ class OJSIExecutorFactory : public JSExecutorFactory {
132
134
  std::shared_ptr<Microsoft::JSI::RuntimeHolderLazyInit> runtimeHolder,
133
135
  NativeLoggingHook loggingHook,
134
136
  std::shared_ptr<TurboModuleRegistry> turboModuleRegistry,
137
+ std::shared_ptr<LongLivedObjectCollection> longLivedObjectCollection,
135
138
  bool isProfilingEnabled,
136
139
  std::shared_ptr<CallInvoker> jsCallInvoker) noexcept
137
140
  : runtimeHolder_{std::move(runtimeHolder)},
138
141
  loggingHook_{std::move(loggingHook)},
139
142
  turboModuleRegistry_{std::move(turboModuleRegistry)},
143
+ longLivedObjectCollection_{std::move(longLivedObjectCollection)},
140
144
  jsCallInvoker_{std::move(jsCallInvoker)},
141
145
  isProfilingEnabled_{isProfilingEnabled} {}
142
146
 
143
147
  private:
144
148
  std::shared_ptr<Microsoft::JSI::RuntimeHolderLazyInit> runtimeHolder_;
145
149
  std::shared_ptr<TurboModuleRegistry> turboModuleRegistry_;
150
+ std::shared_ptr<LongLivedObjectCollection> longLivedObjectCollection_;
146
151
  std::shared_ptr<CallInvoker> jsCallInvoker_;
147
152
  NativeLoggingHook loggingHook_;
148
153
  bool isProfilingEnabled_;
@@ -159,6 +164,7 @@ void logMarker(const facebook::react::ReactMarker::ReactMarkerId /*id*/, const c
159
164
  std::tuple<std::string, facebook::xplat::module::CxxModule::Provider, std::shared_ptr<MessageQueueThread>>>
160
165
  &&cxxModules,
161
166
  std::shared_ptr<TurboModuleRegistry> turboModuleRegistry,
167
+ std::shared_ptr<facebook::react::LongLivedObjectCollection> longLivedObjectCollection,
162
168
  std::unique_ptr<InstanceCallback> &&callback,
163
169
  std::shared_ptr<MessageQueueThread> jsQueue,
164
170
  std::shared_ptr<MessageQueueThread> nativeQueue,
@@ -169,6 +175,7 @@ void logMarker(const facebook::react::ReactMarker::ReactMarkerId /*id*/, const c
169
175
  std::move(jsBundleBasePath),
170
176
  std::move(cxxModules),
171
177
  std::move(turboModuleRegistry),
178
+ std::move(longLivedObjectCollection),
172
179
  std::move(callback),
173
180
  std::move(jsQueue),
174
181
  std::move(nativeQueue),
@@ -198,6 +205,7 @@ void logMarker(const facebook::react::ReactMarker::ReactMarkerId /*id*/, const c
198
205
  std::move(jsBundleBasePath),
199
206
  std::move(cxxModules),
200
207
  std::move(turboModuleRegistry),
208
+ nullptr,
201
209
  std::move(callback),
202
210
  std::move(jsQueue),
203
211
  std::move(nativeQueue),
@@ -235,12 +243,14 @@ InstanceImpl::InstanceImpl(
235
243
  std::tuple<std::string, facebook::xplat::module::CxxModule::Provider, std::shared_ptr<MessageQueueThread>>>
236
244
  &&cxxModules,
237
245
  std::shared_ptr<TurboModuleRegistry> turboModuleRegistry,
246
+ std::shared_ptr<facebook::react::LongLivedObjectCollection> longLivedObjectCollection,
238
247
  std::unique_ptr<InstanceCallback> &&callback,
239
248
  std::shared_ptr<MessageQueueThread> jsQueue,
240
249
  std::shared_ptr<MessageQueueThread> nativeQueue,
241
250
  std::shared_ptr<DevSettings> devSettings,
242
251
  std::shared_ptr<IDevSupportManager> devManager)
243
252
  : m_turboModuleRegistry(std::move(turboModuleRegistry)),
253
+ m_longLivedObjectCollection(std::move(longLivedObjectCollection)),
244
254
  m_jsThread(std::move(jsQueue)),
245
255
  m_nativeQueue(nativeQueue),
246
256
  m_jsBundleBasePath(std::move(jsBundleBasePath)),
@@ -301,6 +311,7 @@ InstanceImpl::InstanceImpl(
301
311
  m_devSettings->jsiRuntimeHolder,
302
312
  m_devSettings->loggingCallback,
303
313
  m_turboModuleRegistry,
314
+ m_longLivedObjectCollection,
304
315
  !m_devSettings->useFastRefresh,
305
316
  m_innerInstance->getJSCallInvoker());
306
317
  } else {
@@ -365,6 +376,7 @@ InstanceImpl::InstanceImpl(
365
376
  m_devSettings->jsiRuntimeHolder,
366
377
  m_devSettings->loggingCallback,
367
378
  m_turboModuleRegistry,
379
+ m_longLivedObjectCollection,
368
380
  !m_devSettings->useFastRefresh,
369
381
  m_innerInstance->getJSCallInvoker());
370
382
  }
@@ -545,6 +557,7 @@ std::vector<std::unique_ptr<NativeModule>> InstanceImpl::GetDefaultNativeModules
545
557
  std::vector<std::unique_ptr<NativeModule>> modules;
546
558
  auto transitionalProps{ReactPropertyBagHelper::CreatePropertyBag()};
547
559
 
560
+ #if (defined(_MSC_VER) && !defined(WINRT))
548
561
  modules.push_back(std::make_unique<CxxNativeModule>(
549
562
  m_innerInstance,
550
563
  Microsoft::React::GetHttpModuleName(),
@@ -552,6 +565,7 @@ std::vector<std::unique_ptr<NativeModule>> InstanceImpl::GetDefaultNativeModules
552
565
  return Microsoft::React::CreateHttpModule(transitionalProps);
553
566
  },
554
567
  nativeQueue));
568
+ #endif
555
569
 
556
570
  modules.push_back(std::make_unique<CxxNativeModule>(
557
571
  m_innerInstance,
@@ -619,8 +633,13 @@ std::vector<std::unique_ptr<NativeModule>> InstanceImpl::GetDefaultNativeModules
619
633
  []() { return std::make_unique<StatusBarManagerModule>(); },
620
634
  nativeQueue));
621
635
 
622
- // #10036 - Blob module not supported in UWP. Need to define property bag lifetime and onwership.
623
- if (Microsoft::React::GetRuntimeOptionBool("Blob.EnableModule")) {
636
+ // These modules are instantiated separately in MSRN (Universal Windows).
637
+ // When there are module name colisions, the last one registered is used.
638
+ // If this code is enabled, we will have unused module instances.
639
+ // Also, MSRN has a different property bag mechanism incompatible with this method's transitionalProps variable.
640
+ #if (defined(_MSC_VER) && !defined(WINRT))
641
+ if (Microsoft::React::GetRuntimeOptionBool("Blob.EnableModule") &&
642
+ !Microsoft::React::GetRuntimeOptionBool("Http.UseMonolithicModule")) {
624
643
  modules.push_back(std::make_unique<CxxNativeModule>(
625
644
  m_innerInstance,
626
645
  Microsoft::React::GetBlobModuleName(),
@@ -633,6 +652,7 @@ std::vector<std::unique_ptr<NativeModule>> InstanceImpl::GetDefaultNativeModules
633
652
  [transitionalProps]() { return Microsoft::React::CreateFileReaderModule(transitionalProps); },
634
653
  nativeQueue));
635
654
  }
655
+ #endif
636
656
 
637
657
  return modules;
638
658
  }
@@ -10,6 +10,7 @@
10
10
  #include "InstanceManager.h"
11
11
 
12
12
  // React Native
13
+ #include <ReactCommon/LongLivedObject.h>
13
14
  #include <cxxreact/Instance.h>
14
15
 
15
16
  // Standard Libriary
@@ -32,6 +33,7 @@ class InstanceImpl final : public InstanceWrapper, private ::std::enable_shared_
32
33
  std::tuple<std::string, facebook::xplat::module::CxxModule::Provider, std::shared_ptr<MessageQueueThread>>>
33
34
  &&cxxModules,
34
35
  std::shared_ptr<TurboModuleRegistry> turboModuleRegistry,
36
+ std::shared_ptr<facebook::react::LongLivedObjectCollection> longLivedObjectCollection,
35
37
  std::unique_ptr<InstanceCallback> &&callback,
36
38
  std::shared_ptr<MessageQueueThread> jsQueue,
37
39
  std::shared_ptr<MessageQueueThread> nativeQueue,
@@ -72,19 +74,7 @@ class InstanceImpl final : public InstanceWrapper, private ::std::enable_shared_
72
74
  std::tuple<std::string, facebook::xplat::module::CxxModule::Provider, std::shared_ptr<MessageQueueThread>>>
73
75
  &&cxxModules,
74
76
  std::shared_ptr<TurboModuleRegistry> turboModuleRegistry,
75
- std::unique_ptr<InstanceCallback> &&callback,
76
- std::shared_ptr<MessageQueueThread> jsQueue,
77
- std::shared_ptr<MessageQueueThread> nativeQueue,
78
- std::shared_ptr<DevSettings> devSettings,
79
- std::shared_ptr<IDevSupportManager> devManager);
80
-
81
- InstanceImpl(
82
- std::shared_ptr<Instance> &&instance,
83
- std::string &&jsBundleBasePath,
84
- std::string &&jsBundleRelativePath,
85
- std::vector<
86
- std::tuple<std::string, facebook::xplat::module::CxxModule::Provider, std::shared_ptr<MessageQueueThread>>>
87
- &&cxxModules,
77
+ std::shared_ptr<facebook::react::LongLivedObjectCollection> longLivedObjectCollection,
88
78
  std::unique_ptr<InstanceCallback> &&callback,
89
79
  std::shared_ptr<MessageQueueThread> jsQueue,
90
80
  std::shared_ptr<MessageQueueThread> nativeQueue,
@@ -102,6 +92,7 @@ class InstanceImpl final : public InstanceWrapper, private ::std::enable_shared_
102
92
  std::string m_jsBundleBasePath;
103
93
  std::shared_ptr<facebook::react::ModuleRegistry> m_moduleRegistry;
104
94
  std::shared_ptr<TurboModuleRegistry> m_turboModuleRegistry;
95
+ std::shared_ptr<facebook::react::LongLivedObjectCollection> m_longLivedObjectCollection;
105
96
  std::shared_ptr<MessageQueueThread> m_jsThread;
106
97
  std::shared_ptr<MessageQueueThread> m_nativeQueue;
107
98
 
@@ -56,6 +56,7 @@
56
56
  <ClCompile Include="$(MSBuildThisFileDirectory)Modules\StatusBarManagerModule.cpp" />
57
57
  <ClCompile Include="$(MSBuildThisFileDirectory)Modules\WebSocketModule.cpp" />
58
58
  <ClCompile Include="$(MSBuildThisFileDirectory)Networking\OriginPolicyHttpFilter.cpp" />
59
+ <ClCompile Include="$(MSBuildThisFileDirectory)Networking\RedirectHttpFilter.cpp" />
59
60
  <ClCompile Include="$(MSBuildThisFileDirectory)Networking\WinRTHttpResource.cpp" />
60
61
  <ClCompile Include="$(MSBuildThisFileDirectory)Networking\WinRTWebSocketResource.cpp" />
61
62
  <ClCompile Include="$(MSBuildThisFileDirectory)OInstance.cpp" />
@@ -103,9 +104,12 @@
103
104
  <ClInclude Include="$(MSBuildThisFileDirectory)Modules\HttpModule.h" />
104
105
  <ClInclude Include="$(MSBuildThisFileDirectory)Modules\NetworkingModule.h" />
105
106
  <ClInclude Include="$(MSBuildThisFileDirectory)Networking\IHttpResource.h" />
107
+ <ClInclude Include="$(MSBuildThisFileDirectory)Networking\IRedirectEventSource.h" />
106
108
  <ClInclude Include="$(MSBuildThisFileDirectory)Networking\IWebSocketResource.h" />
109
+ <ClInclude Include="$(MSBuildThisFileDirectory)Networking\IWinRTHttpRequestFactory.h" />
107
110
  <ClInclude Include="$(MSBuildThisFileDirectory)Networking\OriginPolicy.h" />
108
111
  <ClInclude Include="$(MSBuildThisFileDirectory)Networking\OriginPolicyHttpFilter.h" />
112
+ <ClInclude Include="$(MSBuildThisFileDirectory)Networking\RedirectHttpFilter.h" />
109
113
  <ClInclude Include="$(MSBuildThisFileDirectory)Networking\WinRTHttpResource.h" />
110
114
  <ClInclude Include="$(MSBuildThisFileDirectory)Networking\WinRTTypes.h" />
111
115
  <ClInclude Include="$(MSBuildThisFileDirectory)Networking\WinRTWebSocketResource.h" />
@@ -152,6 +152,9 @@
152
152
  <ClCompile Include="$(MSBuildThisFileDirectory)Modules\FileReaderModule.cpp">
153
153
  <Filter>Source Files\Modules</Filter>
154
154
  </ClCompile>
155
+ <ClCompile Include="$(MSBuildThisFileDirectory)Networking\RedirectHttpFilter.cpp">
156
+ <Filter>Source Files\Networking</Filter>
157
+ </ClCompile>
155
158
  </ItemGroup>
156
159
  <ItemGroup>
157
160
  <Filter Include="Source Files">
@@ -457,6 +460,15 @@
457
460
  <ClInclude Include="$(MSBuildThisFileDirectory)Modules\FileReaderModule.h">
458
461
  <Filter>Header Files\Modules</Filter>
459
462
  </ClInclude>
463
+ <ClInclude Include="$(MSBuildThisFileDirectory)Networking\RedirectHttpFilter.h">
464
+ <Filter>Header Files\Networking</Filter>
465
+ </ClInclude>
466
+ <ClInclude Include="$(MSBuildThisFileDirectory)Networking\IWinRTHttpRequestFactory.h">
467
+ <Filter>Header Files\Networking</Filter>
468
+ </ClInclude>
469
+ <ClInclude Include="$(MSBuildThisFileDirectory)Networking\IRedirectEventSource.h">
470
+ <Filter>Header Files\Networking</Filter>
471
+ </ClInclude>
460
472
  </ItemGroup>
461
473
  <ItemGroup>
462
474
  <None Include="$(MSBuildThisFileDirectory)tracing\rnw.wprp">
@@ -69,19 +69,25 @@ BatchingQueueThread::BatchingQueueThread(
69
69
  void BatchingQueueThread::decoratedNativeCallInvokerReady(
70
70
  std::weak_ptr<facebook::react::Instance> wkInstance) noexcept {
71
71
  std::scoped_lock lck(m_mutex);
72
- m_callInvoker->invokeAsync([wkInstance, this] {
73
- if (auto instance = wkInstance.lock()) {
74
- std::scoped_lock lckQuitting(m_mutexQuitting);
75
-
76
- // If we are shutting down, then then the mutex is being held in quitSynchronous
77
- // Which is waiting for this task to complete, so we cannot take the mutex if quitSynchronous
78
- // is running. -- and since we are shutting down anyway, we can just skip this work.
79
- if (!m_quitting) {
80
- std::scoped_lock lck(m_mutex);
81
- m_callInvoker = instance->getDecoratedNativeCallInvoker(m_callInvoker);
72
+ if (auto instance = wkInstance.lock()) {
73
+ // When items were queued in the undecoratedNativeCallInvoker it will not have called
74
+ // recordTurboModuleAsyncMethodCall. Calling invokeAsync on the decoratedNativeCallInvoker
75
+ // ensures that the queue is properly flushed, on the next batch complete
76
+ auto decoratedCallInvoker = instance->getDecoratedNativeCallInvoker(m_callInvoker);
77
+ decoratedCallInvoker->invokeAsync([decoratedCallInvoker, wkInstance, this] {
78
+ if (auto instance = wkInstance.lock()) {
79
+ std::scoped_lock lckQuitting(m_mutexQuitting);
80
+
81
+ // If we are shutting down, then then the mutex is being held in quitSynchronous
82
+ // Which is waiting for this task to complete, so we cannot take the mutex if quitSynchronous
83
+ // is running. -- and since we are shutting down anyway, we can just skip this work.
84
+ if (!m_quitting) {
85
+ std::scoped_lock lck(m_mutex);
86
+ m_callInvoker = decoratedCallInvoker;
87
+ }
82
88
  }
83
- }
84
- });
89
+ });
90
+ }
85
91
  }
86
92
 
87
93
  BatchingQueueThread::~BatchingQueueThread() noexcept {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-windows",
3
- "version": "0.69.6",
3
+ "version": "0.69.8",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,8 +26,8 @@
26
26
  "@react-native-community/cli": "^8.0.0",
27
27
  "@react-native-community/cli-platform-android": "^8.0.0",
28
28
  "@react-native-community/cli-platform-ios": "^8.0.0",
29
- "@react-native-windows/cli": "0.69.2",
30
- "@react-native-windows/virtualized-list": "0.69.0",
29
+ "@react-native-windows/cli": "0.69.3",
30
+ "@react-native-windows/virtualized-list": "0.69.1",
31
31
  "@react-native/assets": "1.0.0",
32
32
  "@react-native/normalize-color": "2.0.0",
33
33
  "@react-native/polyfills": "2.0.0",
@@ -61,7 +61,7 @@
61
61
  "ws": "^6.1.4"
62
62
  },
63
63
  "devDependencies": {
64
- "@react-native-windows/codegen": "0.69.0",
64
+ "@react-native-windows/codegen": "0.69.1",
65
65
  "@rnw-scripts/eslint-config": "1.1.12",
66
66
  "@rnw-scripts/jest-out-of-tree-snapshot-resolver": "^1.0.6",
67
67
  "@rnw-scripts/metro-dev-config": "0.0.0",
@@ -88,7 +88,7 @@
88
88
  "react-native": "^0.69.0"
89
89
  },
90
90
  "beachball": {
91
- "defaultNpmTag": "latest",
91
+ "defaultNpmTag": "v0.69-stable",
92
92
  "gitTags": true,
93
93
  "disallowedChangeTypes": [
94
94
  "major",