react-native-windows 0.0.0-canary.554 → 0.0.0-canary.556

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.
@@ -133,7 +133,9 @@ void DeviceInfoHolder::SetCallback(
133
133
  Mso::Functor<void(React::JSValueObject &&)> &&callback) noexcept {
134
134
  auto holder = propertyBag.Get(DeviceInfoHolderPropertyId());
135
135
 
136
- (*holder)->m_notifyCallback = std::move(callback);
136
+ if (holder) {
137
+ (*holder)->m_notifyCallback = std::move(callback);
138
+ }
137
139
  }
138
140
 
139
141
  void DeviceInfoHolder::updateDeviceInfo() noexcept {
@@ -13,6 +13,11 @@
13
13
  #include <UI.Xaml.Media.Imaging.h>
14
14
  #include <Views/Image/ReactImage.h>
15
15
  #include <cxxreact/JsArgumentHelpers.h>
16
+ #ifdef USE_FABRIC
17
+ #include <Utils/Helpers.h>
18
+ #include <wincodec.h>
19
+ #include "XamlUtils.h"
20
+ #endif // USE_FABRIC
16
21
  #include <winrt/Windows.Storage.Streams.h>
17
22
  #include "Unicode.h"
18
23
 
@@ -24,11 +29,21 @@ using namespace xaml::Media::Imaging;
24
29
 
25
30
  namespace Microsoft::ReactNative {
26
31
 
32
+ #ifdef USE_FABRIC
33
+ winrt::com_ptr<IWICBitmapSource> wicBitmapSourceFromStream(
34
+ const winrt::Windows::Storage::Streams::IRandomAccessStream &results) noexcept;
35
+ #endif // USE_FABRIC
36
+
27
37
  winrt::fire_and_forget GetImageSizeAsync(
28
38
  std::string uriString,
29
39
  winrt::Microsoft::ReactNative::JSValue &&headers,
30
40
  Mso::Functor<void(int32_t width, int32_t height)> successCallback,
31
- Mso::Functor<void()> errorCallback) {
41
+ Mso::Functor<void()> errorCallback
42
+ #ifdef USE_FABRIC
43
+ ,
44
+ bool useFabric
45
+ #endif // USE_FABRIC
46
+ ) {
32
47
  bool succeeded{false};
33
48
 
34
49
  try {
@@ -52,15 +67,27 @@ winrt::fire_and_forget GetImageSizeAsync(
52
67
  memoryStream = co_await GetImageInlineDataAsync(source);
53
68
  }
54
69
 
55
- winrt::BitmapImage bitmap;
56
- if (memoryStream) {
57
- co_await bitmap.SetSourceAsync(memoryStream);
58
- }
59
-
60
- if (bitmap) {
61
- successCallback(bitmap.PixelWidth(), bitmap.PixelHeight());
62
- succeeded = true;
70
+ #ifdef USE_FABRIC
71
+ if (!useFabric) {
72
+ #endif // USE_FABRIC
73
+ winrt::BitmapImage bitmap;
74
+ if (memoryStream) {
75
+ co_await bitmap.SetSourceAsync(memoryStream);
76
+ }
77
+ if (bitmap) {
78
+ successCallback(bitmap.PixelWidth(), bitmap.PixelHeight());
79
+ succeeded = true;
80
+ }
81
+ #ifdef USE_FABRIC
82
+ } else {
83
+ UINT width, height;
84
+ auto wicBmpSource = wicBitmapSourceFromStream(memoryStream);
85
+ if (SUCCEEDED(wicBmpSource->GetSize(&width, &height))) {
86
+ successCallback(width, height);
87
+ succeeded = true;
88
+ }
63
89
  }
90
+ #endif // USE_FABRIC
64
91
  } catch (winrt::hresult_error const &) {
65
92
  }
66
93
 
@@ -96,7 +123,12 @@ void ImageLoader::getSizeWithHeaders(
96
123
  },
97
124
  [result, context]() noexcept {
98
125
  context.JSDispatcher().Post([result = std::move(result)]() noexcept { result.Reject("Failed"); });
99
- });
126
+ }
127
+ #ifdef USE_FABRIC
128
+ ,
129
+ IsFabricEnabled(context.Properties().Handle())
130
+ #endif // USE_FABRIC
131
+ );
100
132
  });
101
133
  }
102
134
 
@@ -8,11 +8,23 @@
8
8
  #include "ReactHost/ReactInstanceWin.h"
9
9
  #include "ReactNativeHost.h"
10
10
  #include "Utils/Helpers.h"
11
+ #include "XamlUtils.h"
11
12
 
