react-native-windows 0.75.1 → 0.75.2

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 (53) hide show
  1. package/Microsoft.ReactNative/ComponentView.idl +33 -32
  2. package/Microsoft.ReactNative/Composition.Input.idl +2 -0
  3. package/Microsoft.ReactNative/CompositionComponentView.idl +43 -24
  4. package/Microsoft.ReactNative/Fabric/AbiEventEmitter.cpp +21 -0
  5. package/Microsoft.ReactNative/Fabric/AbiEventEmitter.h +23 -0
  6. package/Microsoft.ReactNative/Fabric/AbiShadowNode.cpp +7 -0
  7. package/Microsoft.ReactNative/Fabric/AbiShadowNode.h +3 -0
  8. package/Microsoft.ReactNative/Fabric/ComponentView.cpp +318 -59
  9. package/Microsoft.ReactNative/Fabric/ComponentView.h +155 -33
  10. package/Microsoft.ReactNative/Fabric/Composition/ActivityIndicatorComponentView.cpp +2 -2
  11. package/Microsoft.ReactNative/Fabric/Composition/ComponentViewRegistry.cpp +3 -0
  12. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.cpp +25 -7
  13. package/Microsoft.ReactNative/Fabric/Composition/Composition.Input.h +22 -4
  14. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.cpp +43 -0
  15. package/Microsoft.ReactNative/Fabric/Composition/CompositionDynamicAutomationProvider.h +6 -1
  16. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +147 -119
  17. package/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.h +4 -8
  18. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.cpp +97 -101
  19. package/Microsoft.ReactNative/Fabric/Composition/CompositionViewComponentView.h +28 -52
  20. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.cpp +133 -0
  21. package/Microsoft.ReactNative/Fabric/Composition/ContentIslandComponentView.h +61 -0
  22. package/Microsoft.ReactNative/Fabric/Composition/DebuggingOverlayComponentView.cpp +1 -2
  23. package/Microsoft.ReactNative/Fabric/Composition/ImageComponentView.cpp +1 -4
  24. package/Microsoft.ReactNative/Fabric/Composition/Modal/WindowsModalHostViewComponentView.cpp +1 -2
  25. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.cpp +1 -6
  26. package/Microsoft.ReactNative/Fabric/Composition/ParagraphComponentView.h +0 -1
  27. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp +108 -18
  28. package/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h +33 -5
  29. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +57 -1
  30. package/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.h +6 -0
  31. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.cpp +8 -2
  32. package/Microsoft.ReactNative/Fabric/Composition/RootComponentView.h +2 -0
  33. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.cpp +195 -182
  34. package/Microsoft.ReactNative/Fabric/Composition/ScrollViewComponentView.h +1 -3
  35. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.cpp +16 -4
  36. package/Microsoft.ReactNative/Fabric/Composition/SwitchComponentView.h +3 -3
  37. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.cpp +12 -17
  38. package/Microsoft.ReactNative/Fabric/Composition/TextInput/WindowsTextInputComponentView.h +4 -11
  39. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.cpp +19 -0
  40. package/Microsoft.ReactNative/Fabric/Composition/UiaHelpers.h +4 -0
  41. package/Microsoft.ReactNative/Fabric/Composition/UnimplementedNativeViewComponentView.cpp +1 -2
  42. package/Microsoft.ReactNative/Fabric/FabricUIManagerModule.cpp +10 -7
  43. package/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp +1 -3
  44. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.cpp +20 -1
  45. package/Microsoft.ReactNative/Fabric/platform/react/renderer/components/view/HostPlatformViewProps.h +3 -0
  46. package/Microsoft.ReactNative/IReactCompositionViewComponentBuilder.idl +13 -3
  47. package/Microsoft.ReactNative/IReactViewComponentBuilder.idl +57 -4
  48. package/Microsoft.ReactNative/ReactNativeIsland.idl +3 -0
  49. package/PropertySheets/Generated/PackageVersion.g.props +3 -3
  50. package/PropertySheets/WinUI.props +1 -1
  51. package/Shared/Shared.vcxitems +7 -0
  52. package/just-task.js +1 -1
  53. package/package.json +3 -3
