mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Extract ComponentNameRegistry out of Fabric modules
Summary: This diff extracts ComponentNameRegistry out of Fabric modules This is necessary to avoid depending on Fabric and regressing APK size for other RN apps (e.g. IG) changelog: [internal] internal Reviewed By: JoshuaGross Differential Revision: D26765328 fbshipit-source-id: 0a22c4279146f5243473c74a84e78fad7f08f956
This commit is contained in:
committed by
Facebook GitHub Bot
parent
056f1fd2cd
commit
fca0442bc8
@@ -83,8 +83,6 @@ import com.facebook.react.devsupport.RedBoxHandler;
|
||||
import com.facebook.react.devsupport.interfaces.DevBundleDownloadListener;
|
||||
import com.facebook.react.devsupport.interfaces.DevSupportManager;
|
||||
import com.facebook.react.devsupport.interfaces.PackagerStatusCallback;
|
||||
import com.facebook.react.fabric.ComponentNameResolver;
|
||||
import com.facebook.react.fabric.ComponentNameResolverManager;
|
||||
import com.facebook.react.modules.appearance.AppearanceModule;
|
||||
import com.facebook.react.modules.appregistry.AppRegistry;
|
||||
import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler;
|
||||
@@ -97,6 +95,8 @@ import com.facebook.react.surface.ReactStage;
|
||||
import com.facebook.react.turbomodule.core.TurboModuleManager;
|
||||
import com.facebook.react.turbomodule.core.TurboModuleManagerDelegate;
|
||||
import com.facebook.react.turbomodule.core.interfaces.TurboModuleRegistry;
|
||||
import com.facebook.react.uimanager.ComponentNameResolver;
|
||||
import com.facebook.react.uimanager.ComponentNameResolverManager;
|
||||
import com.facebook.react.uimanager.DisplayMetricsHolder;
|
||||
import com.facebook.react.uimanager.ReactRoot;
|
||||
import com.facebook.react.uimanager.UIImplementationProvider;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "Binding.h"
|
||||
#include "ComponentFactory.h"
|
||||
#include "ComponentNameResolverManager.h"
|
||||
#include "CoreComponentsRegistry.h"
|
||||
#include "EventBeatManager.h"
|
||||
#include "EventEmitterWrapper.h"
|
||||
@@ -22,7 +21,6 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
|
||||
facebook::react::EventEmitterWrapper::registerNatives();
|
||||
facebook::react::StateWrapperImpl::registerNatives();
|
||||
facebook::react::ComponentFactory::registerNatives();
|
||||
facebook::react::ComponentNameResolverManager::registerNatives();
|
||||
facebook::react::CoreComponentsRegistry::registerNatives();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -32,10 +32,12 @@ rn_android_library(
|
||||
":DisplayMetrics",
|
||||
react_native_dep("java/com/facebook/systrace:systrace"),
|
||||
react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"),
|
||||
react_native_dep("libraries/soloader/java/com/facebook/soloader:soloader"),
|
||||
react_native_dep("third-party/java/infer-annotations:infer-annotations"),
|
||||
react_native_target("java/com/facebook/debug/tags:tags"),
|
||||
react_native_target("java/com/facebook/debug/holder:holder"),
|
||||
react_native_target("java/com/facebook/react/bridge:bridge"),
|
||||
react_native_target("java/com/facebook/react/uimanager/jni:jni"),
|
||||
react_native_target("java/com/facebook/react/common:common"),
|
||||
react_native_target("java/com/facebook/react/config:config"),
|
||||
react_native_target("java/com/facebook/react/module/annotations:annotations"),
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.fabric;
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
|
||||
+7
-2
@@ -5,16 +5,17 @@
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
package com.facebook.react.fabric;
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import com.facebook.jni.HybridData;
|
||||
import com.facebook.proguard.annotations.DoNotStrip;
|
||||
import com.facebook.react.bridge.RuntimeExecutor;
|
||||
import com.facebook.soloader.SoLoader;
|
||||
|
||||
public class ComponentNameResolverManager {
|
||||
|
||||
static {
|
||||
FabricSoLoader.staticInit();
|
||||
staticInit();
|
||||
}
|
||||
|
||||
@DoNotStrip
|
||||
@@ -31,4 +32,8 @@ public class ComponentNameResolverManager {
|
||||
RuntimeExecutor runtimeExecutor, Object componentNameResolver);
|
||||
|
||||
private native void installJSIBindings();
|
||||
|
||||
private static void staticInit() {
|
||||
SoLoader.loadLibrary("uimanagerjni");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
# Copyright (c) Facebook, Inc. and its affiliates.
|
||||
#
|
||||
# This source code is licensed under the MIT license found in the
|
||||
# LICENSE file in the root directory of this source tree.
|
||||
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_MODULE := uimanagerjni
|
||||
|
||||
LOCAL_SRC_FILES := $(wildcard $(LOCAL_PATH)/*.cpp)
|
||||
|
||||
LOCAL_SHARED_LIBRARIES := libyoga libglog libfb libfbjni libglog_init libfolly_json libfolly_futures react_render_componentregistry librrc_native
|
||||
|
||||
LOCAL_STATIC_LIBRARIES :=
|
||||
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/
|
||||
|
||||
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/
|
||||
|
||||
LOCAL_CFLAGS := \
|
||||
-DLOG_TAG=\"ReacTNative\"
|
||||
|
||||
LOCAL_CFLAGS += -fexceptions -frtti -std=c++14 -Wall
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
$(call import-module,fbgloginit)
|
||||
$(call import-module,folly)
|
||||
$(call import-module,fb)
|
||||
$(call import-module,fbjni)
|
||||
$(call import-module,yogajni)
|
||||
$(call import-module,glog)
|
||||
|
||||
$(call import-module,react/renderer/componentregistry)
|
||||
$(call import-module,react/renderer/componentregistry/native)
|
||||
@@ -0,0 +1,41 @@
|
||||
load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "FBJNI_TARGET", "react_native_target", "react_native_xplat_target", "rn_xplat_cxx_library", "subdir_glob")
|
||||
|
||||
rn_xplat_cxx_library(
|
||||
name = "jni",
|
||||
srcs = glob(["*.cpp"]),
|
||||
headers = glob(["*.h"]),
|
||||
header_namespace = "",
|
||||
exported_headers = subdir_glob(
|
||||
[
|
||||
("", "**/*.h"),
|
||||
],
|
||||
prefix = "react/uimanager/jni",
|
||||
),
|
||||
compiler_flags = [
|
||||
"-fexceptions",
|
||||
"-frtti",
|
||||
"-std=c++14",
|
||||
"-Wall",
|
||||
],
|
||||
fbandroid_allow_jni_merging = True,
|
||||
labels = ["supermodule:xplat/default/public.react_native.infra"],
|
||||
platforms = (ANDROID),
|
||||
preprocessor_flags = [
|
||||
"-DLOG_TAG=\"ReactNative\"",
|
||||
"-DWITH_FBSYSTRACE=1",
|
||||
],
|
||||
soname = "libuimanagerjni.$(ext)",
|
||||
visibility = ["PUBLIC"],
|
||||
deps = [
|
||||
react_native_xplat_target("runtimeexecutor:runtimeexecutor"),
|
||||
react_native_xplat_target("react/renderer/componentregistry:componentregistry"),
|
||||
react_native_xplat_target("react/renderer/componentregistry/native:native"),
|
||||
react_native_target("jni/react/jni:jni"),
|
||||
"//xplat/fbsystrace:fbsystrace",
|
||||
"//xplat/folly:molly",
|
||||
"//xplat/jsi:JSIDynamic",
|
||||
"//xplat/jsi:jsi",
|
||||
"//xplat/third-party/linker_lib:atomic",
|
||||
FBJNI_TARGET,
|
||||
],
|
||||
)
|
||||
+1
-1
@@ -13,7 +13,7 @@
|
||||
|
||||
#include "ComponentNameResolverManager.h"
|
||||
|
||||
#include <react/renderer/componentregistry/NativeComponentRegistryBinding.h>
|
||||
#include <react/renderer/componentregistry/native/NativeComponentRegistryBinding.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
+2
-2
@@ -26,10 +26,10 @@ class ComponentNameResolverManager
|
||||
: public jni::HybridClass<ComponentNameResolverManager> {
|
||||
public:
|
||||
static auto constexpr kJavaDescriptor =
|
||||
"Lcom/facebook/react/fabric/ComponentNameResolverManager;";
|
||||
"Lcom/facebook/react/uimanager/ComponentNameResolverManager;";
|
||||
|
||||
constexpr static auto ComponentNameResolverJavaDescriptor =
|
||||
"com/facebook/react/fabric/ComponentNameResolver";
|
||||
"com/facebook/react/uimanager/ComponentNameResolver";
|
||||
|
||||
static jni::local_ref<jhybriddata> initHybrid(
|
||||
jni::alias_ref<jhybridobject> jThis,
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
#include <fbjni/fbjni.h>
|
||||
|
||||
#include "ComponentNameResolverManager.h"
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
|
||||
return facebook::jni::initialize(vm, [] {
|
||||
facebook::react::ComponentNameResolverManager::registerNatives();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user