From 6c0ac3da46d16ff63fbe3282937174fd886c74ff Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Jun 2025 09:09:43 +0000 Subject: [PATCH 1/5] Initial plan for issue From c5aec1137aaa5d8afc5e863b32c30bef86fbaaf0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Jun 2025 09:30:11 +0000 Subject: [PATCH 2/5] Add comprehensive Flyout Component E2E tests Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com> --- .../test/FlyoutComponentTest.test.ts | 175 ++++++++++++++++++ 1 file changed, 175 insertions(+) create mode 100644 packages/e2e-test-app-fabric/test/FlyoutComponentTest.test.ts diff --git a/packages/e2e-test-app-fabric/test/FlyoutComponentTest.test.ts b/packages/e2e-test-app-fabric/test/FlyoutComponentTest.test.ts new file mode 100644 index 00000000000..138a26c5a83 --- /dev/null +++ b/packages/e2e-test-app-fabric/test/FlyoutComponentTest.test.ts @@ -0,0 +1,175 @@ +/** + * Copyright (c) Microsoft Corporation. + * Licensed under the MIT License. + * + * @format + */ + +import {dumpVisualTree} from '@react-native-windows/automation-commands'; +import {goToComponentExample} from './RNTesterNavigation'; +import {app} from '@react-native-windows/automation'; +import {verifyNoErrorLogs} from './Helpers'; + +beforeAll(async () => { + // If window is partially offscreen, tests will fail to click on certain elements + await app.setWindowPosition(0, 0); + await app.setWindowSize(1000, 1250); + await goToComponentExample('Flyout'); +}); + +afterEach(async () => { + await verifyNoErrorLogs(); +}); + +describe('Flyout Tests', () => { + test('A Flyout container is displayed with default state', async () => { + const component = await app.findElementByTestID('flyout'); + await component.waitForDisplayed({timeout: 5000}); + const dump = await dumpVisualTree('flyout'); + expect(dump).toMatchSnapshot(); + }); + + test('A Flyout can be opened with a target', async () => { + // Click the "Open Flyout" button to show the flyout + const openButton = await app.findElementByXPath( + '//Button[@Name="Open Flyout"]', + ); + await openButton.waitForDisplayed({timeout: 5000}); + await openButton.click(); + + // Wait for flyout to appear and capture its state + const flyout = await app.findElementByTestID('flyout-accessibility'); + await flyout.waitForDisplayed({timeout: 5000}); + const dump = await dumpVisualTree('flyout-accessibility'); + expect(dump).toMatchSnapshot(); + + // Close the flyout + const closeButton = await app.findElementByXPath('//Button[@Name="Close"]'); + await closeButton.click(); + }); + + test('A Flyout can be opened without a target', async () => { + // Click the "Open Flyout without Target" button + const openButton = await app.findElementByXPath( + '//Button[@Name="Open Flyout without Target"]', + ); + await openButton.waitForDisplayed({timeout: 5000}); + await openButton.click(); + + // Wait for flyout to appear and capture its state + const flyout = await app.findElementByTestID('flyout-accessibility-3'); + await flyout.waitForDisplayed({timeout: 5000}); + const dump = await dumpVisualTree('flyout-accessibility-3'); + expect(dump).toMatchSnapshot(); + + // Close the flyout by clicking outside (light dismiss) + const mainContainer = await app.findElementByTestID('flyout'); + await mainContainer.click(); + }); + + test('A Flyout can be opened with offset', async () => { + // Click the "Open Flyout with Offset" button + const openButton = await app.findElementByXPath( + '//Button[@Name="Open Flyout with Offset"]', + ); + await openButton.waitForDisplayed({timeout: 5000}); + await openButton.click(); + + // Wait for flyout to appear and capture its state + const flyout = await app.findElementByTestID('flyout-accessibility-4'); + await flyout.waitForDisplayed({timeout: 5000}); + const dump = await dumpVisualTree('flyout-accessibility-4'); + expect(dump).toMatchSnapshot(); + + // Close the flyout by clicking outside (light dismiss) + const mainContainer = await app.findElementByTestID('flyout'); + await mainContainer.click(); + }); + + test('A Flyout can have different placement options', async () => { + // Test different placement options by changing the picker value + const placementPicker = await app.findElementByTestID('placement-picker'); + if (await placementPicker.isDisplayed()) { + // Change to bottom placement + await placementPicker.selectByVisibleText('bottom'); + + // Open flyout to test bottom placement + const openButton = await app.findElementByXPath( + '//Button[@Name="Open Flyout"]', + ); + await openButton.click(); + + const flyout = await app.findElementByTestID('flyout-accessibility'); + await flyout.waitForDisplayed({timeout: 5000}); + const dump = await dumpVisualTree('flyout-accessibility'); + expect(dump).toMatchSnapshot(); + + // Close the flyout + const closeButton = await app.findElementByXPath( + '//Button[@Name="Close"]', + ); + await closeButton.click(); + } + }); + + test('A Flyout can be nested with another Flyout', async () => { + // Open the main flyout first + const openButton = await app.findElementByXPath( + '//Button[@Name="Open Flyout"]', + ); + await openButton.waitForDisplayed({timeout: 5000}); + await openButton.click(); + + // Wait for main flyout to appear + const flyout = await app.findElementByTestID('flyout-accessibility'); + await flyout.waitForDisplayed({timeout: 5000}); + + // Open another flyout from within the first one + const openAnotherButton = await app.findElementByXPath( + '//Button[@Name="Open Another Flyout"]', + ); + await openAnotherButton.waitForDisplayed({timeout: 5000}); + await openAnotherButton.click(); + + // Wait for second flyout to appear and capture state + const secondFlyout = await app.findElementByTestID( + 'flyout-accessibility-2', + ); + await secondFlyout.waitForDisplayed({timeout: 5000}); + const dump = await dumpVisualTree('flyout-accessibility-2'); + expect(dump).toMatchSnapshot(); + + // Close both flyouts by clicking outside + const mainContainer = await app.findElementByTestID('flyout'); + await mainContainer.click(); + }); + + test('A Flyout can contain a Popup', async () => { + // Open the main flyout first + const openButton = await app.findElementByXPath( + '//Button[@Name="Open Flyout"]', + ); + await openButton.waitForDisplayed({timeout: 5000}); + await openButton.click(); + + // Wait for main flyout to appear + const flyout = await app.findElementByTestID('flyout-accessibility'); + await flyout.waitForDisplayed({timeout: 5000}); + + // Open a popup from within the flyout + const openPopupButton = await app.findElementByXPath( + '//Button[@Name="Open A Popup"]', + ); + await openPopupButton.waitForDisplayed({timeout: 5000}); + await openPopupButton.click(); + + // Wait for popup to appear and capture state + // Note: Popup testID might need to be determined from the actual implementation + const dump = await dumpVisualTree('flyout-accessibility'); + expect(dump).toMatchSnapshot(); + + // Close the popup and flyout + const mainContainer = await app.findElementByTestID('flyout'); + await mainContainer.click(); + }); +}); From aa71067f87d5a36632fa154ce43daffb2cb068bd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Jun 2025 09:32:01 +0000 Subject: [PATCH 3/5] Add documentation and comments to Flyout tests Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com> --- .../e2e-test-app-fabric/test/FlyoutComponentTest.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/e2e-test-app-fabric/test/FlyoutComponentTest.test.ts b/packages/e2e-test-app-fabric/test/FlyoutComponentTest.test.ts index 138a26c5a83..08ada42e695 100644 --- a/packages/e2e-test-app-fabric/test/FlyoutComponentTest.test.ts +++ b/packages/e2e-test-app-fabric/test/FlyoutComponentTest.test.ts @@ -21,6 +21,9 @@ afterEach(async () => { await verifyNoErrorLogs(); }); +// Note: Flyout is currently excluded from visitAllPages.test.ts which may indicate +// compatibility issues with the Fabric app. These tests may need adjustments +// based on actual Flyout availability and functionality in the e2e-test-app-fabric. describe('Flyout Tests', () => { test('A Flyout container is displayed with default state', async () => { const component = await app.findElementByTestID('flyout'); @@ -31,6 +34,7 @@ describe('Flyout Tests', () => { test('A Flyout can be opened with a target', async () => { // Click the "Open Flyout" button to show the flyout + // Note: Using XPath to find button by Name since it lacks explicit testID const openButton = await app.findElementByXPath( '//Button[@Name="Open Flyout"]', ); @@ -38,6 +42,7 @@ describe('Flyout Tests', () => { await openButton.click(); // Wait for flyout to appear and capture its state + // Note: testID 'flyout-accessibility' should be set in FlyoutExample const flyout = await app.findElementByTestID('flyout-accessibility'); await flyout.waitForDisplayed({timeout: 5000}); const dump = await dumpVisualTree('flyout-accessibility'); From d77cdb476468bb9c12bcbeb24c64995911f1dc2b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Jun 2025 09:45:21 +0000 Subject: [PATCH 4/5] Run yarn change - no change files needed for private package Co-authored-by: anupriya13 <54227869+anupriya13@users.noreply.github.com> --- vnext/codegen/rnwcoreJSI-generated.cpp | 112 +-- vnext/codegen/rnwcoreJSI.h | 1034 ++++++++++++------------ 2 files changed, 573 insertions(+), 573 deletions(-) diff --git a/vnext/codegen/rnwcoreJSI-generated.cpp b/vnext/codegen/rnwcoreJSI-generated.cpp index 75de3b43ef4..9c12f2f7882 100644 --- a/vnext/codegen/rnwcoreJSI-generated.cpp +++ b/vnext/codegen/rnwcoreJSI-generated.cpp @@ -952,41 +952,6 @@ NativeAnimatedTurboModuleCxxSpecJSI::NativeAnimatedTurboModuleCxxSpecJSI(std::sh methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeAnimatedTurboModuleCxxSpecJSI_removeListeners}; methodMap_["queueAndExecuteBatchedOperations"] = MethodMetadata {1, __hostFunction_NativeAnimatedTurboModuleCxxSpecJSI_queueAndExecuteBatchedOperations}; } -static jsi::Value __hostFunction_NativeAppearanceCxxSpecJSI_getColorScheme(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - auto result = static_cast(&turboModule)->getColorScheme( - rt - ); - return result ? jsi::Value(std::move(*result)) : jsi::Value::null(); -} -static jsi::Value __hostFunction_NativeAppearanceCxxSpecJSI_setColorScheme(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - static_cast(&turboModule)->setColorScheme( - rt, - count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt) - ); - return jsi::Value::undefined(); -} -static jsi::Value __hostFunction_NativeAppearanceCxxSpecJSI_addListener(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - static_cast(&turboModule)->addListener( - rt, - count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt) - ); - return jsi::Value::undefined(); -} -static jsi::Value __hostFunction_NativeAppearanceCxxSpecJSI_removeListeners(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - static_cast(&turboModule)->removeListeners( - rt, - count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber() - ); - return jsi::Value::undefined(); -} - -NativeAppearanceCxxSpecJSI::NativeAppearanceCxxSpecJSI(std::shared_ptr jsInvoker) - : TurboModule("Appearance", jsInvoker) { - methodMap_["getColorScheme"] = MethodMetadata {0, __hostFunction_NativeAppearanceCxxSpecJSI_getColorScheme}; - methodMap_["setColorScheme"] = MethodMetadata {1, __hostFunction_NativeAppearanceCxxSpecJSI_setColorScheme}; - methodMap_["addListener"] = MethodMetadata {1, __hostFunction_NativeAppearanceCxxSpecJSI_addListener}; - methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeAppearanceCxxSpecJSI_removeListeners}; -} static jsi::Value __hostFunction_NativeAppStateCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->getConstants( rt @@ -1032,6 +997,41 @@ NativeAppThemeCxxSpecJSI::NativeAppThemeCxxSpecJSI(std::shared_ptr : TurboModule("AppTheme", jsInvoker) { methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeAppThemeCxxSpecJSI_getConstants}; } +static jsi::Value __hostFunction_NativeAppearanceCxxSpecJSI_getColorScheme(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + auto result = static_cast(&turboModule)->getColorScheme( + rt + ); + return result ? jsi::Value(std::move(*result)) : jsi::Value::null(); +} +static jsi::Value __hostFunction_NativeAppearanceCxxSpecJSI_setColorScheme(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + static_cast(&turboModule)->setColorScheme( + rt, + count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt) + ); + return jsi::Value::undefined(); +} +static jsi::Value __hostFunction_NativeAppearanceCxxSpecJSI_addListener(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + static_cast(&turboModule)->addListener( + rt, + count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt) + ); + return jsi::Value::undefined(); +} +static jsi::Value __hostFunction_NativeAppearanceCxxSpecJSI_removeListeners(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + static_cast(&turboModule)->removeListeners( + rt, + count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asNumber() + ); + return jsi::Value::undefined(); +} + +NativeAppearanceCxxSpecJSI::NativeAppearanceCxxSpecJSI(std::shared_ptr jsInvoker) + : TurboModule("Appearance", jsInvoker) { + methodMap_["getColorScheme"] = MethodMetadata {0, __hostFunction_NativeAppearanceCxxSpecJSI_getColorScheme}; + methodMap_["setColorScheme"] = MethodMetadata {1, __hostFunction_NativeAppearanceCxxSpecJSI_setColorScheme}; + methodMap_["addListener"] = MethodMetadata {1, __hostFunction_NativeAppearanceCxxSpecJSI_addListener}; + methodMap_["removeListeners"] = MethodMetadata {1, __hostFunction_NativeAppearanceCxxSpecJSI_removeListeners}; +} static jsi::Value __hostFunction_NativeBlobModuleCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->getConstants( rt @@ -1135,27 +1135,6 @@ NativeClipboardCxxSpecJSI::NativeClipboardCxxSpecJSI(std::shared_ptr(&turboModule)->invokeDefaultBackPressHandler( - rt - ); - return jsi::Value::undefined(); -} - -NativeDeviceEventManagerCxxSpecJSI::NativeDeviceEventManagerCxxSpecJSI(std::shared_ptr jsInvoker) - : TurboModule("DeviceEventManager", jsInvoker) { - methodMap_["invokeDefaultBackPressHandler"] = MethodMetadata {0, __hostFunction_NativeDeviceEventManagerCxxSpecJSI_invokeDefaultBackPressHandler}; -} -static jsi::Value __hostFunction_NativeDeviceInfoCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { - return static_cast(&turboModule)->getConstants( - rt - ); -} - -NativeDeviceInfoCxxSpecJSI::NativeDeviceInfoCxxSpecJSI(std::shared_ptr jsInvoker) - : TurboModule("DeviceInfo", jsInvoker) { - methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeDeviceInfoCxxSpecJSI_getConstants}; -} static jsi::Value __hostFunction_NativeDevLoadingViewCxxSpecJSI_showMessage(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { static_cast(&turboModule)->showMessage( rt, @@ -1299,6 +1278,27 @@ NativeDevSettingsCxxSpecJSI::NativeDevSettingsCxxSpecJSI(std::shared_ptr(&turboModule)->invokeDefaultBackPressHandler( + rt + ); + return jsi::Value::undefined(); +} + +NativeDeviceEventManagerCxxSpecJSI::NativeDeviceEventManagerCxxSpecJSI(std::shared_ptr jsInvoker) + : TurboModule("DeviceEventManager", jsInvoker) { + methodMap_["invokeDefaultBackPressHandler"] = MethodMetadata {0, __hostFunction_NativeDeviceEventManagerCxxSpecJSI_invokeDefaultBackPressHandler}; +} +static jsi::Value __hostFunction_NativeDeviceInfoCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { + return static_cast(&turboModule)->getConstants( + rt + ); +} + +NativeDeviceInfoCxxSpecJSI::NativeDeviceInfoCxxSpecJSI(std::shared_ptr jsInvoker) + : TurboModule("DeviceInfo", jsInvoker) { + methodMap_["getConstants"] = MethodMetadata {0, __hostFunction_NativeDeviceInfoCxxSpecJSI_getConstants}; +} static jsi::Value __hostFunction_NativeDialogManagerAndroidCxxSpecJSI_getConstants(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { return static_cast(&turboModule)->getConstants( rt diff --git a/vnext/codegen/rnwcoreJSI.h b/vnext/codegen/rnwcoreJSI.h index d03a6000dbd..c19042048d1 100644 --- a/vnext/codegen/rnwcoreJSI.h +++ b/vnext/codegen/rnwcoreJSI.h @@ -1871,87 +1871,6 @@ class JSI_EXPORT NativeAnimatedTurboModuleCxxSpec : public TurboModule { }; - class JSI_EXPORT NativeAppearanceCxxSpecJSI : public TurboModule { -protected: - NativeAppearanceCxxSpecJSI(std::shared_ptr jsInvoker); - -public: - virtual std::optional getColorScheme(jsi::Runtime &rt) = 0; - virtual void setColorScheme(jsi::Runtime &rt, jsi::String colorScheme) = 0; - virtual void addListener(jsi::Runtime &rt, jsi::String eventName) = 0; - virtual void removeListeners(jsi::Runtime &rt, double count) = 0; - -}; - -template -class JSI_EXPORT NativeAppearanceCxxSpec : public TurboModule { -public: - jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override { - return delegate_.create(rt, propName); - } - - std::vector getPropertyNames(jsi::Runtime& runtime) override { - return delegate_.getPropertyNames(runtime); - } - - static constexpr std::string_view kModuleName = "Appearance"; - -protected: - NativeAppearanceCxxSpec(std::shared_ptr jsInvoker) - : TurboModule(std::string{NativeAppearanceCxxSpec::kModuleName}, jsInvoker), - delegate_(reinterpret_cast(this), jsInvoker) {} - - -private: - class Delegate : public NativeAppearanceCxxSpecJSI { - public: - Delegate(T *instance, std::shared_ptr jsInvoker) : - NativeAppearanceCxxSpecJSI(std::move(jsInvoker)), instance_(instance) { - - } - - std::optional getColorScheme(jsi::Runtime &rt) override { - static_assert( - bridging::getParameterCount(&T::getColorScheme) == 1, - "Expected getColorScheme(...) to have 1 parameters"); - - return bridging::callFromJs>( - rt, &T::getColorScheme, jsInvoker_, instance_); - } - void setColorScheme(jsi::Runtime &rt, jsi::String colorScheme) override { - static_assert( - bridging::getParameterCount(&T::setColorScheme) == 2, - "Expected setColorScheme(...) to have 2 parameters"); - - return bridging::callFromJs( - rt, &T::setColorScheme, jsInvoker_, instance_, std::move(colorScheme)); - } - void addListener(jsi::Runtime &rt, jsi::String eventName) override { - static_assert( - bridging::getParameterCount(&T::addListener) == 2, - "Expected addListener(...) to have 2 parameters"); - - return bridging::callFromJs( - rt, &T::addListener, jsInvoker_, instance_, std::move(eventName)); - } - void removeListeners(jsi::Runtime &rt, double count) override { - static_assert( - bridging::getParameterCount(&T::removeListeners) == 2, - "Expected removeListeners(...) to have 2 parameters"); - - return bridging::callFromJs( - rt, &T::removeListeners, jsInvoker_, instance_, std::move(count)); - } - - private: - friend class NativeAppearanceCxxSpec; - T *instance_; - }; - - Delegate delegate_; -}; - - #pragma mark - NativeAppStateAppState @@ -2305,6 +2224,87 @@ class JSI_EXPORT NativeAppThemeCxxSpec : public TurboModule { }; + class JSI_EXPORT NativeAppearanceCxxSpecJSI : public TurboModule { +protected: + NativeAppearanceCxxSpecJSI(std::shared_ptr jsInvoker); + +public: + virtual std::optional getColorScheme(jsi::Runtime &rt) = 0; + virtual void setColorScheme(jsi::Runtime &rt, jsi::String colorScheme) = 0; + virtual void addListener(jsi::Runtime &rt, jsi::String eventName) = 0; + virtual void removeListeners(jsi::Runtime &rt, double count) = 0; + +}; + +template +class JSI_EXPORT NativeAppearanceCxxSpec : public TurboModule { +public: + jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.create(rt, propName); + } + + std::vector getPropertyNames(jsi::Runtime& runtime) override { + return delegate_.getPropertyNames(runtime); + } + + static constexpr std::string_view kModuleName = "Appearance"; + +protected: + NativeAppearanceCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(std::string{NativeAppearanceCxxSpec::kModuleName}, jsInvoker), + delegate_(reinterpret_cast(this), jsInvoker) {} + + +private: + class Delegate : public NativeAppearanceCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + NativeAppearanceCxxSpecJSI(std::move(jsInvoker)), instance_(instance) { + + } + + std::optional getColorScheme(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::getColorScheme) == 1, + "Expected getColorScheme(...) to have 1 parameters"); + + return bridging::callFromJs>( + rt, &T::getColorScheme, jsInvoker_, instance_); + } + void setColorScheme(jsi::Runtime &rt, jsi::String colorScheme) override { + static_assert( + bridging::getParameterCount(&T::setColorScheme) == 2, + "Expected setColorScheme(...) to have 2 parameters"); + + return bridging::callFromJs( + rt, &T::setColorScheme, jsInvoker_, instance_, std::move(colorScheme)); + } + void addListener(jsi::Runtime &rt, jsi::String eventName) override { + static_assert( + bridging::getParameterCount(&T::addListener) == 2, + "Expected addListener(...) to have 2 parameters"); + + return bridging::callFromJs( + rt, &T::addListener, jsInvoker_, instance_, std::move(eventName)); + } + void removeListeners(jsi::Runtime &rt, double count) override { + static_assert( + bridging::getParameterCount(&T::removeListeners) == 2, + "Expected removeListeners(...) to have 2 parameters"); + + return bridging::callFromJs( + rt, &T::removeListeners, jsInvoker_, instance_, std::move(count)); + } + + private: + friend class NativeAppearanceCxxSpec; + T *instance_; + }; + + Delegate delegate_; +}; + + #pragma mark - NativeBlobModuleConstants @@ -2595,17 +2595,18 @@ class JSI_EXPORT NativeClipboardCxxSpec : public TurboModule { }; - class JSI_EXPORT NativeDeviceEventManagerCxxSpecJSI : public TurboModule { + class JSI_EXPORT NativeDevLoadingViewCxxSpecJSI : public TurboModule { protected: - NativeDeviceEventManagerCxxSpecJSI(std::shared_ptr jsInvoker); + NativeDevLoadingViewCxxSpecJSI(std::shared_ptr jsInvoker); public: - virtual void invokeDefaultBackPressHandler(jsi::Runtime &rt) = 0; + virtual void showMessage(jsi::Runtime &rt, jsi::String message, std::optional withColor, std::optional withBackgroundColor) = 0; + virtual void hide(jsi::Runtime &rt) = 0; }; template -class JSI_EXPORT NativeDeviceEventManagerCxxSpec : public TurboModule { +class JSI_EXPORT NativeDevLoadingViewCxxSpec : public TurboModule { public: jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override { return delegate_.create(rt, propName); @@ -2615,33 +2616,41 @@ class JSI_EXPORT NativeDeviceEventManagerCxxSpec : public TurboModule { return delegate_.getPropertyNames(runtime); } - static constexpr std::string_view kModuleName = "DeviceEventManager"; + static constexpr std::string_view kModuleName = "DevLoadingView"; protected: - NativeDeviceEventManagerCxxSpec(std::shared_ptr jsInvoker) - : TurboModule(std::string{NativeDeviceEventManagerCxxSpec::kModuleName}, jsInvoker), + NativeDevLoadingViewCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(std::string{NativeDevLoadingViewCxxSpec::kModuleName}, jsInvoker), delegate_(reinterpret_cast(this), jsInvoker) {} private: - class Delegate : public NativeDeviceEventManagerCxxSpecJSI { + class Delegate : public NativeDevLoadingViewCxxSpecJSI { public: Delegate(T *instance, std::shared_ptr jsInvoker) : - NativeDeviceEventManagerCxxSpecJSI(std::move(jsInvoker)), instance_(instance) { + NativeDevLoadingViewCxxSpecJSI(std::move(jsInvoker)), instance_(instance) { } - void invokeDefaultBackPressHandler(jsi::Runtime &rt) override { + void showMessage(jsi::Runtime &rt, jsi::String message, std::optional withColor, std::optional withBackgroundColor) override { static_assert( - bridging::getParameterCount(&T::invokeDefaultBackPressHandler) == 1, - "Expected invokeDefaultBackPressHandler(...) to have 1 parameters"); + bridging::getParameterCount(&T::showMessage) == 4, + "Expected showMessage(...) to have 4 parameters"); return bridging::callFromJs( - rt, &T::invokeDefaultBackPressHandler, jsInvoker_, instance_); + rt, &T::showMessage, jsInvoker_, instance_, std::move(message), std::move(withColor), std::move(withBackgroundColor)); + } + void hide(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::hide) == 1, + "Expected hide(...) to have 1 parameters"); + + return bridging::callFromJs( + rt, &T::hide, jsInvoker_, instance_); } private: - friend class NativeDeviceEventManagerCxxSpec; + friend class NativeDevLoadingViewCxxSpec; T *instance_; }; @@ -2649,54 +2658,333 @@ class JSI_EXPORT NativeDeviceEventManagerCxxSpec : public TurboModule { }; - -#pragma mark - NativeDeviceInfoDeviceInfoConstants + class JSI_EXPORT NativeDevMenuCxxSpecJSI : public TurboModule { +protected: + NativeDevMenuCxxSpecJSI(std::shared_ptr jsInvoker); + +public: + virtual void show(jsi::Runtime &rt) = 0; + virtual void reload(jsi::Runtime &rt) = 0; + virtual void setProfilingEnabled(jsi::Runtime &rt, bool enabled) = 0; + virtual void setHotLoadingEnabled(jsi::Runtime &rt, bool enabled) = 0; -template -struct NativeDeviceInfoDeviceInfoConstants { - P0 Dimensions; - P1 isIPhoneX_deprecated; - bool operator==(const NativeDeviceInfoDeviceInfoConstants &other) const { - return Dimensions == other.Dimensions && isIPhoneX_deprecated == other.isIPhoneX_deprecated; - } }; template -struct NativeDeviceInfoDeviceInfoConstantsBridging { - static T types; - - static T fromJs( - jsi::Runtime &rt, - const jsi::Object &value, - const std::shared_ptr &jsInvoker) { - T result{ - bridging::fromJs(rt, value.getProperty(rt, "Dimensions"), jsInvoker), - bridging::fromJs(rt, value.getProperty(rt, "isIPhoneX_deprecated"), jsInvoker)}; - return result; - } - -#ifdef DEBUG - static jsi::Object DimensionsToJs(jsi::Runtime &rt, decltype(types.Dimensions) value) { - return bridging::toJs(rt, value); - } - - static bool isIPhoneX_deprecatedToJs(jsi::Runtime &rt, decltype(types.isIPhoneX_deprecated) value) { - return bridging::toJs(rt, value); +class JSI_EXPORT NativeDevMenuCxxSpec : public TurboModule { +public: + jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.create(rt, propName); } -#endif - static jsi::Object toJs( - jsi::Runtime &rt, - const T &value, - const std::shared_ptr &jsInvoker) { - auto result = facebook::jsi::Object(rt); - result.setProperty(rt, "Dimensions", bridging::toJs(rt, value.Dimensions, jsInvoker)); - if (value.isIPhoneX_deprecated) { - result.setProperty(rt, "isIPhoneX_deprecated", bridging::toJs(rt, value.isIPhoneX_deprecated.value(), jsInvoker)); - } - return result; + std::vector getPropertyNames(jsi::Runtime& runtime) override { + return delegate_.getPropertyNames(runtime); } -}; + + static constexpr std::string_view kModuleName = "DevMenu"; + +protected: + NativeDevMenuCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(std::string{NativeDevMenuCxxSpec::kModuleName}, jsInvoker), + delegate_(reinterpret_cast(this), jsInvoker) {} + + +private: + class Delegate : public NativeDevMenuCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + NativeDevMenuCxxSpecJSI(std::move(jsInvoker)), instance_(instance) { + + } + + void show(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::show) == 1, + "Expected show(...) to have 1 parameters"); + + return bridging::callFromJs( + rt, &T::show, jsInvoker_, instance_); + } + void reload(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::reload) == 1, + "Expected reload(...) to have 1 parameters"); + + return bridging::callFromJs( + rt, &T::reload, jsInvoker_, instance_); + } + void setProfilingEnabled(jsi::Runtime &rt, bool enabled) override { + static_assert( + bridging::getParameterCount(&T::setProfilingEnabled) == 2, + "Expected setProfilingEnabled(...) to have 2 parameters"); + + return bridging::callFromJs( + rt, &T::setProfilingEnabled, jsInvoker_, instance_, std::move(enabled)); + } + void setHotLoadingEnabled(jsi::Runtime &rt, bool enabled) override { + static_assert( + bridging::getParameterCount(&T::setHotLoadingEnabled) == 2, + "Expected setHotLoadingEnabled(...) to have 2 parameters"); + + return bridging::callFromJs( + rt, &T::setHotLoadingEnabled, jsInvoker_, instance_, std::move(enabled)); + } + + private: + friend class NativeDevMenuCxxSpec; + T *instance_; + }; + + Delegate delegate_; +}; + + + class JSI_EXPORT NativeDevSettingsCxxSpecJSI : public TurboModule { +protected: + NativeDevSettingsCxxSpecJSI(std::shared_ptr jsInvoker); + +public: + virtual void reload(jsi::Runtime &rt) = 0; + virtual void reloadWithReason(jsi::Runtime &rt, jsi::String reason) = 0; + virtual void onFastRefresh(jsi::Runtime &rt) = 0; + virtual void setHotLoadingEnabled(jsi::Runtime &rt, bool isHotLoadingEnabled) = 0; + virtual void setProfilingEnabled(jsi::Runtime &rt, bool isProfilingEnabled) = 0; + virtual void toggleElementInspector(jsi::Runtime &rt) = 0; + virtual void addMenuItem(jsi::Runtime &rt, jsi::String title) = 0; + virtual void openDebugger(jsi::Runtime &rt) = 0; + virtual void addListener(jsi::Runtime &rt, jsi::String eventName) = 0; + virtual void removeListeners(jsi::Runtime &rt, double count) = 0; + virtual void setIsShakeToShowDevMenuEnabled(jsi::Runtime &rt, bool enabled) = 0; + +}; + +template +class JSI_EXPORT NativeDevSettingsCxxSpec : public TurboModule { +public: + jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.create(rt, propName); + } + + std::vector getPropertyNames(jsi::Runtime& runtime) override { + return delegate_.getPropertyNames(runtime); + } + + static constexpr std::string_view kModuleName = "DevSettings"; + +protected: + NativeDevSettingsCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(std::string{NativeDevSettingsCxxSpec::kModuleName}, jsInvoker), + delegate_(reinterpret_cast(this), jsInvoker) {} + + +private: + class Delegate : public NativeDevSettingsCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + NativeDevSettingsCxxSpecJSI(std::move(jsInvoker)), instance_(instance) { + + } + + void reload(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::reload) == 1, + "Expected reload(...) to have 1 parameters"); + + return bridging::callFromJs( + rt, &T::reload, jsInvoker_, instance_); + } + void reloadWithReason(jsi::Runtime &rt, jsi::String reason) override { + static_assert( + bridging::getParameterCount(&T::reloadWithReason) == 2, + "Expected reloadWithReason(...) to have 2 parameters"); + + return bridging::callFromJs( + rt, &T::reloadWithReason, jsInvoker_, instance_, std::move(reason)); + } + void onFastRefresh(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::onFastRefresh) == 1, + "Expected onFastRefresh(...) to have 1 parameters"); + + return bridging::callFromJs( + rt, &T::onFastRefresh, jsInvoker_, instance_); + } + void setHotLoadingEnabled(jsi::Runtime &rt, bool isHotLoadingEnabled) override { + static_assert( + bridging::getParameterCount(&T::setHotLoadingEnabled) == 2, + "Expected setHotLoadingEnabled(...) to have 2 parameters"); + + return bridging::callFromJs( + rt, &T::setHotLoadingEnabled, jsInvoker_, instance_, std::move(isHotLoadingEnabled)); + } + void setProfilingEnabled(jsi::Runtime &rt, bool isProfilingEnabled) override { + static_assert( + bridging::getParameterCount(&T::setProfilingEnabled) == 2, + "Expected setProfilingEnabled(...) to have 2 parameters"); + + return bridging::callFromJs( + rt, &T::setProfilingEnabled, jsInvoker_, instance_, std::move(isProfilingEnabled)); + } + void toggleElementInspector(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::toggleElementInspector) == 1, + "Expected toggleElementInspector(...) to have 1 parameters"); + + return bridging::callFromJs( + rt, &T::toggleElementInspector, jsInvoker_, instance_); + } + void addMenuItem(jsi::Runtime &rt, jsi::String title) override { + static_assert( + bridging::getParameterCount(&T::addMenuItem) == 2, + "Expected addMenuItem(...) to have 2 parameters"); + + return bridging::callFromJs( + rt, &T::addMenuItem, jsInvoker_, instance_, std::move(title)); + } + void openDebugger(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::openDebugger) == 1, + "Expected openDebugger(...) to have 1 parameters"); + + return bridging::callFromJs( + rt, &T::openDebugger, jsInvoker_, instance_); + } + void addListener(jsi::Runtime &rt, jsi::String eventName) override { + static_assert( + bridging::getParameterCount(&T::addListener) == 2, + "Expected addListener(...) to have 2 parameters"); + + return bridging::callFromJs( + rt, &T::addListener, jsInvoker_, instance_, std::move(eventName)); + } + void removeListeners(jsi::Runtime &rt, double count) override { + static_assert( + bridging::getParameterCount(&T::removeListeners) == 2, + "Expected removeListeners(...) to have 2 parameters"); + + return bridging::callFromJs( + rt, &T::removeListeners, jsInvoker_, instance_, std::move(count)); + } + void setIsShakeToShowDevMenuEnabled(jsi::Runtime &rt, bool enabled) override { + static_assert( + bridging::getParameterCount(&T::setIsShakeToShowDevMenuEnabled) == 2, + "Expected setIsShakeToShowDevMenuEnabled(...) to have 2 parameters"); + + return bridging::callFromJs( + rt, &T::setIsShakeToShowDevMenuEnabled, jsInvoker_, instance_, std::move(enabled)); + } + + private: + friend class NativeDevSettingsCxxSpec; + T *instance_; + }; + + Delegate delegate_; +}; + + + class JSI_EXPORT NativeDeviceEventManagerCxxSpecJSI : public TurboModule { +protected: + NativeDeviceEventManagerCxxSpecJSI(std::shared_ptr jsInvoker); + +public: + virtual void invokeDefaultBackPressHandler(jsi::Runtime &rt) = 0; + +}; + +template +class JSI_EXPORT NativeDeviceEventManagerCxxSpec : public TurboModule { +public: + jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override { + return delegate_.create(rt, propName); + } + + std::vector getPropertyNames(jsi::Runtime& runtime) override { + return delegate_.getPropertyNames(runtime); + } + + static constexpr std::string_view kModuleName = "DeviceEventManager"; + +protected: + NativeDeviceEventManagerCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(std::string{NativeDeviceEventManagerCxxSpec::kModuleName}, jsInvoker), + delegate_(reinterpret_cast(this), jsInvoker) {} + + +private: + class Delegate : public NativeDeviceEventManagerCxxSpecJSI { + public: + Delegate(T *instance, std::shared_ptr jsInvoker) : + NativeDeviceEventManagerCxxSpecJSI(std::move(jsInvoker)), instance_(instance) { + + } + + void invokeDefaultBackPressHandler(jsi::Runtime &rt) override { + static_assert( + bridging::getParameterCount(&T::invokeDefaultBackPressHandler) == 1, + "Expected invokeDefaultBackPressHandler(...) to have 1 parameters"); + + return bridging::callFromJs( + rt, &T::invokeDefaultBackPressHandler, jsInvoker_, instance_); + } + + private: + friend class NativeDeviceEventManagerCxxSpec; + T *instance_; + }; + + Delegate delegate_; +}; + + + +#pragma mark - NativeDeviceInfoDeviceInfoConstants + +template +struct NativeDeviceInfoDeviceInfoConstants { + P0 Dimensions; + P1 isIPhoneX_deprecated; + bool operator==(const NativeDeviceInfoDeviceInfoConstants &other) const { + return Dimensions == other.Dimensions && isIPhoneX_deprecated == other.isIPhoneX_deprecated; + } +}; + +template +struct NativeDeviceInfoDeviceInfoConstantsBridging { + static T types; + + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, "Dimensions"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, "isIPhoneX_deprecated"), jsInvoker)}; + return result; + } + +#ifdef DEBUG + static jsi::Object DimensionsToJs(jsi::Runtime &rt, decltype(types.Dimensions) value) { + return bridging::toJs(rt, value); + } + + static bool isIPhoneX_deprecatedToJs(jsi::Runtime &rt, decltype(types.isIPhoneX_deprecated) value) { + return bridging::toJs(rt, value); + } +#endif + + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, "Dimensions", bridging::toJs(rt, value.Dimensions, jsInvoker)); + if (value.isIPhoneX_deprecated) { + result.setProperty(rt, "isIPhoneX_deprecated", bridging::toJs(rt, value.isIPhoneX_deprecated.value(), jsInvoker)); + } + return result; + } +}; @@ -2801,323 +3089,115 @@ struct NativeDeviceInfoDisplayMetricsBridging { #ifdef DEBUG static double widthToJs(jsi::Runtime &rt, decltype(types.width) value) { - return bridging::toJs(rt, value); - } - - static double heightToJs(jsi::Runtime &rt, decltype(types.height) value) { - return bridging::toJs(rt, value); - } - - static double scaleToJs(jsi::Runtime &rt, decltype(types.scale) value) { - return bridging::toJs(rt, value); - } - - static double fontScaleToJs(jsi::Runtime &rt, decltype(types.fontScale) value) { - return bridging::toJs(rt, value); - } -#endif - - static jsi::Object toJs( - jsi::Runtime &rt, - const T &value, - const std::shared_ptr &jsInvoker) { - auto result = facebook::jsi::Object(rt); - result.setProperty(rt, "width", bridging::toJs(rt, value.width, jsInvoker)); - result.setProperty(rt, "height", bridging::toJs(rt, value.height, jsInvoker)); - result.setProperty(rt, "scale", bridging::toJs(rt, value.scale, jsInvoker)); - result.setProperty(rt, "fontScale", bridging::toJs(rt, value.fontScale, jsInvoker)); - return result; - } -}; - - - -#pragma mark - NativeDeviceInfoDisplayMetricsAndroid - -template -struct NativeDeviceInfoDisplayMetricsAndroid { - P0 width; - P1 height; - P2 scale; - P3 fontScale; - P4 densityDpi; - bool operator==(const NativeDeviceInfoDisplayMetricsAndroid &other) const { - return width == other.width && height == other.height && scale == other.scale && fontScale == other.fontScale && densityDpi == other.densityDpi; - } -}; - -template -struct NativeDeviceInfoDisplayMetricsAndroidBridging { - static T types; - - static T fromJs( - jsi::Runtime &rt, - const jsi::Object &value, - const std::shared_ptr &jsInvoker) { - T result{ - bridging::fromJs(rt, value.getProperty(rt, "width"), jsInvoker), - bridging::fromJs(rt, value.getProperty(rt, "height"), jsInvoker), - bridging::fromJs(rt, value.getProperty(rt, "scale"), jsInvoker), - bridging::fromJs(rt, value.getProperty(rt, "fontScale"), jsInvoker), - bridging::fromJs(rt, value.getProperty(rt, "densityDpi"), jsInvoker)}; - return result; - } - -#ifdef DEBUG - static double widthToJs(jsi::Runtime &rt, decltype(types.width) value) { - return bridging::toJs(rt, value); - } - - static double heightToJs(jsi::Runtime &rt, decltype(types.height) value) { - return bridging::toJs(rt, value); - } - - static double scaleToJs(jsi::Runtime &rt, decltype(types.scale) value) { - return bridging::toJs(rt, value); - } - - static double fontScaleToJs(jsi::Runtime &rt, decltype(types.fontScale) value) { - return bridging::toJs(rt, value); - } - - static double densityDpiToJs(jsi::Runtime &rt, decltype(types.densityDpi) value) { - return bridging::toJs(rt, value); - } -#endif - - static jsi::Object toJs( - jsi::Runtime &rt, - const T &value, - const std::shared_ptr &jsInvoker) { - auto result = facebook::jsi::Object(rt); - result.setProperty(rt, "width", bridging::toJs(rt, value.width, jsInvoker)); - result.setProperty(rt, "height", bridging::toJs(rt, value.height, jsInvoker)); - result.setProperty(rt, "scale", bridging::toJs(rt, value.scale, jsInvoker)); - result.setProperty(rt, "fontScale", bridging::toJs(rt, value.fontScale, jsInvoker)); - result.setProperty(rt, "densityDpi", bridging::toJs(rt, value.densityDpi, jsInvoker)); - return result; - } -}; - -class JSI_EXPORT NativeDeviceInfoCxxSpecJSI : public TurboModule { -protected: - NativeDeviceInfoCxxSpecJSI(std::shared_ptr jsInvoker); - -public: - virtual jsi::Object getConstants(jsi::Runtime &rt) = 0; - -}; - -template -class JSI_EXPORT NativeDeviceInfoCxxSpec : public TurboModule { -public: - jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override { - return delegate_.create(rt, propName); - } - - std::vector getPropertyNames(jsi::Runtime& runtime) override { - return delegate_.getPropertyNames(runtime); - } - - static constexpr std::string_view kModuleName = "DeviceInfo"; - -protected: - NativeDeviceInfoCxxSpec(std::shared_ptr jsInvoker) - : TurboModule(std::string{NativeDeviceInfoCxxSpec::kModuleName}, jsInvoker), - delegate_(reinterpret_cast(this), jsInvoker) {} - - -private: - class Delegate : public NativeDeviceInfoCxxSpecJSI { - public: - Delegate(T *instance, std::shared_ptr jsInvoker) : - NativeDeviceInfoCxxSpecJSI(std::move(jsInvoker)), instance_(instance) { - - } - - jsi::Object getConstants(jsi::Runtime &rt) override { - static_assert( - bridging::getParameterCount(&T::getConstants) == 1, - "Expected getConstants(...) to have 1 parameters"); - - return bridging::callFromJs( - rt, &T::getConstants, jsInvoker_, instance_); - } - - private: - friend class NativeDeviceInfoCxxSpec; - T *instance_; - }; - - Delegate delegate_; -}; - - - class JSI_EXPORT NativeDevLoadingViewCxxSpecJSI : public TurboModule { -protected: - NativeDevLoadingViewCxxSpecJSI(std::shared_ptr jsInvoker); - -public: - virtual void showMessage(jsi::Runtime &rt, jsi::String message, std::optional withColor, std::optional withBackgroundColor) = 0; - virtual void hide(jsi::Runtime &rt) = 0; - -}; - -template -class JSI_EXPORT NativeDevLoadingViewCxxSpec : public TurboModule { -public: - jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override { - return delegate_.create(rt, propName); - } - - std::vector getPropertyNames(jsi::Runtime& runtime) override { - return delegate_.getPropertyNames(runtime); - } - - static constexpr std::string_view kModuleName = "DevLoadingView"; - -protected: - NativeDevLoadingViewCxxSpec(std::shared_ptr jsInvoker) - : TurboModule(std::string{NativeDevLoadingViewCxxSpec::kModuleName}, jsInvoker), - delegate_(reinterpret_cast(this), jsInvoker) {} - - -private: - class Delegate : public NativeDevLoadingViewCxxSpecJSI { - public: - Delegate(T *instance, std::shared_ptr jsInvoker) : - NativeDevLoadingViewCxxSpecJSI(std::move(jsInvoker)), instance_(instance) { - - } - - void showMessage(jsi::Runtime &rt, jsi::String message, std::optional withColor, std::optional withBackgroundColor) override { - static_assert( - bridging::getParameterCount(&T::showMessage) == 4, - "Expected showMessage(...) to have 4 parameters"); - - return bridging::callFromJs( - rt, &T::showMessage, jsInvoker_, instance_, std::move(message), std::move(withColor), std::move(withBackgroundColor)); - } - void hide(jsi::Runtime &rt) override { - static_assert( - bridging::getParameterCount(&T::hide) == 1, - "Expected hide(...) to have 1 parameters"); - - return bridging::callFromJs( - rt, &T::hide, jsInvoker_, instance_); - } - - private: - friend class NativeDevLoadingViewCxxSpec; - T *instance_; - }; - - Delegate delegate_; -}; - - - class JSI_EXPORT NativeDevMenuCxxSpecJSI : public TurboModule { -protected: - NativeDevMenuCxxSpecJSI(std::shared_ptr jsInvoker); + return bridging::toJs(rt, value); + } -public: - virtual void show(jsi::Runtime &rt) = 0; - virtual void reload(jsi::Runtime &rt) = 0; - virtual void setProfilingEnabled(jsi::Runtime &rt, bool enabled) = 0; - virtual void setHotLoadingEnabled(jsi::Runtime &rt, bool enabled) = 0; + static double heightToJs(jsi::Runtime &rt, decltype(types.height) value) { + return bridging::toJs(rt, value); + } -}; + static double scaleToJs(jsi::Runtime &rt, decltype(types.scale) value) { + return bridging::toJs(rt, value); + } -template -class JSI_EXPORT NativeDevMenuCxxSpec : public TurboModule { -public: - jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override { - return delegate_.create(rt, propName); + static double fontScaleToJs(jsi::Runtime &rt, decltype(types.fontScale) value) { + return bridging::toJs(rt, value); } +#endif - std::vector getPropertyNames(jsi::Runtime& runtime) override { - return delegate_.getPropertyNames(runtime); + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, "width", bridging::toJs(rt, value.width, jsInvoker)); + result.setProperty(rt, "height", bridging::toJs(rt, value.height, jsInvoker)); + result.setProperty(rt, "scale", bridging::toJs(rt, value.scale, jsInvoker)); + result.setProperty(rt, "fontScale", bridging::toJs(rt, value.fontScale, jsInvoker)); + return result; } +}; - static constexpr std::string_view kModuleName = "DevMenu"; -protected: - NativeDevMenuCxxSpec(std::shared_ptr jsInvoker) - : TurboModule(std::string{NativeDevMenuCxxSpec::kModuleName}, jsInvoker), - delegate_(reinterpret_cast(this), jsInvoker) {} +#pragma mark - NativeDeviceInfoDisplayMetricsAndroid -private: - class Delegate : public NativeDevMenuCxxSpecJSI { - public: - Delegate(T *instance, std::shared_ptr jsInvoker) : - NativeDevMenuCxxSpecJSI(std::move(jsInvoker)), instance_(instance) { +template +struct NativeDeviceInfoDisplayMetricsAndroid { + P0 width; + P1 height; + P2 scale; + P3 fontScale; + P4 densityDpi; + bool operator==(const NativeDeviceInfoDisplayMetricsAndroid &other) const { + return width == other.width && height == other.height && scale == other.scale && fontScale == other.fontScale && densityDpi == other.densityDpi; + } +}; - } +template +struct NativeDeviceInfoDisplayMetricsAndroidBridging { + static T types; - void show(jsi::Runtime &rt) override { - static_assert( - bridging::getParameterCount(&T::show) == 1, - "Expected show(...) to have 1 parameters"); + static T fromJs( + jsi::Runtime &rt, + const jsi::Object &value, + const std::shared_ptr &jsInvoker) { + T result{ + bridging::fromJs(rt, value.getProperty(rt, "width"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, "height"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, "scale"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, "fontScale"), jsInvoker), + bridging::fromJs(rt, value.getProperty(rt, "densityDpi"), jsInvoker)}; + return result; + } - return bridging::callFromJs( - rt, &T::show, jsInvoker_, instance_); - } - void reload(jsi::Runtime &rt) override { - static_assert( - bridging::getParameterCount(&T::reload) == 1, - "Expected reload(...) to have 1 parameters"); +#ifdef DEBUG + static double widthToJs(jsi::Runtime &rt, decltype(types.width) value) { + return bridging::toJs(rt, value); + } - return bridging::callFromJs( - rt, &T::reload, jsInvoker_, instance_); - } - void setProfilingEnabled(jsi::Runtime &rt, bool enabled) override { - static_assert( - bridging::getParameterCount(&T::setProfilingEnabled) == 2, - "Expected setProfilingEnabled(...) to have 2 parameters"); + static double heightToJs(jsi::Runtime &rt, decltype(types.height) value) { + return bridging::toJs(rt, value); + } - return bridging::callFromJs( - rt, &T::setProfilingEnabled, jsInvoker_, instance_, std::move(enabled)); - } - void setHotLoadingEnabled(jsi::Runtime &rt, bool enabled) override { - static_assert( - bridging::getParameterCount(&T::setHotLoadingEnabled) == 2, - "Expected setHotLoadingEnabled(...) to have 2 parameters"); + static double scaleToJs(jsi::Runtime &rt, decltype(types.scale) value) { + return bridging::toJs(rt, value); + } - return bridging::callFromJs( - rt, &T::setHotLoadingEnabled, jsInvoker_, instance_, std::move(enabled)); - } + static double fontScaleToJs(jsi::Runtime &rt, decltype(types.fontScale) value) { + return bridging::toJs(rt, value); + } - private: - friend class NativeDevMenuCxxSpec; - T *instance_; - }; + static double densityDpiToJs(jsi::Runtime &rt, decltype(types.densityDpi) value) { + return bridging::toJs(rt, value); + } +#endif - Delegate delegate_; + static jsi::Object toJs( + jsi::Runtime &rt, + const T &value, + const std::shared_ptr &jsInvoker) { + auto result = facebook::jsi::Object(rt); + result.setProperty(rt, "width", bridging::toJs(rt, value.width, jsInvoker)); + result.setProperty(rt, "height", bridging::toJs(rt, value.height, jsInvoker)); + result.setProperty(rt, "scale", bridging::toJs(rt, value.scale, jsInvoker)); + result.setProperty(rt, "fontScale", bridging::toJs(rt, value.fontScale, jsInvoker)); + result.setProperty(rt, "densityDpi", bridging::toJs(rt, value.densityDpi, jsInvoker)); + return result; + } }; - - class JSI_EXPORT NativeDevSettingsCxxSpecJSI : public TurboModule { +class JSI_EXPORT NativeDeviceInfoCxxSpecJSI : public TurboModule { protected: - NativeDevSettingsCxxSpecJSI(std::shared_ptr jsInvoker); + NativeDeviceInfoCxxSpecJSI(std::shared_ptr jsInvoker); public: - virtual void reload(jsi::Runtime &rt) = 0; - virtual void reloadWithReason(jsi::Runtime &rt, jsi::String reason) = 0; - virtual void onFastRefresh(jsi::Runtime &rt) = 0; - virtual void setHotLoadingEnabled(jsi::Runtime &rt, bool isHotLoadingEnabled) = 0; - virtual void setProfilingEnabled(jsi::Runtime &rt, bool isProfilingEnabled) = 0; - virtual void toggleElementInspector(jsi::Runtime &rt) = 0; - virtual void addMenuItem(jsi::Runtime &rt, jsi::String title) = 0; - virtual void openDebugger(jsi::Runtime &rt) = 0; - virtual void addListener(jsi::Runtime &rt, jsi::String eventName) = 0; - virtual void removeListeners(jsi::Runtime &rt, double count) = 0; - virtual void setIsShakeToShowDevMenuEnabled(jsi::Runtime &rt, bool enabled) = 0; + virtual jsi::Object getConstants(jsi::Runtime &rt) = 0; }; template -class JSI_EXPORT NativeDevSettingsCxxSpec : public TurboModule { +class JSI_EXPORT NativeDeviceInfoCxxSpec : public TurboModule { public: jsi::Value create(jsi::Runtime &rt, const jsi::PropNameID &propName) override { return delegate_.create(rt, propName); @@ -3127,113 +3207,33 @@ class JSI_EXPORT NativeDevSettingsCxxSpec : public TurboModule { return delegate_.getPropertyNames(runtime); } - static constexpr std::string_view kModuleName = "DevSettings"; + static constexpr std::string_view kModuleName = "DeviceInfo"; protected: - NativeDevSettingsCxxSpec(std::shared_ptr jsInvoker) - : TurboModule(std::string{NativeDevSettingsCxxSpec::kModuleName}, jsInvoker), + NativeDeviceInfoCxxSpec(std::shared_ptr jsInvoker) + : TurboModule(std::string{NativeDeviceInfoCxxSpec::kModuleName}, jsInvoker), delegate_(reinterpret_cast(this), jsInvoker) {} private: - class Delegate : public NativeDevSettingsCxxSpecJSI { + class Delegate : public NativeDeviceInfoCxxSpecJSI { public: Delegate(T *instance, std::shared_ptr jsInvoker) : - NativeDevSettingsCxxSpecJSI(std::move(jsInvoker)), instance_(instance) { - - } - - void reload(jsi::Runtime &rt) override { - static_assert( - bridging::getParameterCount(&T::reload) == 1, - "Expected reload(...) to have 1 parameters"); - - return bridging::callFromJs( - rt, &T::reload, jsInvoker_, instance_); - } - void reloadWithReason(jsi::Runtime &rt, jsi::String reason) override { - static_assert( - bridging::getParameterCount(&T::reloadWithReason) == 2, - "Expected reloadWithReason(...) to have 2 parameters"); - - return bridging::callFromJs( - rt, &T::reloadWithReason, jsInvoker_, instance_, std::move(reason)); - } - void onFastRefresh(jsi::Runtime &rt) override { - static_assert( - bridging::getParameterCount(&T::onFastRefresh) == 1, - "Expected onFastRefresh(...) to have 1 parameters"); - - return bridging::callFromJs( - rt, &T::onFastRefresh, jsInvoker_, instance_); - } - void setHotLoadingEnabled(jsi::Runtime &rt, bool isHotLoadingEnabled) override { - static_assert( - bridging::getParameterCount(&T::setHotLoadingEnabled) == 2, - "Expected setHotLoadingEnabled(...) to have 2 parameters"); - - return bridging::callFromJs( - rt, &T::setHotLoadingEnabled, jsInvoker_, instance_, std::move(isHotLoadingEnabled)); - } - void setProfilingEnabled(jsi::Runtime &rt, bool isProfilingEnabled) override { - static_assert( - bridging::getParameterCount(&T::setProfilingEnabled) == 2, - "Expected setProfilingEnabled(...) to have 2 parameters"); - - return bridging::callFromJs( - rt, &T::setProfilingEnabled, jsInvoker_, instance_, std::move(isProfilingEnabled)); - } - void toggleElementInspector(jsi::Runtime &rt) override { - static_assert( - bridging::getParameterCount(&T::toggleElementInspector) == 1, - "Expected toggleElementInspector(...) to have 1 parameters"); - - return bridging::callFromJs( - rt, &T::toggleElementInspector, jsInvoker_, instance_); - } - void addMenuItem(jsi::Runtime &rt, jsi::String title) override { - static_assert( - bridging::getParameterCount(&T::addMenuItem) == 2, - "Expected addMenuItem(...) to have 2 parameters"); - - return bridging::callFromJs( - rt, &T::addMenuItem, jsInvoker_, instance_, std::move(title)); - } - void openDebugger(jsi::Runtime &rt) override { - static_assert( - bridging::getParameterCount(&T::openDebugger) == 1, - "Expected openDebugger(...) to have 1 parameters"); - - return bridging::callFromJs( - rt, &T::openDebugger, jsInvoker_, instance_); - } - void addListener(jsi::Runtime &rt, jsi::String eventName) override { - static_assert( - bridging::getParameterCount(&T::addListener) == 2, - "Expected addListener(...) to have 2 parameters"); + NativeDeviceInfoCxxSpecJSI(std::move(jsInvoker)), instance_(instance) { - return bridging::callFromJs( - rt, &T::addListener, jsInvoker_, instance_, std::move(eventName)); } - void removeListeners(jsi::Runtime &rt, double count) override { - static_assert( - bridging::getParameterCount(&T::removeListeners) == 2, - "Expected removeListeners(...) to have 2 parameters"); - return bridging::callFromJs( - rt, &T::removeListeners, jsInvoker_, instance_, std::move(count)); - } - void setIsShakeToShowDevMenuEnabled(jsi::Runtime &rt, bool enabled) override { + jsi::Object getConstants(jsi::Runtime &rt) override { static_assert( - bridging::getParameterCount(&T::setIsShakeToShowDevMenuEnabled) == 2, - "Expected setIsShakeToShowDevMenuEnabled(...) to have 2 parameters"); + bridging::getParameterCount(&T::getConstants) == 1, + "Expected getConstants(...) to have 1 parameters"); - return bridging::callFromJs( - rt, &T::setIsShakeToShowDevMenuEnabled, jsInvoker_, instance_, std::move(enabled)); + return bridging::callFromJs( + rt, &T::getConstants, jsInvoker_, instance_); } private: - friend class NativeDevSettingsCxxSpec; + friend class NativeDeviceInfoCxxSpec; T *instance_; }; From 43beb61d186acbec64dd272757a27915869d9723 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 12 Jun 2025 18:54:08 +0000 Subject: [PATCH 5/5] Remove Flyout component tests - component not supported in Fabric Co-authored-by: chiaramooney <34109996+chiaramooney@users.noreply.github.com> --- .../test/FlyoutComponentTest.test.ts | 180 ------------------ 1 file changed, 180 deletions(-) delete mode 100644 packages/e2e-test-app-fabric/test/FlyoutComponentTest.test.ts diff --git a/packages/e2e-test-app-fabric/test/FlyoutComponentTest.test.ts b/packages/e2e-test-app-fabric/test/FlyoutComponentTest.test.ts deleted file mode 100644 index 08ada42e695..00000000000 --- a/packages/e2e-test-app-fabric/test/FlyoutComponentTest.test.ts +++ /dev/null @@ -1,180 +0,0 @@ -/** - * Copyright (c) Microsoft Corporation. - * Licensed under the MIT License. - * - * @format - */ - -import {dumpVisualTree} from '@react-native-windows/automation-commands'; -import {goToComponentExample} from './RNTesterNavigation'; -import {app} from '@react-native-windows/automation'; -import {verifyNoErrorLogs} from './Helpers'; - -beforeAll(async () => { - // If window is partially offscreen, tests will fail to click on certain elements - await app.setWindowPosition(0, 0); - await app.setWindowSize(1000, 1250); - await goToComponentExample('Flyout'); -}); - -afterEach(async () => { - await verifyNoErrorLogs(); -}); - -// Note: Flyout is currently excluded from visitAllPages.test.ts which may indicate -// compatibility issues with the Fabric app. These tests may need adjustments -// based on actual Flyout availability and functionality in the e2e-test-app-fabric. -describe('Flyout Tests', () => { - test('A Flyout container is displayed with default state', async () => { - const component = await app.findElementByTestID('flyout'); - await component.waitForDisplayed({timeout: 5000}); - const dump = await dumpVisualTree('flyout'); - expect(dump).toMatchSnapshot(); - }); - - test('A Flyout can be opened with a target', async () => { - // Click the "Open Flyout" button to show the flyout - // Note: Using XPath to find button by Name since it lacks explicit testID - const openButton = await app.findElementByXPath( - '//Button[@Name="Open Flyout"]', - ); - await openButton.waitForDisplayed({timeout: 5000}); - await openButton.click(); - - // Wait for flyout to appear and capture its state - // Note: testID 'flyout-accessibility' should be set in FlyoutExample - const flyout = await app.findElementByTestID('flyout-accessibility'); - await flyout.waitForDisplayed({timeout: 5000}); - const dump = await dumpVisualTree('flyout-accessibility'); - expect(dump).toMatchSnapshot(); - - // Close the flyout - const closeButton = await app.findElementByXPath('//Button[@Name="Close"]'); - await closeButton.click(); - }); - - test('A Flyout can be opened without a target', async () => { - // Click the "Open Flyout without Target" button - const openButton = await app.findElementByXPath( - '//Button[@Name="Open Flyout without Target"]', - ); - await openButton.waitForDisplayed({timeout: 5000}); - await openButton.click(); - - // Wait for flyout to appear and capture its state - const flyout = await app.findElementByTestID('flyout-accessibility-3'); - await flyout.waitForDisplayed({timeout: 5000}); - const dump = await dumpVisualTree('flyout-accessibility-3'); - expect(dump).toMatchSnapshot(); - - // Close the flyout by clicking outside (light dismiss) - const mainContainer = await app.findElementByTestID('flyout'); - await mainContainer.click(); - }); - - test('A Flyout can be opened with offset', async () => { - // Click the "Open Flyout with Offset" button - const openButton = await app.findElementByXPath( - '//Button[@Name="Open Flyout with Offset"]', - ); - await openButton.waitForDisplayed({timeout: 5000}); - await openButton.click(); - - // Wait for flyout to appear and capture its state - const flyout = await app.findElementByTestID('flyout-accessibility-4'); - await flyout.waitForDisplayed({timeout: 5000}); - const dump = await dumpVisualTree('flyout-accessibility-4'); - expect(dump).toMatchSnapshot(); - - // Close the flyout by clicking outside (light dismiss) - const mainContainer = await app.findElementByTestID('flyout'); - await mainContainer.click(); - }); - - test('A Flyout can have different placement options', async () => { - // Test different placement options by changing the picker value - const placementPicker = await app.findElementByTestID('placement-picker'); - if (await placementPicker.isDisplayed()) { - // Change to bottom placement - await placementPicker.selectByVisibleText('bottom'); - - // Open flyout to test bottom placement - const openButton = await app.findElementByXPath( - '//Button[@Name="Open Flyout"]', - ); - await openButton.click(); - - const flyout = await app.findElementByTestID('flyout-accessibility'); - await flyout.waitForDisplayed({timeout: 5000}); - const dump = await dumpVisualTree('flyout-accessibility'); - expect(dump).toMatchSnapshot(); - - // Close the flyout - const closeButton = await app.findElementByXPath( - '//Button[@Name="Close"]', - ); - await closeButton.click(); - } - }); - - test('A Flyout can be nested with another Flyout', async () => { - // Open the main flyout first - const openButton = await app.findElementByXPath( - '//Button[@Name="Open Flyout"]', - ); - await openButton.waitForDisplayed({timeout: 5000}); - await openButton.click(); - - // Wait for main flyout to appear - const flyout = await app.findElementByTestID('flyout-accessibility'); - await flyout.waitForDisplayed({timeout: 5000}); - - // Open another flyout from within the first one - const openAnotherButton = await app.findElementByXPath( - '//Button[@Name="Open Another Flyout"]', - ); - await openAnotherButton.waitForDisplayed({timeout: 5000}); - await openAnotherButton.click(); - - // Wait for second flyout to appear and capture state - const secondFlyout = await app.findElementByTestID( - 'flyout-accessibility-2', - ); - await secondFlyout.waitForDisplayed({timeout: 5000}); - const dump = await dumpVisualTree('flyout-accessibility-2'); - expect(dump).toMatchSnapshot(); - - // Close both flyouts by clicking outside - const mainContainer = await app.findElementByTestID('flyout'); - await mainContainer.click(); - }); - - test('A Flyout can contain a Popup', async () => { - // Open the main flyout first - const openButton = await app.findElementByXPath( - '//Button[@Name="Open Flyout"]', - ); - await openButton.waitForDisplayed({timeout: 5000}); - await openButton.click(); - - // Wait for main flyout to appear - const flyout = await app.findElementByTestID('flyout-accessibility'); - await flyout.waitForDisplayed({timeout: 5000}); - - // Open a popup from within the flyout - const openPopupButton = await app.findElementByXPath( - '//Button[@Name="Open A Popup"]', - ); - await openPopupButton.waitForDisplayed({timeout: 5000}); - await openPopupButton.click(); - - // Wait for popup to appear and capture state - // Note: Popup testID might need to be determined from the actual implementation - const dump = await dumpVisualTree('flyout-accessibility'); - expect(dump).toMatchSnapshot(); - - // Close the popup and flyout - const mainContainer = await app.findElementByTestID('flyout'); - await mainContainer.click(); - }); -});