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