@@ -0,0 +1,61 @@
1
+
2
+ // Copyright (c) Microsoft Corporation.
3
+ // Licensed under the MIT License.
4
+
5
+ #pragma once
6
+
7
+ #include <Fabric/ComponentView.h>
8
+
9
+ #include <Microsoft.ReactNative.Cxx/ReactContext.h>
10
+ #include <winrt/Microsoft.UI.Content.h>
11
+ #include <winrt/Windows.UI.Composition.h>
12
+ #include "CompositionHelpers.h"
13
+ #include "CompositionViewComponentView.h"
14
+
15
+ #pragma warning(push)
16
+ #pragma warning(disable : 4244 4305)
17
+ #include <react/renderer/components/view/ViewProps.h>
18
+ #pragma warning(pop)
19
+ #include "Composition.ContentIslandComponentView.g.h"
20
+
21
+ namespace winrt::Microsoft::ReactNative::Composition::implementation {
22
+
23
+ struct ContentIslandComponentView : ContentIslandComponentViewT<ContentIslandComponentView, ViewComponentView> {
24
+ using Super = ContentIslandComponentViewT<ContentIslandComponentView, ViewComponentView>;
25
+
26
+ void MountChildComponentView(
27
+ const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
28
+ uint32_t index) noexcept override;
29
+ void UnmountChildComponentView(
30
+ const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
31
+ uint32_t index) noexcept override;
32
+ void Connect(const winrt::Microsoft::UI::Content::ContentIsland &contentIsland) noexcept;
33
+
34
+ void updateLayoutMetrics(
35
+ facebook::react::LayoutMetrics const &layoutMetrics,
36
+ facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept;
37
+
38
+ void prepareForRecycle() noexcept override;
39
+
40
+ ContentIslandComponentView(
41
+ const winrt::Microsoft::ReactNative::Composition::Experimental::ICompositionContext &compContext,
42
+ facebook::react::Tag tag,
43
+ winrt::Microsoft::ReactNative::ReactContext const &reactContext);
44
+ ~ContentIslandComponentView() noexcept;
45
+
46
+ private:
47
+ void OnMounted() noexcept;
48
+ void OnUnmounted() noexcept;
49
+ void ParentLayoutChanged() noexcept;
50
+
51
+ bool m_layoutChangePosted{false};
52
+ winrt::Microsoft::UI::Content::ContentIsland m_islandToConnect{nullptr};
53
+ winrt::event_token m_mountedToken;
54
+ winrt::event_token m_unmountedToken;
55
+ std::vector<winrt::Microsoft::ReactNative::ComponentView::LayoutMetricsChanged_revoker> m_layoutMetricChangedRevokers;
56
+ #ifdef USE_EXPERIMENTAL_WINUI3
57
+ winrt::Microsoft::UI::Content::ChildContentLink m_childContentLink{nullptr};
58
+ #endif
59
+ };
60
+
61
+ } // namespace winrt::Microsoft::ReactNative::Composition::implementation
@@ -21,8 +21,7 @@ DebuggingOverlayComponentView::DebuggingOverlayComponentView(
21
21
  reactContext,
22
22
  ComponentViewFeatures::Default &
23
23
  ~(ComponentViewFeatures::Background | ComponentViewFeatures::ShadowProps |
24
- ComponentViewFeatures::NativeBorder),
25
- false) {}
24
+ ComponentViewFeatures::NativeBorder)) {}
26
25
 
27
26
  void DebuggingOverlayComponentView::MountChildComponentView(
28
27
  const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
@@ -72,8 +72,7 @@ ImageComponentView::ImageComponentView(
72
72
  compContext,
73
73
  tag,
74
74
  reactContext,
75
- ComponentViewFeatures::Default & ~ComponentViewFeatures::Background,
76
- false) {}
75
+ ComponentViewFeatures::Default & ~ComponentViewFeatures::Background) {}
77
76
 
