From 4b51417a16e5ea4093014e3e9cf062598df68d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ma=C5=82ecki?= Date: Tue, 29 Sep 2026 06:43:51 -0700 Subject: [PATCH 1/5] Use public umbrellas in mounting headers Summary: Migrate React-Fabric mounting headers to consume the RendererCore, Graphics, and Utils stable umbrellas instead of guarded leaf headers. Add the coreUmbrella dependency to the mounting subspec so dynamic-framework consumers receive the owning header. Avoid RendererDebug.h because its eager utility-template exports change downstream overload lookup; RendererCore already provides the debug flags and declaration types used by mounting. Drop the `#ifdef ANDROID` include of `configurePlatformColorCacheInvalidationHook.h` from the Graphics umbrella. The Android `PlatformColorParser.h` already includes it, and the explicit include broke Android builds that use the cxx graphics platform headers, where that header does not exist. Changelog: [Internal] Differential Revision: D121790104 --- packages/react-native/ReactCommon/React-Fabric.podspec | 1 + .../ReactCommon/react/renderer/mounting/Differentiator.h | 2 +- .../react/renderer/mounting/MountingCoordinator.h | 2 +- .../ReactCommon/react/renderer/mounting/ShadowTree.h | 6 ++---- .../react/renderer/mounting/ShadowTreeRegistry.h | 2 +- .../ReactCommon/react/renderer/mounting/ShadowView.h | 9 ++------- .../react/renderer/mounting/internal/CullingContext.h | 3 +-- .../renderer/mounting/internal/ShadowViewNodePair.h | 4 ++-- .../ReactCommon/react/renderer/mounting/stubs/StubView.h | 4 +--- .../ReactCommon/react/renderer/mounting/stubs/stubs.h | 2 +- .../react/renderer/mounting/updateMountedFlag.h | 2 +- 11 files changed, 14 insertions(+), 23 deletions(-) diff --git a/packages/react-native/ReactCommon/React-Fabric.podspec b/packages/react-native/ReactCommon/React-Fabric.podspec index 8b84f704eef5..a5033590847d 100644 --- a/packages/react-native/ReactCommon/React-Fabric.podspec +++ b/packages/react-native/ReactCommon/React-Fabric.podspec @@ -209,6 +209,7 @@ Pod::Spec.new do |s| end s.subspec "mounting" do |ss| + ss.dependency "React-Fabric/coreUmbrella" ss.dependency "React-jsinspectortracing" ss.source_files = podspec_sources("react/renderer/mounting/**/*.{m,mm,cpp,h}", "react/renderer/mounting/**/*.h") ss.exclude_files = "react/renderer/mounting/tests" diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/Differentiator.h b/packages/react-native/ReactCommon/react/renderer/mounting/Differentiator.h index e0ecb4cfca52..8ba9f99c64d0 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/Differentiator.h +++ b/packages/react-native/ReactCommon/react/renderer/mounting/Differentiator.h @@ -9,7 +9,7 @@ #include -#include +#include #include namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/MountingCoordinator.h b/packages/react-native/ReactCommon/react/renderer/mounting/MountingCoordinator.h index 561a74b8292b..c520508cb06b 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/MountingCoordinator.h +++ b/packages/react-native/ReactCommon/react/renderer/mounting/MountingCoordinator.h @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include #include diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.h b/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.h index 4eeb85abceea..457f9a56e3a2 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.h +++ b/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTree.h @@ -13,14 +13,12 @@ #include #include +#include +#include #include -#include -#include -#include #include #include #include -#include #include "MountingOverrideDelegate.h" namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.h b/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.h index bfe843ebf8f4..d65974423565 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.h +++ b/packages/react-native/ReactCommon/react/renderer/mounting/ShadowTreeRegistry.h @@ -12,7 +12,7 @@ #include #include -#include +#include #include namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/ShadowView.h b/packages/react-native/ReactCommon/react/renderer/mounting/ShadowView.h index e9a51fdf8363..e0dd7d4afc3a 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/ShadowView.h +++ b/packages/react-native/ReactCommon/react/renderer/mounting/ShadowView.h @@ -9,13 +9,8 @@ #include -#include -#include -#include -#include -#include -#include -#include +#include +#include namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/internal/CullingContext.h b/packages/react-native/ReactCommon/react/renderer/mounting/internal/CullingContext.h index 1057b7ab5384..30cc5f4792b1 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/internal/CullingContext.h +++ b/packages/react-native/ReactCommon/react/renderer/mounting/internal/CullingContext.h @@ -9,8 +9,7 @@ #include -#include -#include +#include namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/internal/ShadowViewNodePair.h b/packages/react-native/ReactCommon/react/renderer/mounting/internal/ShadowViewNodePair.h index 899deb527034..a5904bb32f8d 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/internal/ShadowViewNodePair.h +++ b/packages/react-native/ReactCommon/react/renderer/mounting/internal/ShadowViewNodePair.h @@ -9,8 +9,8 @@ #include -#include -#include +#include +#include #include namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/stubs/StubView.h b/packages/react-native/ReactCommon/react/renderer/mounting/stubs/StubView.h index ffd166a0b0dc..c6507521e5ec 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/stubs/StubView.h +++ b/packages/react-native/ReactCommon/react/renderer/mounting/stubs/StubView.h @@ -12,9 +12,7 @@ #include #include -#include -#include -#include +#include #include namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/stubs/stubs.h b/packages/react-native/ReactCommon/react/renderer/mounting/stubs/stubs.h index cd5199c03b34..3948aa4eefcd 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/stubs/stubs.h +++ b/packages/react-native/ReactCommon/react/renderer/mounting/stubs/stubs.h @@ -9,7 +9,7 @@ #include -#include +#include #include #include diff --git a/packages/react-native/ReactCommon/react/renderer/mounting/updateMountedFlag.h b/packages/react-native/ReactCommon/react/renderer/mounting/updateMountedFlag.h index 0f8f8b968758..4ce08d2288a3 100644 --- a/packages/react-native/ReactCommon/react/renderer/mounting/updateMountedFlag.h +++ b/packages/react-native/ReactCommon/react/renderer/mounting/updateMountedFlag.h @@ -9,7 +9,7 @@ #include -#include +#include #include namespace facebook::react { From 9005141e9d138268a4a7fe99f84621ad3c7b4f1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ma=C5=82ecki?= Date: Tue, 29 Sep 2026 06:43:52 -0700 Subject: [PATCH 2/5] Use public umbrellas in attributedstring headers Summary: Migrate React-Fabric attributedstring headers to consume stable Debug, FeatureFlags, CSS, Graphics, MapBuffer, RendererCore, Utils, and View umbrellas instead of guarded leaf headers. Add the direct Buck and CocoaPods dependencies required by those public imports. Avoid RendererDebug.h because its current utility-template export changes downstream overload lookup; RendererCore already provides the debug declaration types used by attributedstring. Changelog: [Internal] Differential Revision: D121793359 --- packages/react-native/React/Base/RCTUtils.mm | 9 +++++---- .../ReactCommon/React-Fabric.podspec | 3 +++ .../attributedstring/AttributedString.h | 5 ++--- .../attributedstring/AttributedStringBox.h | 1 + .../attributedstring/ParagraphAttributes.h | 6 +++--- .../attributedstring/TextAttributes.h | 12 ++++------- .../renderer/attributedstring/conversions.h | 20 ++++++------------- .../renderer/graphics/HostPlatformColor.mm | 8 +++++--- .../textlayoutmanager/RCTTextLayoutManager.mm | 5 +++-- 9 files changed, 32 insertions(+), 37 deletions(-) diff --git a/packages/react-native/React/Base/RCTUtils.mm b/packages/react-native/React/Base/RCTUtils.mm index 04f4e4ed3911..21ddfb6ff1f2 100644 --- a/packages/react-native/React/Base/RCTUtils.mm +++ b/packages/react-native/React/Base/RCTUtils.mm @@ -13,6 +13,7 @@ #import #import #import +#import #import #import @@ -437,20 +438,20 @@ CGSize RCTSwitchSize(void) CGFloat RCTRoundPixelValue(CGFloat value) { CGFloat scale = RCTScreenScale(); - return round(value * scale) / scale; + return std::round(value * scale) / scale; } CGFloat RCTCeilPixelValue(CGFloat value) { CGFloat scale = RCTScreenScale(); - return ceil(value * scale) / scale; + return std::ceil(value * scale) / scale; } CGSize RCTSizeInPixels(CGSize pointSize, CGFloat scale) { return (CGSize){ - ceil(pointSize.width * scale), - ceil(pointSize.height * scale), + std::ceil(pointSize.width * scale), + std::ceil(pointSize.height * scale), }; } diff --git a/packages/react-native/ReactCommon/React-Fabric.podspec b/packages/react-native/ReactCommon/React-Fabric.podspec index a5033590847d..81971b33ae6b 100644 --- a/packages/react-native/ReactCommon/React-Fabric.podspec +++ b/packages/react-native/ReactCommon/React-Fabric.podspec @@ -77,6 +77,9 @@ Pod::Spec.new do |s| end s.subspec "attributedstring" do |ss| + ss.dependency "React-Fabric/coreUmbrella" + ss.dependency "React-Fabric/components/viewUmbrella" + ss.dependency "React-renderercss" ss.source_files = podspec_sources("react/renderer/attributedstring/**/*.{m,mm,cpp,h}", "react/renderer/attributedstring/**/*.{h}") ss.exclude_files = "react/renderer/attributedstring/tests" ss.header_dir = "react/renderer/attributedstring" diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedString.h b/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedString.h index f1cdbe4181cb..4913f3583704 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedString.h +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedString.h @@ -9,11 +9,10 @@ #include +#include +#include #include -#include -#include #include -#include namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h b/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h index 4c9471bde5cf..077bf846c34d 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h @@ -11,6 +11,7 @@ #include +#include #include namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h b/packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h index 7cd8252d7c8f..f9385bebe811 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h @@ -11,10 +11,10 @@ #include +#include +#include +#include #include -#include -#include -#include namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/TextAttributes.h b/packages/react-native/ReactCommon/react/renderer/attributedstring/TextAttributes.h index bcf902f9093a..9f9fdb02b824 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/TextAttributes.h +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/TextAttributes.h @@ -14,16 +14,12 @@ #include #include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h b/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h index e77b21d33653..bdc5258a8664 100644 --- a/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h +++ b/packages/react-native/ReactCommon/react/renderer/attributedstring/conversions.h @@ -9,28 +9,20 @@ #include -#include -#include +#include +#include +#include +#include +#include #include #include #include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include #include #ifdef RN_SERIALIZABLE_STATE +#include #include -#include -#include #endif #include diff --git a/packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm b/packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm index e47deaa95cf6..1fc1a37068bf 100644 --- a/packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm +++ b/packages/react-native/ReactCommon/react/renderer/graphics/platform/ios/react/renderer/graphics/HostPlatformColor.mm @@ -12,6 +12,7 @@ #import #import #import +#import #import using namespace facebook::react; @@ -86,9 +87,10 @@ bool UIColorIsP3ColorSpace(const std::shared_ptr &uiColor) int32_t ColorFromColorComponents(const facebook::react::ColorComponents &components) { float ratio = 255; - auto color = ((int32_t)round((float)components.alpha * ratio) & 0xff) << 24 | - ((int)round((float)components.red * ratio) & 0xff) << 16 | - ((int)round((float)components.green * ratio) & 0xff) << 8 | ((int)round((float)components.blue * ratio) & 0xff); + auto color = ((int32_t)std::round((float)components.alpha * ratio) & 0xff) << 24 | + ((int)std::round((float)components.red * ratio) & 0xff) << 16 | + ((int)std::round((float)components.green * ratio) & 0xff) << 8 | + ((int)std::round((float)components.blue * ratio) & 0xff); return color; } diff --git a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm index af5b225e8e7e..3e5bfd528320 100644 --- a/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm +++ b/packages/react-native/ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTTextLayoutManager.mm @@ -8,6 +8,7 @@ #import "RCTTextLayoutManager.h" #import +#import #import "RCTAttributedTextUtils.h" @@ -186,8 +187,8 @@ - (void)drawAttributedString:(AttributedString)attributedString // remains visible at small sizes and proportionate at // large ones. ~`fontSize / 12` plus a 1.5pt floor. CGFloat thickness = MAX(fontSize / 12.0f, 1.5f); - CGFloat wavyWavelength = 1.0f + 2.0f * round(2.0f * thickness + 0.5f); - CGFloat wavyCpDistance = 0.5f + round(3.0f * thickness + 0.5f); + CGFloat wavyWavelength = 1.0f + 2.0f * std::round(2.0f * thickness + 0.5f); + CGFloat wavyCpDistance = 0.5f + std::round(3.0f * thickness + 0.5f); NSRange targetGlyphRange = [layoutManager glyphRangeForCharacterRange:attrRange actualCharacterRange:nullptr]; From 9b1f5b6132d03df1e697473b7268c5cc7fff7d74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ma=C5=82ecki?= Date: Wed, 30 Sep 2026 02:31:09 -0700 Subject: [PATCH 3/5] Keep ImageManager primitives free of private debug headers Summary: The public `react/renderer/imagemanager/primitives.h` header included the private `react/renderer/debug/debugStringConvertibleUtils.h` for the inline body of `ImageSource::getDebugProps()`. Because the include was unconditional, any strict consumer of `` or `` (which reaches `primitives.h` through the Image event emitter) hit the private header guard and failed to compile. Include the public `DebugStringConvertible.h` and `flags.h` headers instead, which provide `SharedDebugStringConvertibleList` and `RN_DEBUG_STRING_CONVERTIBLE`, and keep only the `getDebugProps()` declaration in the header under the existing `RN_DEBUG_STRING_CONVERTIBLE` guard. Move its unchanged implementation into a new `primitives.cpp`, the only place that needs the private debug helpers. Buck, CMake, and CocoaPods already compile every `imagemanager/*.cpp`, so no build-file changes are needed. Changelog: [Internal] Differential Revision: D122534446 --- .../renderer/imagemanager/primitives.cpp | 49 +++++++++++++++++++ .../react/renderer/imagemanager/primitives.h | 25 ++-------- 2 files changed, 52 insertions(+), 22 deletions(-) create mode 100644 packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.cpp diff --git a/packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.cpp b/packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.cpp new file mode 100644 index 000000000000..bef05830294a --- /dev/null +++ b/packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.cpp @@ -0,0 +1,49 @@ +/* + * 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. + */ + +#include + +#if RN_DEBUG_STRING_CONVERTIBLE +#include +#endif + +namespace facebook::react { + +#if RN_DEBUG_STRING_CONVERTIBLE +SharedDebugStringConvertibleList ImageSource::getDebugProps( + const std::string& prefix) const { + ImageSource imageSource{}; + + SharedDebugStringConvertibleList headersList; + for (const auto& header : headers) { + headersList.push_back(debugStringConvertibleItem( + prefix + "-header-" + header.first, header.second)); + } + + return headersList + + SharedDebugStringConvertibleList{ + debugStringConvertibleItem( + prefix + "-type", toString(type), toString(imageSource.type)), + debugStringConvertibleItem(prefix + "-uri", uri, imageSource.uri), + debugStringConvertibleItem( + prefix + "-bundle", bundle, imageSource.bundle), + debugStringConvertibleItem( + prefix + "-scale", scale, imageSource.scale), + debugStringConvertibleItem( + prefix + "-size", + react::toString(size), + react::toString(imageSource.size)), + debugStringConvertibleItem(prefix + "-body", body, imageSource.body), + debugStringConvertibleItem( + prefix + "-method", method, imageSource.method), + debugStringConvertibleItem( + prefix + "-cache", toString(cache), toString(imageSource.cache)), + }; +} +#endif + +} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.h b/packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.h index b044ae1071ec..c21c5b08b2ac 100644 --- a/packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.h +++ b/packages/react-native/ReactCommon/react/renderer/imagemanager/primitives.h @@ -15,7 +15,8 @@ #include #include #include -#include +#include +#include #include #include @@ -97,27 +98,7 @@ class ImageSource { #endif #if RN_DEBUG_STRING_CONVERTIBLE - SharedDebugStringConvertibleList getDebugProps(const std::string &prefix) const - { - ImageSource imageSource{}; - - SharedDebugStringConvertibleList headersList; - for (const auto &header : headers) { - headersList.push_back(debugStringConvertibleItem(prefix + "-header-" + header.first, header.second)); - } - - return headersList + - SharedDebugStringConvertibleList{ - debugStringConvertibleItem(prefix + "-type", toString(type), toString(imageSource.type)), - debugStringConvertibleItem(prefix + "-uri", uri, imageSource.uri), - debugStringConvertibleItem(prefix + "-bundle", bundle, imageSource.bundle), - debugStringConvertibleItem(prefix + "-scale", scale, imageSource.scale), - debugStringConvertibleItem(prefix + "-size", react::toString(size), react::toString(imageSource.size)), - debugStringConvertibleItem(prefix + "-body", body, imageSource.body), - debugStringConvertibleItem(prefix + "-method", method, imageSource.method), - debugStringConvertibleItem(prefix + "-cache", toString(cache), toString(imageSource.cache)), - }; - } + SharedDebugStringConvertibleList getDebugProps(const std::string &prefix) const; std::string toString(const Type &typeValue) const { From b25db802bfb6f81932bb69eb6d9894cc0ddb20b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ma=C5=82ecki?= Date: Wed, 30 Sep 2026 02:31:28 -0700 Subject: [PATCH 4/5] Clean up Image public header dependencies Summary: Keep the Image component's exported headers self-contained and free of implementation-only dependencies, following the MapBuffer cleanup. - Move the `ImageSource` and `ImageResizeMode` `fromRawValue`/`toString` implementations from `conversions.h` into a new `conversions.cpp`. The header now only declares them, so it no longer exports `glog/logging.h` and `react_native_expect.h`. Every consumer of `conversions.h` (Image props, text input props, and generated component props) already links the Image library in Buck, CocoaPods, and CMake. - Drop the unused Android-only `MapBuffer.h` and `MapBufferBuilder.h` includes from `ImageState.h`; nothing in the Image module uses MapBuffer. - Declare standard-library dependencies directly in the Image headers (``, ``, ``, ``, ``). Changelog: [Internal] Differential Revision: D122534476 --- .../image/ImageComponentDescriptor.h | 2 + .../components/image/ImageEventEmitter.h | 2 + .../renderer/components/image/ImageProps.h | 3 + .../components/image/ImageShadowNode.h | 2 + .../renderer/components/image/ImageState.h | 5 +- .../renderer/components/image/conversions.cpp | 180 ++++++++++++++++++ .../renderer/components/image/conversions.h | 159 +--------------- 7 files changed, 198 insertions(+), 155 deletions(-) create mode 100644 packages/react-native/ReactCommon/react/renderer/components/image/conversions.cpp diff --git a/packages/react-native/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h b/packages/react-native/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h index da793a387562..a4311bb1a418 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h +++ b/packages/react-native/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h @@ -9,6 +9,8 @@ #include +#include + #include #include diff --git a/packages/react-native/ReactCommon/react/renderer/components/image/ImageEventEmitter.h b/packages/react-native/ReactCommon/react/renderer/components/image/ImageEventEmitter.h index cbd7eb781869..03f5da7c7f27 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/image/ImageEventEmitter.h +++ b/packages/react-native/ReactCommon/react/renderer/components/image/ImageEventEmitter.h @@ -9,6 +9,8 @@ #include +#include + #include #include diff --git a/packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.h b/packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.h index 9da186430d42..e8a9be18cd6a 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.h +++ b/packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.h @@ -9,6 +9,9 @@ #include +#include +#include + #include #include #include diff --git a/packages/react-native/ReactCommon/react/renderer/components/image/ImageShadowNode.h b/packages/react-native/ReactCommon/react/renderer/components/image/ImageShadowNode.h index 61bcaba18a47..97c2b752f494 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/image/ImageShadowNode.h +++ b/packages/react-native/ReactCommon/react/renderer/components/image/ImageShadowNode.h @@ -9,6 +9,8 @@ #include +#include + #include #include #include diff --git a/packages/react-native/ReactCommon/react/renderer/components/image/ImageState.h b/packages/react-native/ReactCommon/react/renderer/components/image/ImageState.h index d49393e65d9e..249d6ad01bdb 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/image/ImageState.h +++ b/packages/react-native/ReactCommon/react/renderer/components/image/ImageState.h @@ -9,14 +9,15 @@ #include +#include +#include + #include #include #include #ifdef ANDROID #include -#include -#include #endif namespace facebook::react { diff --git a/packages/react-native/ReactCommon/react/renderer/components/image/conversions.cpp b/packages/react-native/ReactCommon/react/renderer/components/image/conversions.cpp new file mode 100644 index 000000000000..c346d066917e --- /dev/null +++ b/packages/react-native/ReactCommon/react/renderer/components/image/conversions.cpp @@ -0,0 +1,180 @@ +/* + * 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. + */ + +#include + +#include +#include + +#include +#include + +namespace facebook::react { + +void fromRawValue( + const PropsParserContext& /* context */, + const RawValue& value, + ImageSource& result) { + if (value.hasType()) { + result = { + /* .type = */ ImageSource::Type::Remote, + /* .uri = */ (std::string)value, + }; + return; + } + + if (value.hasType>()) { + auto items = (std::unordered_map)value; + result = {}; + + result.type = ImageSource::Type::Remote; + + if (items.find("__packager_asset") != items.end()) { + result.type = ImageSource::Type::Local; + } + + if (items.find("width") != items.end() && + items.find("height") != items.end() && + // The following checks have to be removed after codegen is shipped. + // See T45151459. + items.at("width").hasType() && + items.at("height").hasType()) { + result.size = {(Float)items.at("width"), (Float)items.at("height")}; + } + + if (items.find("scale") != items.end() && + // The following checks have to be removed after codegen is shipped. + // See T45151459. + items.at("scale").hasType()) { + result.scale = (Float)items.at("scale"); + } else { + result.scale = items.find("deprecated") != items.end() ? 0.0f : 1.0f; + } + + if (items.find("url") != items.end() && + // The following should be removed after codegen is shipped. + // See T45151459. + items.at("url").hasType()) { + result.uri = (std::string)items.at("url"); + } + + if (items.find("uri") != items.end() && + // The following should be removed after codegen is shipped. + // See T45151459. + items.at("uri").hasType()) { + result.uri = (std::string)items.at("uri"); + } + + if (items.find("bundle") != items.end() && + // The following should be removed after codegen is shipped. + // See T45151459. + items.at("bundle").hasType()) { + result.bundle = (std::string)items.at("bundle"); + result.type = ImageSource::Type::Local; + } + + if (items.find("headers") != items.end() && + items.at("headers") + .hasType>()) { + auto headers = + (std::unordered_map)items.at("headers"); + for (const auto& header : headers) { + result.headers.push_back(header); + } + } + + if (items.find("body") != items.end() && + items.at("body").hasType()) { + result.body = (std::string)items.at("body"); + } + + if (items.find("method") != items.end() && + items.at("method").hasType()) { + result.method = (std::string)items.at("method"); + } + + if (items.find("cache") != items.end() && + items.at("cache").hasType()) { + auto cache = (std::string)items.at("cache"); + if (cache == "reload") { + result.cache = ImageSource::CacheStategy::Reload; + } else if (cache == "force-cache") { + result.cache = ImageSource::CacheStategy::ForceCache; + } else if (cache == "only-if-cached") { + result.cache = ImageSource::CacheStategy::OnlyIfCached; + } + } + + return; + } + + // The following should be removed after codegen is shipped. + // See T45151459. + result = {}; + result.type = ImageSource::Type::Invalid; +} + +std::string toString(const ImageSource& value) { + return "{uri: " + value.uri + "}"; +} + +void fromRawValue( + const PropsParserContext& /* context */, + const RawValue& value, + ImageResizeMode& result) { + react_native_expect(value.hasType()); + if (!value.hasType()) { + LOG(ERROR) << "Unsupported ImageResizeMode type"; + // "cover" is default in non-Fabric web and iOS + result = ImageResizeMode::Cover; + return; + } + + auto stringValue = (std::string)value; + if (stringValue == "cover") { + result = ImageResizeMode::Cover; + } else if (stringValue == "contain") { + result = ImageResizeMode::Contain; + } else if (stringValue == "stretch") { + result = ImageResizeMode::Stretch; + } else if (stringValue == "center") { + result = ImageResizeMode::Center; + } else if (stringValue == "repeat") { + result = ImageResizeMode::Repeat; + } else if (stringValue == "none") { + result = ImageResizeMode::None; + } else { + LOG(ERROR) << "Unsupported ImageResizeMode value: " << stringValue; + react_native_expect(false); + // "cover" is default in non-Fabric web and iOS + result = ImageResizeMode::Cover; + } +} + +std::string toString(const ImageResizeMode& value) { + switch (value) { + case ImageResizeMode::Cover: + return "cover"; + case ImageResizeMode::Contain: + return "contain"; + case ImageResizeMode::Stretch: + return "stretch"; + case ImageResizeMode::Center: + return "center"; + case ImageResizeMode::Repeat: + return "repeat"; + case ImageResizeMode::None: + return "none"; + default: + LOG(ERROR) << "Unsupported ImageResizeMode value: " << (int)value; + react_native_expect(false); + // "cover" is default in non-Fabric web and iOS + return "cover"; + } +} + +} // namespace facebook::react diff --git a/packages/react-native/ReactCommon/react/renderer/components/image/conversions.h b/packages/react-native/ReactCommon/react/renderer/components/image/conversions.h index 5d38e469e3f2..92a50739988e 100644 --- a/packages/react-native/ReactCommon/react/renderer/components/image/conversions.h +++ b/packages/react-native/ReactCommon/react/renderer/components/image/conversions.h @@ -9,167 +9,20 @@ #include -#include +#include -#include -#include #include -#include +#include #include namespace facebook::react { -inline void fromRawValue(const PropsParserContext & /* context */, const RawValue &value, ImageSource &result) -{ - if (value.hasType()) { - result = { - /* .type = */ ImageSource::Type::Remote, - /* .uri = */ (std::string)value, - }; - return; - } +void fromRawValue(const PropsParserContext & /*context*/, const RawValue &value, ImageSource &result); - if (value.hasType>()) { - auto items = (std::unordered_map)value; - result = {}; +std::string toString(const ImageSource &value); - result.type = ImageSource::Type::Remote; +void fromRawValue(const PropsParserContext & /*context*/, const RawValue &value, ImageResizeMode &result); - if (items.find("__packager_asset") != items.end()) { - result.type = ImageSource::Type::Local; - } - - if (items.find("width") != items.end() && items.find("height") != items.end() && - // The following checks have to be removed after codegen is shipped. - // See T45151459. - items.at("width").hasType() && items.at("height").hasType()) { - result.size = {(Float)items.at("width"), (Float)items.at("height")}; - } - - if (items.find("scale") != items.end() && - // The following checks have to be removed after codegen is shipped. - // See T45151459. - items.at("scale").hasType()) { - result.scale = (Float)items.at("scale"); - } else { - result.scale = items.find("deprecated") != items.end() ? 0.0f : 1.0f; - } - - if (items.find("url") != items.end() && - // The following should be removed after codegen is shipped. - // See T45151459. - items.at("url").hasType()) { - result.uri = (std::string)items.at("url"); - } - - if (items.find("uri") != items.end() && - // The following should be removed after codegen is shipped. - // See T45151459. - items.at("uri").hasType()) { - result.uri = (std::string)items.at("uri"); - } - - if (items.find("bundle") != items.end() && - // The following should be removed after codegen is shipped. - // See T45151459. - items.at("bundle").hasType()) { - result.bundle = (std::string)items.at("bundle"); - result.type = ImageSource::Type::Local; - } - - if (items.find("headers") != items.end() && - items.at("headers").hasType>()) { - auto headers = (std::unordered_map)items.at("headers"); - for (const auto &header : headers) { - result.headers.push_back(header); - } - } - - if (items.find("body") != items.end() && items.at("body").hasType()) { - result.body = (std::string)items.at("body"); - } - - if (items.find("method") != items.end() && items.at("method").hasType()) { - result.method = (std::string)items.at("method"); - } - - if (items.find("cache") != items.end() && items.at("cache").hasType()) { - auto cache = (std::string)items.at("cache"); - if (cache == "reload") { - result.cache = ImageSource::CacheStategy::Reload; - } else if (cache == "force-cache") { - result.cache = ImageSource::CacheStategy::ForceCache; - } else if (cache == "only-if-cached") { - result.cache = ImageSource::CacheStategy::OnlyIfCached; - } - } - - return; - } - - // The following should be removed after codegen is shipped. - // See T45151459. - result = {}; - result.type = ImageSource::Type::Invalid; -} - -inline std::string toString(const ImageSource &value) -{ - return "{uri: " + value.uri + "}"; -} - -inline void fromRawValue(const PropsParserContext & /* context */, const RawValue &value, ImageResizeMode &result) -{ - react_native_expect(value.hasType()); - if (!value.hasType()) { - LOG(ERROR) << "Unsupported ImageResizeMode type"; - // "cover" is default in non-Fabric web and iOS - result = ImageResizeMode::Cover; - return; - } - - auto stringValue = (std::string)value; - if (stringValue == "cover") { - result = ImageResizeMode::Cover; - } else if (stringValue == "contain") { - result = ImageResizeMode::Contain; - } else if (stringValue == "stretch") { - result = ImageResizeMode::Stretch; - } else if (stringValue == "center") { - result = ImageResizeMode::Center; - } else if (stringValue == "repeat") { - result = ImageResizeMode::Repeat; - } else if (stringValue == "none") { - result = ImageResizeMode::None; - } else { - LOG(ERROR) << "Unsupported ImageResizeMode value: " << stringValue; - react_native_expect(false); - // "cover" is default in non-Fabric web and iOS - result = ImageResizeMode::Cover; - } -} - -inline std::string toString(const ImageResizeMode &value) -{ - switch (value) { - case ImageResizeMode::Cover: - return "cover"; - case ImageResizeMode::Contain: - return "contain"; - case ImageResizeMode::Stretch: - return "stretch"; - case ImageResizeMode::Center: - return "center"; - case ImageResizeMode::Repeat: - return "repeat"; - case ImageResizeMode::None: - return "none"; - default: - LOG(ERROR) << "Unsupported ImageResizeMode value: " << (int)value; - react_native_expect(false); - // "cover" is default in non-Fabric web and iOS - return "cover"; - } -} +std::string toString(const ImageResizeMode &value); } // namespace facebook::react From d8120e04948602f06131b7065e555439a2aac258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dawid=20Ma=C5=82ecki?= Date: Wed, 30 Sep 2026 04:03:37 -0700 Subject: [PATCH 5/5] Use Image and ImageManager umbrellas in generated components Summary: Fabric component codegen emitted the fine-grained `react/renderer/imagemanager/primitives.h`, `react/renderer/imagemanager/ImageRequest.h`, and `react/renderer/components/image/conversions.h` headers for `ImageSource` and `ImageRequest` props. Those headers are guarded public module headers, so a strict consumer compiling generated code for a component with an image prop hit the umbrella guard. Emit `` for the `ImageSource` and `ImageRequest` types and `` for the `ImageSource` conversions instead, matching how generated code already consumes `` and ``. Both umbrellas are published by Buck, CMake, CocoaPods (including dynamic frameworks), the iOS prebuild, and Android prefab, and every generated components library already depends on the Image and ImageManager targets. Refresh the affected codegen snapshots. Changelog: [Internal] Differential Revision: D122543836 --- .../GeneratePropsCpp-test.js.snap | 8 ++-- .../__snapshots__/GeneratePropsH-test.js.snap | 10 ++-- .../GeneratePropsCpp-test.js.snap | 8 ++-- .../__snapshots__/GeneratePropsH-test.js.snap | 10 ++-- .../src/generators/ReservedPrimitiveTypes.js | 10 ++-- .../GeneratePropsCpp-test.js.snap | 22 ++++----- .../__snapshots__/GeneratePropsH-test.js.snap | 46 +++++++++---------- .../__snapshots__/GenerateTests-test.js.snap | 22 ++++----- 8 files changed, 66 insertions(+), 70 deletions(-) diff --git a/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap b/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap index adbf0eb81071..a079836a7040 100644 --- a/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap @@ -13,8 +13,8 @@ Object { */ #include +#include #include -#include #include #include @@ -590,7 +590,7 @@ Object { */ #include -#include +#include #include #include @@ -814,7 +814,7 @@ Object { */ #include -#include +#include #include #include @@ -933,7 +933,7 @@ Object { */ #include -#include +#include #include #include diff --git a/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap b/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap index f41b85833b98..4f7518f2a30a 100644 --- a/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap +++ b/packages/react-native-codegen/e2e/deep_imports/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap @@ -13,6 +13,7 @@ Object { */ #pragma once +#include #include #include #include @@ -22,7 +23,6 @@ Object { #include #include #include -#include #include #include @@ -647,10 +647,10 @@ Object { */ #pragma once +#include #include #include #include -#include namespace facebook::react { @@ -818,12 +818,12 @@ Object { */ #pragma once +#include #include #include #include #include #include -#include namespace facebook::react { @@ -908,14 +908,14 @@ Object { */ #pragma once +#include +#include #include -#include #include #include #include #include #include -#include #include namespace facebook::react { diff --git a/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap b/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap index f9b2d81b2d8c..a5420f57ae3a 100644 --- a/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap +++ b/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsCpp-test.js.snap @@ -13,8 +13,8 @@ Object { */ #include +#include #include -#include #include #include @@ -590,7 +590,7 @@ Object { */ #include -#include +#include #include #include @@ -814,7 +814,7 @@ Object { */ #include -#include +#include #include #include @@ -933,7 +933,7 @@ Object { */ #include -#include +#include #include #include diff --git a/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap b/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap index a3ba5b86ea2f..464dedf81604 100644 --- a/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap +++ b/packages/react-native-codegen/e2e/namespaced/__tests__/components/__snapshots__/GeneratePropsH-test.js.snap @@ -13,6 +13,7 @@ Object { */ #pragma once +#include #include #include #include @@ -22,7 +23,6 @@ Object { #include #include #include -#include #include #include @@ -647,10 +647,10 @@ Object { */ #pragma once +#include #include #include #include -#include namespace facebook::react { @@ -818,12 +818,12 @@ Object { */ #pragma once +#include #include #include #include #include #include -#include namespace facebook::react { @@ -908,14 +908,14 @@ Object { */ #pragma once +#include +#include #include -#include #include #include #include #include #include -#include #include namespace facebook::react { diff --git a/packages/react-native-codegen/src/generators/ReservedPrimitiveTypes.js b/packages/react-native-codegen/src/generators/ReservedPrimitiveTypes.js index a99d6b0806d3..731bca95d971 100644 --- a/packages/react-native-codegen/src/generators/ReservedPrimitiveTypes.js +++ b/packages/react-native-codegen/src/generators/ReservedPrimitiveTypes.js @@ -61,10 +61,8 @@ const RESERVED_TYPES: {readonly [ReservedPrimitiveName]: ReservedTypeMapping} = ImageSourcePrimitive: { cpp: { typeName: 'ImageSource', - localIncludes: ['#include '], - conversionIncludes: [ - '#include ', - ], + localIncludes: ['#include '], + conversionIncludes: ['#include '], }, java: { interfaceImports: ['import com.facebook.react.bridge.ReadableMap;'], @@ -74,9 +72,7 @@ const RESERVED_TYPES: {readonly [ReservedPrimitiveName]: ReservedTypeMapping} = ImageRequestPrimitive: { cpp: { typeName: 'ImageRequest', - localIncludes: [ - '#include ', - ], + localIncludes: ['#include '], conversionIncludes: [], }, java: { diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap index a88c7f9758e6..750383cc6ec7 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap @@ -13,7 +13,7 @@ Map { */ #include -#include +#include #include #include @@ -147,7 +147,7 @@ Map { */ #include -#include +#include #include #include @@ -295,7 +295,7 @@ Map { */ #include -#include +#include #include #include @@ -443,8 +443,8 @@ Map { */ #include +#include #include -#include #include #include @@ -725,8 +725,8 @@ Map { */ #include +#include #include -#include #include #include @@ -892,8 +892,8 @@ Map { */ #include +#include #include -#include #include #include @@ -1813,7 +1813,7 @@ Map { */ #include -#include +#include #include #include @@ -2143,7 +2143,7 @@ Map { */ #include -#include +#include #include #include @@ -2262,7 +2262,7 @@ Map { */ #include -#include +#include #include #include @@ -2316,7 +2316,7 @@ Map { */ #include -#include +#include #include #include @@ -2374,7 +2374,7 @@ Map { */ #include -#include +#include #include #include diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap index dddfce67e68a..6e69fc48ee3f 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap @@ -13,14 +13,14 @@ Map { */ #pragma once +#include +#include #include -#include #include #include #include #include #include -#include #include namespace facebook::react { @@ -390,14 +390,14 @@ Map { */ #pragma once +#include +#include #include -#include #include #include #include #include #include -#include #include namespace facebook::react { @@ -767,14 +767,14 @@ Map { */ #pragma once +#include +#include #include -#include #include #include #include #include #include -#include #include namespace facebook::react { @@ -1158,6 +1158,7 @@ Map { */ #pragma once +#include #include #include #include @@ -1166,7 +1167,6 @@ Map { #include #include #include -#include #include #include @@ -1458,14 +1458,14 @@ Map { */ #pragma once +#include +#include #include -#include #include #include #include #include #include -#include #include namespace facebook::react { @@ -1561,14 +1561,14 @@ Map { */ #pragma once +#include +#include #include -#include #include #include #include #include #include -#include #include namespace facebook::react { @@ -1664,14 +1664,14 @@ Map { */ #pragma once +#include +#include #include -#include #include #include #include #include #include -#include #include namespace facebook::react { @@ -1773,6 +1773,7 @@ Map { */ #pragma once +#include #include #include #include @@ -1781,7 +1782,6 @@ Map { #include #include #include -#include #include #include @@ -2073,6 +2073,7 @@ Map { */ #pragma once +#include #include #include #include @@ -2081,7 +2082,6 @@ Map { #include #include #include -#include #include #include @@ -2952,10 +2952,10 @@ Map { */ #pragma once +#include #include #include #include -#include namespace facebook::react { @@ -3250,12 +3250,12 @@ Map { */ #pragma once +#include #include #include #include #include #include -#include namespace facebook::react { @@ -3340,14 +3340,14 @@ Map { */ #pragma once +#include +#include #include -#include #include #include #include #include #include -#include #include namespace facebook::react { @@ -3777,14 +3777,14 @@ Map { */ #pragma once +#include +#include #include -#include #include #include #include #include #include -#include #include namespace facebook::react { @@ -4214,14 +4214,14 @@ Map { */ #pragma once +#include +#include #include -#include #include #include #include #include #include -#include #include namespace facebook::react { diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap index 55dc41f9c75f..a78fa7990fbe 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap @@ -14,7 +14,7 @@ Map { #include #include #include -#include +#include #include #include #include @@ -180,7 +180,7 @@ Map { #include #include #include -#include +#include #include #include #include @@ -346,7 +346,7 @@ Map { #include #include #include -#include +#include #include #include #include @@ -512,8 +512,8 @@ Map { #include #include #include +#include #include -#include #include #include #include @@ -654,8 +654,8 @@ Map { #include #include #include +#include #include -#include #include #include #include @@ -691,8 +691,8 @@ Map { #include #include #include +#include #include -#include #include #include #include @@ -1353,7 +1353,7 @@ Map { #include #include #include -#include +#include #include #include #include @@ -1591,7 +1591,7 @@ Map { #include #include #include -#include +#include #include #include #include @@ -1714,7 +1714,7 @@ Map { #include #include #include -#include +#include #include #include #include @@ -1750,7 +1750,7 @@ Map { #include #include #include -#include +#include #include #include #include @@ -1786,7 +1786,7 @@ Map { #include #include #include -#include +#include #include #include #include