diff --git a/package/android/src/main/cpp/OpenGLError.h b/package/android/src/main/cpp/OpenGLError.h index d213f4c..72e97d0 100644 --- a/package/android/src/main/cpp/OpenGLError.h +++ b/package/android/src/main/cpp/OpenGLError.h @@ -22,8 +22,7 @@ inline std::string getEglErrorIfAny() { class OpenGLError : public std::runtime_error { public: - explicit OpenGLError(const std::string&& message) - : std::runtime_error(message + getEglErrorIfAny()) {} + explicit OpenGLError(const std::string&& message) : std::runtime_error(message + getEglErrorIfAny()) {} static inline void checkIfError(const std::string&& message) { auto error = getEglErrorIfAny(); diff --git a/package/android/src/main/cpp/OpenGLRenderer.cpp b/package/android/src/main/cpp/OpenGLRenderer.cpp index 320015a..3768399 100644 --- a/package/android/src/main/cpp/OpenGLRenderer.cpp +++ b/package/android/src/main/cpp/OpenGLRenderer.cpp @@ -17,9 +17,7 @@ namespace vision { -std::unique_ptr -OpenGLRenderer::CreateWithWindowSurface(std::shared_ptr context, - ANativeWindow* surface) { +std::unique_ptr OpenGLRenderer::CreateWithWindowSurface(std::shared_ptr context, ANativeWindow* surface) { return std::unique_ptr(new OpenGLRenderer(std::move(context), surface)); } diff --git a/package/android/src/main/cpp/OpenGLRenderer.h b/package/android/src/main/cpp/OpenGLRenderer.h index 97223fd..b2b96cb 100644 --- a/package/android/src/main/cpp/OpenGLRenderer.h +++ b/package/android/src/main/cpp/OpenGLRenderer.h @@ -24,8 +24,7 @@ public: * Note: The `surface` is considered moved, and the OpenGL context will release it when it is * being deleted. */ - static std::unique_ptr - CreateWithWindowSurface(std::shared_ptr context, ANativeWindow* surface); + static std::unique_ptr CreateWithWindowSurface(std::shared_ptr context, ANativeWindow* surface); /** * Destroy the OpenGL Context. This needs to be called on the same thread that `use()` was called. */ diff --git a/package/android/src/main/cpp/VideoPipeline.cpp b/package/android/src/main/cpp/VideoPipeline.cpp index d556ada..387e2fc 100644 --- a/package/android/src/main/cpp/VideoPipeline.cpp +++ b/package/android/src/main/cpp/VideoPipeline.cpp @@ -19,13 +19,11 @@ namespace vision { -jni::local_ref -VideoPipeline::initHybrid(jni::alias_ref jThis, int width, int height) { +jni::local_ref VideoPipeline::initHybrid(jni::alias_ref jThis, int width, int height) { return makeCxxInstance(jThis, width, height); } -VideoPipeline::VideoPipeline(jni::alias_ref jThis, int width, int height) - : _javaPart(jni::make_global(jThis)) { +VideoPipeline::VideoPipeline(jni::alias_ref jThis, int width, int height) : _javaPart(jni::make_global(jThis)) { _width = width; _height = height; _context = OpenGLContext::CreateWithOffscreenSurface(); @@ -108,14 +106,10 @@ void VideoPipeline::onFrame(jni::alias_ref transformMatrixPara void VideoPipeline::registerNatives() { registerHybrid({ makeNativeMethod("initHybrid", VideoPipeline::initHybrid), - makeNativeMethod("setFrameProcessorOutputSurface", - VideoPipeline::setFrameProcessorOutputSurface), - makeNativeMethod("removeFrameProcessorOutputSurface", - VideoPipeline::removeFrameProcessorOutputSurface), - makeNativeMethod("setRecordingSessionOutputSurface", - VideoPipeline::setRecordingSessionOutputSurface), - makeNativeMethod("removeRecordingSessionOutputSurface", - VideoPipeline::removeRecordingSessionOutputSurface), + makeNativeMethod("setFrameProcessorOutputSurface", VideoPipeline::setFrameProcessorOutputSurface), + makeNativeMethod("removeFrameProcessorOutputSurface", VideoPipeline::removeFrameProcessorOutputSurface), + makeNativeMethod("setRecordingSessionOutputSurface", VideoPipeline::setRecordingSessionOutputSurface), + makeNativeMethod("removeRecordingSessionOutputSurface", VideoPipeline::removeRecordingSessionOutputSurface), makeNativeMethod("getInputTextureId", VideoPipeline::getInputTextureId), makeNativeMethod("onBeforeFrame", VideoPipeline::onBeforeFrame), makeNativeMethod("onFrame", VideoPipeline::onFrame), diff --git a/package/android/src/main/cpp/VideoPipeline.h b/package/android/src/main/cpp/VideoPipeline.h index b79d0b3..ca2551f 100644 --- a/package/android/src/main/cpp/VideoPipeline.h +++ b/package/android/src/main/cpp/VideoPipeline.h @@ -21,8 +21,7 @@ using namespace facebook; class VideoPipeline : public jni::HybridClass { public: static auto constexpr kJavaDescriptor = "Lcom/mrousavy/camera/core/VideoPipeline;"; - static jni::local_ref initHybrid(jni::alias_ref jThis, int width, - int height); + static jni::local_ref initHybrid(jni::alias_ref jThis, int width, int height); static void registerNatives(); public: diff --git a/package/android/src/main/cpp/frameprocessor/FrameHostObject.cpp b/package/android/src/main/cpp/frameprocessor/FrameHostObject.cpp index 30c5da6..c528c25 100644 --- a/package/android/src/main/cpp/frameprocessor/FrameHostObject.cpp +++ b/package/android/src/main/cpp/frameprocessor/FrameHostObject.cpp @@ -16,8 +16,7 @@ namespace vision { using namespace facebook; -FrameHostObject::FrameHostObject(const jni::alias_ref& frame) - : frame(make_global(frame)) {} +FrameHostObject::FrameHostObject(const jni::alias_ref& frame) : frame(make_global(frame)) {} FrameHostObject::~FrameHostObject() { // Hermes' Garbage Collector (Hades GC) calls destructors on a separate Thread @@ -51,29 +50,25 @@ jsi::Value FrameHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& pr auto name = propName.utf8(runtime); if (name == "incrementRefCount") { - jsi::HostFunctionType incrementRefCount = [=](jsi::Runtime& runtime, const jsi::Value& thisArg, - const jsi::Value* args, + jsi::HostFunctionType incrementRefCount = [=](jsi::Runtime& runtime, const jsi::Value& thisArg, const jsi::Value* args, size_t count) -> jsi::Value { // Increment retain count by one. this->frame->incrementRefCount(); return jsi::Value::undefined(); }; - return jsi::Function::createFromHostFunction( - runtime, jsi::PropNameID::forUtf8(runtime, "incrementRefCount"), 0, incrementRefCount); + return jsi::Function::createFromHostFunction(runtime, jsi::PropNameID::forUtf8(runtime, "incrementRefCount"), 0, incrementRefCount); } if (name == "decrementRefCount") { - auto decrementRefCount = [=](jsi::Runtime& runtime, const jsi::Value& thisArg, - const jsi::Value* args, size_t count) -> jsi::Value { + auto decrementRefCount = [=](jsi::Runtime& runtime, const jsi::Value& thisArg, const jsi::Value* args, size_t count) -> jsi::Value { // Decrement retain count by one. If the retain count is zero, the Frame gets closed. this->frame->decrementRefCount(); return jsi::Value::undefined(); }; - return jsi::Function::createFromHostFunction( - runtime, jsi::PropNameID::forUtf8(runtime, "decrementRefCount"), 0, decrementRefCount); + return jsi::Function::createFromHostFunction(runtime, jsi::PropNameID::forUtf8(runtime, "decrementRefCount"), 0, decrementRefCount); } if (name == "toString") { - jsi::HostFunctionType toString = [=](jsi::Runtime& runtime, const jsi::Value& thisArg, - const jsi::Value* args, size_t count) -> jsi::Value { + jsi::HostFunctionType toString = [=](jsi::Runtime& runtime, const jsi::Value& thisArg, const jsi::Value* args, + size_t count) -> jsi::Value { if (!this->frame) { return jsi::String::createFromUtf8(runtime, "[closed frame]"); } @@ -82,16 +77,14 @@ jsi::Value FrameHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& pr auto str = std::to_string(width) + " x " + std::to_string(height) + " Frame"; return jsi::String::createFromUtf8(runtime, str); }; - return jsi::Function::createFromHostFunction( - runtime, jsi::PropNameID::forUtf8(runtime, "toString"), 0, toString); + return jsi::Function::createFromHostFunction(runtime, jsi::PropNameID::forUtf8(runtime, "toString"), 0, toString); } if (name == "toArrayBuffer") { - jsi::HostFunctionType toArrayBuffer = [=](jsi::Runtime& runtime, const jsi::Value& thisArg, - const jsi::Value* args, size_t count) -> jsi::Value { + jsi::HostFunctionType toArrayBuffer = [=](jsi::Runtime& runtime, const jsi::Value& thisArg, const jsi::Value* args, + size_t count) -> jsi::Value { auto buffer = this->frame->toByteBuffer(); if (!buffer->isDirect()) { - throw std::runtime_error( - "Failed to get byte content of Frame - array is not direct ByteBuffer!"); + throw std::runtime_error("Failed to get byte content of Frame - array is not direct ByteBuffer!"); } auto size = buffer->getDirectSize(); @@ -102,10 +95,8 @@ jsi::Value FrameHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& pr } // Get from global JS cache - auto arrayBufferCache = - runtime.global().getPropertyAsObject(runtime, ARRAYBUFFER_CACHE_PROP_NAME); - auto arrayBuffer = vision::getTypedArray(runtime, arrayBufferCache) - .get(runtime); + auto arrayBufferCache = runtime.global().getPropertyAsObject(runtime, ARRAYBUFFER_CACHE_PROP_NAME); + auto arrayBuffer = vision::getTypedArray(runtime, arrayBufferCache).get(runtime); if (arrayBuffer.size(runtime) != size) { arrayBuffer = vision::TypedArray(runtime, size); runtime.global().setProperty(runtime, ARRAYBUFFER_CACHE_PROP_NAME, arrayBuffer); @@ -117,8 +108,7 @@ jsi::Value FrameHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& pr return arrayBuffer; }; - return jsi::Function::createFromHostFunction( - runtime, jsi::PropNameID::forUtf8(runtime, "toArrayBuffer"), 0, toArrayBuffer); + return jsi::Function::createFromHostFunction(runtime, jsi::PropNameID::forUtf8(runtime, "toArrayBuffer"), 0, toArrayBuffer); } if (name == "isValid") { diff --git a/package/android/src/main/cpp/frameprocessor/FrameProcessorPluginHostObject.cpp b/package/android/src/main/cpp/frameprocessor/FrameProcessorPluginHostObject.cpp index 67b1ac8..e68b26b 100644 --- a/package/android/src/main/cpp/frameprocessor/FrameProcessorPluginHostObject.cpp +++ b/package/android/src/main/cpp/frameprocessor/FrameProcessorPluginHostObject.cpp @@ -12,32 +12,27 @@ namespace vision { using namespace facebook; -std::vector -FrameProcessorPluginHostObject::getPropertyNames(jsi::Runtime& runtime) { +std::vector FrameProcessorPluginHostObject::getPropertyNames(jsi::Runtime& runtime) { std::vector result; result.push_back(jsi::PropNameID::forUtf8(runtime, std::string("call"))); return result; } -jsi::Value FrameProcessorPluginHostObject::get(jsi::Runtime& runtime, - const jsi::PropNameID& propName) { +jsi::Value FrameProcessorPluginHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& propName) { auto name = propName.utf8(runtime); if (name == "call") { return jsi::Function::createFromHostFunction( runtime, jsi::PropNameID::forUtf8(runtime, "call"), 2, - [=](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, - size_t count) -> jsi::Value { + [=](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, size_t count) -> jsi::Value { // Frame is first argument - auto frameHostObject = - arguments[0].asObject(runtime).asHostObject(runtime); + auto frameHostObject = arguments[0].asObject(runtime).asHostObject(runtime); auto frame = frameHostObject->frame; // Options are second argument (possibly undefined) local_ref> options = nullptr; if (count > 1) { - options = - JSIJNIConversion::convertJSIObjectToJNIMap(runtime, arguments[1].asObject(runtime)); + options = JSIJNIConversion::convertJSIObjectToJNIMap(runtime, arguments[1].asObject(runtime)); } // Call actual plugin diff --git a/package/android/src/main/cpp/frameprocessor/FrameProcessorPluginHostObject.h b/package/android/src/main/cpp/frameprocessor/FrameProcessorPluginHostObject.h index 203156a..88e6889 100644 --- a/package/android/src/main/cpp/frameprocessor/FrameProcessorPluginHostObject.h +++ b/package/android/src/main/cpp/frameprocessor/FrameProcessorPluginHostObject.h @@ -16,8 +16,7 @@ using namespace facebook; class FrameProcessorPluginHostObject : public jsi::HostObject { public: - explicit FrameProcessorPluginHostObject(jni::alias_ref plugin) - : _plugin(make_global(plugin)) {} + explicit FrameProcessorPluginHostObject(jni::alias_ref plugin) : _plugin(make_global(plugin)) {} ~FrameProcessorPluginHostObject() {} public: diff --git a/package/android/src/main/cpp/frameprocessor/JSIJNIConversion.cpp b/package/android/src/main/cpp/frameprocessor/JSIJNIConversion.cpp index 3e824d1..b7d8202 100644 --- a/package/android/src/main/cpp/frameprocessor/JSIJNIConversion.cpp +++ b/package/android/src/main/cpp/frameprocessor/JSIJNIConversion.cpp @@ -20,8 +20,7 @@ namespace vision { using namespace facebook; -jni::local_ref> -JSIJNIConversion::convertJSIObjectToJNIMap(jsi::Runtime& runtime, const jsi::Object& object) { +jni::local_ref> JSIJNIConversion::convertJSIObjectToJNIMap(jsi::Runtime& runtime, const jsi::Object& object) { auto propertyNames = object.getPropertyNames(runtime); auto size = propertyNames.size(runtime); auto hashMap = jni::JHashMap::create(); @@ -67,16 +66,14 @@ JSIJNIConversion::convertJSIObjectToJNIMap(jsi::Runtime& runtime, const jsi::Obj } } else { auto stringRepresentation = value.toString(runtime).utf8(runtime); - throw std::runtime_error("Failed to convert jsi::Value to JNI value - unsupported type!" + - stringRepresentation); + throw std::runtime_error("Failed to convert jsi::Value to JNI value - unsupported type!" + stringRepresentation); } } return hashMap; } -jsi::Value JSIJNIConversion::convertJNIObjectToJSIValue(jsi::Runtime& runtime, - const jni::local_ref& object) { +jsi::Value JSIJNIConversion::convertJNIObjectToJSIValue(jsi::Runtime& runtime, const jni::local_ref& object) { if (object == nullptr) { // null @@ -84,22 +81,19 @@ jsi::Value JSIJNIConversion::convertJNIObjectToJSIValue(jsi::Runtime& runtime, } else if (object->isInstanceOf(jni::JBoolean::javaClassStatic())) { // Boolean - static const auto getBooleanFunc = - jni::findClassLocal("java/lang/Boolean")->getMethod("booleanValue"); + static const auto getBooleanFunc = jni::findClassLocal("java/lang/Boolean")->getMethod("booleanValue"); auto boolean = getBooleanFunc(object.get()); return jsi::Value(boolean == true); } else if (object->isInstanceOf(jni::JDouble::javaClassStatic())) { // Double - static const auto getDoubleFunc = - jni::findClassLocal("java/lang/Double")->getMethod("doubleValue"); + static const auto getDoubleFunc = jni::findClassLocal("java/lang/Double")->getMethod("doubleValue"); auto d = getDoubleFunc(object.get()); return jsi::Value(d); } else if (object->isInstanceOf(jni::JInteger::javaClassStatic())) { // Integer - static const auto getIntegerFunc = - jni::findClassLocal("java/lang/Integer")->getMethod("intValue"); + static const auto getIntegerFunc = jni::findClassLocal("java/lang/Integer")->getMethod("intValue"); auto i = getIntegerFunc(object.get()); return jsi::Value(i); } else if (object->isInstanceOf(jni::JString::javaClassStatic())) { diff --git a/package/android/src/main/cpp/frameprocessor/JSIJNIConversion.h b/package/android/src/main/cpp/frameprocessor/JSIJNIConversion.h index f84fff0..5289a32 100644 --- a/package/android/src/main/cpp/frameprocessor/JSIJNIConversion.h +++ b/package/android/src/main/cpp/frameprocessor/JSIJNIConversion.h @@ -14,11 +14,9 @@ namespace JSIJNIConversion { using namespace facebook; - jni::local_ref> convertJSIObjectToJNIMap(jsi::Runtime& runtime, - const jsi::Object& object); + jni::local_ref> convertJSIObjectToJNIMap(jsi::Runtime& runtime, const jsi::Object& object); - jsi::Value convertJNIObjectToJSIValue(jsi::Runtime& runtime, - const jni::local_ref& object); + jsi::Value convertJNIObjectToJSIValue(jsi::Runtime& runtime, const jni::local_ref& object); } // namespace JSIJNIConversion diff --git a/package/android/src/main/cpp/frameprocessor/VisionCameraProxy.cpp b/package/android/src/main/cpp/frameprocessor/VisionCameraProxy.cpp index bbb8c60..b17ebf7 100644 --- a/package/android/src/main/cpp/frameprocessor/VisionCameraProxy.cpp +++ b/package/android/src/main/cpp/frameprocessor/VisionCameraProxy.cpp @@ -27,8 +27,7 @@ namespace vision { using namespace facebook; -VisionCameraProxy::VisionCameraProxy( - const jni::alias_ref& javaProxy) { +VisionCameraProxy::VisionCameraProxy(const jni::alias_ref& javaProxy) { _javaProxy = make_global(javaProxy); } @@ -42,8 +41,7 @@ std::vector VisionCameraProxy::getPropertyNames(jsi::Runtime& r return result; } -void VisionCameraProxy::setFrameProcessor(int viewTag, jsi::Runtime& runtime, - const jsi::Object& object) { +void VisionCameraProxy::setFrameProcessor(int viewTag, jsi::Runtime& runtime, const jsi::Object& object) { _javaProxy->cthis()->setFrameProcessor(viewTag, runtime, object); } @@ -51,9 +49,7 @@ void VisionCameraProxy::removeFrameProcessor(int viewTag) { _javaProxy->cthis()->removeFrameProcessor(viewTag); } -jsi::Value VisionCameraProxy::getFrameProcessorPlugin(jsi::Runtime& runtime, - const std::string& name, - const jsi::Object& jsOptions) { +jsi::Value VisionCameraProxy::getFrameProcessorPlugin(jsi::Runtime& runtime, const std::string& name, const jsi::Object& jsOptions) { auto options = JSIJNIConversion::convertJSIObjectToJNIMap(runtime, jsOptions); auto plugin = _javaProxy->cthis()->getFrameProcessorPlugin(name, options); @@ -68,8 +64,7 @@ jsi::Value VisionCameraProxy::get(jsi::Runtime& runtime, const jsi::PropNameID& if (name == "setFrameProcessor") { return jsi::Function::createFromHostFunction( runtime, jsi::PropNameID::forUtf8(runtime, "setFrameProcessor"), 1, - [this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, - size_t count) -> jsi::Value { + [this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, size_t count) -> jsi::Value { auto viewTag = arguments[0].asNumber(); auto object = arguments[1].asObject(runtime); this->setFrameProcessor(static_cast(viewTag), runtime, object); @@ -79,8 +74,7 @@ jsi::Value VisionCameraProxy::get(jsi::Runtime& runtime, const jsi::PropNameID& if (name == "removeFrameProcessor") { return jsi::Function::createFromHostFunction( runtime, jsi::PropNameID::forUtf8(runtime, "removeFrameProcessor"), 1, - [this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, - size_t count) -> jsi::Value { + [this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, size_t count) -> jsi::Value { auto viewTag = arguments[0].asNumber(); this->removeFrameProcessor(static_cast(viewTag)); return jsi::Value::undefined(); @@ -89,8 +83,7 @@ jsi::Value VisionCameraProxy::get(jsi::Runtime& runtime, const jsi::PropNameID& if (name == "getFrameProcessorPlugin") { return jsi::Function::createFromHostFunction( runtime, jsi::PropNameID::forUtf8(runtime, "getFrameProcessorPlugin"), 1, - [this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, - size_t count) -> jsi::Value { + [this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, size_t count) -> jsi::Value { if (count < 1 || !arguments[0].isString()) { throw jsi::JSError(runtime, "First argument needs to be a string (pluginName)!"); } @@ -104,13 +97,11 @@ jsi::Value VisionCameraProxy::get(jsi::Runtime& runtime, const jsi::PropNameID& return jsi::Value::undefined(); } -void VisionCameraInstaller::install(jni::alias_ref, - jni::alias_ref proxy) { +void VisionCameraInstaller::install(jni::alias_ref, jni::alias_ref proxy) { // global.VisionCameraProxy auto visionCameraProxy = std::make_shared(proxy); jsi::Runtime& runtime = *proxy->cthis()->getJSRuntime(); - runtime.global().setProperty(runtime, "VisionCameraProxy", - jsi::Object::createFromHostObject(runtime, visionCameraProxy)); + runtime.global().setProperty(runtime, "VisionCameraProxy", jsi::Object::createFromHostObject(runtime, visionCameraProxy)); } } // namespace vision diff --git a/package/android/src/main/cpp/frameprocessor/VisionCameraProxy.h b/package/android/src/main/cpp/frameprocessor/VisionCameraProxy.h index cd5e425..67f7981 100644 --- a/package/android/src/main/cpp/frameprocessor/VisionCameraProxy.h +++ b/package/android/src/main/cpp/frameprocessor/VisionCameraProxy.h @@ -28,8 +28,7 @@ public: private: void setFrameProcessor(int viewTag, jsi::Runtime& runtime, const jsi::Object& frameProcessor); void removeFrameProcessor(int viewTag); - jsi::Value getFrameProcessorPlugin(jsi::Runtime& runtime, const std::string& name, - const jsi::Object& options); + jsi::Value getFrameProcessorPlugin(jsi::Runtime& runtime, const std::string& name, const jsi::Object& options); private: jni::global_ref _javaProxy; @@ -38,14 +37,11 @@ private: class VisionCameraInstaller : public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = - "Lcom/mrousavy/camera/frameprocessor/VisionCameraInstaller;"; + static auto constexpr kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessor/VisionCameraInstaller;"; static void registerNatives() { - javaClassStatic()->registerNatives( - {makeNativeMethod("install", VisionCameraInstaller::install)}); + javaClassStatic()->registerNatives({makeNativeMethod("install", VisionCameraInstaller::install)}); } - static void install(jni::alias_ref clazz, - jni::alias_ref proxy); + static void install(jni::alias_ref clazz, jni::alias_ref proxy); }; } // namespace vision diff --git a/package/android/src/main/cpp/frameprocessor/java-bindings/JFrameProcessor.cpp b/package/android/src/main/cpp/frameprocessor/java-bindings/JFrameProcessor.cpp index b4a612b..4f1a71c 100644 --- a/package/android/src/main/cpp/frameprocessor/java-bindings/JFrameProcessor.cpp +++ b/package/android/src/main/cpp/frameprocessor/java-bindings/JFrameProcessor.cpp @@ -22,8 +22,7 @@ void JFrameProcessor::registerNatives() { using TSelf = jni::local_ref; -JFrameProcessor::JFrameProcessor(std::shared_ptr worklet, - std::shared_ptr context) { +JFrameProcessor::JFrameProcessor(std::shared_ptr worklet, std::shared_ptr context) { _workletContext = std::move(context); _workletInvoker = std::make_shared(worklet); } @@ -33,8 +32,7 @@ TSelf JFrameProcessor::create(const std::shared_ptr& work return JFrameProcessor::newObjectCxxArgs(worklet, context); } -void JFrameProcessor::callWithFrameHostObject( - const std::shared_ptr& frameHostObject) const { +void JFrameProcessor::callWithFrameHostObject(const std::shared_ptr& frameHostObject) const { // Call the Frame Processor on the Worklet Runtime jsi::Runtime& runtime = _workletContext->getWorkletRuntime(); @@ -50,11 +48,8 @@ void JFrameProcessor::callWithFrameHostObject( const std::string& message = jsError.getMessage(); _workletContext->invokeOnJsThread([message](jsi::Runtime& jsRuntime) { - auto logFn = jsRuntime.global() - .getPropertyAsObject(jsRuntime, "console") - .getPropertyAsFunction(jsRuntime, "error"); - logFn.call(jsRuntime, jsi::String::createFromUtf8( - jsRuntime, "Frame Processor threw an error: " + message)); + auto logFn = jsRuntime.global().getPropertyAsObject(jsRuntime, "console").getPropertyAsFunction(jsRuntime, "error"); + logFn.call(jsRuntime, jsi::String::createFromUtf8(jsRuntime, "Frame Processor threw an error: " + message)); }); } } diff --git a/package/android/src/main/cpp/frameprocessor/java-bindings/JFrameProcessor.h b/package/android/src/main/cpp/frameprocessor/java-bindings/JFrameProcessor.h index b96673d..3c688a8 100644 --- a/package/android/src/main/cpp/frameprocessor/java-bindings/JFrameProcessor.h +++ b/package/android/src/main/cpp/frameprocessor/java-bindings/JFrameProcessor.h @@ -25,9 +25,8 @@ struct JFrameProcessor : public jni::HybridClass { public: static auto constexpr kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessor/FrameProcessor;"; static void registerNatives(); - static jni::local_ref - create(const std::shared_ptr& worklet, - const std::shared_ptr& context); + static jni::local_ref create(const std::shared_ptr& worklet, + const std::shared_ptr& context); public: /** @@ -37,8 +36,7 @@ public: private: // Private constructor. Use `create(..)` to create new instances. - explicit JFrameProcessor(std::shared_ptr worklet, - std::shared_ptr context); + explicit JFrameProcessor(std::shared_ptr worklet, std::shared_ptr context); private: void callWithFrameHostObject(const std::shared_ptr& frameHostObject) const; diff --git a/package/android/src/main/cpp/frameprocessor/java-bindings/JFrameProcessorPlugin.cpp b/package/android/src/main/cpp/frameprocessor/java-bindings/JFrameProcessorPlugin.cpp index 66de9aa..5627446 100644 --- a/package/android/src/main/cpp/frameprocessor/java-bindings/JFrameProcessorPlugin.cpp +++ b/package/android/src/main/cpp/frameprocessor/java-bindings/JFrameProcessorPlugin.cpp @@ -14,9 +14,8 @@ using namespace jni; using TCallback = jobject(alias_ref, alias_ref> params); -local_ref -JFrameProcessorPlugin::callback(const alias_ref& frame, - const alias_ref>& params) const { +local_ref JFrameProcessorPlugin::callback(const alias_ref& frame, + const alias_ref>& params) const { auto callbackMethod = getClass()->getMethod("callback"); auto result = callbackMethod(self(), frame, params); diff --git a/package/android/src/main/cpp/frameprocessor/java-bindings/JFrameProcessorPlugin.h b/package/android/src/main/cpp/frameprocessor/java-bindings/JFrameProcessorPlugin.h index 2f82454..d565734 100644 --- a/package/android/src/main/cpp/frameprocessor/java-bindings/JFrameProcessorPlugin.h +++ b/package/android/src/main/cpp/frameprocessor/java-bindings/JFrameProcessorPlugin.h @@ -16,15 +16,13 @@ using namespace facebook; using namespace jni; struct JFrameProcessorPlugin : public JavaClass { - static constexpr auto kJavaDescriptor = - "Lcom/mrousavy/camera/frameprocessor/FrameProcessorPlugin;"; + static constexpr auto kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessor/FrameProcessorPlugin;"; public: /** * Call the plugin. */ - local_ref callback(const alias_ref& frame, - const alias_ref>& params) const; + local_ref callback(const alias_ref& frame, const alias_ref>& params) const; }; } // namespace vision diff --git a/package/android/src/main/cpp/frameprocessor/java-bindings/JVisionCameraProxy.cpp b/package/android/src/main/cpp/frameprocessor/java-bindings/JVisionCameraProxy.cpp index 937f6d3..3a5572b 100644 --- a/package/android/src/main/cpp/frameprocessor/java-bindings/JVisionCameraProxy.cpp +++ b/package/android/src/main/cpp/frameprocessor/java-bindings/JVisionCameraProxy.cpp @@ -25,10 +25,9 @@ using TJSCallInvokerHolder = jni::alias_ref; using TOptions = jni::local_ref>; -JVisionCameraProxy::JVisionCameraProxy( - const jni::alias_ref& javaThis, jsi::Runtime* runtime, - const std::shared_ptr& callInvoker, - const jni::global_ref& scheduler) { +JVisionCameraProxy::JVisionCameraProxy(const jni::alias_ref& javaThis, jsi::Runtime* runtime, + const std::shared_ptr& callInvoker, + const jni::global_ref& scheduler) { _javaPart = make_global(javaThis); _runtime = runtime; @@ -43,8 +42,7 @@ JVisionCameraProxy::JVisionCameraProxy( // Run on Frame Processor Worklet Runtime scheduler->cthis()->dispatchAsync([f = std::move(f)]() { f(); }); }; - _workletContext = std::make_shared("VisionCamera", runtime, runOnJS, - runOnWorklet); + _workletContext = std::make_shared("VisionCamera", runtime, runOnJS, runOnWorklet); __android_log_write(ANDROID_LOG_INFO, TAG, "Worklet Context created!"); #else __android_log_write(ANDROID_LOG_INFO, TAG, "Frame Processors are disabled!"); @@ -60,13 +58,10 @@ JVisionCameraProxy::~JVisionCameraProxy() { #endif } -void JVisionCameraProxy::setFrameProcessor(int viewTag, jsi::Runtime& runtime, - const jsi::Object& frameProcessorObject) { +void JVisionCameraProxy::setFrameProcessor(int viewTag, jsi::Runtime& runtime, const jsi::Object& frameProcessorObject) { #if VISION_CAMERA_ENABLE_FRAME_PROCESSORS - auto frameProcessorType = - frameProcessorObject.getProperty(runtime, "type").asString(runtime).utf8(runtime); - auto worklet = std::make_shared( - runtime, frameProcessorObject.getProperty(runtime, "frameProcessor")); + auto frameProcessorType = frameProcessorObject.getProperty(runtime, "type").asString(runtime).utf8(runtime); + auto worklet = std::make_shared(runtime, frameProcessorObject.getProperty(runtime, "frameProcessor")); jni::local_ref frameProcessor; if (frameProcessorType == "frame-processor") { @@ -75,9 +70,7 @@ void JVisionCameraProxy::setFrameProcessor(int viewTag, jsi::Runtime& runtime, throw std::runtime_error("Unknown FrameProcessor.type passed! Received: " + frameProcessorType); } - auto setFrameProcessorMethod = - javaClassLocal()->getMethod)>( - "setFrameProcessor"); + auto setFrameProcessorMethod = javaClassLocal()->getMethod)>("setFrameProcessor"); setFrameProcessorMethod(_javaPart, viewTag, frameProcessor); #else throw std::runtime_error("system/frame-processors-unavailable: Frame Processors are disabled!"); @@ -89,11 +82,9 @@ void JVisionCameraProxy::removeFrameProcessor(int viewTag) { removeFrameProcessorMethod(_javaPart, viewTag); } -local_ref -JVisionCameraProxy::getFrameProcessorPlugin(const std::string& name, TOptions options) { +local_ref JVisionCameraProxy::getFrameProcessorPlugin(const std::string& name, TOptions options) { auto getFrameProcessorPluginMethod = - javaClassLocal()->getMethod, TOptions)>( - "getFrameProcessorPlugin"); + javaClassLocal()->getMethod, TOptions)>("getFrameProcessorPlugin"); return getFrameProcessorPluginMethod(_javaPart, make_jstring(name), std::move(options)); } @@ -101,8 +92,7 @@ void JVisionCameraProxy::registerNatives() { registerHybrid({makeNativeMethod("initHybrid", JVisionCameraProxy::initHybrid)}); } -TSelf JVisionCameraProxy::initHybrid(alias_ref jThis, jlong jsRuntimePointer, - TJSCallInvokerHolder jsCallInvokerHolder, +TSelf JVisionCameraProxy::initHybrid(alias_ref jThis, jlong jsRuntimePointer, TJSCallInvokerHolder jsCallInvokerHolder, const TScheduler& scheduler) { __android_log_write(ANDROID_LOG_INFO, TAG, "Initializing VisionCameraProxy..."); diff --git a/package/android/src/main/cpp/frameprocessor/java-bindings/JVisionCameraProxy.h b/package/android/src/main/cpp/frameprocessor/java-bindings/JVisionCameraProxy.h index b98f430..6faf08d 100644 --- a/package/android/src/main/cpp/frameprocessor/java-bindings/JVisionCameraProxy.h +++ b/package/android/src/main/cpp/frameprocessor/java-bindings/JVisionCameraProxy.h @@ -30,8 +30,8 @@ public: void setFrameProcessor(int viewTag, jsi::Runtime& runtime, const jsi::Object& frameProcessor); void removeFrameProcessor(int viewTag); - jni::local_ref - getFrameProcessorPlugin(const std::string& name, jni::local_ref> options); + jni::local_ref getFrameProcessorPlugin(const std::string& name, + jni::local_ref> options); jsi::Runtime* getJSRuntime() { return _runtime; @@ -48,14 +48,12 @@ private: static auto constexpr TAG = "VisionCameraProxy"; static auto constexpr kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessor/VisionCameraProxy;"; - explicit JVisionCameraProxy(const jni::alias_ref& javaThis, - jsi::Runtime* jsRuntime, + explicit JVisionCameraProxy(const jni::alias_ref& javaThis, jsi::Runtime* jsRuntime, const std::shared_ptr& jsCallInvoker, const jni::global_ref& scheduler); - static jni::local_ref - initHybrid(jni::alias_ref javaThis, jlong jsRuntimePointer, - jni::alias_ref jsCallInvokerHolder, - const jni::alias_ref& scheduler); + static jni::local_ref initHybrid(jni::alias_ref javaThis, jlong jsRuntimePointer, + jni::alias_ref jsCallInvokerHolder, + const jni::alias_ref& scheduler); }; } // namespace vision diff --git a/package/android/src/main/cpp/frameprocessor/java-bindings/JVisionCameraScheduler.h b/package/android/src/main/cpp/frameprocessor/java-bindings/JVisionCameraScheduler.h index ba22a03..06603b0 100644 --- a/package/android/src/main/cpp/frameprocessor/java-bindings/JVisionCameraScheduler.h +++ b/package/android/src/main/cpp/frameprocessor/java-bindings/JVisionCameraScheduler.h @@ -25,8 +25,7 @@ using namespace facebook; */ class JVisionCameraScheduler : public jni::HybridClass { public: - static auto constexpr kJavaDescriptor = - "Lcom/mrousavy/camera/frameprocessor/VisionCameraScheduler;"; + static auto constexpr kJavaDescriptor = "Lcom/mrousavy/camera/frameprocessor/VisionCameraScheduler;"; static jni::local_ref initHybrid(jni::alias_ref jThis); static void registerNatives(); @@ -39,8 +38,7 @@ private: std::queue> _jobs; std::mutex _mutex; - explicit JVisionCameraScheduler(jni::alias_ref jThis) - : _javaPart(jni::make_global(jThis)) {} + explicit JVisionCameraScheduler(jni::alias_ref jThis) : _javaPart(jni::make_global(jThis)) {} // Schedules a call to `trigger` on the VisionCamera FP Thread void scheduleTrigger(); diff --git a/package/cpp/.clang-format b/package/cpp/.clang-format index 1368d5d..f6fcde4 100644 --- a/package/cpp/.clang-format +++ b/package/cpp/.clang-format @@ -6,7 +6,7 @@ Standard: c++14 # Indentation IndentWidth: 2 -ColumnLimit: 100 +ColumnLimit: 140 # Includes SortIncludes: true diff --git a/package/cpp/JSITypedArray.cpp b/package/cpp/JSITypedArray.cpp index 7700fda..0662a24 100644 --- a/package/cpp/JSITypedArray.cpp +++ b/package/cpp/JSITypedArray.cpp @@ -81,16 +81,14 @@ void invalidateArrayBufferCache(jsi::Runtime& runtime) { TypedArrayKind getTypedArrayKindForName(const std::string& name); TypedArrayBase::TypedArrayBase(jsi::Runtime& runtime, size_t size, TypedArrayKind kind) - : TypedArrayBase( - runtime, runtime.global() - .getProperty(runtime, propNameIDCache.getConstructorNameProp(runtime, kind)) - .asObject(runtime) - .asFunction(runtime) - .callAsConstructor(runtime, {static_cast(size)}) - .asObject(runtime)) {} + : TypedArrayBase(runtime, runtime.global() + .getProperty(runtime, propNameIDCache.getConstructorNameProp(runtime, kind)) + .asObject(runtime) + .asFunction(runtime) + .callAsConstructor(runtime, {static_cast(size)}) + .asObject(runtime)) {} -TypedArrayBase::TypedArrayBase(jsi::Runtime& runtime, const jsi::Object& obj) - : jsi::Object(jsi::Value(runtime, obj).asObject(runtime)) {} +TypedArrayBase::TypedArrayBase(jsi::Runtime& runtime, const jsi::Object& obj) : jsi::Object(jsi::Value(runtime, obj).asObject(runtime)) {} TypedArrayKind TypedArrayBase::getKind(jsi::Runtime& runtime) const { auto constructorName = this->getProperty(runtime, propNameIDCache.get(runtime, Prop::Constructor)) @@ -174,13 +172,11 @@ std::vector arrayBufferToVector(jsi::Runtime& runtime, jsi::Object& jsO auto jsArrayBuffer = jsObj.getArrayBuffer(runtime); uint8_t* dataBlock = jsArrayBuffer.data(runtime); - size_t blockSize = - jsArrayBuffer.getProperty(runtime, propNameIDCache.get(runtime, Prop::ByteLength)).asNumber(); + size_t blockSize = jsArrayBuffer.getProperty(runtime, propNameIDCache.get(runtime, Prop::ByteLength)).asNumber(); return std::vector(dataBlock, dataBlock + blockSize); } -void arrayBufferUpdate(jsi::Runtime& runtime, jsi::ArrayBuffer& buffer, std::vector data, - size_t offset) { +void arrayBufferUpdate(jsi::Runtime& runtime, jsi::ArrayBuffer& buffer, std::vector data, size_t offset) { uint8_t* dataBlock = buffer.data(runtime); size_t blockSize = buffer.size(runtime); if (data.size() > blockSize) { @@ -189,28 +185,22 @@ void arrayBufferUpdate(jsi::Runtime& runtime, jsi::ArrayBuffer& buffer, std::vec std::copy(data.begin(), data.end(), dataBlock + offset); } -template -TypedArray::TypedArray(jsi::Runtime& runtime, size_t size) : TypedArrayBase(runtime, size, T) {} +template TypedArray::TypedArray(jsi::Runtime& runtime, size_t size) : TypedArrayBase(runtime, size, T) {} template -TypedArray::TypedArray(jsi::Runtime& runtime, std::vector> data) - : TypedArrayBase(runtime, data.size(), T) { +TypedArray::TypedArray(jsi::Runtime& runtime, std::vector> data) : TypedArrayBase(runtime, data.size(), T) { update(runtime, data); } -template -TypedArray::TypedArray(TypedArrayBase&& base) : TypedArrayBase(std::move(base)) {} +template TypedArray::TypedArray(TypedArrayBase&& base) : TypedArrayBase(std::move(base)) {} -template -std::vector> TypedArray::toVector(jsi::Runtime& runtime) { - auto start = - reinterpret_cast*>(getBuffer(runtime).data(runtime) + byteOffset(runtime)); +template std::vector> TypedArray::toVector(jsi::Runtime& runtime) { + auto start = reinterpret_cast*>(getBuffer(runtime).data(runtime) + byteOffset(runtime)); auto end = start + size(runtime); return std::vector>(start, end); } -template -void TypedArray::update(jsi::Runtime& runtime, const std::vector>& data) { +template void TypedArray::update(jsi::Runtime& runtime, const std::vector>& data) { if (data.size() != size(runtime)) { throw jsi::JSError(runtime, "TypedArray can only be updated with a vector of the same size"); } @@ -218,8 +208,7 @@ void TypedArray::update(jsi::Runtime& runtime, const std::vector*>(rawData)); } -template -void TypedArray::updateUnsafe(jsi::Runtime& runtime, ContentType* data, size_t length) { +template void TypedArray::updateUnsafe(jsi::Runtime& runtime, ContentType* data, size_t length) { if (length != size(runtime)) { throw jsi::JSError(runtime, "TypedArray can only be updated with an array of the same size"); } @@ -231,8 +220,7 @@ template uint8_t* TypedArray::data(jsi::Runtime& runtime) return getBuffer(runtime).data(runtime) + byteOffset(runtime); } -const jsi::PropNameID& PropNameIDCache::getConstructorNameProp(jsi::Runtime& runtime, - TypedArrayKind kind) { +const jsi::PropNameID& PropNameIDCache::getConstructorNameProp(jsi::Runtime& runtime, TypedArrayKind kind) { switch (kind) { case TypedArrayKind::Int8Array: return get(runtime, Prop::Int8Array); @@ -256,9 +244,7 @@ const jsi::PropNameID& PropNameIDCache::getConstructorNameProp(jsi::Runtime& run } jsi::PropNameID PropNameIDCache::createProp(jsi::Runtime& runtime, Prop prop) { - auto create = [&](const std::string& propName) { - return jsi::PropNameID::forUtf8(runtime, propName); - }; + auto create = [&](const std::string& propName) { return jsi::PropNameID::forUtf8(runtime, propName); }; switch (prop) { case Prop::Buffer: return create("buffer"); diff --git a/package/cpp/JSITypedArray.h b/package/cpp/JSITypedArray.h index ae311eb..bed1c53 100644 --- a/package/cpp/JSITypedArray.h +++ b/package/cpp/JSITypedArray.h @@ -97,8 +97,7 @@ bool isTypedArray(jsi::Runtime& runtime, const jsi::Object& jsObj); TypedArrayBase getTypedArray(jsi::Runtime& runtime, const jsi::Object& jsObj); std::vector arrayBufferToVector(jsi::Runtime& runtime, jsi::Object& jsObj); -void arrayBufferUpdate(jsi::Runtime& runtime, jsi::ArrayBuffer& buffer, std::vector data, - size_t offset); +void arrayBufferUpdate(jsi::Runtime& runtime, jsi::ArrayBuffer& buffer, std::vector data, size_t offset); template class TypedArray : public TypedArrayBase { public: diff --git a/package/ios/CameraViewManager.m b/package/ios/CameraViewManager.m index 314441b..031401b 100644 --- a/package/ios/CameraViewManager.m +++ b/package/ios/CameraViewManager.m @@ -14,22 +14,12 @@ @interface RCT_EXTERN_REMAP_MODULE (CameraView, CameraViewManager, RCTViewManager) // Module Functions -RCT_EXTERN_METHOD(getCameraPermissionStatus - : (RCTPromiseResolveBlock)resolve reject - : (RCTPromiseRejectBlock)reject); -RCT_EXTERN_METHOD(getMicrophonePermissionStatus - : (RCTPromiseResolveBlock)resolve reject - : (RCTPromiseRejectBlock)reject); -RCT_EXTERN_METHOD(requestCameraPermission - : (RCTPromiseResolveBlock)resolve reject - : (RCTPromiseRejectBlock)reject); -RCT_EXTERN_METHOD(requestMicrophonePermission - : (RCTPromiseResolveBlock)resolve reject - : (RCTPromiseRejectBlock)reject); +RCT_EXTERN_METHOD(getCameraPermissionStatus : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject); +RCT_EXTERN_METHOD(getMicrophonePermissionStatus : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject); +RCT_EXTERN_METHOD(requestCameraPermission : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject); +RCT_EXTERN_METHOD(requestMicrophonePermission : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject); -RCT_EXTERN_METHOD(getAvailableCameraDevices - : (RCTPromiseResolveBlock)resolve reject - : (RCTPromiseRejectBlock)reject); +RCT_EXTERN_METHOD(getAvailableCameraDevices : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject); // Camera View Properties RCT_EXPORT_VIEW_PROPERTY(isActive, BOOL); @@ -73,10 +63,7 @@ RCT_EXTERN_METHOD(resumeRecording : (nonnull NSNumber*)node resolve : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject); -RCT_EXTERN_METHOD(stopRecording - : (nonnull NSNumber*)node resolve - : (RCTPromiseResolveBlock)resolve reject - : (RCTPromiseRejectBlock)reject); +RCT_EXTERN_METHOD(stopRecording : (nonnull NSNumber*)node resolve : (RCTPromiseResolveBlock)resolve reject : (RCTPromiseRejectBlock)reject); RCT_EXTERN_METHOD(takePhoto : (nonnull NSNumber*)node options : (NSDictionary*)options resolve diff --git a/package/ios/Frame Processor/Frame.h b/package/ios/Frame Processor/Frame.h index ce4d6c4..45775ce 100644 --- a/package/ios/Frame Processor/Frame.h +++ b/package/ios/Frame Processor/Frame.h @@ -14,8 +14,7 @@ @interface Frame : NSObject -- (instancetype _Nonnull)initWithBuffer:(CMSampleBufferRef _Nonnull)buffer - orientation:(UIImageOrientation)orientation; +- (instancetype _Nonnull)initWithBuffer:(CMSampleBufferRef _Nonnull)buffer orientation:(UIImageOrientation)orientation; @property(nonatomic, readonly) CMSampleBufferRef _Nonnull buffer; @property(nonatomic, readonly) UIImageOrientation orientation; diff --git a/package/ios/Frame Processor/Frame.m b/package/ios/Frame Processor/Frame.m index 17da561..0d5e8d7 100644 --- a/package/ios/Frame Processor/Frame.m +++ b/package/ios/Frame Processor/Frame.m @@ -15,8 +15,7 @@ UIImageOrientation orientation; } -- (instancetype)initWithBuffer:(CMSampleBufferRef _Nonnull)buffer - orientation:(UIImageOrientation)orientation { +- (instancetype)initWithBuffer:(CMSampleBufferRef _Nonnull)buffer orientation:(UIImageOrientation)orientation { self = [super init]; if (self) { _buffer = buffer; diff --git a/package/ios/Frame Processor/FrameHostObject.mm b/package/ios/Frame Processor/FrameHostObject.mm index 7bf9b59..7dad25d 100644 --- a/package/ios/Frame Processor/FrameHostObject.mm +++ b/package/ios/Frame Processor/FrameHostObject.mm @@ -46,12 +46,10 @@ jsi::Value FrameHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& pr auto width = CVPixelBufferGetWidth(imageBuffer); auto height = CVPixelBufferGetHeight(imageBuffer); - NSMutableString* string = - [NSMutableString stringWithFormat:@"%lu x %lu Frame", width, height]; + NSMutableString* string = [NSMutableString stringWithFormat:@"%lu x %lu Frame", width, height]; return jsi::String::createFromUtf8(runtime, string.UTF8String); }; - return jsi::Function::createFromHostFunction( - runtime, jsi::PropNameID::forUtf8(runtime, "toString"), 0, toString); + return jsi::Function::createFromHostFunction(runtime, jsi::PropNameID::forUtf8(runtime, "toString"), 0, toString); } if (name == "incrementRefCount") { auto incrementRefCount = JSI_HOST_FUNCTION_LAMBDA { @@ -59,8 +57,7 @@ jsi::Value FrameHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& pr CFRetain(frame.buffer); return jsi::Value::undefined(); }; - return jsi::Function::createFromHostFunction( - runtime, jsi::PropNameID::forUtf8(runtime, "incrementRefCount"), 0, incrementRefCount); + return jsi::Function::createFromHostFunction(runtime, jsi::PropNameID::forUtf8(runtime, "incrementRefCount"), 0, incrementRefCount); } if (name == "decrementRefCount") { auto decrementRefCount = JSI_HOST_FUNCTION_LAMBDA { @@ -69,8 +66,7 @@ jsi::Value FrameHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& pr CFRelease(frame.buffer); return jsi::Value::undefined(); }; - return jsi::Function::createFromHostFunction( - runtime, jsi::PropNameID::forUtf8(runtime, "decrementRefCount"), 0, decrementRefCount); + return jsi::Function::createFromHostFunction(runtime, jsi::PropNameID::forUtf8(runtime, "decrementRefCount"), 0, decrementRefCount); } if (name == "toArrayBuffer") { auto toArrayBuffer = JSI_HOST_FUNCTION_LAMBDA { @@ -82,19 +78,15 @@ jsi::Value FrameHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& pr static constexpr auto ARRAYBUFFER_CACHE_PROP_NAME = "__frameArrayBufferCache"; if (!runtime.global().hasProperty(runtime, ARRAYBUFFER_CACHE_PROP_NAME)) { - vision::TypedArray arrayBuffer(runtime, - arraySize); + vision::TypedArray arrayBuffer(runtime, arraySize); runtime.global().setProperty(runtime, ARRAYBUFFER_CACHE_PROP_NAME, arrayBuffer); } - auto arrayBufferCache = - runtime.global().getPropertyAsObject(runtime, ARRAYBUFFER_CACHE_PROP_NAME); - auto arrayBuffer = vision::getTypedArray(runtime, arrayBufferCache) - .get(runtime); + auto arrayBufferCache = runtime.global().getPropertyAsObject(runtime, ARRAYBUFFER_CACHE_PROP_NAME); + auto arrayBuffer = vision::getTypedArray(runtime, arrayBufferCache).get(runtime); if (arrayBuffer.size(runtime) != arraySize) { - arrayBuffer = - vision::TypedArray(runtime, arraySize); + arrayBuffer = vision::TypedArray(runtime, arraySize); runtime.global().setProperty(runtime, ARRAYBUFFER_CACHE_PROP_NAME, arrayBuffer); } @@ -105,13 +97,11 @@ jsi::Value FrameHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& pr return arrayBuffer; }; - return jsi::Function::createFromHostFunction( - runtime, jsi::PropNameID::forUtf8(runtime, "toArrayBuffer"), 0, toArrayBuffer); + return jsi::Function::createFromHostFunction(runtime, jsi::PropNameID::forUtf8(runtime, "toArrayBuffer"), 0, toArrayBuffer); } if (name == "isValid") { - auto isValid = frame != nil && frame.buffer != nil && CFGetRetainCount(frame.buffer) > 0 && - CMSampleBufferIsValid(frame.buffer); + auto isValid = frame != nil && frame.buffer != nil && CFGetRetainCount(frame.buffer) > 0 && CMSampleBufferIsValid(frame.buffer); return jsi::Value(isValid); } if (name == "width") { diff --git a/package/ios/Frame Processor/FrameProcessor.mm b/package/ios/Frame Processor/FrameProcessor.mm index ab01562..601b021 100644 --- a/package/ios/Frame Processor/FrameProcessor.mm +++ b/package/ios/Frame Processor/FrameProcessor.mm @@ -46,11 +46,8 @@ using namespace facebook; auto message = jsError.getMessage(); _workletContext->invokeOnJsThread([message](jsi::Runtime& jsRuntime) { - auto logFn = jsRuntime.global() - .getPropertyAsObject(jsRuntime, "console") - .getPropertyAsFunction(jsRuntime, "error"); - logFn.call(jsRuntime, jsi::String::createFromUtf8( - jsRuntime, "Frame Processor threw an error: " + message)); + auto logFn = jsRuntime.global().getPropertyAsObject(jsRuntime, "console").getPropertyAsFunction(jsRuntime, "error"); + logFn.call(jsRuntime, jsi::String::createFromUtf8(jsRuntime, "Frame Processor threw an error: " + message)); }); } } diff --git a/package/ios/Frame Processor/FrameProcessorPlugin.m b/package/ios/Frame Processor/FrameProcessorPlugin.m index 6d38b72..6f504eb 100644 --- a/package/ios/Frame Processor/FrameProcessorPlugin.m +++ b/package/ios/Frame Processor/FrameProcessorPlugin.m @@ -12,10 +12,8 @@ @implementation FrameProcessorPlugin - (id _Nullable)callback:(Frame* _Nonnull)frame withArguments:(NSDictionary* _Nullable)arguments { - [NSException - raise:NSInternalInconsistencyException - format: - @"Frame Processor Plugin does not override the `callback(frame:withArguments:)` method!"]; + [NSException raise:NSInternalInconsistencyException + format:@"Frame Processor Plugin does not override the `callback(frame:withArguments:)` method!"]; return nil; } diff --git a/package/ios/Frame Processor/FrameProcessorPluginHostObject.h b/package/ios/Frame Processor/FrameProcessorPluginHostObject.h index 35717d6..b1a6d32 100644 --- a/package/ios/Frame Processor/FrameProcessorPluginHostObject.h +++ b/package/ios/Frame Processor/FrameProcessorPluginHostObject.h @@ -17,8 +17,7 @@ using namespace facebook; class FrameProcessorPluginHostObject : public jsi::HostObject { public: - explicit FrameProcessorPluginHostObject(FrameProcessorPlugin* plugin, - std::shared_ptr callInvoker) + explicit FrameProcessorPluginHostObject(FrameProcessorPlugin* plugin, std::shared_ptr callInvoker) : _plugin(plugin), _callInvoker(callInvoker) {} ~FrameProcessorPluginHostObject() {} diff --git a/package/ios/Frame Processor/FrameProcessorPluginHostObject.mm b/package/ios/Frame Processor/FrameProcessorPluginHostObject.mm index d4dfba1..c21e776 100644 --- a/package/ios/Frame Processor/FrameProcessorPluginHostObject.mm +++ b/package/ios/Frame Processor/FrameProcessorPluginHostObject.mm @@ -14,33 +14,28 @@ using namespace facebook; -std::vector -FrameProcessorPluginHostObject::getPropertyNames(jsi::Runtime& runtime) { +std::vector FrameProcessorPluginHostObject::getPropertyNames(jsi::Runtime& runtime) { std::vector result; result.push_back(jsi::PropNameID::forUtf8(runtime, std::string("call"))); return result; } -jsi::Value FrameProcessorPluginHostObject::get(jsi::Runtime& runtime, - const jsi::PropNameID& propName) { +jsi::Value FrameProcessorPluginHostObject::get(jsi::Runtime& runtime, const jsi::PropNameID& propName) { auto name = propName.utf8(runtime); if (name == "call") { return jsi::Function::createFromHostFunction( runtime, jsi::PropNameID::forUtf8(runtime, "call"), 2, - [=](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, - size_t count) -> jsi::Value { + [=](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, size_t count) -> jsi::Value { // Frame is first argument - auto frameHostObject = - arguments[0].asObject(runtime).asHostObject(runtime); + auto frameHostObject = arguments[0].asObject(runtime).asHostObject(runtime); Frame* frame = frameHostObject->frame; // Options are second argument (possibly undefined) NSDictionary* options = nil; if (count > 1) { auto optionsObject = arguments[1].asObject(runtime); - options = JSINSObjectConversion::convertJSIObjectToNSDictionary(runtime, optionsObject, - _callInvoker); + options = JSINSObjectConversion::convertJSIObjectToNSDictionary(runtime, optionsObject, _callInvoker); } // Call actual Frame Processor Plugin diff --git a/package/ios/Frame Processor/FrameProcessorPluginRegistry.h b/package/ios/Frame Processor/FrameProcessorPluginRegistry.h index 2006309..a25e651 100644 --- a/package/ios/Frame Processor/FrameProcessorPluginRegistry.h +++ b/package/ios/Frame Processor/FrameProcessorPluginRegistry.h @@ -14,13 +14,10 @@ @interface FrameProcessorPluginRegistry : NSObject -typedef FrameProcessorPlugin* _Nonnull (^PluginInitializerFunction)( - NSDictionary* _Nullable options); +typedef FrameProcessorPlugin* _Nonnull (^PluginInitializerFunction)(NSDictionary* _Nullable options); -+ (void)addFrameProcessorPlugin:(NSString* _Nonnull)name - withInitializer:(PluginInitializerFunction _Nonnull)pluginInitializer; ++ (void)addFrameProcessorPlugin:(NSString* _Nonnull)name withInitializer:(PluginInitializerFunction _Nonnull)pluginInitializer; -+ (FrameProcessorPlugin* _Nullable)getPlugin:(NSString* _Nonnull)name - withOptions:(NSDictionary* _Nullable)options; ++ (FrameProcessorPlugin* _Nullable)getPlugin:(NSString* _Nonnull)name withOptions:(NSDictionary* _Nullable)options; @end diff --git a/package/ios/Frame Processor/FrameProcessorPluginRegistry.m b/package/ios/Frame Processor/FrameProcessorPluginRegistry.m index 11bfb5c..3268258 100644 --- a/package/ios/Frame Processor/FrameProcessorPluginRegistry.m +++ b/package/ios/Frame Processor/FrameProcessorPluginRegistry.m @@ -19,10 +19,8 @@ return plugins; } -+ (void)addFrameProcessorPlugin:(NSString*)name - withInitializer:(PluginInitializerFunction)pluginInitializer { - BOOL alreadyExists = - [[FrameProcessorPluginRegistry frameProcessorPlugins] valueForKey:name] != nil; ++ (void)addFrameProcessorPlugin:(NSString*)name withInitializer:(PluginInitializerFunction)pluginInitializer { + BOOL alreadyExists = [[FrameProcessorPluginRegistry frameProcessorPlugins] valueForKey:name] != nil; NSAssert(!alreadyExists, @"Tried to add a Frame Processor Plugin with a name that already exists! Either choose " @"unique names, or " @@ -32,10 +30,8 @@ [[FrameProcessorPluginRegistry frameProcessorPlugins] setValue:pluginInitializer forKey:name]; } -+ (FrameProcessorPlugin*)getPlugin:(NSString* _Nonnull)name - withOptions:(NSDictionary* _Nullable)options { - PluginInitializerFunction initializer = - [[FrameProcessorPluginRegistry frameProcessorPlugins] objectForKey:name]; ++ (FrameProcessorPlugin*)getPlugin:(NSString* _Nonnull)name withOptions:(NSDictionary* _Nullable)options { + PluginInitializerFunction initializer = [[FrameProcessorPluginRegistry frameProcessorPlugins] objectForKey:name]; if (initializer == nil) { return nil; } diff --git a/package/ios/Frame Processor/JSINSObjectConversion.h b/package/ios/Frame Processor/JSINSObjectConversion.h index eef8e57..c1cfac5 100644 --- a/package/ios/Frame Processor/JSINSObjectConversion.h +++ b/package/ios/Frame Processor/JSINSObjectConversion.h @@ -39,27 +39,23 @@ jsi::Value convertObjCObjectToJSIValue(jsi::Runtime& runtime, id value); NSString* convertJSIStringToNSString(jsi::Runtime& runtime, const jsi::String& value); // any... -> NSArray -NSArray* convertJSICStyleArrayToNSArray(jsi::Runtime& runtime, const jsi::Value* array, - size_t length, std::shared_ptr jsInvoker); +NSArray* convertJSICStyleArrayToNSArray(jsi::Runtime& runtime, const jsi::Value* array, size_t length, + std::shared_ptr jsInvoker); // NSArray -> any... jsi::Value* convertNSArrayToJSICStyleArray(jsi::Runtime& runtime, NSArray* array); // [] -> NSArray -NSArray* convertJSIArrayToNSArray(jsi::Runtime& runtime, const jsi::Array& value, - std::shared_ptr jsInvoker); +NSArray* convertJSIArrayToNSArray(jsi::Runtime& runtime, const jsi::Array& value, std::shared_ptr jsInvoker); // {} -> NSDictionary -NSDictionary* convertJSIObjectToNSDictionary(jsi::Runtime& runtime, const jsi::Object& value, - std::shared_ptr jsInvoker); +NSDictionary* convertJSIObjectToNSDictionary(jsi::Runtime& runtime, const jsi::Object& value, std::shared_ptr jsInvoker); // any -> id -id convertJSIValueToObjCObject(jsi::Runtime& runtime, const jsi::Value& value, - std::shared_ptr jsInvoker); +id convertJSIValueToObjCObject(jsi::Runtime& runtime, const jsi::Value& value, std::shared_ptr jsInvoker); // (any...) => any -> (void)(id, id) -RCTResponseSenderBlock convertJSIFunctionToCallback(jsi::Runtime& runtime, - const jsi::Function& value, +RCTResponseSenderBlock convertJSIFunctionToCallback(jsi::Runtime& runtime, const jsi::Function& value, std::shared_ptr jsInvoker); } // namespace JSINSObjectConversion diff --git a/package/ios/Frame Processor/JSINSObjectConversion.mm b/package/ios/Frame Processor/JSINSObjectConversion.mm index 7e43cd6..1427774 100644 --- a/package/ios/Frame Processor/JSINSObjectConversion.mm +++ b/package/ios/Frame Processor/JSINSObjectConversion.mm @@ -85,8 +85,8 @@ NSString* convertJSIStringToNSString(jsi::Runtime& runtime, const jsi::String& v return [NSString stringWithUTF8String:value.utf8(runtime).c_str()]; } -NSArray* convertJSICStyleArrayToNSArray(jsi::Runtime& runtime, const jsi::Value* array, - size_t length, std::shared_ptr jsInvoker) { +NSArray* convertJSICStyleArrayToNSArray(jsi::Runtime& runtime, const jsi::Value* array, size_t length, + std::shared_ptr jsInvoker) { if (length < 1) return @[]; NSMutableArray* result = [NSMutableArray new]; @@ -105,21 +105,17 @@ jsi::Value* convertNSArrayToJSICStyleArray(jsi::Runtime& runtime, NSArray* array return result; } -NSArray* convertJSIArrayToNSArray(jsi::Runtime& runtime, const jsi::Array& value, - std::shared_ptr jsInvoker) { +NSArray* convertJSIArrayToNSArray(jsi::Runtime& runtime, const jsi::Array& value, std::shared_ptr jsInvoker) { size_t size = value.size(runtime); NSMutableArray* result = [NSMutableArray new]; for (size_t i = 0; i < size; i++) { // Insert kCFNull when it's `undefined` value to preserve the indices. - [result - addObject:convertJSIValueToObjCObject(runtime, value.getValueAtIndex(runtime, i), jsInvoker) - ?: (id)kCFNull]; + [result addObject:convertJSIValueToObjCObject(runtime, value.getValueAtIndex(runtime, i), jsInvoker) ?: (id)kCFNull]; } return [result copy]; } -NSDictionary* convertJSIObjectToNSDictionary(jsi::Runtime& runtime, const jsi::Object& value, - std::shared_ptr jsInvoker) { +NSDictionary* convertJSIObjectToNSDictionary(jsi::Runtime& runtime, const jsi::Object& value, std::shared_ptr jsInvoker) { jsi::Array propertyNames = value.getPropertyNames(runtime); size_t size = propertyNames.size(runtime); NSMutableDictionary* result = [NSMutableDictionary new]; @@ -134,8 +130,7 @@ NSDictionary* convertJSIObjectToNSDictionary(jsi::Runtime& runtime, const jsi::O return [result copy]; } -id convertJSIValueToObjCObject(jsi::Runtime& runtime, const jsi::Value& value, - std::shared_ptr jsInvoker) { +id convertJSIValueToObjCObject(jsi::Runtime& runtime, const jsi::Value& value, std::shared_ptr jsInvoker) { if (value.isUndefined() || value.isNull()) { return nil; } @@ -169,8 +164,7 @@ id convertJSIValueToObjCObject(jsi::Runtime& runtime, const jsi::Value& value, throw std::runtime_error("Unsupported jsi::jsi::Value kind"); } -RCTResponseSenderBlock convertJSIFunctionToCallback(jsi::Runtime& runtime, - const jsi::Function& value, +RCTResponseSenderBlock convertJSIFunctionToCallback(jsi::Runtime& runtime, const jsi::Function& value, std::shared_ptr jsInvoker) { auto weakWrapper = CallbackWrapper::createWeak(value.getFunction(runtime), runtime, jsInvoker); RCTBlockGuard* blockGuard = [[RCTBlockGuard alloc] initWithCleanup:^() { @@ -198,8 +192,7 @@ RCTResponseSenderBlock convertJSIFunctionToCallback(jsi::Runtime& runtime, } const jsi::Value* args = convertNSArrayToJSICStyleArray(strongWrapper2->runtime(), responses); - strongWrapper2->callback().call(strongWrapper2->runtime(), args, - static_cast(responses.count)); + strongWrapper2->callback().call(strongWrapper2->runtime(), args, static_cast(responses.count)); strongWrapper2->destroy(); delete[] args; diff --git a/package/ios/Frame Processor/VisionCameraProxy.h b/package/ios/Frame Processor/VisionCameraProxy.h index 32fbffb..198d7dd 100644 --- a/package/ios/Frame Processor/VisionCameraProxy.h +++ b/package/ios/Frame Processor/VisionCameraProxy.h @@ -20,8 +20,7 @@ using namespace facebook; class VisionCameraProxy : public jsi::HostObject { public: - explicit VisionCameraProxy(jsi::Runtime& runtime, - std::shared_ptr callInvoker); + explicit VisionCameraProxy(jsi::Runtime& runtime, std::shared_ptr callInvoker); ~VisionCameraProxy(); public: @@ -31,8 +30,7 @@ public: private: void setFrameProcessor(jsi::Runtime& runtime, int viewTag, const jsi::Object& frameProcessor); void removeFrameProcessor(jsi::Runtime& runtime, int viewTag); - jsi::Value getFrameProcessorPlugin(jsi::Runtime& runtime, std::string name, - const jsi::Object& options); + jsi::Value getFrameProcessorPlugin(jsi::Runtime& runtime, std::string name, const jsi::Object& options); private: std::shared_ptr _workletContext; diff --git a/package/ios/Frame Processor/VisionCameraProxy.mm b/package/ios/Frame Processor/VisionCameraProxy.mm index c4ae104..1bc1317 100644 --- a/package/ios/Frame Processor/VisionCameraProxy.mm +++ b/package/ios/Frame Processor/VisionCameraProxy.mm @@ -37,8 +37,7 @@ __attribute__((objc_runtime_name("_TtC12VisionCamera10CameraView"))) using namespace facebook; -VisionCameraProxy::VisionCameraProxy(jsi::Runtime& runtime, - std::shared_ptr callInvoker) { +VisionCameraProxy::VisionCameraProxy(jsi::Runtime& runtime, std::shared_ptr callInvoker) { _callInvoker = callInvoker; NSLog(@"VisionCameraProxy: Creating Worklet Context..."); @@ -51,8 +50,7 @@ VisionCameraProxy::VisionCameraProxy(jsi::Runtime& runtime, dispatch_async(CameraQueues.videoQueue, [f = std::move(f)]() { f(); }); }; - _workletContext = std::make_shared("VisionCamera", &runtime, - runOnJS, runOnWorklet); + _workletContext = std::make_shared("VisionCamera", &runtime, runOnJS, runOnWorklet); NSLog(@"VisionCameraProxy: Worklet Context Created!"); } @@ -71,23 +69,18 @@ std::vector VisionCameraProxy::getPropertyNames(jsi::Runtime& r return result; } -void VisionCameraProxy::setFrameProcessor(jsi::Runtime& runtime, int viewTag, - const jsi::Object& object) { +void VisionCameraProxy::setFrameProcessor(jsi::Runtime& runtime, int viewTag, const jsi::Object& object) { auto frameProcessorType = object.getProperty(runtime, "type").asString(runtime).utf8(runtime); - auto worklet = std::make_shared( - runtime, object.getProperty(runtime, "frameProcessor")); + auto worklet = std::make_shared(runtime, object.getProperty(runtime, "frameProcessor")); RCTExecuteOnMainQueue(^{ auto currentBridge = [RCTBridge currentBridge]; - auto anonymousView = - [currentBridge.uiManager viewForReactTag:[NSNumber numberWithDouble:viewTag]]; + auto anonymousView = [currentBridge.uiManager viewForReactTag:[NSNumber numberWithDouble:viewTag]]; auto view = static_cast(anonymousView); if (frameProcessorType == "frame-processor") { - view.frameProcessor = [[FrameProcessor alloc] initWithWorklet:worklet - context:_workletContext]; + view.frameProcessor = [[FrameProcessor alloc] initWithWorklet:worklet context:_workletContext]; } else { - throw std::runtime_error("Unknown FrameProcessor.type passed! Received: " + - frameProcessorType); + throw std::runtime_error("Unknown FrameProcessor.type passed! Received: " + frameProcessorType); } }); } @@ -95,20 +88,16 @@ void VisionCameraProxy::setFrameProcessor(jsi::Runtime& runtime, int viewTag, void VisionCameraProxy::removeFrameProcessor(jsi::Runtime& runtime, int viewTag) { RCTExecuteOnMainQueue(^{ auto currentBridge = [RCTBridge currentBridge]; - auto anonymousView = - [currentBridge.uiManager viewForReactTag:[NSNumber numberWithDouble:viewTag]]; + auto anonymousView = [currentBridge.uiManager viewForReactTag:[NSNumber numberWithDouble:viewTag]]; auto view = static_cast(anonymousView); view.frameProcessor = nil; }); } -jsi::Value VisionCameraProxy::getFrameProcessorPlugin(jsi::Runtime& runtime, std::string name, - const jsi::Object& options) { +jsi::Value VisionCameraProxy::getFrameProcessorPlugin(jsi::Runtime& runtime, std::string name, const jsi::Object& options) { NSString* key = [NSString stringWithUTF8String:name.c_str()]; - NSDictionary* optionsObjc = - JSINSObjectConversion::convertJSIObjectToNSDictionary(runtime, options, _callInvoker); - FrameProcessorPlugin* plugin = [FrameProcessorPluginRegistry getPlugin:key - withOptions:optionsObjc]; + NSDictionary* optionsObjc = JSINSObjectConversion::convertJSIObjectToNSDictionary(runtime, options, _callInvoker); + FrameProcessorPlugin* plugin = [FrameProcessorPluginRegistry getPlugin:key withOptions:optionsObjc]; if (plugin == nil) { return jsi::Value::undefined(); } @@ -123,8 +112,7 @@ jsi::Value VisionCameraProxy::get(jsi::Runtime& runtime, const jsi::PropNameID& if (name == "setFrameProcessor") { return jsi::Function::createFromHostFunction( runtime, jsi::PropNameID::forUtf8(runtime, "setFrameProcessor"), 1, - [this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, - size_t count) -> jsi::Value { + [this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, size_t count) -> jsi::Value { auto viewTag = arguments[0].asNumber(); auto object = arguments[1].asObject(runtime); this->setFrameProcessor(runtime, static_cast(viewTag), object); @@ -134,8 +122,7 @@ jsi::Value VisionCameraProxy::get(jsi::Runtime& runtime, const jsi::PropNameID& if (name == "removeFrameProcessor") { return jsi::Function::createFromHostFunction( runtime, jsi::PropNameID::forUtf8(runtime, "removeFrameProcessor"), 1, - [this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, - size_t count) -> jsi::Value { + [this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, size_t count) -> jsi::Value { auto viewTag = arguments[0].asNumber(); this->removeFrameProcessor(runtime, static_cast(viewTag)); return jsi::Value::undefined(); @@ -144,8 +131,7 @@ jsi::Value VisionCameraProxy::get(jsi::Runtime& runtime, const jsi::PropNameID& if (name == "getFrameProcessorPlugin") { return jsi::Function::createFromHostFunction( runtime, jsi::PropNameID::forUtf8(runtime, "getFrameProcessorPlugin"), 1, - [this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, - size_t count) -> jsi::Value { + [this](jsi::Runtime& runtime, const jsi::Value& thisValue, const jsi::Value* arguments, size_t count) -> jsi::Value { if (count < 1 || !arguments[0].isString()) { throw jsi::JSError(runtime, "First argument needs to be a string (pluginName)!"); } @@ -170,8 +156,7 @@ jsi::Value VisionCameraProxy::get(jsi::Runtime& runtime, const jsi::PropNameID& // global.VisionCameraProxy auto visionCameraProxy = std::make_shared(runtime, bridge.jsCallInvoker); - runtime.global().setProperty(runtime, "VisionCameraProxy", - jsi::Object::createFromHostObject(runtime, visionCameraProxy)); + runtime.global().setProperty(runtime, "VisionCameraProxy", jsi::Object::createFromHostObject(runtime, visionCameraProxy)); return YES; }