Skip to content

Commit

Permalink
Expose unstable_fuseboxEnabled API on iOS (#44860)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #44860

- Enables an opt-in to the Fusebox stack on iOS for both architectures in open source.
- Templates use of this opt-in in RNTester.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D58364053

fbshipit-source-id: c604b1589174bf7cfd0fe1bfb5624c4edd0a125d
  • Loading branch information
huntie authored and facebook-github-bot committed Jun 11, 2024
1 parent 1d926d4 commit 812f155
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ NS_ASSUME_NONNULL_BEGIN
/// @return: `true` if the new initialization layer is enabled. Otherwise returns `false`.
- (BOOL)bridgelessEnabled;

/// Controls whether the new debugger stack (codename Fusebox) is enabled.
- (BOOL)unstable_fuseboxEnabled;

/// Return the bundle URL for the main bundle.
- (NSURL *__nullable)bundleURL;

Expand Down
31 changes: 29 additions & 2 deletions packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ - (BOOL)bridgelessEnabled
return [self newArchEnabled];
}

- (BOOL)unstable_fuseboxEnabled
{
return [self unstable_fuseboxEnabled];
}

- (NSURL *)bundleURL
{
[NSException raise:@"RCTAppDelegate::bundleURL not implemented"
Expand Down Expand Up @@ -300,8 +305,26 @@ - (RCTRootViewFactory *)createRCTRootViewFactory

#pragma mark - Feature Flags

class RCTAppDelegateBridgelessFeatureFlags : public facebook::react::ReactNativeFeatureFlagsDefaults {
class RCTAppDelegateFeatureFlags : public facebook::react::ReactNativeFeatureFlagsDefaults {
public:
RCTAppDelegateFeatureFlags(bool fuseboxEnabled)
{
fuseboxEnabled_ = fuseboxEnabled;
}

bool fuseboxEnabledDebug() override
{
return fuseboxEnabled_;
}

private:
bool fuseboxEnabled_;
};

class RCTAppDelegateBridgelessFeatureFlags : public RCTAppDelegateFeatureFlags {
public:
RCTAppDelegateBridgelessFeatureFlags(bool fuseboxEnabled) : RCTAppDelegateFeatureFlags(fuseboxEnabled) {}

bool useModernRuntimeScheduler() override
{
return true;
Expand All @@ -319,7 +342,11 @@ bool batchRenderingUpdatesInEventLoop() override
- (void)_setUpFeatureFlags
{
if ([self bridgelessEnabled]) {
facebook::react::ReactNativeFeatureFlags::override(std::make_unique<RCTAppDelegateBridgelessFeatureFlags>());
facebook::react::ReactNativeFeatureFlags::override(
std::make_unique<RCTAppDelegateBridgelessFeatureFlags>([self unstable_fuseboxEnabled]));
} else {
facebook::react::ReactNativeFeatureFlags::override(
std::make_unique<RCTAppDelegateFeatureFlags>([self unstable_fuseboxEnabled]));
}
}

Expand Down
8 changes: 8 additions & 0 deletions packages/rn-tester/RNTester/AppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ - (BOOL)bridgelessEnabled
return [super bridgelessEnabled];
}

#pragma mark - Experimental settings

// [Experiment] Enable the new debugger stack (codename Fusebox)
- (BOOL)unstable_fuseboxEnabled
{
return false;
}

#pragma mark - RCTComponentViewFactoryComponentProvider

#ifndef RN_DISABLE_OSS_PLUGIN_HEADER
Expand Down

0 comments on commit 812f155

Please sign in to comment.