react-native-windows 0.77.7 → 0.77.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/Libraries/Modal/Modal.windows.js +4 -1
  2. package/Microsoft.ReactNative/CompositionComponentView.idl +13 -1
  3. package/Microsoft.ReactNative/Fabric/AbiPortalShadowNode.cpp +97 -0
  4. package/Microsoft.ReactNative/Fabric/AbiPortalShadowNode.h +53 -0
  5. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.h +160 -17
  6. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +0 -1
  7. package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.cpp +0 -5
  8. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +0 -2
  9. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +13 -32
  10. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +1 -3
  11. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.cpp +1 -1
  12. package/Microsoft.ReactNative/Fabric/Composition/CompositionRootAutomationProvider.h +2 -1
  13. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +25 -20
  14. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +313 -319
  15. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.h +3 -61
  16. package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.cpp +78 -0
  17. package/Microsoft.ReactNative/Fabric/Composition/PortalComponentView.h +52 -0
  18. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +22 -0
  19. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +7 -5
  20. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +79 -19
  21. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +12 -6
  22. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +73 -19
  23. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +16 -0
  24. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +2 -2
  25. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +38 -23
  26. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +1 -6
  27. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.h +0 -3
  28. package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp +0 -2
  29. package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +15 -1
  30. package/Microsoft.ReactNative/ReactNativeHost.cpp +5 -0
  31. package/Microsoft.ReactNative/ReactNativeIsland.idl +5 -1
  32. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  33. package/Shared/Networking/WinRTWebSocketResource.cpp +5 -0
  34. package/Shared/Shared.vcxitems +6 -5
  35. package/Shared/Shared.vcxitems.filters +3 -4
  36. package/codegen/react/components/rnwcore/ActivityIndicatorView.g.h +212 -0
  37. package/codegen/react/components/rnwcore/AndroidDrawerLayout.g.h +295 -0
  38. package/codegen/react/components/rnwcore/AndroidHorizontalScrollContentView.g.h +200 -0
  39. package/codegen/react/components/rnwcore/AndroidProgressBar.g.h +224 -0
  40. package/codegen/react/components/rnwcore/AndroidSwipeRefreshLayout.g.h +250 -0
  41. package/codegen/react/components/rnwcore/AndroidSwitch.g.h +267 -0
  42. package/codegen/react/components/rnwcore/DebuggingOverlay.g.h +234 -0
  43. package/codegen/react/components/rnwcore/InputAccessory.g.h +200 -0
  44. package/codegen/react/components/rnwcore/ModalHostView.g.h +283 -0
  45. package/codegen/react/components/rnwcore/PullToRefreshView.g.h +246 -0
  46. package/codegen/react/components/rnwcore/SafeAreaView.g.h +197 -0
  47. package/codegen/react/components/rnwcore/Switch.g.h +263 -0
  48. package/codegen/react/components/rnwcore/UnimplementedNativeView.g.h +200 -0
  49. package/just-task.js +1 -1
  50. package/package.json +3 -3
  51. package/Microsoft.ReactNative/Fabric/AbiViewComponentDescriptor.cpp +0 -191
  52. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentDescriptor.h +0 -39
  53. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.cpp +0 -18
  54. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewShadowNode.h +0 -39
@@ -290,8 +290,11 @@ class Modal extends React.Component<Props, State> {
290
290
  }
291
291
  }
292
292
 
293
+ // [Windows] - apply empty rootViewStyle to AppContainer to prevent modal from always expanding to fill available space
293
294
  const innerChildren = __DEV__ ? (
294
- <AppContainer rootTag={this.context}>{this.props.children}</AppContainer>
295
+ <AppContainer rootTag={this.context} rootViewStyle={{}}>
296
+ {this.props.children}
297
+ </AppContainer>
295
298
  ) : (
296
299
  this.props.children
297
300
  );
@@ -7,6 +7,7 @@ import "ViewProps.idl";
7
7
  import "Composition.Input.idl";
8
8
  import "CompositionSwitcher.idl";
9
9
  import "IReactContext.idl";
10
+ import "ReactNativeIsland.idl";
10
11
 
11
12
  #include "DocString.h"
12
13
 
@@ -110,8 +111,19 @@ namespace Microsoft.ReactNative.Composition
110
111
  [default_interface]
