Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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.
*
* @generated SignedSource<<95f86b3476aeff097f532b10cabf067e>>
*/

/**
* IMPORTANT: Do NOT modify this file directly.
*
* To change the definition of the flags, edit
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags --update
*/

#include "ReactNativeFeatureFlags.h"
#include "ReactNativePublicFeatureFlags.h"

namespace facebook::react {

bool ReactNativeFeatureFlags_DO_NOT_USE::enableAccumulatedUpdatesInRawPropsAndroid() {
return ReactNativeFeatureFlags::enableAccumulatedUpdatesInRawPropsAndroid();
}

bool ReactNativeFeatureFlags_DO_NOT_USE::enableCppPropsIteratorSetter() {
return ReactNativeFeatureFlags::enableCppPropsIteratorSetter();
}

bool ReactNativeFeatureFlags_DO_NOT_USE::enableExclusivePropsUpdateAndroid() {
return ReactNativeFeatureFlags::enableExclusivePropsUpdateAndroid();
}

bool ReactNativeFeatureFlags_DO_NOT_USE::enableNativeCSSParsing() {
return ReactNativeFeatureFlags::enableNativeCSSParsing();
}

bool ReactNativeFeatureFlags_DO_NOT_USE::enablePropsUpdateReconciliationAndroid() {
return ReactNativeFeatureFlags::enablePropsUpdateReconciliationAndroid();
}

bool ReactNativeFeatureFlags_DO_NOT_USE::useSharedAnimatedBackend() {
return ReactNativeFeatureFlags::useSharedAnimatedBackend();
}

} // namespace facebook::react
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* 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.
*
* @generated SignedSource<<39037a69a47b86d0c6643d90f4058002>>
*/

/**
* IMPORTANT: Do NOT modify this file directly.
*
* To change the definition of the flags, edit
* packages/react-native/scripts/featureflags/ReactNativeFeatureFlags.config.js.
*
* To regenerate this code, run the following script from the repo root:
* yarn featureflags --update
*/

#pragma once

#include <string>

#ifndef RN_EXPORT
#define RN_EXPORT __attribute__((visibility("default")))
#endif

