react-native-windows 0.76.8 → 0.76.10

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 (128) hide show
  1. package/Libraries/Components/Button.windows.js +9 -0
  2. package/Libraries/Components/Pressable/Pressable.windows.js +9 -0
  3. package/Libraries/Components/TextInput/TextInput.windows.js +11 -1
  4. package/Libraries/Components/Touchable/TouchableBounce.windows.js +229 -0
  5. package/Libraries/Components/Touchable/TouchableNativeFeedback.windows.js +373 -0
  6. package/Libraries/Components/Touchable/TouchableOpacity.windows.js +7 -0
  7. package/Libraries/Components/Touchable/TouchableWithoutFeedback.windows.js +8 -0
  8. package/Libraries/Components/View/View.windows.js +11 -1
  9. package/Libraries/Components/View/ViewAccessibility.d.ts +15 -0
  10. package/Libraries/Components/View/ViewAccessibility.windows.js +3 -0
  11. package/Libraries/Components/View/ViewPropTypes.windows.js +3 -0
  12. package/Libraries/Image/Image.windows.js +7 -0
  13. package/Libraries/Modal/Modal.windows.js +4 -1
  14. package/Libraries/Text/Text.windows.js +14 -1
  15. package/Libraries/Text/TextProps.windows.js +3 -0
  16. package/Microsoft.ReactNative/CompositionComponentView.idl +13 -1
  17. package/Microsoft.ReactNative/Fabric/AbiPortalShadowNode.cpp +97 -0
  18. package/Microsoft.ReactNative/Fabric/AbiPortalShadowNode.h +53 -0
  19. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.h +160 -17
  20. package/Microsoft.ReactNative/Fabric/AbiViewProps.cpp +8 -10
  21. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +4 -2
  22. package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.cpp +0 -5
  23. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +428 -39
  24. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +39 -1
  25. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +55 -33
  26. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +5 -3
  27. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp +43 -5
  28. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.h +2 -1
  29. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextProvider.cpp +115 -0
  30. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextProvider.h +41 -0
  31. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.cpp +298 -0
  32. package/Microsoft.ReactNative/Fabric/Composition/CompositionTextRangeProvider.h +59 -0
  33. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +106 -56
  34. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +2 -0
  35. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +163 -10
  36. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +17 -1
  37. package/Microsoft.ReactNative/Fabric/Composition/FocusManager.cpp +4 -2
  38. package/Microsoft.ReactNative/Fabric/Composition/FocusManager.h +9 -1
  39. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +348 -316
  40. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +3 -61
  41. package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.cpp +78 -0
  42. package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.h +52 -0
  43. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +22 -0
  44. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +7 -5
  45. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +99 -37
  46. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +12 -6
  47. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +81 -22
  48. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +21 -2
  49. package/Microsoft.ReactNative/Fabric/Composition/Theme.cpp +6 -1
  50. package/Microsoft.ReactNative/Fabric/Composition/TooltipService.cpp +41 -37
  51. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +76 -33
  52. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +8 -2
  53. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +1 -6
  54. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +0 -3
  55. package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp +0 -2
  56. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/HostPlatformColor.h +5 -8
  57. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorParser.h +1 -2
  58. package/Microsoft.ReactNative/Fabric/platform/react/renderer/graphics/PlatformColorUtils.cpp +1 -1
  59. package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +15 -1
  60. package/Microsoft.ReactNative/IReactContext.cpp +2 -2
  61. package/Microsoft.ReactNative/IReactContext.h +1 -1
  62. package/Microsoft.ReactNative/IReactContext.idl +2 -2
  63. package/Microsoft.ReactNative/IReactPackageBuilder.idl +3 -3
  64. package/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +97 -87
  65. package/Microsoft.ReactNative/Modules/AccessibilityInfoModule.cpp +4 -0
  66. package/Microsoft.ReactNative/Modules/AlertModule.cpp +9 -4
  67. package/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.cpp +1 -1
  68. package/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.cpp +32 -35
  69. package/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.h +7 -4
  70. package/Microsoft.ReactNative/Modules/AppStateModule.cpp +1 -1
  71. package/Microsoft.ReactNative/Modules/AppThemeModuleUwp.cpp +2 -2
  72. package/Microsoft.ReactNative/Modules/AppearanceModule.cpp +2 -2
  73. package/Microsoft.ReactNative/Modules/ClipboardModule.cpp +1 -1
  74. package/Microsoft.ReactNative/Modules/ClipboardModule.h +1 -1
  75. package/Microsoft.ReactNative/Modules/DeviceInfoModule.cpp +3 -3
  76. package/Microsoft.ReactNative/Modules/I18nManagerModule.cpp +1 -1
  77. package/Microsoft.ReactNative/Modules/LogBoxModule.cpp +7 -5
  78. package/Microsoft.ReactNative/Modules/LogBoxModule.h +2 -1
  79. package/Microsoft.ReactNative/Modules/Timing.cpp +2 -2
  80. package/Microsoft.ReactNative/ReactHost/IReactInstance.h +5 -0
  81. package/Microsoft.ReactNative/ReactHost/React.h +0 -3
  82. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +36 -12
  83. package/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +1 -1
  84. package/Microsoft.ReactNative/ReactNativeHost.cpp +9 -4
  85. package/Microsoft.ReactNative/ReactNativeIsland.idl +5 -1
  86. package/Microsoft.ReactNative/ReactPackageBuilder.cpp +3 -3
  87. package/Microsoft.ReactNative/ReactPackageBuilder.h +4 -4
  88. package/Microsoft.ReactNative/Utils/Helpers.cpp +0 -2
  89. package/Microsoft.ReactNative/Views/DevMenu.cpp +6 -6
  90. package/Microsoft.ReactNative/Views/DevMenu.h +1 -1
  91. package/Microsoft.ReactNative/XamlUIService.cpp +13 -7
  92. package/Microsoft.ReactNative/XamlUIService.h +4 -1
  93. package/Microsoft.ReactNative/XamlUIService.idl +2 -0
  94. package/Microsoft.ReactNative.Cxx/JSI/JsiAbiApi.h +6 -2
  95. package/Microsoft.ReactNative.Cxx/NativeModules.h +29 -0
  96. package/Microsoft.ReactNative.Cxx/ReactContext.h +1 -1
  97. package/Microsoft.ReactNative.Cxx/XamlUtils.h +12 -0
  98. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  99. package/PropertySheets/React.Cpp.props +3 -0
  100. package/PropertySheets/WebView2.props +1 -1
  101. package/PropertySheets/WinUI.props +5 -4
  102. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/AccessibilityPrimitives.h +253 -0
  103. package/ReactCommon/TEMP_UntilReactCommonUpdate/react/renderer/components/view/accessibilityPropsConversions.h +799 -0
  104. package/Shared/InspectorPackagerConnection.cpp +2 -5
  105. package/Shared/InspectorPackagerConnection.h +2 -2
  106. package/Shared/Networking/WinRTWebSocketResource.cpp +369 -7
  107. package/Shared/Networking/WinRTWebSocketResource.h +118 -0
  108. package/Shared/Shared.vcxitems +12 -5
  109. package/Shared/Shared.vcxitems.filters +11 -4
  110. package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +212 -0
  111. package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +295 -0
  112. package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +200 -0
  113. package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +224 -0
  114. package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +250 -0
  115. package/codegen/react/components/rnwcore/AndroidSwitch.g.h +267 -0
  116. package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +234 -0
  117. package/codegen/react/components/rnwcore/InputAccessory.g.h +200 -0
  118. package/codegen/react/components/rnwcore/ModalHostView.g.h +279 -0
  119. package/codegen/react/components/rnwcore/PullToRefreshView.g.h +246 -0
  120. package/codegen/react/components/rnwcore/SafeAreaView.g.h +197 -0
  121. package/codegen/react/components/rnwcore/Switch.g.h +263 -0
  122. package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +200 -0
  123. package/just-task.js +1 -1
  124. package/package.json +6 -6
  125. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +0 -191
  126. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentDescriptor.h +0 -39
  127. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.cpp +0 -18
  128. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.h +0 -39
