diff --git a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm index 3028b1902d7f..f5e39bda6b1b 100644 --- a/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm +++ b/packages/react-native/Libraries/AppDelegate/RCTAppDelegate.mm @@ -30,6 +30,7 @@ #else #import #endif +#import #import #import @@ -219,6 +220,10 @@ - (Class)getModuleClassFromName:(const char *)name return std::make_shared(jsInvoker); } + if (name == facebook::react::NativeDOM::kModuleName) { + return std::make_shared(jsInvoker); + } + return nullptr; } diff --git a/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec b/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec index cbc952669aee..7d7483dac622 100644 --- a/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec +++ b/packages/react-native/Libraries/AppDelegate/React-RCTAppDelegate.podspec @@ -77,6 +77,7 @@ Pod::Spec.new do |s| s.dependency "React-CoreModules" s.dependency "React-nativeconfig" s.dependency "ReactCodegen" + s.dependency "React-domnativemodule" s.dependency "React-featureflagsnativemodule" s.dependency "React-microtasksnativemodule" diff --git a/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt b/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt index 1e0a86425d98..bab719bc4f1a 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt +++ b/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt @@ -104,6 +104,7 @@ add_react_common_subdir(react/utils) add_react_common_subdir(react/bridging) add_react_common_subdir(react/renderer/mapbuffer) add_react_common_subdir(react/nativemodule/core) +add_react_common_subdir(react/nativemodule/dom) add_react_common_subdir(react/nativemodule/featureflags) add_react_common_subdir(react/nativemodule/microtasks) add_react_common_subdir(jserrorhandler) diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/newarchdefaults/CMakeLists.txt b/packages/react-native/ReactAndroid/src/main/jni/react/newarchdefaults/CMakeLists.txt index d541aa2305c8..d0fbbe8aba9d 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/newarchdefaults/CMakeLists.txt +++ b/packages/react-native/ReactAndroid/src/main/jni/react/newarchdefaults/CMakeLists.txt @@ -21,6 +21,7 @@ target_link_libraries(react_newarchdefaults react_nativemodule_core react_codegen_rncore react_cxxreactpackage + react_nativemodule_dom react_nativemodule_featureflags react_nativemodule_microtasks jsi) diff --git a/packages/react-native/ReactAndroid/src/main/jni/react/newarchdefaults/DefaultTurboModuleManagerDelegate.cpp b/packages/react-native/ReactAndroid/src/main/jni/react/newarchdefaults/DefaultTurboModuleManagerDelegate.cpp index 7a291d718215..f7547b1f801c 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/react/newarchdefaults/DefaultTurboModuleManagerDelegate.cpp +++ b/packages/react-native/ReactAndroid/src/main/jni/react/newarchdefaults/DefaultTurboModuleManagerDelegate.cpp @@ -9,6 +9,7 @@ #include +#include #include #include #include @@ -83,6 +84,10 @@ std::shared_ptr DefaultTurboModuleManagerDelegate::getTurboModule( return std::make_shared(jsInvoker); } + if (name == NativeDOM::kModuleName) { + return std::make_shared(jsInvoker); + } + return nullptr; } diff --git a/packages/react-native/ReactCommon/react/nativemodule/dom/CMakeLists.txt b/packages/react-native/ReactCommon/react/nativemodule/dom/CMakeLists.txt new file mode 100644 index 000000000000..ebb9c3dd7c7d --- /dev/null +++ b/packages/react-native/ReactCommon/react/nativemodule/dom/CMakeLists.txt @@ -0,0 +1,27 @@ +# 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. + +cmake_minimum_required(VERSION 3.13) +set(CMAKE_VERBOSE_MAKEFILE on) + +add_compile_options( + -fexceptions + -frtti + -std=c++20 + -Wall + -Wpedantic + -DLOG_TAG=\"ReactNative\") + +file(GLOB react_nativemodule_dom_SRC CONFIGURE_DEPENDS *.cpp) +add_library(react_nativemodule_dom SHARED ${react_nativemodule_dom_SRC}) + +target_include_directories(react_nativemodule_dom PUBLIC ${REACT_COMMON_DIR}) + +target_link_libraries(react_nativemodule_dom + rrc_root + react_render_dom + react_render_uimanager + react_codegen_rncore + reactnative) diff --git a/packages/react-native/ReactCommon/react/nativemodule/dom/NativeDOM.cpp b/packages/react-native/ReactCommon/react/nativemodule/dom/NativeDOM.cpp index 301932f97fca..490a692808f5 100644 --- a/packages/react-native/ReactCommon/react/nativemodule/dom/NativeDOM.cpp +++ b/packages/react-native/ReactCommon/react/nativemodule/dom/NativeDOM.cpp @@ -9,7 +9,6 @@ #include #include #include -#include #include #ifdef RN_DISABLE_OSS_PLUGIN_HEADER diff --git a/packages/react-native/ReactCommon/react/nativemodule/dom/React-domnativemodule.podspec b/packages/react-native/ReactCommon/react/nativemodule/dom/React-domnativemodule.podspec new file mode 100644 index 000000000000..d4f354ec59d5 --- /dev/null +++ b/packages/react-native/ReactCommon/react/nativemodule/dom/React-domnativemodule.podspec @@ -0,0 +1,51 @@ +# 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. + +require "json" + +package = JSON.parse(File.read(File.join(__dir__, "..", "..", "..", "..", "package.json"))) +version = package['version'] + +source = { :git => 'https://github.com/facebook/react-native.git' } +if version == '1000.0.0' + # This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in. + source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1") +else + source[:tag] = "v#{version}" +end + +header_search_paths = [] + +if ENV['USE_FRAMEWORKS'] + header_search_paths << "\"$(PODS_TARGET_SRCROOT)/../../..\"" # this is needed to allow the domnativemodule to access its own files +end + +Pod::Spec.new do |s| + s.name = "React-domnativemodule" + s.version = version + s.summary = "React Native DOM native module" + s.homepage = "https://reactnative.dev/" + s.license = package["license"] + s.author = "Meta Platforms, Inc. and its affiliates" + s.platforms = min_supported_versions + s.source = source + s.source_files = "*.{cpp,h}" + s.header_dir = "react/nativemodule/dom" + s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => "c++20", + "HEADER_SEARCH_PATHS" => header_search_paths.join(' '), + "DEFINES_MODULE" => "YES" } + + if ENV['USE_FRAMEWORKS'] + s.module_name = "React_domnativemodule" + s.header_mappings_dir = "../.." + end + + install_modules_dependencies(s) + + s.dependency "ReactCommon/turbomodule/core" + s.dependency "React-Fabric/uimanager" + s.dependency "React-Fabric/dom" + s.dependency "React-Fabric/components/root" +end diff --git a/packages/react-native/scripts/react_native_pods.rb b/packages/react-native/scripts/react_native_pods.rb index cacfbda1ffe7..0f26b6d9dba0 100644 --- a/packages/react-native/scripts/react_native_pods.rb +++ b/packages/react-native/scripts/react_native_pods.rb @@ -129,6 +129,7 @@ def use_react_native! ( pod 'React-featureflags', :path => "#{prefix}/ReactCommon/react/featureflags" pod 'React-featureflagsnativemodule', :path => "#{prefix}/ReactCommon/react/nativemodule/featureflags" pod 'React-microtasksnativemodule', :path => "#{prefix}/ReactCommon/react/nativemodule/microtasks" + pod 'React-domnativemodule', :path => "#{prefix}/ReactCommon/react/nativemodule/dom" pod 'React-Mapbuffer', :path => "#{prefix}/ReactCommon" pod 'React-jserrorhandler', :path => "#{prefix}/ReactCommon/jserrorhandler" pod 'React-nativeconfig', :path => "#{prefix}/ReactCommon"