78
77
  void ImageComponentView::MountChildComponentView(
79
78
  const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
@@ -189,7 +188,6 @@ void ImageComponentView::prepareForRecycle() noexcept {
189
188
  winrt::Microsoft::ReactNative::ImageProps ImageComponentView::ImageProps() noexcept {
190
189
  // We do not currently support custom ImageComponentView's
191
190
  // If we did we would need to create a AbiImageProps and possibly return them here
192
- assert(!m_customComponent);
193
191
  return winrt::make<winrt::Microsoft::ReactNative::implementation::ImageProps>(viewProps());
194
192
  }
195
193
 
@@ -200,7 +198,6 @@ winrt::Microsoft::ReactNative::ImageProps ImageComponentView::ViewProps() noexce
200
198
  winrt::Microsoft::ReactNative::ViewProps ImageComponentView::ViewPropsInner() noexcept {
201
199
  // We do not currently support custom ImageComponentView's
202
200
  // If we did we would need to create a AbiImageProps and possibly return them here
203
- assert(!m_customComponent);
204
201
  return winrt::make<winrt::Microsoft::ReactNative::implementation::ImageProps>(viewProps());
205
202
  }
206
203
 
@@ -27,8 +27,7 @@ WindowsModalHostComponentView::WindowsModalHostComponentView(
27
27
  compContext,
28
28
  tag,
29
29
  reactContext,
30
- ComponentViewFeatures::Default & ~ComponentViewFeatures::Background,
31
- false) {
30
+ ComponentViewFeatures::Default & ~ComponentViewFeatures::Background) {
32
31
  m_context = reactContext; // save context
33
32
  }
34
33
 
@@ -27,8 +27,7 @@ ParagraphComponentView::ParagraphComponentView(
27
27
  compContext,
28
28
  tag,
29
29
  reactContext,
30
- ComponentViewFeatures::Default & ~ComponentViewFeatures::Background,
31
- false) {}
30
+ ComponentViewFeatures::Default & ~ComponentViewFeatures::Background) {}
32
31
 
33
32
  void ParagraphComponentView::MountChildComponentView(
34
33
  const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
@@ -68,10 +67,6 @@ void ParagraphComponentView::updateProps(
68
67
  Super::updateProps(props, oldProps);
69
68
  }
70
69
 
71
- void ParagraphComponentView::updateEventEmitter(facebook::react::EventEmitter::Shared const &eventEmitter) noexcept {
72
- Super::updateEventEmitter(eventEmitter);
73
- }
74
-
75
70
  void ParagraphComponentView::updateState(
76
71
  facebook::react::State::Shared const &state,
77
72
  facebook::react::State::Shared const &oldState) noexcept {
@@ -33,7 +33,6 @@ struct ParagraphComponentView : ParagraphComponentViewT<ParagraphComponentView,
33
33
  uint32_t index) noexcept override;
34
34
  void updateProps(facebook::react::Props::Shared const &props, facebook::react::Props::Shared const &oldProps) noexcept
35
35
  override;
36
- void updateEventEmitter(facebook::react::EventEmitter::Shared const &eventEmitter) noexcept override;
37
36
  void updateLayoutMetrics(
38
37
  facebook::react::LayoutMetrics const &layoutMetrics,
39
38
  facebook::react::LayoutMetrics const &oldLayoutMetrics) noexcept override;
@@ -4,6 +4,7 @@
4
4
  #include "pch.h"
5
5
  #include "ReactCompositionViewComponentBuilder.h"
6
6
  #include <Fabric/Composition/CompositionViewComponentView.h>
7
+ #include <Fabric/Composition/ContentIslandComponentView.h>
7
8
  #include <strsafe.h>
8
9
  #include "DynamicWriter.h"
9
10
  #include "ReactHost/MsoUtils.h"
@@ -46,16 +47,74 @@ LayoutHandler ReactCompositionViewComponentBuilder::LayoutHandler() const noexce
46
47
  return m_layoutHandler;
47
48
  }
48
49
 
49
- void ReactCompositionViewComponentBuilder::SetCreateComponentView(ComponentViewFactory impl) noexcept {
50
- m_createComponentView = impl;
51
- assert(!m_createView); // Only SetCreateComponentView OR SetCreateViewComponentView should be called
50
+ void ReactCompositionViewComponentBuilder::InitializeComponentView(
51
+ const winrt::Microsoft::ReactNative::ComponentView &view) noexcept {
52
+ auto self = winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(view);
53
+ self->MarkAsCustomComponent();
54
+ if (m_customCommandHandler)
55
+ self->CustomCommandHandler(m_customCommandHandler);
56
+ if (m_finalizeUpdateHandler)
57
+ self->FinalizeUpdateHandler(m_finalizeUpdateHandler);
58
+ if (m_updatePropsHandler)
59
+ self->UpdatePropsHandler(m_updatePropsHandler);
60
+ if (m_updateStateHandler)
61
+ self->UpdateStateHandler(m_updateStateHandler);
62
+ if (m_updateEventEmitterHandler)
63
+ self->UpdateEventEmitterHandler(m_updateEventEmitterHandler);
64
+ if (m_mountChildComponentViewHandler)
65
+ self->MountChildComponentViewHandler(m_mountChildComponentViewHandler);
66
+ if (m_unmountChildComponentViewHandler)
67
+ self->UnmountChildComponentViewHandler(m_unmountChildComponentViewHandler);
68
+ if (m_createVisualHandler)
69
+ view.as<winrt::Microsoft::ReactNative::Composition::implementation::ViewComponentView>()->CreateVisualHandler(
70
+ m_createVisualHandler);
71
+ }
72
+
73
+ void ReactCompositionViewComponentBuilder::SetComponentViewInitializer(
74
+ const ComponentViewInitializer &initializer) noexcept {
75
+ m_fnCreateView =
76
+ [initializer](const IReactContext &reactContext, int32_t tag, const Experimental::ICompositionContext &context) {
77
+ auto view = winrt::make<winrt::Microsoft::ReactNative::implementation::ComponentView>(tag, reactContext);
78
+ initializer(view);
79
+ return view;
80
+ };
81
+ m_descriptorConstructorFactory = []() {
82
+ return &facebook::react::concreteComponentDescriptorConstructor<::Microsoft::ReactNative::AbiComponentDescriptor>;
83
+ };
84
+ }
85
+
86
+ void ReactCompositionViewComponentBuilder::SetViewComponentViewInitializer(
87
+ const ViewComponentViewInitializer &initializer) noexcept {
88
+ m_fnCreateView =
89
+ [initializer](const IReactContext &reactContext, int32_t tag, const Experimental::ICompositionContext &context) {
90
+ auto view = winrt::Microsoft::ReactNative::Composition::implementation::ViewComponentView::Create(
91
+ context, tag, reactContext)
92
+ .as<winrt::Microsoft::ReactNative::Composition::ViewComponentView>();
93
+ initializer(view);
94
+ return view;
95
+ };
96
+ m_descriptorConstructorFactory = []() {
97
+ return &facebook::react::concreteComponentDescriptorConstructor<
98
+ ::Microsoft::ReactNative::AbiViewComponentDescriptor>;
99
+ };
100
+ }
101
+
102
+ void ReactCompositionViewComponentBuilder::SetContentIslandComponentViewInitializer(
103
+ const ComponentIslandComponentViewInitializer &initializer) noexcept {
104
+ m_fnCreateView = [initializer](
105
+ const IReactContext &reactContext, int32_t tag, const Experimental::ICompositionContext &context)
106
+ -> winrt::Microsoft::ReactNative::Composition::ContentIslandComponentView {
107
+ auto view = winrt::make<winrt::Microsoft::ReactNative::Composition::implementation::ContentIslandComponentView>(
108
+ context, tag, reactContext);
109
+ initializer(view);
110
+ return view;
111
+ };
112
+ m_descriptorConstructorFactory = []() {
113
+ return &facebook::react::concreteComponentDescriptorConstructor<
114
+ ::Microsoft::ReactNative::AbiViewComponentDescriptor>;
115
+ };
52
116
  }
53
117
 
54
- void ReactCompositionViewComponentBuilder::SetCreateViewComponentView(
55
- CompositionViewComponentViewFactory impl) noexcept {
56
- m_createView = impl;
57
- assert(!m_createComponentView); // Only SetCreateComponentView OR SetCreateViewComponentView should be called
58
- }
59
118
  // (Object handle, Microsoft.ReactNative.IComponentState state) => void
60
119
  // void ReactCompositionViewComponentBuilder::SetStateUpdater(StateUpdater impl) noexcept {
61
120
  // m_stateUpdater = impl;
@@ -93,22 +152,53 @@ void ReactCompositionViewComponentBuilder::SetLayoutHandler(
93
152
  m_layoutHandler = impl;
94
153
  }
95
154
 
155
+ void ReactCompositionViewComponentBuilder::SetCustomCommandHandler(HandleCommandDelegate impl) noexcept {
156
+ m_customCommandHandler = impl;
157
+ }
158
+
159
+ void ReactCompositionViewComponentBuilder::SetFinalizeUpdateHandler(UpdateFinalizerDelegate impl) noexcept {
160
+ m_finalizeUpdateHandler = impl;
161
+ }
162
+
163
+ void ReactCompositionViewComponentBuilder::SetUpdatePropsHandler(UpdatePropsDelegate impl) noexcept {
164
+ m_updatePropsHandler = impl;
165
+ }
166
+
167
+ void ReactCompositionViewComponentBuilder::SetUpdateStateHandler(UpdateStateDelegate impl) noexcept {
168
+ m_updateStateHandler = impl;
169
+ }
170
+
171
+ void ReactCompositionViewComponentBuilder::SetUpdateEventEmitterHandler(UpdateEventEmitterDelegate impl) noexcept {
172
+ m_updateEventEmitterHandler = impl;
173
+ }
174
+
175
+ void ReactCompositionViewComponentBuilder::SetMountChildComponentViewHandler(
176
+ MountChildComponentViewDelegate impl) noexcept {
177
+ m_mountChildComponentViewHandler = impl;
178
+ }
179
+
180
+ void ReactCompositionViewComponentBuilder::SetUnmountChildComponentViewHandler(
181
+ UnmountChildComponentViewDelegate impl) noexcept {
182
+ m_unmountChildComponentViewHandler = impl;
183
+ }
184
+
185
+ void ReactCompositionViewComponentBuilder::SetCreateVisualHandler(CreateVisualDelegate impl) noexcept {
186
+ m_createVisualHandler = impl;
187
+ }
188
+
96
189
  winrt::Microsoft::ReactNative::ComponentView ReactCompositionViewComponentBuilder::CreateView(
97
190
  const IReactContext &reactContext,
98
191
  int32_t tag,
99
192
  const Experimental::ICompositionContext &context) noexcept {
100
- if (m_createView) {
101
- auto args = winrt::make<implementation::CreateCompositionComponentViewArgs>(reactContext, tag, context);
102
- return m_createView(args);
103
- } else {
104
- assert(m_createComponentView);
105
- auto args = winrt::make<winrt::Microsoft::ReactNative::implementation::CreateComponentViewArgs>(reactContext, tag);
106
- return m_createComponentView(args);
107
- }
193
+ assert(m_fnCreateView);
194
+ auto view = m_fnCreateView(reactContext, tag, context);
195
+ InitializeComponentView(view);
196
+ return view;
108
197
  }
109
198
 
110
- bool ReactCompositionViewComponentBuilder::IsViewComponent() const noexcept {
111
- return m_createView != nullptr;
199
+ facebook::react::ComponentDescriptorConstructor *ReactCompositionViewComponentBuilder::GetComponentDescriptorProvider()
200
+ const noexcept {
201
+ return m_descriptorConstructorFactory();
112
202
  }
113
203
 
114
204
  } // namespace winrt::Microsoft::ReactNative::Composition
@@ -2,6 +2,9 @@
2
2
  // Copyright (c) Microsoft Corporation.
3
3
  // Licensed under the MIT License.
4
4
 
5
+ #include <Fabric/AbiComponentDescriptor.h>
6
+ #include <Fabric/AbiViewComponentDescriptor.h>
7
+ #include <react/renderer/componentregistry/ComponentDescriptorProvider.h>
5
8
  #include <react/renderer/core/ReactPrimitives.h>
6
9
  #include "winrt/Microsoft.ReactNative.Composition.Experimental.h"
7
10
  #include "winrt/Microsoft.ReactNative.Composition.h"
@@ -16,7 +19,7 @@ struct ReactCompositionViewComponentBuilder : winrt::implements<
16
19
  ReactCompositionViewComponentBuilder() noexcept;
17
20
 
18
21
  public: // IReactViewComponentBuilder
19
- void SetCreateComponentView(ComponentViewFactory impl) noexcept;
22
+ void SetComponentViewInitializer(const ComponentViewInitializer &initializer) noexcept;
20
23
  void SetCreateProps(ViewPropsFactory impl) noexcept;
21
24
 
22
25
  // (Object handle, Microsoft.ReactNative.IComponentState state) => void
@@ -28,8 +31,19 @@ struct ReactCompositionViewComponentBuilder : winrt::implements<
28
31
  void SetMeasureContentHandler(MeasureContentHandler impl) noexcept;
29
32
  void SetLayoutHandler(LayoutHandler impl) noexcept;
30
33
 
34
+ void SetCustomCommandHandler(HandleCommandDelegate impl) noexcept;
35
+ void SetFinalizeUpdateHandler(UpdateFinalizerDelegate impl) noexcept;
36
+ void SetUpdatePropsHandler(UpdatePropsDelegate impl) noexcept;
37
+ void SetUpdateStateHandler(UpdateStateDelegate impl) noexcept;
38
+ void SetUpdateEventEmitterHandler(UpdateEventEmitterDelegate impl) noexcept;
39
+ void SetMountChildComponentViewHandler(MountChildComponentViewDelegate impl) noexcept;
40
+ void SetUnmountChildComponentViewHandler(UnmountChildComponentViewDelegate impl) noexcept;
41
+
31
42
  public: // Composition::IReactCompositionViewComponentBuilder
32
- void SetCreateViewComponentView(CompositionViewComponentViewFactory impl) noexcept;
43
+ void SetViewComponentViewInitializer(const ViewComponentViewInitializer &initializer) noexcept;
44
+ void SetContentIslandComponentViewInitializer(const ComponentIslandComponentViewInitializer &initializer) noexcept;
45
+
46
+ void SetCreateVisualHandler(CreateVisualDelegate impl) noexcept;
33
47
 
34
48
  public:
35
49
  IComponentProps CreateProps(ViewProps props) noexcept;
@@ -39,7 +53,7 @@ struct ReactCompositionViewComponentBuilder : winrt::implements<
39
53
  winrt::Microsoft::ReactNative::IComponentProps props) noexcept;
40
54
  MeasureContentHandler MeasureContentHandler() const noexcept;
41
55
  LayoutHandler LayoutHandler() const noexcept;
42
- bool IsViewComponent() const noexcept;
56
+ facebook::react::ComponentDescriptorConstructor *GetComponentDescriptorProvider() const noexcept;
43
57
 
44
58
  winrt::Microsoft::ReactNative::ComponentView CreateView(
45
59
  const IReactContext &reactContext,
@@ -47,15 +61,29 @@ struct ReactCompositionViewComponentBuilder : winrt::implements<
47
61
  const Experimental::ICompositionContext &context) noexcept;
48
62
 
49
63
  private:
64
+ void InitializeComponentView(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept;
65
+
50
66
  ViewPropsFactory m_propsFactory;
51
67
  ViewShadowNodeFactory m_shadowNodeFactory;
52
68
  ViewShadowNodeCloner m_shadowNodeCloner;
53
69
  InitialStateDataFactory m_initialStateDataFactory;
54
70
  winrt::Microsoft::ReactNative::MeasureContentHandler m_measureContent;
55
71
  winrt::Microsoft::ReactNative::LayoutHandler m_layoutHandler;
72
+ std::function<winrt::Microsoft::ReactNative::ComponentView(
73
+ const IReactContext &reactContext,
74
+ int32_t tag,
75
+ const Experimental::ICompositionContext &context)>
76
+ m_fnCreateView;
77
+ std::function<facebook::react::ComponentDescriptorConstructor *()> m_descriptorConstructorFactory;
78
+ winrt::Microsoft::ReactNative::HandleCommandDelegate m_customCommandHandler;
79
+ winrt::Microsoft::ReactNative::UpdateFinalizerDelegate m_finalizeUpdateHandler;
80
+ winrt::Microsoft::ReactNative::UpdatePropsDelegate m_updatePropsHandler;
81
+ winrt::Microsoft::ReactNative::UpdateStateDelegate m_updateStateHandler;
82
+ winrt::Microsoft::ReactNative::UpdateEventEmitterDelegate m_updateEventEmitterHandler;
83
+ winrt::Microsoft::ReactNative::MountChildComponentViewDelegate m_mountChildComponentViewHandler;
84
+ winrt::Microsoft::ReactNative::UnmountChildComponentViewDelegate m_unmountChildComponentViewHandler;
56
85
 
57
- ComponentViewFactory m_createComponentView{nullptr};
58
- CompositionViewComponentViewFactory m_createView{nullptr};
86
+ winrt::Microsoft::ReactNative::Composition::CreateVisualDelegate m_createVisualHandler;
59
87
  };
60
88
 
61
89
  } // namespace winrt::Microsoft::ReactNative::Composition