@@ -3,69 +3,11 @@
3
3
 
4
4
  #pragma once
5
5
 
6
- #include <Fabric/ComponentView.h>
7
- #include <Microsoft.ReactNative.Cxx/ReactContext.h>
8
-
9
- #include "Composition.WindowsModalHostComponentView.g.h"
10
- #include "../CompositionViewComponentView.h"
11
-
12
- #include <Fabric/Composition/RootComponentView.h>
13
- #include <react/components/rnwcore/ShadowNodes.h>
6
+ #include <winrt/Microsoft.ReactNative.h>
14
7
 
15
8
  namespace winrt::Microsoft::ReactNative::Composition::implementation {
16
9
 
17
- struct WindowsModalHostComponentView
18
- : WindowsModalHostComponentViewT<WindowsModalHostComponentView, RootComponentView> {
19
- using Super = WindowsModalHostComponentViewT<WindowsModalHostComponentView, RootComponentView>;
20
-
21
- ~WindowsModalHostComponentView();
22
-
23
- [[nodiscard]] static winrt::Microsoft::ReactNative::ComponentView Create(
24
- const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
25
- facebook::react::Tag tag,
26
- winrt::Microsoft::ReactNative::ReactContext const &reactContext) noexcept;
27
-
28
- winrt::Microsoft::ReactNative::Composition::Experimental::IVisual VisualToMountChildrenInto() noexcept override;
29
- void MountChildComponentView(
30
- const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
31
- uint32_t index) noexcept override;
32
- void UnmountChildComponentView(
33
- const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
34
- uint32_t index) noexcept override;
35
-
36
- void AdjustWindowSize() noexcept;
37
-
38
- void updateLayoutMetrics(
39
- facebook::react::LayoutMetrics const &layoutMetrics,
40
- facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept override;
41
-
42
- void updateProps(facebook::react::Props::Shared const &props, facebook::react::Props::Shared const &oldProps) noexcept
43
- override;
44
- static facebook::react::SharedViewProps defaultProps() noexcept;
45
- const facebook::react::ModalHostViewProps &modalHostViewProps() const noexcept;
46
- bool focusable() const noexcept override;
47
- facebook::react::Tag hitTest(facebook::react::Point pt, facebook::react::Point &localPt, bool ignorePointerEvents)
48
- const noexcept override;
49
- virtual std::string DefaultControlType() const noexcept;
50
-
51
- WindowsModalHostComponentView(
52
- const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
53
- facebook::react::Tag tag,
54
- winrt::Microsoft::ReactNative::ReactContext const &reactContext);
55
-
56
- // Used for creating new window
57
- void ShowOnUIThread();
58
- void HideOnUIThread() noexcept;
59
- void EnsureModalCreated();
60
- static void RegisterWndClass() noexcept;
61
-
62
- private:
63
- HWND m_parentHwnd{nullptr};
64
- HWND m_hwnd{nullptr};
65
- uint64_t m_prevWindowID;
66
- bool m_isVisible{false};
67
- bool m_showTitleBar{false};
68
- winrt::Microsoft::ReactNative::ReactNativeIsland m_reactNativeIsland;
69
- };
10
+ void RegisterWindowsModalHostNativeComponent(
11
+ winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder) noexcept;
70
12
 
71
13
  } // namespace winrt::Microsoft::ReactNative::Composition::implementation
@@ -0,0 +1,78 @@
1
+
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+
5
+ #pragma once
6
+
7
+ #include "PortalComponentView.h"
8
+
9
+ #include "Composition.PortalComponentView.g.cpp"
10
+
11
+ namespace winrt::Microsoft::ReactNative::Composition::implementation {
12
+
13
+ PortalComponentView::PortalComponentView(
14
+ const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
15
+ facebook::react::Tag tag,
16
+ winrt::Microsoft::ReactNative::ReactContext const &reactContext,
17
+ winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder *builder)
18
+ : base_type(tag, reactContext, builder) {
19
+ m_rootComponentView = winrt::make_self<winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView>(
20
+ compContext, *this, reactContext);
21
+ }
22
+
23
+ PortalComponentView::~PortalComponentView() {}
24
+
25
+ winrt::Microsoft::ReactNative::Composition::RootComponentView PortalComponentView::ContentRoot() const noexcept {
26
+ return *m_rootComponentView;
27
+ }
28
+
29
+ void PortalComponentView::MountChildComponentView(
30
+ const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
31
+ uint32_t index) noexcept {
32
+ m_rootComponentView->MountChildComponentView(childComponentView, index);
33
+ if (m_builder && m_builder->MountChildComponentViewHandler()) {
34
+ m_builder->MountChildComponentViewHandler()(
35
+ *this,
36
+ winrt::make<winrt::Microsoft::ReactNative::implementation::MountChildComponentViewArgs>(
37
+ childComponentView, index));
38
+ }
39
+ }
40
+
41
+ void PortalComponentView::UnmountChildComponentView(
42
+ const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
43
+ uint32_t index) noexcept {
44
+ if (m_builder && m_builder->UnmountChildComponentViewHandler()) {
45
+ m_builder->UnmountChildComponentViewHandler()(
46
+ *this,
47
+ winrt::make<winrt::Microsoft::ReactNative::implementation::UnmountChildComponentViewArgs>(
48
+ childComponentView, index));
49
+ }
50
+ m_rootComponentView->UnmountChildComponentView(childComponentView, index);
51
+ }
52
+
53
+ const winrt::Microsoft::ReactNative::IComponentProps PortalComponentView::userProps(
54
+ facebook::react::Props::Shared const &props) noexcept {
55
+ const auto &abiViewProps = *std::static_pointer_cast<const ::Microsoft::ReactNative::AbiViewProps>(props);
56
+ return abiViewProps.UserProps();
57
+ }
58
+
59
+ void PortalComponentView::updateProps(
60
+ facebook::react::Props::Shared const &props,
61
+ facebook::react::Props::Shared const &oldProps) noexcept {
62
+ m_rootComponentView->updateProps(props, oldProps);
63
+ base_type::updateProps(props, oldProps);
64
+ }
65
+
66
+ void PortalComponentView::updateLayoutMetrics(
67
+ facebook::react::LayoutMetrics const &layoutMetrics,
68
+ facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept {
69
+ m_rootComponentView->updateLayoutMetrics(layoutMetrics, oldLayoutMetrics);
70
+ base_type::updateLayoutMetrics(layoutMetrics, oldLayoutMetrics);
71
+ }
72
+
73
+ void PortalComponentView::FinalizeUpdates(winrt::Microsoft::ReactNative::ComponentViewUpdateMask updateMask) noexcept {
74
+ m_rootComponentView->FinalizeUpdates(updateMask);
75
+ base_type::FinalizeUpdates(updateMask);
76
+ }
77
+
78
+ } // namespace winrt::Microsoft::ReactNative::Composition::implementation
@@ -0,0 +1,52 @@
1
+
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+
5
+ #pragma once
6
+
7
+ #include <Fabric/ComponentView.h>
8
+ #include <Microsoft.ReactNative.Cxx/ReactContext.h>
9
+ #include "RootComponentView.h"
10
+
11
+ #include "Composition.PortalComponentView.g.h"
12
+
13
+ namespace Microsoft::ReactNative {
14
+ struct CompContext;
15
+ } // namespace Microsoft::ReactNative
16
+
17
+ namespace winrt::Microsoft::ReactNative::Composition::implementation {
18
+
19
+ struct PortalComponentView
20
+ : public PortalComponentViewT<PortalComponentView, winrt::Microsoft::ReactNative::implementation::ComponentView> {
21
+ PortalComponentView(
22
+ const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
23
+ facebook::react::Tag tag,
24
+ winrt::Microsoft::ReactNative::ReactContext const &reactContext,
25
+ winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder *builder);
26
+ virtual ~PortalComponentView();
27
+
28
+ winrt::Microsoft::ReactNative::Composition::RootComponentView ContentRoot() const noexcept;
29
+
30
+ void MountChildComponentView(
31
+ const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
32
+ uint32_t index) noexcept override;
33
+ void UnmountChildComponentView(
34
+ const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
35
+ uint32_t index) noexcept override;
36
+
37
+ const winrt::Microsoft::ReactNative::IComponentProps userProps(
38
+ facebook::react::Props::Shared const &props) noexcept override;
39
+ void updateProps(facebook::react::Props::Shared const &props, facebook::react::Props::Shared const &oldProps) noexcept
40
+ override;
41
+
42
+ void updateLayoutMetrics(
43
+ facebook::react::LayoutMetrics const &layoutMetrics,
44
+ facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept override;
45
+
46
+ void FinalizeUpdates(winrt::Microsoft::ReactNative::ComponentViewUpdateMask updateMask) noexcept override;
47
+
48
+ private:
49
+ winrt::com_ptr<winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView> m_rootComponentView;
50
+ };
51
+
52
+ } // namespace winrt::Microsoft::ReactNative::Composition::implementation
@@ -3,8 +3,10 @@
3
3
 
4
4
  #include "pch.h"
5
5
  #include "ReactCompositionViewComponentBuilder.h"
6
+ #include <Fabric/AbiViewComponentDescriptor.h>
6
7
  #include <Fabric/Composition/CompositionViewComponentView.h>
7
8
  #include <Fabric/Composition/ContentIslandComponentView.h>
9
+ #include <Fabric/Composition/PortalComponentView.h>
8
10
  #include <strsafe.h>
9
11
  #include "CompositionContextHelper.h"
10
12
  #include "DynamicWriter.h"
@@ -111,6 +113,26 @@ void ReactCompositionViewComponentBuilder::SetContentIslandComponentViewInitiali
111
113
  };
112
114
  }
113
115
 
116
+ void ReactCompositionViewComponentBuilder::SetPortalComponentViewInitializer(
117
+ const PortalComponentViewInitializer &initializer) noexcept {
118
+ m_fnCreateView = [initializer](
119
+ const IReactContext &reactContext,
120
+ int32_t tag,
121
+ const Experimental::ICompositionContext &context,
122
+ ComponentViewFeatures /*features*/,
123
+ ReactCompositionViewComponentBuilder &builder)
124
+ -> winrt::Microsoft::ReactNative::Composition::PortalComponentView {
125
+ auto view = winrt::make<winrt::Microsoft::ReactNative::Composition::implementation::PortalComponentView>(
126
+ context, tag, reactContext, &builder);
127
+ initializer(view);
128
+ return view;
129
+ };
130
+ m_descriptorConstructorFactory = []() {
131
+ return &facebook::react::concreteComponentDescriptorConstructor<
132
+ ::Microsoft::ReactNative::AbiPortalComponentDescriptor>;
133
+ };
134
+ }
135
+
114
136
  // (Object handle, Microsoft.ReactNative.IComponentState state) => void
115
137
  // void ReactCompositionViewComponentBuilder::SetStateUpdater(StateUpdater impl) noexcept {
116
138
  // m_stateUpdater = impl;
@@ -3,7 +3,6 @@
3
3
  // Licensed under the MIT License.
4
4
 
5
5
  #include <Fabric/AbiComponentDescriptor.h>
6
- #include <Fabric/AbiViewComponentDescriptor.h>
7
6
  #include <react/renderer/componentregistry/ComponentDescriptorProvider.h>
8
7
  #include <react/renderer/core/ReactPrimitives.h>
9
8
  #include "winrt/Microsoft.ReactNative.Composition.Experimental.h"
@@ -12,10 +11,12 @@
12
11
 
13
12
  namespace winrt::Microsoft::ReactNative::Composition {
14
13
 
15
- struct ReactCompositionViewComponentBuilder : winrt::implements<
16
- ReactCompositionViewComponentBuilder,
17
- IReactViewComponentBuilder,
18
- Composition::IReactCompositionViewComponentBuilder> {
14
+ struct ReactCompositionViewComponentBuilder
15
+ : winrt::implements<
16
+ ReactCompositionViewComponentBuilder,
17
+ IReactViewComponentBuilder,
18
+ Composition::IReactCompositionViewComponentBuilder,
19
+ Composition::Experimental::IReactCompositionViewComponentInternalBuilder> {
19
20
  ReactCompositionViewComponentBuilder() noexcept;
20
21
 
21
22
  public: // IReactViewComponentBuilder
@@ -42,6 +43,7 @@ struct ReactCompositionViewComponentBuilder : winrt::implements<
42
43
  public: // Composition::IReactCompositionViewComponentBuilder
43
44
  void SetViewComponentViewInitializer(const ViewComponentViewInitializer &initializer) noexcept;
44
45
  void SetContentIslandComponentViewInitializer(const ComponentIslandComponentViewInitializer &initializer) noexcept;
46
+ void SetPortalComponentViewInitializer(const PortalComponentViewInitializer &initializer) noexcept;
45
47
  void SetCreateVisualHandler(CreateVisualDelegate impl) noexcept;
46
48
  void SetViewFeatures(ComponentViewFeatures viewFeatures) noexcept;
47
49
  void SetVisualToMountChildrenIntoHandler(VisualToMountChildrenIntoDelegate impl) noexcept;
@@ -127,21 +127,39 @@ ReactNativeIsland::ReactNativeIsland(const winrt::Microsoft::UI::Composition::Co
127
127
  InitTextScaleMultiplier();
128
128
  }
129
129
 
130
- // Constructor to initialize ReactNativeIsland with context and componentView
131
130
  ReactNativeIsland::ReactNativeIsland(
132
- const winrt::Microsoft::UI::Composition::Compositor &compositor,
133
- winrt::Microsoft::ReactNative::IReactContext context,
134
- winrt::Microsoft::ReactNative::ComponentView componentView) noexcept
135
- : m_compositor(compositor),
136
- m_context(context),
131
+ const winrt::Microsoft::ReactNative::Composition::PortalComponentView &portal) noexcept
132
+ : m_compositor(portal.ContentRoot().Compositor()),
133
+ m_context(portal.ReactContext()),
137
134
  m_layoutConstraints({{0, 0}, {0, 0}, winrt::Microsoft::ReactNative::LayoutDirection::Undefined}),
138
135
  m_isFragment(true) {
139
- m_rootTag = componentView.Tag();
136
+ m_portal = winrt::make_weak(portal);
137
+
138
+ auto trueRoot =
139
+ winrt::get_self<winrt::Microsoft::ReactNative::Composition::implementation::PortalComponentView>(portal)
140
+ ->rootComponentView();
141
+ while (auto p = trueRoot->Portal()) {
142
+ trueRoot = winrt::get_self<winrt::Microsoft::ReactNative::Composition::implementation::PortalComponentView>(p)
143
+ ->rootComponentView();
144
+ };
145
+ m_rootTag = trueRoot->Tag();
146
+
140
147
  InitTextScaleMultiplier();
141
- AddFragmentCompositionEventHandler(context, componentView);
148
+ AddFragmentCompositionEventHandler(m_context.Handle(), portal.ContentRoot());
149
+ auto selfPortal = winrt::get_self<winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView>(
150
+ portal.ContentRoot());
151
+ selfPortal->ReactNativeIsland(*this);
152
+ NotifySizeChanged();
153
+ selfPortal->start(*this);
142
154
  }
143
155
 
144
- ReactNativeIsland::ReactNativeIsland() noexcept : ReactNativeIsland(nullptr) {}
156
+ winrt::Microsoft::ReactNative::ReactNativeIsland ReactNativeIsland::CreatePortal(
157
+ const winrt::Microsoft::ReactNative::Composition::PortalComponentView &portal) noexcept {
158
+ return winrt::make<ReactNativeIsland>(portal);
159
+ }
160
+
161
+ ReactNativeIsland::ReactNativeIsland() noexcept
162
+ : ReactNativeIsland(winrt::Microsoft::UI::Composition::Compositor{nullptr}) {}
145
163
 
146
164
  ReactNativeIsland::~ReactNativeIsland() noexcept {
147
165
  #ifdef USE_WINUI3
@@ -159,14 +177,20 @@ ReactNativeIsland::~ReactNativeIsland() noexcept {
159
177
  assert(m_uiDispatcher.HasThreadAccess());
160
178
  UninitRootView();
161
179
  }
180
+
181
+ if (m_island) {
182
+ m_island.Close();
183
+ }
162
184
  }
163
185
 
164
186
  ReactNative::IReactViewHost ReactNativeIsland::ReactViewHost() noexcept {
165
187
  return m_reactViewHost;
166
188
  }
167
189
 
168
- void ReactNativeIsland::ReactViewHost(winrt::Microsoft::ReactNative::IReactViewHost const &value) noexcept {
169
- assert(!m_isFragment); // make sure this isn't a FragmentIsalnd
190
+ void ReactNativeIsland::ReactViewHost(winrt::Microsoft::ReactNative::IReactViewHost const &value) {
191
+ if (m_isFragment)
192
+ winrt::throw_hresult(E_ACCESSDENIED);
193
+
170
194
  if (m_reactViewHost == value) {
171
195
  return;
172
196
  }
@@ -217,6 +241,8 @@ void ReactNativeIsland::AddRenderedVisual(
217
241
 
218
242
  void ReactNativeIsland::RemoveRenderedVisual(
219
243
  const winrt::Microsoft::ReactNative::Composition::Experimental::IVisual &visual) noexcept {
244
+ if (m_isFragment)
245
+ return;
220
246
  assert(m_hasRenderedVisual);
221
247
  InternalRootVisual().Remove(visual);
222
248
  m_hasRenderedVisual = false;
@@ -442,7 +468,7 @@ void ReactNativeIsland::InitRootView(
442
468
 
443
469
  m_context = winrt::Microsoft::ReactNative::ReactContext(std::move(context));
444
470
  m_reactViewOptions = std::move(viewOptions);
445
- m_CompositionEventHandler = std::make_shared<::Microsoft::ReactNative::CompositionEventHandler>(m_context, *this, -1);
471
+ m_CompositionEventHandler = std::make_shared<::Microsoft::ReactNative::CompositionEventHandler>(m_context, *this);
446
472
  m_CompositionEventHandler->Initialize();
447
473
 
448
474
  UpdateRootViewInternal();
@@ -457,15 +483,13 @@ void ReactNativeIsland::AddFragmentCompositionEventHandler(
457
483
  .Get(winrt::Microsoft::ReactNative::ReactDispatcherHelper::UIDispatcherProperty())
458
484
  .try_as<IReactDispatcher>();
459
485
  VerifyElseCrash(m_uiDispatcher.HasThreadAccess());
460
- VerifyElseCrash(m_rootTag != -1);
461
486
  auto uiManager = ::Microsoft::ReactNative::FabricUIManager::FromProperties(
462
487
  winrt::Microsoft::ReactNative::ReactPropertyBag(context.Properties()));
463
488
 
464
489
  if (!m_CompositionEventHandler) {
465
490
  // Create CompositionEventHandler if not already created
466
491
  m_context = winrt::Microsoft::ReactNative::ReactContext(context);
467
- m_CompositionEventHandler =
468
- std::make_shared<::Microsoft::ReactNative::CompositionEventHandler>(m_context, *this, componentView.Tag());
492
+ m_CompositionEventHandler = std::make_shared<::Microsoft::ReactNative::CompositionEventHandler>(m_context, *this);
469
493
  m_CompositionEventHandler->Initialize();
470
494
  m_isInitialized = true;
471
495
  }
@@ -545,6 +569,7 @@ void ReactNativeIsland::ClearLoadingUI() noexcept {
545
569
  void ReactNativeIsland::EnsureLoadingUI() noexcept {}
546
570
 
547
571
  void ReactNativeIsland::ShowInstanceLoaded() noexcept {
572
+ VerifyElseCrash(!m_isFragment);
548
573
  if (m_rootVisual) {
549
574
  ClearLoadingUI();
550
575
 
@@ -740,6 +765,9 @@ void ReactNativeIsland::InitTextScaleMultiplier() noexcept {
740
765
  winrt::Windows::Foundation::Size ReactNativeIsland::Measure(
741
766
  const winrt::Microsoft::ReactNative::LayoutConstraints &layoutConstraints,
742
767
  const winrt::Windows::Foundation::Point &viewportOffset) const {
768
+ if (m_isFragment)
769
+ winrt::throw_hresult(E_ILLEGAL_METHOD_CALL);
770
+
743
771
  facebook::react::Size size{0, 0};
744
772
 
745
773
  if (layoutConstraints.LayoutDirection != winrt::Microsoft::ReactNative::LayoutDirection::LeftToRight &&
@@ -750,7 +778,7 @@ winrt::Windows::Foundation::Size ReactNativeIsland::Measure(
750
778
  facebook::react::LayoutConstraints constraints;
751
779
  ApplyConstraints(layoutConstraints, constraints);
752
780
 
753
- if (m_isInitialized && m_rootTag != -1) {
781
+ if (m_isInitialized && m_rootTag != -1 && m_hasRenderedVisual) {
754
782
  if (auto fabricuiManager = ::Microsoft::ReactNative::FabricUIManager::FromProperties(
755
783
  winrt::Microsoft::ReactNative::ReactPropertyBag(m_context.Properties()))) {
756
784
  facebook::react::LayoutContext context;
@@ -781,7 +809,7 @@ void ReactNativeIsland::Arrange(
781
809
  facebook::react::LayoutConstraints fbLayoutConstraints;
782
810
  ApplyConstraints(layoutConstraints, fbLayoutConstraints);
783
811
 
784
- if (m_isInitialized && m_rootTag != -1) {
812
+ if (m_isInitialized && m_rootTag != -1 && !m_isFragment && m_hasRenderedVisual) {
785
813
  if (auto fabricuiManager = ::Microsoft::ReactNative::FabricUIManager::FromProperties(
786
814
  winrt::Microsoft::ReactNative::ReactPropertyBag(m_context.Properties()))) {
787
815
  facebook::react::LayoutContext context;
@@ -820,6 +848,23 @@ winrt::Microsoft::UI::Content::ContentIsland ReactNativeIsland::Island() {
820
848
  rootVisual));
821
849
  m_island = winrt::Microsoft::UI::Content::ContentIsland::Create(rootVisual);
822
850
 
851
+ auto focusController = winrt::Microsoft::UI::Input::InputFocusController::GetForIsland(m_island);
852
+ focusController.NavigateFocusRequested(
853
+ [weakThis = get_weak()](
854
+ const auto &sender, const winrt::Microsoft::UI::Input::FocusNavigationRequestEventArgs &args) {
855
+ if (auto pThis = weakThis.get()) {
856
+ if (auto rootView = pThis->GetComponentView()) {
857
+ args.Result(
858
+ rootView->NavigateFocus(winrt::Microsoft::ReactNative::FocusNavigationRequest(
859
+ winrt::Microsoft::ReactNative::FocusNavigationReason::First))
860
+ ? winrt::Microsoft::UI::Input::FocusNavigationResult::Moved
861
+ : winrt::Microsoft::UI::Input::FocusNavigationResult::NotMoved);
862
+ } else {
863
+ args.Result(winrt::Microsoft::UI::Input::FocusNavigationResult::NoFocusableElements);
864
+ }
865
+ }
866
+ });
867
+
823
868
  // ContentIsland does not support weak_ref, so we cannot use auto_revoke for these events
824
869
  m_islandAutomationProviderRequestedToken = m_island.AutomationProviderRequested(
825
870
  [weakThis = get_weak()](
@@ -868,21 +913,23 @@ winrt::Microsoft::UI::Content::ContentIsland ReactNativeIsland::Island() {
868
913
  }
869
914
  });
870
915
  #ifdef USE_EXPERIMENTAL_WINUI3
871
- m_islandConnectedToken = m_island.Connected(
872
- [weakThis = get_weak()](
873
- winrt::IInspectable const &, winrt::Microsoft::UI::Content::ContentIsland const &island) {
874
- if (auto pThis = weakThis.get()) {
875
- pThis->OnMounted();
876
- }
877
- });
916
+ if (!m_isFragment) {
917
+ m_islandConnectedToken = m_island.Connected(
918
+ [weakThis = get_weak()](
919
+ winrt::IInspectable const &, winrt::Microsoft::UI::Content::ContentIsland const &island) {
920
+ if (auto pThis = weakThis.get()) {
921
+ pThis->OnMounted();
922
+ }
923
+ });
878
924
 
879
- m_islandDisconnectedToken = m_island.Disconnected(
880
- [weakThis = get_weak()](
881
- winrt::IInspectable const &, winrt::Microsoft::UI::Content::ContentIsland const &island) {
882
- if (auto pThis = weakThis.get()) {
883
- pThis->OnUnmounted();
884
- }
885
- });
925
+ m_islandDisconnectedToken = m_island.Disconnected(
926
+ [weakThis = get_weak()](
927
+ winrt::IInspectable const &, winrt::Microsoft::UI::Content::ContentIsland const &island) {
928
+ if (auto pThis = weakThis.get()) {
929
+ pThis->OnUnmounted();
930
+ }
931
+ });
932
+ }
886
933
  #endif
887
934
  }
888
935
  return m_island;
@@ -903,24 +950,39 @@ void ReactNativeIsland::OnUnmounted() noexcept {
903
950
  if (!m_mounted)
904
951
  return;
905
952
  m_mounted = false;
953
+
954
+ if (m_island && m_island.IsConnected()) {
955
+ auto focusController = winrt::Microsoft::UI::Input::InputFocusController::GetForIsland(m_island);
956
+ auto request = winrt::Microsoft::UI::Input::FocusNavigationRequest::Create(
957
+ winrt::Microsoft::UI::Input::FocusNavigationReason::Programmatic);
958
+ if (focusController.HasFocus()) {
959
+ focusController.DepartFocus(request);
960
+ }
961
+ }
962
+
906
963
  if (auto componentView = GetComponentView()) {
907
964
  componentView->onUnmounted();
908
965
  }
909
966
  }
910
967
 
911
- winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView *
968
+ winrt::com_ptr<winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView>
912
969
  ReactNativeIsland::GetComponentView() noexcept {
970
+ if (auto portal = m_portal.get()) {
971
+ return winrt::get_self<winrt::Microsoft::ReactNative::Composition::implementation::PortalComponentView>(portal)
972
+ ->ContentRoot()
973
+ .as<winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView>();
974
+ }
975
+
913
976
  if (!m_context || m_context.Handle().LoadingState() != winrt::Microsoft::ReactNative::LoadingState::Loaded ||
914
977
  m_rootTag == -1)
915
978
  return nullptr;
916
979
 
917
980
  if (auto fabricuiManager = ::Microsoft::ReactNative::FabricUIManager::FromProperties(
918
981
  winrt::Microsoft::ReactNative::ReactPropertyBag(m_context.Properties()))) {
919
- auto rootComponentViewDescriptor = fabricuiManager->GetViewRegistry().componentViewDescriptorWithTag(
920
- static_cast<facebook::react::SurfaceId>(m_rootTag));
921
- return rootComponentViewDescriptor.view
922
- .as<winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView>()
923
- .get();
982
+ if (auto view = fabricuiManager->GetViewRegistry().findComponentViewWithTag(
983
+ static_cast<facebook::react::SurfaceId>(m_rootTag))) {
984
+ return view.as<winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView>();
985
+ }
924
986
  }
925
987
  return nullptr;
926
988
  }
@@ -12,6 +12,7 @@
12
12
  #include <winrt/Microsoft.ReactNative.h>
13
13
  #include <winrt/Windows.UI.ViewManagement.h>
14
14
  #include "CompositionEventHandler.h"
15
+ #include "PortalComponentView.h"
15
16
  #include "ReactHost/React.h"
16
17
 
17
18
  namespace winrt::Microsoft::ReactNative::implementation {
@@ -48,15 +49,15 @@ struct ReactNativeIsland
48
49
  ~ReactNativeIsland() noexcept;
49
50
 
50
51
  ReactNativeIsland(const winrt::Microsoft::UI::Composition::Compositor &compositor) noexcept;
51
- ReactNativeIsland(
52
- const winrt::Microsoft::UI::Composition::Compositor &compositor,
53
- winrt::Microsoft::ReactNative::IReactContext context,
54
- winrt::Microsoft::ReactNative::ComponentView componentView) noexcept;
52
+ ReactNativeIsland(const winrt::Microsoft::ReactNative::Composition::PortalComponentView &portal) noexcept;
53
+
54
+ static winrt::Microsoft::ReactNative::ReactNativeIsland CreatePortal(
55
+ const winrt::Microsoft::ReactNative::Composition::PortalComponentView &portal) noexcept;
55
56
  winrt::Microsoft::UI::Content::ContentIsland Island();
56
57
 
57
58
  // property ReactViewHost
58
59
  ReactNative::IReactViewHost ReactViewHost() noexcept;
59
- void ReactViewHost(ReactNative::IReactViewHost const &value) noexcept;
60
+ void ReactViewHost(ReactNative::IReactViewHost const &value);
60
61
 
61
62
  winrt::Microsoft::UI::Composition::Visual RootVisual() noexcept;
62
63
 
@@ -104,7 +105,8 @@ struct ReactNativeIsland
104
105
  winrt::Microsoft::ReactNative::FocusNavigationResult NavigateFocus(
105
106
  const winrt::Microsoft::ReactNative::FocusNavigationRequest &request) noexcept;
106
107
 
107
- winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView *GetComponentView() noexcept;
108
+ winrt::com_ptr<winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView>
109
+ GetComponentView() noexcept;
108
110
 
109
111
  int64_t RootTag() const noexcept;
110
112
 
@@ -153,8 +155,12 @@ struct ReactNativeIsland
153
155
  bool m_hasRenderedVisual{false};
154
156
  bool m_showingLoadingUI{false};
155
157
  bool m_mounted{false};
158
+ winrt::weak_ref<winrt::Microsoft::ReactNative::Composition::PortalComponentView> m_portal{nullptr};
156
159
  IReactDispatcher m_uiDispatcher{nullptr};
157
160
  winrt::IInspectable m_uiaProvider{nullptr};
161
+
162
+ // This is the surfaceId that this island belongs to.
163
+ // In the case of portal content root, this will be the surfaceId that contains the portal.
158
164
  int64_t m_rootTag{-1};
159
165
  float m_scaleFactor{1.0};
160
166
  float m_textScaleMultiplier{1.0};