Skip to content

feat: use and initialize RDT Frontend in RDT panel #23

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

Merged

Conversation

hoxyq
Copy link

@hoxyq hoxyq commented Mar 14, 2024

Summary

Stacked on #22.

Last PR in this series of PRs. Uses react-devtools-fusebox as a dependency to initialize React DevTools Frontend.

Loader is rendered while React DevTools is initialized:

  • While we create global bindng and perform some initial Runtime.evaluate calls, this can be throttled by current performance problems with initial load of source maps

Potential improvements, will probably add later:

  • Adding catch block in case if initialization failed, for displaying error message
  • Removing worker CSP patch, and moving in to entrypoints build script, so only rn_fusebox is updated

Test plan

Demo:

Screen.Recording.2024-04-12.at.18.24.50.mov

Upstreaming plan

  • This commit should be sent as a patch to the upstream devtools-frontend repo. I've reviewed the contribution guide.
  • This commit is React Native-specific and cannot be upstreamed.

@hoxyq hoxyq force-pushed the react-devtools/initialize-react-devtools-frontend branch from 1976b59 to a19a4ba Compare April 15, 2024 08:01
@hoxyq hoxyq changed the title [WIP] feat: use and initialize RDT Frontend in RDT panel feat: use and initialize RDT Frontend in RDT panel Apr 15, 2024
@hoxyq hoxyq force-pushed the react-devtools/initialize-react-devtools-frontend branch 2 times, most recently from f8ecde2 to da012d6 Compare April 15, 2024 08:08
@hoxyq hoxyq marked this pull request as ready for review April 15, 2024 08:10
@hoxyq hoxyq force-pushed the react-devtools/initialize-react-devtools-frontend branch 2 times, most recently from 243b4e7 to a28a2f2 Compare April 15, 2024 14:51
Copy link

@motiz88 motiz88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shipittttt

ReactDevTools.initialize(this.contentElement, {
bridge: this.bridge,
store: this.store,
theme: usingDarkTheme ? 'dark' : 'light',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nits - can be filed as followup tasks IMO:

  1. Is this reactive to theme changes?
  2. Does CDT allow the user to override the theme? Will this honour that setting?

Copy link
Author

@hoxyq hoxyq Apr 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this reactive to theme changes?

Nope, it doesn't, unfortunately. I am keeping this in T185412086, because we can reuse it for browser extension.

Does CDT allow the user to override the theme? Will this honour that setting?

Yes, I've specified using dark theme in my Chrome and my Fusebox window is opened in dark mode across different reloads.

@@ -14,7 +14,7 @@
}
}
</style>
<meta http-equiv="Content-Security-Policy" content="object-src 'none'; script-src 'self' 'unsafe-eval' https://chrome-devtools-frontend.appspot.com">
<meta http-equiv="Content-Security-Policy" content="worker-src 'self' blob: ; object-src 'none'; script-src 'self' 'unsafe-eval' https://chrome-devtools-frontend.appspot.com">
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish this was more self-documenting. Might be worth an explanatory comment as part of the file.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about moving this to build_entrypoints script, so only rn_fusebox.html entrypoint gets this.

Will add this tomorrow and add an explanatory comment, basically RDT frontend is using workers API for file uploads.

@hoxyq hoxyq force-pushed the react-devtools/initialize-react-devtools-frontend branch from a28a2f2 to 2cc2cc3 Compare April 15, 2024 20:28
@hoxyq hoxyq merged commit 9222797 into facebook:main Apr 15, 2024
3 checks passed
@hoxyq hoxyq deleted the react-devtools/initialize-react-devtools-frontend branch April 15, 2024 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants