Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 15 additions & 16 deletions packages/react-native/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ let reactCxxReact = RNTarget(
path: "ReactCommon/cxxreact",
searchPaths: [CallInvokerPath],
excludedPaths: ["tests"],
dependencies: [.reactNativeDependencies, .jsi, .reactPerfLogger, .logger, .reactDebug, .reactJsInspector]
dependencies: [.reactNativeDependencies, .jsi, .reactPerfLogger, .logger, .reactDebug, .reactJsErrorHandler, .reactJsInspector]
)

/// React-jsitooling.podspec
Expand All @@ -212,7 +212,7 @@ let reactJsiTooling = RNTarget(
let reactJsiExecutor = RNTarget(
name: .reactJsiExecutor,
path: "ReactCommon/jsiexecutor",
dependencies: [.reactNativeDependencies, .jsi, .reactCxxReact, .reactJsiTooling]
dependencies: [.reactNativeDependencies, .jsi, .reactCxxReact, .reactJsErrorHandler, .reactJsiTooling]
)

/// React-hermes.podspec
Expand Down Expand Up @@ -259,24 +259,15 @@ let reactRuntimeScheduler = RNTarget(
name: .reactRuntimeScheduler,
path: "ReactCommon/react/renderer/runtimescheduler",
excludedPaths: ["tests"],
dependencies: [.reactNativeDependencies, .reactFeatureFlags, .reactCxxReact, .reactPerfLogger, .reactPerformanceTimeline, .reactRendererConsistency, .reactUtils, .reactRuntimeExecutor]
dependencies: [.reactNativeDependencies, .reactFeatureFlags, .reactCxxReact, .reactJsErrorHandler, .reactPerfLogger, .reactPerformanceTimeline, .reactRendererConsistency, .reactUtils, .reactRuntimeExecutor]
)

/// ReactCommon.podspec
/// This target represent the ReactCommon/turbomodule/bridging subspec
/// React-bridging.podspec
let reactTurboModuleBridging = RNTarget(
name: .reactTurboModuleBridging,
path: "ReactCommon/react/bridging",
excludedPaths: ["tests"],
dependencies: [.reactNativeDependencies, .reactPerfLogger, .reactCxxReact, .jsi, .logger]
)

/// React-jserrorhandler.podspec
let reactJsErrorHandler = RNTarget(
name: .reactJsErrorHandler,
path: "ReactCommon/jserrorhandler",
excludedPaths: ["tests"],
dependencies: [.reactNativeDependencies, .jsi, .reactCxxReact, .reactFeatureFlags, .reactDebug, .reactTurboModuleBridging]
dependencies: [.reactNativeDependencies, .reactPerfLogger, .jsi, .logger]
)

/// React-graphicsApple
Expand Down Expand Up @@ -307,7 +298,7 @@ let reactTurboModuleCore = RNTarget(
"ReactCommon/react/nativemodule/core/platform/ios",
],
excludedPaths: ["platform/android", "iostests"],
dependencies: [.reactNativeDependencies, .reactDebug, .reactFeatureFlags, .reactUtils, .reactPerfLogger, .reactCxxReact, .reactTurboModuleBridging, .yoga, .reactRuntimeExecutor]
dependencies: [.reactNativeDependencies, .reactDebug, .reactJsErrorHandler, .reactFeatureFlags, .reactUtils, .reactPerfLogger, .reactCxxReact, .reactTurboModuleBridging, .yoga, .reactRuntimeExecutor]
)

/// React-defaultsnativemodule.podspec
Expand Down Expand Up @@ -396,6 +387,14 @@ let reactCoreModules = RNTarget(
dependencies: [.reactNativeDependencies, .jsi, .yoga, .reactTurboModuleCore, .reactFeatureFlags]
)

