1*af2ec015STomasz Sapeta #include "ReanimatedRuntime.h" 2*af2ec015STomasz Sapeta 3*af2ec015STomasz Sapeta #include <ABI49_0_0cxxreact/ABI49_0_0MessageQueueThread.h> 4*af2ec015STomasz Sapeta #include <ABI49_0_0jsi/ABI49_0_0jsi.h> 5*af2ec015STomasz Sapeta 6*af2ec015STomasz Sapeta #include <memory> 7*af2ec015STomasz Sapeta #include <utility> 8*af2ec015STomasz Sapeta 9*af2ec015STomasz Sapeta #if JS_RUNTIME_HERMES 10*af2ec015STomasz Sapeta #include "ReanimatedHermesRuntime.h" 11*af2ec015STomasz Sapeta #elif JS_RUNTIME_V8 12*af2ec015STomasz Sapeta #include <v8runtime/V8RuntimeFactory.h> 13*af2ec015STomasz Sapeta #else 14*af2ec015STomasz Sapeta #if ABI49_0_0REACT_NATIVE_MINOR_VERSION >= 71 15*af2ec015STomasz Sapeta #include <jsc/JSCRuntime.h> 16*af2ec015STomasz Sapeta #else 17*af2ec015STomasz Sapeta #include <jsi/JSCRuntime.h> 18*af2ec015STomasz Sapeta #endif // ABI49_0_0REACT_NATIVE_MINOR_VERSION 19*af2ec015STomasz Sapeta #endif // JS_RUNTIME 20*af2ec015STomasz Sapeta 21*af2ec015STomasz Sapeta namespace ABI49_0_0reanimated { 22*af2ec015STomasz Sapeta 23*af2ec015STomasz Sapeta using namespace ABI49_0_0facebook; 24*af2ec015STomasz Sapeta using namespace ABI49_0_0React; 25*af2ec015STomasz Sapeta make(jsi::Runtime * rnRuntime,std::shared_ptr<MessageQueueThread> jsQueue)26*af2ec015STomasz Sapetastd::shared_ptr<jsi::Runtime> ReanimatedRuntime::make( 27*af2ec015STomasz Sapeta jsi::Runtime *rnRuntime, 28*af2ec015STomasz Sapeta std::shared_ptr<MessageQueueThread> jsQueue) { 29*af2ec015STomasz Sapeta #if JS_RUNTIME_HERMES 30*af2ec015STomasz Sapeta std::unique_ptr<ABI49_0_0facebook::ABI49_0_0hermes::HermesRuntime> runtime = 31*af2ec015STomasz Sapeta ABI49_0_0facebook::ABI49_0_0hermes::makeHermesRuntime(); 32*af2ec015STomasz Sapeta 33*af2ec015STomasz Sapeta // We don't call `jsQueue->quitSynchronous()` here, since it will be done 34*af2ec015STomasz Sapeta // later in ReanimatedHermesRuntime 35*af2ec015STomasz Sapeta 36*af2ec015STomasz Sapeta return std::make_shared<ReanimatedHermesRuntime>(std::move(runtime), jsQueue); 37*af2ec015STomasz Sapeta #elif JS_RUNTIME_V8 38*af2ec015STomasz Sapeta // This is required by iOS, because there is an assertion in the destructor 39*af2ec015STomasz Sapeta // that the thread was indeed `quit` before. 40*af2ec015STomasz Sapeta jsQueue->quitSynchronous(); 41*af2ec015STomasz Sapeta 42*af2ec015STomasz Sapeta auto config = std::make_unique<rnv8::V8RuntimeConfig>(); 43*af2ec015STomasz Sapeta config->enableInspector = false; 44*af2ec015STomasz Sapeta config->appName = "reanimated"; 45*af2ec015STomasz Sapeta return rnv8::createSharedV8Runtime(rnRuntime, std::move(config)); 46*af2ec015STomasz Sapeta #else 47*af2ec015STomasz Sapeta // This is required by iOS, because there is an assertion in the destructor 48*af2ec015STomasz Sapeta // that the thread was indeed `quit` before 49*af2ec015STomasz Sapeta jsQueue->quitSynchronous(); 50*af2ec015STomasz Sapeta 51*af2ec015STomasz Sapeta return ABI49_0_0facebook::jsc::makeJSCRuntime(); 52*af2ec015STomasz Sapeta #endif 53*af2ec015STomasz Sapeta } 54*af2ec015STomasz Sapeta 55*af2ec015STomasz Sapeta } // namespace reanimated 56