Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "none",
"comment": "Initialize Xaml on demand only for module authors",
"packageName": "react-native-windows",
"email": "[email protected]",
"dependentChangeType": "none"
}
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,14 @@ void ReactCompositionViewComponentBuilder::SetUnmountChildComponentViewHandler(
m_unmountChildComponentViewHandler = impl;
}

bool ReactCompositionViewComponentBuilder::XamlSupport() const noexcept {
return m_xamlSupport;
}

void ReactCompositionViewComponentBuilder::XamlSupport(bool isRequired) noexcept {
m_xamlSupport = isRequired;
}

const UnmountChildComponentViewDelegate &ReactCompositionViewComponentBuilder::UnmountChildComponentViewHandler()
const noexcept {
return m_unmountChildComponentViewHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ struct ReactCompositionViewComponentBuilder
void SetUpdateEventEmitterHandler(UpdateEventEmitterDelegate impl) noexcept;
void SetMountChildComponentViewHandler(MountChildComponentViewDelegate impl) noexcept;
void SetUnmountChildComponentViewHandler(UnmountChildComponentViewDelegate impl) noexcept;
bool XamlSupport() const noexcept;
void XamlSupport(bool isRequired) noexcept;

public: // Composition::IReactCompositionViewComponentBuilder
void SetViewComponentViewInitializer(const ViewComponentViewInitializer &initializer) noexcept;
Expand Down Expand Up @@ -108,6 +110,7 @@ struct ReactCompositionViewComponentBuilder
winrt::Microsoft::ReactNative::Composition::Experimental::IVisualToMountChildrenIntoDelegate
m_visualToMountChildrenIntoHandler;
UpdateLayoutMetricsDelegate m_updateLayoutMetricsHandler;
bool m_xamlSupport{false};
};

} // namespace winrt::Microsoft::ReactNative::Composition
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ bool WindowsComponentDescriptorRegistry::hasComponentProvider(const std::string
return std::find(m_componentNames.begin(), m_componentNames.end(), name) != m_componentNames.end();
}

bool WindowsComponentDescriptorRegistry::isXamlSupportRequired() const noexcept {
return std::any_of(m_builderByName.cbegin(), m_builderByName.cend(), [](const auto &pair) -> bool {
return winrt::get_self<winrt::Microsoft::ReactNative::Composition::ReactCompositionViewComponentBuilder>(
pair.second)
->XamlSupport();
});
}

void WindowsComponentDescriptorRegistry::Add(
winrt::hstring componentName,
winrt::Microsoft::ReactNative::ReactViewComponentProvider const &provider) noexcept {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ struct WindowsComponentDescriptorRegistry {

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

// Returns true if any component requested for XAML support.
bool isXamlSupportRequired() const noexcept;

private:
void add(const facebook::react::ComponentDescriptorProvider &provider) noexcept;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ namespace Microsoft.ReactNative
void SetUpdateEventEmitterHandler(UpdateEventEmitterDelegate impl);
void SetMountChildComponentViewHandler(MountChildComponentViewDelegate impl);
void SetUnmountChildComponentViewHandler(UnmountChildComponentViewDelegate impl);
Boolean XamlSupport { get; set; };
};

// [exclusiveto(ShadowNode)]
Expand Down
11 changes: 0 additions & 11 deletions vnext/Microsoft.ReactNative/IXamlProvider.idl

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@
DISABLE_XAML_GENERATED_MAIN;
REACTWINDOWS_BUILD;
RN_PLATFORM=windows;
RNW_XAML_ISLAND;
NOMINMAX;
FOLLY_CFG_NO_COROUTINES;
FOLLY_NO_CONFIG;
Expand Down
9 changes: 9 additions & 0 deletions vnext/Microsoft.ReactNative/ReactNativeHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#include <winrt/Windows.Foundation.Collections.h>
#include "IReactContext.h"
#include "ReactInstanceSettings.h"
#ifdef RNW_XAML_ISLAND
#include "XamlApplication.h"
#endif // RNW_XAML_ISLAND

#include <Fabric/Composition/Modal/WindowsModalHostViewComponentView.h>
#include <Fabric/WindowsComponentDescriptorRegistry.h>
Expand Down Expand Up @@ -102,6 +105,12 @@ IAsyncAction ReactNativeHost::ReloadInstance() noexcept {
}
}