111
112
  runtimeclass RootComponentView : ViewComponentView {
112
113
  Microsoft.ReactNative.ComponentView GetFocusedComponent();
114
+ Microsoft.ReactNative.ReactNativeIsland ReactNativeIsland { get; };
115
+ DOC_STRING("Is non-null if this RootComponentView is the content of a portal")
116
+ PortalComponentView Portal { get; };
113
117
  };
114
-
118
+
119
+ [experimental]
120
+ [webhosthidden]
121
+ [default_interface]
122
+ DOC_STRING("Used to implement UI that is hosted outside the main UI tree, such as modal.")
123
+ runtimeclass PortalComponentView : Microsoft.ReactNative.ComponentView {
124
+ RootComponentView ContentRoot { get; };
125
+ };
126
+
115
127
  [experimental]
116
128
  [webhosthidden]
117
129
  [default_interface]
@@ -0,0 +1,97 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #include "AbiPortalShadowNode.h"
5
+
6
+ #include <Fabric/Composition/ReactCompositionViewComponentBuilder.h>
7
+ #include <react/debug/react_native_assert.h>
8
+ #include <react/renderer/core/LayoutConstraints.h>
9
+ #include <react/renderer/core/LayoutContext.h>
10
+ #include <react/renderer/core/conversions.h>
11
+
12
+ #include <utility>
13
+
14
+ namespace Microsoft::ReactNative {
15
+
16
+ extern const char AbiPortalComponentName[] = "AbiPortal";
17
+
18
+ facebook::react::Size AbiPortalShadowNode::measureContent(
19
+ const facebook::react::LayoutContext &layoutContext,
20
+ const facebook::react::LayoutConstraints &layoutConstraints) const {
21
+ return {0, 0}; // The portal placeholder node shouldn't take up any space
22
+ }
23
+
24
+ void AbiPortalShadowNode::layout(facebook::react::LayoutContext layoutContext) {
25
+ ensureUnsealed();
26
+ auto layoutMetrics = getLayoutMetrics();
27
+
28
+ auto portalOwningShadowNode = ShadowNode::Unshared{};
29
+
30
+ if (getChildren().empty()) {
31
+ return;
32
+ }
33
+
34
+ // A Portal should only have a single child
35
+ react_native_assert(getChildren().size() == 1);
36
+
37
+ const auto &childNode = getChildren()[0];
38
+
39
+ auto clonedShadowNode = ShadowNode::Unshared{};
40
+
41
+ portalOwningShadowNode = cloneTree(childNode->getFamily(), [&](const ShadowNode &oldShadowNode) {
42
+ clonedShadowNode = oldShadowNode.clone({});
43
+ return clonedShadowNode;
44
+ });
45
+ auto portalShadowNode = static_cast<AbiPortalShadowNode *>(portalOwningShadowNode.get());
46
+
47
+ auto &layoutableShadowNode = dynamic_cast<LayoutableShadowNode &>(*clonedShadowNode);
48
+
49
+ auto &state = getStateData();
50
+
51
+ facebook::react::LayoutConstraints layoutConstraints;
52
+ layoutConstraints.layoutDirection = layoutMetrics.layoutDirection;
53
+
54
+ if (state.userdata) {
55
+ // If the portal component set a state of type IPortalStateData,
56
+ // extract constraint information from it, and use that for layout
57
+ if (auto portalState = state.userdata.try_as<winrt::Microsoft::ReactNative::Composition::IPortalStateData>()) {
58
+ auto stateConstraints = portalState.LayoutConstraints();
59
+
60
+ layoutConstraints.minimumSize = {stateConstraints.MinimumSize.Width, stateConstraints.MinimumSize.Height};
61
+ layoutConstraints.maximumSize = {stateConstraints.MaximumSize.Width, stateConstraints.MaximumSize.Height};
62
+ if (stateConstraints.LayoutDirection == winrt::Microsoft::ReactNative::LayoutDirection::LeftToRight) {
63
+ layoutConstraints.layoutDirection = facebook::react::LayoutDirection::LeftToRight;
64
+ } else if (stateConstraints.LayoutDirection == winrt::Microsoft::ReactNative::LayoutDirection::RightToLeft) {
65
+ layoutConstraints.layoutDirection = facebook::react::LayoutDirection::RightToLeft;
66
+ }
67
+ }
68
+ }
69
+
70
+ // Laying out the `ShadowNode` and the subtree starting from it.
71
+ layoutableShadowNode.layoutTree(layoutContext, layoutConstraints);
72
+
73
+ auto childLayoutMetrics = layoutableShadowNode.getLayoutMetrics();
74
+ childLayoutMetrics.frame.origin = {0, 0};
75
+ layoutableShadowNode.setLayoutMetrics(childLayoutMetrics);
76
+
77
+ // Update the list of children to reflect the changes that we made.
78
+ this->children_ = static_cast<AbiPortalShadowNode *>(portalOwningShadowNode.get())->children_;
79
+ }
80
+
81
+ void AbiPortalShadowNode::Builder(winrt::Microsoft::ReactNative::IReactViewComponentBuilder builder) noexcept {
82
+ m_builder = builder;
83
+ }
84
+
85
+ winrt::Microsoft::ReactNative::IReactViewComponentBuilder AbiPortalShadowNode::Builder() const noexcept {
86
+ return m_builder;
87
+ }
88
+
89
+ void AbiPortalShadowNode::Proxy(winrt::Microsoft::ReactNative::ShadowNode proxy) noexcept {
90
+ m_proxy = proxy;
91
+ }
92
+
93
+ winrt::Microsoft::ReactNative::ShadowNode AbiPortalShadowNode::Proxy() const noexcept {
94
+ return m_proxy;
95
+ }
96
+
97
+ } // namespace Microsoft::ReactNative
@@ -0,0 +1,53 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #pragma once
5
+
6
+ #include <react/components/rnwcore/EventEmitters.h>
7
+ #include <unordered_map>
8
+ #include "AbiShadowNode.h"
9
+ #include "AbiState.h"
10
+ #include "AbiViewProps.h"
11
+
12
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
13
+ #include <react/renderer/core/LayoutContext.h>
14
+
15
+ namespace Microsoft::ReactNative {
16
+
17
+ extern const char AbiPortalComponentName[];
18
+
19
+ class AbiPortalShadowNode final : public facebook::react::ConcreteViewShadowNode<
20
+ AbiPortalComponentName,
21
+ AbiViewProps,
22
+ facebook::react::ViewEventEmitter,
23
+ Microsoft::ReactNative::AbiStateData> {
24
+ public:
25
+ using ConcreteViewShadowNode::ConcreteViewShadowNode;
26
+
27
+ static facebook::react::ShadowNodeTraits BaseTraits() {
28
+ auto traits = facebook::react::ShadowNode::BaseTraits();
29
+ traits.set(facebook::react::ShadowNodeTraits::Trait::FormsStackingContext);
30
+ traits.set(facebook::react::ShadowNodeTraits::Trait::FormsView);
31
+ traits.set(facebook::react::ShadowNodeTraits::Trait::RootNodeKind);
32
+ traits.set(facebook::react::ShadowNodeTraits::Trait::LeafYogaNode);
33
+ traits.set(facebook::react::ShadowNodeTraits::Trait::MeasurableYogaNode);
34
+ return traits;
35
+ }
36
+
37
+ facebook::react::Size measureContent(
38
+ const facebook::react::LayoutContext &layoutContext,
39
+ const facebook::react::LayoutConstraints &layoutConstraints) const override;
40
+ void layout(facebook::react::LayoutContext layoutContext) override;
41
+
42
+ void OnClone(const facebook::react::ShadowNode &sourceShadowNode) noexcept;
43
+ void Builder(winrt::Microsoft::ReactNative::IReactViewComponentBuilder builder) noexcept;
44
+ winrt::Microsoft::ReactNative::IReactViewComponentBuilder Builder() const noexcept;
45
+ void Proxy(winrt::Microsoft::ReactNative::ShadowNode handle) noexcept;
46
+ winrt::Microsoft::ReactNative::ShadowNode Proxy() const noexcept;
47
+
48
+ private:
49
+ winrt::Microsoft::ReactNative::ShadowNode m_proxy{nullptr};
50
+ winrt::Microsoft::ReactNative::IReactViewComponentBuilder m_builder{nullptr};
51
+ };
52
+
53
+ } // namespace Microsoft::ReactNative
@@ -3,16 +3,22 @@
3
3
 
