react-native-windows 0.65.3 → 0.65.7

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.
package/CHANGELOG.json CHANGED
@@ -2,7 +2,97 @@
2
2
  "name": "react-native-windows",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 27 Sep 2021 15:07:04 GMT",
5
+ "date": "Mon, 01 Nov 2021 19:07:04 GMT",
6
+ "tag": "react-native-windows_v0.65.7",
7
+ "version": "0.65.7",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "comment": "Fix race condition when building customer projects",
12
+ "author": "dannyvv@microsoft.com",
13
+ "commit": "b376766f3a64bcdaef810c8d065ddead2e361840",
14
+ "package": "react-native-windows"
15
+ },
16
+ {
17
+ "comment": "Fix Microsoft.ReactNative.dll version string",
18
+ "author": "asklar@microsoft.com",
19
+ "commit": "73ad2b8c3467aaab54fc49e316c219f3a9fc7892",
20
+ "package": "react-native-windows"
21
+ },
22
+ {
23
+ "comment": "Fix crash when using TextInput.blur()",
24
+ "author": "30809111+acoates-ms@users.noreply.github.com",
25
+ "commit": "b2cdb561fc91f81181a1e6d1edf9056dba6e0f01",
26
+ "package": "react-native-windows"
27
+ }
28
+ ]
29
+ }
30
+ },
31
+ {
32
+ "date": "Wed, 20 Oct 2021 19:14:28 GMT",
33
+ "tag": "react-native-windows_v0.65.6",
34
+ "version": "0.65.6",
35
+ "comments": {
36
+ "patch": [
37
+ {
38
+ "comment": "Fix Arm64 Desktop linker experts due to mangled name mismatches",
39
+ "author": "dannyvv@microsoft.com",
40
+ "commit": "2169bb4bc9a4d801b480be9d84638a20a6b4a718",
41
+ "package": "react-native-windows"
42
+ }
43
+ ]
44
+ }
45
+ },
46
+ {
47
+ "date": "Mon, 11 Oct 2021 15:06:57 GMT",
48
+ "tag": "react-native-windows_v0.65.5",
49
+ "version": "0.65.5",
50
+ "comments": {
51
+ "patch": [
52
+ {
53
+ "comment": "[0.65] Add ARM64 support to React.Windows.Desktop.Test.DLL",
54
+ "author": "julio.rocha@microsoft.com",
55
+ "commit": "61c436f7ba37dba9ae812dbd84a74d5c5944dfd1",
56
+ "package": "react-native-windows"
57
+ },
58
+ {
59
+ "comment": "Promote 0.65 to legacy",
60
+ "author": "ngerlem@microsoft.com",
61
+ "commit": "31e9fc28e3edddde4c7a86e40201aede6242e73c",
62
+ "package": "react-native-windows"
63
+ }
64
+ ]
65
+ }
66
+ },
67
+ {
68
+ "date": "Mon, 04 Oct 2021 15:07:05 GMT",
69
+ "tag": "react-native-windows_v0.65.4",
70
+ "version": "0.65.4",
71
+ "comments": {
72
+ "patch": [
73
+ {
74
+ "comment": "Allow injection of custom UI thread",
75
+ "author": "30809111+acoates-ms@users.noreply.github.com",
76
+ "commit": "c5a4ad149cf0e9fbfa1be60592581081ac822d5f",
77
+ "package": "react-native-windows"
78
+ },
79
+ {
80
+ "comment": "Upgrade ReactNative.V8Jsi.Windows to 0.65.5",
81
+ "author": "julio.rocha@microsoft.com",
82
+ "commit": "e7a0d5fc8cca1a886f6788c5bfdf870ce201c62c",
83
+ "package": "react-native-windows"
84
+ },
85
+ {
86
+ "comment": "ReactNativeHost ReloadInstance and UnloadInstance actions do not always fire completed events",
87
+ "author": "30809111+acoates-ms@users.noreply.github.com",
88
+ "commit": "bd4794c46b84e38850491a23170da36dfef3c709",
89
+ "package": "react-native-windows"
90
+ }
91
+ ]
92
+ }
93
+ },
94
+ {
95
+ "date": "Mon, 27 Sep 2021 15:07:16 GMT",
6
96
  "tag": "react-native-windows_v0.65.3",
7
97
  "version": "0.65.3",
8
98
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,17 +1,54 @@
1
1
  # Change Log - react-native-windows
2
2
 
3
- This log was last generated on Mon, 27 Sep 2021 15:07:04 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 01 Nov 2021 19:07:04 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## 0.65.3
7
+ ## 0.65.7
8
8
 
9
- Mon, 27 Sep 2021 15:07:04 GMT
9
+ Mon, 01 Nov 2021 19:07:04 GMT
10
10
 
11
11
  ### Patches
12
12
 
13
- - Migrate NapiJsiRuntime from V8-JSI #8617 (julio.rocha@microsoft.com)
13
+ - Fix race condition when building customer projects (dannyvv@microsoft.com)
14
+ - Fix Microsoft.ReactNative.dll version string (asklar@microsoft.com)
15
+ - Fix crash when using TextInput.blur() (30809111+acoates-ms@users.noreply.github.com)
14
16
 
17
+ ## 0.65.6
18
+
19
+ Wed, 20 Oct 2021 19:14:28 GMT
20
+
21
+ ### Patches
22
+
23
+ - Fix Arm64 Desktop linker experts due to mangled name mismatches (dannyvv@microsoft.com)
24
+
25
+ ## 0.65.5
26
+
27
+ Mon, 11 Oct 2021 15:06:57 GMT
28
+
29
+ ### Patches
30
+
31
+ - [0.65] Add ARM64 support to React.Windows.Desktop.Test.DLL (julio.rocha@microsoft.com)
32
+ - Promote 0.65 to legacy (ngerlem@microsoft.com)
33
+
34
+ ## 0.65.4
35
+
36
+ Mon, 04 Oct 2021 15:07:05 GMT
37
+
38
+ ### Patches
39
+
40
+ - Allow injection of custom UI thread (30809111+acoates-ms@users.noreply.github.com)
41
+ - Upgrade ReactNative.V8Jsi.Windows to 0.65.5 (julio.rocha@microsoft.com)
42
+ - ReactNativeHost ReloadInstance and UnloadInstance actions do not always fire completed events (30809111+acoates-ms@users.noreply.github.com)
43
+
44
+ ## 0.65.3
45
+
46
+ Mon, 27 Sep 2021 15:07:16 GMT
47
+
48
+ ### Patches
49
+
50
+ - Migrate NapiJsiRuntime from V8-JSI #8617 (julio.rocha@microsoft.com)
51
+
15
52
  ## 0.65.2
16
53
 
17
54
  Mon, 06 Sep 2021 15:06:57 GMT
@@ -10,6 +10,27 @@ using namespace Windows::Foundation;
10
10
 
11
11
  namespace winrt::Microsoft::ReactNative::implementation {
12
12
 
13
+ // Implements IDispatchQueue2 on top of a custom IReactDispatcher provided by the application
14
+ struct WrappedReactDispatcher : public Mso::UnknownObject<Mso::React::IDispatchQueue2> {
15
+ WrappedReactDispatcher(const winrt::Microsoft::ReactNative::IReactDispatcher &dispatcher) noexcept
16
+ : m_dispatcher(dispatcher) {}
17
+
18
+ void Post(Mso::DispatchTask &&task) const noexcept override {
19
+ m_dispatcher.Post(task);
20
+ }
21
+
22
+ void InvokeElsePost(Mso::DispatchTask &&task) const noexcept override {
23
+ if (m_dispatcher.HasThreadAccess()) {
24
+ task();
25
+ } else {
26
+ Post(std::move(task));
27
+ }
28
+ }
29
+
30
+ private:
31
+ winrt::Microsoft::ReactNative::IReactDispatcher m_dispatcher;
32
+ };
33
+
13
34
  ReactDispatcher::ReactDispatcher(Mso::DispatchQueue &&queue) noexcept : m_queue{std::move(queue)} {}
14
35
 
15
36
  bool ReactDispatcher::HasThreadAccess() noexcept {
@@ -20,12 +41,29 @@ void ReactDispatcher::Post(ReactDispatcherCallback const &callback) noexcept {
20
41
  return m_queue.Post([callback]() noexcept { callback(); });
21
42
  }
22
43
 
44
+ void ReactDispatcher::Post(Mso::DispatchTask &&task) const noexcept {
45
+ m_queue.Post(std::move(task));
46
+ }
47
+
48
+ void ReactDispatcher::InvokeElsePost(Mso::DispatchTask &&task) const noexcept {
49
+ m_queue.InvokeElsePost(std::move(task));
50
+ }
51
+
23
52
  /*static*/ IReactDispatcher ReactDispatcher::CreateSerialDispatcher() noexcept {
24
53
  return make<ReactDispatcher>(Mso::DispatchQueue{});
25
54
  }
26
55
 
27
- /*static*/ Mso::DispatchQueue ReactDispatcher::GetUIDispatchQueue(IReactPropertyBag const &properties) noexcept {
28
- return GetUIDispatcher(properties).as<ReactDispatcher>()->m_queue;
56
+ /*static*/ Mso::CntPtr<Mso::React::IDispatchQueue2> ReactDispatcher::GetUIDispatchQueue2(
57
+ IReactPropertyBag const &properties) noexcept {
58
+ auto iReactDispatcher = GetUIDispatcher(properties);
59
+
60
+ if (!iReactDispatcher)
61
+ return nullptr;
62
+
63
+ if (auto simpleDispatcher = iReactDispatcher.try_as<IDispatchQueue2>())
64
+ return simpleDispatcher.get();
65
+
66
+ return Mso::Make<WrappedReactDispatcher>(iReactDispatcher);
29
67
  }
30
68
 
31
69
  /*static*/ IReactDispatcher ReactDispatcher::UIThreadDispatcher() noexcept {
@@ -6,9 +6,23 @@
6
6
  #include <dispatchQueue/dispatchQueue.h>
7
7
  #include <winrt/Microsoft.ReactNative.h>
8
8
 
9
+ namespace Mso::React {
10
+
11
+ MSO_GUID(IDispatchQueue2, "a8d9db25-3d16-4476-ae65-682fcee1260c")
12
+ struct IDispatchQueue2 : ::IUnknown {
13
+ //! Post the task to the end of the queue for asynchronous invocation.
14
+ virtual void Post(Mso::DispatchTask &&task) const noexcept = 0;
15
+
16
+ //! Invoke the task immediately if the queue uses the current thread. Otherwise, post it.
17
+ //! The immediate execution ignores the suspend or shutdown states.
18
+ virtual void InvokeElsePost(Mso::DispatchTask &&task) const noexcept = 0;
19
+ };
20
+
21
+ } // namespace Mso::React
22
+
9
23
  namespace winrt::Microsoft::ReactNative::implementation {
10
24
 
11
- struct ReactDispatcher : implements<ReactDispatcher, winrt::default_interface<IReactDispatcher>> {
25
+ struct ReactDispatcher : implements<ReactDispatcher, IReactDispatcher, Mso::React::IDispatchQueue2> {
12
26
  ReactDispatcher() = default;
13
27
  ReactDispatcher(Mso::DispatchQueue &&queue) noexcept;
14
28
 
@@ -17,8 +31,7 @@ struct ReactDispatcher : implements<ReactDispatcher, winrt::default_interface<IR
17
31
 
18
32
  static IReactDispatcher CreateSerialDispatcher() noexcept;
19
33
 
20
- static Mso::DispatchQueue GetUIDispatchQueue(IReactPropertyBag const &properties) noexcept;
21
-
34
+ static Mso::CntPtr<IDispatchQueue2> GetUIDispatchQueue2(IReactPropertyBag const &properties) noexcept;
22
35
  static IReactDispatcher UIThreadDispatcher() noexcept;
23
36
  static IReactPropertyName UIDispatcherProperty() noexcept;
24
37
  static IReactDispatcher GetUIDispatcher(IReactPropertyBag const &properties) noexcept;
@@ -26,6 +39,9 @@ struct ReactDispatcher : implements<ReactDispatcher, winrt::default_interface<IR
26
39
 
27
40
  static IReactPropertyName JSDispatcherProperty() noexcept;
28
41
 
42
+ void Post(Mso::DispatchTask &&task) const noexcept override;
43
+ void InvokeElsePost(Mso::DispatchTask &&task) const noexcept override;
44
+
29
45
  private:
30
46
  Mso::DispatchQueue m_queue;
31
47
  };
@@ -16,11 +16,8 @@ namespace Microsoft::ReactNative {
16
16
 
17
17
  AppearanceChangeListener::AppearanceChangeListener(
18
18
  const Mso::React::IReactContext &context,
19
- Mso::DispatchQueue const &uiQueue) noexcept
20
- : Mso::ActiveObject<>(uiQueue), m_context(&context) {
21
- // Ensure we're constructed on the UI thread
22
- VerifyElseCrash(uiQueue.HasThreadAccess());
23
-
19
+ const Mso::React::IDispatchQueue2 &uiQueue) noexcept
20
+ : m_queue(&uiQueue), m_context(&context) {
24
21
  if (auto currentApp = xaml::TryGetCurrentApplication()) {
25
22
  m_currentTheme = currentApp.RequestedTheme();
26
23
 
@@ -29,7 +26,11 @@ AppearanceChangeListener::AppearanceChangeListener(
29
26
  m_revoker = m_uiSettings.ColorValuesChanged(
30
27
  winrt::auto_revoke, [weakThis{Mso::WeakPtr(this)}](const auto & /*sender*/, const auto & /*args*/) noexcept {
31
28
  if (auto strongThis = weakThis.GetStrongPtr()) {
32
- strongThis->InvokeInQueueStrong([strongThis]() noexcept { strongThis->OnColorValuesChanged(); });
29
+ strongThis->m_queue->Post([weakThis]() noexcept {
30
+ if (auto strongThis = weakThis.GetStrongPtr()) {
31
+ strongThis->OnColorValuesChanged();
32
+ }
33
+ });
33
34
  }
34
35
  });
35
36
  }
@@ -3,30 +3,34 @@
3
3
 
4
4
  #pragma once
5
5
 
6
- #include <activeObject/activeObject.h>
7
6
  #include <cxxreact/CxxModule.h>
8
7
  #include <eventWaitHandle/eventWaitHandle.h>
9
8
 
10
9
  #include <winrt/Windows.UI.ViewManagement.h>
11
10
 
11
+ #include <IReactDispatcher.h>
12
12
  #include <React.h>
13
+ #include <object/refCountedObject.h>
13
14
  #include "IReactInstance.h"
14
15
 
15
16
  namespace Microsoft::ReactNative {
16
17
 
17
18
  // Listens for the current theme on the UI thread, storing the most recent. Will emit JS events on Appearance change.
18
- class AppearanceChangeListener final : public Mso::ActiveObject<> {
19
+ class AppearanceChangeListener final : public Mso::RefCountedObject<Mso::RefCountStrategy::WeakRef, Mso::IRefCounted> {
19
20
  using ApplicationTheme = xaml::ApplicationTheme;
20
21
  using UISettings = winrt::Windows::UI::ViewManagement::UISettings;
21
22
 
22
23
  public:
23
- AppearanceChangeListener(const Mso::React::IReactContext &context, Mso::DispatchQueue const &uiQueue) noexcept;
24
+ AppearanceChangeListener(
25
+ const Mso::React::IReactContext &context,
26
+ const Mso::React::IDispatchQueue2 &uiQueue) noexcept;
24
27
  const char *GetColorScheme() const noexcept;
25
28
 
26
29
  private:
27
30
  static const char *ToString(ApplicationTheme theme) noexcept;
28
31
  void OnColorValuesChanged() noexcept;
29
32
 
33
+ Mso::CntPtr<const Mso::React::IDispatchQueue2> m_queue;
30
34
  UISettings m_uiSettings;
31
35
  UISettings::ColorValuesChanged_revoker m_revoker;
32
36
  std::atomic<ApplicationTheme> m_currentTheme;
@@ -163,11 +163,9 @@ struct RootShadowNode final : public ShadowNodeBase {
163
163
  }
164
164
 
165
165
  void AddView(ShadowNode &child, int64_t index) override {
166
- auto panel(GetView().as<winrt::Panel>());
167
- if (panel != nullptr) {
168
- auto childView = static_cast<ShadowNodeBase &>(child).GetView().as<xaml::UIElement>();
169
- panel.Children().InsertAt(static_cast<uint32_t>(index), childView);
170
- }
166
+ auto panel(GetView().as<winrt::Microsoft::ReactNative::ReactRootView>());
167
+ winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactRootView>(panel)->AddView(
168
+ static_cast<uint32_t>(index), static_cast<ShadowNodeBase &>(child).GetView().as<xaml::UIElement>());
171
169
  }
172
170
  };
173
171
 
@@ -5,6 +5,7 @@
5
5
  #include "ReactCoreInjection.h"
6
6
  #include "ReactCoreInjection.g.cpp"
7
7
  #include "ReactViewOptions.g.cpp"
8
+ #include <future/futureWinRT.h>
8
9
  #include "IReactContext.h"
9
10
  #include "ReactContext.h"
10
11
  #include "ReactInstanceWin.h"
@@ -86,16 +87,18 @@ ReactViewHost::ReactViewHost(
86
87
 
87
88
  // ReactViewOptions ReactViewHost::Options() noexcept;
88
89
  // ReactNative::ReactNativeHost ReactViewHost::ReactHost() noexcept {}
89
- void ReactViewHost::ReloadViewInstance() noexcept {
90
- m_viewHost->ReloadViewInstance();
90
+ winrt::Windows::Foundation::IAsyncAction ReactViewHost::ReloadViewInstance() noexcept {
91
+ return make<Mso::AsyncActionFutureAdapter>(m_viewHost->ReloadViewInstance());
91
92
  }
92
93
 
93
- void ReactViewHost::ReloadViewInstanceWithOptions(ReactNative::ReactViewOptions options) noexcept {
94
- m_viewHost->ReloadViewInstanceWithOptions(options.as<ReactViewOptions>()->CreateViewOptions());
94
+ winrt::Windows::Foundation::IAsyncAction ReactViewHost::ReloadViewInstanceWithOptions(
95
+ ReactNative::ReactViewOptions options) noexcept {
96
+ return make<Mso::AsyncActionFutureAdapter>(
97
+ m_viewHost->ReloadViewInstanceWithOptions(options.as<ReactViewOptions>()->CreateViewOptions()));
95
98
  }
96
99
 
97
- void ReactViewHost::UnloadViewInstance() noexcept {
98
- m_viewHost->UnloadViewInstance();
100
+ winrt::Windows::Foundation::IAsyncAction ReactViewHost::UnloadViewInstance() noexcept {
101
+ return make<Mso::AsyncActionFutureAdapter>(m_viewHost->UnloadViewInstance());
99
102
  }
100
103
 
101
104
  //! This class ensures that we access ReactRootView from UI thread.
@@ -149,10 +152,16 @@ struct ReactViewInstance : public Mso::UnknownObject<Mso::RefCountStrategy::Weak
149
152
  }
150
153
  };
151
154
 
152
- void ReactViewHost::AttachViewInstance(ReactNative::IReactViewInstance viewInstance) noexcept {
153
- m_viewHost->AttachViewInstance(*Mso::Make<ReactViewInstance>(viewInstance, m_uiDispatcher));
155
+ winrt::Windows::Foundation::IAsyncAction ReactViewHost::AttachViewInstance(
156
+ ReactNative::IReactViewInstance viewInstance) noexcept {
157
+ return make<Mso::AsyncActionFutureAdapter>(
158
+ m_viewHost->AttachViewInstance(*Mso::Make<ReactViewInstance>(viewInstance, m_uiDispatcher)));
154
159
  }
155
160
 
156
- void ReactViewHost::DetachViewInstance() noexcept {}
161
+ winrt::Windows::Foundation::IAsyncAction ReactViewHost::DetachViewInstance() noexcept {
162
+ Mso::Promise<void> promise;
163
+ promise.SetValue();
164
+ return make<Mso::AsyncActionFutureAdapter>(promise.AsFuture());
165
+ }
157
166
 
158
167
  } // namespace winrt::Microsoft::ReactNative::implementation
@@ -53,12 +53,11 @@ struct ReactViewHost : public winrt::implements<ReactViewHost, IReactViewHost> {
53
53
  Mso::React::IReactViewHost &viewHost,
54
54
  const winrt::Microsoft::ReactNative::IReactDispatcher &uiDispatcher);
55
55
 
56
- /*Windows::Foundation::IAsyncAction */ void ReloadViewInstance() noexcept;
57
- /*Windows::Foundation::IAsyncAction */ void ReloadViewInstanceWithOptions(
58
- ReactNative::ReactViewOptions options) noexcept;
59
- /*Windows::Foundation::IAsyncAction */ void UnloadViewInstance() noexcept;
60
- /*Windows::Foundation::IAsyncAction */ void AttachViewInstance(IReactViewInstance viewInstance) noexcept;
61
- /*Windows::Foundation::IAsyncAction */ void DetachViewInstance() noexcept;
56
+ Windows::Foundation::IAsyncAction ReloadViewInstance() noexcept;
57
+ Windows::Foundation::IAsyncAction ReloadViewInstanceWithOptions(ReactNative::ReactViewOptions options) noexcept;
58
+ Windows::Foundation::IAsyncAction UnloadViewInstance() noexcept;
59
+ Windows::Foundation::IAsyncAction AttachViewInstance(IReactViewInstance viewInstance) noexcept;
60
+ Windows::Foundation::IAsyncAction DetachViewInstance() noexcept;
62
61
 
63
62
  private:
64
63
  Mso::CntPtr<Mso::React::IReactViewHost> m_viewHost;
@@ -50,19 +50,19 @@ DOC_STRING("Settings per each IReactViewHost associated with an IReactHost insta
50
50
  interface IReactViewHost
51
51
  {
52
52
  DOC_STRING("Reloads the IReactViewInstance if it is attached.")
53
- /*Windows.Foundation.IAsyncAction*/ void ReloadViewInstance();
53
+ Windows.Foundation.IAsyncAction ReloadViewInstance();
54
54
 
55
55
  DOC_STRING("Reloads IReactViewInstance if it is attached with a new set of options.")
56
- /*Windows.Foundation.IAsyncAction*/ void ReloadViewInstanceWithOptions(ReactViewOptions options);
56
+ Windows.Foundation.IAsyncAction ReloadViewInstanceWithOptions(ReactViewOptions options);
57
57
 
58
58
  DOC_STRING("Unloads the attached IReactViewInstance.")
59
- /*Windows.Foundation.IAsyncAction*/ void UnloadViewInstance();
59
+ Windows.Foundation.IAsyncAction UnloadViewInstance();
60
60
 
61
61
  DOC_STRING("Attaches IReactViewInstance to the IReactViewHost.")
62
- /*Windows.Foundation.IAsyncAction*/ void AttachViewInstance(IReactViewInstance viewInstance);
62
+ Windows.Foundation.IAsyncAction AttachViewInstance(IReactViewInstance viewInstance);
63
63
 
64
64
  DOC_STRING("Detaches IReactViewInstance from the IReactViewHost.")
65
- /*Windows.Foundation.IAsyncAction*/ void DetachViewInstance();
65
+ Windows.Foundation.IAsyncAction DetachViewInstance();
66
66
  }
67
67
 
68
68
  [experimental]
@@ -350,168 +350,174 @@ void ReactInstanceWin::Initialize() noexcept {
350
350
  });
351
351
  #endif
352
352
 
353
- Mso::PostFuture(m_uiQueue, [weakThis = Mso::WeakPtr{this}]() noexcept {
354
- #ifndef CORE_ABI
353
+ m_uiQueue->Post([this, weakThis = Mso::WeakPtr{this}]() noexcept {
355
354
  // Objects that must be created on the UI thread
356
355
  if (auto strongThis = weakThis.GetStrongPtr()) {
356
+ #ifndef CORE_ABI
357
357
  strongThis->m_appTheme = std::make_shared<Microsoft::ReactNative::AppTheme>(
358
358
  strongThis->GetReactContext(), strongThis->m_uiMessageThread.LoadWithLock());
359
359
  Microsoft::ReactNative::I18nManager::InitI18nInfo(
360
360
  winrt::Microsoft::ReactNative::ReactPropertyBag(strongThis->Options().Properties));
361
361
  strongThis->m_appearanceListener = Mso::Make<Microsoft::ReactNative::AppearanceChangeListener>(
362
- strongThis->GetReactContext(), strongThis->m_uiQueue);
363
-
362
+ strongThis->GetReactContext(), *(strongThis->m_uiQueue));
364
363
  Microsoft::ReactNative::DeviceInfoHolder::InitDeviceInfoHolder(strongThis->GetReactContext());
365
- }
366
364
  #endif
367
- }).Then(Queue(), [this, weakThis = Mso::WeakPtr{this}]() noexcept {
368
- if (auto strongThis = weakThis.GetStrongPtr()) {
369
- // auto cxxModulesProviders = GetCxxModuleProviders();
370
-
371
- auto devSettings = std::make_shared<facebook::react::DevSettings>();
372
- devSettings->useJITCompilation = m_options.EnableJITCompilation;
373
- devSettings->sourceBundleHost = SourceBundleHost();
374
- devSettings->sourceBundlePort = SourceBundlePort();
375
- devSettings->debugBundlePath = DebugBundlePath();
376
- devSettings->liveReloadCallback = GetLiveReloadCallback();
377
- devSettings->errorCallback = GetErrorCallback();
378
- devSettings->loggingCallback = GetLoggingCallback();
379
- m_redboxHandler = devSettings->redboxHandler = std::move(GetRedBoxHandler());
380
- devSettings->useDirectDebugger = m_useDirectDebugger;
381
- devSettings->debuggerBreakOnNextLine = m_debuggerBreakOnNextLine;
382
- devSettings->debuggerPort = m_options.DeveloperSettings.DebuggerPort;
383
- devSettings->debuggerRuntimeName = m_options.DeveloperSettings.DebuggerRuntimeName;
384
- devSettings->useWebDebugger = m_useWebDebugger;
385
- devSettings->useFastRefresh = m_isFastReloadEnabled;
386
- // devSettings->memoryTracker = GetMemoryTracker();
387
- devSettings->bundleRootPath = BundleRootPath();
388
-
389
- devSettings->waitingForDebuggerCallback = GetWaitingForDebuggerCallback();
390
- devSettings->debuggerAttachCallback = GetDebuggerAttachCallback();
391
- #ifndef CORE_ABI
392
- devSettings->showDevMenuCallback = [weakThis]() noexcept {
365
+
366
+ strongThis->Queue().Post([this, weakThis]() noexcept {
393
367
  if (auto strongThis = weakThis.GetStrongPtr()) {
394
- strongThis->m_uiQueue.Post([context = strongThis->m_reactContext]() {
395
- Microsoft::ReactNative::DevMenuManager::Show(context->Properties());
396
- });
397
- }
398
- };
368
+ // auto cxxModulesProviders = GetCxxModuleProviders();
369
+
370
+ auto devSettings = std::make_shared<facebook::react::DevSettings>();
371
+ devSettings->useJITCompilation = m_options.EnableJITCompilation;
372
+ devSettings->sourceBundleHost = SourceBundleHost();
373
+ devSettings->sourceBundlePort = SourceBundlePort();
374
+ devSettings->debugBundlePath = DebugBundlePath();
375
+ devSettings->liveReloadCallback = GetLiveReloadCallback();
376
+ devSettings->errorCallback = GetErrorCallback();
377
+ devSettings->loggingCallback = GetLoggingCallback();
378
+ m_redboxHandler = devSettings->redboxHandler = std::move(GetRedBoxHandler());
379
+ devSettings->useDirectDebugger = m_useDirectDebugger;
380
+ devSettings->debuggerBreakOnNextLine = m_debuggerBreakOnNextLine;
381
+ devSettings->debuggerPort = m_options.DeveloperSettings.DebuggerPort;
382
+ devSettings->debuggerRuntimeName = m_options.DeveloperSettings.DebuggerRuntimeName;
383
+ devSettings->useWebDebugger = m_useWebDebugger;
384
+ devSettings->useFastRefresh = m_isFastReloadEnabled;
385
+ // devSettings->memoryTracker = GetMemoryTracker();
386
+ devSettings->bundleRootPath = BundleRootPath();
387
+
388
+ devSettings->waitingForDebuggerCallback = GetWaitingForDebuggerCallback();
389
+ devSettings->debuggerAttachCallback = GetDebuggerAttachCallback();
390
+
391
+ #ifndef CORE_ABI
392
+ devSettings->showDevMenuCallback = [weakThis]() noexcept {
393
+ if (auto strongThis = weakThis.GetStrongPtr()) {
394
+ strongThis->m_uiQueue->Post([context = strongThis->m_reactContext]() {
395
+ Microsoft::ReactNative::DevMenuManager::Show(context->Properties());
396
+ });
397
+ }
398
+ };
399
399
  #endif
400
400
 
401
- // Now that ReactNativeWindows is building outside devmain, it is missing
402
- // fix given by PR https://github.com/microsoft/react-native-windows/pull/2624 causing
403
- // regression. We're turning off console redirection till the fix is available in devmain.
404
- // Bug https://office.visualstudio.com/DefaultCollection/OC/_workitems/edit/3441551 is tracking this
405
- devSettings->debuggerConsoleRedirection = false; // JSHost::ChangeGate::ChakraCoreDebuggerConsoleRedirection();
401
+ // Now that ReactNativeWindows is building outside devmain, it is missing
402
+ // fix given by PR https://github.com/microsoft/react-native-windows/pull/2624 causing
403
+ // regression. We're turning off console redirection till the fix is available in devmain.
404
+ // Bug https://office.visualstudio.com/DefaultCollection/OC/_workitems/edit/3441551 is tracking this
405
+ devSettings->debuggerConsoleRedirection =
406
+ false; // JSHost::ChangeGate::ChakraCoreDebuggerConsoleRedirection();
406
407
 
407
408
  #ifdef CORE_ABI
408
- std::vector<facebook::react::NativeModuleDescription> cxxModules;
409
+ std::vector<facebook::react::NativeModuleDescription> cxxModules;
409
410
  #else
410
- // Acquire default modules and then populate with custom modules.
411
- // Note that some of these have custom thread affinity.
412
- std::vector<facebook::react::NativeModuleDescription> cxxModules = Microsoft::ReactNative::GetCoreModules(
413
- m_batchingUIThread,
414
- m_jsMessageThread.Load(),
415
- std::move(m_appTheme),
416
- std::move(m_appearanceListener),
417
- m_reactContext);
411
+ // Acquire default modules and then populate with custom modules.
412
+ // Note that some of these have custom thread affinity.
413
+ std::vector<facebook::react::NativeModuleDescription> cxxModules = Microsoft::ReactNative::GetCoreModules(
414
+ m_batchingUIThread,
415
+ m_jsMessageThread.Load(),
416
+ std::move(m_appTheme),
417
+ std::move(m_appearanceListener),
418
+ m_reactContext);
418
419
  #endif
419
420
 
420
- auto nmp = std::make_shared<winrt::Microsoft::ReactNative::NativeModulesProvider>();
421
+ auto nmp = std::make_shared<winrt::Microsoft::ReactNative::NativeModulesProvider>();
421
422
 
422
- LoadModules(nmp, m_options.TurboModuleProvider);
423
+ LoadModules(nmp, m_options.TurboModuleProvider);
423
424
 
424
- auto modules = nmp->GetModules(m_reactContext, m_jsMessageThread.Load());
425
- cxxModules.insert(
426
- cxxModules.end(), std::make_move_iterator(modules.begin()), std::make_move_iterator(modules.end()));
425
+ auto modules = nmp->GetModules(m_reactContext, m_jsMessageThread.Load());
426
+ cxxModules.insert(
427
+ cxxModules.end(), std::make_move_iterator(modules.begin()), std::make_move_iterator(modules.end()));
427
428
 
428
- if (m_options.ModuleProvider != nullptr) {
429
- std::vector<facebook::react::NativeModuleDescription> customCxxModules =
430
- m_options.ModuleProvider->GetModules(m_reactContext, m_jsMessageThread.Load());
431
- cxxModules.insert(std::end(cxxModules), std::begin(customCxxModules), std::end(customCxxModules));
432
- }
429
+ if (m_options.ModuleProvider != nullptr) {
430
+ std::vector<facebook::react::NativeModuleDescription> customCxxModules =
431
+ m_options.ModuleProvider->GetModules(m_reactContext, m_jsMessageThread.Load());
432
+ cxxModules.insert(std::end(cxxModules), std::begin(customCxxModules), std::end(customCxxModules));
433
+ }
433
434
 
434
- std::unique_ptr<facebook::jsi::ScriptStore> scriptStore = nullptr;
435
- std::unique_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore = nullptr;
435
+ std::unique_ptr<facebook::jsi::ScriptStore> scriptStore = nullptr;
436
+ std::unique_ptr<facebook::jsi::PreparedScriptStore> preparedScriptStore = nullptr;
436
437
 
437
- switch (m_options.JsiEngine) {
438
- case JSIEngine::Hermes:
438
+ switch (m_options.JsiEngine) {
439
+ case JSIEngine::Hermes:
439
440
  #if defined(USE_HERMES)
440
- devSettings->jsiRuntimeHolder =
441
- std::make_shared<facebook::react::HermesRuntimeHolder>(devSettings, m_jsMessageThread.Load());
442
- devSettings->inlineSourceMap = false;
443
- break;
441
+ devSettings->jsiRuntimeHolder =
442
+ std::make_shared<facebook::react::HermesRuntimeHolder>(devSettings, m_jsMessageThread.Load());
443
+ devSettings->inlineSourceMap = false;
444
+ break;
444
445
  #endif
445
- case JSIEngine::V8:
446
+ case JSIEngine::V8:
446
447
  #if defined(USE_V8)
447
448
  #ifndef CORE_ABI
448
- preparedScriptStore =
449
- std::make_unique<facebook::react::BasePreparedScriptStoreImpl>(getApplicationLocalFolder());
449
+ preparedScriptStore =
450
+ std::make_unique<facebook::react::BasePreparedScriptStoreImpl>(getApplicationLocalFolder());
450
451
  #endif // CORE_ABI
451
- devSettings->jsiRuntimeHolder = std::make_shared<facebook::react::V8JSIRuntimeHolder>(
452
- devSettings, m_jsMessageThread.Load(), std::move(scriptStore), std::move(preparedScriptStore));
453
- break;
452
+ devSettings->jsiRuntimeHolder = std::make_shared<facebook::react::V8JSIRuntimeHolder>(
453
+ devSettings, m_jsMessageThread.Load(), std::move(scriptStore), std::move(preparedScriptStore));
454
+ break;
454
455
  #endif // USE_V8
455
- case JSIEngine::Chakra:
456
+ case JSIEngine::Chakra:
456
457
  #ifndef CORE_ABI
457
- if (m_options.EnableByteCodeCaching || !m_options.ByteCodeFileUri.empty()) {
458
- scriptStore = std::make_unique<Microsoft::ReactNative::UwpScriptStore>();
459
- preparedScriptStore = std::make_unique<Microsoft::ReactNative::UwpPreparedScriptStore>(
460
- winrt::to_hstring(m_options.ByteCodeFileUri));
461
- }
458
+ if (m_options.EnableByteCodeCaching || !m_options.ByteCodeFileUri.empty()) {
459
+ scriptStore = std::make_unique<Microsoft::ReactNative::UwpScriptStore>();
460
+ preparedScriptStore = std::make_unique<Microsoft::ReactNative::UwpPreparedScriptStore>(
461
+ winrt::to_hstring(m_options.ByteCodeFileUri));
462
+ }
462
463
  #endif
463
- devSettings->jsiRuntimeHolder = std::make_shared<Microsoft::JSI::ChakraRuntimeHolder>(
464
- devSettings, m_jsMessageThread.Load(), std::move(scriptStore), std::move(preparedScriptStore));
465
- break;
466
- }
464
+ devSettings->jsiRuntimeHolder = std::make_shared<Microsoft::JSI::ChakraRuntimeHolder>(
465
+ devSettings, m_jsMessageThread.Load(), std::move(scriptStore), std::move(preparedScriptStore));
466
+ break;
467
+ }
467
468
 
468
- m_jsiRuntimeHolder = devSettings->jsiRuntimeHolder;
469
-
470
- try {
471
- // We need to keep the instance wrapper alive as its destruction shuts down the native queue.
472
- m_options.TurboModuleProvider->SetReactContext(
473
- winrt::make<implementation::ReactContext>(Mso::Copy(m_reactContext)));
474
- auto bundleRootPath = devSettings->bundleRootPath;
475
- auto instanceWrapper = facebook::react::CreateReactInstance(
476
- std::shared_ptr<facebook::react::Instance>(strongThis->m_instance.Load()),
477
- std::move(bundleRootPath), // bundleRootPath
478
- std::move(cxxModules),
479
- m_options.TurboModuleProvider,
480
- std::make_unique<BridgeUIBatchInstanceCallback>(weakThis),
481
- m_jsMessageThread.Load(),
482
- Mso::Copy(m_batchingUIThread),
483
- std::move(devSettings));
484
-
485
- m_instanceWrapper.Exchange(std::move(instanceWrapper));
469
+ m_jsiRuntimeHolder = devSettings->jsiRuntimeHolder;
470
+
471
+ try {
472
+ // We need to keep the instance wrapper alive as its destruction shuts down the native queue.
473
+ m_options.TurboModuleProvider->SetReactContext(
474
+ winrt::make<implementation::ReactContext>(Mso::Copy(m_reactContext)));
475
+ auto bundleRootPath = devSettings->bundleRootPath;
476
+ auto instanceWrapper = facebook::react::CreateReactInstance(
477
+ std::shared_ptr<facebook::react::Instance>(strongThis->m_instance.Load()),
478
+ std::move(bundleRootPath), // bundleRootPath
479
+ std::move(cxxModules),
480
+ m_options.TurboModuleProvider,
481
+ std::make_unique<BridgeUIBatchInstanceCallback>(weakThis),
482
+ m_jsMessageThread.Load(),
483
+ Mso::Copy(m_batchingUIThread),
484
+ std::move(devSettings));
485
+
486
+ m_instanceWrapper.Exchange(std::move(instanceWrapper));
486
487
 
487
488
  #ifdef USE_FABRIC
488
- // Eagerly init the FabricUI binding
489
- if (m_options.EnableFabric()) {
490
- Microsoft::ReactNative::SchedulerSettings::SetRuntimeExecutor(
491
- winrt::Microsoft::ReactNative::ReactPropertyBag(m_reactContext->Properties()),
492
- m_instanceWrapper.Load()->GetInstance()->getRuntimeExecutor(false /*shouldFlush*/));
493
- m_options.TurboModuleProvider->getModule("FabricUIManagerBinding", m_instance.Load()->getJSCallInvoker());
494
- }
489
+ // Eagerly init the FabricUI binding
490
+ if (m_options.EnableFabric()) {
491
+ Microsoft::ReactNative::SchedulerSettings::SetRuntimeExecutor(
492
+ winrt::Microsoft::ReactNative::ReactPropertyBag(m_reactContext->Properties()),
493
+ m_instanceWrapper.Load()->GetInstance()->getRuntimeExecutor(false /*shouldFlush*/));
494
+ m_options.TurboModuleProvider->getModule("FabricUIManagerBinding", m_instance.Load()->getJSCallInvoker());
495
+ }
495
496
  #endif
497
+ LoadJSBundles();
498
+
499
+ if (UseDeveloperSupport() && State() != ReactInstanceState::HasError) {
500
+ folly::dynamic params = folly::dynamic::array(
501
+ STRING(RN_PLATFORM),
502
+ DebugBundlePath(),
503
+ SourceBundleHost(),
504
+ SourceBundlePort(),
505
+ m_isFastReloadEnabled);
506
+ m_instance.Load()->callJSFunction("HMRClient", "setup", std::move(params));
507
+ }
496
508
 
497
- LoadJSBundles();
498
-
499
- if (UseDeveloperSupport() && State() != ReactInstanceState::HasError) {
500
- folly::dynamic params = folly::dynamic::array(
501
- STRING(RN_PLATFORM), DebugBundlePath(), SourceBundleHost(), SourceBundlePort(), m_isFastReloadEnabled);
502
- m_instance.Load()->callJSFunction("HMRClient", "setup", std::move(params));
509
+ } catch (std::exception &e) {
510
+ OnErrorWithMessage(e.what());
511
+ OnErrorWithMessage("UwpReactInstance: Failed to create React Instance.");
512
+ } catch (winrt::hresult_error const &e) {
513
+ OnErrorWithMessage(Microsoft::Common::Unicode::Utf16ToUtf8(e.message().c_str(), e.message().size()));
514
+ OnErrorWithMessage("UwpReactInstance: Failed to create React Instance.");
515
+ } catch (...) {
516
+ OnErrorWithMessage("UwpReactInstance: Failed to create React Instance.");
517
+ }
503
518
  }
504
-
505
- } catch (std::exception &e) {
506
- OnErrorWithMessage(e.what());
507
- OnErrorWithMessage("UwpReactInstance: Failed to create React Instance.");
508
- } catch (winrt::hresult_error const &e) {
509
- OnErrorWithMessage(Microsoft::Common::Unicode::Utf16ToUtf8(e.message().c_str(), e.message().size()));
510
- OnErrorWithMessage("UwpReactInstance: Failed to create React Instance.");
511
- } catch (...) {
512
- OnErrorWithMessage("UwpReactInstance: Failed to create React Instance.");
513
- }
514
- }
519
+ });
520
+ };
515
521
  });
516
522
  }
517
523
 
@@ -656,10 +662,11 @@ void ReactInstanceWin::InitNativeMessageThread() noexcept {
656
662
 
657
663
  void ReactInstanceWin::InitUIMessageThread() noexcept {
658
664
  // Native queue was already given us in constructor.
659
- m_uiQueue = winrt::Microsoft::ReactNative::implementation::ReactDispatcher::GetUIDispatchQueue(m_options.Properties);
665
+
666
+ m_uiQueue = winrt::Microsoft::ReactNative::implementation::ReactDispatcher::GetUIDispatchQueue2(m_options.Properties);
660
667
  VerifyElseCrashSz(m_uiQueue, "No UI Dispatcher provided");
661
- m_uiMessageThread.Exchange(
662
- std::make_shared<MessageDispatchQueue>(m_uiQueue, Mso::MakeWeakMemberFunctor(this, &ReactInstanceWin::OnError)));
668
+ m_uiMessageThread.Exchange(std::make_shared<MessageDispatchQueue2>(
669
+ *m_uiQueue, Mso::MakeWeakMemberFunctor(this, &ReactInstanceWin::OnError)));
663
670
 
664
671
  auto batchingUIThread = Microsoft::ReactNative::MakeBatchingQueueThread(m_uiMessageThread.Load());
665
672
  m_batchingUIThread = batchingUIThread;
@@ -744,7 +751,7 @@ std::shared_ptr<IRedBoxHandler> ReactInstanceWin::GetRedBoxHandler() noexcept {
744
751
  #ifndef CORE_ABI
745
752
  } else if (UseDeveloperSupport()) {
746
753
  auto localWkReactHost = m_weakReactHost;
747
- return CreateDefaultRedBoxHandler(std::move(localWkReactHost), Mso::Copy(m_uiQueue));
754
+ return CreateDefaultRedBoxHandler(std::move(localWkReactHost), *m_uiQueue);
748
755
  #endif
749
756
  } else {
750
757
  return {};
@@ -3,6 +3,7 @@
3
3
 
4
4
  #pragma once
5
5
 
6
+ #include "IReactDispatcher.h"
6
7
  #include "IReactInstanceInternal.h"
7
8
  #include "ReactContext.h"
8
9
  #include "ReactNativeHeaders.h"
@@ -178,7 +179,7 @@ class ReactInstanceWin final : public Mso::ActiveObject<IReactInstanceInternal>
178
179
  std::shared_ptr<Microsoft::ReactNative::AppTheme> m_appTheme;
179
180
  Mso::CntPtr<Microsoft::ReactNative::AppearanceChangeListener> m_appearanceListener;
180
181
  #endif
181
- Mso::DispatchQueue m_uiQueue;
182
+ Mso::CntPtr<Mso::React::IDispatchQueue2> m_uiQueue;
182
183
  std::deque<JSCallEntry> m_jsCallQueue;
183
184
 
184
185
  std::shared_ptr<facebook::jsi::RuntimeHolderLazyInit> m_jsiRuntimeHolder;
@@ -304,9 +304,6 @@ void ReactRootView::ShowInstanceLoading() noexcept {
304
304
 
305
305
  void ReactRootView::EnsureFocusSafeHarbor() noexcept {
306
306
  if (!m_focusSafeHarbor) {
307
- // focus safe harbor is delayed to be inserted to the visual tree
308
- VerifyElseCrash(Children().Size() == 1);
309
-
310
307
  m_focusSafeHarbor = xaml::Controls::ContentControl{};
311
308
  m_focusSafeHarbor.Width(0.0);
312
309
  m_focusSafeHarbor.IsTabStop(false);
@@ -486,4 +483,32 @@ Windows::Foundation::Size ReactRootView::ArrangeOverride(Windows::Foundation::Si
486
483
  return finalSize;
487
484
  }
488
485
 
486
+ // Maps react-native's view of the root view to the actual UI
487
+ // react-native is unaware that there are non-RN elements within the ReactRootView
488
+ uint32_t ReactRootView::RNIndexToXamlIndex(uint32_t index) noexcept {
489
+ // If m_focusSafeHarbor exists, it should be at index 0
490
+ // m_xamlRootView is the next element, followed by any RN content.
491
+ #if DEBUG
492
+ uint32_t findIndex{0};
493
+ Assert(!m_focusSafeHarbor || Children().IndexOf(m_focusSafeHarbor, findIndex) && findIndex == 0);
494
+ Assert(Children().IndexOf(m_xamlRootView, findIndex) && findIndex == (m_focusSafeHarbor ? 1 : 0));
495
+ #endif
496
+
497
+ return index + (m_focusSafeHarbor ? 2 : 1);
498
+ }
499
+
500
+ void ReactRootView::AddView(uint32_t index, xaml::UIElement child) {
501
+ Children().InsertAt(RNIndexToXamlIndex(index), child);
502
+ }
503
+
504
+ void ReactRootView::RemoveAllChildren() {
505
+ const uint32_t numLeft = m_focusSafeHarbor ? 2 : 1;
506
+ while (Children().Size() > numLeft)
507
+ Children().RemoveAt(numLeft);
508
+ }
509
+
510
+ void ReactRootView::RemoveChildAt(uint32_t index) {
511
+ Children().RemoveAt(RNIndexToXamlIndex(index));
512
+ }
513
+
489
514
  } // namespace winrt::Microsoft::ReactNative::implementation
@@ -38,6 +38,11 @@ struct ReactRootView : ReactRootViewT<ReactRootView>, ::Microsoft::ReactNative::
38
38
 
39
39
  void ReloadView() noexcept;
40
40
 
41
+ // Used by RootViewManager
42
+ void AddView(uint32_t index, xaml::UIElement child);
43
+ void RemoveAllChildren();
44
+ void RemoveChildAt(uint32_t index);
45
+
41
46
  public: // IXamlRootView
42
47
  ::Microsoft::ReactNative::XamlView GetXamlView() const noexcept override;
43
48
 
@@ -93,6 +98,7 @@ struct ReactRootView : ReactRootViewT<ReactRootView>, ::Microsoft::ReactNative::
93
98
  // JS created children
94
99
  winrt::Grid m_xamlRootView{nullptr};
95
100
 
101
+ uint32_t RNIndexToXamlIndex(uint32_t index) noexcept;
96
102
  void UpdatePerspective();
97
103
  void UpdateRootViewInternal() noexcept;
98
104
  void ClearLoadingUI() noexcept;
@@ -408,8 +408,10 @@ struct RedBox : public std::enable_shared_from_this<RedBox> {
408
408
  * This class is implemented such that the methods on IRedBoxHandler are thread safe.
409
409
  */
410
410
  struct DefaultRedBoxHandler final : public std::enable_shared_from_this<DefaultRedBoxHandler>, IRedBoxHandler {
411
- DefaultRedBoxHandler(Mso::WeakPtr<Mso::React::IReactHost> &&weakReactHost, Mso::DispatchQueue &&uiQueue) noexcept
412
- : m_weakReactHost{std::move(weakReactHost)}, m_uiQueue{std::move(uiQueue)} {}
411
+ DefaultRedBoxHandler(
412
+ Mso::WeakPtr<Mso::React::IReactHost> &&weakReactHost,
413
+ const Mso::React::IDispatchQueue2 &uiQueue) noexcept
414
+ : m_weakReactHost{std::move(weakReactHost)}, m_uiQueue{&uiQueue} {}
413
415
 
414
416
  ~DefaultRedBoxHandler() {
415
417
  // Hide any currently showing redBoxes
@@ -418,7 +420,7 @@ struct DefaultRedBoxHandler final : public std::enable_shared_from_this<DefaultR
418
420
  std::scoped_lock lock{m_lockRedBox};
419
421
  std::swap(m_redBoxes, redBoxes);
420
422
  }
421
- m_uiQueue.Post([redBoxes = std::move(redBoxes)]() {
423
+ m_uiQueue->Post([redBoxes = std::move(redBoxes)]() {
422
424
  for (const auto &redBox : redBoxes) {
423
425
  redBox->Dismiss();
424
426
  }
@@ -472,14 +474,14 @@ struct DefaultRedBoxHandler final : public std::enable_shared_from_this<DefaultR
472
474
  }
473
475
 
474
476
  if (redbox) {
475
- m_uiQueue.Post([redboxCaptured = std::move(redbox), errorInfo = std::move(info)]() {
477
+ m_uiQueue->Post([redboxCaptured = std::move(redbox), errorInfo = std::move(info)]() {
476
478
  redboxCaptured->UpdateError(std::move(errorInfo));
477
479
  });
478
480
  }
479
481
  }
480
482
 
481
483
  virtual void dismissRedbox() override {
482
- m_uiQueue.Post([wkthis = std::weak_ptr(shared_from_this())]() {
484
+ m_uiQueue->Post([wkthis = std::weak_ptr(shared_from_this())]() {
483
485
  if (auto pthis = wkthis.lock()) {
484
486
  std::scoped_lock lock{pthis->m_lockRedBox};
485
487
  if (!pthis->m_redBoxes.empty())
@@ -523,11 +525,11 @@ struct DefaultRedBoxHandler final : public std::enable_shared_from_this<DefaultR
523
525
  return;
524
526
  m_showingRedBox = true;
525
527
 
526
- m_uiQueue.Post([redboxCaptured = std::move(redbox)]() { redboxCaptured->ShowNewJSError(); });
528
+ m_uiQueue->Post([redboxCaptured = std::move(redbox)]() { redboxCaptured->ShowNewJSError(); });
527
529
  }
528
530
 
529
531
  private:
530
- const Mso::DispatchQueue m_uiQueue;
532
+ Mso::CntPtr<const Mso::React::IDispatchQueue2> m_uiQueue;
531
533
  bool m_showingRedBox{false}; // Access from UI Thread only
532
534
  std::mutex m_lockRedBox;
533
535
  std::vector<std::shared_ptr<RedBox>> m_redBoxes; // Protected by m_lockRedBox
@@ -575,9 +577,9 @@ std::shared_ptr<IRedBoxHandler> CreateRedBoxHandler(
575
577
 
576
578
  std::shared_ptr<IRedBoxHandler> CreateDefaultRedBoxHandler(
577
579
  Mso::WeakPtr<IReactHost> &&weakReactHost,
578
- Mso::DispatchQueue &&uiQueue) noexcept {
580
+ const Mso::React::IDispatchQueue2 &uiQueue) noexcept {
579
581
  #ifndef CORE_ABI
580
- return std::make_shared<DefaultRedBoxHandler>(std::move(weakReactHost), std::move(uiQueue));
582
+ return std::make_shared<DefaultRedBoxHandler>(std::move(weakReactHost), uiQueue);
581
583
  #else
582
584
  return nullptr;
583
585
  #endif
@@ -2,6 +2,7 @@
2
2
  // Licensed under the MIT License.
3
3
  #pragma once
4
4
  #include <DevSettings.h>
5
+ #include "IReactDispatcher.h"
5
6
  #include "IRedBoxHandler.h"
6
7
  #include "ReactHost/React.h"
7
8
 
@@ -12,5 +13,5 @@ std::shared_ptr<IRedBoxHandler> CreateRedBoxHandler(
12
13
 
13
14
  std::shared_ptr<IRedBoxHandler> CreateDefaultRedBoxHandler(
14
15
  Mso::WeakPtr<IReactHost> &&weakReactHost,
15
- Mso::DispatchQueue &&uiQueue) noexcept;
16
+ const Mso::React::IDispatchQueue2 &uiQueue) noexcept;
16
17
  } // namespace Mso::React
@@ -34,7 +34,7 @@ struct DefaultRedBoxHandler : winrt::implements<DefaultRedBoxHandler, IRedBoxHan
34
34
  auto hostImpl = winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeHost>(host);
35
35
  Mso::WeakPtr<Mso::React::IReactHost> wkHost(hostImpl->ReactHost());
36
36
  m_redBoxHandler = Mso::React::CreateDefaultRedBoxHandler(
37
- std::move(wkHost), ReactDispatcher::GetUIDispatchQueue(host.InstanceSettings().Properties()));
37
+ std::move(wkHost), *ReactDispatcher::GetUIDispatchQueue2(host.InstanceSettings().Properties()));
38
38
  }
39
39
 
40
40
  void ShowNewError(IRedBoxErrorInfo const &info, RedBoxErrorType type) noexcept {
@@ -4,7 +4,7 @@
4
4
  #define STRINGIZE(s) #s
5
5
 
6
6
  #ifdef RNW_PKG_VERSION_STR
7
- #define VER_FILEVERSION_STR STRINGIZE(RNW_PKG_VERSION_STR)
7
+ #define VER_FILEVERSION_STR XSTRINGIZE(RNW_PKG_VERSION_STR)
8
8
  #else
9
9
  #define VER_FILEVERSION_STR "Private Build"
10
10
  #endif
@@ -6,6 +6,7 @@
6
6
  #include "RootViewManager.h"
7
7
 
8
8
  #include <IXamlRootView.h>
9
+ #include <ReactRootView.h>
9
10
  #include <UI.Xaml.Controls.h>
10
11
 
11
12
  namespace winrt {
@@ -29,21 +30,19 @@ XamlView RootViewManager::CreateViewCore(int64_t /*tag*/, const winrt::Microsoft
29
30
  }
30
31
 
31
32
  void RootViewManager::AddView(const XamlView &parent, const XamlView &child, int64_t index) {
32
- auto panel(parent.as<winrt::Panel>());
33
- if (panel != nullptr)
34
- panel.Children().InsertAt(static_cast<uint32_t>(index), child.as<xaml::UIElement>());
33
+ // Goes through RootShadowNode::AddView instead of here
34
+ assert(false);
35
35
  }
36
36
 
37
37
  void RootViewManager::RemoveAllChildren(const XamlView &parent) {
38
- auto panel(parent.as<winrt::Panel>());
39
- if (panel != nullptr)
40
- panel.Children().Clear();
38
+ auto panel(parent.as<winrt::Microsoft::ReactNative::ReactRootView>());
39
+ winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactRootView>(panel)->RemoveAllChildren();
41
40
  }
42
41
 
43
42
  void RootViewManager::RemoveChildAt(const XamlView &parent, int64_t index) {
44
- auto panel(parent.as<winrt::Panel>());
45
- if (panel != nullptr)
46
- panel.Children().RemoveAt(static_cast<uint32_t>(index));
43
+ auto panel(parent.as<winrt::Microsoft::ReactNative::ReactRootView>());
44
+ winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactRootView>(panel)->RemoveChildAt(
45
+ static_cast<uint32_t>(index));
47
46
  }
48
47
 
49
48
  void RootViewManager::SetLayoutProps(
@@ -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.8.0-ms.0" targetFramework="native" />
11
- <!-- package id="ReactNative.V8Jsi.Windows.UWP" version="0.65.2" targetFramework="native" / -->
11
+ <!-- package id="ReactNative.V8Jsi.Windows.UWP" version="0.65.5" targetFramework="native" / -->
12
12
  </packages>
@@ -57,7 +57,9 @@ struct AsyncActionFutureAdapter : winrt::implements<
57
57
  m_completedAssigned = true;
58
58
 
59
59
  if (m_status == AsyncStatus::Started) {
60
- m_completed = winrt::impl::make_agile_delegate(handler);
60
+ m_completed = winrt::impl::make_agile_delegate(
61
+ [keepAlive = get_strong(), handler = std::move(handler)](
62
+ auto const &task, winrt::Windows::Foundation::AsyncStatus status) { handler(task, status); });
61
63
  return;
62
64
  }
63
65
 
@@ -9,7 +9,7 @@
9
9
  <RunAutolinkCheck Condition="'$(RunAutolinkCheck)' == ''">true</RunAutolinkCheck>
10
10
  <AutolinkCommand Condition="'$(AutolinkCommand)' == ''">npx react-native autolink-windows</AutolinkCommand>
11
11
  <AutolinkCommandWorkingDir Condition="'$(AutolinkCommandWorkingDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(ProjectDir), 'package.json'))</AutolinkCommandWorkingDir>
12
- <AutolinkCommandArgs Condition="'$(AutolinkCommandArgs)' == '' And '$(SolutionPath)' != '' And '$(ProjectPath)' != ''">--check --sln "$([MSBuild]::MakeRelative($(AutolinkCommandWorkingDir), $(SolutionPath)))" --proj "$([MSBuild]::MakeRelative($(AutolinkCommandWorkingDir), $(ProjectPath)))"</AutolinkCommandArgs>
12
+ <AutolinkCommandArgs Condition="'$(AutolinkCommandArgs)' == '' And '$(SolutionPath)' != '' And '$(SolutionPath)' != '*Undefined*' And '$(ProjectPath)' != ''">--check --sln "$([MSBuild]::MakeRelative($(AutolinkCommandWorkingDir), $(SolutionPath)))" --proj "$([MSBuild]::MakeRelative($(AutolinkCommandWorkingDir), $(ProjectPath)))"</AutolinkCommandArgs>
13
13
  <AutolinkCommandArgs Condition="'$(AutolinkCommandArgs)' == ''">--check</AutolinkCommandArgs>
14
14
  </PropertyGroup>
15
15
 
@@ -11,7 +11,7 @@
11
11
  <EnableHermesInspectorInReleaseFlavor Condition="'$(EnableHermesInspectorInReleaseFlavor)' == ''">false</EnableHermesInspectorInReleaseFlavor>
12
12
 
13
13
  <UseV8 Condition="'$(UseV8)' == ''">false</UseV8>
14
- <V8Version Condition="'$(V8Version)' == ''">0.65.2</V8Version>
14
+ <V8Version Condition="'$(V8Version)' == ''">0.65.5</V8Version>
15
15
  <V8PackageName>ReactNative.V8Jsi.Windows</V8PackageName>
16
16
  <V8PackageName Condition="'$(V8AppPlatform)' != 'win32'">$(V8PackageName).UWP</V8PackageName>
17
17
  <V8Package>$(SolutionDir)packages\$(V8PackageName).$(V8Version)</V8Package>
@@ -28,10 +28,12 @@
28
28
  <file src="$nugetroot$\x64\Release\React.Windows.Desktop\Microsoft.ReactNative.winmd" target="lib\ship\x64"/>
29
29
  <file src="$nugetroot$\ARM64\Release\React.Windows.Desktop\Microsoft.ReactNative.winmd" target="lib\ship\ARM64"/>
30
30
 
31
- <file src="$nugetroot$\x86\Debug\React.Windows.Desktop.Test.DLL\React.Windows.Desktop.Test.**" target="lib\debug\x86" exclude="**\*.iobj;**\*.ipdb;**\*.exp;**\*.ilk" />
32
- <file src="$nugetroot$\x64\Debug\React.Windows.Desktop.Test.DLL\React.Windows.Desktop.Test.**" target="lib\debug\x64" exclude="**\*.iobj;**\*.ipdb;**\*.exp;**\*.ilk" />
33
- <file src="$nugetroot$\x86\Release\React.Windows.Desktop.Test.DLL\React.Windows.Desktop.Test.**" target="lib\ship\x86" exclude="**\*.iobj;**\*.ipdb;**\*.exp;**\*.ilk" />
34
- <file src="$nugetroot$\x64\Release\React.Windows.Desktop.Test.DLL\React.Windows.Desktop.Test.**" target="lib\ship\x64" exclude="**\*.iobj;**\*.ipdb;**\*.exp;**\*.ilk" />
31
+ <file src="$nugetroot$\x86\Debug\React.Windows.Desktop.Test.DLL\React.Windows.Desktop.Test.**" target="lib\debug\x86" exclude="**\*.iobj;**\*.ipdb;**\*.exp;**\*.ilk" />
32
+ <file src="$nugetroot$\x64\Debug\React.Windows.Desktop.Test.DLL\React.Windows.Desktop.Test.**" target="lib\debug\x64" exclude="**\*.iobj;**\*.ipdb;**\*.exp;**\*.ilk" />
33
+ <file src="$nugetroot$\ARM64\Debug\React.Windows.Desktop.Test.DLL\React.Windows.Desktop.Test.**" target="lib\debug\ARM64" exclude="**\*.iobj;**\*.ipdb;**\*.exp;**\*.ilk" />
34
+ <file src="$nugetroot$\x86\Release\React.Windows.Desktop.Test.DLL\React.Windows.Desktop.Test.**" target="lib\ship\x86" exclude="**\*.iobj;**\*.ipdb;**\*.exp;**\*.ilk" />
35
+ <file src="$nugetroot$\x64\Release\React.Windows.Desktop.Test.DLL\React.Windows.Desktop.Test.**" target="lib\ship\x64" exclude="**\*.iobj;**\*.ipdb;**\*.exp;**\*.ilk" />
36
+ <file src="$nugetroot$\ARM64\Release\React.Windows.Desktop.Test.DLL\React.Windows.Desktop.Test.**" target="lib\ship\ARM64" exclude="**\*.iobj;**\*.ipdb;**\*.exp;**\*.ilk" />
35
37
 
36
38
  <file src="$nugetroot$\inc\callinvoker\ReactCommon\CallInvoker.h" target="inc\ReactCommon"/>
37
39
  <file src="$nugetroot$\inc\runtimeexecutor\ReactCommon\RuntimeExecutor.h" target="inc\ReactCommon"/>
@@ -88,4 +88,83 @@ void MessageDispatchQueue::quitSynchronous() {
88
88
  }
89
89
  }
90
90
 
91
+ //=============================================================================================
92
+ // MessageDispatchQueue2 implementation.
93
+ //=============================================================================================
94
+
95
+ MessageDispatchQueue2::MessageDispatchQueue2(
96
+ Mso::React::IDispatchQueue2 &dispatchQueue,
97
+ Mso::Functor<void(const Mso::ErrorCode &)> &&errorHandler,
98
+ Mso::Promise<void> &&whenQuit) noexcept
99
+ : m_stopped{false},
100
+ m_errorHandler{std::move(errorHandler)},
101
+ m_whenQuit{std::move(whenQuit)},
102
+ m_dispatchQueue{&dispatchQueue} {}
103
+
104
+ MessageDispatchQueue2::~MessageDispatchQueue2() noexcept {}
105
+
106
+ void MessageDispatchQueue2::runOnQueue(std::function<void()> &&func) {
107
+ if (m_stopped) {
108
+ return;
109
+ }
110
+
111
+ m_dispatchQueue->Post([pThis = shared_from_this(), func = std::move(func)]() noexcept {
112
+ if (!pThis->m_stopped) {
113
+ pThis->tryFunc(func);
114
+ }
115
+ });
116
+ }
117
+
118
+ void MessageDispatchQueue2::tryFunc(const std::function<void()> &func) noexcept {
119
+ try {
120
+ func();
121
+ } catch (const std::exception & /*ex*/) {
122
+ if (auto errorHandler = m_errorHandler.Get()) {
123
+ errorHandler->Invoke(Mso::ExceptionErrorProvider().MakeErrorCode(std::current_exception()));
124
+ }
125
+ }
126
+ }
127
+
128
+ void MessageDispatchQueue2::runSync(const Mso::VoidFunctorRef &func) noexcept {
129
+ Mso::ManualResetEvent callbackFinished{};
130
+
131
+ m_dispatchQueue->InvokeElsePost(Mso::MakeDispatchTask(
132
+ /*callback:*/
133
+ [&func, &callbackFinished]() noexcept {
134
+ func();
135
+ callbackFinished.Set();
136
+ },
137
+ /*onCancel:*/ [&func, &callbackFinished]() noexcept { callbackFinished.Set(); }));
138
+
139
+ callbackFinished.Wait();
140
+ }
141
+
142
+ // runOnQueueSync and quitSynchronous are dangerous. They should only be
143
+ // used for initialization and cleanup.
144
+ void MessageDispatchQueue2::runOnQueueSync(std::function<void()> &&func) {
145
+ if (m_stopped) {
146
+ return;
147
+ }
148
+
149
+ runSync([this, &func]() noexcept {
150
+ if (!m_stopped) {
151
+ tryFunc(func);
152
+ }
153
+ });
154
+ }
155
+
156
+ // Once quitSynchronous() returns, no further work should run on the queue.
157
+ void MessageDispatchQueue2::quitSynchronous() {
158
+ m_stopped = true;
159
+ runSync([]() noexcept {});
160
+
161
+ if (m_whenQuit) {
162
+ m_dispatchQueue->Post([sharedThis = shared_from_this()]() noexcept {
163
+ if (auto thisPtr = sharedThis.get()) {
164
+ thisPtr->m_whenQuit.SetValue();
165
+ }
166
+ });
167
+ }
168
+ }
169
+
91
170
  } // namespace Mso::React
@@ -3,6 +3,7 @@
3
3
 
4
4
  #pragma once
5
5
 
6
+ #include <IReactDispatcher.h>
6
7
  #include <cxxreact/MessageQueueThread.h>
7
8
  #include <functional/FunctorRef.h>
8
9
  #include <future/Future.h>
@@ -43,4 +44,34 @@ struct MessageDispatchQueue : facebook::react::MessageQueueThread, std::enable_s
43
44
  const Mso::Promise<void> m_whenQuit;
44
45
  };
45
46
 
47
+ struct MessageDispatchQueue2 : facebook::react::MessageQueueThread,
48
+ std::enable_shared_from_this<MessageDispatchQueue2> {
49
+ MessageDispatchQueue2(
50
+ Mso::React::IDispatchQueue2 &dispatchQueue,
51
+ Mso::Functor<void(const Mso::ErrorCode &)> &&errorHandler,
52
+ Mso::Promise<void> &&whenQuit = nullptr) noexcept;
53
+
54
+ ~MessageDispatchQueue2() noexcept override;
55
+
56
+ public: // FastMessageQueueThread implementation
57
+ void runOnQueue(std::function<void()> &&func) override;
58
+
59
+ // runOnQueueSync and quitSynchronous are dangerous. They should only be
60
+ // used for initialization and cleanup.
61
+ void runOnQueueSync(std::function<void()> &&func) override;
62
+
63
+ // Once quitSynchronous() returns, no further work should run on the queue.
64
+ void quitSynchronous() override;
65
+
66
+ private:
67
+ void runSync(const Mso::VoidFunctorRef &func) noexcept;
68
+ void tryFunc(const std::function<void()> &func) noexcept;
69
+
70
+ private:
71
+ std::atomic<bool> m_stopped;
72
+ Mso::CntPtr<Mso::React::IDispatchQueue2> m_dispatchQueue;
73
+ Mso::Functor<void(const Mso::ErrorCode &)> m_errorHandler;
74
+ const Mso::Promise<void> m_whenQuit;
75
+ };
76
+
46
77
  } // namespace Mso::React
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-windows",
3
- "version": "0.65.3",
3
+ "version": "0.65.7",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -25,7 +25,7 @@
25
25
  "@react-native-community/cli": "^6.0.0",
26
26
  "@react-native-community/cli-platform-android": "^6.0.0",
27
27
  "@react-native-community/cli-platform-ios": "^6.0.0",
28
- "@react-native-windows/cli": "0.65.0",
28
+ "@react-native-windows/cli": "0.65.2",
29
29
  "@react-native/assets": "1.0.0",
30
30
  "@react-native/normalize-color": "1.0.0",
31
31
  "@react-native/polyfills": "1.0.0",
@@ -55,7 +55,7 @@
55
55
  "ws": "^6.1.4"
56
56
  },
57
57
  "devDependencies": {
58
- "@react-native-windows/codegen": "0.65.0",
58
+ "@react-native-windows/codegen": "0.65.1",
59
59
  "@rnw-scripts/eslint-config": "1.1.6",
60
60
  "@types/node": "^14.14.22",
61
61
  "@types/react": "16.9.11",
@@ -78,7 +78,7 @@
78
78
  "react-native": "^0.65.0"
79
79
  },
80
80
  "beachball": {
81
- "defaultNpmTag": "latest",
81
+ "defaultNpmTag": "v0.65-stable",
82
82
  "gitTags": true,
83
83
  "disallowedChangeTypes": [
84
84
  "major",