diff --git a/change/react-native-windows-73433f3d-c91f-4ae8-9618-75adc965a722.json b/change/react-native-windows-73433f3d-c91f-4ae8-9618-75adc965a722.json new file mode 100644 index 00000000000..01a2c2b5d7d --- /dev/null +++ b/change/react-native-windows-73433f3d-c91f-4ae8-9618-75adc965a722.json @@ -0,0 +1,7 @@ +{ + "type": "prerelease", + "comment": "Remove Paper-only code from Fabric builds of Microsoft.ReactNative", + "packageName": "react-native-windows", + "email": "jthysell@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/vnext/Desktop/React.Windows.Desktop.vcxproj b/vnext/Desktop/React.Windows.Desktop.vcxproj index 67b07672bc0..13d8a833198 100644 --- a/vnext/Desktop/React.Windows.Desktop.vcxproj +++ b/vnext/Desktop/React.Windows.Desktop.vcxproj @@ -149,9 +149,6 @@ --> CORE_ABI;%(PreprocessorDefinitions) - - USE_FABRIC;%(PreprocessorDefinitions) - diff --git a/vnext/Microsoft.ReactNative.Cxx/ReactContext.h b/vnext/Microsoft.ReactNative.Cxx/ReactContext.h index a095a22624a..9023a39b3f1 100644 --- a/vnext/Microsoft.ReactNative.Cxx/ReactContext.h +++ b/vnext/Microsoft.ReactNative.Cxx/ReactContext.h @@ -65,7 +65,7 @@ struct ReactContext { m_handle.EmitJSEvent(eventEmitterName, eventName, MakeJSValueWriter(std::forward(args)...)); } -#if !defined(CORE_ABI) && !defined(__APPLE__) && !defined(CXXUNITTESTS) +#if !defined(CORE_ABI) && !defined(USE_FABRIC) && !defined(__APPLE__) && !defined(CXXUNITTESTS) // Dispatch eventName event to the view. // args are either function arguments or a single lambda with 'IJSValueWriter const&' argument. template diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp index b254d602ef3..ece0121fcc3 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/CompositionEventHandler.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include diff --git a/vnext/Microsoft.ReactNative/IReactContext.cpp b/vnext/Microsoft.ReactNative/IReactContext.cpp index 522b9335d9a..8e79b0fa2c7 100644 --- a/vnext/Microsoft.ReactNative/IReactContext.cpp +++ b/vnext/Microsoft.ReactNative/IReactContext.cpp @@ -4,7 +4,7 @@ #include "pch.h" #include "IReactContext.h" #include "DynamicWriter.h" -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) #include "XamlUIService.h" #endif @@ -121,7 +121,7 @@ LoadingState ReactContext::LoadingState() noexcept { }; } -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) // Deprecated: Use XamlUIService directly. void ReactContext::DispatchEvent( xaml::FrameworkElement const &view, diff --git a/vnext/Microsoft.ReactNative/IReactContext.h b/vnext/Microsoft.ReactNative/IReactContext.h index d157190c8fd..e22e0cf6f03 100644 --- a/vnext/Microsoft.ReactNative/IReactContext.h +++ b/vnext/Microsoft.ReactNative/IReactContext.h @@ -46,7 +46,7 @@ struct ReactContext : winrt::implements { IInspectable JSRuntime() noexcept; LoadingState LoadingState() noexcept; -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) void DispatchEvent( xaml::FrameworkElement const &view, hstring const &eventName, diff --git a/vnext/Microsoft.ReactNative/IReactContext.idl b/vnext/Microsoft.ReactNative/IReactContext.idl index 8634ae2fc7c..2aebfa210d5 100644 --- a/vnext/Microsoft.ReactNative/IReactContext.idl +++ b/vnext/Microsoft.ReactNative/IReactContext.idl @@ -5,7 +5,7 @@ import "IJSValueWriter.idl"; // The import is to be deprecated with IReactContex import "IReactNotificationService.idl"; import "IReactPropertyBag.idl"; -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) #include "NamespaceRedirect.h" // The include is to be deprecated with IReactContext::DispatchEvent #endif @@ -185,7 +185,7 @@ namespace Microsoft.ReactNative "It is an experimental property that may be removed or changed in a future version.") Object JSRuntime { get; }; -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) [deprecated("Use @XamlUIService.DispatchEvent instead", deprecate, 1)] DOC_STRING("Deprecated property. Use @XamlUIService.DispatchEvent instead. It will be removed in a future version.") void DispatchEvent(XAML_NAMESPACE.FrameworkElement view, String eventName, JSValueArgWriter eventDataArgWriter); diff --git a/vnext/Microsoft.ReactNative/IReactPackageBuilder.idl b/vnext/Microsoft.ReactNative/IReactPackageBuilder.idl index 3790933f43e..4a9675ab5f3 100644 --- a/vnext/Microsoft.ReactNative/IReactPackageBuilder.idl +++ b/vnext/Microsoft.ReactNative/IReactPackageBuilder.idl @@ -3,7 +3,7 @@ import "IReactContext.idl"; import "IReactModuleBuilder.idl"; -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) import "IViewManager.idl"; #endif @@ -14,7 +14,7 @@ namespace Microsoft.ReactNative DOC_STRING("Provides information about a custom native module. See @IReactModuleBuilder.") delegate Object ReactModuleProvider(IReactModuleBuilder moduleBuilder); -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) DOC_STRING("Provides information about a custom view manager. See @IViewManager.") delegate IViewManager ReactViewManagerProvider(); #endif @@ -32,7 +32,7 @@ namespace Microsoft.ReactNative "NOTE: TurboModules using JSI directly will not run correctly while using @ReactInstanceSettings.UseWebDebugger") void AddTurboModule(String moduleName, ReactModuleProvider moduleProvider); -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) DOC_STRING("Adds a custom view manager. See @ReactViewManagerProvider.") void AddViewManager(String viewManagerName, ReactViewManagerProvider viewManagerProvider); #endif diff --git a/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj b/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj index 8896653a690..835bd404bc9 100644 --- a/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj +++ b/vnext/Microsoft.ReactNative/Microsoft.ReactNative.vcxproj @@ -188,16 +188,11 @@ - - - DevMenuControl.xaml - Code - IJSValueReader.idl @@ -208,7 +203,6 @@ IJSValueWriter.idl - IReactDispatcher.idl @@ -265,20 +259,14 @@ - - - - - ReactApplication.idl - IReactContext.idl Code @@ -317,7 +305,6 @@ Timer.idl Code - @@ -331,9 +318,57 @@ + + + + IReactPackageBuilder.idl + + + IReactPropertyBag.idl + Code + + + + + + QuirkSettings.idl + Code + + + ReactPointerEventArgs.idl + Code + + + XamlUIService.idl + Code + + + + + + + DevMenuControl.xaml + Code + + + + LayoutService.idl + Code + + + + + ReactApplication.idl + + + + ReactRootView.idl + Code + + + - @@ -384,55 +419,17 @@ - - - LayoutService.idl - Code - - - XamlUIService.idl - Code - - - IReactPackageBuilder.idl - - - IReactPropertyBag.idl - Code - - - ReactRootView.idl - Code - - - - - - QuirkSettings.idl - Code - - XamlHelper.idl Code + - - ReactPointerEventArgs.idl - Code - - - - - DevMenuControl.xaml - Code - - @@ -467,8 +464,6 @@ - - ReactPointerEventArgs.idl Code @@ -476,11 +471,7 @@ Create - - ReactApplication.idl - - @@ -488,6 +479,37 @@ + + + + XamlUIService.idl + Code + + + + + + + + DevMenuControl.xaml + Code + + + + LayoutService.idl + Code + + + + + ReactApplication.idl + + + ReactRootView.idl + Code + + + @@ -536,53 +558,41 @@ - - - - LayoutService.idl - Code - - - XamlUIService.idl - Code - - - ReactRootView.idl - Code - - - - XamlHelper.idl Code + + + + + + Designer + + + + DevMenuControl.xaml Code - - - - - - Designer - - Designer - + Designer + + + + - @@ -621,7 +631,7 @@ {a9d95a91-4db7-4f72-beb6-fe8a5c89bfbd} - + Designer diff --git a/vnext/Microsoft.ReactNative/Modules/AccessibilityInfoModule.cpp b/vnext/Microsoft.ReactNative/Modules/AccessibilityInfoModule.cpp index 3e5098ccea8..af25b74353d 100644 --- a/vnext/Microsoft.ReactNative/Modules/AccessibilityInfoModule.cpp +++ b/vnext/Microsoft.ReactNative/Modules/AccessibilityInfoModule.cpp @@ -3,9 +3,11 @@ #include "pch.h" #include "AccessibilityInfoModule.h" +#ifndef USE_FABRIC #include #include #include +#endif #include #include #include @@ -50,6 +52,7 @@ void AccessibilityInfo::setAccessibilityFocus(double /*reactTag*/) noexcept { void AccessibilityInfo::announceForAccessibility(std::wstring announcement) noexcept { m_context.UIDispatcher().Post([context = m_context, announcement = std::move(announcement)] { +#ifndef USE_FABRIC // Windows requires a specific element to announce from. Unfortunately the react-native API does not provide a tag // So we need to find something to raise the notification event from. xaml::UIElement element{nullptr}; @@ -77,6 +80,7 @@ void AccessibilityInfo::announceForAccessibility(std::wstring announcement) noex xaml::Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent, hstr, hstr); +#endif }); } diff --git a/vnext/Microsoft.ReactNative/Modules/AlertModule.cpp b/vnext/Microsoft.ReactNative/Modules/AlertModule.cpp index d16763e40da..60eb8fb5dd1 100644 --- a/vnext/Microsoft.ReactNative/Modules/AlertModule.cpp +++ b/vnext/Microsoft.ReactNative/Modules/AlertModule.cpp @@ -5,12 +5,15 @@ #include "AlertModule.h" #include "Unicode.h" +#ifndef USE_FABRIC #include #include #include #include #include #include +#endif + #include #include "Utils/Helpers.h" @@ -36,6 +39,7 @@ void Alert::showAlert( }); } +#ifndef USE_FABRIC void Alert::ProcessPendingAlertRequestsXaml() noexcept { const auto &pendingAlert = pendingAlerts.front(); const auto &args = pendingAlert.args; @@ -155,8 +159,7 @@ void Alert::ProcessPendingAlertRequestsXaml() noexcept { ProcessPendingAlertRequests(); }); } - -#ifdef USE_FABRIC +#else void Alert::ProcessPendingAlertRequestsMessageDialog() noexcept { const auto &pendingAlert = pendingAlerts.front(); const auto &args = pendingAlert.args; @@ -220,10 +223,11 @@ void Alert::ProcessPendingAlertRequests() noexcept { if (pendingAlerts.empty()) return; +#ifndef USE_FABRIC if (xaml::TryGetCurrentUwpXamlApplication()) { ProcessPendingAlertRequestsXaml(); } -#ifdef USE_FABRIC +#else else { // If we don't have xaml loaded, fallback to using MessageDialog ProcessPendingAlertRequestsMessageDialog(); diff --git a/vnext/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.cpp b/vnext/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.cpp index 74cb55d982e..e4e5907cfae 100644 --- a/vnext/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.cpp +++ b/vnext/Microsoft.ReactNative/Modules/Animated/NativeAnimatedNodeManager.cpp @@ -50,7 +50,7 @@ comp::Compositor NativeAnimatedNodeManager::Compositor() const noexcept { compositionContext); } #endif -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) // TODO: Islands - need to get the XamlView associated with this animation in order to // use the compositor Microsoft::ReactNative::GetCompositor(xamlView) return Microsoft::ReactNative::GetCompositor(); diff --git a/vnext/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.cpp b/vnext/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.cpp index c65ea6cde58..2f3c69809c2 100644 --- a/vnext/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.cpp +++ b/vnext/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.cpp @@ -3,13 +3,13 @@ #include "pch.h" -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) #include #include +#include #endif #include -#include #include #include "NativeAnimatedNodeManager.h" #include "PropsAnimatedNode.h" @@ -84,9 +84,11 @@ void PropsAnimatedNode::DisconnectFromView(int64_t viewTag) { } if (m_centerPointAnimation) { +#if !defined(CORE_ABI) && !defined(USE_FABRIC) if (const auto target = GetUIElement()) { target.StopAnimation(m_centerPointAnimation); } +#endif m_centerPointAnimation = nullptr; } m_needsCenterPointAnimation = false; @@ -140,6 +142,7 @@ void PropsAnimatedNode::UpdateView() { } } +#if !defined(CORE_ABI) && !defined(USE_FABRIC) static void EnsureUIElementDirtyForRender(xaml::UIElement uiElement) { auto compositeMode = uiElement.CompositeMode(); switch (compositeMode) { @@ -153,16 +156,19 @@ static void EnsureUIElementDirtyForRender(xaml::UIElement uiElement) { } uiElement.CompositeMode(compositeMode); } +#endif void PropsAnimatedNode::StartAnimations() { assert(m_useComposition); if (m_expressionAnimations.size()) { AnimationView view = GetAnimationView(); if (view) { +#if !defined(CORE_ABI) && !defined(USE_FABRIC) // Work around for https://github.com/microsoft/microsoft-ui-xaml/issues/2511 if (view.m_element) { EnsureUIElementDirtyForRender(view.m_element); } +#endif for (const auto &anim : m_expressionAnimations) { if (anim.second.Target() == L"Translation.X") { m_subchannelPropertySet.StartAnimation(L"TranslationX", anim.second); @@ -177,18 +183,20 @@ void PropsAnimatedNode::StartAnimations() { m_subchannelPropertySet.StartAnimation(L"ScaleY", anim.second); StartAnimation(view, m_scaleCombined); } else if (anim.second.Target() == L"Rotation") { +#if !defined(CORE_ABI) && !defined(USE_FABRIC) if (view.m_element) { view.m_element.RotationAxis(m_rotationAxis); -#ifdef USE_FABRIC - } else { + } +#else + if (view.m_componentView) { auto visual = winrt::Microsoft::ReactNative::Composition::Experimental::CompositionContextHelper::InnerVisual( view.m_componentView .as() ->Visual()); visual.RotationAxis(m_rotationAxis); -#endif } +#endif StartAnimation(view, anim.second); } else { StartAnimation(view, anim.second); @@ -322,20 +330,18 @@ void PropsAnimatedNode::MakeAnimation(int64_t valueNodeTag, FacadeType facadeTyp } } +#if !defined(CORE_ABI) && !defined(USE_FABRIC) Microsoft::ReactNative::ShadowNodeBase *PropsAnimatedNode::GetShadowNodeBase() { -#ifndef CORE_ABI if (const auto uiManager = Microsoft::ReactNative::GetNativeUIManager(m_context).lock()) { if (const auto nativeUIManagerHost = uiManager->getHost()) { return static_cast( nativeUIManagerHost->FindShadowNodeForTag(m_connectedViewTag)); } } -#endif return nullptr; } xaml::UIElement PropsAnimatedNode::GetUIElement() { -#ifndef CORE_ABI if (IsRS5OrHigher()) { if (const auto shadowNodeBase = GetShadowNodeBase()) { if (const auto shadowNodeView = shadowNodeBase->GetView()) { @@ -343,12 +349,12 @@ xaml::UIElement PropsAnimatedNode::GetUIElement() { } } } -#endif return nullptr; } +#endif void PropsAnimatedNode::CommitProps() { -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) if (const auto node = GetShadowNodeBase()) { if (!node->m_zombie) { node->updateProperties(m_props); @@ -358,43 +364,35 @@ void PropsAnimatedNode::CommitProps() { } PropsAnimatedNode::AnimationView PropsAnimatedNode::GetAnimationView() { -#ifdef USE_FABRIC - if (auto fabricuiManager = FabricUIManager::FromProperties(m_context.Properties())) { - auto componentView = fabricuiManager->GetViewRegistry().findComponentViewWithTag( - static_cast(m_connectedViewTag)); - if (componentView) { - return {nullptr, componentView}; - } - } -#endif // USE_FABRIC -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) if (IsRS5OrHigher()) { if (const auto shadowNodeBase = GetShadowNodeBase()) { if (const auto shadowNodeView = shadowNodeBase->GetView()) { -#ifdef USE_FABRIC - return {shadowNodeView.as(), nullptr}; -#else return {shadowNodeView.as()}; -#endif } } } -#endif // CORE_ABI - -#ifdef USE_FABRIC - return {nullptr, nullptr}; #else - return {nullptr}; + if (auto fabricuiManager = FabricUIManager::FromProperties(m_context.Properties())) { + auto componentView = fabricuiManager->GetViewRegistry().findComponentViewWithTag( + static_cast(m_connectedViewTag)); + if (componentView) { + return {componentView}; + } + } #endif + return {nullptr}; } void PropsAnimatedNode::StartAnimation( const AnimationView &view, const comp::CompositionAnimation &animation) noexcept { +#if !defined(CORE_ABI) && !defined(USE_FABRIC) if (view.m_element) { view.m_element.StartAnimation(animation); -#ifdef USE_FABRIC - } else if (view.m_componentView) { + } +#else + if (view.m_componentView) { auto baseComponentView = view.m_componentView.as(); auto visual = winrt::Microsoft::ReactNative::Composition::Experimental::CompositionContextHelper::InnerVisual( @@ -414,17 +412,16 @@ void PropsAnimatedNode::StartAnimation( } visual.StartAnimation(targetProp, animation); } -#endif } +#endif } comp::CompositionPropertySet PropsAnimatedNode::EnsureCenterPointPropertySet(const AnimationView &view) noexcept { -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) if (view.m_element) { return GetShadowNodeBase()->EnsureTransformPS(); } -#endif -#ifdef USE_FABRIC +#else if (view.m_componentView) { return view.m_componentView.as() ->EnsureCenterPointPropertySet(); diff --git a/vnext/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.h b/vnext/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.h index 8b4b0ff60f4..784dc61c5e0 100644 --- a/vnext/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.h +++ b/vnext/Microsoft.ReactNative/Modules/Animated/PropsAnimatedNode.h @@ -36,23 +36,26 @@ class PropsAnimatedNode final : public AnimatedNode { private: struct AnimationView { +#if !defined(CORE_ABI) && !defined(USE_FABRIC) xaml::UIElement m_element; -#ifdef USE_FABRIC +#else winrt::Microsoft::ReactNative::ComponentView m_componentView; #endif operator bool() const noexcept { -#ifdef USE_FABRIC - return m_element || m_componentView; -#else +#if !defined(CORE_ABI) && !defined(USE_FABRIC) return m_element != nullptr; +#else + return m_componentView != nullptr; #endif } }; void CommitProps(); void MakeAnimation(int64_t valueNodeTag, FacadeType facadeType); +#if !defined(CORE_ABI) && !defined(USE_FABRIC) Microsoft::ReactNative::ShadowNodeBase *GetShadowNodeBase(); xaml::UIElement GetUIElement(); +#endif AnimationView GetAnimationView(); void StartAnimation(const AnimationView &view, const comp::CompositionAnimation &animation) noexcept; comp::CompositionPropertySet EnsureCenterPointPropertySet(const AnimationView &view) noexcept; diff --git a/vnext/Microsoft.ReactNative/Modules/LogBoxModule.cpp b/vnext/Microsoft.ReactNative/Modules/LogBoxModule.cpp index e5a227eb6cf..af9161a9981 100644 --- a/vnext/Microsoft.ReactNative/Modules/LogBoxModule.cpp +++ b/vnext/Microsoft.ReactNative/Modules/LogBoxModule.cpp @@ -8,14 +8,15 @@ #include "ReactHost/ReactInstanceWin.h" #include "ReactNativeHost.h" #include "Utils/Helpers.h" -#include "XamlUtils.h" #ifdef USE_FABRIC #include #include #include -#endif +#else #include +#include "XamlUtils.h" +#endif namespace Microsoft::ReactNative { @@ -121,7 +122,7 @@ void LogBox::ShowOnUIThread() noexcept { auto host = React::implementation::ReactNativeHost::GetReactNativeHost(m_context.Properties()); if (!host) return; - +#ifndef USE_FABRIC if (!IsFabricEnabled(m_context.Properties().Handle())) { m_logBoxContent = React::ReactRootView(); m_logBoxContent.ComponentName(L"LogBox"); @@ -170,7 +171,7 @@ void LogBox::ShowOnUIThread() noexcept { m_popup.Child(m_logBoxContent); m_popup.IsOpen(true); } -#ifdef USE_FABRIC +#else else { RegisterWndClass(); @@ -212,7 +213,7 @@ void LogBox::HideOnUIThread() noexcept { if (m_hwnd) { ::ShowWindow(m_hwnd, SW_HIDE); } -#endif // USE_FABRIC +#else // USE_FABRIC if (m_popup) { m_popup.Closed(m_tokenClosed); m_sizeChangedRevoker.revoke(); @@ -220,6 +221,7 @@ void LogBox::HideOnUIThread() noexcept { m_popup = nullptr; m_logBoxContent = nullptr; } +#endif // USE_FABRIC } void LogBox::Initialize(React::ReactContext const &reactContext) noexcept { diff --git a/vnext/Microsoft.ReactNative/Modules/LogBoxModule.h b/vnext/Microsoft.ReactNative/Modules/LogBoxModule.h index b9a55a641ea..1ec3bf92df2 100644 --- a/vnext/Microsoft.ReactNative/Modules/LogBoxModule.h +++ b/vnext/Microsoft.ReactNative/Modules/LogBoxModule.h @@ -32,9 +32,10 @@ struct LogBox : public std::enable_shared_from_this { winrt::Microsoft::ReactNative::ReactContext m_context; #ifdef USE_FABRIC HWND m_hwnd{nullptr}; -#endif // USE_FABRIC +#else xaml::Controls::Primitives::Popup m_popup{nullptr}; winrt::Microsoft::ReactNative::ReactRootView m_logBoxContent{nullptr}; +#endif // USE_FABRIC xaml::FrameworkElement::SizeChanged_revoker m_sizeChangedRevoker; winrt::event_token m_tokenClosed; }; diff --git a/vnext/Microsoft.ReactNative/ReactHost/IReactInstance.h b/vnext/Microsoft.ReactNative/ReactHost/IReactInstance.h index 1c8a7a68523..a12c3c22a8f 100644 --- a/vnext/Microsoft.ReactNative/ReactHost/IReactInstance.h +++ b/vnext/Microsoft.ReactNative/ReactHost/IReactInstance.h @@ -6,7 +6,10 @@ #include #include + +#if !defined(CORE_ABI) && !defined(USE_FABRIC) #include "XamlView.h" +#endif #include #include @@ -15,7 +18,9 @@ namespace Microsoft::ReactNative { struct INativeUIManager; class ExpressionAnimationStore; +#if !defined(CORE_ABI) && !defined(USE_FABRIC) struct IXamlRootView; +#endif typedef unsigned int LiveReloadCallbackCookie; typedef unsigned int ErrorCallbackCookie; diff --git a/vnext/Microsoft.ReactNative/ReactHost/React.h b/vnext/Microsoft.ReactNative/ReactHost/React.h index f909cf9dbcc..dc7867f39b8 100644 --- a/vnext/Microsoft.ReactNative/ReactHost/React.h +++ b/vnext/Microsoft.ReactNative/ReactHost/React.h @@ -22,10 +22,7 @@ #undef GetCurrentTime #endif -#ifndef CORE_ABI -// The IReactInstance.h brings dependency on XAML. Exclude it for the UI technology independent code. #include -#endif #include diff --git a/vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp b/vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp index f5e7506d760..528c880f052 100644 --- a/vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp +++ b/vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.cpp @@ -66,11 +66,16 @@ #include #endif -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) #include +#include +#include "Modules/NativeUIManager.h" +#include "Modules/PaperUIManagerModule.h" +#endif + +#ifndef CORE_ABI #include #include -#include #include "ConfigureBundlerDlg.h" #include "Modules/AccessibilityInfoModule.h" #include "Modules/AlertModule.h" @@ -81,8 +86,6 @@ #include "Modules/I18nManagerModule.h" #include "Modules/LinkingManagerModule.h" #include "Modules/LogBoxModule.h" -#include "Modules/NativeUIManager.h" -#include "Modules/PaperUIManagerModule.h" #else #include "Modules/DesktopTimingModule.h" #endif @@ -163,7 +166,7 @@ struct BridgeUIBatchInstanceCallback final : public facebook::react::InstanceCal UIBatchCompleteCallbackProperty())) { (*callback)(instance->m_reactContext->Properties()); } -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) if (auto uiManager = Microsoft::ReactNative::GetNativeUIManager(*instance->m_reactContext).lock()) { uiManager->onBatchComplete(); } @@ -188,7 +191,7 @@ struct BridgeUIBatchInstanceCallback final : public facebook::react::InstanceCal UIBatchCompleteCallbackProperty())) { (*callback)(instance->m_reactContext->Properties()); } -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) if (auto uiManager = Microsoft::ReactNative::GetNativeUIManager(*instance->m_reactContext).lock()) { uiManager->onBatchComplete(); } @@ -346,15 +349,16 @@ void ReactInstanceWin::LoadModules( } #endif -#ifndef CORE_ABI - +#if !defined(CORE_ABI) && !defined(USE_FABRIC) if (!IsBridgeless()) { registerTurboModule( L"UIManager", // TODO: Use MakeTurboModuleProvider after it satisfies ReactNativeSpecs::UIManagerSpec winrt::Microsoft::ReactNative::MakeModuleProvider<::Microsoft::ReactNative::UIManager>()); } +#endif +#ifndef CORE_ABI registerTurboModule( L"AccessibilityInfo", winrt::Microsoft::ReactNative::MakeTurboModuleProvider<::Microsoft::ReactNative::AccessibilityInfo>()); @@ -496,7 +500,7 @@ void ReactInstanceWin::Initialize() noexcept { void ReactInstanceWin::InitDevMenu() noexcept { Microsoft::ReactNative::DevMenuManager::InitDevMenu(m_reactContext, [weakReactHost = m_weakReactHost]() noexcept { -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) Microsoft::ReactNative::ShowConfigureBundlerDialog(weakReactHost); #endif // CORE_ABI }); @@ -753,7 +757,7 @@ void ReactInstanceWin::InitializeWithBridge() noexcept { InitUIQueue(); InitUIMessageThread(); -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) // InitUIManager uses m_legacyReactInstance InitUIManager(); #endif @@ -1144,7 +1148,7 @@ bool ReactInstanceWin::IsBridgeless() noexcept { winrt::Microsoft::ReactNative::ReactPropertyBag(m_reactContext->Properties())); } -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) void ReactInstanceWin::InitUIManager() noexcept { std::vector> viewManagers; @@ -1445,12 +1449,14 @@ void ReactInstanceWin::AttachMeasuredRootView( if (!useFabric || m_useWebDebugger) { int64_t rootTag = -1; +#if !defined(CORE_ABI) && !defined(USE_FABRIC) if (auto uiManager = Microsoft::ReactNative::GetNativeUIManager(*m_reactContext).lock()) { rootTag = uiManager->AddMeasuredRootView(rootView); rootView->SetTag(rootTag); } else { assert(false); } +#endif std::string jsMainModuleName = rootView->JSComponentName(); folly::dynamic params = folly::dynamic::array( diff --git a/vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h b/vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h index 56e86112aa6..f098dcf6845 100644 --- a/vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h +++ b/vnext/Microsoft.ReactNative/ReactHost/ReactInstanceWin.h @@ -111,7 +111,7 @@ class ReactInstanceWin final : public Mso::ActiveObject void InitNativeMessageThread() noexcept; void InitUIMessageThread() noexcept; void SetupHMRClient() noexcept; -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) void InitUIManager() noexcept; #endif diff --git a/vnext/Microsoft.ReactNative/ReactNativeHost.cpp b/vnext/Microsoft.ReactNative/ReactNativeHost.cpp index 4b41880ffca..67f59d23822 100644 --- a/vnext/Microsoft.ReactNative/ReactNativeHost.cpp +++ b/vnext/Microsoft.ReactNative/ReactNativeHost.cpp @@ -25,7 +25,7 @@ using namespace winrt; using namespace Windows::Foundation; using namespace Windows::Foundation::Collections; -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) using namespace xaml; using namespace xaml::Controls; #endif @@ -88,7 +88,7 @@ ReactNativeHostProperty() noexcept { IAsyncAction ReactNativeHost::ReloadInstance() noexcept { auto modulesProvider = std::make_shared(); -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) auto viewManagersProvider = std::make_shared(); #endif @@ -106,7 +106,7 @@ IAsyncAction ReactNativeHost::ReloadInstance() noexcept { m_packageBuilder = make( modulesProvider, -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) viewManagersProvider, #endif turboModulesProvider, @@ -168,7 +168,7 @@ IAsyncAction ReactNativeHost::ReloadInstance() noexcept { reactOptions.SetJsiEngine(static_cast(m_instanceSettings.JSIEngineOverride())); reactOptions.ModuleProvider = modulesProvider; -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) reactOptions.ViewManagerProvider = viewManagersProvider; #endif reactOptions.TurboModuleProvider = turboModulesProvider; diff --git a/vnext/Microsoft.ReactNative/ReactPackageBuilder.cpp b/vnext/Microsoft.ReactNative/ReactPackageBuilder.cpp index efe880e784f..68ae9158ab2 100644 --- a/vnext/Microsoft.ReactNative/ReactPackageBuilder.cpp +++ b/vnext/Microsoft.ReactNative/ReactPackageBuilder.cpp @@ -16,7 +16,7 @@ namespace winrt::Microsoft::ReactNative { ReactPackageBuilder::ReactPackageBuilder( std::shared_ptr const &modulesProvider, -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) std::shared_ptr const &viewManagersProvider, #endif std::shared_ptr const &turboModulesProvider, @@ -26,7 +26,7 @@ ReactPackageBuilder::ReactPackageBuilder( #endif bool isWebDebugging) noexcept : m_modulesProvider{modulesProvider}, -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) m_viewManagersProvider{viewManagersProvider}, #endif m_turboModulesProvider{turboModulesProvider}, @@ -42,7 +42,7 @@ void ReactPackageBuilder::AddModule(hstring const &moduleName, ReactModuleProvid m_modulesProvider->AddModuleProvider(moduleName, moduleProvider); } -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) void ReactPackageBuilder::AddViewManager( hstring const &viewManagerName, ReactViewManagerProvider const &viewManagerProvider) noexcept { diff --git a/vnext/Microsoft.ReactNative/ReactPackageBuilder.h b/vnext/Microsoft.ReactNative/ReactPackageBuilder.h index 73f0de1be5a..cb69db9d31d 100644 --- a/vnext/Microsoft.ReactNative/ReactPackageBuilder.h +++ b/vnext/Microsoft.ReactNative/ReactPackageBuilder.h @@ -4,7 +4,7 @@ #include "NativeModulesProvider.h" #include "TurboModulesProvider.h" -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) #include "ViewManagersProvider.h" #endif #include "winrt/Microsoft.ReactNative.h" @@ -26,7 +26,7 @@ struct ReactPackageBuilder : winrt::implements< > { ReactPackageBuilder( std::shared_ptr const &modulesProvider, -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) std::shared_ptr const &viewManagersProvider, #endif std::shared_ptr const &turboModulesProvider, @@ -39,7 +39,7 @@ struct ReactPackageBuilder : winrt::implements< public: // IReactPackageBuilder void AddModule(hstring const &moduleName, ReactModuleProvider const &moduleProvider) noexcept; -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) void AddViewManager(hstring const &viewManagerName, ReactViewManagerProvider const &viewManagerProvider) noexcept; #endif void AddTurboModule(hstring const &moduleName, ReactModuleProvider const &moduleProvider) noexcept; @@ -52,7 +52,7 @@ struct ReactPackageBuilder : winrt::implements< private: std::shared_ptr m_modulesProvider; -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) std::shared_ptr m_viewManagersProvider; #endif std::shared_ptr m_turboModulesProvider; diff --git a/vnext/Microsoft.ReactNative/Utils/Helpers.cpp b/vnext/Microsoft.ReactNative/Utils/Helpers.cpp index e1ca04037ad..f7a9e98e64d 100644 --- a/vnext/Microsoft.ReactNative/Utils/Helpers.cpp +++ b/vnext/Microsoft.ReactNative/Utils/Helpers.cpp @@ -14,8 +14,6 @@ #endif // USE_FABRIC namespace winrt { -using namespace xaml::Controls::Primitives; -using namespace xaml::Media; using namespace Windows::Foundation::Metadata; } // namespace winrt diff --git a/vnext/Microsoft.ReactNative/Views/DevMenu.cpp b/vnext/Microsoft.ReactNative/Views/DevMenu.cpp index 1b8f6a7a4c6..2d59627e885 100644 --- a/vnext/Microsoft.ReactNative/Views/DevMenu.cpp +++ b/vnext/Microsoft.ReactNative/Views/DevMenu.cpp @@ -10,7 +10,7 @@ #include "IReactDispatcher.h" #include "Modules/DevSettingsModule.h" -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) #include #include "DevMenuControl.h" #include "UI.Xaml.Controls.Primitives.h" @@ -37,7 +37,7 @@ struct IDevMenu { virtual void Show() noexcept = 0; }; -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) bool IsCtrlShiftD(winrt::Windows::System::VirtualKey key) noexcept { return ( key == winrt::Windows::System::VirtualKey::D && @@ -116,7 +116,7 @@ const wchar_t *HermesProfilerLabel(Mso::CntPtr const : L"Stop and copy trace path to clipboard"; } -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) struct InAppXamlDevMenu : public IDevMenu, public std::enable_shared_from_this { InAppXamlDevMenu(Mso::CntPtr const &reactContext) : m_context(reactContext) {} @@ -348,7 +348,7 @@ struct WindowsPopupMenuDevMenu : public IDevMenu, public std::enable_shared_from DevMenuManager::DevMenuManager(Mso::CntPtr const &reactContext) : m_context(reactContext) {} void DevMenuManager::Init() noexcept { -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) auto uiDispatcher = React::implementation::ReactDispatcher::GetUIDispatcher(m_context->Properties()); uiDispatcher.Post([weakThis = weak_from_this()]() { if (auto strongThis = weakThis.lock()) { @@ -396,7 +396,7 @@ std::shared_ptr GetOrCreateDevMenu(Mso::CntPtr std::shared_ptr { -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) if (xaml::TryGetCurrentUwpXamlApplication()) { auto devMenu = std::make_shared(reactContext); return devMenu; diff --git a/vnext/Microsoft.ReactNative/Views/DevMenu.h b/vnext/Microsoft.ReactNative/Views/DevMenu.h index d9c43706928..2e2a58c622c 100644 --- a/vnext/Microsoft.ReactNative/Views/DevMenu.h +++ b/vnext/Microsoft.ReactNative/Views/DevMenu.h @@ -21,7 +21,7 @@ struct DevMenuManager : public std::enable_shared_from_this { private: void Init() noexcept; const Mso::CntPtr m_context; -#ifndef CORE_ABI +#if !defined(CORE_ABI) && !defined(USE_FABRIC) winrt::CoreDispatcher::AcceleratorKeyActivated_revoker m_coreDispatcherAKARevoker{}; xaml::UIElement::KeyDown_revoker m_keyDownRevoker; #endif diff --git a/vnext/Microsoft.ReactNative/XamlUIService.cpp b/vnext/Microsoft.ReactNative/XamlUIService.cpp index c898e9e969a..16fbebeaedd 100644 --- a/vnext/Microsoft.ReactNative/XamlUIService.cpp +++ b/vnext/Microsoft.ReactNative/XamlUIService.cpp @@ -4,17 +4,28 @@ #include "pch.h" #include "XamlUIService.h" #include "XamlUIService.g.cpp" + +#ifndef USE_FABRIC #include #include -#include "DynamicWriter.h" #include "ShadowNodeBase.h" #include "Views/ShadowNodeBase.h" +#endif + +#include "DynamicWriter.h" #include "XamlView.h" namespace winrt::Microsoft::ReactNative::implementation { XamlUIService::XamlUIService(Mso::CntPtr &&context) noexcept : m_context(context) {} +/*static*/ winrt::Microsoft::ReactNative::XamlUIService XamlUIService::FromContext(IReactContext context) { + return context.Properties() + .Get(XamlUIService::XamlUIServiceProperty().Handle()) + .try_as(); +} + +#ifndef USE_FABRIC xaml::DependencyObject XamlUIService::ElementFromReactTag(int64_t reactTag) noexcept { if (auto uiManager = ::Microsoft::ReactNative::GetNativeUIManager(*m_context).lock()) { auto shadowNode = uiManager->getHost()->FindShadowNodeForTag(reactTag); @@ -26,12 +37,6 @@ xaml::DependencyObject XamlUIService::ElementFromReactTag(int64_t reactTag) noex return nullptr; } -/*static*/ winrt::Microsoft::ReactNative::XamlUIService XamlUIService::FromContext(IReactContext context) { - return context.Properties() - .Get(XamlUIService::XamlUIServiceProperty().Handle()) - .try_as(); -} - void XamlUIService::DispatchEvent( xaml::FrameworkElement const &view, hstring const &eventName, @@ -64,6 +69,7 @@ winrt::Microsoft::ReactNative::ReactRootView XamlUIService::GetReactRootView( } return nullptr; } +#endif /*static*/ ReactPropertyId XamlUIService::XamlUIServiceProperty() noexcept { static ReactPropertyId uiManagerProperty{L"ReactNative.UIManager", L"XamlUIManager"}; diff --git a/vnext/Microsoft.ReactNative/XamlUIService.h b/vnext/Microsoft.ReactNative/XamlUIService.h index 661caaf9549..ff35288a879 100644 --- a/vnext/Microsoft.ReactNative/XamlUIService.h +++ b/vnext/Microsoft.ReactNative/XamlUIService.h @@ -15,14 +15,17 @@ struct XamlUIService : XamlUIServiceT { XamlUIService(Mso::CntPtr &&context) noexcept; static ReactPropertyId XamlUIServiceProperty() noexcept; - xaml::DependencyObject ElementFromReactTag(int64_t reactTag) noexcept; static winrt::Microsoft::ReactNative::XamlUIService FromContext(IReactContext context); + +#ifndef USE_FABRIC + xaml::DependencyObject ElementFromReactTag(int64_t reactTag) noexcept; void DispatchEvent( xaml::FrameworkElement const &view, hstring const &eventName, JSValueArgWriter const &eventDataArgWriter) noexcept; winrt::Microsoft::ReactNative::ReactRootView GetReactRootView(xaml::FrameworkElement const &view) noexcept; +#endif static void SetXamlRoot(IReactPropertyBag const &properties, xaml::XamlRoot const &xamlRoot) noexcept; static void SetAccessibleRoot( diff --git a/vnext/Microsoft.ReactNative/XamlUIService.idl b/vnext/Microsoft.ReactNative/XamlUIService.idl index 2f94c7e08dc..abdc6aeb4ac 100644 --- a/vnext/Microsoft.ReactNative/XamlUIService.idl +++ b/vnext/Microsoft.ReactNative/XamlUIService.idl @@ -19,6 +19,7 @@ namespace Microsoft.ReactNative DOC_STRING("Use this method to get access to the @XamlUIService associated with the @IReactContext.") static XamlUIService FromContext(IReactContext context); +#ifndef USE_FABRIC DOC_STRING("Gets the backing XAML element from a react tag.") XAML_NAMESPACE.DependencyObject ElementFromReactTag(Int64 reactTag); @@ -27,6 +28,7 @@ namespace Microsoft.ReactNative DOC_STRING("Gets the @ReactRootView view for a given element.") ReactRootView GetReactRootView(XAML_NAMESPACE.FrameworkElement view); +#endif DOC_STRING( "Sets the @Windows.UI.Xaml.XamlRoot element for the app. " diff --git a/vnext/PropertySheets/React.Cpp.props b/vnext/PropertySheets/React.Cpp.props index ba4b1d9e470..bb589c90608 100644 --- a/vnext/PropertySheets/React.Cpp.props +++ b/vnext/PropertySheets/React.Cpp.props @@ -73,6 +73,9 @@ --> _DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR;%(PreprocessorDefinitions) + + USE_FABRIC;%(PreprocessorDefinitions) + diff --git a/vnext/Shared/Shared.vcxitems.filters b/vnext/Shared/Shared.vcxitems.filters index dae607c5aa5..9be57880a88 100644 --- a/vnext/Shared/Shared.vcxitems.filters +++ b/vnext/Shared/Shared.vcxitems.filters @@ -329,6 +329,7 @@ +