4
4
  #pragma once
5
5
 
6
+ #include <Fabric/Composition/ReactCompositionViewComponentBuilder.h>
7
+ #include <Fabric/WindowsComponentDescriptorRegistry.h>
8
+ #include <ReactContext.h>
6
9
  #include <react/renderer/components/view/ConcreteViewShadowNode.h>
7
10
  #include <react/renderer/core/ComponentDescriptor.h>
11
+ #include "AbiPortalShadowNode.h"
8
12
  #include "AbiViewProps.h"
9
13
  #include "AbiViewShadowNode.h"
14
+ #include "DynamicReader.h"
10
15
  #include "winrt/Microsoft.ReactNative.h"
11
16
 
12
17
  namespace Microsoft::ReactNative {
13
18
 
14
- class AbiViewComponentDescriptor : public facebook::react::ComponentDescriptor {
15
- using ShadowNodeT = AbiViewShadowNode;
19
+ template <typename ShadowNodeT>
20
+ class ConcreteAbiViewComponentDescriptor : public facebook::react::ComponentDescriptor {
21
+ protected:
16
22
  using SharedShadowNodeT = std::shared_ptr<const ShadowNodeT>;
17
23
 
18
24
  public:
@@ -24,34 +30,142 @@ class AbiViewComponentDescriptor : public facebook::react::ComponentDescriptor {
24
30
  using ConcreteState = typename ShadowNodeT::ConcreteState;
25
31
  using ConcreteStateData = typename ShadowNodeT::ConcreteState::Data;
26
32
 
27
- AbiViewComponentDescriptor(facebook::react::ComponentDescriptorParameters const &parameters);
33
+ ConcreteAbiViewComponentDescriptor(facebook::react::ComponentDescriptorParameters const &parameters)
34
+ : ComponentDescriptor(parameters) {
35
+ auto flavor = std::static_pointer_cast<std::string const>(this->flavor_);
36
+ m_builder = WindowsComponentDescriptorRegistry::FromProperties(
37
+ parameters.contextContainer->at<winrt::Microsoft::ReactNative::ReactContext>("MSRN.ReactContext")
38
+ .Properties())
39
+ ->GetDescriptor(flavor);
40
+
41
+ rawPropsParser_.prepare<ConcreteProps>();
42
+ }
43
+ facebook::react::ComponentHandle getComponentHandle() const override {
44
+ return reinterpret_cast<facebook::react::ComponentHandle>(getComponentName());
45
+ }
46
+
47
+ facebook::react::ComponentName getComponentName() const override {
48
+ return std::static_pointer_cast<std::string const>(this->flavor_)->c_str();
49
+ }
50
+
51
+ facebook::react::ShadowNodeTraits getTraits() const override {
52
+ auto traits = ShadowNodeT::BaseTraits();
53
+ if (winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
54
+ ->MeasureContentHandler()) {
55
+ traits.set(facebook::react::ShadowNodeTraits::LeafYogaNode);
56
+ traits.set(facebook::react::ShadowNodeTraits::MeasurableYogaNode);
57
+ }
58
+ return traits;
59
+ }
28
60
 
29
- facebook::react::ComponentHandle getComponentHandle() const override;
30
- facebook::react::ComponentName getComponentName() const override;
31
- facebook::react::ShadowNodeTraits getTraits() const override;
32
61
  std::shared_ptr<facebook::react::ShadowNode> createShadowNode(
33
62
  const facebook::react::ShadowNodeFragment &fragment,
34
- facebook::react::ShadowNodeFamily::Shared const &family) const override;
63
+ facebook::react::ShadowNodeFamily::Shared const &family) const override {
64
+ auto shadowNode = std::make_shared<ShadowNodeT>(fragment, family, getTraits());
65
+ shadowNode->Proxy(winrt::make<winrt::Microsoft::ReactNative::implementation::YogaLayoutableShadowNode>(shadowNode));
66
+ winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
67
+ ->CreateShadowNode(shadowNode->Proxy());
68
+
69
+ adopt(*shadowNode);
70
+ return shadowNode;
71
+ }
72
+
35
73
  facebook::react::ShadowNode::Unshared cloneShadowNode(
36
74
  const facebook::react::ShadowNode &sourceShadowNode,
37
- const facebook::react::ShadowNodeFragment &fragment) const override;
75
+ const facebook::react::ShadowNodeFragment &fragment) const override {
76
+ auto shadowNode = std::make_shared<ShadowNodeT>(sourceShadowNode, fragment);
77
+ shadowNode->Proxy(winrt::make<winrt::Microsoft::ReactNative::implementation::YogaLayoutableShadowNode>(shadowNode));
78
+ winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
79
+ ->CloneShadowNode(shadowNode->Proxy(), static_cast<const ShadowNodeT &>(sourceShadowNode).Proxy());
80
+
81
+ adopt(*shadowNode);
82
+ return shadowNode;
83
+ }
38
84
 
39
85
  void appendChild(
40
86
  const facebook::react::ShadowNode::Shared &parentShadowNode,
41
- const facebook::react::ShadowNode::Shared &childShadowNode) const override;
87
+ const facebook::react::ShadowNode::Shared &childShadowNode) const override {
88
+ auto concreteParentShadowNode = std::static_pointer_cast<const ShadowNodeT>(parentShadowNode);
89
+ auto concreteNonConstParentShadowNode = std::const_pointer_cast<ShadowNodeT>(concreteParentShadowNode);
90
+ concreteNonConstParentShadowNode->appendChild(childShadowNode);
91
+ }
92
+
42
93
  virtual facebook::react::Props::Shared cloneProps(
43
94
  const facebook::react::PropsParserContext &context,
44
95
  const facebook::react::Props::Shared &props,
45
- facebook::react::RawProps rawProps) const override;
96
+ facebook::react::RawProps rawProps) const override {
97
+ // Optimization:
98
+ // Quite often nodes are constructed with default/empty props: the base
99
+ // `props` object is `null` (there no base because it's not cloning) and the
100
+ // `rawProps` is empty. In this case, we can return the default props object
101
+ // of a concrete type entirely bypassing parsing.
102
+ if (!props && rawProps.isEmpty()) {
103
+ return ShadowNodeT::defaultSharedProps();
104
+ }
105
+
106
+ if constexpr (facebook::react::RawPropsFilterable<ShadowNodeT>) {
107
+ ShadowNodeT::filterRawProps(rawProps);
108
+ }
109
+
110
+ rawProps.parse(rawPropsParser_);
111
+
112
+ // Call old-style constructor
113
+ // auto shadowNodeProps = std::make_shared<ShadowNodeT::Props>(context, rawProps, props);
114
+ auto shadowNodeProps = std::make_shared<AbiViewProps>(
115
+ context, props ? static_cast<AbiViewProps const &>(*props) : *ShadowNodeT::defaultSharedProps(), rawProps);
116
+ auto viewProps =
117
+ winrt::make<winrt::Microsoft::ReactNative::implementation::ViewProps>(shadowNodeProps, false /*holdRef*/);
118
+ auto userProps =
119
+ winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
120
+ ->CreateProps(viewProps, props ? static_cast<AbiViewProps const &>(*props).UserProps() : nullptr);
121
+ shadowNodeProps->SetUserProps(userProps, viewProps);
122
+
123
+ const auto &dynamic = static_cast<folly::dynamic>(rawProps);
124
+ for (const auto &pair : dynamic.items()) {
125
+ const auto &propName = pair.first.getString();
126
+ auto hash = RAW_PROPS_KEY_HASH(propName);
127
+ shadowNodeProps.get()->setProp(context, hash, propName.c_str(), facebook::react::RawValue(pair.second));
128
+ userProps.SetProp(
129
+ hash, winrt::to_hstring(propName), winrt::make<winrt::Microsoft::ReactNative::DynamicReader>(pair.second));
130
+ }
131
+ return shadowNodeProps;
132
+ }
133
+
46
134
  virtual facebook::react::State::Shared createInitialState(
47
135
  facebook::react::Props::Shared const &props,
48
- facebook::react::ShadowNodeFamily::Shared const &family) const override;
136
+ facebook::react::ShadowNodeFamily::Shared const &family) const override {
137
+ if (std::is_same<ConcreteStateData, facebook::react::StateData>::value) {
138
+ // Default case: Returning `null` for nodes that don't use `State`.
139
+ return nullptr;
140
+ }
141
+
142
+ return std::make_shared<ConcreteState>(
143
+ std::make_shared<ConcreteStateData const>(
144
+ ConcreteAbiViewComponentDescriptor<ShadowNodeT>::initialStateData(props, family, *this)),
145
+ family);
146
+ }
147
+
49
148
  virtual facebook::react::State::Shared createState(
50
149
  facebook::react::ShadowNodeFamily const &family,
51
- facebook::react::StateData::Shared const &data) const override;
150
+ facebook::react::StateData::Shared const &data) const override {
151
+ if (std::is_same<ConcreteStateData, facebook::react::StateData>::value) {
152
+ // Default case: Returning `null` for nodes that don't use `State`.
153
+ return nullptr;
154
+ }
155
+
156
+ react_native_assert(data && "Provided `data` is nullptr.");
157
+
158
+ return std::make_shared<ConcreteState const>(
159
+ std::static_pointer_cast<ConcreteStateData const>(data), *family.getMostRecentState());
160
+ }
52
161
 
