#pragma once #include #include #include #include #include "AnimatedSensorModule.h" #include "ErrorHandler.h" #include "LayoutAnimationsProxy.h" #include "NativeReanimatedModuleSpec.h" #include "PlatformDepMethodsHolder.h" #include "RuntimeDecorator.h" #include "RuntimeManager.h" #include "Scheduler.h" #include "SingleInstanceChecker.h" namespace reanimated { using FrameCallback = std::function; class ShareableValue; class MutableValue; class MapperRegistry; class EventHandlerRegistry; class NativeReanimatedModule : public NativeReanimatedModuleSpec, public RuntimeManager { friend ShareableValue; friend MutableValue; public: NativeReanimatedModule( std::shared_ptr jsInvoker, std::shared_ptr scheduler, std::shared_ptr rt, std::shared_ptr errorHandler, std::function propObtainer, std::shared_ptr layoutAnimationsProxy, PlatformDepMethodsHolder platformDepMethodsHolder); void installCoreFunctions(jsi::Runtime &rt, const jsi::Value &valueSetter) override; jsi::Value makeShareable(jsi::Runtime &rt, const jsi::Value &value) override; jsi::Value makeMutable(jsi::Runtime &rt, const jsi::Value &value) override; jsi::Value makeRemote(jsi::Runtime &rt, const jsi::Value &value) override; jsi::Value startMapper( jsi::Runtime &rt, const jsi::Value &worklet, const jsi::Value &inputs, const jsi::Value &outputs, const jsi::Value &updater, const jsi::Value &viewDescriptors) override; void stopMapper(jsi::Runtime &rt, const jsi::Value &mapperId) override; jsi::Value registerEventHandler( jsi::Runtime &rt, const jsi::Value &eventHash, const jsi::Value &worklet) override; void unregisterEventHandler( jsi::Runtime &rt, const jsi::Value ®istrationId) override; jsi::Value getViewProp( jsi::Runtime &rt, const jsi::Value &viewTag, const jsi::Value &propName, const jsi::Value &callback) override; jsi::Value enableLayoutAnimations(jsi::Runtime &rt, const jsi::Value &config) override; jsi::Value configureProps( jsi::Runtime &rt, const jsi::Value &uiProps, const jsi::Value &nativeProps) override; void onRender(double timestampMs); void onEvent(std::string eventName, std::string eventAsString); bool isAnyHandlerWaitingForEvent(std::string eventName); void maybeRequestRender(); UpdaterFunction updaterFunction; jsi::Value registerSensor( jsi::Runtime &rt, const jsi::Value &sensorType, const jsi::Value &interval, const jsi::Value &sensorDataContainer) override; void unregisterSensor(jsi::Runtime &rt, const jsi::Value &sensorId) override; jsi::Value subscribeForKeyboardEvents( jsi::Runtime &rt, const jsi::Value &keyboardEventContainer) override; void unsubscribeFromKeyboardEvents( jsi::Runtime &rt, const jsi::Value &listenerId) override; private: std::shared_ptr mapperRegistry; std::shared_ptr eventHandlerRegistry; std::function requestRender; std::shared_ptr dummyEvent; std::vector frameCallbacks; bool renderRequested = false; std::function propObtainer; std::function onRenderCallback; std::shared_ptr layoutAnimationsProxy; AnimatedSensorModule animatedSensorModule; ConfigurePropsFunction configurePropsPlatformFunction; KeyboardEventSubscribeFunction subscribeForKeyboardEventsFunction; KeyboardEventUnsubscribeFunction unsubscribeFromKeyboardEventsFunction; #ifdef DEBUG SingleInstanceChecker singleInstanceChecker_; #endif }; } // namespace reanimated