Skip to content

Commit 2f643a7

Browse files
j-piaseckifacebook-github-bot
authored andcommitted
Cover componentregistry with Stable API guards (#58302)
Summary: Classifies `react/renderer/componentregistry:componentregistry` as a public target under the C++ stable API three-tier visibility model and introduces the module umbrella `React/ComponentRegistry.h` as its public entry point. This module has no podspec of its own - it ships as a subspec of `React-Fabric` - so the `componentregistryUmbrella` subspec and the matching `headers-config.js` entry are added to the parent pod. The umbrella re-exports all five of the module's headers. The sibling `react/renderer/componentregistry/native:native` target is private under the same model. The guards are inert unless a consumer defines `RN_STRICT_API`, so there is no behavior change. Changelog: [General][Added] - Add `<React/ComponentRegistry.h>` umbrella header as the public entry point for `react/renderer/componentregistry` Differential Revision: D118612734
1 parent a9203b8 commit 2f643a7

10 files changed

Lines changed: 62 additions & 0 deletions

File tree

‎packages/react-native/ReactAndroid/build.gradle.kts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ val preparePrefab by
134134
"../ReactCommon/react/renderer/componentregistry/",
135135
"react/renderer/componentregistry/",
136136
),
137+
Pair("../ReactCommon/react/renderer/componentregistry/React/", "React/"),
137138
// react_renderer_consistency
138139
Pair(
139140
"../ReactCommon/react/renderer/consistency/",

‎packages/react-native/ReactCommon/React-Fabric.podspec‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ Pod::Spec.new do |s|
120120
ss.header_dir = "react/renderer/componentregistry"
121121
end
122122

123+
s.subspec "componentregistryUmbrella" do |ss|
124+
ss.source_files = "react/renderer/componentregistry/React/*.h"
125+
ss.header_dir = ""
126+
ss.header_mappings_dir = "react/renderer/componentregistry"
127+
end
128+
123129
s.subspec "componentregistrynative" do |ss|
124130
ss.source_files = podspec_sources("react/renderer/componentregistry/native/**/*.{m,mm,cpp,h}", "react/renderer/componentregistry/native/**/*.{h}")
125131
ss.header_dir = "react/renderer/componentregistry/native"

‎packages/react-native/ReactCommon/react/renderer/componentregistry/CMakeLists.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@ file(GLOB react_renderer_componentregistry_SRC CONFIGURE_DEPENDS *.cpp)
1212
add_library(react_renderer_componentregistry OBJECT ${react_renderer_componentregistry_SRC})
1313

1414
target_include_directories(react_renderer_componentregistry PUBLIC ${REACT_COMMON_DIR})
15+
target_include_directories(react_renderer_componentregistry INTERFACE ${REACT_COMMON_DIR}/react/renderer/componentregistry)
1516

1617
target_link_libraries(react_renderer_componentregistry
1718
folly_runtime
1819
glog_init
1920
jsi
21+
react_cxxstableapi
2022
react_debug
2123
react_renderer_core
2224
react_renderer_debug

‎packages/react-native/ReactCommon/react/renderer/componentregistry/ComponentDescriptorFactory.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#include <react/cxxstableapi/UmbrellaGuard.h>
11+
1012
#include <memory>
1113

1214
#include <react/renderer/core/ComponentDescriptor.h>

‎packages/react-native/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProvider.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#include <react/cxxstableapi/UmbrellaGuard.h>
11+
1012
#include <react/renderer/core/ComponentDescriptor.h>
1113
#include <react/renderer/core/EventDispatcher.h>
1214
#include <react/utils/ContextContainer.h>

‎packages/react-native/ReactCommon/react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#include <react/cxxstableapi/UmbrellaGuard.h>
11+
1012
#include <shared_mutex>
1113
#include <unordered_map>
1214

‎packages/react-native/ReactCommon/react/renderer/componentregistry/ComponentDescriptorRegistry.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#include <react/cxxstableapi/UmbrellaGuard.h>
11+
1012
#include <memory>
1113
#include <shared_mutex>
1214
#include <unordered_map>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
#pragma once
9+
10+
// =============================================================================
11+
// Umbrella header for the `react/renderer/componentregistry` module - public
12+
// entry point.
13+
//
14+
// #include <React/ComponentRegistry.h>
15+
//
16+
// Re-exports the module's public interface headers. React Native's own code
17+
// should keep using the fine-grained `<react/renderer/componentregistry/...>`
18+
// includes; only outside consumers use this umbrella.
19+
// =============================================================================
20+
21+
// Marks that the following headers are pulled in through the umbrella, so their
22+
// shared guard (<react/cxxstableapi/UmbrellaGuard.h>) accepts them. The marker
23+
// is saved and restored rather than defined and undefined: the scope ends at
24+
// this block, so later *direct* includes in the same TU are still caught, and
25+
// it nests inside an enclosing umbrella rather than disarming it.
26+
#pragma push_macro("RN_UMBRELLA_CONTEXT")
27+
#undef RN_UMBRELLA_CONTEXT
28+
#define RN_UMBRELLA_CONTEXT 1
29+
30+
#include <react/renderer/componentregistry/ComponentDescriptorFactory.h>
31+
#include <react/renderer/componentregistry/ComponentDescriptorProvider.h>
32+
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
33+
#include <react/renderer/componentregistry/ComponentDescriptorRegistry.h>
34+
#include <react/renderer/componentregistry/componentNameByReactViewName.h>
35+
36+
#undef RN_UMBRELLA_CONTEXT
37+
#pragma pop_macro("RN_UMBRELLA_CONTEXT")

‎packages/react-native/ReactCommon/react/renderer/componentregistry/componentNameByReactViewName.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#pragma once
99

10+
#include <react/cxxstableapi/UmbrellaGuard.h>
11+
1012
#include <string>
1113

1214
namespace facebook::react {

‎packages/react-native/scripts/ios-prebuild/headers-config.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ const PodspecExceptions /*: {[key: string]: PodSpecConfiguration} */ = {
8787
headerDir: 'react/renderer/componentregistry',
8888
},
8989

90+
{
91+
name: 'componentregistryUmbrella',
92+
headerPatterns: ['react/renderer/componentregistry/React/*.h'],
93+
headerDir: 'React',
94+
},
95+
9096
{
9197
name: 'componentregistrynative',
9298
headerPatterns: ['react/renderer/componentregistry/native/**/*.h'],

0 commit comments

Comments
 (0)