53
162
  facebook::react::ShadowNodeFamily::Shared createFamily(
54
- facebook::react::ShadowNodeFamilyFragment const &fragment) const override;
163
+ facebook::react::ShadowNodeFamilyFragment const &fragment) const override {
164
+ auto eventEmitter = std::make_shared<const ConcreteEventEmitter>(
165
+ std::make_shared<facebook::react::EventTarget>(fragment.instanceHandle, fragment.surfaceId), eventDispatcher_);
166
+ return std::make_shared<facebook::react::ShadowNodeFamily>(
167
+ fragment, std::move(eventEmitter), eventDispatcher_, *this);
168
+ }
55
169
 
56
170
  protected:
57
171
  /*
@@ -66,15 +180,44 @@ class AbiViewComponentDescriptor : public facebook::react::ComponentDescriptor {
66
180
  * - Set `ShadowNode`'s size from state in
67
181
  * `ModalHostViewComponentDescriptor`.
68
182
  */
69
- virtual void adopt(facebook::react::ShadowNode &shadowNode) const;
183
+ virtual void adopt(facebook::react::ShadowNode &shadowNode) const {
184
+ react_native_assert(shadowNode.getComponentHandle() == getComponentHandle());
185
+
186
+ auto &abiViewShadowNode = static_cast<AbiViewShadowNode &>(shadowNode);
187
+
188
+ abiViewShadowNode.Builder(m_builder);
189
+
190
+ if (winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(m_builder)
191
+ ->MeasureContentHandler()) {
192
+ abiViewShadowNode.dirtyLayout();
193
+ abiViewShadowNode.enableMeasurement();
194
+ }
195
+ }
70
196
 