@@ -143,9 +143,13 @@ ReactNativeIsland::ReactNativeIsland(const winrt::Microsoft::UI::Composition::Co
143
143
 
144
144
  ReactNativeIsland::~ReactNativeIsland() noexcept {
145
145
  #ifdef USE_WINUI3
146
- if (m_island && m_island.IsConnected()) {
146
+ if (m_island) {
147
147
  m_island.AutomationProviderRequested(m_islandAutomationProviderRequestedToken);
148
148
  m_island.StateChanged(m_islandStateChangedToken);
149
+ #ifdef USE_EXPERIMENTAL_WINUI3
150
+ m_island.Connected(m_islandConnectedToken);
151
+ m_island.Disconnected(m_islandDisconnectedToken);
152
+ #endif
149
153
  }
150
154
  #endif
151
155
 
@@ -199,6 +203,12 @@ void ReactNativeIsland::AddRenderedVisual(
199
203
  assert(!m_hasRenderedVisual);
200
204
  InternalRootVisual().InsertAt(visual, 0);
201
205
  m_hasRenderedVisual = true;
206
+
207
+ if (m_mounted) {
208
+ if (auto componentView = GetComponentView()) {
209
+ componentView->onMounted();
210
+ }
211
+ }
202
212
  }
203
213
 
204
214
  void ReactNativeIsland::RemoveRenderedVisual(
@@ -398,6 +408,7 @@ void ReactNativeIsland::InitRootView(
398
408
  m_context = winrt::Microsoft::ReactNative::ReactContext(std::move(context));
399
409
  m_reactViewOptions = std::move(viewOptions);
400
410
  m_CompositionEventHandler = std::make_shared<::Microsoft::ReactNative::CompositionEventHandler>(m_context, *this);
411
+ m_CompositionEventHandler->Initialize();
401
412
 
402
413
  UpdateRootViewInternal();
403
414
 
@@ -761,13 +772,58 @@ winrt::Microsoft::UI::Content::ContentIsland ReactNativeIsland::Island() {
761
772
  if (args.DidRasterizationScaleChange()) {
762
773
  pThis->ScaleFactor(island.RasterizationScale());
763
774
  }
775
+ #ifndef USE_EXPERIMENTAL_WINUI3 // Use this in place of Connected/Disconnected events for now. -- Its not quite what we
776
+ // want, but it will do for now.
777
+ if (args.DidSiteVisibleChange()) {
778
+ if (island.IsSiteVisible()) {
779
+ pThis->OnMounted();
780
+ } else {
781
+ pThis->OnUnmounted();
782
+ }
783
+ }
784
+ #endif
764
785
  }
765
786
  });
787
+ #ifdef USE_EXPERIMENTAL_WINUI3
788
+ m_islandConnectedToken = m_island.Connected(
789
+ [weakThis = get_weak()](
790
+ winrt::IInspectable const &, winrt::Microsoft::UI::Content::ContentIsland const &island) {
791
+ if (auto pThis = weakThis.get()) {
792
+ pThis->OnMounted();
793
+ }
794
+ });
795
+
796
+ m_islandDisconnectedToken = m_island.Disconnected(
797
+ [weakThis = get_weak()](
798
+ winrt::IInspectable const &, winrt::Microsoft::UI::Content::ContentIsland const &island) {
799
+ if (auto pThis = weakThis.get()) {
800
+ pThis->OnUnmounted();
801
+ }
802
+ });
803
+ #endif
766
804
  }
767
805
  return m_island;
768
806
  }
769
807
  #endif
770
808
 
809
+ void ReactNativeIsland::OnMounted() noexcept {
810
+ if (m_mounted)
811
+ return;
812
+ m_mounted = true;
813
+ if (auto componentView = GetComponentView()) {
814
+ componentView->onMounted();
815
+ }
816
+ }
817
+
818
+ void ReactNativeIsland::OnUnmounted() noexcept {
819
+ if (!m_mounted)
820
+ return;
821
+ m_mounted = false;
822
+ if (auto componentView = GetComponentView()) {
823
+ componentView->onUnmounted();
824
+ }
825
+ }
826
+
771
827
  winrt::Microsoft::ReactNative::Composition::implementation::RootComponentView *
772
828
  ReactNativeIsland::GetComponentView() noexcept {
773
829
  if (!m_context || m_context.Handle().LoadingState() != winrt::Microsoft::ReactNative::LoadingState::Loaded ||
@@ -61,6 +61,9 @@ struct ReactNativeIsland
61
61
  winrt::Microsoft::ReactNative::Composition::Experimental::IVisual InternalRootVisual() noexcept;
62
62
  void InternalRootVisual(winrt::Microsoft::ReactNative::Composition::Experimental::IVisual const &value) noexcept;
63
63
 
64
+ void OnMounted() noexcept;
65
+ void OnUnmounted() noexcept;
66
+
64
67
  // property Size
65
68
  winrt::Windows::Foundation::Size Size() noexcept;
66
69
  void Size(winrt::Windows::Foundation::Size value) noexcept;
@@ -126,6 +129,8 @@ struct ReactNativeIsland
126
129
  winrt::event_token m_islandFrameworkClosedToken;
127
130
  winrt::event_token m_islandAutomationProviderRequestedToken;
128
131
  winrt::event_token m_islandStateChangedToken;
132
+ winrt::event_token m_islandConnectedToken;
133
+ winrt::event_token m_islandDisconnectedToken;
129
134
  #endif
130
135
 
131
136
  HWND m_hwnd{0};
@@ -133,6 +138,7 @@ struct ReactNativeIsland
133
138
  bool m_isJSViewAttached{false};
134
139
  bool m_hasRenderedVisual{false};
135
140
  bool m_showingLoadingUI{false};
141
+ bool m_mounted{false};
136
142
  IReactDispatcher m_uiDispatcher{nullptr};
137
143
  winrt::IInspectable m_uiaProvider{nullptr};
138
144
  int64_t m_rootTag{-1};
@@ -24,8 +24,7 @@ RootComponentView::RootComponentView(
24
24
  reactContext,
25
25
  ComponentViewFeatures::Default &
26
26
  ~(ComponentViewFeatures::Background | ComponentViewFeatures::ShadowProps |
27
- ComponentViewFeatures::NativeBorder),
28
- false) {}
27
+ ComponentViewFeatures::NativeBorder)) {}
29
28
 
30
29
  RootComponentView::~RootComponentView() {
31
30
  if (auto rootView = m_wkRootView.get()) {
@@ -203,6 +202,13 @@ winrt::IInspectable RootComponentView::UiaProviderFromPoint(const POINT &ptPixel
203
202
  return winrt::get_self<winrt::Microsoft::ReactNative::implementation::ComponentView>(view)->EnsureUiaProvider();
204
203
  }
205
204
 
205
+ winrt::Microsoft::UI::Content::ContentIsland RootComponentView::parentContentIsland() noexcept {
206
+ if (auto rootView = m_wkRootView.get()) {
207
+ return winrt::get_self<winrt::Microsoft::ReactNative::implementation::ReactNativeIsland>(rootView)->Island();
208
+ }
209
+ return nullptr;
210
+ }
211
+
206
212
  winrt::Microsoft::ReactNative::implementation::ClipState RootComponentView::getClipState() noexcept {
207
213
  return winrt::Microsoft::ReactNative::implementation::ClipState::NoClip;
208
214
  }
@@ -36,6 +36,8 @@ struct RootComponentView : RootComponentViewT<RootComponentView, ViewComponentVi
36
36
 
37
37
  RootComponentView *rootComponentView() noexcept override;
38
38
 
39
+ winrt::Microsoft::UI::Content::ContentIsland parentContentIsland() noexcept;
40
+
39
41
  // Index that visuals can be inserted into OuterVisual for debugging UI
40
42
  uint32_t overlayIndex() noexcept;
41
43
  void start(const winrt::Microsoft::ReactNative::ReactNativeIsland &rootView) noexcept;