Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add react-devtools-fusebox as third party dependency #22

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/gni/devtools_grd_files.gni
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,10 @@ grd_files_release_sources = [
"front_end/third_party/marked/marked.js",
"front_end/third_party/puppeteer-replay/puppeteer-replay.js",
"front_end/third_party/puppeteer/puppeteer.js",
"front_end/third_party/react-devtools/package/frontend.css.js",
"front_end/third_party/react-devtools/package/frontend.js",
"front_end/third_party/react-devtools/package/importFile.worker.worker.js",
"front_end/third_party/react-devtools/react-devtools.js",
"front_end/third_party/wasmparser/wasmparser.js",
"front_end/ui/components/adorners/adorners.js",
"front_end/ui/components/buttons/buttons.js",
Expand Down
2 changes: 2 additions & 0 deletions front_end/panels/react_devtools/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ devtools_module("react_devtools") {
sources = [ "ReactDevToolsView.ts", "ReactDevToolsModel.ts" ]

deps = [
"../../core/sdk:bundle",
"../../models/react_native:bundle",
"../../third_party/react-devtools:bundle",
"../../ui/legacy:bundle",
]
}
Expand Down
10 changes: 5 additions & 5 deletions front_end/panels/react_devtools/ReactDevToolsModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import * as SDK from '../../core/sdk/sdk.js';
import * as ReactNativeModels from '../../models/react_native/react_native.js';

type JSONValue = null | string | number | boolean | {[key: string]: JSONValue} | JSONValue[];
import type * as ReactDevToolsTypes from '../../third_party/react-devtools/react-devtools.js';

export const enum Events {
Initialized = 'Initialized',
Expand All @@ -15,7 +15,7 @@ export const enum Events {

export type EventTypes = {
[Events.Initialized]: void,
[Events.MessageReceived]: JSONValue,
[Events.MessageReceived]: ReactDevToolsTypes.Message,
};

export class ReactDevToolsModel extends SDK.SDKModel.SDKModel<EventTypes> {
Expand All @@ -42,7 +42,7 @@ export class ReactDevToolsModel extends SDK.SDKModel.SDKModel<EventTypes> {

rdtModel.subscribeToDomainMessages(
ReactDevToolsModel.FUSEBOX_BINDING_NAMESPACE,
message => this.onMessage(message),
message => this.onMessage(message as ReactDevToolsTypes.Message),
);
void rdtModel.initializeDomain(ReactDevToolsModel.FUSEBOX_BINDING_NAMESPACE).then(() => this.onInitialization());
}
Expand All @@ -51,7 +51,7 @@ export class ReactDevToolsModel extends SDK.SDKModel.SDKModel<EventTypes> {
this.dispatchEventToListeners(Events.Initialized);
}

async sendMessage(message: JSONValue): Promise<void> {
async sendMessage(message: ReactDevToolsTypes.Message): Promise<void> {
const rdtModel = this.rdtModel;
if (!rdtModel) {
throw new Error('Failed to send message from ReactDevToolsModel: ReactDevToolsBindingsModel was null');
Expand All @@ -60,7 +60,7 @@ export class ReactDevToolsModel extends SDK.SDKModel.SDKModel<EventTypes> {
await rdtModel.sendMessage(ReactDevToolsModel.FUSEBOX_BINDING_NAMESPACE, message);
}

onMessage(message: JSONValue): void {
onMessage(message: ReactDevToolsTypes.Message): void {
this.dispatchEventToListeners(Events.MessageReceived, message);
}
}
Expand Down
1 change: 1 addition & 0 deletions front_end/third_party/additional_readme_paths.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
"marked",
"puppeteer",
"puppeteer-replay",
"react-devtools",
"wasmparser"
]
36 changes: 36 additions & 0 deletions front_end/third_party/react-devtools/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("../../../scripts/build/ninja/devtools_entrypoint.gni")
import("../../../scripts/build/ninja/devtools_pre_built.gni")
import("../../../scripts/build/ninja/generate_css.gni")
import("../../../scripts/build/ninja/vars.gni")
import("../visibility.gni")

generate_css("css_files") {
sources = [ "package/frontend.css" ]
}

devtools_pre_built("react-devtools") {
sources_are_release = false

sources = [
"react-devtools-tsconfig.json",
"package/frontend.d.ts",
"package/frontend.js",
"package/importFile.worker.worker.js"
]
}

devtools_entrypoint("bundle") {
entrypoint = "react-devtools.ts"

deps = [
":css_files",
":react-devtools",
]

visibility = [ "../../panels/react_devtools/*" ]
visibility += devtools_third_party_visibility
}
9 changes: 9 additions & 0 deletions front_end/third_party/react-devtools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# react-devtools

## Sources for this package?
https://github.com/facebook/react/tree/main/packages/react-devtools-fusebox

## How to update this package?
1. Clone [`react`](https://github.com/facebook/react) repo and run `yarn build` in [`packages/react-devtools-fusebox`](https://github.com/facebook/react/tree/main/packages/react-devtools-fusebox)
2. Copy all artifacts from `build` folder to `package` folder here.
3. Update `frontend.d.ts` if needed, type definitions are not included in the build yet.
Loading
Loading