71
197
  private:
72
198
  static ConcreteStateData initialStateData(
73
- const facebook::react::Props::Shared & /*props*/,
199
+ const facebook::react::Props::Shared &props,
74
200
  const facebook::react::ShadowNodeFamily::Shared & /*family*/,
75
- const facebook::react::ComponentDescriptor & /*componentDescriptor*/) noexcept;
201
+ const facebook::react::ComponentDescriptor &componentDescriptor) noexcept {
202
+ return {winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(
203
+ static_cast<const ConcreteAbiViewComponentDescriptor<ShadowNodeT> &>(componentDescriptor).m_builder)
204
+ ->InitialStateData(std::static_pointer_cast<AbiViewProps const>(props)->UserProps())};
205
+ return {};
206
+ }
76
207
 
77
- winrt::Microsoft::ReactNative::IReactViewComponentBuilder m_builder;
208
+ winrt::Microsoft::ReactNative::IReactViewComponentBuilder m_builder{nullptr};
209
+ };
210
+
211
+ class AbiViewComponentDescriptor : public ConcreteAbiViewComponentDescriptor<AbiViewShadowNode> {
212
+ public:
213
+ AbiViewComponentDescriptor(facebook::react::ComponentDescriptorParameters const &parameters)
214
+ : ConcreteAbiViewComponentDescriptor<AbiViewShadowNode>(parameters) {}
215
+ };
216
+
217
+ class AbiPortalComponentDescriptor : public ConcreteAbiViewComponentDescriptor<AbiPortalShadowNode> {
218
+ public:
219
+ AbiPortalComponentDescriptor(facebook::react::ComponentDescriptorParameters const &parameters)
220
+ : ConcreteAbiViewComponentDescriptor<AbiPortalShadowNode>(parameters) {}
78
221
  };
