mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: There's no need for this to be a setter/getter, as there are no side-effects, and it means we can use the same helper method to read it as other feature flags. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D36595602 fbshipit-source-id: d27c01bd39d03606a6f8c17ba181a8cd0bf58dbb
77 lines
2.8 KiB
Java
77 lines
2.8 KiB
Java
/*
|
|
* 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.fabric;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import com.facebook.react.bridge.JSIModuleProvider;
|
|
import com.facebook.react.bridge.ReactApplicationContext;
|
|
import com.facebook.react.bridge.UIManager;
|
|
import com.facebook.react.common.mapbuffer.MapBufferSoLoader;
|
|
import com.facebook.react.config.ReactFeatureFlags;
|
|
import com.facebook.react.fabric.events.EventBeatManager;
|
|
import com.facebook.react.uimanager.ViewManagerRegistry;
|
|
import com.facebook.systrace.Systrace;
|
|
|
|
public class FabricJSIModuleProvider implements JSIModuleProvider<UIManager> {
|
|
|
|
@NonNull private final ReactApplicationContext mReactApplicationContext;
|
|
@NonNull private final ComponentFactory mComponentFactory;
|
|
@NonNull private final ReactNativeConfig mConfig;
|
|
@NonNull private final ViewManagerRegistry mViewManagerRegistry;
|
|
|
|
public FabricJSIModuleProvider(
|
|
@NonNull ReactApplicationContext reactApplicationContext,
|
|
@NonNull ComponentFactory componentFactory,
|
|
@NonNull ReactNativeConfig config,
|
|
@NonNull ViewManagerRegistry viewManagerRegistry) {
|
|
mReactApplicationContext = reactApplicationContext;
|
|
mComponentFactory = componentFactory;
|
|
mConfig = config;
|
|
mViewManagerRegistry = viewManagerRegistry;
|
|
}
|
|
|
|
@Override
|
|
public UIManager get() {
|
|
Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.get");
|
|
final EventBeatManager eventBeatManager = new EventBeatManager(mReactApplicationContext);
|
|
final FabricUIManager uiManager = createUIManager(eventBeatManager);
|
|
|
|
Systrace.beginSection(
|
|
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.registerBinding");
|
|
final Binding binding = new Binding();
|
|
|
|
if (ReactFeatureFlags.mapBufferSerializationEnabled) {
|
|
MapBufferSoLoader.staticInit();
|
|
}
|
|
|
|
binding.register(
|
|
mReactApplicationContext.getCatalystInstance().getRuntimeExecutor(),
|
|
mReactApplicationContext.getCatalystInstance().getRuntimeScheduler(),
|
|
uiManager,
|
|
eventBeatManager,
|
|
mComponentFactory,
|
|
mConfig);
|
|
|
|
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
|
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
|
|
|
return uiManager;
|
|
}
|
|
|
|
private FabricUIManager createUIManager(@NonNull EventBeatManager eventBeatManager) {
|
|
Systrace.beginSection(
|
|
Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.createUIManager");
|
|
|
|
FabricUIManager fabricUIManager;
|
|
fabricUIManager =
|
|
new FabricUIManager(mReactApplicationContext, mViewManagerRegistry, eventBeatManager);
|
|
Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE);
|
|
return fabricUIManager;
|
|
}
|
|
}
|