/// React-jserrorhandler.podspec
let reactJsErrorHandler = RNTarget(
name: .reactJsErrorHandler,
path: "ReactCommon/jserrorhandler",
excludedPaths: ["tests"],
dependencies: [.reactNativeDependencies, .jsi, .reactFeatureFlags, .reactDebug, .reactTurboModuleBridging]
)

/// React-runtimeCore.podspec
/// React-runtimeHermes.podspec
let reactRuntime = RNTarget(
Expand Down Expand Up @@ -904,7 +903,7 @@ extension String {
static let reactRCTLinking = "React-RCTLinking"
static let reactCoreModules = "React-CoreModules"
static let reactRCTAnimatedModuleProvider = "RCTAnimatedModuleProvider"
static let reactTurboModuleBridging = "ReactCommon/turbomodule/bridging"
static let reactTurboModuleBridging = "React-bridging"
static let reactTurboModuleCore = "ReactCommon/turbomodule/core"
static let reactTurboModuleCoreDefaults = "ReactCommon/turbomodule/core/defaults"
static let reactTurboModuleCoreMicrotasks = "ReactCommon/turbomodule/core/microtasks"
Expand Down
16 changes: 3 additions & 13 deletions packages/react-native/ReactCommon/ReactCommon.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -43,27 +43,17 @@ Pod::Spec.new do |s|
s.subspec "turbomodule" do |ss|
ss.dependency "React-callinvoker", version
ss.dependency "React-perflogger", version
ss.dependency "React-cxxreact", version
ss.dependency "React-jsi", version
ss.dependency "React-logger", version
if use_hermes()
ss.dependency "hermes-engine"
end

ss.subspec "bridging" do |sss|
sss.dependency "React-jsi", version
sss.source_files = podspec_sources("react/bridging/**/*.{cpp,h}", "react/bridging/**/*.h")
sss.exclude_files = "react/bridging/tests"
sss.header_dir = "react/bridging"
sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\"" }
if use_hermes()
sss.dependency "hermes-engine"
end
end

ss.subspec "core" do |sss|
sss.source_files = podspec_sources("react/nativemodule/core/ReactCommon/**/*.{cpp,h}", "react/nativemodule/core/ReactCommon/**/*.h")
sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_debug.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_featureflags.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers\"" }
sss.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_debug.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_featureflags.framework/Headers\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-utils/React_utils.framework/Headers\"" }
sss.dependency "React-bridging"
sss.dependency "React-cxxreact", version
sss.dependency "React-debug", version
sss.dependency "React-featureflags", version
sss.dependency "React-utils", version
Expand Down
1 change: 1 addition & 0 deletions packages/react-native/ReactCommon/cxxreact/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ target_link_libraries(react_cxxreact
callinvoker
folly_runtime
glog
jserrorhandler
jsi
jsinspector
logger
Expand Down
34 changes: 2 additions & 32 deletions packages/react-native/ReactCommon/cxxreact/ErrorUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,6 @@

#pragma once

#include <jsi/jsi.h>
#warning Deprecated: use <jserrorhandler/ErrorUtils.h> instead.

namespace facebook::react {

inline static void handleJSError(jsi::Runtime &runtime, const jsi::JSError &error, bool isFatal)
{
auto errorUtils = runtime.global().getProperty(runtime, "ErrorUtils");
if (errorUtils.isUndefined() || !errorUtils.isObject() ||
!errorUtils.getObject(runtime).hasProperty(runtime, "reportFatalError") ||
!errorUtils.getObject(runtime).hasProperty(runtime, "reportError")) {
// ErrorUtils was not set up. This probably means the bundle didn't
// load properly.
throw jsi::JSError(
runtime,
"ErrorUtils is not set up properly. Something probably went wrong trying to load the JS bundle. Trying to report error " +
error.getMessage(),
error.getStack());
}

// TODO(janzer): Rewrite this function to return the processed error
// instead of just reporting it through the native module
if (isFatal) {
auto func = errorUtils.asObject(runtime).getPropertyAsFunction(runtime, "reportFatalError");

func.call(runtime, error.value());
} else {
auto func = errorUtils.asObject(runtime).getPropertyAsFunction(runtime, "reportError");

func.call(runtime, error.value());
}
}

} // namespace facebook::react
#include <jserrorhandler/ErrorUtils.h>
2 changes: 1 addition & 1 deletion packages/react-native/ReactCommon/cxxreact/Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#ifndef RCT_REMOVE_LEGACY_ARCH

#include "ErrorUtils.h"
#include <jserrorhandler/ErrorUtils.h>
#include "JSBigString.h"
#include "JSBundleType.h"
#include "JSExecutor.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <jsi/jsi.h>
#include <reactperflogger/BridgeNativeModulePerfLogger.h>

#include "ErrorUtils.h"
#include <jserrorhandler/ErrorUtils.h>
#include "Instance.h"
#include "JSBigString.h"
#include "MessageQueueThread.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Pod::Spec.new do |s|
s.source = source
s.source_files = podspec_sources("*.{cpp,h}", "*.h")
s.pod_target_xcconfig = {
"HEADER_SEARCH_PATHS" => "\"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_debug.framework/Headers\" \"${PODS_CONFIGURATION_BUILD_DIR}/React-runtimeexecutor/React_runtimeexecutor.framework/Headers\"",
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/..\" \"$(PODS_CONFIGURATION_BUILD_DIR)/React-debug/React_debug.framework/Headers\" \"${PODS_CONFIGURATION_BUILD_DIR}/React-runtimeexecutor/React_runtimeexecutor.framework/Headers\"",
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard()
}
s.header_dir = "cxxreact"
Expand All @@ -40,6 +40,7 @@ Pod::Spec.new do |s|
s.dependency "React-callinvoker", version
add_dependency(s, "React-runtimeexecutor", :additional_framework_paths => ["platform/ios"])
s.dependency "React-perflogger", version
s.dependency "React-jserrorhandler", version
s.dependency "React-jsi", version
s.dependency "React-logger", version
s.dependency "React-debug", version
Expand Down
42 changes: 42 additions & 0 deletions packages/react-native/ReactCommon/jserrorhandler/ErrorUtils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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 "ErrorUtils.h"

namespace facebook::react {

void handleJSError(
jsi::Runtime& runtime,
const jsi::JSError& error,
bool isFatal) {
auto errorUtils = runtime.global().getProperty(runtime, "ErrorUtils");
if (errorUtils.isUndefined() || !errorUtils.isObject() ||
!errorUtils.getObject(runtime).hasProperty(runtime, "reportFatalError") ||
!errorUtils.getObject(runtime).hasProperty(runtime, "reportError")) {
// ErrorUtils was not set up. This probably means the bundle didn't
// load properly.
throw jsi::JSError(
runtime,
"ErrorUtils is not set up properly. Something probably went wrong trying to load the JS bundle. Trying to report error " +
error.getMessage(),
error.getStack());
}

// TODO(janzer): Rewrite this function to return the processed error
// instead of just reporting it through the native module
if (isFatal) {
auto func = errorUtils.asObject(runtime).getPropertyAsFunction(
runtime, "reportFatalError");
func.call(runtime, error.value());
} else {
auto func = errorUtils.asObject(runtime).getPropertyAsFunction(
runtime, "reportError");
func.call(runtime, error.value());
}
}

} // namespace facebook::react
16 changes: 16 additions & 0 deletions packages/react-native/ReactCommon/jserrorhandler/ErrorUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* 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 <jsi/jsi.h>

namespace facebook::react {

void handleJSError(jsi::Runtime &runtime, const jsi::JSError &error, bool isFatal);

} // namespace facebook::react
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
*/

#include "JsErrorHandler.h"
#include <cxxreact/ErrorUtils.h>
#include <glog/logging.h>
#include <react/bridging/Bridging.h>
#include <react/featureflags/ReactNativeFeatureFlags.h>
#include <ostream>
#include <string>
#include "ErrorUtils.h"
#include "StackTraceParser.h"

using namespace facebook;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.source = source
s.header_dir = "jserrorhandler"
s.source_files = podspec_sources(["JsErrorHandler.{cpp,h}", "StackTraceParser.{cpp,h}"], ["JsErrorHandler.h", "StackTraceParser.h"])
s.source_files = podspec_sources(["ErrorUtils.{cpp,h}", "JsErrorHandler.{cpp,h}", "StackTraceParser.{cpp,h}"], ["ErrorUtils.h", "JsErrorHandler.h", "StackTraceParser.h"])
s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard()
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/..\""
}

