react-native 0.83.6 → 0.83.7

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.
Files changed (52) hide show
  1. package/Libraries/Core/ReactNativeVersion.js +1 -1
  2. package/React/Base/RCTVersion.m +1 -1
  3. package/React/CoreModules/RCTJscSafeUrl+Internal.h +23 -0
  4. package/React/CoreModules/RCTJscSafeUrl.mm +38 -0
  5. package/React/CoreModules/RCTRedBox+Internal.h +42 -0
  6. package/React/CoreModules/RCTRedBox.mm +30 -450
  7. package/React/CoreModules/RCTRedBox2AnsiParser+Internal.h +22 -0
  8. package/React/CoreModules/RCTRedBox2AnsiParser.mm +55 -0
  9. package/React/CoreModules/RCTRedBox2Controller+Internal.h +34 -0
  10. package/React/CoreModules/RCTRedBox2Controller.mm +764 -0
  11. package/React/CoreModules/RCTRedBox2ErrorParser+Internal.h +46 -0
  12. package/React/CoreModules/RCTRedBox2ErrorParser.mm +57 -0
  13. package/React/CoreModules/RCTRedBoxController+Internal.h +31 -0
  14. package/React/CoreModules/RCTRedBoxController.mm +447 -0
  15. package/React/CoreModules/RCTRedBoxHMRClient+Internal.h +26 -0
  16. package/React/CoreModules/RCTRedBoxHMRClient.mm +125 -0
  17. package/React/CoreModules/React-CoreModules.podspec +1 -0
  18. package/React/FBReactNativeSpec/FBReactNativeSpecJSI.h +16 -0
  19. package/ReactAndroid/gradle.properties +1 -1
  20. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlags.kt +13 -1
  21. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxAccessor.kt +21 -1
  22. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsCxxInterop.kt +5 -1
  23. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsDefaults.kt +5 -1
  24. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsLocalAccessor.kt +23 -1
  25. package/ReactAndroid/src/main/java/com/facebook/react/internal/featureflags/ReactNativeFeatureFlagsProvider.kt +5 -1
  26. package/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.kt +1 -1
  27. package/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.cpp +29 -1
  28. package/ReactAndroid/src/main/jni/react/featureflags/JReactNativeFeatureFlagsCxxInterop.h +7 -1
  29. package/ReactCommon/cxxreact/ReactNativeVersion.h +2 -2
  30. package/ReactCommon/react/debug/CMakeLists.txt +2 -1
  31. package/ReactCommon/react/debug/React-debug.podspec +7 -1
  32. package/ReactCommon/react/debug/redbox/AnsiParser.cpp +139 -0
  33. package/ReactCommon/react/debug/redbox/AnsiParser.h +35 -0
  34. package/ReactCommon/react/debug/redbox/JscSafeUrl.cpp +179 -0
  35. package/ReactCommon/react/debug/redbox/JscSafeUrl.h +27 -0
  36. package/ReactCommon/react/debug/redbox/RedBoxErrorParser.cpp +171 -0
  37. package/ReactCommon/react/debug/redbox/RedBoxErrorParser.h +40 -0
  38. package/ReactCommon/react/debug/redbox/tests/AnsiParserTest.cpp +97 -0
  39. package/ReactCommon/react/debug/redbox/tests/JscSafeUrlTest.cpp +173 -0
  40. package/ReactCommon/react/debug/redbox/tests/RedBoxErrorParserTest.cpp +107 -0
  41. package/ReactCommon/react/featureflags/ReactNativeFeatureFlags.cpp +9 -1
  42. package/ReactCommon/react/featureflags/ReactNativeFeatureFlags.h +11 -1
  43. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.cpp +58 -22
  44. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsAccessor.h +6 -2
  45. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDefaults.h +9 -1
  46. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsDynamicProvider.h +19 -1
  47. package/ReactCommon/react/featureflags/ReactNativeFeatureFlagsProvider.h +3 -1
  48. package/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.cpp +11 -1
  49. package/ReactCommon/react/nativemodule/featureflags/NativeReactNativeFeatureFlags.h +5 -1
  50. package/package.json +8 -8
  51. package/src/private/featureflags/ReactNativeFeatureFlags.js +11 -1
  52. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +3 -1
