From e98820843bc441db79cddcd8c5affcf99a16131c Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Tue, 21 Nov 2023 07:01:51 -0800 Subject: [PATCH] Rename JSEngineInstance -> JSRuntimeFactory (#41548) Summary: `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 --- .../Libraries/AppDelegate/RCTAppDelegate.mm | 8 ++++---- .../com/facebook/react/defaults/DefaultReactHost.kt | 4 ++-- .../react/defaults/DefaultReactHostDelegate.kt | 6 +++--- .../java/com/facebook/react/runtime/JSCInstance.java | 2 +- .../{JSEngineInstance.java => JSRuntimeFactory.java} | 4 ++-- .../com/facebook/react/runtime/ReactHostDelegate.kt | 4 ++-- .../java/com/facebook/react/runtime/ReactInstance.java | 6 +++--- .../facebook/react/runtime/hermes/HermesInstance.kt | 4 ++-- .../jni/react/runtime/hermes/jni/JHermesInstance.h | 6 +++--- .../jni/{JJSEngineInstance.h => JJSRuntimeFactory.h} | 8 ++++---- .../src/main/jni/react/runtime/jni/JReactInstance.cpp | 8 ++++---- .../src/main/jni/react/runtime/jni/JReactInstance.h | 8 ++++---- .../src/main/jni/react/runtime/jsc/jni/OnLoad.cpp | 6 +++--- .../facebook/react/runtime/ReactHostDelegateTest.kt | 4 ++-- .../runtime/{JSEngineInstance.h => JSRuntimeFactory.h} | 6 +++--- .../ReactCommon/react/runtime/iostests/RCTHostTests.mm | 2 +- .../platform/ios/ReactCommon/RCTHermesInstance.h | 4 ++-- .../react/runtime/platform/ios/ReactCommon/RCTHost.h | 4 ++-- .../react/runtime/platform/ios/ReactCommon/RCTHost.mm | 8 ++++---- .../runtime/platform/ios/ReactCommon/RCTInstance.h | 4 ++-- .../runtime/platform/ios/ReactCommon/RCTInstance.mm | 10 +++++----- .../runtime/platform/ios/ReactCommon/RCTJscInstance.h | 4 ++-- .../react/test_utils/ios/Shims/ShimRCTInstance.mm | 6 +++--- 23 files changed, 63 insertions(+), 63 deletions(-) rename packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/{JSEngineInstance.java => JSRuntimeFactory.java} (85%) rename packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/{JJSEngineInstance.h => JJSRuntimeFactory.h} (64%) rename packages/react-native/ReactCommon/react/runtime/{JSEngineInstance.h => JSRuntimeFactory.h} (79%) diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm index b2982786800026..3f3bb759ba63e8 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm @@ -38,7 +38,7 @@ #import #import #import -#import +#import static NSString *const kRNConcurrentRoot = @"concurrentRoot"; @@ -293,8 +293,8 @@ - (void)createReactHost _reactHost = [[RCTHost alloc] initWithBundleURL:[self bundleURL] hostDelegate:nil turboModuleManagerDelegate:self - jsEngineProvider:^std::shared_ptr() { - return [weakSelf createJSEngineInstance]; + jsEngineProvider:^std::shared_ptr() { + return [weakSelf createJSRuntimeFactory]; }]; [_reactHost setBundleURLProvider:^NSURL *() { return [weakSelf bundleURL]; @@ -303,7 +303,7 @@ - (void)createReactHost [_reactHost start]; } -- (std::shared_ptr)createJSEngineInstance +- (std::shared_ptr)createJSRuntimeFactory { #if RCT_USE_HERMES return std::make_shared(_reactNativeConfig, nullptr); diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt index d481e33c0bd1d9..9a102597199dc1 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHost.kt @@ -54,13 +54,13 @@ object DefaultReactHost { if (reactHost == null) { val jsBundleLoader = JSBundleLoader.createAssetLoader(context, "assets://$jsBundleAssetPath", true) - val jsEngineInstance = if (isHermesEnabled) HermesInstance() else JSCInstance() + val jsRuntimeFactory = if (isHermesEnabled) HermesInstance() else JSCInstance() val defaultReactHostDelegate = DefaultReactHostDelegate( jsMainModulePath = jsMainModulePath, jsBundleLoader = jsBundleLoader, reactPackages = packageList, - jsEngineInstance = jsEngineInstance, + jsRuntimeFactory = jsRuntimeFactory, turboModuleManagerDelegateBuilder = DefaultTurboModuleManagerDelegate.Builder()) val reactJsExceptionHandler = ReactJsExceptionHandler { _ -> } val componentFactory = ComponentFactory() diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHostDelegate.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHostDelegate.kt index 7221334217754f..40529ef869842e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHostDelegate.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/defaults/DefaultReactHostDelegate.kt @@ -14,7 +14,7 @@ import com.facebook.react.bridge.JSBundleLoader import com.facebook.react.common.annotations.UnstableReactNativeAPI import com.facebook.react.fabric.ReactNativeConfig import com.facebook.react.runtime.BindingsInstaller -import com.facebook.react.runtime.JSEngineInstance +import com.facebook.react.runtime.JSRuntimeFactory import com.facebook.react.runtime.ReactHostDelegate import com.facebook.react.runtime.hermes.HermesInstance @@ -28,7 +28,7 @@ import com.facebook.react.runtime.hermes.HermesInstance * @param jsBundleLoader Bundle loader to use when setting up JS environment.

Example: * [JSBundleLoader.createFileLoader(application, bundleFile)] * @param reactPackages list of reactPackages to expose Native Modules and View Components to JS - * @param jsEngineInstance Object that holds a native reference to the javascript engine + * @param jsRuntimeFactory Object that holds a native reference to the JS Runtime factory * @param bindingsInstaller Object that holds a native C++ references that allow host applications * to install C++ objects into jsi::Runtime during the initialization of React Native * @param reactNativeConfig ReactNative Configuration that allows to customize the behavior of @@ -42,7 +42,7 @@ class DefaultReactHostDelegate( override val jsMainModulePath: String, override val jsBundleLoader: JSBundleLoader, override val reactPackages: List = emptyList(), - override val jsEngineInstance: JSEngineInstance = HermesInstance(), + override val jsRuntimeFactory: JSRuntimeFactory = HermesInstance(), override val bindingsInstaller: BindingsInstaller = DefaultBindingsInstaller(), private val reactNativeConfig: ReactNativeConfig = ReactNativeConfig.DEFAULT_CONFIG, private val exceptionHandler: (Exception) -> Unit = {}, diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSCInstance.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSCInstance.java index 8fb32073cfafed..0524c58eac2312 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSCInstance.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSCInstance.java @@ -13,7 +13,7 @@ import com.facebook.soloader.SoLoader; @Nullsafe(Nullsafe.Mode.LOCAL) -public class JSCInstance extends JSEngineInstance { +public class JSCInstance extends JSRuntimeFactory { static { SoLoader.loadLibrary("jscinstance"); } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSEngineInstance.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSRuntimeFactory.java similarity index 85% rename from packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSEngineInstance.java rename to packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSRuntimeFactory.java index 708e71676641d3..83d3e9f841a801 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSEngineInstance.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/JSRuntimeFactory.java @@ -13,14 +13,14 @@ import com.facebook.soloader.SoLoader; @Nullsafe(Nullsafe.Mode.LOCAL) -public abstract class JSEngineInstance { +public abstract class JSRuntimeFactory { static { SoLoader.loadLibrary("rninstance"); } @DoNotStrip private final HybridData mHybridData; - protected JSEngineInstance(HybridData hybridData) { + protected JSRuntimeFactory(HybridData hybridData) { mHybridData = hybridData; } } diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostDelegate.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostDelegate.kt index a26880fc71df4b..6b9f71d1f6f02f 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostDelegate.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactHostDelegate.kt @@ -38,7 +38,7 @@ interface ReactHostDelegate { val reactPackages: List /** Object that holds a native reference to the javascript engine */ - val jsEngineInstance: JSEngineInstance + val jsRuntimeFactory: JSRuntimeFactory /** * Bundle loader to use when setting up JS environment.

Example: @@ -68,7 +68,7 @@ interface ReactHostDelegate { class ReactHostDelegateBase( override val jsMainModulePath: String, override val jsBundleLoader: JSBundleLoader, - override val jsEngineInstance: JSEngineInstance, + override val jsRuntimeFactory: JSRuntimeFactory, override val turboModuleManagerDelegateBuilder: ReactPackageTurboModuleManagerDelegate.Builder, override val reactPackages: List = emptyList(), diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java index 8d1b0a52137571..e5e36fe7709deb 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.java @@ -167,7 +167,7 @@ public void onHostDestroy() { } }); - JSEngineInstance jsEngineInstance = mDelegate.getJsEngineInstance(); + JSRuntimeFactory jsRuntimeFactory = mDelegate.getJsRuntimeFactory(); BindingsInstaller bindingsInstaller = mDelegate.getBindingsInstaller(); // Notify JS if profiling is enabled boolean isProfiling = @@ -177,7 +177,7 @@ public void onHostDestroy() { boolean useModernRuntimeScheduler = ReactFeatureFlags.useModernRuntimeScheduler; mHybridData = initHybrid( - jsEngineInstance, + jsRuntimeFactory, jsMessageQueueThread, nativeModulesMessageQueueThread, mJavaTimerManager, @@ -432,7 +432,7 @@ public Collection getNativeModules() { @DoNotStrip private native HybridData initHybrid( - JSEngineInstance jsEngineInstance, + JSRuntimeFactory jsRuntimeFactory, MessageQueueThread jsMessageQueueThread, MessageQueueThread nativeModulesMessageQueueThread, JavaTimerManager timerManager, diff --git a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/hermes/HermesInstance.kt b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/hermes/HermesInstance.kt index 7c96e99b6a5c4e..e20bc7ca0b474e 100644 --- a/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/hermes/HermesInstance.kt +++ b/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/runtime/hermes/HermesInstance.kt @@ -10,11 +10,11 @@ package com.facebook.react.runtime.hermes import com.facebook.jni.HybridData import com.facebook.jni.annotations.DoNotStrip import com.facebook.react.fabric.ReactNativeConfig -import com.facebook.react.runtime.JSEngineInstance +import com.facebook.react.runtime.JSRuntimeFactory import com.facebook.soloader.SoLoader class HermesInstance constructor(reactNativeConfig: ReactNativeConfig?) : - JSEngineInstance(initHybrid(reactNativeConfig as Any?)) { + JSRuntimeFactory(initHybrid(reactNativeConfig as Any?)) { constructor() : this(null) diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/hermes/jni/JHermesInstance.h b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/hermes/jni/JHermesInstance.h index 9d500aaa3c3c30..abc417cc065433 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/hermes/jni/JHermesInstance.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/hermes/jni/JHermesInstance.h @@ -14,14 +14,14 @@ #include #include #include -#include +#include #include -#include "../../jni/JJSEngineInstance.h" +#include "../../jni/JJSRuntimeFactory.h" namespace facebook::react { class JHermesInstance - : public jni::HybridClass { + : public jni::HybridClass { public: static constexpr auto kJavaDescriptor = "Lcom/facebook/react/runtime/hermes/HermesInstance;"; diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JJSEngineInstance.h b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JJSRuntimeFactory.h similarity index 64% rename from packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JJSEngineInstance.h rename to packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JJSRuntimeFactory.h index 06619c451c6805..03c312cd378dbc 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JJSEngineInstance.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JJSRuntimeFactory.h @@ -9,15 +9,15 @@ #include #include -#include +#include namespace facebook::react { -class JJSEngineInstance : public jni::HybridClass, - public JSEngineInstance { +class JJSRuntimeFactory : public jni::HybridClass, + public JSRuntimeFactory { public: static auto constexpr kJavaDescriptor = - "Lcom/facebook/react/runtime/JSEngineInstance;"; + "Lcom/facebook/react/runtime/JSRuntimeFactory;"; private: friend HybridBase; diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp index 325c3c32d0646d..09a46dc4e58c90 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.cpp @@ -29,7 +29,7 @@ namespace facebook::react { JReactInstance::JReactInstance( - jni::alias_ref jsEngineInstance, + jni::alias_ref jsRuntimeFactory, jni::alias_ref jsMessageQueueThread, jni::alias_ref nativeMessageQueueThread, jni::alias_ref javaTimerManager, @@ -62,7 +62,7 @@ JReactInstance::JReactInstance( jBindingsInstaller_ = jni::make_global(jBindingsInstaller); instance_ = std::make_unique( - jsEngineInstance->cthis()->createJSRuntime(sharedJSMessageQueueThread), + jsRuntimeFactory->cthis()->createJSRuntime(sharedJSMessageQueueThread), sharedJSMessageQueueThread, timerManager, std::move(jsErrorHandlingFunc), @@ -110,7 +110,7 @@ JReactInstance::JReactInstance( jni::local_ref JReactInstance::initHybrid( jni::alias_ref /* unused */, - jni::alias_ref jsEngineInstance, + jni::alias_ref jsRuntimeFactory, jni::alias_ref jsMessageQueueThread, jni::alias_ref nativeMessageQueueThread, jni::alias_ref javaTimerManager, @@ -120,7 +120,7 @@ jni::local_ref JReactInstance::initHybrid( bool isProfiling, bool useModernRuntimeScheduler) { return makeCxxInstance( - jsEngineInstance, + jsRuntimeFactory, jsMessageQueueThread, nativeMessageQueueThread, javaTimerManager, diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.h b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.h index 0fd9a28a438a28..41ea4891bd50bf 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.h +++ b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jni/JReactInstance.h @@ -18,12 +18,12 @@ #include #include #include -#include +#include #include #include #include "JBindingsInstaller.h" -#include "JJSEngineInstance.h" +#include "JJSRuntimeFactory.h" #include "JJSTimerExecutor.h" #include "JJavaTimerManager.h" #include "JReactExceptionManager.h" @@ -37,7 +37,7 @@ class JReactInstance : public jni::HybridClass { static jni::local_ref initHybrid( jni::alias_ref, - jni::alias_ref jsEngineInstance, + jni::alias_ref jsRuntimeFactory, jni::alias_ref jsMessageQueueThread, jni::alias_ref nativeMessageQueueThread, @@ -83,7 +83,7 @@ class JReactInstance : public jni::HybridClass { friend HybridBase; explicit JReactInstance( - jni::alias_ref jsEngineInstance, + jni::alias_ref jsRuntimeFactory, jni::alias_ref jsMessageQueueThread, jni::alias_ref nativeMessageQueueThread, diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jsc/jni/OnLoad.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jsc/jni/OnLoad.cpp index 02e384cac712dd..068e02b41b8767 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jsc/jni/OnLoad.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/runtime/jsc/jni/OnLoad.cpp @@ -10,12 +10,12 @@ #include #include #include -#include -#include +#include +#include namespace facebook::react { -class JSCInstance : public jni::HybridClass { +class JSCInstance : public jni::HybridClass { public: static constexpr auto kJavaDescriptor = "Lcom/facebook/react/runtime/JSCInstance;"; diff --git a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/runtime/ReactHostDelegateTest.kt b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/runtime/ReactHostDelegateTest.kt index 33932b8a87bf34..0407c0ae127f25 100644 --- a/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/runtime/ReactHostDelegateTest.kt +++ b/packages/react-native/ReactAndroid/src/test/java/com/facebook/react/runtime/ReactHostDelegateTest.kt @@ -34,13 +34,13 @@ class ReactHostDelegateTest { val jsBundleLoader: JSBundleLoader = Mockito.mock(JSBundleLoader::class.java) val turboModuleManagerDelegateBuilderMock: ReactPackageTurboModuleManagerDelegate.Builder = Mockito.mock(ReactPackageTurboModuleManagerDelegate.Builder::class.java) - val hermesInstance: JSEngineInstance = Mockito.mock(HermesInstance::class.java) + val hermesInstance: JSRuntimeFactory = Mockito.mock(HermesInstance::class.java) val jsMainModulePathMocked = "mockedJSMainModulePath" val delegate = DefaultReactHostDelegate( jsMainModulePath = jsMainModulePathMocked, jsBundleLoader = jsBundleLoader, - jsEngineInstance = hermesInstance, + jsRuntimeFactory = hermesInstance, turboModuleManagerDelegateBuilder = turboModuleManagerDelegateBuilderMock) assertThat(delegate.jsMainModulePath).isEqualTo(jsMainModulePathMocked) diff --git a/packages/react-native/ReactCommon/react/runtime/JSEngineInstance.h b/packages/react-native/ReactCommon/react/runtime/JSRuntimeFactory.h similarity index 79% rename from packages/react-native/ReactCommon/react/runtime/JSEngineInstance.h rename to packages/react-native/ReactCommon/react/runtime/JSRuntimeFactory.h index 30cf7025c96eaf..431a2930650444 100644 --- a/packages/react-native/ReactCommon/react/runtime/JSEngineInstance.h +++ b/packages/react-native/ReactCommon/react/runtime/JSRuntimeFactory.h @@ -14,14 +14,14 @@ namespace facebook::react { /** - * Interface for a class that creates and owns an instance of a JS VM + * Interface for a class that creates instances of a JS VM */ -class JSEngineInstance { +class JSRuntimeFactory { public: virtual std::unique_ptr createJSRuntime( std::shared_ptr msgQueueThread) noexcept = 0; - virtual ~JSEngineInstance() = default; + virtual ~JSRuntimeFactory() = default; }; } // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/runtime/iostests/RCTHostTests.mm b/packages/react-native/ReactCommon/react/runtime/iostests/RCTHostTests.mm index 606d2d9dabd1f1..de2e016b95afc4 100644 --- a/packages/react-native/ReactCommon/react/runtime/iostests/RCTHostTests.mm +++ b/packages/react-native/ReactCommon/react/runtime/iostests/RCTHostTests.mm @@ -56,7 +56,7 @@ - (void)setUp _subject = [[RCTHost alloc] initWithBundleURL:OCMClassMock([NSURL class]) hostDelegate:_mockHostDelegate turboModuleManagerDelegate:OCMProtocolMock(@protocol(RCTTurboModuleManagerDelegate)) - jsEngineProvider:^std::shared_ptr() { + jsEngineProvider:^std::shared_ptr() { return std::make_shared(); }]; } diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHermesInstance.h b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHermesInstance.h index 0f3722443945dc..d811aa6335652d 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHermesInstance.h +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHermesInstance.h @@ -10,7 +10,7 @@ #import #import #import -#import +#import #import namespace facebook { @@ -19,7 +19,7 @@ using CrashManagerProvider = std::function()>; // ObjC++ wrapper for HermesInstance.cpp -class RCTHermesInstance : public JSEngineInstance { +class RCTHermesInstance : public JSRuntimeFactory { public: RCTHermesInstance(); RCTHermesInstance( diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.h b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.h index 3dc528f8a506ec..124504a638f997 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.h +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.h @@ -9,7 +9,7 @@ #import #import -#import +#import #import "RCTInstance.h" @@ -53,7 +53,7 @@ NS_ASSUME_NONNULL_BEGIN @end -typedef std::shared_ptr (^RCTHostJSEngineProvider)(void); +typedef std::shared_ptr (^RCTHostJSEngineProvider)(void); @interface RCTHost : NSObject diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm index 53ddc5cab4368b..64daf56c38d7be 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTHost.mm @@ -147,7 +147,7 @@ - (void)start [_instance invalidate]; } _instance = [[RCTInstance alloc] initWithDelegate:self - jsEngineInstance:[self _provideJSEngine] + jsRuntimeFactory:[self _provideJSEngine] bundleManager:_bundleManager turboModuleManagerDelegate:_turboModuleManagerDelegate onInitialBundleLoad:_onInitialBundleLoad @@ -214,7 +214,7 @@ - (void)didReceiveReloadCommand } _instance = [[RCTInstance alloc] initWithDelegate:self - jsEngineInstance:[self _provideJSEngine] + jsRuntimeFactory:[self _provideJSEngine] bundleManager:_bundleManager turboModuleManagerDelegate:_turboModuleManagerDelegate onInitialBundleLoad:_onInitialBundleLoad @@ -301,10 +301,10 @@ - (void)_attachSurface:(RCTFabricSurface *)surface return surfaces; } -- (std::shared_ptr)_provideJSEngine +- (std::shared_ptr)_provideJSEngine { RCTAssert(_jsEngineProvider, @"_jsEngineProvider must be non-nil"); - std::shared_ptr jsEngine = _jsEngineProvider(); + std::shared_ptr jsEngine = _jsEngineProvider(); RCTAssert(jsEngine != nullptr, @"_jsEngineProvider must return a nonnull pointer"); return jsEngine; diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.h b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.h index 79e9ff50e2e9ee..047dc38af97774 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.h +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.h @@ -9,7 +9,7 @@ #import #import -#import +#import #import #import "RCTContextContainerHandling.h" @@ -68,7 +68,7 @@ typedef void (^_Null_unspecified RCTInstanceInitialBundleLoadCompletionBlock)(); @interface RCTInstance : NSObject - (instancetype)initWithDelegate:(id)delegate - jsEngineInstance:(std::shared_ptr)jsEngineInstance + jsRuntimeFactory:(std::shared_ptr)jsRuntimeFactory bundleManager:(RCTBundleManager *)bundleManager turboModuleManagerDelegate:(id)turboModuleManagerDelegate onInitialBundleLoad:(RCTInstanceInitialBundleLoadCompletionBlock)onInitialBundleLoad diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm index bf5bd8fe6ba42d..6ed73ed4d85814 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm @@ -67,7 +67,7 @@ @interface RCTInstance () @implementation RCTInstance { std::unique_ptr _reactInstance; - std::shared_ptr _jsEngineInstance; + std::shared_ptr _jsRuntimeFactory; __weak id _appTMMDelegate; __weak id _delegate; RCTSurfacePresenter *_surfacePresenter; @@ -86,7 +86,7 @@ @implementation RCTInstance { #pragma mark - Public - (instancetype)initWithDelegate:(id)delegate - jsEngineInstance:(std::shared_ptr)jsEngineInstance + jsRuntimeFactory:(std::shared_ptr)jsRuntimeFactory bundleManager:(RCTBundleManager *)bundleManager turboModuleManagerDelegate:(id)tmmDelegate onInitialBundleLoad:(RCTInstanceInitialBundleLoadCompletionBlock)onInitialBundleLoad @@ -98,7 +98,7 @@ - (instancetype)initWithDelegate:(id)delegate [_performanceLogger markStartForTag:RCTPLReactInstanceInit]; _delegate = delegate; - _jsEngineInstance = jsEngineInstance; + _jsRuntimeFactory = jsRuntimeFactory; _appTMMDelegate = tmmDelegate; _jsThreadManager = [RCTJSThreadManager new]; _onInitialBundleLoad = onInitialBundleLoad; @@ -149,7 +149,7 @@ - (void)invalidate // Clean up all the Resources self->_reactInstance = nullptr; - self->_jsEngineInstance = nullptr; + self->_jsRuntimeFactory = nullptr; self->_appTMMDelegate = nil; self->_delegate = nil; self->_displayLink = nil; @@ -223,7 +223,7 @@ - (void)_start // Create the React Instance _reactInstance = std::make_unique( - _jsEngineInstance->createJSRuntime(_jsThreadManager.jsMessageThread), + _jsRuntimeFactory->createJSRuntime(_jsThreadManager.jsMessageThread), _jsThreadManager.jsMessageThread, timerManager, jsErrorHandlingFunc, diff --git a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTJscInstance.h b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTJscInstance.h index bcb1393519d1b8..8ad3220f45d309 100644 --- a/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTJscInstance.h +++ b/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTJscInstance.h @@ -7,12 +7,12 @@ #import #import -#import +#import namespace facebook { namespace react { -class RCTJscInstance : public JSEngineInstance { +class RCTJscInstance : public JSRuntimeFactory { public: RCTJscInstance(); diff --git a/packages/react-native/ReactCommon/react/test_utils/ios/Shims/ShimRCTInstance.mm b/packages/react-native/ReactCommon/react/test_utils/ios/Shims/ShimRCTInstance.mm index 77476f9dfd3d52..884448d45b2c84 100644 --- a/packages/react-native/ReactCommon/react/test_utils/ios/Shims/ShimRCTInstance.mm +++ b/packages/react-native/ReactCommon/react/test_utils/ios/Shims/ShimRCTInstance.mm @@ -23,7 +23,7 @@ - (instancetype)init [RCTInstance class], [ShimRCTInstance class], @selector(initWithDelegate: - jsEngineInstance:bundleManager:turboModuleManagerDelegate:onInitialBundleLoad:moduleRegistry:)); + jsRuntimeFactory:bundleManager:turboModuleManagerDelegate:onInitialBundleLoad:moduleRegistry:)); RCTSwizzleInstanceSelector([RCTInstance class], [ShimRCTInstance class], @selector(invalidate)); RCTSwizzleInstanceSelector( [RCTInstance class], [ShimRCTInstance class], @selector(callFunctionOnJSModule:method:args:)); @@ -38,7 +38,7 @@ - (void)reset [RCTInstance class], [ShimRCTInstance class], @selector(initWithDelegate: - jsEngineInstance:bundleManager:turboModuleManagerDelegate:onInitialBundleLoad:moduleRegistry:)); + jsRuntimeFactory:bundleManager:turboModuleManagerDelegate:onInitialBundleLoad:moduleRegistry:)); RCTSwizzleInstanceSelector([RCTInstance class], [ShimRCTInstance class], @selector(invalidate)); RCTSwizzleInstanceSelector( [RCTInstance class], [ShimRCTInstance class], @selector(callFunctionOnJSModule:method:args:)); @@ -47,7 +47,7 @@ - (void)reset } - (instancetype)initWithDelegate:(id)delegate - jsEngineInstance:(std::shared_ptr)jsEngineInstance + jsRuntimeFactory:(std::shared_ptr)jsRuntimeFactory bundleManager:(RCTBundleManager *)bundleManager turboModuleManagerDelegate:(id)tmmDelegate onInitialBundleLoad:(RCTInstanceInitialBundleLoadCompletionBlock)onInitialBundleLoad