From fafbee240235ea0e63eb01abd31ce32d6a576429 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Thu, 28 Aug 2025 03:39:42 -0700 Subject: [PATCH] Remove CxxSharedModuleWrapper from open-source (#52672) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52672 This was used internally to work around some limitations of the bridge lifecycle. Given that we now have C++ TurboModules which are much more versatile, let's remove unnecessary concepts externally, as we move towards deprecating legacy C++ modules entirely. Changelog: [General][Breaking] Removed CxxSharedModuleWrapper Reviewed By: rshest Differential Revision: D78484221 fbshipit-source-id: 95ed46b597dac55d823b70abe196264ce5b326ab --- .../jni/react/jni/CxxSharedModuleWrapper.h | 37 ----------------- .../cxxreact/SharedProxyCxxModule.h | 40 ------------------- 2 files changed, 77 deletions(-) delete mode 100644 packages/react-native/ReactAndroid/src/main/jni/react/jni/CxxSharedModuleWrapper.h delete mode 100644 packages/react-native/ReactCommon/cxxreact/SharedProxyCxxModule.h diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/jni/CxxSharedModuleWrapper.h b/packages/react-native/ReactAndroid/src/main/jni/react/jni/CxxSharedModuleWrapper.h deleted file mode 100644 index 8d6dd71f8c0..00000000000 --- a/packages/react-native/ReactAndroid/src/main/jni/react/jni/CxxSharedModuleWrapper.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include - -#include "CxxModuleWrapperBase.h" - -namespace facebook::react { - -class CxxSharedModuleWrapper : public CxxModuleWrapperBase { - public: - std::string getName() override { - return shared_->getName(); - } - - std::unique_ptr getModule() override { - // Instead of just moving out the stored CxxModule, this creates a - // proxy which passes calls to the shared stored CxxModule. - - return std::make_unique(shared_); - } - - protected: - explicit CxxSharedModuleWrapper( - std::unique_ptr module) - : shared_(std::move(module)) {} - - std::shared_ptr shared_; -}; - -} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/cxxreact/SharedProxyCxxModule.h b/packages/react-native/ReactCommon/cxxreact/SharedProxyCxxModule.h deleted file mode 100644 index c01f3791767..00000000000 --- a/packages/react-native/ReactCommon/cxxreact/SharedProxyCxxModule.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -#pragma once - -#include - -#include - -namespace facebook::xplat::module { - -// Allows a Cxx-module to be shared or reused across multiple React instances -// Caveat: the setInstance call is not forwarded, so usages of getInstance -// inside your module (e.g. dispatching events) will always be nullptr. -class SharedProxyCxxModule : public CxxModule { - public: - explicit SharedProxyCxxModule(std::shared_ptr shared) - : shared_(shared) {} - - std::string getName() override { - return shared_->getName(); - } - - auto getConstants() -> std::map override { - return shared_->getConstants(); - } - - auto getMethods() -> std::vector override { - return shared_->getMethods(); - } - - private: - std::shared_ptr shared_; -}; - -} // namespace facebook::xplat::module