@@ -22,14 +22,8 @@ namespace facebook::react::jsinspector_modern {
22
22
23
23
#define ANSI_WEIGHT_BOLD " \x1B [1m"
24
24
#define ANSI_WEIGHT_RESET " \x1B [22m"
25
- #define ANSI_STYLE_ITALIC " \x1B [3m"
26
- #define ANSI_STYLE_RESET " \x1B [23m"
27
25
#define ANSI_COLOR_BG_YELLOW " \x1B [48;2;253;247;231m"
28
-
29
- static constexpr auto kModernCDPBackendNotice =
30
- ANSI_COLOR_BG_YELLOW ANSI_WEIGHT_BOLD
31
- " NOTE:" ANSI_WEIGHT_RESET " You are using the " ANSI_STYLE_ITALIC
32
- " modern" ANSI_STYLE_RESET " CDP backend for React Native (HostTarget)." sv;
26
+ #define CSS_STYLE_PLACEHOLDER " %c"
33
27
34
28
HostAgent::HostAgent (
35
29
FrontendChannel frontendChannel,
@@ -51,12 +45,15 @@ void HostAgent::handleRequest(const cdp::PreparsedRequest& req) {
51
45
if (req.method == " Log.enable" ) {
52
46
sessionState_.isLogDomainEnabled = true ;
53
47
54
- // Send a log entry identifying the modern CDP backend.
55
- sendInfoLogEntry (kModernCDPBackendNotice );
48
+ if (sessionState_.isFuseboxClientDetected ) {
49
+ sendFuseboxNotice ();
50
+ }
56
51
57
52
// Send a log entry with the integration name.
58
53
if (sessionMetadata_.integrationName ) {
59
- sendInfoLogEntry (" Integration: " + *sessionMetadata_.integrationName );
54
+ sendInfoLogEntry (
55
+ ANSI_COLOR_BG_YELLOW " Debugger integration: " +
56
+ *sessionMetadata_.integrationName );
60
57
}
61
58
62
59
shouldSendOKResponse = true ;
@@ -100,6 +97,15 @@ void HostAgent::handleRequest(const cdp::PreparsedRequest& req) {
100
97
: std::nullopt,
101
98
});
102
99
100
+ shouldSendOKResponse = true ;
101
+ isFinishedHandlingRequest = true ;
102
+ } else if (req.method == " FuseboxClient.setClientMetadata" ) {
103
+ sessionState_.isFuseboxClientDetected = true ;
104
+
105
+ if (sessionState_.isLogDomainEnabled ) {
106
+ sendFuseboxNotice ();
107
+ }
108
+
103
109
shouldSendOKResponse = true ;
104
110
isFinishedHandlingRequest = true ;
105
111
}
@@ -120,7 +126,23 @@ void HostAgent::handleRequest(const cdp::PreparsedRequest& req) {
120
126
req.method + " not implemented yet" ));
121
127
}
122
128
123
- void HostAgent::sendInfoLogEntry (std::string_view text) {
129
+ void HostAgent::sendFuseboxNotice () {
130
+ static constexpr auto kFuseboxNotice = ANSI_COLOR_BG_YELLOW
131
+ " Welcome to the new React Native debugger (codename " ANSI_WEIGHT_BOLD
132
+ " React Fusebox " CSS_STYLE_PLACEHOLDER
133
+ " ⚡️" CSS_STYLE_PLACEHOLDER ANSI_WEIGHT_RESET " )." sv;
134
+
135
+ sendInfoLogEntry (
136
+ kFuseboxNotice , {" font-family: sans-serif;" , " font-family: monospace;" });
137
+ }
138
+
139
+ void HostAgent::sendInfoLogEntry (
140
+ std::string_view text,
141
+ std::initializer_list<std::string_view> args) {
142
+ folly::dynamic argsArray = folly::dynamic::array ();
143
+ for (auto arg : args) {
144
+ argsArray.push_back (arg);
145
+ }
124
146
frontendChannel_ (cdp::jsonNotification (
125
147
" Log.entryAdded" ,
126
148
folly::dynamic::object (
@@ -130,7 +152,7 @@ void HostAgent::sendInfoLogEntry(std::string_view text) {
130
152
duration_cast<milliseconds>(
131
153
system_clock::now ().time_since_epoch ())
132
154
.count ())(" source" , " other" )(
133
- " level" , " info" )(" text" , text))));
155
+ " level" , " info" )(" text" , text)( " args " , std::move (argsArray)) )));
134
156
}
135
157
136
158
void HostAgent::setCurrentInstanceAgent (
0 commit comments