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 8c356cb7eec..fed18a18fc7 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,14 +4,14 @@ * 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<> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update 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 ca5c8ff1d07..65c786512eb 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,14 +4,14 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<5b653e8a53f557ffc0f46b3e81e99bed>> + * @generated SignedSource<> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update 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 f90ae279e35..83deb2d4a17 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,14 +4,14 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<47be3dbe5558f720a6c61742f2c63bf8>> + * @generated SignedSource<<41a2646126f7f448be8c8397b1698a4a>> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update 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 cbb9dcdabe8..ab793abe3fa 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,14 +4,14 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<70c19d5bb1e0c09f52b89b4bb3645b9d>> + * @generated SignedSource<> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update 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 15639b90d14..0db66793923 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,14 +4,14 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<7ba0cb94c10989838250252fa06768a0>> + * @generated SignedSource<<77fc4d6577fc0e2e9a0500cc762bba77>> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update 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 8b477054ea8..7d64ca81414 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,14 +4,14 @@ * 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<<49a63388fa661d81b9cec735ac705bd0>> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update 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 7419a24d36d..1bb1d5bbe40 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,14 +4,14 @@ * 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<> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update 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 b03aba4b813..11976df07f6 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,14 +4,14 @@ * 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<<356873b4021fcfe9a2afa79417813975>> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/ReactNativeFeatureFlagsProviderHolder.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/ReactNativeFeatureFlagsProviderHolder.cpp index eac87db03ee..9c4b817235c 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/ReactNativeFeatureFlagsProviderHolder.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/ReactNativeFeatureFlagsProviderHolder.cpp @@ -4,14 +4,14 @@ * 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<<40972962362d704915fe7c851ef6a545>> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/ReactNativeFeatureFlagsProviderHolder.h b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/ReactNativeFeatureFlagsProviderHolder.h index 2f01f8ad159..71d23314521 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/ReactNativeFeatureFlagsProviderHolder.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/featureflags/ReactNativeFeatureFlagsProviderHolder.h @@ -4,14 +4,14 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<879b0c096c4a2e9692a5e133bdfd8809>> + * @generated SignedSource<> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp index 9d4b4c50bb0..981a5dfe54e 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp @@ -4,14 +4,14 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<6ccf42209dea35cd5c6ac9eb882c2ef7>> + * @generated SignedSource<> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h index af9c3fa5270..f823ef82f3d 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h @@ -4,14 +4,14 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<252f46e2c95e08d1180f656c870087b7>> + * @generated SignedSource<> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp index 03026dd293c..7dbeca63453 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp @@ -4,14 +4,14 @@ * 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<<0f2ef778c97b1928fde0245008015227>> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h index 546e6fbbdb0..6d6474bec1d 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h @@ -4,14 +4,14 @@ * 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<<4de1ed8503548f440c1a0e4f903c80c7>> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h index 28f5b0d55bd..5b3d4090752 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h @@ -4,14 +4,14 @@ * 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<> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update diff --git a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h index 7a252cfa02f..cc0eede94bd 100644 --- a/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h +++ b/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h @@ -4,14 +4,14 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<72abac7cc75e65bf1ded596033637050>> + * @generated SignedSource<> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp index 2a381896ace..49350b33e85 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp @@ -4,14 +4,14 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<64ea070fb82bd703eb617dcf64c6a7d1>> + * @generated SignedSource<<19dba0cacd4599408a2adeeeb1dce6f2>> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update diff --git a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h index 9a419a94a24..bdacf6ffd26 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h +++ b/packages/react-native/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h @@ -4,14 +4,14 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @generated SignedSource<<994628655312f57c8ab774e9f119eb18>> + * @generated SignedSource<<4ce1b29660d13ea8dfe09777d9907f3f>> */ /** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update diff --git a/packages/react-native/scripts/featureflags/README.md b/packages/react-native/scripts/featureflags/README.md index a011dc85442..7cb68fec081 100644 --- a/packages/react-native/scripts/featureflags/README.md +++ b/packages/react-native/scripts/featureflags/README.md @@ -11,39 +11,25 @@ everywhere. ## Definition -The source of truth for the definition of the flags is the file `ReactNativeFeatureFlags.json` -in this directory. That JSON file should have the following structure: +The source of truth for the definition of the flags is the file +`ReactNativeFeatureFlags.config.js` in this directory. -```flow -type Config = { - common: FeatureFlagsList, - jsOnly: FeatureFlagsList, -}; - -type FeatureFlagsList = { - [flagName: string]: { - description: string, - defaultValue: boolean | number | string, - }, -}; -``` - -Example: -```json -{ - "common": { - "enableMicrotasks": { - "description": "Enable the use of microtasks in the JS runtime.", - "defaultValue": false +Example contents: +```javascript +module.exports = { + common: { + enableMicrotasks: { + description: 'Enable the use of microtasks in the JS runtime.', + defaultValue: false } }, - "jsOnly": { - "enableAccessToHostTreeInFabric": { - "description": "Enables access to the host tree in Fabric using DOM-compatible APIs.", - "defaultValue": false + jsOnly: { + enableAccessToHostTreeInFabric: { + description: 'Enables access to the host tree in Fabric using DOM-compatible APIs.', + defaultValue: false } } -} +}; ``` After any changes to this definitions, the code that provides access to them @@ -52,6 +38,16 @@ repository. ## Access +You can access the common feature flags from anywhere in your application using +the `ReactNativeFeatureFlags` interface (available in C++/Objective-C++, +Kotlin/Java and JavaScript). JS-only feature flags can only be accessed from +JavaScript. + +**Accessing feature flags should be considered fast for all use cases**. +Feature flags are cached at every layer, which prevents having to go through JNI +when accessing the values from Kotlin and through JSI when accessing the values +from JavaScript. + ### C++ / Objective-C ```c++ @@ -90,6 +86,15 @@ if (ReactNativeFeatureFlags.enableAccessToHostTreeInFabric()) { ## Customization +Feature flags provide the default values defined in the configuration unless +overrides are applied at the application level. Overrides for common feature +flags can only be defined in native, while overrides for JS-ony flags can only +be defined in JavaScript. + +Overrides must be applied before any of the available feature flags has been +accessed. This prevents having inconsistent behavior during the lifecycle of the +application. + ### C++/Objective-C ```c++ diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js new file mode 100644 index 00000000000..ab2874123dc --- /dev/null +++ b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js @@ -0,0 +1,97 @@ +/** + * 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 + */ + +import type {FeatureFlagDefinitions} from './types'; + +const definitions: FeatureFlagDefinitions = { + common: { + // This is only used in unit tests for the feature flags system. + commonTestFlag: { + description: 'Common flag for testing. Do NOT modify.', + defaultValue: false, + }, + + useModernRuntimeScheduler: { + description: + 'When enabled, it uses the modern fork of RuntimeScheduler that allows scheduling tasks with priorities from any thread.', + defaultValue: false, + }, + enableMicrotasks: { + description: + 'Enables the use of microtasks in Hermes (scheduling) and RuntimeScheduler (execution).', + defaultValue: false, + }, + batchRenderingUpdatesInEventLoop: { + description: + 'When enabled, the RuntimeScheduler processing the event loop will batch all rendering updates and dispatch them together at the end of each iteration of the loop.', + defaultValue: false, + }, + enableSpannableBuildingUnification: { + description: + 'Uses new, deduplicated logic for constructing Android Spannables from text fragments', + defaultValue: false, + }, + enableCustomDrawOrderFabric: { + description: + 'When enabled, Fabric will use customDrawOrder in ReactViewGroup (similar to old architecture).', + defaultValue: false, + }, + enableFixForClippedSubviewsCrash: { + description: + 'Attempt at fixing a crash related to subview clipping on Android. This is a kill switch for the fix', + defaultValue: false, + }, + }, + + jsOnly: { + // This is only used in unit tests for the feature flags system. + jsOnlyTestFlag: { + description: 'JS-only flag for testing. Do NOT modify.', + defaultValue: false, + }, + + isLayoutAnimationEnabled: { + description: + 'Function used to enable / disabled Layout Animations in React Native.', + defaultValue: true, + }, + animatedShouldDebounceQueueFlush: { + description: + 'Enables an experimental flush-queue debouncing in Animated.js.', + defaultValue: false, + }, + animatedShouldUseSingleOp: { + description: + 'Enables an experimental mega-operation for Animated.js that replaces many calls to native with a single call into native, to reduce JSI/JNI traffic.', + defaultValue: false, + }, + enableAccessToHostTreeInFabric: { + description: + 'Enables access to the host tree in Fabric using DOM-compatible APIs.', + defaultValue: false, + }, + shouldUseAnimatedObjectForTransform: { + description: + 'Enables use of AnimatedObject for animating transform values.', + defaultValue: false, + }, + shouldUseSetNativePropsInFabric: { + description: 'Enables use of setNativeProps in JS driven animations.', + defaultValue: true, + }, + shouldUseRemoveClippedSubviewsAsDefaultOnIOS: { + description: + 'removeClippedSubviews prop will be used as the default in FlatList on iOS to match Android', + defaultValue: false, + }, + }, +}; + +export default definitions; diff --git a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json b/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json deleted file mode 100644 index 95a4df931b4..00000000000 --- a/packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "common": { - "commonTestFlag": { - "description": "Common flag for testing. Do NOT modify.", - "defaultValue": false - }, - "useModernRuntimeScheduler": { - "description": "When enabled, it uses the modern fork of RuntimeScheduler that allows scheduling tasks with priorities from any thread.", - "defaultValue": false - }, - "enableMicrotasks": { - "description": "Enables the use of microtasks in Hermes (scheduling) and RuntimeScheduler (execution).", - "defaultValue": false - }, - "batchRenderingUpdatesInEventLoop": { - "description": "When enabled, the RuntimeScheduler processing the event loop will batch all rendering updates and dispatch them together at the end of each iteration of the loop.", - "defaultValue": false - }, - "enableSpannableBuildingUnification": { - "description": "Uses new, deduplicated logic for constructing Android Spannables from text fragments", - "defaultValue": false - }, - "enableCustomDrawOrderFabric": { - "description": "When enabled, Fabric will use customDrawOrder in ReactViewGroup (similar to old architecture).", - "defaultValue": false - }, - "enableFixForClippedSubviewsCrash": { - "description": "Attempt at fixing a crash related to subview clipping on Android. This is a kill switch for the fix", - "defaultValue": false - } - }, - "jsOnly": { - "jsOnlyTestFlag": { - "description": "JS-only flag for testing. Do NOT modify.", - "defaultValue": false - }, - "isLayoutAnimationEnabled": { - "description": "Function used to enable / disabled Layout Animations in React Native.", - "defaultValue": true - }, - "animatedShouldDebounceQueueFlush": { - "description": "Enables an experimental flush-queue debouncing in Animated.js.", - "defaultValue": false - }, - "animatedShouldUseSingleOp": { - "description": "Enables an experimental mega-operation for Animated.js that replaces many calls to native with a single call into native, to reduce JSI/JNI traffic.", - "defaultValue": false - }, - "enableAccessToHostTreeInFabric": { - "description": "Enables access to the host tree in Fabric using DOM-compatible APIs.", - "defaultValue": false - }, - "shouldUseAnimatedObjectForTransform": { - "description": "Enables use of AnimatedObject for animating transform values.", - "defaultValue": false - }, - "shouldUseSetNativePropsInFabric": { - "description": "Enables use of setNativeProps in JS driven animations.", - "defaultValue": true - }, - "shouldUseRemoveClippedSubviewsAsDefaultOnIOS": { - "description": "removeClippedSubviews prop will be used as the default in FlatList on iOS to match Android", - "defaultValue": false - } - } -} diff --git a/packages/react-native/scripts/featureflags/update.js b/packages/react-native/scripts/featureflags/update.js index db12eb2fba2..46ce9493f14 100644 --- a/packages/react-native/scripts/featureflags/update.js +++ b/packages/react-native/scripts/featureflags/update.js @@ -9,7 +9,7 @@ */ import generateFiles from './generateFiles'; -import fs from 'fs'; +import featureFlagDefinitions from './ReactNativeFeatureFlags.config'; import path from 'path'; const REACT_NATIVE_PACKAGE_ROOT = path.join(__dirname, '..', '..'); @@ -17,12 +17,7 @@ const REACT_NATIVE_PACKAGE_ROOT = path.join(__dirname, '..', '..'); export default function update(verifyUnchanged: boolean): void { generateFiles( { - featureFlagDefinitions: JSON.parse( - fs.readFileSync( - path.join(__dirname, 'ReactNativeFeatureFlags.json'), - 'utf8', - ), - ), + featureFlagDefinitions, jsPath: path.join( REACT_NATIVE_PACKAGE_ROOT, 'src', diff --git a/packages/react-native/scripts/featureflags/utils.js b/packages/react-native/scripts/featureflags/utils.js index c05ec864b7a..1634f3c73ff 100644 --- a/packages/react-native/scripts/featureflags/utils.js +++ b/packages/react-native/scripts/featureflags/utils.js @@ -44,7 +44,7 @@ export const DO_NOT_MODIFY_COMMENT = `/** * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update diff --git a/packages/react-native/src/private/featureflags/NativeReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/NativeReactNativeFeatureFlags.js index 22050a3f31b..78bc969baeb 100644 --- a/packages/react-native/src/private/featureflags/NativeReactNativeFeatureFlags.js +++ b/packages/react-native/src/private/featureflags/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<<2ca87dc970592f66d83f4799c4047c9b>> + * @generated SignedSource<> * @flow strict-local */ @@ -12,7 +12,7 @@ * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update diff --git a/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js b/packages/react-native/src/private/featureflags/ReactNativeFeatureFlags.js index dc612641d20..32c632c8b15 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<<52b25f675aa8d5ae45941f0ee951358a>> * @flow strict-local */ @@ -12,7 +12,7 @@ * IMPORTANT: Do NOT modify this file directly. * * To change the definition of the flags, edit - * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.json. + * packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js. * * To regenerate this code, run the following script from the repo root: * yarn featureflags-update