Skip to content

Commit dbc7ce3

Browse files
Drop XamlHost component
1 parent e4ec885 commit dbc7ce3

12 files changed

+28
-47
lines changed

vnext/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,14 @@ void ReactCompositionViewComponentBuilder::SetUnmountChildComponentViewHandler(
227227
m_unmountChildComponentViewHandler = impl;
228228
}
229229

230+
bool ReactCompositionViewComponentBuilder::XamlSupport() noexcept {
231+
return m_xamlSupport;
232+
}
233+
234+
void ReactCompositionViewComponentBuilder::XamlSupport(bool isRequired) noexcept {
235+
m_xamlSupport = isRequired;
236+
}
237+
230238
const UnmountChildComponentViewDelegate &ReactCompositionViewComponentBuilder::UnmountChildComponentViewHandler()
231239
const noexcept {
232240
return m_unmountChildComponentViewHandler;

vnext/Microsoft.ReactNative/Fabric/Composition/ReactCompositionViewComponentBuilder.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ struct ReactCompositionViewComponentBuilder
3939
void SetUpdateEventEmitterHandler(UpdateEventEmitterDelegate impl) noexcept;
4040
void SetMountChildComponentViewHandler(MountChildComponentViewDelegate impl) noexcept;
4141
void SetUnmountChildComponentViewHandler(UnmountChildComponentViewDelegate impl) noexcept;
42+
void XamlSupport() const noexcept;
43+
bool XamlSupport() noexcept;
4244

4345
public: // Composition::IReactCompositionViewComponentBuilder
4446
void SetViewComponentViewInitializer(const ViewComponentViewInitializer &initializer) noexcept;
@@ -108,6 +110,7 @@ struct ReactCompositionViewComponentBuilder
108110
winrt::Microsoft::ReactNative::Composition::Experimental::IVisualToMountChildrenIntoDelegate
109111
m_visualToMountChildrenIntoHandler;
110112
UpdateLayoutMetricsDelegate m_updateLayoutMetricsHandler;
113+
bool m_xamlSupport{false};
111114
};
112115

113116
} // namespace winrt::Microsoft::ReactNative::Composition

vnext/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ bool WindowsComponentDescriptorRegistry::hasComponentProvider(const std::string
5454
return std::find(m_componentNames.begin(), m_componentNames.end(), name) != m_componentNames.end();
5555
}
5656

57+
bool WindowsComponentDescriptorRegistry::isXamlSupportRequired() const noexcept {
58+
return std::any_of(m_builderByName.cbegin(), m_builderByName.cend(), [](const auto& pair) -> bool {
59+
return winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(pair.second)
60+
->XamlSupport();
61+
});
62+
}
63+
5764
void WindowsComponentDescriptorRegistry::Add(
5865
winrt::hstring componentName,
5966
winrt::Microsoft::ReactNative::ReactViewComponentProvider const &provider) noexcept {

vnext/Microsoft.ReactNative/Fabric/WindowsComponentDescriptorRegistry.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ struct WindowsComponentDescriptorRegistry {
3434

3535
bool hasComponentProvider(const std::string &name) noexcept;
3636

37+
// Returns true if any component requested for XAML support.
38+
bool isXamlSupportRequired() const noexcept;
39+
3740
private:
3841
void add(const facebook::react::ComponentDescriptorProvider &provider) noexcept;
3942

vnext/Microsoft.ReactNative/IReactViewComponentBuilder.idl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ namespace Microsoft.ReactNative
124124
void SetUpdateEventEmitterHandler(UpdateEventEmitterDelegate impl);
125125
void SetMountChildComponentViewHandler(MountChildComponentViewDelegate impl);
126126
void SetUnmountChildComponentViewHandler(UnmountChildComponentViewDelegate impl);
127+
Boolean XamlSupport { get; set; };
127128
};
128129

129130
// [exclusiveto(ShadowNode)]

vnext/Microsoft.ReactNative/ReactNativeHost.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <winrt/Windows.Foundation.Collections.h>
1414
#include "IReactContext.h"
1515
#include "ReactInstanceSettings.h"
16+
#include "XamlApplication.h"
1617

1718
#include <Fabric/Composition/Modal/WindowsModalHostViewComponentView.h>
1819
#include <Fabric/WindowsComponentDescriptorRegistry.h>
@@ -102,6 +103,10 @@ IAsyncAction ReactNativeHost::ReloadInstance() noexcept {
102103
}
103104
}
104105

106+
if (componentregistry->isXamlSupportRequired()) {
107+
winrt::Microsoft::ReactNative::Xaml::implementation::XamlApplication::EnsureCreated();
108+
}
109+
105110
ReactPropertyBag(m_instanceSettings.Properties()).Set(ReactNativeHostProperty(), get_weak());
106111

107112
Mso::React::ReactOptions reactOptions{};

vnext/Shared/Shared.vcxitems

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,6 @@
139139
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true' OR '$(SupportWinUI3Islands)' != 'true'">true</ExcludedFromBuild>
140140
<DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\XamlApplication.idl</DependentUpon>
141141
<SubType>Code</SubType>
142-
</ClCompile>
143-
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\XamlHost.cpp">
144-
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true' OR '$(SupportWinUI3Islands)' != 'true'">true</ExcludedFromBuild>
145-
<DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\XamlApplication.idl</DependentUpon>
146-
<SubType>Code</SubType>
147142
</ClCompile>
148143
<ClCompile Include="$(MSBuildThisFileDirectory)BaseFileReaderResource.cpp" />
149144
<ClCompile Include="$(MSBuildThisFileDirectory)BaseScriptStoreImpl.cpp" />
@@ -248,11 +243,6 @@
248243
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true' OR '$(SupportWinUI3Islands)' != 'true'">true</ExcludedFromBuild>
249244
<DependentUpon>$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\XamlApplication.idl</DependentUpon>
250245
<SubType>Code</SubType>
251-
</ClInclude>
252-
<ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\XamlHost.h">
253-
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true' OR '$(SupportWinUI3Islands)' != 'true'">true</ExcludedFromBuild>
254-
<DependentUpon>$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\XamlApplication.idl</DependentUpon>
255-
<SubType>Code</SubType>
256246
</ClInclude>
257247
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\DynamicReader.cpp">
258248
<DependentUpon>$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\IJSValueReader.idl</DependentUpon>

vnext/overrides.json

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -694,18 +694,6 @@
694694
"file": "src-win/src/private/specs_DEPRECATED/modules/NativePlatformConstantsWindows.js",
695695
"baseFile": "packages/react-native/src/private/specs_DEPRECATED/modules/NativePlatformConstantsAndroid.js",
696696
"baseHash": "365c5df75b38b129d364af3f6700cb206ce5bd2a"
697-
},
698-
{
699-
"type": "platform",
700-
"file": "src-win/Libraries/Components/Xaml/XamlHost.d.ts"
701-
},
702-
{
703-
"type": "platform",
704-
"file": "src-win/Libraries/Components/Xaml/XamlHost.windows.js"
705-
},
706-
{
707-
"type": "platform",
708-
"file": "src-win/src/private/specs_DEPRECATED/components/Xaml/XamlHostNativeComponent.js"
709697
}
710698
]
711-
}
699+
}

vnext/src-win/Libraries/Components/Xaml/XamlHost.d.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.

vnext/src-win/Libraries/Components/Xaml/XamlHost.windows.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)