Skip to content
Open
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
2 changes: 0 additions & 2 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ NS_ASSUME_NONNULL_BEGIN
* - (UIViewController *)createRootViewController;
* - (void)setRootView:(UIView *)rootView toRootViewController:(UIViewController *)rootViewController;
* New Architecture:
* - (BOOL)turboModuleEnabled;
* - (BOOL)fabricEnabled;
* - (NSDictionary *)prepareInitialProps
* - (Class)getModuleClassFromName:(const char *)name
* - (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,21 +116,6 @@ - (BOOL)newArchEnabled
return YES;
}

- (BOOL)bridgelessEnabled
{
return YES;
}

- (BOOL)fabricEnabled
{
return YES;
}

- (BOOL)turboModuleEnabled
{
return YES;
}

- (Class)getModuleClassFromName:(const char *)name
{
return nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,7 @@ - (RCTRootViewFactory *)createRCTRootViewFactory
};

RCTRootViewFactoryConfiguration *configuration =
[[RCTRootViewFactoryConfiguration alloc] initWithBundleURLBlock:bundleUrlBlock
newArchEnabled:YES
turboModuleEnabled:YES
bridgelessEnabled:YES];
[[RCTRootViewFactoryConfiguration alloc] initWithBundleURLBlock:bundleUrlBlock newArchEnabled:YES];

