react-native-tvos 0.83.6-0 → 0.83.10-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Libraries/ActionSheetIOS/React-RCTActionSheet.podspec +1 -1
- package/Libraries/Animated/components/AnimatedScrollView.js +1 -1
- package/Libraries/AppDelegate/React-RCTAppDelegate.podspec +1 -1
- package/Libraries/Blob/React-RCTBlob.podspec +1 -1
- package/Libraries/Components/Button.js +2 -2
- package/Libraries/Components/ScrollView/ScrollView.d.ts +1 -1
- package/Libraries/Components/ScrollView/ScrollView.js +1 -1
- package/Libraries/Components/TV/TVViewPropTypes.js +9 -0
- package/Libraries/Components/TextInput/AndroidTextInputNativeComponent.js +1 -1
- package/Libraries/Components/TextInput/TextInput.flow.js +1 -1
- package/Libraries/Components/Touchable/Touchable.d.ts +1 -1
- package/Libraries/Components/View/View.js +7 -3
- package/Libraries/Components/View/ViewAccessibility.d.ts +1 -1
- package/Libraries/Components/View/ViewAccessibility.js +1 -1
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Core/Timers/JSTimers.js +1 -1
- package/Libraries/Core/setUpNavigator.js +1 -1
- package/Libraries/EventEmitter/RCTNativeAppEventEmitter.d.ts +1 -1
- package/Libraries/FBLazyVector/FBLazyVector.podspec +1 -1
- package/Libraries/Image/ImageSource.d.ts +1 -1
- package/Libraries/Image/RCTImageLoader.mm +1 -1
- package/Libraries/Image/React-RCTImage.podspec +1 -1
- package/Libraries/Interaction/PanResponder.js +1 -1
- package/Libraries/LinkingIOS/React-RCTLinking.podspec +1 -1
- package/Libraries/NativeAnimation/React-RCTAnimation.podspec +1 -1
- package/Libraries/NativeComponent/TVViewConfig.js +1 -0
- package/Libraries/Network/React-RCTNetwork.podspec +1 -1
- package/Libraries/PushNotificationIOS/React-RCTPushNotification.podspec +1 -1
- package/Libraries/Renderer/README.md +2 -2
- package/Libraries/Required/RCTRequired.podspec +1 -1
- package/Libraries/Settings/React-RCTSettings.podspec +1 -1
- package/Libraries/Text/React-RCTText.podspec +1 -1
- package/Libraries/TypeSafety/RCTTypeSafety.podspec +1 -1
- package/Libraries/Utilities/PolyfillFunctions.js +1 -1
- package/Libraries/Vibration/React-RCTVibration.podspec +1 -1
- package/README-core.md +6 -6
- package/README.md +13 -1
- package/React/Base/RCTVersion.m +1 -1
- package/React/CoreModules/RCTJscSafeUrl+Internal.h +23 -0
- package/React/CoreModules/RCTJscSafeUrl.mm +38 -0
- package/React/CoreModules/RCTRedBox+Internal.h +42 -0
- package/React/CoreModules/RCTRedBox.mm +30 -471
- package/React/CoreModules/RCTRedBox2AnsiParser+Internal.h +22 -0
- package/React/CoreModules/RCTRedBox2AnsiParser.mm +55 -0
- package/React/CoreModules/RCTRedBox2Controller+Internal.h +34 -0
- package/React/CoreModules/RCTRedBox2Controller.mm +764 -0
- package/React/CoreModules/RCTRedBox2ErrorParser+Internal.h +46 -0
- package/React/CoreModules/RCTRedBox2ErrorParser.mm +57 -0
- package/React/CoreModules/RCTRedBoxController+Internal.h +31 -0
- package/React/CoreModules/RCTRedBoxController.mm +447 -0
- package/React/CoreModules/RCTRedBoxHMRClient+Internal.h +26 -0
- package/React/CoreModules/RCTRedBoxHMRClient.mm +125 -0
- package/React/CoreModules/React-CoreModules.podspec +2 -1
- package/React/FBReactNativeSpec/FBReactNativeSpecJSI.h +24 -0
- package/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +49 -17
- package/React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm +12 -1
- package/React/Fabric/Mounting/ComponentViews/View/RCTViewComponentView.mm +35 -7
- package/React/React-RCTFBReactNativeSpec.podspec +1 -1
- package/React/React-RCTFabric.podspec +1 -1
- package/React/Runtime/React-RCTRuntime.podspec +1 -1
- package/React/Tests/Mounting/RCTViewComponentViewTests.mm +145 -0
- package/React/Views/ScrollView/RCTScrollView.m +1 -1
- package/React-Core.podspec +1 -1
- package/React.podspec +1 -1
- package/ReactAndroid/build.gradle.kts +1 -1
- package/ReactAndroid/gradle.properties +1 -1
- package/ReactAndroid/hermes-engine/build.gradle.kts +6 -0
- package/ReactAndroid/publish.gradle +20 -46
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/CxxInspectorPackagerConnection.kt +99 -9
- package/ReactAndroid/src/main/java/com/facebook/react/devsupport/inspector/InspectorNetworkHelper.kt +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/SurfaceMountingManager.java +2 -2
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt +19 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt +31 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt +7 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt +7 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt +34 -1
- package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt +7 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/core/JavaTimerManager.kt +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/core/ReactAndroidHWInputDeviceHelper.java +1 -0
- package/ReactAndroid/src/main/java/com/facebook/react/modules/intent/IntentModule.kt +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.kt +3 -3
- package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/runtime/ReactInstance.kt +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java +14 -4
- package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java +14 -4
- package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewHelper.kt +46 -6
- package/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollViewManager.kt +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.kt +2 -2
- package/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.kt +2 -2
- package/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextSelectionWatcher.kt +1 -1
- package/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.kt +1 -0
- package/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewManager.kt +5 -0
- package/ReactAndroid/src/main/jni/CMakeLists.txt +7 -0
- package/ReactAndroid/src/main/jni/react/devsupport/JCxxInspectorPackagerConnectionWebSocket.cpp +29 -2
- package/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp +43 -1
- package/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h +10 -1
- package/ReactApple/Libraries/RCTFoundation/RCTDeprecation/RCTDeprecation.podspec +1 -1
- package/ReactApple/RCTSwiftUI/RCTSwiftUI.podspec +1 -1
- package/ReactApple/RCTSwiftUIWrapper/RCTSwiftUIWrapper.podspec +1 -1
- package/ReactCommon/React-Fabric.podspec +7 -1
- package/ReactCommon/React-FabricComponents.podspec +1 -1
- package/ReactCommon/React-FabricImage.podspec +1 -1
- package/ReactCommon/React-Mapbuffer.podspec +1 -1
- package/ReactCommon/ReactCommon.podspec +1 -1
- package/ReactCommon/callinvoker/React-callinvoker.podspec +1 -1
- package/ReactCommon/cxxreact/React-cxxreact.podspec +1 -1
- package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
- package/ReactCommon/hermes/React-hermes.podspec +1 -1
- package/ReactCommon/hermes/executor/React-jsitracing.podspec +1 -1
- package/ReactCommon/jserrorhandler/React-jserrorhandler.podspec +1 -1
- package/ReactCommon/jsi/React-jsi.podspec +1 -1
- package/ReactCommon/jsiexecutor/React-jsiexecutor.podspec +1 -1
- package/ReactCommon/jsinspector-modern/InspectorInterfaces.cpp +7 -3
- package/ReactCommon/jsinspector-modern/React-jsinspector.podspec +1 -1
- package/ReactCommon/jsinspector-modern/TracingAgent.cpp +1 -5
- package/ReactCommon/jsinspector-modern/cdp/React-jsinspectorcdp.podspec +1 -1
- package/ReactCommon/jsinspector-modern/network/React-jsinspectornetwork.podspec +1 -1
- package/ReactCommon/jsinspector-modern/tracing/React-jsinspectortracing.podspec +1 -1
- package/ReactCommon/jsitooling/React-jsitooling.podspec +1 -1
- package/ReactCommon/logger/React-logger.podspec +1 -1
- package/ReactCommon/oscompat/React-oscompat.podspec +1 -1
- package/ReactCommon/react/debug/CMakeLists.txt +2 -1
- package/ReactCommon/react/debug/React-debug.podspec +8 -2
- package/ReactCommon/react/debug/redbox/AnsiParser.cpp +139 -0
- package/ReactCommon/react/debug/redbox/AnsiParser.h +35 -0
- package/ReactCommon/react/debug/redbox/JscSafeUrl.cpp +179 -0
- package/ReactCommon/react/debug/redbox/JscSafeUrl.h +27 -0
- package/ReactCommon/react/debug/redbox/RedBoxErrorParser.cpp +171 -0
- package/ReactCommon/react/debug/redbox/RedBoxErrorParser.h +40 -0
- package/ReactCommon/react/debug/redbox/tests/AnsiParserTest.cpp +97 -0
- package/ReactCommon/react/debug/redbox/tests/JscSafeUrlTest.cpp +173 -0
- package/ReactCommon/react/debug/redbox/tests/RedBoxErrorParserTest.cpp +107 -0
- package/ReactCommon/react/featureflags/React-featureflags.podspec +1 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp +13 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h +16 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp +106 -52
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h +8 -2
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h +13 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h +28 -1
- package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h +4 -1
- package/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.cpp +1 -1
- package/ReactCommon/react/nativemodule/core/platform/ios/React-NativeModulesApple.podspec +1 -1
- package/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTInteropTurboModule.mm +1 -1
- package/ReactCommon/react/nativemodule/core/platform/ios/ReactCommon/RCTTurboModule.mm +1 -1
- package/ReactCommon/react/nativemodule/defaults/CMakeLists.txt +1 -0
- package/ReactCommon/react/nativemodule/defaults/DefaultTurboModules.cpp +7 -0
- package/ReactCommon/react/nativemodule/defaults/React-defaultsnativemodule.podspec +2 -1
- package/ReactCommon/react/nativemodule/dom/React-domnativemodule.podspec +1 -1
- package/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp +16 -1
- package/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h +7 -1
- package/ReactCommon/react/nativemodule/featureflags/React-featureflagsnativemodule.podspec +1 -1
- package/ReactCommon/react/nativemodule/idlecallbacks/React-idlecallbacksnativemodule.podspec +1 -1
- package/ReactCommon/react/nativemodule/intersectionobserver/React-intersectionobservernativemodule.podspec +1 -1
- package/ReactCommon/react/nativemodule/microtasks/React-microtasksnativemodule.podspec +1 -1
- package/ReactCommon/react/nativemodule/mutationobserver/NativeMutationObserver.h +4 -0
- package/ReactCommon/react/nativemodule/mutationobserver/React-mutationobservernativemodule.podspec +66 -0
- package/ReactCommon/react/nativemodule/samples/ReactCommon-Samples.podspec +1 -1
- package/ReactCommon/react/nativemodule/webperformance/React-webperformancenativemodule.podspec +1 -1
- package/ReactCommon/react/networking/React-networking.podspec +1 -1
- package/ReactCommon/react/performance/cdpmetrics/React-performancecdpmetrics.podspec +1 -1
- package/ReactCommon/react/performance/timeline/React-performancetimeline.podspec +1 -1
- package/ReactCommon/react/renderer/animated/internal/primitives.h +1 -1
- package/ReactCommon/react/renderer/components/view/BaseViewProps.cpp +7 -0
- package/ReactCommon/react/renderer/components/view/BaseViewProps.h +1 -0
- package/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.cpp +18 -0
- package/ReactCommon/react/renderer/components/view/platform/android/react/renderer/components/view/HostPlatformViewProps.h +1 -0
- package/ReactCommon/react/renderer/consistency/React-rendererconsistency.podspec +1 -1
- package/ReactCommon/react/renderer/css/React-renderercss.podspec +1 -1
- package/ReactCommon/react/renderer/debug/React-rendererdebug.podspec +1 -1
- package/ReactCommon/react/renderer/graphics/React-graphics.podspec +1 -1
- package/ReactCommon/react/renderer/imagemanager/platform/ios/React-ImageManager.podspec +1 -1
- package/ReactCommon/react/renderer/mounting/internal/CullingContext.cpp +1 -1
- package/ReactCommon/react/renderer/runtimescheduler/React-runtimescheduler.podspec +1 -1
- package/ReactCommon/react/runtime/React-RuntimeCore.podspec +1 -1
- package/ReactCommon/react/runtime/React-RuntimeHermes.podspec +1 -1
- package/ReactCommon/react/runtime/platform/ios/React-RuntimeApple.podspec +1 -1
- package/ReactCommon/react/timing/React-timing.podspec +1 -1
- package/ReactCommon/react/utils/React-utils.podspec +1 -1
- package/ReactCommon/reactperflogger/React-perflogger.podspec +1 -1
- package/ReactCommon/runtimeexecutor/React-runtimeexecutor.podspec +1 -1
- package/ReactCommon/yoga/Yoga.podspec +2 -2
- package/ReactCommon/yoga/yoga/algorithm/AbsoluteLayout.cpp +2 -0
- package/ReactCommon/yoga/yoga/algorithm/CalculateLayout.cpp +11 -7
- package/ReactCommon/yoga/yoga/algorithm/CalculateLayout.h +2 -0
- package/ReactCommon/yoga/yoga/node/Node.cpp +6 -1
- package/package.json +9 -9
- package/scripts/cocoapods/rncore.rb +26 -8
- package/scripts/cocoapods/rndependencies.rb +26 -5
- package/scripts/cocoapods/spm.rb +1 -1
- package/scripts/cocoapods/utils.rb +2 -2
- package/scripts/codegen/templates/ReactAppDependencyProvider.podspec.template +1 -1
- package/scripts/codegen/templates/ReactCodegen.podspec.template +1 -1
- package/scripts/ios-configure-glog.sh +1 -1
- package/scripts/react_native_pods.rb +1 -0
- package/sdks/hermes-engine/hermes-engine.podspec +6 -1
- package/sdks/hermes-engine/hermes-utils.rb +27 -5
- package/src/private/featureflags/ReactNativeFeatureFlags.js +16 -1
- package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +4 -1
- package/src/private/setup/setUpDefaultReactNativeEnvironment.js +6 -0
- package/src/private/types/HostInstance.js +1 -1
- package/src/types/globals.d.ts +2 -2
- package/third-party-podspecs/RCT-Folly.podspec +1 -1
- package/third-party-podspecs/ReactNativeDependencies.podspec +1 -1
- package/third-party-podspecs/glog.podspec +1 -1
- package/types/public/ReactNativeTVTypes.d.ts +9 -0
- package/types/public/ReactNativeTypes.d.ts +2 -2
|
@@ -0,0 +1,171 @@
|
|
|
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
|
+
#include "RedBoxErrorParser.h"
|
|
9
|
+
|
|
10
|
+
#include <regex> // NOLINT(facebook-hte-BadInclude-regex)
|
|
11
|
+
#include <unordered_set>
|
|
12
|
+
|
|
13
|
+
// @lint-ignore-every CLANGTIDY facebook-hte-StdRegexIsAwful
|
|
14
|
+
namespace facebook::react::unstable_redbox {
|
|
15
|
+
|
|
16
|
+
namespace {
|
|
17
|
+
|
|
18
|
+
const std::regex& metroErrorRegex() {
|
|
19
|
+
static const std::regex re(
|
|
20
|
+
R"(^(?:InternalError Metro has encountered an error:) (.*): (.*) \((\d+):(\d+)\)\n\n([\s\S]+))");
|
|
21
|
+
return re;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const std::regex& babelTransformErrorRegex() {
|
|
25
|
+
static const std::regex re(
|
|
26
|
+
R"(^(?:TransformError )?(?:SyntaxError: |ReferenceError: )(.*): (.*) \((\d+):(\d+)\)\n\n([\s\S]+))");
|
|
27
|
+
return re;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const std::regex& bundleLoadErrorRegex() {
|
|
31
|
+
static const std::regex re(R"(^(\w+) in (\S+): (.+) \((\d+):(\d+)\))");
|
|
32
|
+
return re;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const std::regex& babelCodeFrameErrorRegex() {
|
|
36
|
+
static const std::regex re(
|
|
37
|
+
R"(^(?:TransformError )?(?:.*):? (?:.*?)(\/.*): ([\s\S]+?)\n([ >]{2}[\d\s]+ \|[\s\S]+|\x1b[\s\S]+))");
|
|
38
|
+
return re;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
bool startsWithTransformError(const std::string& msg) {
|
|
42
|
+
return msg.rfind("TransformError ", 0) == 0;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const std::unordered_set<std::string>& knownBundleLoadErrorTypes() {
|
|
46
|
+
static const std::unordered_set<std::string> types{
|
|
47
|
+
"SyntaxError", "ReferenceError", "TypeError", "UnableToResolveError"};
|
|
48
|
+
return types;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
} // namespace
|
|
52
|
+
|
|
53
|
+
ParsedError parseErrorMessage(
|
|
54
|
+
const std::string& message,
|
|
55
|
+
const std::string& name,
|
|
56
|
+
const std::string& componentStack,
|
|
57
|
+
bool isFatal) {
|
|
58
|
+
std::smatch match;
|
|
59
|
+
|
|
60
|
+
if (message.empty()) {
|
|
61
|
+
return ParsedError{
|
|
62
|
+
.title = isFatal ? "Uncaught Error" : "Error",
|
|
63
|
+
.message = "",
|
|
64
|
+
.codeFrame = std::nullopt,
|
|
65
|
+
.isCompileError = false,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 1. Metro internal error
|
|
70
|
+
if (std::regex_search(message, match, metroErrorRegex())) {
|
|
71
|
+
return ParsedError{
|
|
72
|
+
.title = match[1].str().empty() ? "Metro Error" : match[1].str(),
|
|
73
|
+
.message = match[2].str(),
|
|
74
|
+
.codeFrame =
|
|
75
|
+
CodeFrame{
|
|
76
|
+
.content = match[5].str(),
|
|
77
|
+
.fileName = "",
|
|
78
|
+
.row = std::stoi(match[3].str()),
|
|
79
|
+
.column = std::stoi(match[4].str()),
|
|
80
|
+
},
|
|
81
|
+
.isCompileError = true,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// 2. Babel transform error
|
|
86
|
+
if (std::regex_search(message, match, babelTransformErrorRegex())) {
|
|
87
|
+
return ParsedError{
|
|
88
|
+
.title = "Syntax Error",
|
|
89
|
+
.message = match[2].str(),
|
|
90
|
+
.codeFrame =
|
|
91
|
+
CodeFrame{
|
|
92
|
+
.content = match[5].str(),
|
|
93
|
+
.fileName = match[1].str(),
|
|
94
|
+
.row = std::stoi(match[3].str()),
|
|
95
|
+
.column = std::stoi(match[4].str()),
|
|
96
|
+
},
|
|
97
|
+
.isCompileError = true,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// 3. Bundle loading error: "ErrorType in /path: message (line:col)"
|
|
102
|
+
if (std::regex_search(message, match, bundleLoadErrorRegex())) {
|
|
103
|
+
const auto& errorType = match[1].str();
|
|
104
|
+
if (knownBundleLoadErrorTypes().count(errorType) > 0) {
|
|
105
|
+
std::string title = errorType == "UnableToResolveError"
|
|
106
|
+
? "Module Not Found"
|
|
107
|
+
: "Syntax Error";
|
|
108
|
+
std::optional<std::string> codeFrameContent;
|
|
109
|
+
auto newlinePos = message.find('\n');
|
|
110
|
+
if (newlinePos != std::string::npos) {
|
|
111
|
+
codeFrameContent = message.substr(newlinePos + 1);
|
|
112
|
+
}
|
|
113
|
+
return ParsedError{
|
|
114
|
+
.title = title,
|
|
115
|
+
.message = match[3].str(),
|
|
116
|
+
.codeFrame =
|
|
117
|
+
CodeFrame{
|
|
118
|
+
.content = codeFrameContent.value_or(""),
|
|
119
|
+
.fileName = match[2].str(),
|
|
120
|
+
.row = std::stoi(match[4].str()),
|
|
121
|
+
.column = std::stoi(match[5].str()),
|
|
122
|
+
},
|
|
123
|
+
.isCompileError = true,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// 4. Babel code frame error
|
|
129
|
+
if (std::regex_search(message, match, babelCodeFrameErrorRegex())) {
|
|
130
|
+
return ParsedError{
|
|
131
|
+
.title = "Syntax Error",
|
|
132
|
+
.message = match[2].str(),
|
|
133
|
+
.codeFrame =
|
|
134
|
+
CodeFrame{
|
|
135
|
+
.content = match[3].str(),
|
|
136
|
+
.fileName = match[1].str(),
|
|
137
|
+
},
|
|
138
|
+
.isCompileError = true,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// 5. Generic transform error (no code frame)
|
|
143
|
+
if (startsWithTransformError(message)) {
|
|
144
|
+
return ParsedError{
|
|
145
|
+
.title = "Syntax Error",
|
|
146
|
+
.message = message,
|
|
147
|
+
.codeFrame = std::nullopt,
|
|
148
|
+
.isCompileError = true,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// 6. Determine title from context (matching LogBoxInspectorHeader title map)
|
|
153
|
+
std::string title;
|
|
154
|
+
if (!name.empty()) {
|
|
155
|
+
title = name;
|
|
156
|
+
} else if (!componentStack.empty()) {
|
|
157
|
+
title = "Render Error";
|
|
158
|
+
} else if (isFatal) {
|
|
159
|
+
title = "Uncaught Error";
|
|
160
|
+
} else {
|
|
161
|
+
title = "Error";
|
|
162
|
+
}
|
|
163
|
+
return ParsedError{
|
|
164
|
+
.title = title,
|
|
165
|
+
.message = message,
|
|
166
|
+
.codeFrame = std::nullopt,
|
|
167
|
+
.isCompileError = false,
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
} // namespace facebook::react::unstable_redbox
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
#include <optional>
|
|
11
|
+
#include <string>
|
|
12
|
+
|
|
13
|
+
namespace facebook::react::unstable_redbox {
|
|
14
|
+
|
|
15
|
+
struct CodeFrame {
|
|
16
|
+
std::string content;
|
|
17
|
+
std::string fileName;
|
|
18
|
+
int row = 0;
|
|
19
|
+
int column = 0;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
struct ParsedError {
|
|
23
|
+
std::string title;
|
|
24
|
+
std::string message;
|
|
25
|
+
std::optional<CodeFrame> codeFrame;
|
|
26
|
+
bool isCompileError = false;
|
|
27
|
+
bool isRetryable = true;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Parse a raw error message into structured components.
|
|
32
|
+
* C++ port of parseLogBoxException from parseLogBoxLog.js.
|
|
33
|
+
*/
|
|
34
|
+
ParsedError parseErrorMessage(
|
|
35
|
+
const std::string &message,
|
|
36
|
+
const std::string &name = "",
|
|
37
|
+
const std::string &componentStack = "",
|
|
38
|
+
bool isFatal = true);
|
|
39
|
+
|
|
40
|
+
} // namespace facebook::react::unstable_redbox
|
|
@@ -0,0 +1,97 @@
|
|
|
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
|
+
#include <gtest/gtest.h>
|
|
9
|
+
#include <react/debug/redbox/AnsiParser.h>
|
|
10
|
+
|
|
11
|
+
using namespace facebook::react::unstable_redbox;
|
|
12
|
+
|
|
13
|
+
TEST(AnsiParserTest, ParsesPlainText) {
|
|
14
|
+
auto spans = parseAnsi("hello world");
|
|
15
|
+
ASSERT_EQ(spans.size(), 1);
|
|
16
|
+
EXPECT_EQ(spans[0].text, "hello world");
|
|
17
|
+
EXPECT_FALSE(spans[0].foregroundColor.has_value());
|
|
18
|
+
EXPECT_FALSE(spans[0].backgroundColor.has_value());
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
TEST(AnsiParserTest, ParsesRedForeground) {
|
|
22
|
+
auto spans = parseAnsi("\x1b[31mred text\x1b[0m normal");
|
|
23
|
+
ASSERT_EQ(spans.size(), 2);
|
|
24
|
+
EXPECT_EQ(spans[0].text, "red text");
|
|
25
|
+
ASSERT_TRUE(spans[0].foregroundColor.has_value());
|
|
26
|
+
EXPECT_EQ(spans[0].foregroundColor->r, 187);
|
|
27
|
+
EXPECT_EQ(spans[0].foregroundColor->g, 86);
|
|
28
|
+
EXPECT_EQ(spans[0].foregroundColor->b, 83);
|
|
29
|
+
|
|
30
|
+
EXPECT_EQ(spans[1].text, " normal");
|
|
31
|
+
EXPECT_FALSE(spans[1].foregroundColor.has_value());
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
TEST(AnsiParserTest, ParsesMultipleColors) {
|
|
35
|
+
auto spans = parseAnsi("\x1b[32mgreen\x1b[34mblue\x1b[0m");
|
|
36
|
+
ASSERT_EQ(spans.size(), 2);
|
|
37
|
+
EXPECT_EQ(spans[0].text, "green");
|
|
38
|
+
EXPECT_EQ(spans[0].foregroundColor->r, 144);
|
|
39
|
+
EXPECT_EQ(spans[1].text, "blue");
|
|
40
|
+
EXPECT_EQ(spans[1].foregroundColor->r, 125);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
TEST(AnsiParserTest, ParsesBrightColors) {
|
|
44
|
+
auto spans = parseAnsi("\x1b[93myellow\x1b[0m");
|
|
45
|
+
ASSERT_EQ(spans.size(), 1);
|
|
46
|
+
EXPECT_EQ(spans[0].text, "yellow");
|
|
47
|
+
ASSERT_TRUE(spans[0].foregroundColor.has_value());
|
|
48
|
+
EXPECT_EQ(spans[0].foregroundColor->r, 234);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
TEST(AnsiParserTest, ParsesBackgroundColor) {
|
|
52
|
+
auto spans = parseAnsi("\x1b[41mred bg\x1b[0m");
|
|
53
|
+
ASSERT_EQ(spans.size(), 1);
|
|
54
|
+
EXPECT_EQ(spans[0].text, "red bg");
|
|
55
|
+
EXPECT_FALSE(spans[0].foregroundColor.has_value());
|
|
56
|
+
ASSERT_TRUE(spans[0].backgroundColor.has_value());
|
|
57
|
+
EXPECT_EQ(spans[0].backgroundColor->r, 187);
|
|
58
|
+
EXPECT_EQ(spans[0].backgroundColor->g, 86);
|
|
59
|
+
EXPECT_EQ(spans[0].backgroundColor->b, 83);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
TEST(AnsiParserTest, ResetClearsBackground) {
|
|
63
|
+
auto spans = parseAnsi("\x1b[31;42mcolored\x1b[49mfg only\x1b[0m");
|
|
64
|
+
ASSERT_EQ(spans.size(), 2);
|
|
65
|
+
ASSERT_TRUE(spans[0].foregroundColor.has_value());
|
|
66
|
+
ASSERT_TRUE(spans[0].backgroundColor.has_value());
|
|
67
|
+
ASSERT_TRUE(spans[1].foregroundColor.has_value());
|
|
68
|
+
EXPECT_FALSE(spans[1].backgroundColor.has_value());
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
TEST(AnsiParserTest, ResetShorthandClearsColors) {
|
|
72
|
+
auto spans = parseAnsi("\x1b[31mred\x1b[mplain");
|
|
73
|
+
ASSERT_EQ(spans.size(), 2);
|
|
74
|
+
EXPECT_EQ(spans[0].text, "red");
|
|
75
|
+
ASSERT_TRUE(spans[0].foregroundColor.has_value());
|
|
76
|
+
EXPECT_EQ(spans[1].text, "plain");
|
|
77
|
+
EXPECT_FALSE(spans[1].foregroundColor.has_value());
|
|
78
|
+
EXPECT_FALSE(spans[1].backgroundColor.has_value());
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
TEST(AnsiParserTest, StripsAnsi) {
|
|
82
|
+
auto result = stripAnsi("\x1b[31mred\x1b[0m and \x1b[32mgreen\x1b[0m");
|
|
83
|
+
EXPECT_EQ(result, "red and green");
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
TEST(AnsiParserTest, HandlesEmptyString) {
|
|
87
|
+
auto spans = parseAnsi("");
|
|
88
|
+
EXPECT_TRUE(spans.empty());
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
TEST(AnsiParserTest, HandlesSemicolonSeparatedCodes) {
|
|
92
|
+
auto spans = parseAnsi("\x1b[1;31mtext\x1b[0m");
|
|
93
|
+
ASSERT_EQ(spans.size(), 1);
|
|
94
|
+
EXPECT_EQ(spans[0].text, "text");
|
|
95
|
+
ASSERT_TRUE(spans[0].foregroundColor.has_value());
|
|
96
|
+
EXPECT_EQ(spans[0].foregroundColor->r, 187);
|
|
97
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
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
|
+
#include <gtest/gtest.h>
|
|
9
|
+
#include <react/debug/redbox/JscSafeUrl.h>
|
|
10
|
+
|
|
11
|
+
using namespace facebook::react::unstable_redbox;
|
|
12
|
+
|
|
13
|
+
// --- toNormalUrl ---
|
|
14
|
+
|
|
15
|
+
// Rewrites urls treating //& in paths as ?
|
|
16
|
+
TEST(JscSafeUrlTest, ToNormalUrl_RewritesMarkerInAbsolutePath) {
|
|
17
|
+
EXPECT_EQ(
|
|
18
|
+
toNormalUrl("/path1/path2//&foo=bar?bar=baz#frag?"),
|
|
19
|
+
"/path1/path2?foo=bar&bar=baz#frag?");
|
|
20
|
+
// Idempotent
|
|
21
|
+
EXPECT_EQ(
|
|
22
|
+
toNormalUrl("/path1/path2?foo=bar&bar=baz#frag?"),
|
|
23
|
+
"/path1/path2?foo=bar&bar=baz#frag?");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
TEST(JscSafeUrlTest, ToNormalUrl_RewritesMarkerInRelativePathWithEncoding) {
|
|
27
|
+
EXPECT_EQ(
|
|
28
|
+
toNormalUrl("relative/path/with%3B%26/encoded//&foo=bar?bar=baz#frag?"),
|
|
29
|
+
"relative/path/with%3B%26/encoded?foo=bar&bar=baz#frag?");
|
|
30
|
+
EXPECT_EQ(
|
|
31
|
+
toNormalUrl("relative/path/with%3B%26/encoded?foo=bar&bar=baz#frag?"),
|
|
32
|
+
"relative/path/with%3B%26/encoded?foo=bar&bar=baz#frag?");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
TEST(JscSafeUrlTest, ToNormalUrl_RewritesMarkerInFullUrl) {
|
|
36
|
+
EXPECT_EQ(
|
|
37
|
+
toNormalUrl(
|
|
38
|
+
"https://user:password@mydomain.com:8080/path1/path2//&foo=bar?bar=baz#frag?"),
|
|
39
|
+
"https://user:password@mydomain.com:8080/path1/path2?foo=bar&bar=baz#frag?");
|
|
40
|
+
EXPECT_EQ(
|
|
41
|
+
toNormalUrl(
|
|
42
|
+
"https://user:password@mydomain.com:8080/path1/path2?foo=bar&bar=baz#frag?"),
|
|
43
|
+
"https://user:password@mydomain.com:8080/path1/path2?foo=bar&bar=baz#frag?");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
TEST(JscSafeUrlTest, ToNormalUrl_RewritesMarkerWithoutFragment) {
|
|
47
|
+
EXPECT_EQ(
|
|
48
|
+
toNormalUrl("http://127.0.0.1/path1/path2//&foo=bar&bar=baz"),
|
|
49
|
+
"http://127.0.0.1/path1/path2?foo=bar&bar=baz");
|
|
50
|
+
EXPECT_EQ(
|
|
51
|
+
toNormalUrl("http://127.0.0.1/path1/path2?foo=bar&bar=baz"),
|
|
52
|
+
"http://127.0.0.1/path1/path2?foo=bar&bar=baz");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Returns other strings exactly as given
|
|
56
|
+
TEST(JscSafeUrlTest, ToNormalUrl_PassthroughForQueryWithMarkerAfter) {
|
|
57
|
+
auto url = "http://user:password/@mydomain.com/foo?bar=zoo?baz=quux//&";
|
|
58
|
+
EXPECT_EQ(toNormalUrl(url), url);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
TEST(JscSafeUrlTest, ToNormalUrl_PassthroughForSimpleQuery) {
|
|
62
|
+
auto url = "/foo?bar=zoo?baz=quux";
|
|
63
|
+
EXPECT_EQ(toNormalUrl(url), url);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
TEST(JscSafeUrlTest, ToNormalUrl_PassthroughForOpaqueUri) {
|
|
67
|
+
auto url = "proto:arbitrary_bad_url";
|
|
68
|
+
EXPECT_EQ(toNormalUrl(url), url);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
TEST(JscSafeUrlTest, ToNormalUrl_PassthroughForStar) {
|
|
72
|
+
EXPECT_EQ(toNormalUrl("*"), "*");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
TEST(JscSafeUrlTest, ToNormalUrl_PassthroughForRelativePath) {
|
|
76
|
+
auto url = "relative/path";
|
|
77
|
+
EXPECT_EQ(toNormalUrl(url), url);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// --- toJscSafeUrl ---
|
|
81
|
+
|
|
82
|
+
// Replaces the first ? with a JSC-friendly delimiter, url-encodes subsequent
|
|
83
|
+
// ?, and is idempotent
|
|
84
|
+
TEST(JscSafeUrlTest, ToJscSafeUrl_FullUrlWithEncodedQuestionMark) {
|
|
85
|
+
auto input =
|
|
86
|
+
"https://user:password@mydomain.com:8080/path1/path2?foo=bar&bar=question?#frag?";
|
|
87
|
+
auto output =
|
|
88
|
+
"https://user:password@mydomain.com:8080/path1/path2//&foo=bar&bar=question%3F#frag?";
|
|
89
|
+
EXPECT_EQ(toJscSafeUrl(input), output);
|
|
90
|
+
EXPECT_EQ(toJscSafeUrl(output), output);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
TEST(JscSafeUrlTest, ToJscSafeUrl_SimpleUrl) {
|
|
94
|
+
auto input = "http://127.0.0.1/path1/path2?foo=bar";
|
|
95
|
+
auto output = "http://127.0.0.1/path1/path2//&foo=bar";
|
|
96
|
+
EXPECT_EQ(toJscSafeUrl(input), output);
|
|
97
|
+
EXPECT_EQ(toJscSafeUrl(output), output);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
TEST(JscSafeUrlTest, ToJscSafeUrl_PassthroughForStar) {
|
|
101
|
+
EXPECT_EQ(toJscSafeUrl("*"), "*");
|
|
102
|
+
EXPECT_EQ(toJscSafeUrl("*"), "*");
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
TEST(JscSafeUrlTest, ToJscSafeUrl_PassthroughForAbsolutePath) {
|
|
106
|
+
EXPECT_EQ(toJscSafeUrl("/absolute/path"), "/absolute/path");
|
|
107
|
+
EXPECT_EQ(toJscSafeUrl("/absolute/path"), "/absolute/path");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
TEST(JscSafeUrlTest, ToJscSafeUrl_PassthroughForRelativePath) {
|
|
111
|
+
EXPECT_EQ(toJscSafeUrl("relative/path"), "relative/path");
|
|
112
|
+
EXPECT_EQ(toJscSafeUrl("relative/path"), "relative/path");
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
TEST(JscSafeUrlTest, ToJscSafeUrl_EmptyQueryDropped) {
|
|
116
|
+
EXPECT_EQ(toJscSafeUrl("/?"), "/");
|
|
117
|
+
EXPECT_EQ(toJscSafeUrl("/"), "/");
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
TEST(JscSafeUrlTest, ToJscSafeUrl_PassthroughForUrlWithoutQuery) {
|
|
121
|
+
auto url = "http://127.0.0.1/path1/path";
|
|
122
|
+
EXPECT_EQ(toJscSafeUrl(url), url);
|
|
123
|
+
EXPECT_EQ(toJscSafeUrl(url), url);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
TEST(JscSafeUrlTest, ToJscSafeUrl_AbsolutePathWithEncodedQuestionMark) {
|
|
127
|
+
auto input = "/path1/path2?foo=bar&bar=question?#frag?";
|
|
128
|
+
auto output = "/path1/path2//&foo=bar&bar=question%3F#frag?";
|
|
129
|
+
EXPECT_EQ(toJscSafeUrl(input), output);
|
|
130
|
+
EXPECT_EQ(toJscSafeUrl(output), output);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
TEST(JscSafeUrlTest, ToJscSafeUrl_RelativePathWithEncodedQuestionMark) {
|
|
134
|
+
auto input = "relative/path?foo=bar&bar=question?#frag?";
|
|
135
|
+
auto output = "relative/path//&foo=bar&bar=question%3F#frag?";
|
|
136
|
+
EXPECT_EQ(toJscSafeUrl(input), output);
|
|
137
|
+
EXPECT_EQ(toJscSafeUrl(output), output);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
TEST(JscSafeUrlTest, ToJscSafeUrl_AlreadySafeWithExtraQuery) {
|
|
141
|
+
auto input = "/path1/path2//&foo=bar&bar=question%3F?extra=query#frag?";
|
|
142
|
+
auto output = "/path1/path2//&foo=bar&bar=question%3F&extra=query#frag?";
|
|
143
|
+
EXPECT_EQ(toJscSafeUrl(input), output);
|
|
144
|
+
EXPECT_EQ(toJscSafeUrl(output), output);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// Throws on a URL with an empty path and a query string
|
|
148
|
+
TEST(JscSafeUrlTest, ToJscSafeUrl_ThrowsForEmptyPathWithQuery) {
|
|
149
|
+
EXPECT_THROW(toJscSafeUrl("http://127.0.0.1?foo=bar"), std::invalid_argument);
|
|
150
|
+
EXPECT_THROW(toJscSafeUrl("http://127.0.0.1?q#hash"), std::invalid_argument);
|
|
151
|
+
EXPECT_THROW(toJscSafeUrl("?foo=bar"), std::invalid_argument);
|
|
152
|
+
EXPECT_THROW(toJscSafeUrl("?foo=/bar#hash"), std::invalid_argument);
|
|
153
|
+
EXPECT_THROW(toJscSafeUrl("/?bar=baz/"), std::invalid_argument);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// --- isJscSafeUrl ---
|
|
157
|
+
|
|
158
|
+
TEST(JscSafeUrlTest, IsJscSafeUrl_TrueForSafeUrls) {
|
|
159
|
+
EXPECT_TRUE(isJscSafeUrl("http://example.com//&foo=bar//#frag=//"));
|
|
160
|
+
EXPECT_TRUE(isJscSafeUrl("http://example.com/with/path//&foo=bar//#frag=//"));
|
|
161
|
+
EXPECT_TRUE(isJscSafeUrl("//&foo=bar//#frag=//"));
|
|
162
|
+
EXPECT_TRUE(isJscSafeUrl("relative/path///&foo=bar//&#frag=//&"));
|
|
163
|
+
EXPECT_TRUE(isJscSafeUrl("/absolute/path//&foo=bar//&#frag=//&"));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
TEST(JscSafeUrlTest, IsJscSafeUrl_FalseForNormalUrls) {
|
|
167
|
+
EXPECT_FALSE(isJscSafeUrl("http://example.com?foo=bar//&#frag=//"));
|
|
168
|
+
EXPECT_FALSE(
|
|
169
|
+
isJscSafeUrl("http://example.com/with/path/?foo=bar//&#frag=//"));
|
|
170
|
+
EXPECT_FALSE(isJscSafeUrl("?foo=bar//&#frag=//&"));
|
|
171
|
+
EXPECT_FALSE(isJscSafeUrl("relative/path/?foo=bar//#frag=//"));
|
|
172
|
+
EXPECT_FALSE(isJscSafeUrl("/absolute/path/?foo=bar//&#frag=//"));
|
|
173
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
#include <gtest/gtest.h>
|
|
9
|
+
#include <react/debug/redbox/RedBoxErrorParser.h>
|
|
10
|
+
|
|
11
|
+
using namespace facebook::react::unstable_redbox;
|
|
12
|
+
|
|
13
|
+
TEST(RedBoxErrorParserTest, ParsesBabelTransformError) {
|
|
14
|
+
auto result = parseErrorMessage(
|
|
15
|
+
"SyntaxError: /path/to/file.js: Unexpected token (10:5)\n\n"
|
|
16
|
+
"> 10 | const x = {\n"
|
|
17
|
+
" | ^");
|
|
18
|
+
|
|
19
|
+
EXPECT_EQ(result.title, "Syntax Error");
|
|
20
|
+
EXPECT_EQ(result.message, "Unexpected token");
|
|
21
|
+
ASSERT_TRUE(result.codeFrame.has_value());
|
|
22
|
+
EXPECT_EQ(result.codeFrame->fileName, "/path/to/file.js");
|
|
23
|
+
EXPECT_EQ(result.codeFrame->row, 10);
|
|
24
|
+
EXPECT_EQ(result.codeFrame->column, 5);
|
|
25
|
+
EXPECT_TRUE(result.isCompileError);
|
|
26
|
+
EXPECT_TRUE(result.isRetryable);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
TEST(RedBoxErrorParserTest, ParsesMetroError) {
|
|
30
|
+
auto result = parseErrorMessage(
|
|
31
|
+
"InternalError Metro has encountered an error: "
|
|
32
|
+
"BundleError: Unable to resolve module (1:0)\n\n"
|
|
33
|
+
"code frame here");
|
|
34
|
+
|
|
35
|
+
EXPECT_EQ(result.title, "BundleError");
|
|
36
|
+
EXPECT_EQ(result.message, "Unable to resolve module");
|
|
37
|
+
ASSERT_TRUE(result.codeFrame.has_value());
|
|
38
|
+
EXPECT_EQ(result.codeFrame->row, 1);
|
|
39
|
+
EXPECT_TRUE(result.isCompileError);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
TEST(RedBoxErrorParserTest, ParsesBundleLoadError_SyntaxError) {
|
|
43
|
+
auto result = parseErrorMessage(
|
|
44
|
+
"SyntaxError in /app/index.js: Unexpected token (3:10)\ncode frame");
|
|
45
|
+
|
|
46
|
+
EXPECT_EQ(result.title, "Syntax Error");
|
|
47
|
+
EXPECT_EQ(result.message, "Unexpected token");
|
|
48
|
+
ASSERT_TRUE(result.codeFrame.has_value());
|
|
49
|
+
EXPECT_EQ(result.codeFrame->fileName, "/app/index.js");
|
|
50
|
+
EXPECT_EQ(result.codeFrame->row, 3);
|
|
51
|
+
EXPECT_EQ(result.codeFrame->column, 10);
|
|
52
|
+
EXPECT_TRUE(result.isCompileError);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
TEST(RedBoxErrorParserTest, ParsesBundleLoadError_UnableToResolve) {
|
|
56
|
+
auto result = parseErrorMessage(
|
|
57
|
+
"UnableToResolveError in /app/index.js: Cannot find module (1:0)");
|
|
58
|
+
|
|
59
|
+
EXPECT_EQ(result.title, "Module Not Found");
|
|
60
|
+
EXPECT_TRUE(result.isCompileError);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
TEST(RedBoxErrorParserTest, ParsesGenericTransformError) {
|
|
64
|
+
auto result = parseErrorMessage("TransformError some error message");
|
|
65
|
+
|
|
66
|
+
EXPECT_EQ(result.title, "Syntax Error");
|
|
67
|
+
EXPECT_EQ(result.message, "TransformError some error message");
|
|
68
|
+
EXPECT_FALSE(result.codeFrame.has_value());
|
|
69
|
+
EXPECT_TRUE(result.isCompileError);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
TEST(RedBoxErrorParserTest, DefaultsToUncaughtError) {
|
|
73
|
+
auto result = parseErrorMessage("TypeError: undefined is not a function");
|
|
74
|
+
|
|
75
|
+
EXPECT_EQ(result.title, "Uncaught Error");
|
|
76
|
+
EXPECT_EQ(result.message, "TypeError: undefined is not a function");
|
|
77
|
+
EXPECT_FALSE(result.codeFrame.has_value());
|
|
78
|
+
EXPECT_FALSE(result.isCompileError);
|
|
79
|
+
EXPECT_TRUE(result.isRetryable);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
TEST(RedBoxErrorParserTest, UsesNameForTitle) {
|
|
83
|
+
auto result = parseErrorMessage("something broke", "CustomError");
|
|
84
|
+
|
|
85
|
+
EXPECT_EQ(result.title, "CustomError");
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
TEST(RedBoxErrorParserTest, UsesRenderErrorForComponentStack) {
|
|
89
|
+
auto result =
|
|
90
|
+
parseErrorMessage("something broke", "", "in MyComponent\nin App");
|
|
91
|
+
|
|
92
|
+
EXPECT_EQ(result.title, "Render Error");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
TEST(RedBoxErrorParserTest, NonFatalDefaultsToError) {
|
|
96
|
+
auto result = parseErrorMessage("warning message", "", "", false);
|
|
97
|
+
|
|
98
|
+
EXPECT_EQ(result.title, "Error");
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
TEST(RedBoxErrorParserTest, HandlesEmptyMessage) {
|
|
102
|
+
auto result = parseErrorMessage("");
|
|
103
|
+
|
|
104
|
+
EXPECT_EQ(result.title, "Uncaught Error");
|
|
105
|
+
EXPECT_EQ(result.message, "");
|
|
106
|
+
EXPECT_FALSE(result.codeFrame.has_value());
|
|
107
|
+
}
|
|
@@ -8,7 +8,7 @@ require "json"
|
|
|
8
8
|
package = JSON.parse(File.read(File.join(__dir__, "..", "..", "..", "package.json")))
|
|
9
9
|
version = package['version']
|
|
10
10
|
|
|
11
|
-
source = { :git => 'https://github.com/
|
|
11
|
+
source = { :git => 'https://github.com/react/react-native.git' }
|
|
12
12
|
if version == '1000.0.0'
|
|
13
13
|
# This is an unpublished version, use the latest commit hash of the react-native repo, which we’re presumably in.
|
|
14
14
|
source[:commit] = `git rev-parse HEAD`.strip if system("git rev-parse --git-dir > /dev/null 2>&1")
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @generated SignedSource<<
|
|
7
|
+
* @generated SignedSource<<c7d08e6d97766cbb68db8772611530b5>>
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -170,6 +170,10 @@ bool ReactNativeFeatureFlags::enableModuleArgumentNSNullConversionIOS() {
|
|
|
170
170
|
return getAccessor().enableModuleArgumentNSNullConversionIOS();
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
+
bool ReactNativeFeatureFlags::enableMutationObserverByDefault() {
|
|
174
|
+
return getAccessor().enableMutationObserverByDefault();
|
|
175
|
+
}
|
|
176
|
+
|
|
173
177
|
bool ReactNativeFeatureFlags::enableNativeCSSParsing() {
|
|
174
178
|
return getAccessor().enableNativeCSSParsing();
|
|
175
179
|
}
|
|
@@ -290,6 +294,14 @@ bool ReactNativeFeatureFlags::preventShadowTreeCommitExhaustion() {
|
|
|
290
294
|
return getAccessor().preventShadowTreeCommitExhaustion();
|
|
291
295
|
}
|
|
292
296
|
|
|
297
|
+
bool ReactNativeFeatureFlags::redBoxV2Android() {
|
|
298
|
+
return getAccessor().redBoxV2Android();
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
bool ReactNativeFeatureFlags::redBoxV2IOS() {
|
|
302
|
+
return getAccessor().redBoxV2IOS();
|
|
303
|
+
}
|
|
304
|
+
|
|
293
305
|
bool ReactNativeFeatureFlags::shouldPressibilityUseW3CPointerEventsForHover() {
|
|
294
306
|
return getAccessor().shouldPressibilityUseW3CPointerEventsForHover();
|
|
295
307
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @generated SignedSource<<
|
|
7
|
+
* @generated SignedSource<<f8bd95ee62cd377756a0ca08caf3027a>>
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -219,6 +219,11 @@ class ReactNativeFeatureFlags {
|
|
|
219
219
|
*/
|
|
220
220
|
RN_EXPORT static bool enableModuleArgumentNSNullConversionIOS();
|
|
221
221
|
|
|
222
|
+
/**
|
|
223
|
+
* Enables the MutationObserver Web API in React Native.
|
|
224
|
+
*/
|
|
225
|
+
RN_EXPORT static bool enableMutationObserverByDefault();
|
|
226
|
+
|
|
222
227
|
/**
|
|
223
228
|
* Parse CSS strings using the Fabric CSS parser instead of ViewConfig processing
|
|
224
229
|
*/
|
|
@@ -369,6 +374,16 @@ class ReactNativeFeatureFlags {
|
|
|
369
374
|
*/
|
|
370
375
|
RN_EXPORT static bool preventShadowTreeCommitExhaustion();
|
|
371
376
|
|
|
377
|
+
/**
|
|
378
|
+
* Use the redesigned RedBox error overlay on Android, styled to match the LogBox visual language.
|
|
379
|
+
*/
|
|
380
|
+
RN_EXPORT static bool redBoxV2Android();
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Use the redesigned RedBox error overlay on iOS, styled to match the LogBox visual language.
|
|
384
|
+
*/
|
|
385
|
+
RN_EXPORT static bool redBoxV2IOS();
|
|
386
|
+
|
|
372
387
|
/**
|
|
373
388
|
* Function used to enable / disable Pressibility from using W3C Pointer Events for its hover callbacks
|
|
374
389
|
*/
|