diff --git a/packages/react-native/Libraries/Pressability/Pressability.js b/packages/react-native/Libraries/Pressability/Pressability.js index ff70d67148f..eabfb8320fe 100644 --- a/packages/react-native/Libraries/Pressability/Pressability.js +++ b/packages/react-native/Libraries/Pressability/Pressability.js @@ -16,8 +16,8 @@ import type { MouseEvent, } from '../Types/CoreEventTypes'; +import * as ReactNativeFeatureFlags from '../../src/private/featureflags/ReactNativeFeatureFlags'; import SoundManager from '../Components/Sound/SoundManager'; -import ReactNativeFeatureFlags from '../ReactNative/ReactNativeFeatureFlags'; import UIManager from '../ReactNative/UIManager'; import {type RectOrSize, normalizeRect} from '../StyleSheet/Rect'; import {type PointerEvent} from '../Types/CoreEventTypes'; diff --git a/packages/react-native/Libraries/ReactNative/ReactNativeFeatureFlags.js b/packages/react-native/Libraries/ReactNative/ReactNativeFeatureFlags.js deleted file mode 100644 index e14f21fb3ae..00000000000 --- a/packages/react-native/Libraries/ReactNative/ReactNativeFeatureFlags.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @flow strict - * @format - */ - -export type FeatureFlags = { - /** - * Function used to enable / disable W3C pointer event emitting in React Native. - * If enabled you must also flip the equivalent native flags on each platform: - * iOS -> RCTSetDispatchW3CPointerEvents - * Android -> ReactFeatureFlags.dispatchPointerEvents - */ - shouldEmitW3CPointerEvents: () => boolean, - /** - * Function used to enable / disable Pressibility from using W3C Pointer Events - * for its hover callbacks - */ - shouldPressibilityUseW3CPointerEventsForHover: () => boolean, -}; - -const ReactNativeFeatureFlags: FeatureFlags = { - shouldEmitW3CPointerEvents: () => false, - shouldPressibilityUseW3CPointerEventsForHover: () => false, -}; - -export default ReactNativeFeatureFlags; diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt index 9e0ffd62f78..1a6f0187938 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<6f50c9b7a356260abf8afc022aba8fc2>> + * @generated SignedSource<> */ /** @@ -324,6 +324,12 @@ public object ReactNativeFeatureFlags { @JvmStatic public fun releaseImageDataWhenConsumed(): Boolean = accessor.releaseImageDataWhenConsumed() + /** + * Function used to enable / disable Pressibility from using W3C Pointer Events for its hover callbacks + */ + @JvmStatic + public fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean = accessor.shouldPressibilityUseW3CPointerEventsForHover() + /** * Skip activity identity assertion in ReactHostImpl::onHostPause() */ diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt index 3ff17fcde0e..cc975edc0b3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> */ /** @@ -69,6 +69,7 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces private var preparedTextCacheSizeCache: Double? = null private var preventShadowTreeCommitExhaustionWithLockingCache: Boolean? = null private var releaseImageDataWhenConsumedCache: Boolean? = null + private var shouldPressibilityUseW3CPointerEventsForHoverCache: Boolean? = null private var skipActivityIdentityAssertionOnHostPauseCache: Boolean? = null private var traceTurboModulePromiseRejectionsOnAndroidCache: Boolean? = null private var updateRuntimeShadowNodeReferencesOnCommitCache: Boolean? = null @@ -525,6 +526,15 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces return cached } + override fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean { + var cached = shouldPressibilityUseW3CPointerEventsForHoverCache + if (cached == null) { + cached = ReactNativeFeatureFlagsCxxInterop.shouldPressibilityUseW3CPointerEventsForHover() + shouldPressibilityUseW3CPointerEventsForHoverCache = cached + } + return cached + } + override fun skipActivityIdentityAssertionOnHostPause(): Boolean { var cached = skipActivityIdentityAssertionOnHostPauseCache if (cached == null) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt index 33f68663097..ed513c683b3 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> */ /** @@ -126,6 +126,8 @@ public object ReactNativeFeatureFlagsCxxInterop { @DoNotStrip @JvmStatic public external fun releaseImageDataWhenConsumed(): Boolean + @DoNotStrip @JvmStatic public external fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean + @DoNotStrip @JvmStatic public external fun skipActivityIdentityAssertionOnHostPause(): Boolean @DoNotStrip @JvmStatic public external fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt index 703cb465e3c..b9a5997726d 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<<1c1ae67a283926bd5da1c5ddad875810>> */ /** @@ -121,6 +121,8 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi override fun releaseImageDataWhenConsumed(): Boolean = false + override fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean = false + override fun skipActivityIdentityAssertionOnHostPause(): Boolean = false override fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean = false diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt index f5988c97a2d..0d23b458104 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<1c4bee4de12fc3e38a09f2ddf9b39601>> + * @generated SignedSource<<4c1cfcf144eb98e871358413340a7651>> */ /** @@ -73,6 +73,7 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc private var preparedTextCacheSizeCache: Double? = null private var preventShadowTreeCommitExhaustionWithLockingCache: Boolean? = null private var releaseImageDataWhenConsumedCache: Boolean? = null + private var shouldPressibilityUseW3CPointerEventsForHoverCache: Boolean? = null private var skipActivityIdentityAssertionOnHostPauseCache: Boolean? = null private var traceTurboModulePromiseRejectionsOnAndroidCache: Boolean? = null private var updateRuntimeShadowNodeReferencesOnCommitCache: Boolean? = null @@ -578,6 +579,16 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc return cached } + override fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean { + var cached = shouldPressibilityUseW3CPointerEventsForHoverCache + if (cached == null) { + cached = currentProvider.shouldPressibilityUseW3CPointerEventsForHover() + accessedFeatureFlags.add("shouldPressibilityUseW3CPointerEventsForHover") + shouldPressibilityUseW3CPointerEventsForHoverCache = cached + } + return cached + } + override fun skipActivityIdentityAssertionOnHostPause(): Boolean { var cached = skipActivityIdentityAssertionOnHostPauseCache if (cached == null) { diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt index 384df25636d..427e80d8fdd 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<366629baac4727e7db4042a8e9dcab93>> + * @generated SignedSource<<02df7850c3578fb7d033038e517e7cef>> */ /** @@ -121,6 +121,8 @@ public interface ReactNativeFeatureFlagsProvider { @DoNotStrip public fun releaseImageDataWhenConsumed(): Boolean + @DoNotStrip public fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean + @DoNotStrip public fun skipActivityIdentityAssertionOnHostPause(): Boolean @DoNotStrip public fun traceTurboModulePromiseRejectionsOnAndroid(): Boolean diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp index a351bad8a80..e6cd6c0f712 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<1ec5b2dea32e6f318622cb24a9d66ef2>> + * @generated SignedSource<> */ /** @@ -333,6 +333,12 @@ class ReactNativeFeatureFlagsJavaProvider return method(javaProvider_); } + bool shouldPressibilityUseW3CPointerEventsForHover() override { + static const auto method = + getReactNativeFeatureFlagsProviderJavaClass()->getMethod("shouldPressibilityUseW3CPointerEventsForHover"); + return method(javaProvider_); + } + bool skipActivityIdentityAssertionOnHostPause() override { static const auto method = getReactNativeFeatureFlagsProviderJavaClass()->getMethod("skipActivityIdentityAssertionOnHostPause"); @@ -666,6 +672,11 @@ bool JReactNativeFeatureFlagsCxxInterop::releaseImageDataWhenConsumed( return ReactNativeFeatureFlags::releaseImageDataWhenConsumed(); } +bool JReactNativeFeatureFlagsCxxInterop::shouldPressibilityUseW3CPointerEventsForHover( + facebook::jni::alias_ref /*unused*/) { + return ReactNativeFeatureFlags::shouldPressibilityUseW3CPointerEventsForHover(); +} + bool JReactNativeFeatureFlagsCxxInterop::skipActivityIdentityAssertionOnHostPause( facebook::jni::alias_ref /*unused*/) { return ReactNativeFeatureFlags::skipActivityIdentityAssertionOnHostPause(); @@ -914,6 +925,9 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() { makeNativeMethod( "releaseImageDataWhenConsumed", JReactNativeFeatureFlagsCxxInterop::releaseImageDataWhenConsumed), + makeNativeMethod( + "shouldPressibilityUseW3CPointerEventsForHover", + JReactNativeFeatureFlagsCxxInterop::shouldPressibilityUseW3CPointerEventsForHover), makeNativeMethod( "skipActivityIdentityAssertionOnHostPause", JReactNativeFeatureFlagsCxxInterop::skipActivityIdentityAssertionOnHostPause), diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h index b968373609b..375b24b1d8b 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<3570d50c3ff20d976b7145c0c36fd6ac>> + * @generated SignedSource<<956c5e2083b578aea5289299939d2e5c>> */ /** @@ -177,6 +177,9 @@ class JReactNativeFeatureFlagsCxxInterop static bool releaseImageDataWhenConsumed( facebook::jni::alias_ref); + static bool shouldPressibilityUseW3CPointerEventsForHover( + facebook::jni::alias_ref); + static bool skipActivityIdentityAssertionOnHostPause( facebook::jni::alias_ref); diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp index 8937569d5cd..6d178508c60 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<1c8a4501d6e0d7d0b162283cbbdf6a87>> + * @generated SignedSource<<9aa9bee329a282a5acffebdd0fe10aff>> */ /** @@ -222,6 +222,10 @@ bool ReactNativeFeatureFlags::releaseImageDataWhenConsumed() { return getAccessor().releaseImageDataWhenConsumed(); } +bool ReactNativeFeatureFlags::shouldPressibilityUseW3CPointerEventsForHover() { + return getAccessor().shouldPressibilityUseW3CPointerEventsForHover(); +} + bool ReactNativeFeatureFlags::skipActivityIdentityAssertionOnHostPause() { return getAccessor().skipActivityIdentityAssertionOnHostPause(); } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h index a9971efd724..585ca7c01a2 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<3edca00b84d9b4d30c7d9bf5a8dee039>> + * @generated SignedSource<> */ /** @@ -284,6 +284,11 @@ class ReactNativeFeatureFlags { */ RN_EXPORT static bool releaseImageDataWhenConsumed(); + /** + * Function used to enable / disable Pressibility from using W3C Pointer Events for its hover callbacks + */ + RN_EXPORT static bool shouldPressibilityUseW3CPointerEventsForHover(); + /** * Skip activity identity assertion in ReactHostImpl::onHostPause() */ diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp index ffa261884ea..5b2fba14e88 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<5149f256e2692114e5d4b4efb839589a>> + * @generated SignedSource<<9b38f912e401b970753bf59ce58601e7>> */ /** @@ -911,6 +911,24 @@ bool ReactNativeFeatureFlagsAccessor::releaseImageDataWhenConsumed() { return flagValue.value(); } +bool ReactNativeFeatureFlagsAccessor::shouldPressibilityUseW3CPointerEventsForHover() { + auto flagValue = shouldPressibilityUseW3CPointerEventsForHover_.load(); + + if (!flagValue.has_value()) { + // This block is not exclusive but it is not necessary. + // If multiple threads try to initialize the feature flag, we would only + // be accessing the provider multiple times but the end state of this + // instance and the returned flag value would be the same. + + markFlagAsAccessed(49, "shouldPressibilityUseW3CPointerEventsForHover"); + + flagValue = currentProvider_->shouldPressibilityUseW3CPointerEventsForHover(); + shouldPressibilityUseW3CPointerEventsForHover_ = flagValue; + } + + return flagValue.value(); +} + bool ReactNativeFeatureFlagsAccessor::skipActivityIdentityAssertionOnHostPause() { auto flagValue = skipActivityIdentityAssertionOnHostPause_.load(); @@ -920,7 +938,7 @@ bool ReactNativeFeatureFlagsAccessor::skipActivityIdentityAssertionOnHostPause() // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(49, "skipActivityIdentityAssertionOnHostPause"); + markFlagAsAccessed(50, "skipActivityIdentityAssertionOnHostPause"); flagValue = currentProvider_->skipActivityIdentityAssertionOnHostPause(); skipActivityIdentityAssertionOnHostPause_ = flagValue; @@ -938,7 +956,7 @@ bool ReactNativeFeatureFlagsAccessor::traceTurboModulePromiseRejectionsOnAndroid // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(50, "traceTurboModulePromiseRejectionsOnAndroid"); + markFlagAsAccessed(51, "traceTurboModulePromiseRejectionsOnAndroid"); flagValue = currentProvider_->traceTurboModulePromiseRejectionsOnAndroid(); traceTurboModulePromiseRejectionsOnAndroid_ = flagValue; @@ -956,7 +974,7 @@ bool ReactNativeFeatureFlagsAccessor::updateRuntimeShadowNodeReferencesOnCommit( // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(51, "updateRuntimeShadowNodeReferencesOnCommit"); + markFlagAsAccessed(52, "updateRuntimeShadowNodeReferencesOnCommit"); flagValue = currentProvider_->updateRuntimeShadowNodeReferencesOnCommit(); updateRuntimeShadowNodeReferencesOnCommit_ = flagValue; @@ -974,7 +992,7 @@ bool ReactNativeFeatureFlagsAccessor::useAlwaysAvailableJSErrorHandling() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(52, "useAlwaysAvailableJSErrorHandling"); + markFlagAsAccessed(53, "useAlwaysAvailableJSErrorHandling"); flagValue = currentProvider_->useAlwaysAvailableJSErrorHandling(); useAlwaysAvailableJSErrorHandling_ = flagValue; @@ -992,7 +1010,7 @@ bool ReactNativeFeatureFlagsAccessor::useFabricInterop() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(53, "useFabricInterop"); + markFlagAsAccessed(54, "useFabricInterop"); flagValue = currentProvider_->useFabricInterop(); useFabricInterop_ = flagValue; @@ -1010,7 +1028,7 @@ bool ReactNativeFeatureFlagsAccessor::useNativeEqualsInNativeReadableArrayAndroi // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(54, "useNativeEqualsInNativeReadableArrayAndroid"); + markFlagAsAccessed(55, "useNativeEqualsInNativeReadableArrayAndroid"); flagValue = currentProvider_->useNativeEqualsInNativeReadableArrayAndroid(); useNativeEqualsInNativeReadableArrayAndroid_ = flagValue; @@ -1028,7 +1046,7 @@ bool ReactNativeFeatureFlagsAccessor::useNativeTransformHelperAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(55, "useNativeTransformHelperAndroid"); + markFlagAsAccessed(56, "useNativeTransformHelperAndroid"); flagValue = currentProvider_->useNativeTransformHelperAndroid(); useNativeTransformHelperAndroid_ = flagValue; @@ -1046,7 +1064,7 @@ bool ReactNativeFeatureFlagsAccessor::useNativeViewConfigsInBridgelessMode() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(56, "useNativeViewConfigsInBridgelessMode"); + markFlagAsAccessed(57, "useNativeViewConfigsInBridgelessMode"); flagValue = currentProvider_->useNativeViewConfigsInBridgelessMode(); useNativeViewConfigsInBridgelessMode_ = flagValue; @@ -1064,7 +1082,7 @@ bool ReactNativeFeatureFlagsAccessor::useOptimizedEventBatchingOnAndroid() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(57, "useOptimizedEventBatchingOnAndroid"); + markFlagAsAccessed(58, "useOptimizedEventBatchingOnAndroid"); flagValue = currentProvider_->useOptimizedEventBatchingOnAndroid(); useOptimizedEventBatchingOnAndroid_ = flagValue; @@ -1082,7 +1100,7 @@ bool ReactNativeFeatureFlagsAccessor::useRawPropsJsiValue() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(58, "useRawPropsJsiValue"); + markFlagAsAccessed(59, "useRawPropsJsiValue"); flagValue = currentProvider_->useRawPropsJsiValue(); useRawPropsJsiValue_ = flagValue; @@ -1100,7 +1118,7 @@ bool ReactNativeFeatureFlagsAccessor::useShadowNodeStateOnClone() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(59, "useShadowNodeStateOnClone"); + markFlagAsAccessed(60, "useShadowNodeStateOnClone"); flagValue = currentProvider_->useShadowNodeStateOnClone(); useShadowNodeStateOnClone_ = flagValue; @@ -1118,7 +1136,7 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModuleInterop() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(60, "useTurboModuleInterop"); + markFlagAsAccessed(61, "useTurboModuleInterop"); flagValue = currentProvider_->useTurboModuleInterop(); useTurboModuleInterop_ = flagValue; @@ -1136,7 +1154,7 @@ bool ReactNativeFeatureFlagsAccessor::useTurboModules() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(61, "useTurboModules"); + markFlagAsAccessed(62, "useTurboModules"); flagValue = currentProvider_->useTurboModules(); useTurboModules_ = flagValue; @@ -1154,7 +1172,7 @@ double ReactNativeFeatureFlagsAccessor::virtualViewPrerenderRatio() { // be accessing the provider multiple times but the end state of this // instance and the returned flag value would be the same. - markFlagAsAccessed(62, "virtualViewPrerenderRatio"); + markFlagAsAccessed(63, "virtualViewPrerenderRatio"); flagValue = currentProvider_->virtualViewPrerenderRatio(); virtualViewPrerenderRatio_ = flagValue; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h index fe7ab05d3a5..a02018a4cc5 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> */ /** @@ -81,6 +81,7 @@ class ReactNativeFeatureFlagsAccessor { double preparedTextCacheSize(); bool preventShadowTreeCommitExhaustionWithLocking(); bool releaseImageDataWhenConsumed(); + bool shouldPressibilityUseW3CPointerEventsForHover(); bool skipActivityIdentityAssertionOnHostPause(); bool traceTurboModulePromiseRejectionsOnAndroid(); bool updateRuntimeShadowNodeReferencesOnCommit(); @@ -106,7 +107,7 @@ class ReactNativeFeatureFlagsAccessor { std::unique_ptr currentProvider_; bool wasOverridden_; - std::array, 63> accessedFeatureFlags_; + std::array, 64> accessedFeatureFlags_; std::atomic> commonTestFlag_; std::atomic> cxxNativeAnimatedEnabled_; @@ -157,6 +158,7 @@ class ReactNativeFeatureFlagsAccessor { std::atomic> preparedTextCacheSize_; std::atomic> preventShadowTreeCommitExhaustionWithLocking_; std::atomic> releaseImageDataWhenConsumed_; + std::atomic> shouldPressibilityUseW3CPointerEventsForHover_; std::atomic> skipActivityIdentityAssertionOnHostPause_; std::atomic> traceTurboModulePromiseRejectionsOnAndroid_; std::atomic> updateRuntimeShadowNodeReferencesOnCommit_; diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h index e2973572ac5..95862038d00 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> */ /** @@ -223,6 +223,10 @@ class ReactNativeFeatureFlagsDefaults : public ReactNativeFeatureFlagsProvider { return false; } + bool shouldPressibilityUseW3CPointerEventsForHover() override { + return false; + } + bool skipActivityIdentityAssertionOnHostPause() override { return false; } diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h index 380f54028c9..d046cb85370 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<44670421b1b5991cd6af3fb7b1c1bf6c>> + * @generated SignedSource<<04e32e131f4bd461a5fc19a3249f6068>> */ /** @@ -486,6 +486,15 @@ class ReactNativeFeatureFlagsDynamicProvider : public ReactNativeFeatureFlagsDef return ReactNativeFeatureFlagsDefaults::releaseImageDataWhenConsumed(); } + bool shouldPressibilityUseW3CPointerEventsForHover() override { + auto value = values_["shouldPressibilityUseW3CPointerEventsForHover"]; + if (!value.isNull()) { + return value.getBool(); + } + + return ReactNativeFeatureFlagsDefaults::shouldPressibilityUseW3CPointerEventsForHover(); + } + bool skipActivityIdentityAssertionOnHostPause() override { auto value = values_["skipActivityIdentityAssertionOnHostPause"]; if (!value.isNull()) { diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h index 4d4c3145294..dfb20a4ef3f 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<082c6d17eec877d054193eb9dea45b6d>> + * @generated SignedSource<<77b10024ee8f8d4494641f98d06e3086>> */ /** @@ -74,6 +74,7 @@ class ReactNativeFeatureFlagsProvider { virtual double preparedTextCacheSize() = 0; virtual bool preventShadowTreeCommitExhaustionWithLocking() = 0; virtual bool releaseImageDataWhenConsumed() = 0; + virtual bool shouldPressibilityUseW3CPointerEventsForHover() = 0; virtual bool skipActivityIdentityAssertionOnHostPause() = 0; virtual bool traceTurboModulePromiseRejectionsOnAndroid() = 0; virtual bool updateRuntimeShadowNodeReferencesOnCommit() = 0; diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp index 3a9c53d7e08..dff40a271fe 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<5b33805daf165bd61f382354685d1d70>> + * @generated SignedSource<> */ /** @@ -289,6 +289,11 @@ bool NativeReactNativeFeatureFlags::releaseImageDataWhenConsumed( return ReactNativeFeatureFlags::releaseImageDataWhenConsumed(); } +bool NativeReactNativeFeatureFlags::shouldPressibilityUseW3CPointerEventsForHover( + jsi::Runtime& /*runtime*/) { + return ReactNativeFeatureFlags::shouldPressibilityUseW3CPointerEventsForHover(); +} + bool NativeReactNativeFeatureFlags::skipActivityIdentityAssertionOnHostPause( jsi::Runtime& /*runtime*/) { return ReactNativeFeatureFlags::skipActivityIdentityAssertionOnHostPause(); diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h index 30b46c17d31..8b3d568ff2d 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h +++ b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<3487c7ee26cfd5776c85dcf6a6e7fc10>> + * @generated SignedSource<<6bd1e1fcaff90a5588716ac2d65257e0>> */ /** @@ -134,6 +134,8 @@ class NativeReactNativeFeatureFlags bool releaseImageDataWhenConsumed(jsi::Runtime& runtime); + bool shouldPressibilityUseW3CPointerEventsForHover(jsi::Runtime& runtime); + bool skipActivityIdentityAssertionOnHostPause(jsi::Runtime& runtime); bool traceTurboModulePromiseRejectionsOnAndroid(jsi::Runtime& runtime); diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js index 19211078798..674d3bed414 100644 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -569,6 +569,16 @@ const definitions: FeatureFlagDefinitions = { }, ossReleaseStage: 'none', }, + shouldPressibilityUseW3CPointerEventsForHover: { + defaultValue: false, + metadata: { + description: + 'Function used to enable / disable Pressibility from using W3C Pointer Events for its hover callbacks', + expectedReleaseValue: true, + purpose: 'release', + }, + ossReleaseStage: 'none', + }, skipActivityIdentityAssertionOnHostPause: { defaultValue: false, metadata: { diff --git a/packages/react-native/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js b/packages/react-native/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js index 8c5bd2b2439..e2b00f93565 100644 --- a/packages/react-native/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js +++ b/packages/react-native/src/private/devsupport/devmenu/elementinspector/ReactDevToolsOverlay.js @@ -15,8 +15,8 @@ import type {ReactDevToolsAgent} from '../../../../../Libraries/Types/ReactDevTo import type {InspectedElement} from './Inspector'; import View from '../../../../../Libraries/Components/View/View'; -import ReactNativeFeatureFlags from '../../../../../Libraries/ReactNative/ReactNativeFeatureFlags'; import StyleSheet from '../../../../../Libraries/StyleSheet/StyleSheet'; +import * as ReactNativeFeatureFlags from '../../../../../src/private/featureflags/ReactNativeFeatureFlags'; import ElementBox from './ElementBox'; import * as React from 'react'; @@ -129,7 +129,7 @@ export default function ReactDevToolsOverlay({ if (isInspecting) { const events = // Pointer events only work on fabric - ReactNativeFeatureFlags.shouldEmitW3CPointerEvents() + ReactNativeFeatureFlags.shouldPressibilityUseW3CPointerEventsForHover() ? { onPointerMove, onPointerDown: onPointerMove, diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index 0aa34258fe7..29b421818f7 100644 --- a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js +++ b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<> + * @generated SignedSource<> * @flow strict * @noformat */ @@ -95,6 +95,7 @@ export type ReactNativeFeatureFlags = $ReadOnly<{ preparedTextCacheSize: Getter, preventShadowTreeCommitExhaustionWithLocking: Getter, releaseImageDataWhenConsumed: Getter, + shouldPressibilityUseW3CPointerEventsForHover: Getter, skipActivityIdentityAssertionOnHostPause: Getter, traceTurboModulePromiseRejectionsOnAndroid: Getter, updateRuntimeShadowNodeReferencesOnCommit: Getter, @@ -366,6 +367,10 @@ export const preventShadowTreeCommitExhaustionWithLocking: Getter = cre * Releases the cached image data when it is consumed by the observers. */ export const releaseImageDataWhenConsumed: Getter = createNativeFlagGetter('releaseImageDataWhenConsumed', false); +/** + * Function used to enable / disable Pressibility from using W3C Pointer Events for its hover callbacks + */ +export const shouldPressibilityUseW3CPointerEventsForHover: Getter = createNativeFlagGetter('shouldPressibilityUseW3CPointerEventsForHover', false); /** * Skip activity identity assertion in ReactHostImpl::onHostPause() */ diff --git a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js index 58c71c9562a..c5d637b1474 100644 --- a/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +++ b/packages/react-native/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js @@ -4,7 +4,7 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<8051b5c10479f9ad92faad99586578d9>> + * @generated SignedSource<<9a2b156d961a4da075b6a8b318252cf3>> * @flow strict * @noformat */ @@ -74,6 +74,7 @@ export interface Spec extends TurboModule { +preparedTextCacheSize?: () => number; +preventShadowTreeCommitExhaustionWithLocking?: () => boolean; +releaseImageDataWhenConsumed?: () => boolean; + +shouldPressibilityUseW3CPointerEventsForHover?: () => boolean; +skipActivityIdentityAssertionOnHostPause?: () => boolean; +traceTurboModulePromiseRejectionsOnAndroid?: () => boolean; +updateRuntimeShadowNodeReferencesOnCommit?: () => boolean; diff --git a/packages/rn-tester/js/examples/Pressable/PressableExample.js b/packages/rn-tester/js/examples/Pressable/PressableExample.js index f9b60c11f76..b385cf275f3 100644 --- a/packages/rn-tester/js/examples/Pressable/PressableExample.js +++ b/packages/rn-tester/js/examples/Pressable/PressableExample.js @@ -10,6 +10,7 @@ import type {RNTesterModule} from '../../types/RNTesterTypes'; +import * as PressableExampleFbInternal from './PressableExampleFbInternal'; import * as React from 'react'; import { Alert, @@ -21,7 +22,6 @@ import { Text, View, } from 'react-native'; -import ReactNativeFeatureFlags from 'react-native/Libraries/ReactNative/ReactNativeFeatureFlags'; const {useEffect, useRef, useState} = React; @@ -274,25 +274,6 @@ function PressableDisabled() { ); } -function PressableHoverStyle() { - const [hovered, setHovered] = useState(false); - return ( - - setHovered(true)} - onHoverOut={() => setHovered(false)}> - Hover Me - - - ); -} - const styles = StyleSheet.create({ row: { justifyContent: 'center', @@ -587,17 +568,9 @@ const examples = [ return ; }, }, + ...PressableExampleFbInternal.examples, ]; -if (ReactNativeFeatureFlags.shouldPressibilityUseW3CPointerEventsForHover()) { - examples.push({ - title: 'Change style based on Hover', - render(): React.Node { - return ; - }, - }); -} - module.exports = ({ title: 'Pressable', documentationURL: 'https://reactnative.dev/docs/pressable', diff --git a/packages/rn-tester/js/examples/Pressable/PressableExampleFbInternal.js b/packages/rn-tester/js/examples/Pressable/PressableExampleFbInternal.js new file mode 100644 index 00000000000..aa09fc9aa70 --- /dev/null +++ b/packages/rn-tester/js/examples/Pressable/PressableExampleFbInternal.js @@ -0,0 +1,12 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +// $FlowFixMe +export const examples: Array = []; diff --git a/packages/rn-tester/js/utils/RNTesterList.android.js b/packages/rn-tester/js/utils/RNTesterList.android.js index 68efd3341d2..a91d9309c9d 100644 --- a/packages/rn-tester/js/utils/RNTesterList.android.js +++ b/packages/rn-tester/js/utils/RNTesterList.android.js @@ -13,7 +13,6 @@ import type {RNTesterModule, RNTesterModuleInfo} from '../types/RNTesterTypes'; import * as RNTesterListFbInternal from './RNTesterListFbInternal'; -import ReactNativeFeatureFlags from 'react-native/Libraries/ReactNative/ReactNativeFeatureFlags'; const Components: Array = [ { @@ -367,14 +366,6 @@ const APIs: Array = ([ ...RNTesterListFbInternal.APIs, ]: Array).filter(Boolean); -if (ReactNativeFeatureFlags.shouldEmitW3CPointerEvents()) { - APIs.push({ - key: 'W3C PointerEvents', - category: 'Experimental', - module: require('../examples/Experimental/W3CPointerEventsExample').default, - }); -} - const Playgrounds: Array = [ { key: 'PlaygroundExample', diff --git a/packages/rn-tester/js/utils/RNTesterList.ios.js b/packages/rn-tester/js/utils/RNTesterList.ios.js index e85d056acdc..a84724ee89b 100644 --- a/packages/rn-tester/js/utils/RNTesterList.ios.js +++ b/packages/rn-tester/js/utils/RNTesterList.ios.js @@ -11,7 +11,6 @@ import type {RNTesterModule, RNTesterModuleInfo} from '../types/RNTesterTypes'; import * as RNTesterListFbInternal from './RNTesterListFbInternal'; -import ReactNativeFeatureFlags from 'react-native/Libraries/ReactNative/ReactNativeFeatureFlags'; const Components: Array = [ { @@ -341,14 +340,6 @@ const APIs: Array = ([ ...RNTesterListFbInternal.APIs, ]: Array).filter(Boolean); -if (ReactNativeFeatureFlags.shouldEmitW3CPointerEvents()) { - APIs.push({ - key: 'W3C PointerEvents', - category: 'Experimental', - module: require('../examples/Experimental/W3CPointerEventsExample').default, - }); -} - const Playgrounds: Array = [ { key: 'PlaygroundExample',