resolve_use_frameworks(s, header_mappings_dir: '../', module_name: "React_jserrorhandler")

s.dependency "React-jsi"
s.dependency "React-cxxreact"
s.dependency "ReactCommon/turbomodule/bridging"
s.dependency "React-bridging"
add_dependency(s, "React-featureflags")
add_dependency(s, "React-debug")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ Pod::Spec.new do |s|
s.platforms = min_supported_versions
s.source = source
s.source_files = podspec_sources("jsireact/*.{cpp,h}", "jsireact/*.h")
s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard() }
s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/..\"" }
s.header_dir = "jsireact"

s.dependency "React-cxxreact"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

#include "jsireact/JSIExecutor.h"

#include <cxxreact/ErrorUtils.h>
#include <cxxreact/JSBigString.h>
#include <cxxreact/ModuleRegistry.h>
#include <cxxreact/ReactMarker.h>
#include <cxxreact/TraceSection.h>
#include <folly/json.h>
#include <glog/logging.h>
#include <jserrorhandler/ErrorUtils.h>
#include <jsi/JSIDynamic.h>
#include <jsi/instrumentation.h>
#include <reactperflogger/BridgeNativeModulePerfLogger.h>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# 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

Pod::Spec.new do |s|
s.name = "React-bridging"
s.version = version
s.summary = "-"
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 = podspec_sources("*.{cpp,h}", "*.h")
s.header_dir = "react/bridging"
s.pod_target_xcconfig = {
"USE_HEADERMAP" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
"DEFINES_MODULE" => "YES"
}

