Skip to content

Commit dac9f65

Browse files
committed
Inital validation
1 parent 0806212 commit dac9f65

29 files changed

+617
-6
lines changed

packages/sample-app-fabric/App.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import React from 'react';
99
import {SafeAreaView, StatusBar, useColorScheme} from 'react-native';
1010
import {NewAppScreen} from '@react-native/new-app-screen';
11+
import XamlHost from 'react-native-windows/Libraries/Components/Xaml/XamlHost';
1112

1213
function App(): React.JSX.Element {
1314
const isDarkMode = useColorScheme() === 'dark';
@@ -18,7 +19,9 @@ function App(): React.JSX.Element {
1819
barStyle={isDarkMode ? 'light-content' : 'dark-content'}
1920
backgroundColor="transparent"
2021
translucent
21-
/>
22+
/>
23+
<XamlHost label="sharath" style={{ width: 300, height: 200, borderWidth: 2, borderColor: 'black' }} />
24+
<XamlHost label="sharath" style={{ width: 300, height: 200, borderWidth: 2, borderColor: 'black' }} />
2225
<NewAppScreen />
2326
</SafeAreaView>
2427
);

packages/sample-app-fabric/windows/SampleAppFabric/SampleAppFabric.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@
88

99
#include "NativeModules.h"
1010

11+
#include "../../../../vnext/Microsoft.ReactNative/XamlHost.h"
12+
13+
1114
// A PackageProvider containing any turbo modules you define within this app project
1215
struct CompReactPackageProvider
1316
: winrt::implements<CompReactPackageProvider, winrt::Microsoft::ReactNative::IReactPackageProvider> {
1417
public: // IReactPackageProvider
1518
void CreatePackage(winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder) noexcept {
1619
AddAttributedModules(packageBuilder, true);
20+
RegisterXamlHostComponentView(packageBuilder);
1721
}
1822
};
1923

packages/sample-app-fabric/windows/SampleAppFabric/SampleAppFabric.vcxproj

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@
7777
<DisableSpecificWarnings>4453;28204</DisableSpecificWarnings>
7878
</ClCompile>
7979
<Link>
80-
<AdditionalDependencies>shell32.lib;user32.lib;windowsapp.lib;%(AdditionalDependenices)</AdditionalDependencies>
81-
<SubSystem>Windows</SubSystem>
80+
<AdditionalDependencies>shell32.lib;user32.lib;windowsapp.lib;Microsoft.ReactNative.lib;%(AdditionalDependencies)</AdditionalDependencies>
81+
<AdditionalLibraryDirectories>..\..\..\..\vnext\target\x64\Debug\Microsoft.ReactNative\</AdditionalLibraryDirectories>
82+
<SubSystem>Windows</SubSystem>
8283
<GenerateDebugInformation>true</GenerateDebugInformation>
8384
</Link>
8485
</ItemDefinitionGroup>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<Application
2+
x:Class="Microsoft.ReactNative.XamlApplication"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:local="using:Microsoft.ReactNative">
6+
</Application>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ ContentIslandComponentView::~ContentIslandComponentView() noexcept {
178178
void ContentIslandComponentView::MountChildComponentView(
179179
const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
180180
uint32_t index) noexcept {
181-
assert(false);
181+
//assert(false);
182182
base_type::MountChildComponentView(childComponentView, index);
183183
}
184184

185185
void ContentIslandComponentView::UnmountChildComponentView(
186186
const winrt::Microsoft::ReactNative::ComponentView &childComponentView,
187187
uint32_t index) noexcept {
188-
assert(false);
188+
//assert(false);
189189
base_type::UnmountChildComponentView(childComponentView, index);
190190
}
191191

vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
</ImportGroup>
6969
<ImportGroup Label="Shared" />
7070
<Import Project="..\Chakra\Chakra.vcxitems" Label="Shared" />
71-
<Import Project="..\Shared\Shared.vcxitems" Label="Shared" />
71+
<Import Project="..\Shared\Shared.vcxitems" Label="Shared" /><Import Project="..\Shared\Shared.vcxitems" Label="Shared" />
7272
<Import Project="..\Mso\Mso.vcxitems" Label="Shared" />
7373
<Import Project="..\Microsoft.ReactNative.Cxx\Microsoft.ReactNative.Cxx.vcxitems" Label="Shared" />
7474
<ImportGroup Label="PropertySheets">

vnext/Microsoft.ReactNative/Pch/pch.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,20 @@
7777
#include <activeObject/activeObject.h>
7878
#include <functional/functorRef.h>
7979
#include <future/future.h>
80+
81+
#include <winrt/Microsoft.UI.Composition.h>
82+
#include <winrt/Microsoft.UI.Dispatching.h>
83+
#include <winrt/Microsoft.UI.Xaml.Controls.Primitives.h>
84+
#include <winrt/Microsoft.UI.Xaml.Controls.h>
85+
#include <winrt/Microsoft.UI.Xaml.Data.h>
86+
#include <winrt/Microsoft.UI.Xaml.Interop.h>
87+
#include <winrt/Microsoft.UI.Xaml.Markup.h>
88+
#include <winrt/Microsoft.UI.Xaml.Media.h>
89+
#include <winrt/Microsoft.UI.Xaml.Navigation.h>
90+
#include <winrt/Microsoft.UI.Xaml.Shapes.h>
91+
#include <winrt/Microsoft.UI.Xaml.h>
92+
#include <winrt/Microsoft.Windows.ApplicationModel.Resources.h>
93+
#include <winrt/Windows.ApplicationModel.Activation.h>
94+
#include <winrt/Windows.Foundation.Collections.h>
95+
#include <winrt/Windows.Foundation.h>
96+
#include <winrt/Windows.UI.Xaml.Interop.h>
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
#include "pch.h"
2+
#include "XamlApplication.h"
3+
#include "XamlApplication.g.cpp"
4+
5+
#include "winrt/Microsoft.UI.Xaml.XamlTypeInfo.h"
6+
7+
namespace winrt::Microsoft::ReactNative::implementation
8+
{
9+
using namespace ::winrt::Microsoft::UI::Xaml;
10+
using namespace ::winrt::Microsoft::UI::Xaml::Markup;
11+
using namespace ::winrt::Windows::UI::Xaml::Interop;
12+
XamlApplication::XamlApplication()
13+
{
14+
//m_providers.push_back(winrt::make_self<XamlMetaDataProvider>().as<winrt::Microsoft::UI::Xaml::Markup::IXamlMetadataProvider>());
15+
s_current = *this;
16+
17+
// TODO: It's probably not a good idea to only load the controls pri file, there are other ones too.
18+
auto resourceManager =
19+
winrt::Microsoft::Windows::ApplicationModel::Resources::ResourceManager(L"Microsoft.UI.Xaml.Controls.pri");
20+
21+
this->ResourceManagerRequested([resourceManager](auto &&, ResourceManagerRequestedEventArgs args) {
22+
args.CustomResourceManager(resourceManager);
23+
});
24+
winrt::Microsoft::UI::Xaml::Hosting::WindowsXamlManager::InitializeForCurrentThread();
25+
26+
m_providers.push_back(
27+
winrt::make_self<XamlMetaDataProvider>()
28+
.as<winrt::Microsoft::UI::Xaml::Markup::IXamlMetadataProvider>()); // Default generated provider
29+
m_providers.push_back(winrt::Microsoft::UI::Xaml::XamlTypeInfo::XamlControlsXamlMetaDataProvider());
30+
31+
auto winUIResources = winrt::Microsoft::UI::Xaml::Controls::XamlControlsResources();
32+
Resources().MergedDictionaries().Append(winUIResources);
33+
}
34+
35+
XamlApplication::~XamlApplication()
36+
{
37+
s_current = nullptr;
38+
}
39+
40+
void XamlApplication::AddMetadataProvider(winrt::Microsoft::UI::Xaml::Markup::IXamlMetadataProvider const& otherProvider)
41+
{
42+
m_providers.push_back(otherProvider);
43+
}
44+
45+
winrt::Microsoft::UI::Xaml::Markup::IXamlType XamlApplication::GetXamlType(winrt::Windows::UI::Xaml::Interop::TypeName const& type)
46+
{
47+
for (auto &&provider : m_providers) {
48+
if (auto result = provider.GetXamlType(type)) {
49+
return result;
50+
}
51+
}
52+
return nullptr;
53+
}
54+
55+
winrt::Microsoft::UI::Xaml::Markup::IXamlType XamlApplication::GetXamlType(hstring const& fullName)
56+
{
57+
for (auto &&provider : m_providers) {
58+
if (auto result = provider.GetXamlType(fullName)) {
59+
return result;
60+
}
61+
}
62+
63+
return nullptr;
64+
}
65+
com_array<winrt::Microsoft::UI::Xaml::Markup::XmlnsDefinition> XamlApplication::GetXmlnsDefinitions()
66+
{
67+
std::vector<::winrt::Microsoft::UI::Xaml::Markup::XmlnsDefinition> allDefinitions;
68+
for (const auto &provider : m_providers) {
69+
auto definitionsCurrentProvider = provider.GetXmlnsDefinitions();
70+
for (const auto &definition : definitionsCurrentProvider) {
71+
allDefinitions.insert(allDefinitions.begin(), definition);
72+
}
73+
}
74+
return winrt::com_array<::winrt::Microsoft::UI::Xaml::Markup::XmlnsDefinition>(
75+
allDefinitions.begin(), allDefinitions.end());
76+
}
77+
78+
winrt::Microsoft::ReactNative::XamlApplication XamlApplication::s_current{nullptr};
79+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#pragma once
2+
#include "XamlApplication.g.h"
3+
4+
#include "winrt/Microsoft.UI.Xaml.Hosting.h"
5+
#include "winrt/Microsoft.UI.Xaml.Interop.h"
6+
#include "winrt/Microsoft.UI.Xaml.Markup.h"
7+
#include "winrt/Microsoft.UI.Xaml.h"
8+
9+
#include "winrt/Windows.UI.Xaml.Interop.h"
10+
11+
#include "XamlMetaDataProvider.h"
12+
13+
namespace winrt::Microsoft::ReactNative::implementation
14+
{
15+
struct XamlApplication : XamlApplicationT<XamlApplication>
16+
{
17+
XamlApplication();
18+
~XamlApplication();
19+
20+
static void EnsureCreated()
21+
{
22+
if (Current() == nullptr) {
23+
s_current = winrt::make<winrt::Microsoft::ReactNative::implementation::XamlApplication>();
24+
}
25+
}
26+
27+
static winrt::Microsoft::ReactNative::XamlApplication Current()
28+
{
29+
return s_current;
30+
}
31+
32+
void AddMetadataProvider(winrt::Microsoft::UI::Xaml::Markup::IXamlMetadataProvider const& otherProvider);
33+
winrt::Microsoft::UI::Xaml::Markup::IXamlType GetXamlType(winrt::Windows::UI::Xaml::Interop::TypeName const& type);
34+
winrt::Microsoft::UI::Xaml::Markup::IXamlType GetXamlType(hstring const& fullName);
35+
com_array<winrt::Microsoft::UI::Xaml::Markup::XmlnsDefinition> GetXmlnsDefinitions();
36+
37+
private:
38+
static winrt::Microsoft::ReactNative::XamlApplication s_current;
39+
std::vector<winrt::Microsoft::UI::Xaml::Markup::IXamlMetadataProvider> m_providers;
40+
};
41+
}
42+
namespace winrt::Microsoft::ReactNative::factory_implementation
43+
{
44+
struct XamlApplication : XamlApplicationT<XamlApplication, implementation::XamlApplication>
45+
{
46+
};
47+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
namespace Microsoft.ReactNative {
5+
[webhosthidden][default_interface] runtimeclass XamlApplication : Microsoft.UI.Xaml.Application,
6+
Microsoft.UI.Xaml.Markup.IXamlMetadataProvider {
7+
XamlApplication();
8+
9+
static void EnsureCreated();
10+
11+
static XamlApplication Current {
12+
get;
13+
};
14+
15+
void AddMetadataProvider(Microsoft.UI.Xaml.Markup.IXamlMetadataProvider otherProvider);
16+
}
17+
} // namespace Microsoft.ReactNative. Xaml

0 commit comments

Comments
 (0)