Skip to content

Commit eab7902

Browse files
committed
Replace Fusebox setClientMetadata handshake with ReactNativeApplicationModel
1 parent 6b80704 commit eab7902

File tree

9 files changed

+16
-95
lines changed

9 files changed

+16
-95
lines changed

front_end/core/protocol_client/InspectorBackend.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -672,10 +672,6 @@ export class TargetBase {
672672
return this.getAgent('Fetch');
673673
}
674674

675-
fuseboxClientAgent(): ProtocolProxyApi.FuseboxClientApi {
676-
return this.getAgent('FuseboxClient');
677-
}
678-
679675
heapProfilerAgent(): ProtocolProxyApi.HeapProfilerApi {
680676
return this.getAgent('HeapProfiler');
681677
}

front_end/core/sdk/ReactNativeApplicationModel.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import type * as ProtocolProxyApi from '../../generated/protocol-proxy-api.js';
77
import type * as Protocol from '../../generated/protocol.js';
88

9+
import * as Host from '../../core/host/host.js';
910
import {Capability, type Target} from './Target.js';
1011
import {SDKModel} from './SDKModel.js';
1112

@@ -21,14 +22,26 @@ export class ReactNativeApplicationModel extends SDKModel<EventTypes> implements
2122
this.#enabled = false;
2223
this.#agent = target.reactNativeApplicationAgent();
2324
target.registerReactNativeApplicationDispatcher(this);
25+
26+
// Auto-init. Paired with registering this model immediately in rn_fusebox.ts.
27+
this.ensureEnabled();
2428
}
2529

2630
ensureEnabled(): void {
2731
if (this.#enabled) {
2832
return;
2933
}
3034

31-
void this.#agent.invoke_enable();
35+
void this.#agent.invoke_enable()
36+
.then(result => {
37+
const maybeError = result.getError();
38+
const success = !maybeError;
39+
Host.rnPerfMetrics.fuseboxSetClientMetadataFinished(success, maybeError);
40+
})
41+
.catch(reason => {
42+
const success = false;
43+
Host.rnPerfMetrics.fuseboxSetClientMetadataFinished(success, reason);
44+
});
3245
this.#enabled = true;
3346
}
3447

