react-native-windows 0.74.35 → 0.74.37

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 (27) hide show
  1. package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +8 -10
  2. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +4 -1
  3. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +1 -1
  4. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +2 -2
  5. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +5 -2
  6. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +2 -1
  7. package/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp +41 -37
  8. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h +3 -8
  9. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorParser.h +0 -1
  10. package/Microsoft.ReactNative.Cxx/NativeModules.h +9 -0
  11. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  12. package/Shared/Networking/WinRTWebSocketResource.cpp +371 -6
  13. package/Shared/Networking/WinRTWebSocketResource.h +118 -0
  14. package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +6 -6
  15. package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +6 -6
  16. package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +6 -6
  17. package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +6 -6
  18. package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +6 -6
  19. package/codegen/react/components/rnwcore/AndroidSwitch.g.h +6 -6
  20. package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +6 -6
  21. package/codegen/react/components/rnwcore/InputAccessory.g.h +6 -6
  22. package/codegen/react/components/rnwcore/ModalHostView.g.h +6 -6
  23. package/codegen/react/components/rnwcore/PullToRefreshView.g.h +6 -6
  24. package/codegen/react/components/rnwcore/SafeAreaView.g.h +6 -6
  25. package/codegen/react/components/rnwcore/Switch.g.h +6 -6
  26. package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +6 -6
  27. package/package.json +3 -3
@@ -77,14 +77,12 @@ winrt::Microsoft::ReactNative::Color Color::ReadValue(
77
77
  switch (reader.ValueType()) {
78
78
  case JSValueType::Int64: {
79
79
  auto argb = reader.GetInt64();
80
- return winrt::make<Color>(facebook::react::Color{
81
- /*m_isDefined*/ true,
82
- /*color*/
83
- {static_cast<uint8_t>((argb >> 24) & 0xFF),
84
- static_cast<uint8_t>((argb >> 16) & 0xFF),
85
- static_cast<uint8_t>((argb >> 8) & 0xFF),
86
- static_cast<uint8_t>(argb & 0xFF)},
87
- {}});
80
+ return winrt::make<Color>(facebook::react::Color{/*color*/
81
+ {static_cast<uint8_t>((argb >> 24) & 0xFF),
82
+ static_cast<uint8_t>((argb >> 16) & 0xFF),
83
+ static_cast<uint8_t>((argb >> 8) & 0xFF),
84
+ static_cast<uint8_t>(argb & 0xFF)},
85
+ {}});
88
86
  }
89
87
  case JSValueType::Object: {
90
88
  std::vector<std::string> platformColors;
@@ -96,10 +94,10 @@ winrt::Microsoft::ReactNative::Color Color::ReadValue(
96
94
  SkipValue<JSValue>(reader); // Skip this property
97
95
  }
98
96
  }
99
- return winrt::make<Color>(facebook::react::Color{/*m_isDefined*/ true, /*color*/ {}, std::move(platformColors)});
97
+ return winrt::make<Color>(facebook::react::Color{/*color*/ {}, std::move(platformColors)});
100
98
  }
101
99
  default:
102
- return winrt::make<Color>(facebook::react::Color{/*m_isDefined*/ false, /*color*/ {0, 0, 0, 0}, {}});
100
+ return winrt::make<Color>(facebook::react::Color{/*color*/ {0, 0, 0, 0}, {}});
103
101
  }
104
102
  }
105
103
 
