Files
react-native/packages/react-native/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h
T
Alex Hunt b5117520fc Enforce sorting of feature flag definitions (#43329)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43329

Improve maintainability of this file, in particular reducing the probability of a merge conflict for new entries.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D54539469

fbshipit-source-id: dc2fca42b4490d87c532b21043b0855d8d1a894d
2024-03-05 17:27:23 -08:00

127 lines
4.0 KiB
C++

/*
* 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<<036e7f3ee4def5b955ed61c707bbc8f8>>
*/
/**
* 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 <react/featureflags/ReactNativeFeatureFlagsAccessor.h>
#include <react/featureflags/ReactNativeFeatureFlagsProvider.h>
#include <memory>
namespace facebook::react {
/**
* This class provides access to internal React Native feature flags.
*
* All the methods are thread-safe (as long as the methods in the overridden
* provider are).
*/
class ReactNativeFeatureFlags {
public:
/**
* Common flag for testing. Do NOT modify.
*/
static bool commonTestFlag();
/**
* 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.
*/
static bool batchRenderingUpdatesInEventLoop();
/**
* Enables the use of a background executor to compute layout and commit updates on Fabric (this system is deprecated and should not be used).
*/
static bool enableBackgroundExecutor();
/**
* When enabled, Fabric will use customDrawOrder in ReactViewGroup (similar to old architecture).
*/
static bool enableCustomDrawOrderFabric();
/**
* Attempt at fixing a crash related to subview clipping on Android. This is a kill switch for the fix
*/
static bool enableFixForClippedSubviewsCrash();
/**
* Enables the use of microtasks in Hermes (scheduling) and RuntimeScheduler (execution).
*/
static bool enableMicrotasks();
/**
* Uses new, deduplicated logic for constructing Android Spannables from text fragments
*/
static bool enableSpannableBuildingUnification();
/**
* Flag determining if the C++ implementation of InspectorPackagerConnection should be used instead of the per-platform one. This flag is global and should not be changed across React Host lifetimes.
*/
static bool inspectorEnableCxxInspectorPackagerConnection();
/**
* Flag determining if the modern CDP backend should be enabled. This flag is global and should not be changed across React Host lifetimes.
*/
static bool inspectorEnableModernCDPRegistry();
/**
* When enabled, it uses the modern fork of RuntimeScheduler that allows scheduling tasks with priorities from any thread.
*/
static bool useModernRuntimeScheduler();
/**
* Overrides the feature flags with the ones provided by the given provider
* (generally one that extends `ReactNativeFeatureFlagsDefaults`).
*
* This method must be called before you initialize the React Native runtime.
*
* @example
*
* ```
* class MyReactNativeFeatureFlags : public ReactNativeFeatureFlagsDefaults {
* public:
* bool someFlag() override;
* };
*
* ReactNativeFeatureFlags.override(
* std::make_unique<MyReactNativeFeatureFlags>());
* ```
*/
static void override(
std::unique_ptr<ReactNativeFeatureFlagsProvider> provider);
/**
* Removes the overridden feature flags and makes the API return default
* values again.
*
* This is **dangerous**. Use it only if you really understand the
* implications of this method.
*
* This should only be called if you destroy the React Native runtime and
* need to create a new one with different overrides. In that case,
* call `dangerouslyReset` after destroying the runtime and `override` again
* before initializing the new one.
*/
static void dangerouslyReset();
private:
ReactNativeFeatureFlags() = delete;
static ReactNativeFeatureFlagsAccessor& getAccessor(bool reset = false);
};
} // namespace facebook::react