@@ -45,11 +58,3 @@ export const enum Events {
4558
export type EventTypes = {
4659
[Events.MetadataUpdated]: Protocol.ReactNativeApplication.MetadataUpdatedEvent,
4760
};
48-
49-
SDKModel.register(
50-
ReactNativeApplicationModel,
51-
{
52-
capabilities: Capability.None,
53-
autostart: true,
54-
},
55-
);

front_end/entrypoints/rn_fusebox/rn_fusebox.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -91,30 +91,12 @@ document.addEventListener('visibilitychange', () => {
9191
Host.rnPerfMetrics.browserVisibilityChanged(document.visibilityState);
9292
});
9393

94-
class FuseboxClientMetadataModel extends SDK.SDKModel.SDKModel<void> {
95-
constructor(target: SDK.Target.Target) {
96-
super(target);
97-
Host.rnPerfMetrics.fuseboxSetClientMetadataStarted();
98-
target.fuseboxClientAgent()
99-
.invoke_setClientMetadata()
100-
.then(result => {
101-
const maybeError = result.getError();
102-
const success = !maybeError;
103-
Host.rnPerfMetrics.fuseboxSetClientMetadataFinished(success, maybeError);
104-
})
105-
.catch(reason => {
106-
const success = false;
107-
Host.rnPerfMetrics.fuseboxSetClientMetadataFinished(success, reason);
108-
});
109-
}
110-
}
111-
11294
SDK.SDKModel.SDKModel.register(
113-
FuseboxClientMetadataModel,
95+
SDK.ReactNativeApplicationModel.ReactNativeApplicationModel,
11496
{
11597
capabilities: SDK.Target.Capability.None,
11698
autostart: true,
117-
// Ensure FuseboxClient.setClientMetadata is sent before most other CDP domains
99+
// Ensure ReactNativeApplication.enable is sent before most other CDP domains
118100
// are initialised. This allows the backend to confidently detect non-Fusebox
119101
// clients by the fact that they send e.g. Runtime.enable without sending any
120102
// Fusebox-specific messages first.

front_end/generated/InspectorBackendCommands.js

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

front_end/generated/protocol-mapping.d.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -765,17 +765,6 @@ export namespace ProtocolMapping {
765765
}
766766

767767
export interface Commands {
768-
/**
769-
* Identifies the current client as being Fusebox.
770-
*
771-
* The Fusebox backend may use this knowledge to print an informational
772-
* message to the console, etc. The client should send this before enabling
773-
* the Runtime and Log domains.
774-
*/
775-
'FuseboxClient.setClientMetadata': {
776-
paramsType: [];
777-
returnType: void;
778-
};
779768
/**
780769
* Disables events from backend.
781770
*/

front_end/generated/protocol-proxy-api.d.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ declare namespace ProtocolProxyApi {
1818
export type ProtocolDomainName = keyof ProtocolApi;
1919

2020
export interface ProtocolApi {
21-
FuseboxClient: FuseboxClientApi;
22-
2321
ReactNativeApplication: ReactNativeApplicationApi;
2422

2523
Accessibility: AccessibilityApi;
@@ -123,8 +121,6 @@ declare namespace ProtocolProxyApi {
123121
}
124122

125123
export interface ProtocolDispatchers {
126-
FuseboxClient: FuseboxClientDispatcher;
127-
128124
ReactNativeApplication: ReactNativeApplicationDispatcher;
129125

130126
Accessibility: AccessibilityDispatcher;
@@ -227,21 +223,6 @@ declare namespace ProtocolProxyApi {
227223

228224
}
229225

230-
231-
export interface FuseboxClientApi {
232-
/**
233-
* Identifies the current client as being Fusebox.
234-
*
235-
* The Fusebox backend may use this knowledge to print an informational
236-
* message to the console, etc. The client should send this before enabling
237-
* the Runtime and Log domains.
238-
*/
239-
invoke_setClientMetadata(): Promise<Protocol.ProtocolResponseWithError>;
240-
241-
}
242-
export interface FuseboxClientDispatcher {
243-
}
244-
245226
export interface ReactNativeApplicationApi {
246227
/**
247228
* Disables events from backend.

front_end/generated/protocol.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@ export interface ProtocolResponseWithError {
1818
type OpaqueType<Tag extends string> = {protocolOpaqueTypeTag: Tag};
1919
type OpaqueIdentifier<RepresentationType, Tag extends string> = RepresentationType&OpaqueType<Tag>;
2020

21-
/**
22-
* A React Native-specific domain pertaining to the Fusebox (React Native
23-
* DevTools) client.
24-
*/
25-
export namespace FuseboxClient {
26-
}
27-
2821
/**
2922
* A React Native-specific domain for interacting with React Native application
3023
* features.

third_party/blink/public/devtools_protocol/browser_protocol.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@
44
"minor": "3"
55
},
66
"domains": [
7-
{
8-
"domain": "FuseboxClient",
9-
"description": "A React Native-specific domain pertaining to the Fusebox (React Native\nDevTools) client.",
10-
"experimental": true,
11-
"commands": [
12-
{
13-
"name": "setClientMetadata",
14-
"description": "Identifies the current client as being Fusebox.\n\nThe Fusebox backend may use this knowledge to print an informational\nmessage to the console, etc. The client should send this before enabling\nthe Runtime and Log domains."
15-
}
16-
]
17-
},
187
{
198
"domain": "ReactNativeApplication",
209
"description": "A React Native-specific domain for interacting with React Native application\nfeatures.",

third_party/blink/public/devtools_protocol/react_native_domains.pdl

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
11
# Copyright (c) Meta Platforms, Inc. and affiliates.
22

3-
# A React Native-specific domain pertaining to the Fusebox (React Native
4-
# DevTools) client.
5-
experimental domain FuseboxClient
6-
7-
# Identifies the current client as being Fusebox.
8-
#
9-
# The Fusebox backend may use this knowledge to print an informational
10-
# message to the console, etc. The client should send this before enabling
11-
# the Runtime and Log domains.
12-
command setClientMetadata
13-
143
# A React Native-specific domain for interacting with React Native application
154
# features.
165
experimental domain ReactNativeApplication

0 commit comments

Comments
 (0)