Skip to content

Commit de4e138

Browse files
[0.85] Backport RedBox 2.0 for iOS (#56640)
Summary: Pull Request resolved: #56640 Cherry-pick of 13 commits from `main` (and 1 from `0.83-stable`) adding the experimental RedBox 2.0 implementation for iOS to `0.85-stable`, plus supporting build fixes. Changes included: - Add per-platform `redBoxV2IOS` / `redBoxV2Android` feature flags - Extract `RCTRedBoxController` from `RCTRedBox.mm` (#56509) - Add LogBox-styled error overlay (#56550) - Add shared C++ error parser and ANSI renderer (#56553) - Show syntax-highlighted code frames (#56551) - Mark all errors as retryable (#56552) - Auto-reload on retryable errors (#56549) - Attempt to clear RedBox by automatically reloading on Metro file change (#56554) - Fix truncated filenames in call stack frames (#56565) - Guard tvOS-unavailable APIs in `RCTRedBox2Controller` (#56568) - Fix C++ syntax in Objective-C header breaking React module build (#56569) - Add `redbox` subspec to `React-debug` pod (#56584) — from `0.83-stable`, needed for static library builds - Fix React-CoreModules missing `React-featureflags` header path under `use_frameworks!` (#56591) All RedBox 2.0 features gated behind the `redBoxV2IOS` feature flag (disabled by default). Changelog: [Internal] Test Plan: - CI - Feature is behind `redBoxV2IOS` flag, disabled by default Co-authored-by: Moti Zilberman <moti@meta.com>
1 parent 28fb4a2 commit de4e138

47 files changed

Lines changed: 2993 additions & 496 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/react-native/Package.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ let reactRendererConsistency = RNTarget(
9393
let reactDebug = RNTarget(
9494
name: .reactDebug,
9595
path: "ReactCommon/react/debug",
96+
excludedPaths: ["tests", "redbox/tests"],
9697
dependencies: [.reactNativeDependencies]
9798
)
9899
/// React-jsi.podspec
@@ -385,7 +386,7 @@ let reactCoreModules = RNTarget(
385386
name: .reactCoreModules,
386387
path: "React/CoreModules",
387388
excludedPaths: ["PlatformStubs/RCTStatusBarManager.mm"],
388-
dependencies: [.reactNativeDependencies, .jsi, .yoga, .reactTurboModuleCore]
389+
dependencies: [.reactNativeDependencies, .jsi, .yoga, .reactTurboModuleCore, .reactFeatureFlags]
389390
)
390391

391392
/// React-runtimeCore.podspec
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
#import <Foundation/Foundation.h>
9+
10+
/**
11+
* Converts between standard URLs and JSC-safe URLs.
12+
*
13+
* JSC (JavaScriptCore) strips query strings from source URLs in stack traces
14+
* as of iOS 16.4. Metro works around this by encoding the query string into
15+
* the URL path. These methods convert between the two formats.
16+
*/
17+
@interface RCTJscSafeUrl : NSObject
18+
19+
+ (nonnull NSString *)normalUrlFromJscSafeUrl:(nonnull NSString *)url;
20+
+ (nonnull NSString *)jscSafeUrlFromNormalUrl:(nonnull NSString *)url;
21+
+ (BOOL)isJscSafeUrl:(nonnull NSString *)url;
22+
23+
@end
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
#import "RCTJscSafeUrl+Internal.h"
9+
10+
#import <React/RCTDefines.h>
11+
#import <react/debug/redbox/JscSafeUrl.h>
12+
13+
#if RCT_DEV_MENU
14+
15+
using facebook::react::unstable_redbox::isJscSafeUrl;
16+
using facebook::react::unstable_redbox::toJscSafeUrl;
17+
using facebook::react::unstable_redbox::toNormalUrl;
18+
19+
@implementation RCTJscSafeUrl
20+
21+
+ (NSString *)normalUrlFromJscSafeUrl:(NSString *)url
22+
{
23+
return [NSString stringWithUTF8String:toNormalUrl(url.UTF8String).c_str()];
24+
}
25+
26+
+ (NSString *)jscSafeUrlFromNormalUrl:(NSString *)url
27+
{
28+
return [NSString stringWithUTF8String:toJscSafeUrl(url.UTF8String).c_str()];
29+
}
30+
31+
+ (BOOL)isJscSafeUrl:(NSString *)url
32+
{
33+
return isJscSafeUrl(url.UTF8String);
34+
}
35+
36+
@end
37+
38+
#endif
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
#import <React/RCTDefines.h>
9+
#import <UIKit/UIKit.h>
10+
11+
#if RCT_DEV_MENU
12+
13+
@class RCTJSStackFrame;
14+
15+
@protocol RCTRedBoxControllerActionDelegate <NSObject>
16+
17+
- (void)redBoxController:(UIViewController *)redBoxController openStackFrameInEditor:(RCTJSStackFrame *)stackFrame;
18+
- (void)reloadFromRedBoxController:(UIViewController *)redBoxController;
19+
- (void)loadExtraDataViewController;
20+
21+
@end
22+
23+
@protocol RCTRedBoxControlling <NSObject>
24+
25+
@property (nonatomic, weak) id<RCTRedBoxControllerActionDelegate> actionDelegate;
26+
27+
- (void)showErrorMessage:(NSString *)message
28+
withStack:(NSArray<RCTJSStackFrame *> *)stack
29+
isUpdate:(BOOL)isUpdate
30+
errorCookie:(int)errorCookie;
31+
32+
- (void)dismiss;
33+
34+
@end
35+
36+
@protocol RCTRedBox2Controlling <RCTRedBoxControlling>
37+
38+
@property (nonatomic, strong, nullable) NSURL *bundleURL;
39+
40+
@end
41+
42+
#endif

0 commit comments

Comments
 (0)