#ifdef RNW_XAML_ISLAND
if (componentregistry->isXamlSupportRequired()) {
winrt::Microsoft::ReactNative::Xaml::implementation::XamlApplication::EnsureCreated();
}
#endif // RNW_XAML_ISLAND

ReactPropertyBag(m_instanceSettings.Properties()).Set(ReactNativeHostProperty(), get_weak());

Mso::React::ReactOptions reactOptions{};
Expand Down
11 changes: 0 additions & 11 deletions vnext/Shared/Shared.vcxitems
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true' OR '$(SupportWinUI3Islands)' != 'true'">true</ExcludedFromBuild>
<DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\XamlApplication.idl</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\XamlHost.cpp">
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true' OR '$(SupportWinUI3Islands)' != 'true'">true</ExcludedFromBuild>
<DependentUpon>$(ReactNativeWindowsDir)Microsoft.ReactNative\XamlApplication.idl</DependentUpon>
<SubType>Code</SubType>
</ClCompile>
<ClCompile Include="$(MSBuildThisFileDirectory)BaseFileReaderResource.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)BaseScriptStoreImpl.cpp" />
Expand Down Expand Up @@ -248,11 +243,6 @@
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true' OR '$(SupportWinUI3Islands)' != 'true'">true</ExcludedFromBuild>
<DependentUpon>$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\XamlApplication.idl</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
<ClInclude Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\XamlHost.h">
<ExcludedFromBuild Condition="'$(UseFabric)' != 'true' OR '$(SupportWinUI3Islands)' != 'true'">true</ExcludedFromBuild>
<DependentUpon>$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\XamlApplication.idl</DependentUpon>
<SubType>Code</SubType>
</ClInclude>
<ClCompile Include="$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\DynamicReader.cpp">
<DependentUpon>$(MSBuildThisFileDirectory)..\Microsoft.ReactNative\IJSValueReader.idl</DependentUpon>
Expand Down Expand Up @@ -612,7 +602,6 @@
<Midl Condition="'$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\ViewProps.idl" />
<Midl Condition="'$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\ReactNativeAppBuilder.idl" />
<Midl Condition="('$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' == 'true') AND '$(SupportWinUI3Islands)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\XamlApplication.idl" />
<Midl Condition="('$(UseFabric)' == 'true' OR '$(IncludeFabricInterface)' == 'true') AND '$(SupportWinUI3Islands)' == 'true'" Include="$(ReactNativeWindowsDir)Microsoft.ReactNative\IXamlProvider.idl" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(NodeApiJsiDir)src\ApiLoaders\HermesApi.h" />
Expand Down
14 changes: 1 addition & 13 deletions vnext/overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -694,18 +694,6 @@
"file": "src-win/src/private/specs_DEPRECATED/modules/NativePlatformConstantsWindows.js",
"baseFile": "packages/react-native/src/private/specs_DEPRECATED/modules/NativePlatformConstantsAndroid.js",
"baseHash": "365c5df75b38b129d364af3f6700cb206ce5bd2a"
},
{
"type": "platform",
"file": "src-win/Libraries/Components/Xaml/XamlHost.d.ts"
},
{
"type": "platform",
"file": "src-win/Libraries/Components/Xaml/XamlHost.windows.js"
},
{
"type": "platform",
"file": "src-win/src/private/specs_DEPRECATED/components/Xaml/XamlHostNativeComponent.js"
}
]
}
}
13 changes: 0 additions & 13 deletions vnext/src-win/Libraries/Components/Xaml/XamlHost.d.ts

This file was deleted.

7 changes: 0 additions & 7 deletions vnext/src-win/Libraries/Components/Xaml/XamlHost.windows.js

This file was deleted.

3 changes: 0 additions & 3 deletions vnext/src-win/index.windows.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,6 @@ module.exports = {
get AppTheme() {
return require('./Libraries/AppTheme/AppTheme').AppTheme;
},
get XamlHost() {
return require('./Libraries/Components/Xaml/XamlHost').default;
},
} as ReactNativePublicAPI;

if (__DEV__) {
Expand Down
1 change: 0 additions & 1 deletion vnext/src-win/index.windows.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,6 @@ export {HandledEventPhase } from './Libraries/Components/View/ViewPropTypes'

export {default as ViewWindows} from './Libraries/Components/View/View';
export {AppTheme} from './Libraries/AppTheme/AppTheme';
export {default as XamlHost} from './Libraries/Components/Xaml/XamlHost';
// End Windows Specific exports

// #endregion

This file was deleted.

Loading