namespace facebook::react {

/**
* This class provides public access to select internal React Native feature flags.
*/
class ReactNativeFeatureFlags_DO_NOT_USE {
public:
/**
* When enabled, Android will accumulate updates in rawProps to reduce the number of mounting instructions for cascading re-renders.
*/
RN_EXPORT static bool enableAccumulatedUpdatesInRawPropsAndroid();

/**
* Enable prop iterator setter-style construction of Props in C++ (this flag is not used in Java).
*/
RN_EXPORT static bool enableCppPropsIteratorSetter();

/**
* When enabled, Android will disable Props 1.5 raw value merging when Props 2.0 is available.
*/
RN_EXPORT static bool enableExclusivePropsUpdateAndroid();

/**
* Parse CSS strings using the Fabric CSS parser instead of ViewConfig processing
*/
RN_EXPORT static bool enableNativeCSSParsing();

/**
* When enabled, Android will receive prop updates based on the differences between the last rendered shadow node and the last committed shadow node.
*/
RN_EXPORT static bool enablePropsUpdateReconciliationAndroid();

/**
* Use shared animation backend in C++ Animated
*/
RN_EXPORT static bool useSharedAnimatedBackend();
};

} // namespace facebook::react
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ const definitions: FeatureFlagDefinitions = {
ossReleaseStage: 'canary',
},
enableAccumulatedUpdatesInRawPropsAndroid: {
dangerouslyExposeInPublicCppHeaders: true,
defaultValue: false,
metadata: {
dateAdded: '2024-12-10',
Expand Down Expand Up @@ -233,6 +234,7 @@ const definitions: FeatureFlagDefinitions = {
ossReleaseStage: 'none',
},
enableCppPropsIteratorSetter: {
dangerouslyExposeInPublicCppHeaders: true,
defaultValue: false,
metadata: {
dateAdded: '2024-09-13',
Expand Down Expand Up @@ -287,6 +289,7 @@ const definitions: FeatureFlagDefinitions = {
ossReleaseStage: 'none',
},
enableExclusivePropsUpdateAndroid: {
dangerouslyExposeInPublicCppHeaders: true,
defaultValue: false,
metadata: {
dateAdded: '2025-11-11',
Expand Down Expand Up @@ -517,6 +520,7 @@ const definitions: FeatureFlagDefinitions = {
ossReleaseStage: 'none',
},
enableNativeCSSParsing: {
dangerouslyExposeInPublicCppHeaders: true,
defaultValue: false,
metadata: {
dateAdded: '2025-02-07',
Expand All @@ -538,6 +542,7 @@ const definitions: FeatureFlagDefinitions = {
ossReleaseStage: 'none',
},
enablePropsUpdateReconciliationAndroid: {
dangerouslyExposeInPublicCppHeaders: true,
defaultValue: false,
metadata: {
dateAdded: '2024-07-12',
Expand Down Expand Up @@ -923,6 +928,7 @@ const definitions: FeatureFlagDefinitions = {
ossReleaseStage: 'none',
},
useSharedAnimatedBackend: {
dangerouslyExposeInPublicCppHeaders: true,
defaultValue: false,
metadata: {
dateAdded: '2025-08-02',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import ReactNativeFeatureFlagsDefaultsH from './templates/common-cxx/ReactNative
import ReactNativeFeatureFlagsDynamicProviderH from './templates/common-cxx/ReactNativeFeatureFlagsDynamicProvider.h-template';
import ReactNativeFeatureFlagsOverrides from './templates/common-cxx/ReactNativeFeatureFlagsOverridesOSS_Stage_.h-template';
import ReactNativeFeatureFlagsProviderH from './templates/common-cxx/ReactNativeFeatureFlagsProvider.h-template';
import ReactNativePublicFeatureFlagsCPP from './templates/common-cxx/ReactNativePublicFeatureFlags.cpp-template';
import ReactNativePublicFeatureFlagsH from './templates/common-cxx/ReactNativePublicFeatureFlags.h-template';
import path from 'node:path';

export default function generateCommonCxxModules(
Expand All @@ -30,6 +32,10 @@ export default function generateCommonCxxModules(
ReactNativeFeatureFlagsH(featureFlagDefinitions),
[path.join(commonCxxPath, 'ReactNativeFeatureFlags.cpp')]:
ReactNativeFeatureFlagsCPP(featureFlagDefinitions),
[path.join(commonCxxPath, 'ReactNativePublicFeatureFlags.h')]:
ReactNativePublicFeatureFlagsH(featureFlagDefinitions),
[path.join(commonCxxPath, 'ReactNativePublicFeatureFlags.cpp')]:
ReactNativePublicFeatureFlagsCPP(featureFlagDefinitions),
[path.join(commonCxxPath, 'ReactNativeFeatureFlagsAccessor.h')]:
ReactNativeFeatureFlagsAccessorH(featureFlagDefinitions),
[path.join(commonCxxPath, 'ReactNativeFeatureFlagsAccessor.cpp')]:
Expand Down
13 changes: 12 additions & 1 deletion packages/react-native/scripts/featureflags/generateFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,18 @@ export default function generateFiles(
...generatorConfig.featureFlagDefinitions,
common: Object.fromEntries(
Object.entries(generatorConfig.featureFlagDefinitions.common).filter(
([_, definition]) => !definition.skipNativeAPI,
([name, definition]) => {
if (
definition.skipNativeAPI &&
definition.dangerouslyExposeInPublicCppHeaders
) {
throw new Error(
`${name} cannot have both skipNativeAPI and dangerouslyExposeInPublicCppHeaders enabled at the same time.`,
);
}

return !definition.skipNativeAPI;
},
),
),
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* 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';

import {DO_NOT_MODIFY_COMMENT, getCxxTypeFromDefaultValue} from '../../utils';
import signedsource from 'signedsource';

export default function (definitions: FeatureFlagDefinitions): string {
return signedsource.signFile(`/*
* 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.
*
* ${signedsource.getSigningToken()}
*/

${DO_NOT_MODIFY_COMMENT}

#include "ReactNativeFeatureFlags.h"
#include "ReactNativePublicFeatureFlags.h"

namespace facebook::react {

${Object.entries(definitions.common)
.filter(([_, flagConfig]) => flagConfig.dangerouslyExposeInPublicCppHeaders)
.map(
([flagName, flagConfig]) =>
`${getCxxTypeFromDefaultValue(
flagConfig.defaultValue,
)} ReactNativeFeatureFlags_DO_NOT_USE::${flagName}() {
return ReactNativeFeatureFlags::${flagName}();
}`,
)
.join('\n\n')}

} // namespace facebook::react
`);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* 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';

import {DO_NOT_MODIFY_COMMENT, getCxxTypeFromDefaultValue} from '../../utils';
import signedsource from 'signedsource';

export default function (definitions: FeatureFlagDefinitions): string {
return signedsource.signFile(`/*
* 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.
*
* ${signedsource.getSigningToken()}
*/

${DO_NOT_MODIFY_COMMENT}

#pragma once

#include <string>

#ifndef RN_EXPORT
#define RN_EXPORT __attribute__((visibility("default")))
#endif

namespace facebook::react {

/**
* This class provides public access to select internal React Native feature flags.
*/
class ReactNativeFeatureFlags_DO_NOT_USE {
public:
${Object.entries(definitions.common)
.filter(([_, flagConfig]) => flagConfig.dangerouslyExposeInPublicCppHeaders)
.map(
([flagName, flagConfig]) =>
` /**
* ${flagConfig.metadata.description}
*/
RN_EXPORT static ${getCxxTypeFromDefaultValue(flagConfig.defaultValue)} ${flagName}();`,
)
.join('\n\n')}
};

} // namespace facebook::react
`);
}
2 changes: 2 additions & 0 deletions packages/react-native/scripts/featureflags/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export type CommonFeatureFlagConfig<
// Indicates if this API should only be defined in JavaScript, only to
// preserve backwards compatibility with existing native code temporarily.
skipNativeAPI?: true,
// Whether this flag should be exposed by the public feature flags entrypoint.
dangerouslyExposeInPublicCppHeaders?: true,
}>;

export type CommonFeatureFlagList = Readonly<{
Expand Down
Loading