@@ -0,0 +1,125 @@
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 "RCTRedBoxHMRClient+Internal.h"
9
+
10
+ #if RCT_DEV_MENU
11
+
12
+ @implementation RCTRedBoxHMRClient {
13
+ NSURL *_bundleURL;
14
+ NSURLSessionWebSocketTask *_webSocketTask;
15
+ NSURLSession *_session;
16
+ void (^_onFileChange)(void);
17
+ BOOL _stopped;
18
+ }
19
+
20
+ - (instancetype)initWithBundleURL:(NSURL *)bundleURL onFileChange:(void (^)(void))onFileChange
21
+ {
22
+ if (self = [super init]) {
23
+ _bundleURL = bundleURL;
24
+ _onFileChange = [onFileChange copy];
25
+ }
26
+ return self;
27
+ }
28
+
29
+ - (void)start
30
+ {
31
+ if (![_bundleURL.scheme hasPrefix:@"http"]) {
32
+ return;
33
+ }
34
+
35
+ NSURLComponents *components = [[NSURLComponents alloc] initWithURL:_bundleURL resolvingAgainstBaseURL:NO];
36
+ components.scheme = [_bundleURL.scheme isEqualToString:@"https"] ? @"wss" : @"ws";
37
+ components.path = @"/hot";
38
+ components.query = nil;
39
+ components.fragment = nil;
40
+ NSURL *wsURL = components.URL;
41
+ if (!wsURL) {
42
+ return;
43
+ }
44
+
45
+ _session = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]
46
+ delegate:self
47
+ delegateQueue:nil];
48
+ _webSocketTask = [_session webSocketTaskWithURL:wsURL];
49
+ [_webSocketTask resume];
50
+ }
51
+
52
+ - (void)stop
53
+ {
54
+ _stopped = YES;
55
+ _onFileChange = nil;
56
+ [_webSocketTask cancel];
57
+ _webSocketTask = nil;
58
+ [_session invalidateAndCancel];
59
+ _session = nil;
60
+ }
61
+
62
+ - (void)URLSession:(__unused NSURLSession *)session
63
+ webSocketTask:(__unused NSURLSessionWebSocketTask *)webSocketTask
64
+ didOpenWithProtocol:(__unused NSString *)protocol
65
+ {
66
+ NSDictionary *registration = @{
67
+ @"type" : @"register-entrypoints",
68
+ @"entryPoints" : @[ _bundleURL.absoluteString ],
69
+ };
70
+ NSData *json = [NSJSONSerialization dataWithJSONObject:registration options:0 error:nil];
71
+ NSURLSessionWebSocketMessage *msg = [[NSURLSessionWebSocketMessage alloc]
72
+ initWithString:[[NSString alloc] initWithData:json encoding:NSUTF8StringEncoding]];
73
+ [_webSocketTask sendMessage:msg
74
+ completionHandler:^(__unused NSError *error){
75
+ }];
76
+ [self _listenForNextMessage];
77
+ }
78
+
79
+ - (void)_listenForNextMessage
80
+ {
81
+ if (_stopped) {
82
+ return;
83
+ }
84
+ __weak __typeof(self) weakSelf = self;
85
+ [_webSocketTask receiveMessageWithCompletionHandler:^(NSURLSessionWebSocketMessage *message, NSError *error) {
86
+ if (error || !message) {
87
+ return;
88
+ }
89
+ [weakSelf _handleMessage:message];
90
+ [weakSelf _listenForNextMessage];
91
+ }];
92
+ }
93
+
94
+ - (void)_handleMessage:(NSURLSessionWebSocketMessage *)message
95
+ {
96
+ if (message.type != NSURLSessionWebSocketMessageTypeString || _stopped) {
97
+ return;
98
+ }
99
+ NSData *data = [message.string dataUsingEncoding:NSUTF8StringEncoding];
100
+ NSDictionary *json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
101
+ if ([json[@"type"] isEqualToString:@"update-start"]) {
102
+ // Ignore the initial update that fires when the client first registers.
103
+ // Only react to subsequent file changes.
104
+ NSDictionary *body = json[@"body"];
105
+ if ([body isKindOfClass:[NSDictionary class]] && [body[@"isInitialUpdate"] boolValue]) {
106
+ return;
107
+ }
108
+ dispatch_async(dispatch_get_main_queue(), ^{
109
+ if (self->_onFileChange) {
110
+ self->_onFileChange();
111
+ }
112
+ });
113
+ }
114
+ }
115
+
116
+ - (void)URLSession:(__unused NSURLSession *)session
117
+ webSocketTask:(__unused NSURLSessionWebSocketTask *)task
118
+ didCloseWithCode:(__unused NSURLSessionWebSocketCloseCode)closeCode
119
+ reason:(__unused NSData *)reason
120
+ {
121
+ }
122
+
123
+ @end
124
+
125
+ #endif
@@ -51,6 +51,7 @@ Pod::Spec.new do |s|
51
51
  s.dependency "React-Core/CoreModulesHeaders", version