resolve_use_frameworks(s, header_mappings_dir: "../..", module_name: "React_bridging")

s.dependency "React-jsi"
s.dependency "React-callinvoker"
s.dependency "React-timing"
s.dependency "React-logger"
s.dependency "React-perflogger"

add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Pod::Spec.new do |s|
s.source_files = podspec_sources("ReactCommon/**/*.{mm,cpp,h}", "ReactCommon/**/*.{h}")

s.dependency "ReactCommon/turbomodule/core"
s.dependency "ReactCommon/turbomodule/bridging"
s.dependency "React-bridging"
s.dependency "React-callinvoker"
s.dependency "React-Core"
s.dependency "React-cxxreact"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ target_include_directories(react_renderer_runtimescheduler PUBLIC ${REACT_COMMON

target_link_libraries(react_renderer_runtimescheduler
callinvoker
jserrorhandler
jsi
react_debug
react_performance_timeline
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ Pod::Spec.new do |s|
s.dependency "React-featureflags"
s.dependency "React-timing"
s.dependency "React-jsi"
s.dependency "React-jserrorhandler"
s.dependency "React-performancetimeline"
s.dependency "React-rendererconsistency"
add_dependency(s, "React-debug")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include "RuntimeScheduler_Legacy.h"
#endif

#include <cxxreact/ErrorUtils.h>
#include <cxxreact/TraceSection.h>
#include <jserrorhandler/ErrorUtils.h>
#ifndef RCT_REMOVE_LEGACY_ARCH
#include <react/featureflags/ReactNativeFeatureFlags.h>
#endif
Expand Down
Loading
Loading