From 3eb2b01cc9180f54b9b64f7f5164d3948ff9a73f Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Tue, 7 Jan 2025 04:19:25 -0800 Subject: [PATCH] Rename SurfaceRegistryBinding to AppRegistryBinding (#48337) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/48337 `SurfaceRegistryBinding` refers to a forked `SurfaceRegistry` we had for a while in bridgeless but which was merged back into `AppRegistry`. Align the native name as well to make it explicit that all this class does is call into `AppRegistry`. Changelog: [Internal] Reviewed By: rshest Differential Revision: D67342499 --- ...stryBinding.cpp => AppRegistryBinding.cpp} | 16 +++--- .../renderer/uimanager/AppRegistryBinding.h | 50 +++++++++++++++++++ .../uimanager/SurfaceRegistryBinding.h | 43 ++-------------- .../react/renderer/uimanager/UIManager.cpp | 8 +-- 4 files changed, 65 insertions(+), 52 deletions(-) rename packages/react-native/ReactCommon/react/renderer/uimanager/{SurfaceRegistryBinding.cpp => AppRegistryBinding.cpp} (84%) create mode 100644 packages/react-native/ReactCommon/react/renderer/uimanager/AppRegistryBinding.h diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/AppRegistryBinding.cpp similarity index 84% rename from packages/react-native/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.cpp rename to packages/react-native/ReactCommon/react/renderer/uimanager/AppRegistryBinding.cpp index eeed20b043b22c..2a40e37149bb97 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/AppRegistryBinding.cpp @@ -5,19 +5,19 @@ * LICENSE file in the root directory of this source tree. */ -#include "SurfaceRegistryBinding.h" +#include "AppRegistryBinding.h" #include #include namespace facebook::react { -void SurfaceRegistryBinding::startSurface( +/* static */ void AppRegistryBinding::startSurface( jsi::Runtime& runtime, SurfaceId surfaceId, const std::string& moduleName, const folly::dynamic& initialProps, DisplayMode displayMode) { - TraceSection s("SurfaceRegistryBinding::startSurface"); + TraceSection s("AppRegistryBinding::startSurface"); jsi::Object parameters(runtime); parameters.setProperty(runtime, "rootTag", surfaceId); parameters.setProperty( @@ -28,7 +28,7 @@ void SurfaceRegistryBinding::startSurface( auto registry = global.getProperty(runtime, "RN$AppRegistry"); if (!registry.isObject()) { throw std::runtime_error( - "SurfaceRegistryBinding::startSurface failed. Global was not installed."); + "AppRegistryBinding::startSurface failed. Global was not installed."); } auto method = std::move(registry).asObject(runtime).getPropertyAsFunction( runtime, "runApplication"); @@ -39,7 +39,7 @@ void SurfaceRegistryBinding::startSurface( jsi::Value(runtime, displayModeToInt(displayMode))}); } -void SurfaceRegistryBinding::setSurfaceProps( +/* static */ void AppRegistryBinding::setSurfaceProps( jsi::Runtime& runtime, SurfaceId surfaceId, const std::string& moduleName, @@ -56,7 +56,7 @@ void SurfaceRegistryBinding::setSurfaceProps( auto registry = global.getProperty(runtime, "RN$AppRegistry"); if (!registry.isObject()) { throw std::runtime_error( - "SurfaceRegistryBinding::setSurfaceProps failed. Global was not installed."); + "AppRegistryBinding::setSurfaceProps failed. Global was not installed."); } auto method = std::move(registry).asObject(runtime).getPropertyAsFunction( @@ -68,7 +68,7 @@ void SurfaceRegistryBinding::setSurfaceProps( jsi::Value(runtime, displayModeToInt(displayMode))}); } -void SurfaceRegistryBinding::stopSurface( +/* static */ void AppRegistryBinding::stopSurface( jsi::Runtime& runtime, SurfaceId surfaceId) { auto global = runtime.global(); @@ -76,7 +76,7 @@ void SurfaceRegistryBinding::stopSurface( if (!stopFunction.isObject() || !stopFunction.asObject(runtime).isFunction(runtime)) { throw std::runtime_error( - "SurfaceRegistryBinding::stopSurface failed. Global was not installed."); + "AppRegistryBinding::stopSurface failed. Global was not installed."); } std::move(stopFunction) diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/AppRegistryBinding.h b/packages/react-native/ReactCommon/react/renderer/uimanager/AppRegistryBinding.h new file mode 100644 index 00000000000000..cd596e920ca29d --- /dev/null +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/AppRegistryBinding.h @@ -0,0 +1,50 @@ +/* + * 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 +#include + +namespace facebook::react { + +class AppRegistryBinding final { + public: + AppRegistryBinding() = delete; + + /* + * Starts React Native Surface with given id, moduleName, and props. + * Thread synchronization must be enforced externally. + */ + static void startSurface( + jsi::Runtime& runtime, + SurfaceId surfaceId, + const std::string& moduleName, + const folly::dynamic& initialProps, + DisplayMode displayMode); + + /* + * Updates the React Native Surface identified with surfaceId and moduleName + * with the given props. + * Thread synchronization must be enforced externally. + */ + static void setSurfaceProps( + jsi::Runtime& runtime, + SurfaceId surfaceId, + const std::string& moduleName, + const folly::dynamic& initialProps, + DisplayMode displayMode); + + /* + * Stops React Native Surface with given id. + * Thread synchronization must be enforced externally. + */ + static void stopSurface(jsi::Runtime& runtime, SurfaceId surfaceId); +}; + +} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.h b/packages/react-native/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.h index aa3811a6849c90..5d9b6400971f44 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.h +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/SurfaceRegistryBinding.h @@ -7,44 +7,7 @@ #pragma once -#include -#include -#include +#warning \ + "The SurfaceRegistryBinding.h header has been renamed to AppRegistryBinding.h" -namespace facebook::react { - -class SurfaceRegistryBinding final { - public: - SurfaceRegistryBinding() = delete; - - /* - * Starts React Native Surface with given id, moduleName, and props. - * Thread synchronization must be enforced externally. - */ - static void startSurface( - jsi::Runtime& runtime, - SurfaceId surfaceId, - const std::string& moduleName, - const folly::dynamic& initialProps, - DisplayMode displayMode); - - /* - * Updates the React Native Surface identified with surfaceId and moduleName - * with the given props. - * Thread synchronization must be enforced externally. - */ - static void setSurfaceProps( - jsi::Runtime& runtime, - SurfaceId surfaceId, - const std::string& moduleName, - const folly::dynamic& initialProps, - DisplayMode displayMode); - - /* - * Stops React Native Surface with given id. - * Thread synchronization must be enforced externally. - */ - static void stopSurface(jsi::Runtime& runtime, SurfaceId surfaceId); -}; - -} // namespace facebook::react +#include diff --git a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp index 8aad7271463758..d83c350c564e4e 100644 --- a/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp +++ b/packages/react-native/ReactCommon/react/renderer/uimanager/UIManager.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include @@ -237,7 +237,7 @@ void UIManager::startSurface( runtimeExecutor_([=](jsi::Runtime& runtime) { TraceSection s("UIManager::startSurface::onRuntime"); - SurfaceRegistryBinding::startSurface( + AppRegistryBinding::startSurface( runtime, surfaceId, moduleName, props, displayMode); }); } @@ -255,7 +255,7 @@ void UIManager::setSurfaceProps( TraceSection s("UIManager::setSurfaceProps"); runtimeExecutor_([=](jsi::Runtime& runtime) { - SurfaceRegistryBinding::setSurfaceProps( + AppRegistryBinding::setSurfaceProps( runtime, surfaceId, moduleName, props, displayMode); }); } @@ -275,7 +275,7 @@ ShadowTree::Unique UIManager::stopSurface(SurfaceId surfaceId) const { // commits from the JavaScript side will not be able to reference a // `ShadowTree` and will fail silently. runtimeExecutor_([=](jsi::Runtime& runtime) { - SurfaceRegistryBinding::stopSurface(runtime, surfaceId); + AppRegistryBinding::stopSurface(runtime, surfaceId); }); if (leakChecker_) {