52
52
  s.dependency "React-RCTImage", version
53
53
  s.dependency "React-jsi", version
54
+ s.dependency "React-featureflags"
54
55
  s.dependency 'React-RCTBlob'
55
56
  add_dependency(s, "React-debug")
56
57
  add_dependency(s, "React-runtimeexecutor", :additional_framework_paths => ["platform/ios"])
@@ -290,6 +290,8 @@ protected:
290
290
  methodMap_["perfMonitorV2Enabled"] = MethodMetadata {.argCount = 0, .invoker = __perfMonitorV2Enabled};
291
291
  methodMap_["preparedTextCacheSize"] = MethodMetadata {.argCount = 0, .invoker = __preparedTextCacheSize};
292
292
  methodMap_["preventShadowTreeCommitExhaustion"] = MethodMetadata {.argCount = 0, .invoker = __preventShadowTreeCommitExhaustion};
293
+ methodMap_["redBoxV2Android"] = MethodMetadata {.argCount = 0, .invoker = __redBoxV2Android};
294
+ methodMap_["redBoxV2IOS"] = MethodMetadata {.argCount = 0, .invoker = __redBoxV2IOS};
293
295
  methodMap_["shouldPressibilityUseW3CPointerEventsForHover"] = MethodMetadata {.argCount = 0, .invoker = __shouldPressibilityUseW3CPointerEventsForHover};
294
296
  methodMap_["shouldTriggerResponderTransferOnScrollAndroid"] = MethodMetadata {.argCount = 0, .invoker = __shouldTriggerResponderTransferOnScrollAndroid};
295
297
  methodMap_["skipActivityIdentityAssertionOnHostPause"] = MethodMetadata {.argCount = 0, .invoker = __skipActivityIdentityAssertionOnHostPause};
@@ -783,6 +785,20 @@ private:
783
785
  return bridging::callFromJs<bool>(rt, &T::preventShadowTreeCommitExhaustion, static_cast<NativeReactNativeFeatureFlagsCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule));
784
786
  }
785
787
 