13
+ #ifdef USE_FABRIC
14
+ #include <Fabric/Composition/CompositionContextHelper.h>
15
+ #include <Fabric/Composition/CompositionUIService.h>
16
+ #include <winrt/Windows.UI.Composition.h>
17
+ #endif
12
18
  #include <UI.Xaml.Controls.Primitives.h>
13
19
 
14
20
  namespace Microsoft::ReactNative {
15
21
 
22
+ #ifdef USE_FABRIC
23
+ constexpr PCWSTR c_logBoxWindowClassName = L"MS_REACTNATIVE_LOGBOX";
24
+ constexpr auto CompHostProperty = L"CompHost";
25
+ const int LOGBOX_DEFAULT_WIDTH = 700;
26
+ const int LOGBOX_DEFAULT_HEIGHT = 1000;
27
+ #endif // USE_FABRIC
16
28
  void LogBox::Show() noexcept {
17
29
  if (!Mso::React::ReactOptions::UseDeveloperSupport(m_context.Properties().Handle())) {
18
30
  return;
@@ -33,59 +45,163 @@ void LogBox::Hide() noexcept {
33
45
  });
34
46
  }
35
47
 
48
+ #ifdef USE_FABRIC
49
+ LRESULT CALLBACK LogBoxWndProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam) noexcept {
50
+ auto data = reinterpret_cast<::IUnknown *>(GetProp(hwnd, CompHostProperty));
51
+ winrt::com_ptr<winrt::IUnknown> spunk;
52
+ React::CompositionHwndHost host{nullptr};
53
+
54
+ if (data) {
55
+ winrt::check_hresult(data->QueryInterface(winrt::guid_of<React::CompositionHwndHost>(), winrt::put_abi(host)));
56
+ auto result = static_cast<LRESULT>(host.TranslateMessage(message, wparam, lparam));
57
+ if (result)
58
+ return result;
59
+ }
60
+
61
+ switch (message) {
62
+ case WM_NCCREATE: {
63
+ auto cs = reinterpret_cast<CREATESTRUCT *>(lparam);
64
+ auto windowData = static_cast<::IUnknown *>(cs->lpCreateParams);
65
+ SetProp(hwnd, CompHostProperty, reinterpret_cast<::IUnknown *>(windowData));
66
+ break;
67
+ }
68
+ case WM_CREATE: {
69
+ host.Initialize((uint64_t)hwnd);
70
+ break;
71
+ }
72
+ case WM_CLOSE: {
73
+ // Just hide the window instead of destroying it
74
+ ::ShowWindow(hwnd, SW_HIDE);
75
+ return 0;
76
+ }
77
+ case WM_DESTROY: {
78
+ data->Release();
79
+ SetProp(hwnd, CompHostProperty, nullptr);
80
+ }
81
+ }
82
+
83
+ return DefWindowProc(hwnd, message, wparam, lparam);
84
+ }
85
+
86
+ void LogBox::RegisterWndClass() noexcept {
87
+ static bool registered = false;
88
+ if (registered)
89
+ return;
90
+
91
+ HINSTANCE hInstance = GetModuleHandle(NULL);
92
+
93
+ WNDCLASSEXW wcex = {};
94
+ wcex.cbSize = sizeof(WNDCLASSEX);
95
+ wcex.style = CS_HREDRAW | CS_VREDRAW;
96
+ wcex.lpfnWndProc = &LogBoxWndProc;
97
+ wcex.cbClsExtra = DLGWINDOWEXTRA;
98
+ wcex.cbWndExtra = sizeof(winrt::impl::abi<winrt::Microsoft::ReactNative::ICompositionHwndHost>::type *);
99
+ wcex.hInstance = hInstance;
100
+ wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
101
+ wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
102
+ wcex.lpszClassName = c_logBoxWindowClassName;
103
+ ATOM classId = RegisterClassEx(&wcex);
104
+ WINRT_VERIFY(classId);
105
+ winrt::check_win32(!classId);
106
+
107
+ registered = true;
108
+ }
109
+ #endif // USE_FABRIC
110
+
36
111
  void LogBox::ShowOnUIThread() noexcept {
37
112
  auto host = React::implementation::ReactNativeHost::GetReactNativeHost(m_context.Properties());
38
113
  if (!host)
39
114
  return;
40
115
 
41
- m_logBoxContent = React::ReactRootView();
42
- m_logBoxContent.ComponentName(L"LogBox");
43
- m_logBoxContent.ReactNativeHost(host);
116
+ if (!IsFabricEnabled(m_context.Properties().Handle())) {
117
+ m_logBoxContent = React::ReactRootView();
118
+ m_logBoxContent.ComponentName(L"LogBox");
119
+ m_logBoxContent.ReactNativeHost(host);
44
120
 
45
- m_popup = xaml::Controls::Primitives::Popup{};
46
- xaml::FrameworkElement root{nullptr};
121
+ m_popup = xaml::Controls::Primitives::Popup{};
122
+ xaml::FrameworkElement root{nullptr};
47
123
 
48
- if (Is19H1OrHigher()) {
49
- // XamlRoot added in 19H1 - is required to be set for XamlIsland scenarios
50
- if (auto xamlRoot = React::XamlUIService::GetXamlRoot(m_context.Properties().Handle())) {
51
- m_popup.XamlRoot(xamlRoot);
52
- root = xamlRoot.Content().as<xaml::FrameworkElement>();
124
+ if (Is19H1OrHigher()) {
125
+ // XamlRoot added in 19H1 - is required to be set for XamlIsland scenarios
126
+ if (auto xamlRoot = React::XamlUIService::GetXamlRoot(m_context.Properties().Handle())) {
127
+ m_popup.XamlRoot(xamlRoot);
128
+ root = xamlRoot.Content().as<xaml::FrameworkElement>();
129
+ }
53
130
  }
54
- }
55
131
 
56
- if (!root) {
57
- auto window = xaml::Window::Current();
58
- root = window.Content().as<xaml::FrameworkElement>();
132
+ if (!root) {
133
+ auto window = xaml::Window::Current();
134
+ root = window.Content().as<xaml::FrameworkElement>();
135
+ }
136
+
137
+ m_logBoxContent.MaxHeight(root.ActualHeight());
138
+ m_logBoxContent.Height(root.ActualHeight());
139
+ m_logBoxContent.MaxWidth(root.ActualWidth());
140
+ m_logBoxContent.Width(root.ActualWidth());
141
+ m_logBoxContent.UpdateLayout();
142
+
143
+ m_sizeChangedRevoker = root.SizeChanged(
144
+ winrt::auto_revoke,
145
+ [wkThis = weak_from_this()](auto const & /*sender*/, xaml::SizeChangedEventArgs const &args) {
146
+ if (auto strongThis = wkThis.lock()) {
147
+ strongThis->m_logBoxContent.MaxHeight(args.NewSize().Height);
148
+ strongThis->m_logBoxContent.Height(args.NewSize().Height);
149
+ strongThis->m_logBoxContent.MaxWidth(args.NewSize().Width);
150
+ strongThis->m_logBoxContent.Width(args.NewSize().Width);
151
+ }
152
+ });
153
+
154
+ m_tokenClosed = m_popup.Closed(
155
+ [wkThis = weak_from_this()](auto const & /*sender*/, winrt::IInspectable const & /*args*/) noexcept {
156
+ if (auto strongThis = wkThis.lock()) {
157
+ strongThis->HideOnUIThread();
158
+ }
159
+ });
160
+
161
+ m_popup.Child(m_logBoxContent);
162
+ m_popup.IsOpen(true);
59
163
  }
164
+ #ifdef USE_FABRIC
165
+ else {
166
+ RegisterWndClass();
167
+
168
+ if (!m_hwnd) {
169
+ auto CompositionHwndHost = React::CompositionHwndHost();
170
+ CompositionHwndHost.ComponentName(L"LogBox");
171
+ CompositionHwndHost.ReactNativeHost(host);
172
+ HINSTANCE hInstance = GetModuleHandle(NULL);
173
+ winrt::impl::abi<winrt::Microsoft::ReactNative::ICompositionHwndHost>::type *pHost{nullptr};
174
+ winrt::com_ptr<::IUnknown> spunk;
175
+ CompositionHwndHost.as(spunk);
176
+ spunk->AddRef(); // Will be stored in windowData
177
+
178
+ m_hwnd = CreateWindow(
179
+ c_logBoxWindowClassName,
180
+ L"React-Native LogBox",
181
+ WS_OVERLAPPEDWINDOW,
182
+ CW_USEDEFAULT,
183
+ CW_USEDEFAULT,
184
+ LOGBOX_DEFAULT_WIDTH,
185
+ LOGBOX_DEFAULT_HEIGHT,
186
+ nullptr,
187
+ nullptr,
188
+ hInstance,
189
+ spunk.get());
190
+ }
60
191
 
61
- m_logBoxContent.MaxHeight(root.ActualHeight());
62
- m_logBoxContent.Height(root.ActualHeight());
63
- m_logBoxContent.MaxWidth(root.ActualWidth());
64
- m_logBoxContent.Width(root.ActualWidth());
65
- m_logBoxContent.UpdateLayout();
66
-
67
- m_sizeChangedRevoker = root.SizeChanged(
68
- winrt::auto_revoke, [wkThis = weak_from_this()](auto const & /*sender*/, xaml::SizeChangedEventArgs const &args) {
69
- if (auto strongThis = wkThis.lock()) {
70
- strongThis->m_logBoxContent.MaxHeight(args.NewSize().Height);
71
- strongThis->m_logBoxContent.Height(args.NewSize().Height);
72
- strongThis->m_logBoxContent.MaxWidth(args.NewSize().Width);
73
- strongThis->m_logBoxContent.Width(args.NewSize().Width);
74
- }
75
- });
76
-
77
- m_tokenClosed = m_popup.Closed(
78
- [wkThis = weak_from_this()](auto const & /*sender*/, winrt::IInspectable const & /*args*/) noexcept {
79
- if (auto strongThis = wkThis.lock()) {
80
- strongThis->HideOnUIThread();
81
- }
82
- });
83
-
84
- m_popup.Child(m_logBoxContent);
85
- m_popup.IsOpen(true);
192
+ ShowWindow(m_hwnd, SW_NORMAL);
193
+ BringWindowToTop(m_hwnd);
194
+ SetFocus(m_hwnd);
195
+ }
196
+ #endif // USE_FABRIC
86
197
  }
87
198
 
88
199
  void LogBox::HideOnUIThread() noexcept {
200
+ #ifdef USE_FABRIC
201
+ if (m_hwnd) {
202
+ ::ShowWindow(m_hwnd, SW_HIDE);
203
+ }
204
+ #endif // USE_FABRIC
89
205
  if (m_popup) {
90
206
  m_popup.Closed(m_tokenClosed);
91
207
  m_sizeChangedRevoker.revoke();
@@ -21,10 +21,16 @@ struct LogBox : public std::enable_shared_from_this<LogBox> {
21
21
  REACT_METHOD(Hide, L"hide") void Hide() noexcept;
22
22
 
23
23
  private:
24
+ #ifdef USE_FABRIC
25
+ static void RegisterWndClass() noexcept;
26
+ #endif // USE_FABRIC
24
27
  void ShowOnUIThread() noexcept;
25
28
  void HideOnUIThread() noexcept;
26
29
 
27
30
  React::ReactContext m_context;
31
+ #ifdef USE_FABRIC
32
+ HWND m_hwnd{nullptr};
33
+ #endif // USE_FABRIC
28
34
  xaml::Controls::Primitives::Popup m_popup{nullptr};
29
35
  React::ReactRootView m_logBoxContent{nullptr};
30
36
  xaml::FrameworkElement::SizeChanged_revoker m_sizeChangedRevoker;
@@ -202,25 +202,6 @@ int64_t NativeUIManager::AddMeasuredRootView(facebook::react::IReactRootView *ro
202
202
 
203
203
  m_host->RegisterRootView(rootView, tag, width, height);
204
204
 
205
- // TODO: call UpdateRootNodeSize when ReactRootView size changes
206
- /*var resizeCount = 0;
207
- rootView.SetOnSizeChangedListener((sender, args) =>
208
- {
209
- var currentCount = ++resizeCount;
210
- var newWidth = args.NewSize.Width;
211
- var newHeight = args.NewSize.Height;
212
-
213
- Context.RunOnNativeModulesQueueThread(() =>
214
- {
215
- if (currentCount == resizeCount)
216
- {
217
- Context.AssertOnNativeModulesQueueThread();
218
- _uiImplementation.UpdateRootNodeSize(tag, newWidth, newHeight,
219
- _eventDispatcher);
220
- }
221
- });
222
- });*/
223
-
224
205
  return tag;
225
206
  }
226
207
 
@@ -798,7 +798,10 @@ std::shared_ptr<IRedBoxHandler> ReactInstanceWin::GetRedBoxHandler() noexcept {
798
798
  #ifndef CORE_ABI
799
799
  } else if (UseDeveloperSupport()) {
800
800
  auto localWkReactHost = m_weakReactHost;
801
- return CreateDefaultRedBoxHandler(std::move(localWkReactHost), *m_uiQueue);
801
+ return CreateDefaultRedBoxHandler(
802
+ winrt::Microsoft::ReactNative::ReactPropertyBag(m_reactContext->Properties()),
803
+ std::move(localWkReactHost),
804
+ *m_uiQueue);
802
805
  #endif
803
806
  } else {
804
807
  return {};
@@ -979,12 +982,9 @@ void ReactInstanceWin::AttachMeasuredRootView(
979
982
  facebook::react::IReactRootView *rootView,
980
983
  const winrt::Microsoft::ReactNative::JSValueArgWriter &initialProps,
981
984
  bool useFabric) noexcept {
982
- #ifndef CORE_ABI
983
985
  if (State() == ReactInstanceState::HasError)
984
986
  return;
985
987
 
986
- int64_t rootTag = -1;
987
-
988
988
  #ifdef USE_FABRIC
989
989
  if (useFabric && !m_useWebDebugger) {
990
990
  auto uiManager = ::Microsoft::ReactNative::FabricUIManager::FromProperties(
@@ -993,10 +993,12 @@ void ReactInstanceWin::AttachMeasuredRootView(
993
993
  auto rootTag = Microsoft::ReactNative::getNextRootViewTag();
994
994
  rootView->SetTag(rootTag);
995
995
  uiManager->startSurface(rootView, rootTag, rootView->JSComponentName(), DynamicWriter::ToDynamic(initialProps));
996
-
997
- } else
996
+ }
998
997
  #endif
999
- {
998
+ #ifndef CORE_ABI
999
+ if (!useFabric || m_useWebDebugger) {
1000
+ int64_t rootTag = -1;
1001
+
1000
1002
  if (auto uiManager = Microsoft::ReactNative::GetNativeUIManager(*m_reactContext).lock()) {
1001
1003
  rootTag = uiManager->AddMeasuredRootView(rootView);
1002
1004
  rootView->SetTag(rootTag);
@@ -2,6 +2,7 @@
2
2
  // Licensed under the MIT License.
3
3
  #include "pch.h"
4
4
  #include "RedBox.h"
5
+ #include <ReactPropertyBag.h>
5
6
  #include <boost/algorithm/string.hpp>
6
7
  #include <functional/functor.h>
7
8
  #include <regex>
@@ -14,6 +15,12 @@
14
15
  #include <winrt/Windows.Foundation.h>
15
16
 
16
17
  #ifndef CORE_ABI
18
+
19
+ #ifdef USE_FABRIC
20
+ #include <Shobjidl.h>
21
+ #include <Utils/Helpers.h>
22
+ #include <winrt/Windows.UI.Popups.h>
23
+ #endif // USE_FABRIC
17
24
  #include <UI.Xaml.Controls.Primitives.h>
18
25
  #include <UI.Xaml.Controls.h>
19
26
  #include <UI.Xaml.Documents.h>
@@ -27,8 +34,8 @@
27
34
  #include <winrt/Windows.Web.Http.h>
28
35
  #include "CppWinRTIncludes.h"
29
36
  #include "Utils/Helpers.h"
37
+ #endif // CORE_ABI
30
38
  #include "XamlUtils.h"
31
- #endif
32
39
 
33
40
  using namespace winrt::Windows::Foundation;
34
41
 
@@ -39,17 +46,21 @@ using IInspectable = winrt::Windows::Foundation::IInspectable;
39
46
  #ifndef CORE_ABI
40
47
  struct RedBox : public std::enable_shared_from_this<RedBox> {
41
48
  RedBox(
49
+ winrt::Microsoft::ReactNative::ReactPropertyBag &propBag,
42
50
  const Mso::WeakPtr<IReactHost> &weakReactHost,
43
51
  Mso::Functor<void(uint32_t)> &&onClosedCallback,
44
52
  ErrorInfo &&errorInfo) noexcept
45
53
  : m_weakReactHost(weakReactHost),
54
+ m_propBag(propBag),
46
55
  m_onClosedCallback(std::move(onClosedCallback)),
47
56
  m_errorInfo(std::move(errorInfo)) {}
48
57
 
49
58
  void Dismiss() noexcept {
59
+ #ifdef USE_FABRIC
50
60
  if (m_popup) {
51
61
  m_popup.IsOpen(false);
52
62
  }
63
+ #endif // USE_FABRIC
53
64
  }
54
65
 
55
66
  void Reload() noexcept {
@@ -67,8 +78,36 @@ struct RedBox : public std::enable_shared_from_this<RedBox> {
67
78
  }
68
79
  }
69
80
 
70
- void ShowNewJSError() noexcept {
71
- m_showing = true;
81
+ #ifdef USE_FABRIC
82
+ void ShowNewJsErrorUsingMessageDialog() noexcept {
83
+ // Using MessageDialog is "easy", but it does mean we cannot update the message when symbols are resolved.
84
+ // Ideally we'd have a dialog we could push UI updates to. -- Maybe we could load XAML and host the XAML dialog?
85
+
86
+ std::stringstream ss;
87
+ ss << m_errorInfo.Message;
88
+ ss << std::endl << std::endl;
89
+ for (auto frame : m_errorInfo.Callstack) {
90
+ ss << frame.Method << "\n" << frame.File << ":" << frame.Line << ":" << frame.Column << std::endl;
91
+ }
92
+
93
+ auto msg = winrt::Windows::UI::Popups::MessageDialog(winrt::to_hstring(ss.str()), L"React Native Error");
94
+ auto hwnd = reinterpret_cast<HWND>(
95
+ *m_propBag.Get(winrt::Microsoft::ReactNative::ReactPropertyId<uint64_t>(L"RootHwndForDevUI")));
96
+ auto initializeWithWindow{msg.as<::IInitializeWithWindow>()};
97
+ initializeWithWindow->Initialize(hwnd);
98
+ msg.Commands().Append(
99
+ winrt::Windows::UI::Popups::UICommand(L"Dismiss", [](winrt::Windows::UI::Popups::IUICommand const &command){}));
100
+ msg.Commands().Append(winrt::Windows::UI::Popups::UICommand(
101
+ L"Reload", [wkHost = m_weakReactHost](winrt::Windows::UI::Popups::IUICommand const &command) {
102
+ if (auto reactHost = wkHost.GetStrongPtr()) {
103
+ reactHost->ReloadInstance();
104
+ }
105
+ }));
106
+ msg.ShowAsync();
107
+ }
108
+ #endif USE_FABRIC
109
+
110
+ void ShowNewJSErrorUsingXaml() noexcept {
72
111
  m_popup = xaml::Controls::Primitives::Popup{};
73
112
 
74
113
  const winrt::hstring xamlString =
@@ -166,6 +205,19 @@ struct RedBox : public std::enable_shared_from_this<RedBox> {
166
205
  m_popup.IsOpen(true);
167
206
  }
168
207
 
208
+ void ShowNewJSError() noexcept {
209
+ m_showing = true;
210
+
211
+ #ifdef USE_FABRIC
212
+ if (Microsoft::ReactNative::IsFabricEnabled(m_propBag.Handle())) {
213
+ ShowNewJsErrorUsingMessageDialog();
214
+ } else
215
+ #endif // USE_FABRIC
216
+ {
217
+ ShowNewJSErrorUsingXaml();
218
+ }
219
+ }
220
+
169
221
  void UpdateError(const ErrorInfo &&info) noexcept {
170
222
  m_errorInfo = std::move(info);
171
223
  if (m_showing) {
@@ -328,6 +380,9 @@ struct RedBox : public std::enable_shared_from_this<RedBox> {
328
380
  }
329
381
 
330
382
  void PopulateFrameStackUI() noexcept {
383
+ if (!m_stackPanel)
384
+ return;
385
+
331
386
  m_stackPanel.Children().Clear();
332
387
  for (const auto &frame : m_errorInfo.Callstack) {
333
388
  const winrt::hstring xamlFrameString =
@@ -396,12 +451,14 @@ struct RedBox : public std::enable_shared_from_this<RedBox> {
396
451
  xaml::Controls::TextBlock m_errorMessageText{nullptr};
397
452
  xaml::Controls::TextBlock m_errorStackText{nullptr};
398
453
 
399
- bool m_showing = false;
400
- Mso::Functor<void(uint32_t)> m_onClosedCallback;
401
454
  xaml::FrameworkElement::SizeChanged_revoker m_sizeChangedRevoker;
402
455
  winrt::event_token m_tokenClosed;
403
456
  winrt::event_token m_tokenDismiss;
404
457
  winrt::event_token m_tokenReload;
458
+
459
+ winrt::Microsoft::ReactNative::ReactPropertyBag m_propBag;
460
+ bool m_showing = false;
461
+ Mso::Functor<void(uint32_t)> m_onClosedCallback;
405
462
  ErrorInfo m_errorInfo;
406
463
  Mso::WeakPtr<IReactHost> m_weakReactHost;
407
464
  };
@@ -411,9 +468,10 @@ struct RedBox : public std::enable_shared_from_this<RedBox> {
411
468
  */
412
469
  struct DefaultRedBoxHandler final : public std::enable_shared_from_this<DefaultRedBoxHandler>, IRedBoxHandler {
413
470
  DefaultRedBoxHandler(
471
+ const winrt::Microsoft::ReactNative::ReactPropertyBag &propBag,
414
472
  Mso::WeakPtr<Mso::React::IReactHost> &&weakReactHost,
415
473
  const Mso::React::IDispatchQueue2 &uiQueue) noexcept
416
- : m_weakReactHost{std::move(weakReactHost)}, m_uiQueue{&uiQueue} {}
474
+ : m_weakReactHost{std::move(weakReactHost)}, m_uiQueue{&uiQueue}, m_propBag(propBag) {}
417
475
 
418
476
  ~DefaultRedBoxHandler() {
419
477
  // Hide any currently showing redBoxes
@@ -441,6 +499,7 @@ struct DefaultRedBoxHandler final : public std::enable_shared_from_this<DefaultR
441
499
  }
442
500
 
443
501
  std::shared_ptr<RedBox> redbox(std::make_shared<RedBox>(
502
+ m_propBag,
444
503
  m_weakReactHost,
445
504
  [wkthis = std::weak_ptr(shared_from_this())](uint32_t id) {
446
505
  if (auto pthis = wkthis.lock()) {
@@ -532,12 +591,13 @@ struct DefaultRedBoxHandler final : public std::enable_shared_from_this<DefaultR
532
591
 
533
592
  private:
534
593
  Mso::CntPtr<const Mso::React::IDispatchQueue2> m_uiQueue;
594
+ winrt::Microsoft::ReactNative::ReactPropertyBag m_propBag;
535
595
  bool m_showingRedBox{false}; // Access from UI Thread only
536
596
  std::mutex m_lockRedBox;
537
597
  std::vector<std::shared_ptr<RedBox>> m_redBoxes; // Protected by m_lockRedBox
538
598
  const Mso::WeakPtr<IReactHost> m_weakReactHost;
539
599
  };
540
- #endif
600
+ #endif // CORE_ABI
541
601
 
542
602
  struct RedBoxHandler final : public Mso::React::IRedBoxHandler {
543
603
  RedBoxHandler(winrt::Microsoft::ReactNative::IRedBoxHandler const &redBoxHandler) : m_redBoxHandler(redBoxHandler) {}
@@ -578,10 +638,11 @@ std::shared_ptr<IRedBoxHandler> CreateRedBoxHandler(
578
638
  }
579
639
 
580
640
  std::shared_ptr<IRedBoxHandler> CreateDefaultRedBoxHandler(
641
+ const winrt::Microsoft::ReactNative::ReactPropertyBag &propBag,
581
642
  Mso::WeakPtr<IReactHost> &&weakReactHost,
582
643
  const Mso::React::IDispatchQueue2 &uiQueue) noexcept {
583
644
  #ifndef CORE_ABI
584
- return std::make_shared<DefaultRedBoxHandler>(std::move(weakReactHost), uiQueue);
645
+ return std::make_shared<DefaultRedBoxHandler>(propBag, std::move(weakReactHost), uiQueue);
585
646
  #else
586
647
  return nullptr;
587
648
  #endif
@@ -2,6 +2,7 @@
2
2
  // Licensed under the MIT License.
3
3
  #pragma once
4
4
  #include <DevSettings.h>
5
+ #include <ReactPropertyBag.h>
5
6
  #include "IReactDispatcher.h"
6
7
  #include "IRedBoxHandler.h"
7
8
  #include "ReactHost/React.h"
@@ -12,6 +13,7 @@ std::shared_ptr<IRedBoxHandler> CreateRedBoxHandler(
12
13
  winrt::Microsoft::ReactNative::IRedBoxHandler const &redBoxHandler) noexcept;
13
14
 
14
15
  std::shared_ptr<IRedBoxHandler> CreateDefaultRedBoxHandler(
16
+ const winrt::Microsoft::ReactNative::ReactPropertyBag &propBag,
15
17
  Mso::WeakPtr<IReactHost> &&weakReactHost,
16
18
  const Mso::React::IDispatchQueue2 &uiQueue) noexcept;
17
19
  } // namespace Mso::React
@@ -34,7 +34,9 @@ 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::GetUIDispatchQueue2(host.InstanceSettings().Properties()));
37
+ ReactPropertyBag(host.InstanceSettings().Properties()),
38
+ std::move(wkHost),
39
+ *ReactDispatcher::GetUIDispatchQueue2(host.InstanceSettings().Properties()));
38
40
  }
39
41
 
40
42
  void ShowNewError(IRedBoxErrorInfo const &info, RedBoxErrorType type) noexcept {
@@ -12,6 +12,10 @@
12
12
  #include <appmodel.h>
13
13
  #include <processthreadsapi.h>
14
14
 
15
+ #ifdef USE_FABRIC
16
+ #include <Fabric/Composition/CompositionUIService.h>
17
+ #endif // USE_FABRIC
18
+
15
19
  namespace winrt {
16
20
  using namespace xaml::Controls::Primitives;
17
21
  using namespace xaml::Media;
@@ -119,9 +123,10 @@ bool IsWinUI3Island() {
119
123
  #endif
120
124
  }
121
125
 
122
- bool IsFabricEnabled(winrt::Microsoft::ReactNative::IReactPropertyBag const & /*properties*/) {
126
+ bool IsFabricEnabled(winrt::Microsoft::ReactNative::IReactPropertyBag const &properties) {
123
127
  #ifdef USE_FABRIC
124
- return false; // Once we add an instance property to control switching to fabric, this will check that.
128
+ return winrt::Microsoft::ReactNative::Composition::implementation::CompositionUIService::GetCompositionContext(
129
+ properties) != nullptr;
125
130
  #else
126
131
  return false;
127
132
  #endif
@@ -165,6 +165,24 @@ void ViewManagerBase::GetExportedCustomBubblingEventTypeConstants(
165
165
  // Keyboard events
166
166
  L"KeyUp",
167
167
  L"KeyDown",
168
+
169
+ // Pointer events
170
+ L"PointerCancel",
171
+ L"PointerCancelCapture",
172
+ L"PointerDown",
173
+ L"PointerDownCapture",
174
+ L"PointerEnter",
175
+ L"PointerEnterCapture",
176
+ L"PointerLeave",
177
+ L"PointerLeaveCapture",
178
+ L"PointerMove",
179
+ L"PointerMoveCapture",
180
+ L"PointerUp",
181
+ L"PointerUpCapture",
182
+ L"PointerOut",
183
+ L"PointerOutCapture",
184
+ L"PointerOver",
185
+ L"PointerOverCapture",
168
186
  };
169
187
 
170
188
  folly::dynamic bubblingEvents = folly::dynamic::object();
@@ -10,7 +10,7 @@
10
10
  -->
11
11
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
12
12
  <PropertyGroup>
13
- <ReactNativeWindowsVersion>0.0.0-canary.554</ReactNativeWindowsVersion>
13
+ <ReactNativeWindowsVersion>0.0.0-canary.556</ReactNativeWindowsVersion>
14
14
  <ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
15
15
  <ReactNativeWindowsMinor>0</ReactNativeWindowsMinor>
16
16
  <ReactNativeWindowsPatch>0</ReactNativeWindowsPatch>
@@ -44,6 +44,7 @@
44
44
  <file src="$nugetroot$\inc\stubs\**\*.*" target="inc" />
45
45
 
46
46
  <file src="$nugetroot$\inc\Shared\AbiSafe.h" target="inc"/>
47
+ <file src="$nugetroot$\inc\Shared\Composition\CompositionSwitcher.interop.h" target="inc"/>
47
48
  <file src="$nugetroot$\inc\Shared\DevSettings.h" target="inc"/>
48
49
  <file src="$nugetroot$\inc\ReactWin32\INativeUIManagerLegacy.h" target="inc"/>
49
50
  <file src="$nugetroot$\inc\Shared\InstanceManager.h" target="inc"/>
@@ -127,9 +127,6 @@
127
127
  <ClCompile Include="$(MSBuildThisFileDirectory)HermesShim.cpp">
128
128
  <Filter>Source Files</Filter>
129
129
  </ClCompile>
130
- <ClCompile Include="$(MSBuildThisFileDirectory)Modules\BlobModule.cpp">
131
- <Filter>Source Files\Modules</Filter>
132
- </ClCompile>
133
130
  <ClCompile Include="$(MSBuildThisFileDirectory)Modules\HttpModule.cpp">
134
131
  <Filter>Source Files\Modules</Filter>
135
132
  </ClCompile>
@@ -400,15 +397,6 @@
400
397
  <ClInclude Include="$(MSBuildThisFileDirectory)HermesShim.h">
401
398
  <Filter>Header Files</Filter>
402
399
  </ClInclude>
403
- <ClInclude Include="$(MSBuildThisFileDirectory)Modules\IWebSocketModuleContentHandler.h">
404
- <Filter>Header Files\Modules</Filter>
405
- </ClInclude>
406
- <ClInclude Include="$(MSBuildThisFileDirectory)Modules\BlobModule.h">
407
- <Filter>Header Files\Modules</Filter>
408
- </ClInclude>
409
- <ClInclude Include="$(MSBuildThisFileDirectory)Modules\IWebSocketModuleProxy.h">
410
- <Filter>Header Files\Modules</Filter>
411
- </ClInclude>
412
400
  <ClInclude Include="$(MSBuildThisFileDirectory)Modules\HttpModule.h">
413
401
  <Filter>Header Files\Modules</Filter>
414
402
  </ClInclude>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-windows",
3
- "version": "0.0.0-canary.554",
3
+ "version": "0.0.0-canary.556",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",