79
222
 
80
223
  } // namespace Microsoft::ReactNative
@@ -639,7 +639,6 @@ facebook::react::Tag ComponentView::hitTest(
639
639
  }
640
640
 
641
641
  winrt::IInspectable ComponentView::EnsureUiaProvider() noexcept {
642
- assert(false);
643
642
  return nullptr;
644
643
  }
645
644
 
@@ -15,8 +15,6 @@
15
15
  #include <Fabric/Composition/CompositionViewComponentView.h>
16
16
  #include <Fabric/Composition/DebuggingOverlayComponentView.h>
17
17
  #include <Fabric/Composition/ImageComponentView.h>
18
- #include <Fabric/Composition/Modal/WindowsModalHostViewComponentView.h>
19
- #include <Fabric/Composition/Modal/WindowsModalHostViewShadowNode.h>
20
18
  #include <Fabric/Composition/ParagraphComponentView.h>
21
19
  #include <Fabric/Composition/RootComponentView.h>
22
20
  #include <Fabric/Composition/ScrollViewComponentView.h>
@@ -59,9 +57,6 @@ ComponentViewDescriptor const &ComponentViewRegistry::dequeueComponentViewWithCo
59
57
  } else if (componentHandle == facebook::react::ImageShadowNode::Handle()) {
60
58
  view = winrt::Microsoft::ReactNative::Composition::implementation::ImageComponentView::Create(
61
59
  compContext, tag, m_context);
62
- } else if (componentHandle == facebook::react::WindowsModalHostViewShadowNode::Handle()) {
63
- view = winrt::Microsoft::ReactNative::Composition::implementation::WindowsModalHostComponentView::Create(
64
- compContext, tag, m_context);
65
60
  } else if (componentHandle == facebook::react::WindowsTextInputShadowNode::Handle()) {
66
61
  view = winrt::Microsoft::ReactNative::Composition::implementation::WindowsTextInputComponentView::Create(
67
62
  compContext, tag, m_context);
@@ -202,8 +202,6 @@ HRESULT __stdcall CompositionDynamicAutomationProvider::GetPatternProvider(PATTE
202
202
  winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(strongView)->props());
203
203
  if (props == nullptr)
204
204
  return UIA_E_ELEMENTNOTAVAILABLE;
205
- auto accessibilityRole =
206
- props->accessibilityRole.empty() ? compositionView->DefaultControlType() : props->accessibilityRole;
207
205
  // Invoke control pattern is used to support controls that do not maintain state
208
206
  // when activated but rather initiate or perform a single, unambiguous action.
209
207
  if (patternId == UIA_InvokePatternId && (props->onAccessibilityTap)) {
@@ -142,9 +142,8 @@ struct CompositionInputKeyboardSource : winrt::implements<
142
142
 
143
143
  CompositionEventHandler::CompositionEventHandler(
144
144
  const winrt::Microsoft::ReactNative::ReactContext &context,
145
- const winrt::Microsoft::ReactNative::ReactNativeIsland &reactNativeIsland,
146
- const int fragmentTag)
147
- : m_fragmentTag(fragmentTag), m_context(context), m_wkRootView(reactNativeIsland) {}
145
+ const winrt::Microsoft::ReactNative::ReactNativeIsland &reactNativeIsland)
146
+ : m_context(context), m_wkRootView(reactNativeIsland) {}
148
147
 
149
148
  void CompositionEventHandler::Initialize() noexcept {
150
149
  #ifdef USE_WINUI3
@@ -348,11 +347,8 @@ facebook::react::SurfaceId CompositionEventHandler::SurfaceId() const noexcept {
348
347
 
349
348
  winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView &
350
349
  CompositionEventHandler::RootComponentView() const noexcept {
351
- auto rootComponentViewDescriptor = (::Microsoft::ReactNative::FabricUIManager::FromProperties(m_context.Properties()))
352
- ->GetViewRegistry()
353
- .componentViewDescriptorWithTag(SurfaceId());
354
- return *rootComponentViewDescriptor.view
355
- .as<winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView>();
350
+ auto island = m_wkRootView.get();
351
+ return *winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(island)->GetComponentView();
356
352
  }
357
353
 
358
354
  void CompositionEventHandler::onPointerWheelChanged(
@@ -365,6 +361,9 @@ void CompositionEventHandler::onPointerWheelChanged(
365
361
  facebook::react::Point ptLocal;
366
362
  facebook::react::Point ptScaled = {static_cast<float>(position.X), static_cast<float>(position.Y)};
367
363
 
364
+ // In the case of a sub rootview, we may have a non-zero origin. hitTest takes a pt in the parent coords, so we
365
+ // need to apply the current origin
366
+ ptScaled += RootComponentView().layoutMetrics().frame.origin;
368
367
  auto tag = RootComponentView().hitTest(ptScaled, ptLocal);
369
368
 
370
369
  if (tag == -1)
@@ -977,6 +976,11 @@ void CompositionEventHandler::getTargetPointerArgs(
977
976
  tag = -1;
978
977
 
979
978
  ptScaled = {position.X, position.Y};
979
+
980
+ // In the case of a sub rootview, we may have a non-zero origin. hitTest takes a pt in the parent coords, so we need
981
+ // to apply the current origin
982
+ ptScaled += RootComponentView().layoutMetrics().frame.origin;
983
+
980
984
  if (std::find(m_capturedPointers.begin(), m_capturedPointers.end(), pointerId) != m_capturedPointers.end()) {
981
985
  assert(m_pointerCapturingComponentTag != -1);
982
986
  tag = m_pointerCapturingComponentTag;
@@ -989,30 +993,7 @@ void CompositionEventHandler::getTargetPointerArgs(
989
993
  ptLocal.y = ptScaled.y - (clientRect.top / strongRootView.ScaleFactor());
990
994
  }
991
995
  } else {
992
- if (m_fragmentTag == -1) {
993
- tag = RootComponentView().hitTest(ptScaled, ptLocal);
994
- return;
995
- }
996
-
997
- // check if the fragment tag exists
998
- if (!fabricuiManager->GetViewRegistry().findComponentViewWithTag(m_fragmentTag)) {
999
- return;
1000
- }
1001
-
1002
- auto fagmentView = fabricuiManager->GetViewRegistry().componentViewDescriptorWithTag(m_fragmentTag).view;
1003
- auto fagmentchildren = fagmentView.Children();
1004
-
1005
- // call the hitTest with the fargment as the RootComponent
1006
- for (auto index = fagmentchildren.Size(); index > 0; index--) {
1007
- auto childView = fagmentchildren.GetAt(index - 1);
1008
- auto targetTag =
1009
- winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(childView)->hitTest(
1010
- ptScaled, ptLocal);
1011
- if (targetTag != -1) {
1012
- tag = targetTag;
1013
- break;
1014
- }
1015
- }
996
+ tag = RootComponentView().hitTest(ptScaled, ptLocal);
1016
997
  }
1017
998
  }
1018
999
 
@@ -31,8 +31,7 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
31
31
  public:
32
32
  CompositionEventHandler(
33
33
  const winrt::Microsoft::ReactNative::ReactContext &context,
34
- const winrt::Microsoft::ReactNative::ReactNativeIsland &ReactNativeIsland,
35
- const int fragmentTag);
34
+ const winrt::Microsoft::ReactNative::ReactNativeIsland &ReactNativeIsland);
36
35
  virtual ~CompositionEventHandler();
37
36
 
38
37
  void Initialize() noexcept;
@@ -152,7 +151,6 @@ class CompositionEventHandler : public std::enable_shared_from_this<CompositionE
152
151
 
153
152
  std::map<PointerId, ActiveTouch> m_activeTouches; // iOS is map of touch event args to ActiveTouch..?
154
153
  PointerId m_touchId = 0;
155
- int m_fragmentTag = -1;
156
154
 
157
155
  std::map<PointerId, std::vector<ReactTaggedView>> m_currentlyHoveredViewsPerPointer;
158
156
  winrt::weak_ref<winrt::Microsoft::ReactNative::ReactNativeIsland> m_wkRootView;
@@ -167,7 +167,7 @@ HRESULT __stdcall CompositionRootAutomationProvider::get_ProviderOptions(Provide
167
167
  return S_OK;
168
168
  }
169
169
 
170
- winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView *
170
+ winrt::com_ptr<winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView>
171
171
  CompositionRootAutomationProvider::rootComponentView() noexcept {
172
172
  if (auto rootView = m_wkRootView.get()) {
173
173
  auto innerRootView = winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(rootView);
@@ -63,7 +63,8 @@ class CompositionRootAutomationProvider : public winrt::implements<
63
63
  };
64
64
 
65
65
  private:
66
- winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView *rootComponentView() noexcept;
66
+ winrt::com_ptr<winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView>
67
+ rootComponentView() noexcept;
67
68
 
68
69
  HRESULT AdvisePropertiesAdded(SAFEARRAY *psaProperties) noexcept;
69
70
  HRESULT AdvisePropertiesRemoved(SAFEARRAY *psaProperties) noexcept;