788
+ static jsi::Value __redBoxV2Android(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* /*args*/, size_t /*count*/) {
789
+ static_assert(
790
+ bridging::getParameterCount(&T::redBoxV2Android) == 1,
791
+ "Expected redBoxV2Android(...) to have 1 parameters");
792
+ return bridging::callFromJs<bool>(rt, &T::redBoxV2Android, static_cast<NativeReactNativeFeatureFlagsCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule));
793
+ }
794
+
795
+ static jsi::Value __redBoxV2IOS(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* /*args*/, size_t /*count*/) {
796
+ static_assert(
797
+ bridging::getParameterCount(&T::redBoxV2IOS) == 1,
798
+ "Expected redBoxV2IOS(...) to have 1 parameters");
799
+ return bridging::callFromJs<bool>(rt, &T::redBoxV2IOS, static_cast<NativeReactNativeFeatureFlagsCxxSpec*>(&turboModule)->jsInvoker_, static_cast<T*>(&turboModule));
800
+ }
801
+
786
802
  static jsi::Value __shouldPressibilityUseW3CPointerEventsForHover(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* /*args*/, size_t /*count*/) {
787
803
  static_assert(
788
804
  bridging::getParameterCount(&T::shouldPressibilityUseW3CPointerEventsForHover) == 1,
@@ -1,4 +1,4 @@
1
- VERSION_NAME=0.83.6
1
+ VERSION_NAME=0.83.7
2
2
  react.internal.publishingGroup=com.facebook.react
3
3
  react.internal.hermesPublishingGroup=com.facebook.hermes
4
4
 
@@ -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<<a92c35b9527c3954516ee68db651afa7>>
7
+ * @generated SignedSource<<26dfce17f8149372c967e83a1e55b497>>
8
8
  */
9
9
 
10
10
  /**
@@ -426,6 +426,18 @@ public object ReactNativeFeatureFlags {
426
426
  @JvmStatic
427
427
  public fun preventShadowTreeCommitExhaustion(): Boolean = accessor.preventShadowTreeCommitExhaustion()
428
428
 
429
+ /**
430
+ * Use the redesigned RedBox error overlay on Android, styled to match the LogBox visual language.
431
+ */
432
+ @JvmStatic
433
+ public fun redBoxV2Android(): Boolean = accessor.redBoxV2Android()
434
+
435
+ /**
436
+ * Use the redesigned RedBox error overlay on iOS, styled to match the LogBox visual language.
437
+ */
438
+ @JvmStatic
439
+ public fun redBoxV2IOS(): Boolean = accessor.redBoxV2IOS()
440
+
429
441
  /**
430
442
  * Function used to enable / disable Pressibility from using W3C Pointer Events for its hover callbacks
431
443
  */
@@ -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<<a9ec10139cccac681fb73d8155377b02>>
7
+ * @generated SignedSource<<7523b02820a1f77c0a851ed051770f51>>
8
8
  */
9
9
 
10
10
  /**
@@ -86,6 +86,8 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
86
86
  private var perfMonitorV2EnabledCache: Boolean? = null
87
87
  private var preparedTextCacheSizeCache: Double? = null
88
88
  private var preventShadowTreeCommitExhaustionCache: Boolean? = null
89
+ private var redBoxV2AndroidCache: Boolean? = null
90
+ private var redBoxV2IOSCache: Boolean? = null
89
91
  private var shouldPressibilityUseW3CPointerEventsForHoverCache: Boolean? = null
90
92
  private var shouldTriggerResponderTransferOnScrollAndroidCache: Boolean? = null
91
93
  private var skipActivityIdentityAssertionOnHostPauseCache: Boolean? = null
@@ -702,6 +704,24 @@ internal class ReactNativeFeatureFlagsCxxAccessor : ReactNativeFeatureFlagsAcces
702
704
  return cached
703
705
  }
704
706
 
707
+ override fun redBoxV2Android(): Boolean {
708
+ var cached = redBoxV2AndroidCache
709
+ if (cached == null) {
710
+ cached = ReactNativeFeatureFlagsCxxInterop.redBoxV2Android()
711
+ redBoxV2AndroidCache = cached
712
+ }
713
+ return cached
714
+ }
715
+
716
+ override fun redBoxV2IOS(): Boolean {
717
+ var cached = redBoxV2IOSCache
718
+ if (cached == null) {
719
+ cached = ReactNativeFeatureFlagsCxxInterop.redBoxV2IOS()
720
+ redBoxV2IOSCache = cached
721
+ }
722
+ return cached
723
+ }
724
+
705
725
  override fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean {
706
726
  var cached = shouldPressibilityUseW3CPointerEventsForHoverCache
707
727
  if (cached == null) {
@@ -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<<ceb1cf55a1d6b6d71ad27ec7f8594b50>>
7
+ * @generated SignedSource<<0fa0febd40941c466222d1af82f677cf>>
8
8
  */
9
9
 
10
10
  /**
@@ -160,6 +160,10 @@ public object ReactNativeFeatureFlagsCxxInterop {
160
160
 
161
161
  @DoNotStrip @JvmStatic public external fun preventShadowTreeCommitExhaustion(): Boolean
162
162
 
163
+ @DoNotStrip @JvmStatic public external fun redBoxV2Android(): Boolean
164
+
165
+ @DoNotStrip @JvmStatic public external fun redBoxV2IOS(): Boolean
166
+
163
167
  @DoNotStrip @JvmStatic public external fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean
164
168
 
165
169
  @DoNotStrip @JvmStatic public external fun shouldTriggerResponderTransferOnScrollAndroid(): Boolean
@@ -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<<fd1d27cb393bb274b44db0bcec73c7f8>>
7
+ * @generated SignedSource<<9158a8f1750ec5e9e530399fe09f52cf>>
8
8
  */
9
9
 
10
10
  /**
@@ -155,6 +155,10 @@ public open class ReactNativeFeatureFlagsDefaults : ReactNativeFeatureFlagsProvi
155
155
 
156
156
  override fun preventShadowTreeCommitExhaustion(): Boolean = false
157
157
 
158
+ override fun redBoxV2Android(): Boolean = false
159
+
160
+ override fun redBoxV2IOS(): Boolean = false
161
+
158
162
  override fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean = false
159
163
 
160
164
  override fun shouldTriggerResponderTransferOnScrollAndroid(): Boolean = false
@@ -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<<38e86d50298e5c4199d456f709ac13fc>>
7
+ * @generated SignedSource<<9feb91e31a7d54e4b3f7737fb524800b>>
8
8
  */
9
9
 
10
10
  /**
@@ -90,6 +90,8 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
90
90
  private var perfMonitorV2EnabledCache: Boolean? = null
91
91
  private var preparedTextCacheSizeCache: Double? = null
92
92
  private var preventShadowTreeCommitExhaustionCache: Boolean? = null
93
+ private var redBoxV2AndroidCache: Boolean? = null
94
+ private var redBoxV2IOSCache: Boolean? = null
93
95
  private var shouldPressibilityUseW3CPointerEventsForHoverCache: Boolean? = null
94
96
  private var shouldTriggerResponderTransferOnScrollAndroidCache: Boolean? = null
95
97
  private var skipActivityIdentityAssertionOnHostPauseCache: Boolean? = null
@@ -772,6 +774,26 @@ internal class ReactNativeFeatureFlagsLocalAccessor : ReactNativeFeatureFlagsAcc
772
774
  return cached
773
775
  }
774
776
 
777
+ override fun redBoxV2Android(): Boolean {
778
+ var cached = redBoxV2AndroidCache
779
+ if (cached == null) {
780
+ cached = currentProvider.redBoxV2Android()
781
+ accessedFeatureFlags.add("redBoxV2Android")
782
+ redBoxV2AndroidCache = cached
783
+ }
784
+ return cached
785
+ }
786
+
787
+ override fun redBoxV2IOS(): Boolean {
788
+ var cached = redBoxV2IOSCache
789
+ if (cached == null) {
790
+ cached = currentProvider.redBoxV2IOS()
791
+ accessedFeatureFlags.add("redBoxV2IOS")
792
+ redBoxV2IOSCache = cached
793
+ }
794
+ return cached
795
+ }
796
+
775
797
  override fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean {
776
798
  var cached = shouldPressibilityUseW3CPointerEventsForHoverCache
777
799
  if (cached == null) {
@@ -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<<eb09ee29f25cd03df2e7c3d2b3def992>>
7
+ * @generated SignedSource<<5425bfe01cb2aaecc61b65b8c2f7dad0>>
8
8
  */
9
9
 
10
10
  /**
@@ -155,6 +155,10 @@ public interface ReactNativeFeatureFlagsProvider {
155
155
 
156
156
  @DoNotStrip public fun preventShadowTreeCommitExhaustion(): Boolean
157
157
 
158
+ @DoNotStrip public fun redBoxV2Android(): Boolean
159
+
160
+ @DoNotStrip public fun redBoxV2IOS(): Boolean
161
+
158
162
  @DoNotStrip public fun shouldPressibilityUseW3CPointerEventsForHover(): Boolean
159
163
 
160
164
  @DoNotStrip public fun shouldTriggerResponderTransferOnScrollAndroid(): Boolean
@@ -14,7 +14,7 @@ public object ReactNativeVersion {
14
14
  public val VERSION: Map<String, Any?> = mapOf(
15
15
  "major" to 0,
16
16
  "minor" to 83,
17
- "patch" to 6,
17
+ "patch" to 7,
18
18
  "prerelease" to null
19
19
  )
20
20
  }
@@ -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<<d4aa5fd7828c31ac309551066662eeaa>>
7
+ * @generated SignedSource<<986de1b799ad8bc22a323365aef3533b>>
8
8
  */
9
9
 
10
10
  /**
@@ -435,6 +435,18 @@ class ReactNativeFeatureFlagsJavaProvider
435
435
  return method(javaProvider_);
436
436
  }
437
437
 
438
+ bool redBoxV2Android() override {
439
+ static const auto method =
440
+ getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("redBoxV2Android");
441
+ return method(javaProvider_);
442
+ }
443
+
444
+ bool redBoxV2IOS() override {
445
+ static const auto method =
446
+ getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("redBoxV2IOS");
447
+ return method(javaProvider_);
448
+ }
449
+
438
450
  bool shouldPressibilityUseW3CPointerEventsForHover() override {
439
451
  static const auto method =
440
452
  getReactNativeFeatureFlagsProviderJavaClass()->getMethod<jboolean()>("shouldPressibilityUseW3CPointerEventsForHover");
@@ -895,6 +907,16 @@ bool JReactNativeFeatureFlagsCxxInterop::preventShadowTreeCommitExhaustion(
895
907
  return ReactNativeFeatureFlags::preventShadowTreeCommitExhaustion();
896
908
  }
897
909
 
910
+ bool JReactNativeFeatureFlagsCxxInterop::redBoxV2Android(
911
+ facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
912
+ return ReactNativeFeatureFlags::redBoxV2Android();
913
+ }
914
+
915
+ bool JReactNativeFeatureFlagsCxxInterop::redBoxV2IOS(
916
+ facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
917
+ return ReactNativeFeatureFlags::redBoxV2IOS();
918
+ }
919
+
898
920
  bool JReactNativeFeatureFlagsCxxInterop::shouldPressibilityUseW3CPointerEventsForHover(
899
921
  facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop> /*unused*/) {
900
922
  return ReactNativeFeatureFlags::shouldPressibilityUseW3CPointerEventsForHover();
@@ -1229,6 +1251,12 @@ void JReactNativeFeatureFlagsCxxInterop::registerNatives() {
1229
1251
  makeNativeMethod(
1230
1252
  "preventShadowTreeCommitExhaustion",
1231
1253
  JReactNativeFeatureFlagsCxxInterop::preventShadowTreeCommitExhaustion),
1254
+ makeNativeMethod(
1255
+ "redBoxV2Android",
1256
+ JReactNativeFeatureFlagsCxxInterop::redBoxV2Android),
1257
+ makeNativeMethod(
1258
+ "redBoxV2IOS",
1259
+ JReactNativeFeatureFlagsCxxInterop::redBoxV2IOS),
1232
1260
  makeNativeMethod(
1233
1261
  "shouldPressibilityUseW3CPointerEventsForHover",
1234
1262
  JReactNativeFeatureFlagsCxxInterop::shouldPressibilityUseW3CPointerEventsForHover),
@@ -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<<554bd02cd328ba462d4e703b653d6cdd>>
7
+ * @generated SignedSource<<f5aa0f101192f55b7ac12705d7667424>>
8
8
  */
9
9
 
10
10
  /**
@@ -228,6 +228,12 @@ class JReactNativeFeatureFlagsCxxInterop
228
228
  static bool preventShadowTreeCommitExhaustion(
229
229
  facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
230
230
 
231
+ static bool redBoxV2Android(
232
+ facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
233
+
234
+ static bool redBoxV2IOS(
235
+ facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
236
+
231
237
  static bool shouldPressibilityUseW3CPointerEventsForHover(
232
238
  facebook::jni::alias_ref<JReactNativeFeatureFlagsCxxInterop>);
233
239
 
@@ -14,14 +14,14 @@
14
14
 
15
15
  #define REACT_NATIVE_VERSION_MAJOR 0
16
16
  #define REACT_NATIVE_VERSION_MINOR 83
17
- #define REACT_NATIVE_VERSION_PATCH 6
17
+ #define REACT_NATIVE_VERSION_PATCH 7
18
18
 
19
19
  namespace facebook::react {
20
20
 
21
21
  constexpr struct {
22
22
  int32_t Major = 0;
23
23
  int32_t Minor = 83;
24
- int32_t Patch = 6;
24
+ int32_t Patch = 7;
25
25
  std::string_view Prerelease = "";
26
26
  } ReactNativeVersion;
27
27
 
@@ -9,7 +9,8 @@ set(CMAKE_VERBOSE_MAKEFILE on)
9
9
  include(${REACT_COMMON_DIR}/cmake-utils/react-native-flags.cmake)
10
10
 
11
11
  file(GLOB react_debug_SRC CONFIGURE_DEPENDS *.cpp)
12
- add_library(react_debug OBJECT ${react_debug_SRC})
12
+ file(GLOB react_debug_redbox_SRC CONFIGURE_DEPENDS redbox/*.cpp)
13
+ add_library(react_debug OBJECT ${react_debug_SRC} ${react_debug_redbox_SRC})
13
14
 
14
15
  target_include_directories(react_debug PUBLIC ${REACT_COMMON_DIR})
15
16
 
@@ -25,10 +25,16 @@ Pod::Spec.new do |s|
25
25
  s.author = "Meta Platforms, Inc. and its affiliates"
26
26
  s.platforms = min_supported_versions
27
27
  s.source = source
28
- s.source_files = podspec_sources("**/*.{cpp,h}", "**/*.h")
28
+ s.source_files = podspec_sources("*.{cpp,h}", "*.h")
29
29
  s.header_dir = "react/debug"
30
30
  s.pod_target_xcconfig = { "CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
31
31
  "DEFINES_MODULE" => "YES" }
32
32
 
33
33
  resolve_use_frameworks(s, header_mappings_dir: "../..", module_name: "React_debug")
34
+
35
+ s.subspec "redbox" do |ss|
36
+ ss.source_files = podspec_sources("redbox/*.{cpp,h}", "redbox/*.h")
37
+ ss.exclude_files = "redbox/tests/**/*.{cpp,h}"
38
+ ss.header_dir = "react/debug/redbox"
39
+ end
34
40
  end
@@ -0,0 +1,139 @@
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 "AnsiParser.h"
9
+
10
+ #include <optional>
11
+
12
+ #include <regex> // NOLINT(facebook-hte-BadInclude-regex)
13
+
14
+ // @lint-ignore-every CLANGTIDY facebook-hte-StdRegexIsAwful
15
+ namespace facebook::react::unstable_redbox {
16
+
17
+ namespace {
18
+
19
+ // Afterglow theme colors (matching AnsiHighlight.js)
20
+ std::optional<AnsiColor> ansiColor(int code) {
21
+ switch (code) {
22
+ case 30:
23
+ return AnsiColor{.r = 27, .g = 27, .b = 27}; // black
24
+ case 31:
25
+ return AnsiColor{.r = 187, .g = 86, .b = 83}; // red
26
+ case 32:
27
+ return AnsiColor{.r = 144, .g = 157, .b = 98}; // green
28
+ case 33:
29
+ return AnsiColor{.r = 234, .g = 193, .b = 121}; // yellow
30
+ case 34:
31
+ return AnsiColor{.r = 125, .g = 169, .b = 199}; // blue
32
+ case 35:
33
+ return AnsiColor{.r = 176, .g = 101, .b = 151}; // magenta
34
+ case 36:
35
+ return AnsiColor{.r = 140, .g = 220, .b = 216}; // cyan
36
+ case 37:
37
+ return std::nullopt; // white = default
38
+ case 90:
39
+ return AnsiColor{.r = 98, .g = 98, .b = 98}; // bright black
40
+ case 91:
41
+ return AnsiColor{.r = 187, .g = 86, .b = 83}; // bright red
42
+ case 92:
43
+ return AnsiColor{.r = 144, .g = 157, .b = 98}; // bright green
44
+ case 93:
45
+ return AnsiColor{.r = 234, .g = 193, .b = 121}; // bright yellow
46
+ case 94:
47
+ return AnsiColor{.r = 125, .g = 169, .b = 199}; // bright blue
48
+ case 95:
49
+ return AnsiColor{.r = 176, .g = 101, .b = 151}; // bright magenta
50
+ case 96:
51
+ return AnsiColor{.r = 140, .g = 220, .b = 216}; // bright cyan
52
+ case 97:
53
+ return AnsiColor{.r = 247, .g = 247, .b = 247}; // bright white
54
+ default:
55
+ return std::nullopt;
56
+ }
57
+ }
58
+
59
+ const std::regex& ansiRegex() {
60
+ static const std::regex re(R"(\x1b\[([0-9;]*)m)");
61
+ return re;
62
+ }
63
+
64
+ int parseSgrCode(const std::string& params, size_t& pos) {
65
+ size_t next = params.find(';', pos);
66
+ if (next == std::string::npos) {
67
+ next = params.size();
68
+ }
69
+ int code = 0;
70
+ for (size_t i = pos; i < next; ++i) {
71
+ code = code * 10 + (params[i] - '0');
72
+ }
73
+ pos = next + 1;
74
+ return code;
75
+ }
76
+
77
+ } // namespace
78
+
79
+ std::vector<AnsiSpan> parseAnsi(const std::string& text) {
80
+ std::vector<AnsiSpan> spans;
81
+ std::optional<AnsiColor> currentFg;
82
+ std::optional<AnsiColor> currentBg;
83
+ auto it = std::sregex_iterator(text.begin(), text.end(), ansiRegex());
84
+ auto end = std::sregex_iterator();
85
+ size_t lastEnd = 0;
86
+
87
+ for (; it != end; ++it) {
88
+ const auto& match = *it;
89
+ auto matchStart = static_cast<size_t>(match.position());
90
+
91
+ if (matchStart > lastEnd) {
92
+ spans.push_back(
93
+ AnsiSpan{
94
+ .text = text.substr(lastEnd, matchStart - lastEnd),
95
+ .foregroundColor = currentFg,
96
+ .backgroundColor = currentBg});
97
+ }
98
+ lastEnd = matchStart + match.length();
99
+
100
+ std::string params = match[1].str();
101
+ // ESC[m (no params) is equivalent to ESC[0m (reset all attributes)
102
+ if (params.empty()) {
103
+ currentFg = std::nullopt;
104
+ currentBg = std::nullopt;
105
+ }
106
+ size_t pos = 0;
107
+ while (pos < params.size()) {
108
+ int code = parseSgrCode(params, pos);
109
+ if (code == 0) {
110
+ currentFg = std::nullopt;
111
+ currentBg = std::nullopt;
112
+ } else if ((code >= 30 && code <= 37) || (code >= 90 && code <= 97)) {
113
+ currentFg = ansiColor(code);
114
+ } else if ((code >= 40 && code <= 47) || (code >= 100 && code <= 107)) {
115
+ currentBg = ansiColor(code - 10);
116
+ } else if (code == 39) {
117
+ currentFg = std::nullopt;
118
+ } else if (code == 49) {
119
+ currentBg = std::nullopt;
120
+ }
121
+ }
122
+ }
123
+
124
+ if (lastEnd < text.size()) {
125
+ spans.push_back(
126
+ AnsiSpan{
127
+ .text = text.substr(lastEnd),
128
+ .foregroundColor = currentFg,
129
+ .backgroundColor = currentBg});
130
+ }
131
+
132
+ return spans;
133
+ }
134
+
135
+ std::string stripAnsi(const std::string& text) {
136
+ return std::regex_replace(text, ansiRegex(), "");
137
+ }
138
+
139
+ } // namespace facebook::react::unstable_redbox
@@ -0,0 +1,35 @@
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
+ #include <vector>
13
+
14
+ namespace facebook::react::unstable_redbox {
15
+
16
+ struct AnsiColor {
17
+ uint8_t r, g, b;
18
+ };
19
+
20
+ struct AnsiSpan {
21
+ std::string text;
22
+ std::optional<AnsiColor> foregroundColor;
23
+ std::optional<AnsiColor> backgroundColor;
24
+ };
25
+
26
+ /**
27
+ * Parse ANSI escape sequences in text and produce a list of styled spans.
28
+ * Uses the Afterglow color theme (matching LogBox's AnsiHighlight.js).
29
+ */
30
+ std::vector<AnsiSpan> parseAnsi(const std::string &text);
31
+
32
+ /** Strip all ANSI escape sequences from text. */
33
+ std::string stripAnsi(const std::string &text);
34
+
35
+ } // namespace facebook::react::unstable_redbox