Skip to content

Commit b58cba7

Browse files
motiz88facebook-github-bot
authored andcommitted
Rename JSEngineInstance -> JSRuntimeFactory (facebook#41548)
Summary: Pull Request resolved: facebook#41548 `JSEngineInstance` is a misnomer - this interface actually creates `jsi::Runtime`s and doesn't represent an "instance of a JS engine". This diff renames it to `JSRuntimeFactory`. Changelog: [Internal] Reviewed By: huntie, arushikesarwani94 Differential Revision: D51447882 fbshipit-source-id: e118fe5c202607500a62d8e15afec088c4946969
1 parent ce0dabd commit b58cba7

File tree

23 files changed

+63
-63
lines changed

23 files changed

+63
-63
lines changed

packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
#import <react/config/ReactNativeConfig.h>
3939
#import <react/renderer/runtimescheduler/RuntimeScheduler.h>
4040
#import <react/renderer/runtimescheduler/RuntimeSchedulerCallInvoker.h>
41-
#import <react/runtime/JSEngineInstance.h>
41+
#import <react/runtime/JSRuntimeFactory.h>
4242

4343
static NSString *const kRNConcurrentRoot = @"concurrentRoot";
4444

@@ -293,8 +293,8 @@ - (void)createReactHost
293293
_reactHost = [[RCTHost alloc] initWithBundleURL:[self bundleURL]
294294
hostDelegate:nil
295295
turboModuleManagerDelegate:self
296-
jsEngineProvider:^std::shared_ptr<facebook::react::JSEngineInstance>() {
297-
return [weakSelf createJSEngineInstance];
296+
jsEngineProvider:^std::shared_ptr<facebook::react::JSRuntimeFactory>() {
297+
return [weakSelf createJSRuntimeFactory];
298298
}];
299299
[_reactHost setBundleURLProvider:^NSURL *() {
300300
return [weakSelf bundleURL];
@@ -303,7 +303,7 @@ - (void)createReactHost
303303
[_reactHost start];
304304
}
305305

306-
- (std::shared_ptr<facebook::react::JSEngineInstance>)createJSEngineInstance
306+
- (std::shared_ptr<facebook::react::JSRuntimeFactory>)createJSRuntimeFactory
307307
{
308308
#if RCT_USE_HERMES
309309
return std::make_shared<facebook::react::RCTHermesInstance>(_reactNativeConfig, nullptr);

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ object DefaultReactHost {
5454
if (reactHost == null) {
5555
val jsBundleLoader =
5656
JSBundleLoader.createAssetLoader(context, "assets://$jsBundleAssetPath", true)
57-
val jsEngineInstance = if (isHermesEnabled) HermesInstance() else JSCInstance()
57+
val jsRuntimeFactory = if (isHermesEnabled) HermesInstance() else JSCInstance()
5858
val defaultReactHostDelegate =
5959
DefaultReactHostDelegate(
6060
jsMainModulePath = jsMainModulePath,
6161
jsBundleLoader = jsBundleLoader,
6262
reactPackages = packageList,
63-
jsEngineInstance = jsEngineInstance,
63+
jsRuntimeFactory = jsRuntimeFactory,
6464
turboModuleManagerDelegateBuilder = DefaultTurboModuleManagerDelegate.Builder())
6565
val reactJsExceptionHandler = ReactJsExceptionHandler { _ -> }
6666
val componentFactory = ComponentFactory()

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHostDelegate.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import com.facebook.react.bridge.JSBundleLoader
1414
import com.facebook.react.common.annotations.UnstableReactNativeAPI
1515
import com.facebook.react.fabric.ReactNativeConfig
1616
import com.facebook.react.runtime.BindingsInstaller
17-
import com.facebook.react.runtime.JSEngineInstance
17+
import com.facebook.react.runtime.JSRuntimeFactory
1818
import com.facebook.react.runtime.ReactHostDelegate
1919
import com.facebook.react.runtime.hermes.HermesInstance
2020

@@ -28,7 +28,7 @@ import com.facebook.react.runtime.hermes.HermesInstance
2828
* @param jsBundleLoader Bundle loader to use when setting up JS environment. <p>Example:
2929
* [JSBundleLoader.createFileLoader(application, bundleFile)]
3030
* @param reactPackages list of reactPackages to expose Native Modules and View Components to JS
31-
* @param jsEngineInstance Object that holds a native reference to the javascript engine
31+
* @param jsRuntimeFactory Object that holds a native reference to the JS Runtime factory
3232
* @param bindingsInstaller Object that holds a native C++ references that allow host applications
3333
* to install C++ objects into jsi::Runtime during the initialization of React Native
3434
* @param reactNativeConfig ReactNative Configuration that allows to customize the behavior of
@@ -42,7 +42,7 @@ class DefaultReactHostDelegate(
4242
override val jsMainModulePath: String,
4343
override val jsBundleLoader: JSBundleLoader,
4444
override val reactPackages: List<ReactPackage> = emptyList(),
45-
override val jsEngineInstance: JSEngineInstance = HermesInstance(),
45+
override val jsRuntimeFactory: JSRuntimeFactory = HermesInstance(),
4646
override val bindingsInstaller: BindingsInstaller = DefaultBindingsInstaller(),
4747
private val reactNativeConfig: ReactNativeConfig = ReactNativeConfig.DEFAULT_CONFIG,
4848
private val exceptionHandler: (Exception) -> Unit = {},

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSCInstance.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import com.facebook.soloader.SoLoader;
1414

1515
@Nullsafe(Nullsafe.Mode.LOCAL)
16-
public class JSCInstance extends JSEngineInstance {
16+
public class JSCInstance extends JSRuntimeFactory {
1717
static {
1818
SoLoader.loadLibrary("jscinstance");
1919
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSEngineInstance.java renamed to packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSRuntimeFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
import com.facebook.soloader.SoLoader;
1414

1515
@Nullsafe(Nullsafe.Mode.LOCAL)
16-
public abstract class JSEngineInstance {
16+
public abstract class JSRuntimeFactory {
1717
static {
1818
SoLoader.loadLibrary("rninstance");
1919
}
2020

2121
@DoNotStrip private final HybridData mHybridData;
2222

23-
protected JSEngineInstance(HybridData hybridData) {
23+
protected JSRuntimeFactory(HybridData hybridData) {
2424
mHybridData = hybridData;
2525
}
2626
}

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostDelegate.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ interface ReactHostDelegate {
3838
val reactPackages: List<ReactPackage>
3939

4040
/** Object that holds a native reference to the javascript engine */
41-
val jsEngineInstance: JSEngineInstance
41+
val jsRuntimeFactory: JSRuntimeFactory
4242

4343
/**
4444
* Bundle loader to use when setting up JS environment. <p>Example:
@@ -68,7 +68,7 @@ interface ReactHostDelegate {
6868
class ReactHostDelegateBase(
6969
override val jsMainModulePath: String,
7070
override val jsBundleLoader: JSBundleLoader,
71-
override val jsEngineInstance: JSEngineInstance,
71+
override val jsRuntimeFactory: JSRuntimeFactory,
7272
override val turboModuleManagerDelegateBuilder:
7373
ReactPackageTurboModuleManagerDelegate.Builder,
7474
override val reactPackages: List<ReactPackage> = emptyList(),

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public void onHostDestroy() {
167167
}
168168
});
169169

170-
JSEngineInstance jsEngineInstance = mDelegate.getJsEngineInstance();
170+
JSRuntimeFactory jsRuntimeFactory = mDelegate.getJsRuntimeFactory();
171171
BindingsInstaller bindingsInstaller = mDelegate.getBindingsInstaller();
172172
// Notify JS if profiling is enabled
173173
boolean isProfiling =
@@ -177,7 +177,7 @@ public void onHostDestroy() {
177177
boolean useModernRuntimeScheduler = ReactFeatureFlags.useModernRuntimeScheduler;
178178
mHybridData =
179179
initHybrid(
180-
jsEngineInstance,
180+
jsRuntimeFactory,
181181
jsMessageQueueThread,
182182
nativeModulesMessageQueueThread,
183183
mJavaTimerManager,
@@ -432,7 +432,7 @@ public Collection<NativeModule> getNativeModules() {
432432

433433
@DoNotStrip
434434
private native HybridData initHybrid(
435-
JSEngineInstance jsEngineInstance,
435+
JSRuntimeFactory jsRuntimeFactory,
436436
MessageQueueThread jsMessageQueueThread,
437437
MessageQueueThread nativeModulesMessageQueueThread,
438438
JavaTimerManager timerManager,

packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/hermes/HermesInstance.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ package com.facebook.react.runtime.hermes
1010
import com.facebook.jni.HybridData
1111
import com.facebook.jni.annotations.DoNotStrip
1212
import com.facebook.react.fabric.ReactNativeConfig
13-
import com.facebook.react.runtime.JSEngineInstance
13+
import com.facebook.react.runtime.JSRuntimeFactory
1414
import com.facebook.soloader.SoLoader
1515

1616
class HermesInstance constructor(reactNativeConfig: ReactNativeConfig?) :
17-
JSEngineInstance(initHybrid(reactNativeConfig as Any?)) {
17+
JSRuntimeFactory(initHybrid(reactNativeConfig as Any?)) {
1818

1919
constructor() : this(null)
2020

packages/react-native/ReactAndroid/src/main/jni/react/runtime/hermes/jni/JHermesInstance.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
#include <jni.h>
1515
#include <jsi/jsi.h>
1616
#include <react/config/ReactNativeConfig.h>
17-
#include <react/runtime/JSEngineInstance.h>
17+
#include <react/runtime/JSRuntimeFactory.h>
1818
#include <react/runtime/hermes/HermesInstance.h>
19-
#include "../../jni/JJSEngineInstance.h"
19+
#include "../../jni/JJSRuntimeFactory.h"
2020

2121
namespace facebook::react {
2222

2323
class JHermesInstance
24-
: public jni::HybridClass<JHermesInstance, JJSEngineInstance> {
24+
: public jni::HybridClass<JHermesInstance, JJSRuntimeFactory> {
2525
public:
2626
static constexpr auto kJavaDescriptor =
2727
"Lcom/facebook/react/runtime/hermes/HermesInstance;";

packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JJSEngineInstance.h renamed to packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JJSRuntimeFactory.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99

1010
#include <fbjni/fbjni.h>
1111
#include <jni.h>
12-
#include <react/runtime/JSEngineInstance.h>
12+
#include <react/runtime/JSRuntimeFactory.h>
1313

1414
namespace facebook::react {
1515

16-
class JJSEngineInstance : public jni::HybridClass<JJSEngineInstance>,
17-
public JSEngineInstance {
16+
class JJSRuntimeFactory : public jni::HybridClass<JJSRuntimeFactory>,
17+
public JSRuntimeFactory {
1818
public:
1919
static auto constexpr kJavaDescriptor =
20-
"Lcom/facebook/react/runtime/JSEngineInstance;";
20+
"Lcom/facebook/react/runtime/JSRuntimeFactory;";
2121

2222
private:
2323
friend HybridBase;

0 commit comments

Comments
 (0)