@@ -279,7 +279,10 @@ void ComponentView::parent(const winrt::Microsoft::ReactNative::ComponentView &p
279
279
  m_parent = parent;
280
280
  if (!parent) {
281
281
  if (oldRootView && oldRootView->GetFocusedComponent() == *this) {
282
- oldRootView->TrySetFocusedComponent(oldParent, winrt::Microsoft::ReactNative::FocusNavigationDirection::None);
282
+ oldRootView->TrySetFocusedComponent(
283
+ oldParent,
284
+ winrt::Microsoft::ReactNative::FocusNavigationDirection::None,
285
+ true /*forceNoSelectionIfCannotMove*/);
283
286
  }
284
287
  }
285
288
  if (parent) {
@@ -183,7 +183,7 @@ void ComponentView::updateProps(
183
183
  updateShadowProps(oldViewProps, newViewProps);
184
184
  }
185
185
  if (oldViewProps.tooltip != newViewProps.tooltip) {
186
- if (!m_tooltipTracked && newViewProps.tooltip) {
186
+ if (!m_tooltipTracked && newViewProps.tooltip && !newViewProps.tooltip->empty()) {
187
187
  TooltipService::GetCurrent(m_reactContext.Properties())->StartTracking(*this);
188
188
  m_tooltipTracked = true;
189
189
  } else if (m_tooltipTracked && !newViewProps.tooltip) {
@@ -771,7 +771,7 @@ winrt::Windows::Foundation::Size ReactNativeIsland::Measure(
771
771
  facebook::react::LayoutConstraints constraints;
772
772
  ApplyConstraints(layoutConstraints, constraints);
773
773
 
774
- if (m_isInitialized && m_rootTag != -1) {
774
+ if (m_isInitialized && m_rootTag != -1 && m_hasRenderedVisual) {
775
775
  if (auto fabricuiManager = ::Microsoft::ReactNative::FabricUIManager::FromProperties(
776
776
  winrt::Microsoft::ReactNative::ReactPropertyBag(m_context.Properties()))) {
777
777
  facebook::react::LayoutContext context;
@@ -802,7 +802,7 @@ void ReactNativeIsland::Arrange(
802
802
  facebook::react::LayoutConstraints fbLayoutConstraints;
803
803
  ApplyConstraints(layoutConstraints, fbLayoutConstraints);
804
804
 
805
- if (m_isInitialized && m_rootTag != -1 && !m_isFragment) {
805
+ if (m_isInitialized && m_rootTag != -1 && !m_isFragment && m_hasRenderedVisual) {
806
806
  if (auto fabricuiManager = ::Microsoft::ReactNative::FabricUIManager::FromProperties(
807
807
  winrt::Microsoft::ReactNative::ReactPropertyBag(m_context.Properties()))) {
808
808
  facebook::react::LayoutContext context;
@@ -120,7 +120,8 @@ bool RootComponentView::NavigateFocus(const winrt::Microsoft::ReactNative::Focus
120
120
 
121
121
  bool RootComponentView::TrySetFocusedComponent(
122
122
  const winrt::Microsoft::ReactNative::ComponentView &view,
123
- winrt::Microsoft::ReactNative::FocusNavigationDirection direction) noexcept {
123
+ winrt::Microsoft::ReactNative::FocusNavigationDirection direction,
124
+ bool forceNoSelectionIfCannotMove /*= false*/) noexcept {
124
125
  auto target = view;
125
126
  auto selfView = winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(target);
126
127
  if (selfView && !selfView->focusable()) {
@@ -128,7 +129,7 @@ bool RootComponentView::TrySetFocusedComponent(
128
129
  direction == winrt::Microsoft::ReactNative::FocusNavigationDirection::Previous)
129
130
  ? FocusManager::FindLastFocusableElement(target)
130
131
  : FocusManager::FindFirstFocusableElement(target);
131
- if (!target)
132
+ if (!target && !forceNoSelectionIfCannotMove)
132
133
  return false;
133
134
  selfView = winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(target);
134
135
  }
@@ -154,6 +155,8 @@ bool RootComponentView::TrySetFocusedComponent(
154
155
  winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(losingFocusArgs.NewFocusedComponent())
155
156
  ->rootComponentView()
156
157
  ->SetFocusedComponent(gettingFocusArgs.NewFocusedComponent(), direction);
158
+ } else {
159
+ SetFocusedComponent(nullptr, direction);
157
160
  }
158
161
 
159
162
  return true;
@@ -32,7 +32,8 @@ struct RootComponentView : RootComponentViewT<RootComponentView, ViewComponentVi
32
32
  winrt::Microsoft::ReactNative::FocusNavigationDirection direction) noexcept;
33
33
  bool TrySetFocusedComponent(
34
34
  const winrt::Microsoft::ReactNative::ComponentView &view,
35
- winrt::Microsoft::ReactNative::FocusNavigationDirection direction) noexcept;
35
+ winrt::Microsoft::ReactNative::FocusNavigationDirection direction,
36
+ bool forceNoSelectionIfCannotMove = false) noexcept;
36
37
 
37
38
  bool NavigateFocus(const winrt::Microsoft::ReactNative::FocusNavigationRequest &request) noexcept;
38
39
 
@@ -10,6 +10,7 @@
10
10
  #include <react/renderer/core/LayoutConstraints.h>
11
11
  #include <react/renderer/textlayoutmanager/TextLayoutManager.h>
12
12
  #include <winrt/Microsoft.ReactNative.Composition.h>
13
+ #include <winrt/Windows.UI.ViewManagement.h>
13
14
  #include "TextDrawing.h"
14
15
  #include "dwmapi.h"
15
16
 
@@ -49,7 +50,9 @@ facebook::react::AttributedStringBox CreateTooltipAttributedString(const std::st
49
50
  auto fragment = facebook::react::AttributedString::Fragment{};
50
51
  fragment.string = tooltip;
51
52
  fragment.textAttributes.fontSize = tooltipFontSize;
52
- attributedString.appendFragment(fragment);
53
+ fragment.textAttributes.fontSizeMultiplier =
54
+ static_cast<float>(winrt::Windows::UI::ViewManagement::UISettings().TextScaleFactor());
55
+ attributedString.appendFragment(std::move(fragment));
53
56
  return facebook::react::AttributedStringBox{attributedString};
54
57
  }
55
58
 
@@ -231,14 +234,13 @@ void TooltipTracker::OnUnmounted(
231
234
  }
232
235
 
233
236
  void TooltipTracker::ShowTooltip(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
234
- auto viewCompView = view.as<winrt::Microsoft::ReactNative::Composition::ViewComponentView>();
235
-
236
- auto selfView =
237
- winrt::get_self<winrt::Microsoft::ReactNative::Composition::implementation::ViewComponentView>(viewCompView);
238
- auto parentHwnd = selfView->GetHwndForParenting();
239
237
  DestroyTimer();
240
238
 
241
239
  if (!m_hwndTip) {
240
+ auto viewCompView = view.as<winrt::Microsoft::ReactNative::Composition::ViewComponentView>();
241
+ auto selfView =
242
+ winrt::get_self<winrt::Microsoft::ReactNative::Composition::implementation::ViewComponentView>(viewCompView);
243
+ auto parentHwnd = selfView->GetHwndForParenting();
242
244
  auto tooltipData = std::make_unique<TooltipData>(view);
243
245
  tooltipData->attributedString = CreateTooltipAttributedString(*selfView->viewProps()->tooltip);
244
246
 
@@ -256,37 +258,39 @@ void TooltipTracker::ShowTooltip(const winrt::Microsoft::ReactNative::ComponentV
256
258
  facebook::react::TextLayoutManager::GetTextLayout(
257
259
  tooltipData->attributedString, {} /*paragraphAttributes*/, layoutConstraints, tooltipData->textLayout);
258
260
 
259
- DWRITE_TEXT_METRICS tm;
260
- winrt::check_hresult(tooltipData->textLayout->GetMetrics(&tm));
261
-
262
- tooltipData->width =
263
- static_cast<int>(tm.width + ((tooltipHorizontalPadding + tooltipHorizontalPadding) * scaleFactor));
264
- tooltipData->height = static_cast<int>(tm.height + ((tooltipTopPadding + tooltipBottomPadding) * scaleFactor));
265
-
266
- POINT pt = {static_cast<LONG>(m_pos.X), static_cast<LONG>(m_pos.Y)};
267
- ClientToScreen(parentHwnd, &pt);
268
-
269
- RegisterTooltipWndClass();
270
- HINSTANCE hInstance = GetModuleHandle(NULL);
271
- m_hwndTip = CreateWindow(
272
- c_tooltipWindowClassName,
273
- L"Tooltip",
274
- WS_POPUP,
275
- pt.x - tooltipData->width / 2,
276
- static_cast<int>(pt.y - tooltipData->height - (toolTipPlacementMargin * scaleFactor)),
277
- tooltipData->width,
278
- tooltipData->height,
279
- parentHwnd,
280
- NULL,
281
- hInstance,
282
- tooltipData.get());
283
-
284
- DWM_WINDOW_CORNER_PREFERENCE preference = DWMWCP_ROUNDSMALL;
285
- UINT borderThickness = 0;
286
- DwmSetWindowAttribute(m_hwndTip, DWMWA_WINDOW_CORNER_PREFERENCE, &preference, sizeof(preference));
287
-
288
- tooltipData.release();
289
- AnimateWindow(m_hwndTip, toolTipAnimationTimeMs, AW_BLEND);
261
+ if (tooltipData->textLayout) {
262
+ DWRITE_TEXT_METRICS tm;
263
+ winrt::check_hresult(tooltipData->textLayout->GetMetrics(&tm));
264
+
265
+ tooltipData->width =
266
+ static_cast<int>((tm.width + tooltipHorizontalPadding + tooltipHorizontalPadding) * scaleFactor);
267
+ tooltipData->height = static_cast<int>((tm.height + tooltipTopPadding + tooltipBottomPadding) * scaleFactor);
268
+
269
+ POINT pt = {static_cast<LONG>(m_pos.X), static_cast<LONG>(m_pos.Y)};
270
+ ClientToScreen(parentHwnd, &pt);
271
+
272
+ RegisterTooltipWndClass();
273
+ HINSTANCE hInstance = GetModuleHandle(NULL);
274
+ m_hwndTip = CreateWindow(
275
+ c_tooltipWindowClassName,
276
+ L"Tooltip",
277
+ WS_POPUP,
278
+ pt.x - tooltipData->width / 2,
279
+ static_cast<int>(pt.y - tooltipData->height - (toolTipPlacementMargin * scaleFactor)),
280
+ tooltipData->width,
281
+ tooltipData->height,
282
+ parentHwnd,
283
+ NULL,
284
+ hInstance,
285
+ tooltipData.get());
286
+
287
+ DWM_WINDOW_CORNER_PREFERENCE preference = DWMWCP_ROUNDSMALL;
288
+ UINT borderThickness = 0;
289
+ DwmSetWindowAttribute(m_hwndTip, DWMWA_WINDOW_CORNER_PREFERENCE, &preference, sizeof(preference));
290
+
291
+ tooltipData.release();
292
+ AnimateWindow(m_hwndTip, toolTipAnimationTimeMs, AW_BLEND);
293
+ }
290
294
  }
291
295
  }
292
296
 
@@ -12,13 +12,10 @@ namespace facebook::react {
12
12
 
13
13
  struct Color {
14
14
  bool operator==(const Color &otherColor) const {
15
- return m_isUndefined && otherColor.m_isUndefined ||
16
- (m_isUndefined == otherColor.m_isUndefined && m_color == otherColor.m_color &&
17
- m_platformColor == otherColor.m_platformColor);
15
+ return m_color == otherColor.m_color && m_platformColor == otherColor.m_platformColor;
18
16
  }
19
17
  bool operator!=(const Color &otherColor) const {
20
- return m_isUndefined != otherColor.m_isUndefined || m_color != otherColor.m_color ||
21
- m_platformColor != otherColor.m_platformColor;
18
+ return m_color != otherColor.m_color || m_platformColor != otherColor.m_platformColor;
22
19
  }
23
20
 
24
21
  winrt::Windows::UI::Color AsWindowsColor() const {
@@ -36,13 +33,12 @@ struct Color {
36
33
  return RGB(m_color.R, m_color.G, m_color.B) | (m_color.A << 24);
37
34
  }
38
35
 
39
- bool m_isUndefined;
40
36
  winrt::Windows::UI::Color m_color;
41
37
  std::vector<std::string> m_platformColor;
42
38
  };
43
39
 
44
40
  namespace HostPlatformColor {
45
- static const facebook::react::Color UndefinedColor{true};
41
+ static const facebook::react::Color UndefinedColor{{0, 0, 0, 0} /*Black*/, {} /*Empty PlatformColors*/};
46
42
  } // namespace HostPlatformColor
47
43
 
48
44
  inline Color hostPlatformColorFromComponents(ColorComponents components) {
@@ -53,7 +49,6 @@ inline Color hostPlatformColorFromComponents(ColorComponents components) {
53
49
  static_cast<uint8_t>((int)round(components.green * ratio) & 0xff),
54
50
  static_cast<uint8_t>((int)round(components.blue * ratio) & 0xff)};
55
51
  return {
56
- /* .m_isUndefined = */ false,
57
52
  /* .m_color = */ color,
58
53
  /* .m_platformColor = */ {}};
59
54
  }
@@ -19,7 +19,6 @@ parsePlatformColor(const ContextContainer &contextContainer, int32_t surfaceId,
19
19
  auto map = (std::unordered_map<std::string, std::vector<std::string>>)value;
20
20
  if (map.find("windowsbrush") != map.end()) {
21
21
  facebook::react::Color color = {
22
- /* .m_isDefined = */ true,
23
22
  /* .m_color = */ {},
24
23
  /* .m_platformColor = */ std::move(map["windowsbrush"]),
25
24
  };
@@ -1360,6 +1360,15 @@ inline ReactModuleProvider MakeTurboModuleProvider() noexcept {
1360
1360
  return MakeModuleProvider<TModule>();
1361
1361
  }
1362
1362
 
1363
+ // Clang does not allow a virtual function address to be a constexpr statement
1364
+ #if !defined(CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS)
1365
+ #if defined(__clang__)
1366
+ #define CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS
1367
+ #else
1368
+ #define CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS constexpr
1369
+ #endif
1370
+ #endif
1371
+
1363
1372
  } // namespace winrt::Microsoft::ReactNative
1364
1373
 
1365
1374
  namespace React {
@@ -10,11 +10,11 @@
10
10
  -->
11
11
  <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
12
12
  <PropertyGroup>
13
- <ReactNativeWindowsVersion>0.74.35</ReactNativeWindowsVersion>
13
+ <ReactNativeWindowsVersion>0.74.37</ReactNativeWindowsVersion>
14
14
  <ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
15
15
  <ReactNativeWindowsMinor>74</ReactNativeWindowsMinor>
16
- <ReactNativeWindowsPatch>35</ReactNativeWindowsPatch>
16
+ <ReactNativeWindowsPatch>37</ReactNativeWindowsPatch>
17
17
  <ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
18
- <ReactNativeWindowsCommitId>21a93f9e66a80f831b4713ab8bf85ce7ab8155cf</ReactNativeWindowsCommitId>
18
+ <ReactNativeWindowsCommitId>4ad063f22757b42a70478b2c145520e621fd2bf5</ReactNativeWindowsCommitId>
19
19
  </PropertyGroup>
20
20
  </Project>