configuration.customizeRootView = ^(UIView *_Nonnull rootView) {
[weakSelf.delegate customizeRootView:(RCTRootView *)rootView];
Expand Down
19 changes: 0 additions & 19 deletions packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@ typedef void (^RCTLoadSourceForBridgeBlock)(RCTBridge *bridge, RCTSourceLoadBloc
#pragma mark - RCTRootViewFactory Configuration
@interface RCTRootViewFactoryConfiguration : NSObject

/// This property controls whether the App will use the Fabric renderer of the New Architecture or not.
@property (nonatomic, assign, readonly) BOOL fabricEnabled;

/// This property controls whether React Native's new initialization layer is enabled.
@property (nonatomic, assign, readonly) BOOL bridgelessEnabled;

/// This method controls whether the `turboModules` feature of the New Architecture is turned on or off
@property (nonatomic, assign, readonly) BOOL turboModuleEnabled;

/// Return the bundle URL for the main bundle.
@property (nonatomic, nonnull) RCTBundleURLBlock bundleURLBlock;

Expand All @@ -64,16 +55,6 @@ typedef void (^RCTLoadSourceForBridgeBlock)(RCTBridge *bridge, RCTSourceLoadBloc
* pointing to a path inside the app resources, e.g. `file://.../main.jsbundle`.
*
*/
- (instancetype)initWithBundleURLBlock:(RCTBundleURLBlock)bundleURLBlock
newArchEnabled:(BOOL)newArchEnabled
turboModuleEnabled:(BOOL)turboModuleEnabled
bridgelessEnabled:(BOOL)bridgelessEnabled __deprecated;

- (instancetype)initWithBundleURL:(NSURL *)bundleURL
newArchEnabled:(BOOL)newArchEnabled
turboModuleEnabled:(BOOL)turboModuleEnabled
bridgelessEnabled:(BOOL)bridgelessEnabled __deprecated;

- (instancetype)initWithBundleURLBlock:(RCTBundleURLBlock)bundleURLBlock
newArchEnabled:(BOOL)newArchEnabled NS_DESIGNATED_INITIALIZER;

Expand Down
27 changes: 0 additions & 27 deletions packages/react-native/Libraries/AppDelegate/RCTRootViewFactory.mm
Original file line number Diff line number Diff line change
Expand Up @@ -42,37 +42,10 @@ - (instancetype)initWithBundleURLBlock:(RCTBundleURLBlock)bundleURLBlock newArch
return [self initWithBundleURLBlock:bundleURLBlock];
}

- (instancetype)initWithBundleURL:(NSURL *)bundleURL
newArchEnabled:(BOOL)newArchEnabled
turboModuleEnabled:(BOOL)turboModuleEnabled
bridgelessEnabled:(BOOL)bridgelessEnabled
{
return [self initWithBundleURLBlock:^{
return bundleURL;
}];
}

- (instancetype)initWithBundleURLBlock:(RCTBundleURLBlock)bundleURLBlock
newArchEnabled:(BOOL)newArchEnabled
turboModuleEnabled:(BOOL)turboModuleEnabled
bridgelessEnabled:(BOOL)bridgelessEnabled
{
if (self = [super init]) {
_bundleURLBlock = bundleURLBlock;
_fabricEnabled = YES;
_turboModuleEnabled = YES;
_bridgelessEnabled = YES;
}
return self;
}

- (instancetype)initWithBundleURLBlock:(RCTBundleURLBlock)bundleURLBlock
{
if (self = [super init]) {
_bundleURLBlock = bundleURLBlock;
_fabricEnabled = YES;
_turboModuleEnabled = YES;
_bridgelessEnabled = YES;
}
return self;
}
Expand Down
10 changes: 0 additions & 10 deletions packages/react-native/ReactAndroid/api/ReactAndroid.api
Original file line number Diff line number Diff line change
Expand Up @@ -1768,18 +1768,8 @@ public final class com/facebook/react/defaults/DefaultComponentsRegistry {

public final class com/facebook/react/defaults/DefaultNewArchitectureEntryPoint {
public static final field INSTANCE Lcom/facebook/react/defaults/DefaultNewArchitectureEntryPoint;
public static final fun getBridgelessEnabled ()Z
public static final fun getConcurrentReactEnabled ()Z
public static final fun getFabricEnabled ()Z
public final fun getReleaseLevel ()Lcom/facebook/react/common/ReleaseLevel;
public static final fun getTurboModulesEnabled ()Z
public static final fun load ()V
public static final fun load (Z)V
public static final fun load (ZZ)V
public static final fun load (ZZZ)V
public static synthetic fun load$default (ZILjava/lang/Object;)V
public static synthetic fun load$default (ZZILjava/lang/Object;)V
public static synthetic fun load$default (ZZZILjava/lang/Object;)V
public final fun setReleaseLevel (Lcom/facebook/react/common/ReleaseLevel;)V
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/

@file:Suppress("DEPRECATION") // We want to use ReactFeatureFlags here specifically

package com.facebook.react.defaults

import com.facebook.react.common.ReleaseLevel
import com.facebook.react.common.annotations.VisibleForTesting
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlags
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsOverrides_RNOSS_Canary_Android
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsOverrides_RNOSS_Experimental_Android
Expand All @@ -20,74 +17,20 @@ import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsProvider
/**
* A utility class that serves as an entry point for users setup the New Architecture.
*
* This class needs to be invoked as `DefaultNewArchitectureEntryPoint.load(...)` by passing a
* series of optional parameters.
* This class needs to be invoked as `DefaultNewArchitectureEntryPoint.load()`.
*
* By default it loads a library called `appmodules`. `appmodules` is a convention used to refer to
* the application dynamic library. If changed here should be updated also inside the template.
*
* By default it also enables both TurboModules, Fabric and Concurrent React (aka React 18), and
* Bridgeless
* The [releaseLevel] selects which feature flag release channel the app is loaded with.
*/
public object DefaultNewArchitectureEntryPoint {

public var releaseLevel: ReleaseLevel = ReleaseLevel.STABLE

/**
* Loads the React Native New Architecture entry point with the default configuration.
*
* This will load the app with TurboModules, Fabric and Bridgeless by default.
*/
/** Loads the React Native New Architecture entry point. */
@JvmStatic
public fun load() {
load(turboModulesEnabled = true, fabricEnabled = true, bridgelessEnabled = true)
}

@JvmStatic
@Deprecated(
message =
"Loading the entry point with different flags for Fabric, TurboModule and Bridgeless is deprecated." +
"Please use load() instead when loading the New Architecture.",
replaceWith = ReplaceWith("load()"),
)
public fun load(
turboModulesEnabled: Boolean = true,
) {
load(turboModulesEnabled, fabricEnabled = true, bridgelessEnabled = true)
}

@JvmStatic
@Deprecated(
message =
"Loading the entry point with different flags for Fabric, TurboModule and Bridgeless is deprecated." +
"Please use load() instead when loading the New Architecture.",
replaceWith = ReplaceWith("load()"),
)
public fun load(
turboModulesEnabled: Boolean = true,
fabricEnabled: Boolean = true,
) {
load(turboModulesEnabled, fabricEnabled, bridgelessEnabled = true)
}

@JvmStatic
@Deprecated(
message =
"Loading the entry point with different flags for Fabric, TurboModule and Bridgeless is deprecated." +
"Please use load() instead when loading the New Architecture.",
replaceWith = ReplaceWith("load()"),
)
public fun load(
turboModulesEnabled: Boolean = true,
fabricEnabled: Boolean = true,
bridgelessEnabled: Boolean = true,
) {
val (isValid, errorMessage) =
isConfigurationValid(turboModulesEnabled, fabricEnabled, bridgelessEnabled)
if (!isValid) {
error(errorMessage)
}

when (releaseLevel) {
ReleaseLevel.EXPERIMENTAL -> {
ReactNativeFeatureFlags.override(
Expand All @@ -102,65 +45,13 @@ public object DefaultNewArchitectureEntryPoint {
}
}

privateTurboModulesEnabled = turboModulesEnabled
privateBridgelessEnabled = bridgelessEnabled

DefaultSoLoader.maybeLoadSoLibrary()
}

@JvmStatic
internal fun loadWithFeatureFlags(featureFlags: ReactNativeFeatureFlagsProvider) {
ReactNativeFeatureFlags.override(featureFlags)

privateTurboModulesEnabled = true
privateBridgelessEnabled = featureFlags.enableBridgelessArchitecture()

val (isValid, errorMessage) =
isConfigurationValid(
privateTurboModulesEnabled,
true,
privateBridgelessEnabled,
)
if (!isValid) {
error(errorMessage)
}

DefaultSoLoader.maybeLoadSoLibrary()
}

@JvmStatic
public val fabricEnabled: Boolean
get() = true

private var privateTurboModulesEnabled: Boolean = false

@JvmStatic
public val turboModulesEnabled: Boolean
get() = privateTurboModulesEnabled

@JvmStatic
public val concurrentReactEnabled: Boolean
get() = true

private var privateBridgelessEnabled: Boolean = false

@JvmStatic
public val bridgelessEnabled: Boolean
get() = privateBridgelessEnabled

@VisibleForTesting
public fun isConfigurationValid(
turboModulesEnabled: Boolean,
fabricEnabled: Boolean,
bridgelessEnabled: Boolean,
): Pair<Boolean, String> =
if (!turboModulesEnabled || !fabricEnabled || !bridgelessEnabled) {
false to
"You cannot load React Native with the New Architecture disabled. " +
"Please use DefaultNewArchitectureEntryPoint.load() instead of " +
"DefaultNewArchitectureEntryPoint.load(turboModulesEnabled=$turboModulesEnabled, " +
"fabricEnabled=$fabricEnabled, bridgelessEnabled=$bridgelessEnabled)"
} else {
true to ""
}
}
Loading
Loading