Skip to content

Commit c26d2fe

Browse files
Ruslan Lesiutinfacebook-github-bot
authored andcommitted
refactor: TraceUpdates native component -> DebuggingOverlay (facebook#41562)
Summary: Changelog: [Internal] We will use this native component as a single layer for drawing debugging information: both for trace updates and inspected components from React DevTools. Differential Revision: D51470789
1 parent c5aa184 commit c26d2fe

File tree

14 files changed

+56
-56
lines changed

14 files changed

+56
-56
lines changed

packages/react-native/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlay.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
* @format
99
*/
1010

11+
import type {Overlay} from '../../Debugging/DebuggingOverlayNativeComponent';
1112
import type {
1213
InstanceFromReactDevTools,
1314
ReactDevToolsAgent,
1415
} from '../../Types/ReactDevToolsTypes';
15-
import type {Overlay} from './TraceUpdateOverlayNativeComponent';
1616

17+
import TraceUpdateOverlayNativeComponent, {
18+
Commands,
19+
} from '../../Debugging/DebuggingOverlayNativeComponent';
1720
import processColor from '../../StyleSheet/processColor';
1821
import StyleSheet from '../../StyleSheet/StyleSheet';
1922
import View from '../View/View';
20-
import TraceUpdateOverlayNativeComponent, {
21-
Commands,
22-
} from './TraceUpdateOverlayNativeComponent';
2323
import * as React from 'react';
2424

2525
const {useEffect, useRef, useState} = React;

packages/react-native/Libraries/Components/TraceUpdateOverlay/TraceUpdateOverlayNativeComponent.js renamed to packages/react-native/Libraries/Debugging/DebuggingOverlayNativeComponent.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,26 @@
88
* @format
99
*/
1010

11-
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
12-
import type {ProcessedColorValue} from '../../StyleSheet/processColor';
13-
import type {ViewProps} from '../View/ViewPropTypes';
11+
import type {ViewProps} from '../Components/View/ViewPropTypes';
12+
import type {HostComponent} from '../Renderer/shims/ReactNativeTypes';
13+
import type {ProcessedColorValue} from '../StyleSheet/processColor';
1414

15-
import codegenNativeCommands from '../../Utilities/codegenNativeCommands';
16-
import codegenNativeComponent from '../../Utilities/codegenNativeComponent';
15+
import codegenNativeCommands from '../Utilities/codegenNativeCommands';
16+
import codegenNativeComponent from '../Utilities/codegenNativeComponent';
1717
import * as React from 'react';
1818

1919
type NativeProps = $ReadOnly<{|
2020
...ViewProps,
2121
|}>;
22-
export type TraceUpdateOverlayNativeComponentType = HostComponent<NativeProps>;
22+
export type DebuggingOverlayNativeComponentType = HostComponent<NativeProps>;
2323
export type Overlay = {
2424
rect: {left: number, top: number, width: number, height: number},
2525
color: ?ProcessedColorValue,
2626
};
2727

2828
interface NativeCommands {
2929
+draw: (
30-
viewRef: React.ElementRef<TraceUpdateOverlayNativeComponentType>,
30+
viewRef: React.ElementRef<DebuggingOverlayNativeComponentType>,
3131
// TODO(T144046177): Ideally we can pass array of Overlay, but currently
3232
// Array type is not supported in RN codegen for building native commands.
3333
overlays: string,
@@ -38,6 +38,6 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
3838
supportedCommands: ['draw'],
3939
});
4040

41-
export default (codegenNativeComponent<NativeProps>('TraceUpdateOverlay', {
42-
paperComponentName: 'RCTTraceUpdateOverlay',
41+
export default (codegenNativeComponent<NativeProps>('DebuggingOverlay', {
42+
paperComponentName: 'RCTDebuggingOverlay',
4343
}): HostComponent<NativeProps>);

packages/react-native/React/Fabric/Mounting/ComponentViews/TraceUpdateOverlay/RCTTraceUpdateOverlayComponentView.h renamed to packages/react-native/React/Fabric/Mounting/ComponentViews/DebuggingOverlay/RCTDebuggingOverlayComponentView.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99

1010
#import <React/RCTViewComponentView.h>
1111

12-
@interface RCTTraceUpdateOverlayComponentView : RCTViewComponentView
12+
@interface RCTDebuggingOverlayComponentView : RCTViewComponentView
1313

1414
@end

packages/react-native/React/Fabric/Mounting/ComponentViews/TraceUpdateOverlay/RCTTraceUpdateOverlayComponentView.mm renamed to packages/react-native/React/Fabric/Mounting/ComponentViews/DebuggingOverlay/RCTDebuggingOverlayComponentView.mm

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
#import "RCTTraceUpdateOverlayComponentView.h"
8+
#import "RCTDebuggingOverlayComponentView.h"
99

10+
#import <React/RCTDebuggingOverlay.h>
1011
#import <React/RCTDefines.h>
1112
#import <React/RCTLog.h>
12-
#import <React/RCTTraceUpdateOverlay.h>
1313

1414
#import <react/renderer/components/rncore/ComponentDescriptors.h>
1515
#import <react/renderer/components/rncore/EventEmitters.h>
@@ -19,17 +19,17 @@
1919

2020
using namespace facebook::react;
2121

22-
@implementation RCTTraceUpdateOverlayComponentView {
23-
RCTTraceUpdateOverlay *_overlay;
22+
@implementation RCTDebuggingOverlayComponentView {
23+
RCTDebuggingOverlay *_overlay;
2424
}
2525

2626
- (instancetype)initWithFrame:(CGRect)frame
2727
{
2828
if (self = [super initWithFrame:frame]) {
29-
static const auto defaultProps = std::make_shared<const TraceUpdateOverlayProps>();
29+
static const auto defaultProps = std::make_shared<const DebuggingOverlayProps>();
3030
_props = defaultProps;
3131

32-
_overlay = [[RCTTraceUpdateOverlay alloc] initWithFrame:self.bounds];
32+
_overlay = [[RCTDebuggingOverlay alloc] initWithFrame:self.bounds];
3333

3434
self.contentView = _overlay;
3535
}
@@ -41,22 +41,22 @@ - (instancetype)initWithFrame:(CGRect)frame
4141

4242
+ (ComponentDescriptorProvider)componentDescriptorProvider
4343
{
44-
return concreteComponentDescriptorProvider<TraceUpdateOverlayComponentDescriptor>();
44+
return concreteComponentDescriptorProvider<DebuggingOverlayComponentDescriptor>();
4545
}
4646

4747
#pragma mark - Native commands
4848

4949
- (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
5050
{
5151
if (![commandName isEqualToString:@"draw"]) {
52-
RCTLogError(@"%@ received unsupported command %@", @"TraceUpdateOverlay", commandName);
52+
RCTLogError(@"%@ received unsupported command %@", @"DebuggingOverlay", commandName);
5353
return;
5454
}
5555

5656
NSObject *arg0 = args[0];
5757
#if RCT_DEBUG
5858
if (!RCTValidateTypeOfViewCommandArgument(
59-
arg0, [NSString class], @"string", @"TraceUpdateOverlay", commandName, @"1st")) {
59+
arg0, [NSString class], @"string", @"DebuggingOverlay", commandName, @"1st")) {
6060
return;
6161
}
6262
#endif
@@ -67,7 +67,7 @@ - (void)handleCommand:(const NSString *)commandName args:(const NSArray *)args
6767

6868
@end
6969

70-
Class<RCTComponentViewProtocol> RCTTraceUpdateOverlayCls(void)
70+
Class<RCTComponentViewProtocol> RCTDebuggingOverlayCls(void)
7171
{
72-
return RCTTraceUpdateOverlayComponentView.class;
72+
return RCTDebuggingOverlayComponentView.class;
7373
}

packages/react-native/React/Fabric/Mounting/ComponentViews/RCTFabricComponentsPlugins.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ Class<RCTComponentViewProtocol> RCTFabricComponentsProvider(const char *name);
3131

3232
// Lookup functions
3333
Class<RCTComponentViewProtocol> RCTActivityIndicatorViewCls(void) __attribute__((used));
34+
Class<RCTComponentViewProtocol> RCTDebuggingOverlayCls(void) __attribute__((used));
3435
Class<RCTComponentViewProtocol> RCTInputAccessoryCls(void) __attribute__((used));
3536
Class<RCTComponentViewProtocol> RCTParagraphCls(void) __attribute__((used));
3637
Class<RCTComponentViewProtocol> RCTPullToRefreshViewCls(void) __attribute__((used));
3738
Class<RCTComponentViewProtocol> RCTSafeAreaViewCls(void) __attribute__((used));
3839
Class<RCTComponentViewProtocol> RCTScrollViewCls(void) __attribute__((used));
3940
Class<RCTComponentViewProtocol> RCTSwitchCls(void) __attribute__((used));
4041
Class<RCTComponentViewProtocol> RCTTextInputCls(void) __attribute__((used));
41-
Class<RCTComponentViewProtocol> RCTTraceUpdateOverlayCls(void) __attribute__((used));
4242
Class<RCTComponentViewProtocol> RCTUnimplementedNativeViewCls(void) __attribute__((used));
4343
Class<RCTComponentViewProtocol> RCTViewCls(void) __attribute__((used));
4444
Class<RCTComponentViewProtocol> RCTImageCls(void) __attribute__((used));

packages/react-native/React/Fabric/Mounting/ComponentViews/RCTFabricComponentsPlugins.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
Class<RCTComponentViewProtocol> RCTFabricComponentsProvider(const char *name) {
2020
static std::unordered_map<std::string, Class (*)(void)> sFabricComponentsClassMap = {
2121
{"ActivityIndicatorView", RCTActivityIndicatorViewCls},
22+
{"DebuggingOverlay", RCTDebuggingOverlayCls},
2223
{"InputAccessoryView", RCTInputAccessoryCls},
2324
{"Paragraph", RCTParagraphCls},
2425
{"PullToRefreshView", RCTPullToRefreshViewCls},
2526
{"SafeAreaView", RCTSafeAreaViewCls},
2627
{"ScrollView", RCTScrollViewCls},
2728
{"Switch", RCTSwitchCls},
2829
{"TextInput", RCTTextInputCls},
29-
{"TraceUpdateOverlay", RCTTraceUpdateOverlayCls},
3030
{"UnimplementedNativeView", RCTUnimplementedNativeViewCls},
3131
{"View", RCTViewCls},
3232
{"Image", RCTImageCls},

packages/react-native/React/Views/RCTTraceUpdateOverlay.h renamed to packages/react-native/React/Views/RCTDebuggingOverlay.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
#import <React/RCTView.h>
1111

12-
@interface RCTTraceUpdateOverlay : RCTView
12+
@interface RCTDebuggingOverlay : RCTView
1313

1414
- (void)draw:(NSString *)serializedNodes;
1515

packages/react-native/React/Views/RCTTraceUpdateOverlay.m renamed to packages/react-native/React/Views/RCTDebuggingOverlay.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
#import "RCTTraceUpdateOverlay.h"
8+
#import "RCTDebuggingOverlay.h"
99

1010
#import <React/RCTLog.h>
1111

12-
@implementation RCTTraceUpdateOverlay
12+
@implementation RCTDebuggingOverlay
1313

1414
- (void)draw:(NSString *)serializedNodes
1515
{
@@ -24,7 +24,7 @@ - (void)draw:(NSString *)serializedNodes
2424
id deserializedNodes = [NSJSONSerialization JSONObjectWithData:serializedNodesAsData options:0 error:&error];
2525

2626
if (error) {
27-
RCTLogError(@"Failed to parse serialized nodes passed to RCTTraceUpdatesOverlay");
27+
RCTLogError(@"Failed to parse serialized nodes passed to RCTDebuggingOverlay");
2828
return;
2929
}
3030

packages/react-native/React/Views/RCTTraceUpdateOverlayManager.h renamed to packages/react-native/React/Views/RCTDebuggingOverlayManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77

88
#import <React/RCTViewManager.h>
99

10-
@interface RCTTraceUpdateOverlayManager : RCTViewManager
10+
@interface RCTDebuggingOverlayManager : RCTViewManager
1111

1212
@end

packages/react-native/React/Views/RCTTraceUpdateOverlayManager.m renamed to packages/react-native/React/Views/RCTDebuggingOverlayManager.m

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,32 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
#import "RCTTraceUpdateOverlayManager.h"
9-
#import "RCTTraceUpdateOverlay.h"
8+
#import "RCTDebuggingOverlayManager.h"
9+
#import "RCTDebuggingOverlay.h"
1010

1111
#import <React/RCTLog.h>
1212
#import <React/RCTUIManager.h>
1313

1414
#import "RCTBridge.h"
1515

16-
@implementation RCTTraceUpdateOverlayManager
16+
@implementation RCTDebuggingOverlayManager
1717

1818
RCT_EXPORT_MODULE()
1919

2020
- (UIView *)view
2121
{
22-
return [RCTTraceUpdateOverlay new];
22+
return [RCTDebuggingOverlay new];
2323
}
2424

2525
RCT_EXPORT_METHOD(draw : (nonnull NSNumber *)viewTag nodes : (NSString *)serializedNodes)
2626
{
2727
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
2828
UIView *view = viewRegistry[viewTag];
2929

30-
if ([view isKindOfClass:[RCTTraceUpdateOverlay class]]) {
31-
[(RCTTraceUpdateOverlay *)view draw:serializedNodes];
30+
if ([view isKindOfClass:[RCTDebuggingOverlay class]]) {
31+
[(RCTDebuggingOverlay *)view draw:serializedNodes];
3232
} else {
33-
RCTLogError(@"Expected view to be RCTTraceUpdateOverlay, got %@", NSStringFromClass([view class]));
33+
RCTLogError(@"Expected view to be RCTDebuggingOverlay, got %@", NSStringFromClass([view class]));
3434
}
3535
}];
3636
}

0 commit comments

Comments
 (0)