diff --git a/change/@office-iss-react-native-win32-18a6ea62-b290-4a92-8aba-0c715198568e.json b/change/@office-iss-react-native-win32-18a6ea62-b290-4a92-8aba-0c715198568e.json new file mode 100644 index 00000000000..06b9579d66f --- /dev/null +++ b/change/@office-iss-react-native-win32-18a6ea62-b290-4a92-8aba-0c715198568e.json @@ -0,0 +1,7 @@ +{ + "comment": "Fix react-native-platform-override version mismatch", + "type": "prerelease", + "packageName": "@office-iss/react-native-win32", + "email": "protikbiswas100@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@react-native-windows-automation-30167d73-ae79-4baf-b88a-bbb57d6e33da.json b/change/@react-native-windows-automation-30167d73-ae79-4baf-b88a-bbb57d6e33da.json new file mode 100644 index 00000000000..3e6590afe87 --- /dev/null +++ b/change/@react-native-windows-automation-30167d73-ae79-4baf-b88a-bbb57d6e33da.json @@ -0,0 +1,7 @@ +{ + "comment": "adding reactnativeisland changes", + "type": "prerelease", + "packageName": "@react-native-windows/automation", + "email": "protikbiswas100@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@react-native-windows-automation-channel-64572999-914d-4a58-9ddf-3edda88a141b.json b/change/@react-native-windows-automation-channel-64572999-914d-4a58-9ddf-3edda88a141b.json new file mode 100644 index 00000000000..cb98c98d461 --- /dev/null +++ b/change/@react-native-windows-automation-channel-64572999-914d-4a58-9ddf-3edda88a141b.json @@ -0,0 +1,7 @@ +{ + "comment": "Fix C++ formatting", + "type": "prerelease", + "packageName": "@react-native-windows/automation-channel", + "email": "protikbiswas100@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/@react-native-windows-automation-commands-442aab14-68de-478e-84c2-32b9d56468d5.json b/change/@react-native-windows-automation-commands-442aab14-68de-478e-84c2-32b9d56468d5.json new file mode 100644 index 00000000000..49e9ef80ac0 --- /dev/null +++ b/change/@react-native-windows-automation-commands-442aab14-68de-478e-84c2-32b9d56468d5.json @@ -0,0 +1,7 @@ +{ + "comment": "Merge branch 'main' into user/protikbiswas100/15353-cleanup", + "type": "prerelease", + "packageName": "@react-native-windows/automation-commands", + "email": "protikbiswas100@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/react-native-platform-override-db8f5e58-f1bd-4f99-b898-4d36e6a4e23f.json b/change/react-native-platform-override-db8f5e58-f1bd-4f99-b898-4d36e6a4e23f.json new file mode 100644 index 00000000000..cdbb58dcff2 --- /dev/null +++ b/change/react-native-platform-override-db8f5e58-f1bd-4f99-b898-4d36e6a4e23f.json @@ -0,0 +1,7 @@ +{ + "comment": "applying package updates ***NO_CI***", + "type": "prerelease", + "packageName": "react-native-platform-override", + "email": "protikbiswas100@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/react-native-windows-53ef702f-70d9-44e6-a142-08d062e5f76f.json b/change/react-native-windows-53ef702f-70d9-44e6-a142-08d062e5f76f.json new file mode 100644 index 00000000000..59811ac8d5f --- /dev/null +++ b/change/react-native-windows-53ef702f-70d9-44e6-a142-08d062e5f76f.json @@ -0,0 +1,7 @@ +{ + "comment": "Revert \"Fix format errors\"", + "type": "prerelease", + "packageName": "react-native-windows", + "email": "protikbiswas100@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/change/react-native-windows-init-7f1c5ba8-b789-413d-9d63-0fae1f9aadb1.json b/change/react-native-windows-init-7f1c5ba8-b789-413d-9d63-0fae1f9aadb1.json new file mode 100644 index 00000000000..e2f5eb2b825 --- /dev/null +++ b/change/react-native-windows-init-7f1c5ba8-b789-413d-9d63-0fae1f9aadb1.json @@ -0,0 +1,7 @@ +{ + "comment": "Merge branch 'main' into user/protikbiswas100/15353-cleanup", + "type": "prerelease", + "packageName": "react-native-windows-init", + "email": "protikbiswas100@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/package.json b/package.json index d2cf99e2118..695d30bbe0e 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "fast-glob": "^3.2.11", "husky": "^4.2.5", "prettier-plugin-hermes-parser": "0.21.1", - "react-native-platform-override": "0.0.0-canary.1015", + "react-native-platform-override": "0.0.0-canary.1016", "unbroken": "1.0.27", "lage": "^2.7.1", "lodash": "^4.17.15" diff --git a/packages/playground/windows/playground-composition/CustomComponent.cpp b/packages/playground/windows/playground-composition/CustomComponent.cpp deleted file mode 100644 index 4d0e778cb4a..00000000000 --- a/packages/playground/windows/playground-composition/CustomComponent.cpp +++ /dev/null @@ -1,248 +0,0 @@ -#include "pch.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "YogaXamlPanel.h" - -namespace winrt::PlaygroundApp::implementation { - -/* - * Custom Properties can be passed from JS to this native component - * This struct will eventually be codegen'd from the JS spec file - */ -REACT_STRUCT(CustomXamlComponentProps) -struct CustomXamlComponentProps - : winrt::implements { - CustomXamlComponentProps( - winrt::Microsoft::ReactNative::ViewProps props, - const winrt::Microsoft::ReactNative::IComponentProps &cloneFrom) - : m_props(props) { - if (cloneFrom) { - auto cloneFromProps = cloneFrom.as(); - label = cloneFromProps->label; - } - } - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); - } - - REACT_FIELD(label); - winrt::hstring label; - winrt::Microsoft::ReactNative::ViewProps m_props; -}; - -// Custom state used when using native layout to store the desired size of the Xaml control for use during RN -// layout on a background thread -struct CustomXamlComponentStateData : winrt::implements { - CustomXamlComponentStateData(winrt::Windows::Foundation::Size ds) : desiredSize(ds) {} - winrt::Windows::Foundation::Size desiredSize; -}; - -// Should be codegen'd -REACT_STRUCT(OnMyEvent) -struct OnMyEvent { - REACT_FIELD(value) - bool value; - - REACT_FIELD(target) - int32_t target; -}; - -// Should be codegen'd -struct CustomXamlComponentEventEmitter { - CustomXamlComponentEventEmitter(const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter) - : m_eventEmitter(eventEmitter) {} - - void onMyEvent(OnMyEvent &value) const { - m_eventEmitter.DispatchEvent(L"MyEvent", [value](const winrt::Microsoft::ReactNative::IJSValueWriter writer) { - winrt::Microsoft::ReactNative::WriteValue(writer, value); - }); - } - - private: - winrt::Microsoft::ReactNative::EventEmitter m_eventEmitter{nullptr}; -}; - -struct CustomComponentUserData : winrt::implements { - void Initialize( - const winrt::Microsoft::ReactNative::Composition::ContentIslandComponentView &islandView, - bool nativeLayout) { - nativeLayout; - islandView; - m_xamlIsland = winrt::Microsoft::UI::Xaml::XamlIsland{}; - m_xamlIsland.Content(CreateXamlButtonContent(nativeLayout)); - islandView.Connect(m_xamlIsland.ContentIsland()); - } - - void PropsChanged( - const winrt::Microsoft::ReactNative::Composition::ContentIslandComponentView & /*islandView*/, - const winrt::Microsoft::ReactNative::IComponentProps &newProps, - const winrt::Microsoft::ReactNative::IComponentProps & /*oldProps*/) { - auto myProps = newProps.as(); - m_buttonLabelTextBlock.Text(myProps->label); - } - - void FinalizeUpdates() noexcept { - if (m_eventEmitter) { - OnMyEvent args; - args.value = false; - m_eventEmitter->onMyEvent(args); - } - } - - winrt::Microsoft::UI::Xaml::UIElement CreateXamlButtonContent(bool nativeLayout) { - m_buttonLabelTextBlock = winrt::Microsoft::UI::Xaml::Controls::TextBlock(); - m_buttonLabelTextBlock.Text(L"This is a Xaml Button set to ellipisify on truncation"); - m_buttonLabelTextBlock.TextTrimming(winrt::Microsoft::UI::Xaml::TextTrimming::CharacterEllipsis); - - auto button = winrt::Microsoft::UI::Xaml::Controls::Button(); - button.Margin({3, 3, 3, 3}); - button.Content(m_buttonLabelTextBlock); - - // If we are using native layout then wrap the element in a YogaXamlPanel which reports any changes to desired size - // of the XAML element. - if (!nativeLayout) { - return button; - } - - auto yogaXamlPanel = winrt::make( - [&](winrt::Windows::Foundation::Size desiredSize) { - if (m_state) { - auto state = winrt::get_self(m_state.Data()); - if (desiredSize != state->desiredSize) { - m_state.UpdateStateWithMutation([desiredSize](winrt::Windows::Foundation::IInspectable /*data*/) { - return winrt::make(desiredSize); - }); - } - } - }); - - // yogaXamlPanel.Background(winrt::Microsoft::UI::Xaml::Media::SolidColorBrush({255, 124, 124, 155})); - yogaXamlPanel.VerticalAlignment(winrt::Microsoft::UI::Xaml::VerticalAlignment::Stretch); - yogaXamlPanel.HorizontalAlignment(winrt::Microsoft::UI::Xaml::HorizontalAlignment::Stretch); - - yogaXamlPanel.Children().Append(button); - - return yogaXamlPanel; - } - - static void ConfigureBuilderForCustomComponent( - winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder, - bool nativeLayout) { - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props, - const winrt::Microsoft::ReactNative::IComponentProps &cloneFrom) noexcept { - return winrt::make(props, cloneFrom); - }); - - builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &source, - winrt::Microsoft::ReactNative::ComponentViewUpdateMask /*mask*/) { - auto userData = source.UserData().as(); - userData->FinalizeUpdates(); - }); - - auto compBuilder = builder.as(); - - compBuilder.SetContentIslandComponentViewInitializer( - [nativeLayout]( - const winrt::Microsoft::ReactNative::Composition::ContentIslandComponentView &islandView) noexcept { - auto userData = winrt::make_self(); - userData->Initialize(islandView, nativeLayout); - islandView.UserData(*userData); - - islandView.Destroying([](const winrt::IInspectable &sender, const winrt::IInspectable & /*args*/) { - auto senderIslandView = sender.as(); - auto userData = senderIslandView.UserData().as(); - userData->m_xamlIsland.Close(); - }); - }); - - builder.SetUpdateEventEmitterHandler([](const winrt::Microsoft::ReactNative::ComponentView &source, - const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter) { - auto senderIslandView = source.as(); - auto userData = senderIslandView.UserData().as(); - userData->m_eventEmitter = std::make_unique(eventEmitter); - }); - - if (nativeLayout) { - builder.SetMeasureContentHandler([](winrt::Microsoft::ReactNative::ShadowNode shadowNode, - winrt::Microsoft::ReactNative::LayoutContext layoutContext, - winrt::Microsoft::ReactNative::LayoutConstraints layoutContraints) noexcept { - shadowNode.Tag(winrt::box_value(layoutContraints)); - - auto currentState = winrt::get_self(shadowNode.StateData()); - - if (currentState) { - // Snap up to the nearest whole pixel to avoid pixel snapping truncations - auto size = winrt::Windows::Foundation::Size{ - std::ceil(currentState->desiredSize.Width * layoutContext.PointScaleFactor()) / - layoutContext.PointScaleFactor() + - 1.0f, - std::ceil(currentState->desiredSize.Height * layoutContext.PointScaleFactor()) / - layoutContext.PointScaleFactor() + - 1.0f, - }; - return size; - } - - return winrt::Windows::Foundation::Size{0, 0}; - }); - builder.SetInitialStateDataFactory([](const winrt::Microsoft::ReactNative::IComponentProps & /*props*/) noexcept { - return winrt::make(winrt::Windows::Foundation::Size{0, 0}); - }); - } - - builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &source, - const winrt::Microsoft::ReactNative::IComponentProps &newProps, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps) { - auto senderIslandView = source.as(); - auto userData = senderIslandView.UserData().as(); - userData->PropsChanged(senderIslandView, newProps, oldProps); - }); - - builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &source, - const winrt::Microsoft::ReactNative::IComponentState &newState) { - auto senderIslandView = source.as(); - auto userData = senderIslandView.UserData().as(); - userData->m_state = newState; - }); - } - - private: - winrt::Microsoft::UI::Xaml::Controls::TextBlock m_buttonLabelTextBlock{nullptr}; - winrt::Microsoft::ReactNative::IComponentState m_state; - std::unique_ptr m_eventEmitter{nullptr}; - winrt::Microsoft::UI::Xaml::XamlIsland m_xamlIsland{nullptr}; -}; - -static void RegisterViewComponent(winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder) { - packageBuilder.as().AddViewComponent( - L"CustomXamlComponentWithNativeLayout", - [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - CustomComponentUserData::ConfigureBuilderForCustomComponent(builder, true /*nativeLayout*/); - }); - - packageBuilder.as().AddViewComponent( - L"CustomXamlComponentWithYogaLayout", - [](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - CustomComponentUserData::ConfigureBuilderForCustomComponent(builder, false /*nativeLayout*/); - }); -} -} // namespace winrt::PlaygroundApp::implementation - -void RegisterCustomComponent(winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder) noexcept { - winrt::PlaygroundApp::implementation::RegisterViewComponent(packageBuilder); -} diff --git a/packages/playground/windows/playground-composition/Playground-Composition.cpp b/packages/playground/windows/playground-composition/Playground-Composition.cpp index 562e3a4eb00..37ba850ccbc 100644 --- a/packages/playground/windows/playground-composition/Playground-Composition.cpp +++ b/packages/playground/windows/playground-composition/Playground-Composition.cpp @@ -23,14 +23,9 @@ #include #include -// Includes from sample-custom-component -#include - winrt::Microsoft::UI::Dispatching::DispatcherQueueController g_liftedDispatcherQueueController{nullptr}; winrt::Microsoft::UI::Composition::Compositor g_liftedCompositor{nullptr}; -void RegisterCustomComponent(winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder) noexcept; - /** * This ImageHandler will accept images with a uri using the ellipse protocol and render an ellipse image * @@ -79,25 +74,6 @@ struct EllipseImageHandler } }; -struct EllipseReactPackageProvider - : winrt::implements { - public: // IReactPackageProvider - void CreatePackage(winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder) noexcept { - // Register ellipse: uri handler for images - packageBuilder.as().AddUriImageProvider( - winrt::make()); - } -}; - -// Have to use TurboModules to override built in modules.. so the standard attributed package provider doesn't work. -struct CompReactPackageProvider - : winrt::implements { - public: // IReactPackageProvider - void CreatePackage(winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder) noexcept { - RegisterCustomComponent(packageBuilder); - } -}; - constexpr auto WindowDataProperty = L"WindowData"; int RunPlayground(int showCmd); @@ -172,10 +148,6 @@ struct WindowData { winrt::Microsoft::ReactNative::HttpSettings::SetDefaultUserAgent( host.InstanceSettings(), L"React Native Windows Playground"); - host.PackageProviders().Append(winrt::make()); - - host.PackageProviders().Append(winrt::SampleCustomComponent::ReactPackageProvider()); - winrt::Microsoft::ReactNative::ReactCoreInjection::SetTopLevelWindowId( host.InstanceSettings().Properties(), reinterpret_cast(hwnd)); @@ -189,9 +161,6 @@ struct WindowData { winrt::Microsoft::ReactNative::Composition::CompositionUIService::SetCompositor( InstanceSettings(), g_liftedCompositor); - // Register ellipse:// uri hander for images - host.PackageProviders().Append(winrt::make()); - m_bridge = winrt::Microsoft::UI::Content::DesktopChildSiteBridge::Create( g_liftedCompositor, winrt::Microsoft::UI::GetWindowIdFromWindow(hwnd)); diff --git a/packages/playground/windows/playground-composition/Playground-Composition.vcxproj b/packages/playground/windows/playground-composition/Playground-Composition.vcxproj index 975ad13f903..da94bfbd2ad 100644 --- a/packages/playground/windows/playground-composition/Playground-Composition.vcxproj +++ b/packages/playground/windows/playground-composition/Playground-Composition.vcxproj @@ -129,7 +129,6 @@ App.xaml Code - diff --git a/packages/sample-custom-component/src/FabricXamlCalendarViewNativeComponent.ts b/packages/sample-custom-component/src/FabricXamlCalendarViewNativeComponent.ts deleted file mode 100644 index 2344e4975ee..00000000000 --- a/packages/sample-custom-component/src/FabricXamlCalendarViewNativeComponent.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * @format - * @flow - */ - -'use strict'; - -// Temporary test example for UseExperimentalWinUI3=true -// Remove when we get react-native-xaml working well for Fabric - -import {codegenNativeComponent} from 'react-native'; -import type {ViewProps} from 'react-native'; -import type {DirectEventHandler} from 'react-native/Libraries/Types/CodegenTypes'; - -type SelectedDatesChangedEvent = Readonly<{ - value: boolean; - startDate: string; -}>; - -export interface CalendarViewProps extends ViewProps { - label: string; - onSelectedDatesChanged?: DirectEventHandler; -} - -export default codegenNativeComponent('CalendarView'); diff --git a/packages/sample-custom-component/src/index.ts b/packages/sample-custom-component/src/index.ts index 182564080ea..b5b3be97b92 100644 --- a/packages/sample-custom-component/src/index.ts +++ b/packages/sample-custom-component/src/index.ts @@ -1,13 +1,10 @@ import MovingLight from './MovingLight'; -import type {MovingLightHandle} from './MovingLight'; +import type { MovingLightHandle } from './MovingLight'; import DrawingIsland from './DrawingIsland'; -import CalendarView from './FabricXamlCalendarViewNativeComponent' - export { DrawingIsland, MovingLight, MovingLightHandle, - CalendarView, }; \ No newline at end of file diff --git a/packages/sample-custom-component/windows/SampleCustomComponent/CalendarView.cpp b/packages/sample-custom-component/windows/SampleCustomComponent/CalendarView.cpp deleted file mode 100644 index 4557d956634..00000000000 --- a/packages/sample-custom-component/windows/SampleCustomComponent/CalendarView.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. -#include "pch.h" - -#include "CalendarView.h" - -#if defined(RNW_NEW_ARCH) - -#include "codegen/react/components/SampleCustomComponent/CalendarView.g.h" - -#include - -namespace winrt::SampleCustomComponent { - -// This is a "toy" implementation of Xaml's CalendarView, just for bringup and testing. -// When UseExperimentalWinUI3 and UseNewArchitecture are both true, it will host a -// CalendarView control in a XamlIsland. But we only expose a few APIs right now. -// Later, we'll expose this through react-native-xaml. - -struct CalendarViewComponentView : public winrt::implements, - Codegen::BaseCalendarView { - void InitializeContentIsland( - const winrt::Microsoft::ReactNative::Composition::ContentIslandComponentView &islandView) noexcept { - m_xamlIsland = winrt::Microsoft::UI::Xaml::XamlIsland{}; - m_calendarView = winrt::Microsoft::UI::Xaml::Controls::CalendarView{}; - m_xamlIsland.Content(m_calendarView); - islandView.Connect(m_xamlIsland.ContentIsland()); - - m_calendarView.SelectedDatesChanged([this](auto &&, auto &&) { - if (auto emitter = EventEmitter()) { - Codegen::CalendarView_OnSelectedDatesChanged args; - auto selectedDates = m_calendarView.SelectedDates(); - if (selectedDates.Size() == 0) { - args.startDate = "(none)"; - } else { - auto firstSelectedDate = selectedDates.GetAt(0); - - auto tt = winrt::clock::to_time_t(firstSelectedDate); - tm local{}; - localtime_s(&local, &tt); - auto timeStr = std::put_time(&local, "%F"); - - std::stringstream ss; - ss << (timeStr._Tptr->tm_year + 1900) << "-" << (timeStr._Tptr->tm_mon + 1) << "-" << timeStr._Tptr->tm_mday; - - args.startDate = ss.str(); - } - emitter->onSelectedDatesChanged(args); - } - }); - } - - private: - winrt::Microsoft::UI::Xaml::XamlIsland m_xamlIsland{nullptr}; - winrt::Microsoft::UI::Xaml::Controls::CalendarView m_calendarView{nullptr}; -}; - -} // namespace winrt::SampleCustomComponent - -void RegisterCalendarViewComponentView(winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder) { - winrt::SampleCustomComponent::Codegen::RegisterCalendarViewNativeComponent< - winrt::SampleCustomComponent::CalendarViewComponentView>( - packageBuilder, - [](const winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder &builder) { - builder.SetContentIslandComponentViewInitializer( - [](const winrt::Microsoft::ReactNative::Composition::ContentIslandComponentView &islandView) noexcept { - auto userData = winrt::make_self(); - userData->InitializeContentIsland(islandView); - islandView.UserData(*userData); - }); - }); -} - -#endif // defined(RNW_NEW_ARCH) diff --git a/packages/sample-custom-component/windows/SampleCustomComponent/CalendarView.h b/packages/sample-custom-component/windows/SampleCustomComponent/CalendarView.h deleted file mode 100644 index da5efefed10..00000000000 --- a/packages/sample-custom-component/windows/SampleCustomComponent/CalendarView.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -#if defined(RNW_NEW_ARCH) - -void RegisterCalendarViewComponentView(winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder); - -#endif // defined(RNW_NEW_ARCH) diff --git a/packages/sample-custom-component/windows/SampleCustomComponent/ReactPackageProvider.cpp b/packages/sample-custom-component/windows/SampleCustomComponent/ReactPackageProvider.cpp index ba3a413f5a6..16d46adb132 100644 --- a/packages/sample-custom-component/windows/SampleCustomComponent/ReactPackageProvider.cpp +++ b/packages/sample-custom-component/windows/SampleCustomComponent/ReactPackageProvider.cpp @@ -7,7 +7,6 @@ #include "ReactPackageProvider.g.cpp" #endif -#include "CalendarView.h" #include "DrawingIsland.h" #include "MovingLight.h" @@ -21,7 +20,6 @@ void ReactPackageProvider::CreatePackage(IReactPackageBuilder const &packageBuil #ifdef RNW_NEW_ARCH RegisterDrawingIslandComponentView(packageBuilder); RegisterMovingLightNativeComponent(packageBuilder); - RegisterCalendarViewComponentView(packageBuilder); #endif // #ifdef RNW_NEW_ARCH } diff --git a/packages/sample-custom-component/windows/SampleCustomComponent/SampleCustomComponent.vcxproj b/packages/sample-custom-component/windows/SampleCustomComponent/SampleCustomComponent.vcxproj index 7f679b2b4a6..5863e90a037 100644 --- a/packages/sample-custom-component/windows/SampleCustomComponent/SampleCustomComponent.vcxproj +++ b/packages/sample-custom-component/windows/SampleCustomComponent/SampleCustomComponent.vcxproj @@ -100,7 +100,6 @@ - DrawingIsland.idl @@ -123,7 +122,6 @@ ReactPackageProvider.idl - diff --git a/packages/sample-custom-component/windows/SampleCustomComponent/codegen/react/components/SampleCustomComponent/CalendarView.g.h b/packages/sample-custom-component/windows/SampleCustomComponent/codegen/react/components/SampleCustomComponent/CalendarView.g.h deleted file mode 100644 index 7df163dc929..00000000000 --- a/packages/sample-custom-component/windows/SampleCustomComponent/codegen/react/components/SampleCustomComponent/CalendarView.g.h +++ /dev/null @@ -1,217 +0,0 @@ - -/* - * This file is auto-generated from CalendarViewNativeComponent spec file in flow / TypeScript. - */ -// clang-format off -#pragma once - -#include - -#ifdef RNW_NEW_ARCH -#include - -#include -#include -#endif // #ifdef RNW_NEW_ARCH - -#ifdef RNW_NEW_ARCH - -namespace winrt::SampleCustomComponent::Codegen { - -REACT_STRUCT(CalendarViewProps) -struct CalendarViewProps : winrt::implements { - CalendarViewProps(winrt::Microsoft::ReactNative::ViewProps props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) - : ViewProps(props) - { - if (cloneFrom) { - auto cloneFromProps = cloneFrom.as(); - label = cloneFromProps->label; - } - } - - void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept { - winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this); - } - - REACT_FIELD(label) - std::string label; - - const winrt::Microsoft::ReactNative::ViewProps ViewProps; -}; - -REACT_STRUCT(CalendarView_OnSelectedDatesChanged) -struct CalendarView_OnSelectedDatesChanged { - REACT_FIELD(value) - bool value{}; - - REACT_FIELD(startDate) - std::string startDate; -}; - -struct CalendarViewEventEmitter { - CalendarViewEventEmitter(const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter) - : m_eventEmitter(eventEmitter) {} - - using OnSelectedDatesChanged = CalendarView_OnSelectedDatesChanged; - - void onSelectedDatesChanged(OnSelectedDatesChanged &value) const { - m_eventEmitter.DispatchEvent(L"selectedDatesChanged", [value](const winrt::Microsoft::ReactNative::IJSValueWriter writer) { - winrt::Microsoft::ReactNative::WriteValue(writer, value); - }); - } - - private: - winrt::Microsoft::ReactNative::EventEmitter m_eventEmitter{nullptr}; -}; - -template -struct BaseCalendarView { - - virtual void UpdateProps( - const winrt::Microsoft::ReactNative::ComponentView &/*view*/, - const winrt::com_ptr &newProps, - const winrt::com_ptr &/*oldProps*/) noexcept { - m_props = newProps; - } - - // UpdateLayoutMetrics will only be called if this method is overridden - virtual void UpdateLayoutMetrics( - const winrt::Microsoft::ReactNative::ComponentView &/*view*/, - const winrt::Microsoft::ReactNative::LayoutMetrics &/*newLayoutMetrics*/, - const winrt::Microsoft::ReactNative::LayoutMetrics &/*oldLayoutMetrics*/) noexcept { - } - - // UpdateState will only be called if this method is overridden - virtual void UpdateState( - const winrt::Microsoft::ReactNative::ComponentView &/*view*/, - const winrt::Microsoft::ReactNative::IComponentState &/*newState*/) noexcept { - } - - virtual void UpdateEventEmitter(const std::shared_ptr &eventEmitter) noexcept { - m_eventEmitter = eventEmitter; - } - - // MountChildComponentView will only be called if this method is overridden - virtual void MountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/, - const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &/*args*/) noexcept { - } - - // UnmountChildComponentView will only be called if this method is overridden - virtual void UnmountChildComponentView(const winrt::Microsoft::ReactNative::ComponentView &/*view*/, - const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &/*args*/) noexcept { - } - - // Initialize will only be called if this method is overridden - virtual void Initialize(const winrt::Microsoft::ReactNative::ComponentView &/*view*/) noexcept { - } - - // CreateVisual will only be called if this method is overridden - virtual winrt::Microsoft::UI::Composition::Visual CreateVisual(const winrt::Microsoft::ReactNative::ComponentView &view) noexcept { - return view.as().Compositor().CreateSpriteVisual(); - } - - // FinalizeUpdate will only be called if this method is overridden - virtual void FinalizeUpdate(const winrt::Microsoft::ReactNative::ComponentView &/*view*/, - winrt::Microsoft::ReactNative::ComponentViewUpdateMask /*mask*/) noexcept { - } - - - - const std::shared_ptr& EventEmitter() const { return m_eventEmitter; } - const winrt::com_ptr& Props() const { return m_props; } - -private: - winrt::com_ptr m_props; - std::shared_ptr m_eventEmitter; -}; - -template -void RegisterCalendarViewNativeComponent( - winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder, - std::function builderCallback) noexcept { - packageBuilder.as().AddViewComponent( - L"CalendarView", [builderCallback](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept { - auto compBuilder = builder.as(); - - builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props, - const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) noexcept { - return winrt::make(props, cloneFrom); - }); - - builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::IComponentProps &newProps, - const winrt::Microsoft::ReactNative::IComponentProps &oldProps) noexcept { - auto userData = view.UserData().as(); - userData->UpdateProps(view, newProps ? newProps.as() : nullptr, oldProps ? oldProps.as() : nullptr); - }); - - compBuilder.SetUpdateLayoutMetricsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::LayoutMetrics &newLayoutMetrics, - const winrt::Microsoft::ReactNative::LayoutMetrics &oldLayoutMetrics) noexcept { - auto userData = view.UserData().as(); - userData->UpdateLayoutMetrics(view, newLayoutMetrics, oldLayoutMetrics); - }); - - builder.SetUpdateEventEmitterHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::EventEmitter &eventEmitter) noexcept { - auto userData = view.UserData().as(); - userData->UpdateEventEmitter(std::make_shared(eventEmitter)); - }); - - if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::FinalizeUpdate != &BaseCalendarView::FinalizeUpdate) { - builder.SetFinalizeUpdateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, - winrt::Microsoft::ReactNative::ComponentViewUpdateMask mask) noexcept { - auto userData = view.UserData().as(); - userData->FinalizeUpdate(view, mask); - }); - } - - if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::UpdateState != &BaseCalendarView::UpdateState) { - builder.SetUpdateStateHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::IComponentState &newState) noexcept { - auto userData = view.UserData().as(); - userData->UpdateState(view, newState); - }); - } - - if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::MountChildComponentView != &BaseCalendarView::MountChildComponentView) { - builder.SetMountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::MountChildComponentViewArgs &args) noexcept { - auto userData = view.UserData().as(); - return userData->MountChildComponentView(view, args); - }); - } - - if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::UnmountChildComponentView != &BaseCalendarView::UnmountChildComponentView) { - builder.SetUnmountChildComponentViewHandler([](const winrt::Microsoft::ReactNative::ComponentView &view, - const winrt::Microsoft::ReactNative::UnmountChildComponentViewArgs &args) noexcept { - auto userData = view.UserData().as(); - return userData->UnmountChildComponentView(view, args); - }); - } - - compBuilder.SetViewComponentViewInitializer([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept { - auto userData = winrt::make_self(); - if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::Initialize != &BaseCalendarView::Initialize) { - userData->Initialize(view); - } - view.UserData(*userData); - }); - - if CONSTEXPR_SUPPORTED_ON_VIRTUAL_FN_ADDRESS (&TUserData::CreateVisual != &BaseCalendarView::CreateVisual) { - compBuilder.SetCreateVisualHandler([](const winrt::Microsoft::ReactNative::ComponentView &view) noexcept { - auto userData = view.UserData().as(); - return userData->CreateVisual(view); - }); - } - - // Allow app to further customize the builder - if (builderCallback) { - builderCallback(compBuilder); - } - }); -} - -} // namespace winrt::SampleCustomComponent::Codegen - -#endif // #ifdef RNW_NEW_ARCH diff --git a/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp b/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp index 54b9ff491b1..1a721041833 100644 --- a/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp +++ b/vnext/Microsoft.ReactNative/Fabric/Composition/ReactNativeIsland.cpp @@ -174,8 +174,8 @@ ReactNativeIsland::~ReactNativeIsland() noexcept { m_island.AutomationProviderRequested(m_islandAutomationProviderRequestedToken); m_island.StateChanged(m_islandStateChangedToken); #ifdef USE_EXPERIMENTAL_WINUI3 - m_island.Connected(m_islandConnectedToken); - m_island.Disconnected(m_islandDisconnectedToken); + // m_island.Connected(m_islandConnectedToken); + /// m_island.Disconnected(m_islandDisconnectedToken); #endif } @@ -977,21 +977,21 @@ winrt::Microsoft::UI::Content::ContentIsland ReactNativeIsland::Island() { }); #ifdef USE_EXPERIMENTAL_WINUI3 if (!m_isFragment) { - m_islandConnectedToken = m_island.Connected( + /*m_islandConnectedToken = m_island.Connected( [weakThis = get_weak()]( winrt::IInspectable const &, winrt::Microsoft::UI::Content::ContentIsland const &island) { if (auto pThis = weakThis.get()) { pThis->OnMounted(); } - }); + });*/ - m_islandDisconnectedToken = m_island.Disconnected( + /*m_islandDisconnectedToken = m_island.Disconnected( [weakThis = get_weak()]( winrt::IInspectable const &, winrt::Microsoft::UI::Content::ContentIsland const &island) { if (auto pThis = weakThis.get()) { pThis->OnUnmounted(); } - }); + });*/ } #endif }