Skip to content

Commit

Permalink
Move BridgelessReactPackage to com.facebook.react package (#37697)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #37697

Move BridgelessReactPackage to com.facebook.react package.
This is necessary because BridgelessReactPackage is a core package that needs to be part of RN (and should not be re-defined by all apps)

I will revisit naming in a later diff

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: cortinico, philIip

Differential Revision: D46408934

fbshipit-source-id: ac172d22a6d70c9d33d2e119da93b25736d85383
  • Loading branch information
mdvacca authored and facebook-github-bot committed Jun 13, 2023
1 parent 8351b08 commit 3f7507b
Showing 1 changed file with 70 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* 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.
*/

package com.facebook.react;

import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.devsupport.LogBoxModule;
import com.facebook.react.devsupport.interfaces.DevSupportManager;
import com.facebook.react.module.annotations.ReactModuleList;
import com.facebook.react.module.model.ReactModuleInfoProvider;
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
import com.facebook.react.modules.core.DeviceEventManagerModule;
import com.facebook.react.modules.debug.DevSettingsModule;
import com.facebook.react.modules.debug.SourceCodeModule;
import com.facebook.react.modules.deviceinfo.DeviceInfoModule;
import com.facebook.react.modules.systeminfo.AndroidInfoModule;

@Nullsafe(Nullsafe.Mode.LOCAL)
@ReactModuleList(
nativeModules = {
AndroidInfoModule.class,
DeviceInfoModule.class,
DevSettingsModule.class,
SourceCodeModule.class,
LogBoxModule.class,
DeviceEventManagerModule.class,
})
public class BridgelessReactPackage extends TurboReactPackage {

private DevSupportManager mDevSupportManager;
private DefaultHardwareBackBtnHandler mHardwareBackBtnHandler;

public BridgelessReactPackage(
DevSupportManager devSupportManager, DefaultHardwareBackBtnHandler hardwareBackBtnHandler) {
mDevSupportManager = devSupportManager;
mHardwareBackBtnHandler = hardwareBackBtnHandler;
}

@Override
public NativeModule getModule(String name, ReactApplicationContext reactContext) {
switch (name) {
case AndroidInfoModule.NAME:
return new AndroidInfoModule(reactContext);
case DeviceInfoModule.NAME:
return new DeviceInfoModule(reactContext);
case SourceCodeModule.NAME:
return new SourceCodeModule(reactContext);
case DevSettingsModule.NAME:
return new DevSettingsModule(reactContext, mDevSupportManager);
case DeviceEventManagerModule.NAME:
return new DeviceEventManagerModule(reactContext, mHardwareBackBtnHandler);
case LogBoxModule.NAME:
return new LogBoxModule(reactContext, mDevSupportManager);
default:
throw new IllegalArgumentException(
"In BridgelessReactPackage, could not find Native module for " + name);
}
}

@Override
public ReactModuleInfoProvider getReactModuleInfoProvider() {
return new BridgelessReactPackage$$ReactModuleInfoProvider();
}
}

0 comments on commit 3f7507b

Please sign in to comment.