GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — refactor: allow custom impl of backend realod-to-profile support check by EdmondChuiHW · Pull Request #31048 · react/react Conversation
Contributor
SummaryIn preparation to support reload-to-profile in Fusebox (#31021), we need a way to check capability of different backends, e.g. web vs React Native. How did you test this change?
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| inspectedElement: [InspectedElementPayload], | ||
| isBackendStorageAPISupported: [boolean], | ||
| isSynchronousXHRSupported: [boolean], | ||
| isReloadAndProfileSupported: [boolean], |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can it be backendSupportsReloadAndProfile or isReloadAndProfileSupportedByBackend?
The final version is up to you, I just want it to explicitly mention that this is about backend.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| const agent = new Agent(bridge); | ||
| bridge.send('isReloadAndProfileSupported', isReloadAndProfileSupported()); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think we should move it somewhere. Can this actually be an argument on initBackend?
Notice that you don't have any changes related to the browser extension, this is because it has its own logic for backend initialization:
https://github.com/facebook/react/blob/fc4a33eaa9c935ac860ab6043b95d55540068571/packages/react-devtools-extensions/src/contentScripts/backendManager.js#L99-L161
Then, inside initBackend, we could do something like:
if (isReloadAndProfileSupported()) {
agent.onReloadAndProfileSupportedByHost();
}
and inside Agent this method would just send this event:
this._bridge.send('isReloadAndProfileSupported', true);
and the only remaining thing is hardcoding true for initBackend call in the extension code, which I've referenced above
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This will allow us to reuse as much as possible, and reduce the fragmentation: instead of having custom logic, like here in react-devtools-core/src/backend.js, we would pass an argument to initBackend, which is from react-devtools-shared
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Great idea! Much cleaner to have this logic back into Agent/initBackend. Updated
Sorry, something went wrong.
There was an error while loading. Please reload this page.
32a04cc to
19ad6d1
Compare
| }); | ||
|
|
||
| const getIsReloadAndProfileSupported = | ||
| hook.settings?.getIsReloadAndProfileSupported ?? |
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This won't do anything, because you don't store it on the Hook object, and you don't need to.
Can you add boolean optional parameter to initBackend here?
https://github.com/facebook/react/blob/a15bbe14751287cb7ac124ff88f694d0883f3ac6/packages/react-devtools-shared/src/backend/index.js#L16-L20
Then, anywhere where you are calling initBackend: browser extension content script, react-devtools-core, react-devtools-inline, you will provide this argument.
For browser extension it will be true by default, for react-devtools-inline it will be false (we don't support it), for react-devtools-core this will be the return of the function isReloadAndProfileSupported, which is passed from the Host (React Native in our case)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
3f6d608 to
9a7cec7
Compare
| hook: DevToolsHook, | ||
| agent: Agent, | ||
| global: Object, | ||
| getIsReloadAndProfileSupported: () => boolean = defaultGetIsReloadAndProfileSupported, |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Can this be boolean with a default value false? And then wrappers around it are going to pass just a boolean value, and react-devtools-core is going to pass getIsReloadAndProfileSupported().
With a current implementation, the extension is going to use defaultGetIsReloadAndProfileSupported, but actually it should just receive a static true value.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't the extension still need to check the local/session storage capabilities, e.g. incognito mode?
Edit: I'm inclined to keep this PR focused on just the refactoring, i.e. keeping existing things working the way it has been, even if it's suboptimal/obsolete. We can follow up and remove the checks in a separate PR as needed
Sorry, something went wrong.
There was an error while loading. Please reload this page.
9a7cec7 to
a474aa8
Compare
## Summary Add reload to profile for Fusebox Stacked on #31048. See 6be1977 ## How did you test this change? Test E2E in [D63233256](https://www.internalfb.com/diff/D63233256)
**breaking change for canary users: Bumps peer dependency of React from `19.0.0-rc-778e1ed2-20240926` to `19.0.0-rc-3edc000d-20240926`** [diff react/react@778e1ed2...3edc000d](react/react@778e1ed...3edc000) <details> <summary>React upstream changes</summary> - react/react#31078 - react/react#31083 - react/react#31079 - react/react#31080 - react/react#31076 - react/react#31021 - react/react#31069 - react/react#31074 - react/react#31073 - react/react#31047 - react/react#31046 - react/react#31045 - react/react#31072 - react/react#30980 - react/react#30463 - react/react#30694 - react/react#31039 - react/react#31048 - react/react#31068 </details> --------- Co-authored-by: Josh Story <[email protected]>
Changes in this release: * Fix React Compiler badging ([poteto](https://github.com/poteto) in [#31196](#31196)) * fix[react-devtools]: fixed timeline profiler tests ([hoxyq](https://github.com/hoxyq) in [#31261](#31261)) * fix[react-devtools]: record timeline data only when supported ([hoxyq](https://github.com/hoxyq) in [#31154](#31154)) * refactor[react-devtools]: flatten reload and profile config ([hoxyq](https://github.com/hoxyq) in [#31132](#31132)) * fix[react-devtools]: remove all listeners when Agent is shutdown ([hoxyq](https://github.com/hoxyq) in [#31151](#31151)) * fix[react-devtools]: removed redundant startProfiling call ([hoxyq](https://github.com/hoxyq) in [#31131](#31131)) * refactor[react-devtools/fiber/renderer]: optimize durations resolution ([hoxyq](https://github.com/hoxyq) in [#31118](#31118)) * fix[react-devtools]: update profiling status before receiving response from backend ([hoxyq](https://github.com/hoxyq) in [#31117](#31117)) * fix[react-devtools]: wrap key string in preformatted text html element ([hoxyq](https://github.com/hoxyq) in [#31153](#31153)) * chore[react-devtools]: drop legacy context tests ([hoxyq](https://github.com/hoxyq) in [#31059](#31059)) * chore[react-devtools]: add legacy mode error message to the ignore list for tests ([hoxyq](https://github.com/hoxyq) in [#31060](#31060)) * fix[react-devtools]: request hook initialization inside http server response ([hoxyq](https://github.com/hoxyq) in [#31102](#31102)) * [Flight] Serialize Server Components Props in DEV ([sebmarkbage](https://github.com/sebmarkbage) in [#31105](#31105)) * Add: reload to profile for Fusebox ([EdmondChuiHW](https://github.com/EdmondChuiHW) in [#31021](#31021)) * refactor: allow custom impl of backend realod-to-profile support check ([EdmondChuiHW](https://github.com/EdmondChuiHW) in [#31048](#31048)) * fix: use public instance in Fiber renderer and expose it from getInspectorDataForViewAtPoint ([hoxyq](https://github.com/hoxyq) in [#31068](#31068))
react#31048) <!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory. Before submitting a pull request, please make sure the following is done: 1. Fork [the repository](https://github.com/facebook/react) and create your branch from `main`. 2. Run `yarn` in the repository root. 3. If you've fixed a bug or added code that should be tested, add tests! 4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch TestName` is helpful in development. 5. Run `yarn test --prod` to test in the production environment. It supports the same options as `yarn test`. 6. If you need a debugger, run `yarn test --debug --watch TestName`, open `chrome://inspect`, and press "Inspect". 7. Format your code with [prettier](https://github.com/prettier/prettier) (`yarn prettier`). 8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only check changed files. 9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`). 10. If you haven't already, complete the CLA. Learn more about contributing: https://reactjs.org/docs/how-to-contribute.html --> ## Summary In preparation to support reload-to-profile in Fusebox (react#31021), we need a way to check capability of different backends, e.g. web vs React Native. ## How did you test this change? <!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. How exactly did you verify that your PR solves the issue you wanted to solve? If you leave this empty, your PR will very likely be closed. --> * Default, e.g. existing web impl = no-op * Custom impl: is called
## Summary Add reload to profile for Fusebox Stacked on react#31048. See react@6be1977 ## How did you test this change? Test E2E in [D63233256](https://www.internalfb.com/diff/D63233256)
Changes in this release: * Fix React Compiler badging ([poteto](https://github.com/poteto) in [react#31196](react#31196)) * fix[react-devtools]: fixed timeline profiler tests ([hoxyq](https://github.com/hoxyq) in [react#31261](react#31261)) * fix[react-devtools]: record timeline data only when supported ([hoxyq](https://github.com/hoxyq) in [react#31154](react#31154)) * refactor[react-devtools]: flatten reload and profile config ([hoxyq](https://github.com/hoxyq) in [react#31132](react#31132)) * fix[react-devtools]: remove all listeners when Agent is shutdown ([hoxyq](https://github.com/hoxyq) in [react#31151](react#31151)) * fix[react-devtools]: removed redundant startProfiling call ([hoxyq](https://github.com/hoxyq) in [react#31131](react#31131)) * refactor[react-devtools/fiber/renderer]: optimize durations resolution ([hoxyq](https://github.com/hoxyq) in [react#31118](react#31118)) * fix[react-devtools]: update profiling status before receiving response from backend ([hoxyq](https://github.com/hoxyq) in [react#31117](react#31117)) * fix[react-devtools]: wrap key string in preformatted text html element ([hoxyq](https://github.com/hoxyq) in [react#31153](react#31153)) * chore[react-devtools]: drop legacy context tests ([hoxyq](https://github.com/hoxyq) in [react#31059](react#31059)) * chore[react-devtools]: add legacy mode error message to the ignore list for tests ([hoxyq](https://github.com/hoxyq) in [react#31060](react#31060)) * fix[react-devtools]: request hook initialization inside http server response ([hoxyq](https://github.com/hoxyq) in [react#31102](react#31102)) * [Flight] Serialize Server Components Props in DEV ([sebmarkbage](https://github.com/sebmarkbage) in [react#31105](react#31105)) * Add: reload to profile for Fusebox ([EdmondChuiHW](https://github.com/EdmondChuiHW) in [react#31021](react#31021)) * refactor: allow custom impl of backend realod-to-profile support check ([EdmondChuiHW](https://github.com/EdmondChuiHW) in [react#31048](react#31048)) * fix: use public instance in Fiber renderer and expose it from getInspectorDataForViewAtPoint ([hoxyq](https://github.com/hoxyq) in [react#31068](react#31068))
a474aa80
Deployed
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.