Commit Graph

316 Commits

Author SHA1 Message Date
Edmond Chui
f8024b0686 refactor: allow custom impl of backend realod-to-profile support check (#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 (#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
2024-09-26 12:39:28 +01:00
Ruslan Lesiutin
d2e9b9b4dc React DevTools 5.3.1 -> 6.0.0 (#31058)
Full list of changes:
* refactor: data source for errors and warnings tracking is now in Store
([hoxyq](https://github.com/hoxyq) in
[#31010](https://github.com/facebook/react/pull/31010))
* fix: consider alternate as a key for componentLogsEntry when
inspecting raw fiber instance ([hoxyq](https://github.com/hoxyq) in
[#31009](https://github.com/facebook/react/pull/31009))
* Fix: profiling crashes #30661 #28838
([EdmondChuiHW](https://github.com/EdmondChuiHW) in
[#31024](https://github.com/facebook/react/pull/31024))
* chore: remove using local storage for persisting console settings on
the frontend ([hoxyq](https://github.com/hoxyq) in
[#31002](https://github.com/facebook/react/pull/31002))
* feat: display message if user ended up opening hook script
([hoxyq](https://github.com/hoxyq) in
[#31000](https://github.com/facebook/react/pull/31000))
* feat: expose installHook with settings argument from
react-devtools-core/backend ([hoxyq](https://github.com/hoxyq) in
[#30987](https://github.com/facebook/react/pull/30987))
* chore: remove settings manager from react-devtools-core
([hoxyq](https://github.com/hoxyq) in
[#30986](https://github.com/facebook/react/pull/30986))
* feat[react-devtools/extension]: use chrome.storage to persist settings
across sessions ([hoxyq](https://github.com/hoxyq) in
[#30636](https://github.com/facebook/react/pull/30636))
* refactor[react-devtools]: propagate settings from global hook object
to frontend ([hoxyq](https://github.com/hoxyq) in
[#30610](https://github.com/facebook/react/pull/30610))
* chore[react-devtools]: extract some utils into separate modules to
unify implementations ([hoxyq](https://github.com/hoxyq) in
[#30597](https://github.com/facebook/react/pull/30597))
* refactor[react-devtools]: move console patching to global hook
([hoxyq](https://github.com/hoxyq) in
[#30596](https://github.com/facebook/react/pull/30596))
* refactor[react-devtools]: remove browserTheme from
ConsolePatchSettings ([hoxyq](https://github.com/hoxyq) in
[#30566](https://github.com/facebook/react/pull/30566))
* feat[react-devtools]: add settings to global hook object
([hoxyq](https://github.com/hoxyq) in
[#30564](https://github.com/facebook/react/pull/30564))
* fix: add Error prefix to Error objects names
([hoxyq](https://github.com/hoxyq) in
[#30969](https://github.com/facebook/react/pull/30969))
* Add enableComponentPerformanceTrack Flag
([sebmarkbage](https://github.com/sebmarkbage) in
[#30960](https://github.com/facebook/react/pull/30960))
* fix[rdt/fiber/renderer.js]: getCurrentFiber can be injected as null
([hoxyq](https://github.com/hoxyq) in
[#30968](https://github.com/facebook/react/pull/30968))
* disable `enableSiblingPrerendering` in experimental channel
([gnoff](https://github.com/gnoff) in
[#30952](https://github.com/facebook/react/pull/30952))
* refactor[react-devtools]: initialize renderer interface early
([hoxyq](https://github.com/hoxyq) in
[#30946](https://github.com/facebook/react/pull/30946))
* Start prerendering Suspense retries immediately
([acdlite](https://github.com/acdlite) in
[#30934](https://github.com/facebook/react/pull/30934))
* refactor[Agent/Store]: Store to send messages only after Agent is
initialized ([hoxyq](https://github.com/hoxyq) in
[#30945](https://github.com/facebook/react/pull/30945))
* refactor[RendererInterface]: expose onErrorOrWarning and
getComponentStack ([hoxyq](https://github.com/hoxyq) in
[#30931](https://github.com/facebook/react/pull/30931))
* Implement getComponentStack and onErrorOrWarning for replayed Flight
logs ([sebmarkbage](https://github.com/sebmarkbage) in
[#30930](https://github.com/facebook/react/pull/30930))
* Use Unicode Atom Symbol instead of Atom Emoji
([sebmarkbage](https://github.com/sebmarkbage) in
[#30832](https://github.com/facebook/react/pull/30832))
* Improve Layering Between Console and Renderer
([sebmarkbage](https://github.com/sebmarkbage) in
[#30925](https://github.com/facebook/react/pull/30925))
* Add Map for Server Component Logs
([sebmarkbage](https://github.com/sebmarkbage) in
[#30905](https://github.com/facebook/react/pull/30905))
* Delete fiberToFiberInstanceMap
([sebmarkbage](https://github.com/sebmarkbage) in
[#30900](https://github.com/facebook/react/pull/30900))
* Add Flight Renderer ([sebmarkbage](https://github.com/sebmarkbage) in
[#30906](https://github.com/facebook/react/pull/30906))
* Refactor Error / Warning Count Tracking
([sebmarkbage](https://github.com/sebmarkbage) in
[#30899](https://github.com/facebook/react/pull/30899))
* [flow] Upgrade Flow to 0.245.2
([SamChou19815](https://github.com/SamChou19815) in
[#30919](https://github.com/facebook/react/pull/30919))
* Separate RDT Fusebox into single-panel entry points
([huntie](https://github.com/huntie) in
[#30708](https://github.com/facebook/react/pull/30708))
* Build Updater List from the Commit instead of Map
([sebmarkbage](https://github.com/sebmarkbage) in
[#30897](https://github.com/facebook/react/pull/30897))
* Simplify Context Change Tracking in Profiler
([sebmarkbage](https://github.com/sebmarkbage) in
[#30896](https://github.com/facebook/react/pull/30896))
* Remove use of .alternate in root and recordProfilingDurations
([sebmarkbage](https://github.com/sebmarkbage) in
[#30895](https://github.com/facebook/react/pull/30895))
* Handle reordered contexts in Profiler
([sebmarkbage](https://github.com/sebmarkbage) in
[#30887](https://github.com/facebook/react/pull/30887))
* Refactor Forcing Fallback / Error of Suspense / Error Boundaries
([sebmarkbage](https://github.com/sebmarkbage) in
[#30870](https://github.com/facebook/react/pull/30870))
* Avoid getFiberIDUnsafe in debug() Helper
([sebmarkbage](https://github.com/sebmarkbage) in
[#30878](https://github.com/facebook/react/pull/30878))
* Include some Filtered Fiber Instances
([sebmarkbage](https://github.com/sebmarkbage) in
[#30865](https://github.com/facebook/react/pull/30865))
* Track root instances in a root Map
([sebmarkbage](https://github.com/sebmarkbage) in
[#30875](https://github.com/facebook/react/pull/30875))
* Track all public HostInstances in a Map
([sebmarkbage](https://github.com/sebmarkbage) in
[#30831](https://github.com/facebook/react/pull/30831))
* Support VirtualInstances in findAllCurrentHostInstances
([sebmarkbage](https://github.com/sebmarkbage) in
[#30853](https://github.com/facebook/react/pull/30853))
* Add Filtering of Environment Names
([sebmarkbage](https://github.com/sebmarkbage) in
[#30850](https://github.com/facebook/react/pull/30850))
* Support secondary environment name when it changes
([sebmarkbage](https://github.com/sebmarkbage) in
[#30842](https://github.com/facebook/react/pull/30842))
* Increase max payload for websocket in standalone app
([runeb](https://github.com/runeb) in
[#30848](https://github.com/facebook/react/pull/30848))
* Filter Server Components
([sebmarkbage](https://github.com/sebmarkbage) in
[#30839](https://github.com/facebook/react/pull/30839))
* Track virtual instances on the tracked path for selections
([sebmarkbage](https://github.com/sebmarkbage) in
[#30802](https://github.com/facebook/react/pull/30802))
* Remove displayName from inspected data
([sebmarkbage](https://github.com/sebmarkbage) in
[#30841](https://github.com/facebook/react/pull/30841))
* chore[react-devtools/hook]: remove unused native values
([hoxyq](https://github.com/hoxyq) in
[#30827](https://github.com/facebook/react/pull/30827))
* chore[react-devtools/extensions]: remove unused storage permission
([hoxyq](https://github.com/hoxyq) in
[#30826](https://github.com/facebook/react/pull/30826))
* fix[react-devtools/extensions]: fixed tabs API calls and displaying
restricted access popup ([hoxyq](https://github.com/hoxyq) in
[#30825](https://github.com/facebook/react/pull/30825))
* feat[react-devtools]: support Manifest v3 for Firefox extension
([hoxyq](https://github.com/hoxyq) in
[#30824](https://github.com/facebook/react/pull/30824))
* Reconcile Fibers Against Previous Children Instances
([sebmarkbage](https://github.com/sebmarkbage) in
[#30822](https://github.com/facebook/react/pull/30822))
* Remove findCurrentFiberUsingSlowPathByFiberInstance
([sebmarkbage](https://github.com/sebmarkbage) in
[#30818](https://github.com/facebook/react/pull/30818))
* Track Tree Base Duration of Virtual Instances
([sebmarkbage](https://github.com/sebmarkbage) in
[#30817](https://github.com/facebook/react/pull/30817))
* Use Owner Stacks to Implement View Source of a Server Component
([sebmarkbage](https://github.com/sebmarkbage) in
[#30798](https://github.com/facebook/react/pull/30798))
* Make function inspection instant
([sebmarkbage](https://github.com/sebmarkbage) in
[#30786](https://github.com/facebook/react/pull/30786))
* Make Functions Clickable to Jump to Definition
([sebmarkbage](https://github.com/sebmarkbage) in
[#30769](https://github.com/facebook/react/pull/30769))
* Support REACT_LEGACY_ELEMENT_TYPE for formatting JSX
([sebmarkbage](https://github.com/sebmarkbage) in
[#30779](https://github.com/facebook/react/pull/30779))
* Find owners from the parent path that matches the Fiber or
ReactComponentInfo ([sebmarkbage](https://github.com/sebmarkbage) in
[#30717](https://github.com/facebook/react/pull/30717))
* [Flight/DevTools] Pass the Server Component's "key" as Part of the
ReactComponentInfo ([sebmarkbage](https://github.com/sebmarkbage) in
[#30703](https://github.com/facebook/react/pull/30703))
* Hide props section if it is null
([sebmarkbage](https://github.com/sebmarkbage) in
[#30696](https://github.com/facebook/react/pull/30696))
* Support Server Components in Tree
([sebmarkbage](https://github.com/sebmarkbage) in
[#30684](https://github.com/facebook/react/pull/30684))
* fix[react-devtools/InspectedElement]: fixed border stylings when some
of the panels are not rendered ([hoxyq](https://github.com/hoxyq) in
[#30676](https://github.com/facebook/react/pull/30676))
* Compute new reordered child set from the instance tree
([sebmarkbage](https://github.com/sebmarkbage) in
[#30668](https://github.com/facebook/react/pull/30668))
* Unmount instance by walking the instance tree instead of the fiber
tree ([sebmarkbage](https://github.com/sebmarkbage) in
[#30665](https://github.com/facebook/react/pull/30665))
* Further Refactoring of Unmounts
([sebmarkbage](https://github.com/sebmarkbage) in
[#30658](https://github.com/facebook/react/pull/30658))
* Remove lodash.throttle ([sebmarkbage](https://github.com/sebmarkbage)
in [#30657](https://github.com/facebook/react/pull/30657))
* Unmount by walking previous nodes no longer in the new tree
([sebmarkbage](https://github.com/sebmarkbage) in
[#30644](https://github.com/facebook/react/pull/30644))
* Build up DevTools Instance Shadow Tree
([sebmarkbage](https://github.com/sebmarkbage) in
[#30625](https://github.com/facebook/react/pull/30625))
* chore[packages/react-devtools]: remove unused index.js
([hoxyq](https://github.com/hoxyq) in
[#30579](https://github.com/facebook/react/pull/30579))
* Track DOM nodes to Fiber map for HostHoistable Resources
([sebmarkbage](https://github.com/sebmarkbage) in
[#30590](https://github.com/facebook/react/pull/30590))
* Rename mountFiberRecursively/updateFiberRecursively
([sebmarkbage](https://github.com/sebmarkbage) in
[#30586](https://github.com/facebook/react/pull/30586))
* Allow Highlighting/Inspect HostSingletons/Hoistables and Resources
([sebmarkbage](https://github.com/sebmarkbage) in
[#30584](https://github.com/facebook/react/pull/30584))
* chore[react-devtools]: add global for native and use it to fork
backend implementation ([hoxyq](https://github.com/hoxyq) in
[#30533](https://github.com/facebook/react/pull/30533))
* Enable pointEvents while scrolling
([sebmarkbage](https://github.com/sebmarkbage) in
[#30560](https://github.com/facebook/react/pull/30560))
* Make Element Inspection Feel Snappy
([sebmarkbage](https://github.com/sebmarkbage) in
[#30555](https://github.com/facebook/react/pull/30555))
* Track the parent DevToolsInstance while mounting a tree
([sebmarkbage](https://github.com/sebmarkbage) in
[#30542](https://github.com/facebook/react/pull/30542))
* Add DevToolsInstance to Store Stateful Information
([sebmarkbage](https://github.com/sebmarkbage) in
[#30517](https://github.com/facebook/react/pull/30517))
* Implement "best renderer" by taking the inner most matched node
([sebmarkbage](https://github.com/sebmarkbage) in
[#30494](https://github.com/facebook/react/pull/30494))
* Rename NativeElement to HostInstance in the Bridge
([sebmarkbage](https://github.com/sebmarkbage) in
[#30491](https://github.com/facebook/react/pull/30491))
* Rename Fiber to Element in the Bridge Protocol and RendererInterface
([sebmarkbage](https://github.com/sebmarkbage) in
[#30490](https://github.com/facebook/react/pull/30490))
* Stop filtering owner stacks
([sebmarkbage](https://github.com/sebmarkbage) in
[#30438](https://github.com/facebook/react/pull/30438))
* [Fiber] Call life-cycles with a react-stack-bottom-frame stack frame
([sebmarkbage](https://github.com/sebmarkbage) in
[#30429](https://github.com/facebook/react/pull/30429))
* [Flight] Prefix owner stacks added to the console.log with the current
stack ([sebmarkbage](https://github.com/sebmarkbage) in
[#30427](https://github.com/facebook/react/pull/30427))
* [BE] switch to hermes parser for prettier
([kassens](https://github.com/kassens) in
[#30421](https://github.com/facebook/react/pull/30421))
* Implement Owner Stacks ([sebmarkbage](https://github.com/sebmarkbage)
in [#30417](https://github.com/facebook/react/pull/30417))
* [BE] upgrade prettier to 3.3.3 ([kassens](https://github.com/kassens)
in [#30420](https://github.com/facebook/react/pull/30420))
* [ci] Add yarn_test_build job to gh actions
* [Fizz] Refactor Component Stack Nodes
([sebmarkbage](https://github.com/sebmarkbage) in
[#30298](https://github.com/facebook/react/pull/30298))
* Print component stacks as error objects to get source mapping
([sebmarkbage](https://github.com/sebmarkbage) in
[#30289](https://github.com/facebook/react/pull/30289))
* Upgrade flow to 0.235.0 ([kassens](https://github.com/kassens) in
[#30118](https://github.com/facebook/react/pull/30118))
* fix: path handling in react devtools
([Jack-Works](https://github.com/Jack-Works) in
[#29199](https://github.com/facebook/react/pull/29199))
2024-09-25 14:38:34 +01:00
Ruslan Lesiutin
c21ce4a396 feat: display message if user ended up opening hook script (#31000)
In https://github.com/facebook/react/pull/30596 we've moved console
patching to the global hook. Generally speaking, the patching happens
even before React is loaded on the page.

If browser DevTools were opened after when `console.error` or
`console.warn` were called, the source script will be `hook.js`, because
of the patching.

![devtools-opened-after-the-message](https://github.com/user-attachments/assets/3d3dbc16-96b8-4234-b061-57b21b60cf2e)

This is because ignore listing is not applied retroactively by Chrome
DevTools.
If you had it open before console calls, Hook script would be correctly
filtered out from the stack:

![devtools-opened-before-the-message](https://github.com/user-attachments/assets/3e99cb22-97b0-4b49-9a76-f7bc948e6452)

I had hopes that the fix for
https://issues.chromium.org/issues/345248263 will also apply ignore
listing retroactively, but looks like we need to open a separate feature
request for the Chrome DevTools team.

With these changes, if user attempts to open `hook.js` script, they are
going to see this message:
![Screenshot 2024-09-19 at 11 30
59](https://github.com/user-attachments/assets/5850b74c-329f-4fbe-a3dd-33f9ac717ee9)
2024-09-19 15:44:34 +01:00
Ruslan Lesiutin
f37c7bc653 feat[react-devtools/extension]: use chrome.storage to persist settings across sessions (#30636)
Stacked on https://github.com/facebook/react/pull/30610 and whats under
it. See [last
commit](248ddba186).

Now, we are using
[`chrome.storage`](https://developer.chrome.com/docs/extensions/reference/api/storage)
to persist settings for the browser extension across different sessions.
Once settings are updated from the UI, the `Store` will emit
`settingsUpdated` event, and we are going to persist them via
`chrome.storage.local.set` in `main/index.js`.

When hook is being injected, we are going to pass a `Promise`, which is
going to be resolved after the settings are read from the storage via
`chrome.storage.local.get` in `hookSettingsInjector.js`.
2024-09-18 18:26:39 +01:00
Ruslan Lesiutin
b521ef8a2a refactor[react-devtools]: remove browserTheme from ConsolePatchSettings (#30566)
Stacked on https://github.com/facebook/react/pull/30564.

We are no longer using browser theme in our console patching, this was
removed in unification of console patching for strict mode, we started
using ansi escape symbols and forking based on browser theme is no
longer required - https://github.com/facebook/react/pull/29869

The real browser theme initialization for frontend is happening at the
other place and is not affected:

40be968257/packages/react-devtools-shared/src/devtools/views/Settings/SettingsContext.js (L117-L120)
2024-09-18 18:02:13 +01:00
Ruslan Lesiutin
bb6b86ed59 refactor[react-devtools]: initialize renderer interface early (#30946)
The current state is that `rendererInterface`, which contains all the
backend logic, like generating component stack or attaching errors to
fibers, or traversing the Fiber tree, ..., is only mounted after the
Frontend is created.

For browser extension, this means that we don't patch console or track
errors and warnings before Chrome DevTools is opened.

With these changes, `rendererInterface` is created right after
`renderer` is injected from React via global hook object (e. g.
`__REACT_DEVTOOLS_GLOBAL_HOOK__.inject(...)`.

Because of the current implementation, in case of multiple Reacts on the
page, all of them will patch the console independently. This will be
fixed in one of the next PRs, where I am moving console patching to the
global Hook.

This change of course makes `hook.js` script bigger, but I think it is a
reasonable trade-off for better DevX. We later can add more heuristics
to optimize the performance (if necessary) of `rendererInterface` for
cases when Frontend was connected late and Backend is attempting to
flush out too many recorded operations.

This essentially reverts https://github.com/facebook/react/pull/26563.
2024-09-12 13:59:29 +01:00
Sebastian Markbåge
d160aa0fbb [DevTools] Use Unicode Atom Symbol instead of Atom Emoji (#30832)
This reverts #19603.

Before:
<img width="724" alt="Screenshot 2024-08-28 at 12 07 29 AM"
src="https://github.com/user-attachments/assets/0613088f-c013-4f1c-92c3-fbdae8c1f109">

After:
<img width="771" alt="Screenshot 2024-08-28 at 12 08 13 AM"
src="https://github.com/user-attachments/assets/eef21bee-d11f-4f0a-9147-053a163f720f">

Consensus seems to be that while the purple on is a bit clearer and
easier to read. The purple is not on brand so it doesn't look like
React. It looks ugly. It's distracting (too eye catching). Taking away
attention from other tabs in an unfair way.

It also gets worse with more tabs added. We plan on both adding another
tab and panes inside other tabs (elements/sources) soon. Each needs to
be marked somehow as part of React but spelling it out is too long.
Putting inside a second tab means two clicks and takes away real-estate
from our extension and doesn't solve the problem with extension panes in
other tabs. We also plan on adding multiple different tracks to the
Performance tab which also needs a name other than just React and
spelling out React as a prefix is too long. The Emoji is too
distracting. So it seems best to uniformly apply the symbol - albeit it
might just look like a dot to many.

Dark mode looks close to on brand:

<img width="1089" alt="Screenshot 2024-08-28 at 12 32 50 AM"
src="https://github.com/user-attachments/assets/7175a540-4241-4c26-9e4d-4d367873af57">
2024-09-10 00:09:42 -04:00
Ruslan Lesiutin
a19a8ab44f chore[react-devtools/hook]: remove unused native values (#30827)
Stacked on https://github.com/facebook/react/pull/30826. See [this
commit](ec0e48ed7a).

This is unused.
2024-08-29 11:34:31 +01:00
Ruslan Lesiutin
233d63c497 chore[react-devtools/extensions]: remove unused storage permission (#30826)
Stacked on https://github.com/facebook/react/pull/30825. See [this
commit](b2130701cf).

We are not using `storage` anywhere yet, but will be soon. This
permission is not needed.
2024-08-29 11:32:18 +01:00
Ruslan Lesiutin
795b3207ce fix[react-devtools/extensions]: fixed tabs API calls and displaying restricted access popup (#30825)
Stacked on https://github.com/facebook/react/pull/30824. See [this
commit](c9830d6474).

Turns out we should be listing `tabs` in our permissions, if we want to
be able to receive tab url, once its updated.
This also fixes `chrome.tabs.onCreated` event subscription, because [it
should receive only tab
object](https://developer.chrome.com/docs/extensions/reference/api/tabs#event-onCreated),
and not 3 arguments, as expected in the previous implementation.
2024-08-29 11:31:43 +01:00
Ruslan Lesiutin
537c74e16a feat[react-devtools]: support Manifest v3 for Firefox extension (#30824)
Firefox [finally supports
`ExecutionWorld.MAIN`](https://bugzilla.mozilla.org/show_bug.cgi?id=1736575)
in content scripts, which means we can migrate the browser extension to
Manifest V3.

This PR also removes a bunch of no longer required explicit branching
for Firefox case, when we are using Manifest V3-only APIs.

We are also removing XMLHttpRequest injection, which is no longer needed
and restricted in Manifest V3. The new standardized approach (same as in
Chromium) doesn't violate CSP rules, which means that extension can
finally be used for apps running in production mode.
2024-08-29 11:28:35 +01:00
Sebastian Markbåge
f65ac7bd4a [DevTools] Make function inspection instant (#30786)
I noticed that there is a delay due to the inspection being split into
one part that gets the attribute and another eval that does the
inspection. This is a bit hacky and uses temporary global names that are
leaky. The timeout was presumably to ensure that the first step had
fully propagated but it's slow. As we've learned, it can be throttled,
and it isn't a guarantee either way.

Instead, we can just consolidate these into a single operation that
by-passes the bridge and goes straight to the renderer interface from
the eval.

I did the same for the viewElementSource helper even though that's not
currently in use since #28471 but I think we probably should return to
that technique when it's available since it's more reliable than the
throw - at least in Chrome. I'm not sure about the status of React
Native here. In Firefox, inspecting a function with source maps doesn't
seem to work. It doesn't jump to original code.
2024-08-26 11:53:17 -04:00
Ruslan Lesiutin
8269d55d23 chore[react-devtools]: add global for native and use it to fork backend implementation (#30533)
Adding `__IS_NATIVE__` global, which will be used for forking backend
implementation. Will only be set to `true` for `react-devtools-core`
package, which is used by `react-native`.

Ideally, we should name it `react-devtools-native`, and keep
`react-devtools-core` as host-agnostic.

With this change, the next release of `react-devtools-core` should
append component stack as Error object, not as string, and should add
`(<anonymous>)` suffix to component stack frames.
2024-08-02 10:51:15 +01:00
Sebastian Markbåge
33e54fa252 [DevTools] Rename NativeElement to HostInstance in the Bridge (#30491)
Stacked on #30490.

This is in the same spirit but to clarify the difference between what is
React Native vs part of any generic Host. We used to use "Native" to
mean three different concepts. Now "Native" just means React Native.

E.g. from the frontend's perspective the Host can be
Highlighted/Inspected. However, that in turn can then be implemented as
either direct DOM manipulation or commands to React Native. So frontend
-> backend is "Host" but backend -> React Native is "Native" while
backend -> DOM is "Web".

Rename NativeElementsPanel to BuiltinElementsPanel. This isn't a React
Native panel but one part of the surrounding DevTools. We refer to Host
more as the thing running React itself. I.e. where the backend lives.
The runtime you're inspecting. The DevTools itself needs a third term.
So I went with "Builtin".
2024-07-30 09:12:12 -04:00
Sebastian Markbåge
ec98d36c3a [DevTools] Rename Fiber to Element in the Bridge Protocol and RendererInterface (#30490)
I need to start clarifying where things are really actually Fibers and
where they're not since I'm adding Server Components as a separate type
of component instance which is not backed by a Fiber.

Nothing in the front end should really know anything about what kind of
renderer implementation we're inspecting and indeed it's already not
always a "Fiber" in the legacy renderer.

We typically refer to this as a "Component Instance" but the front end
currently refers to it as an Element as it historically grew from the
browser DevTools Elements tab.

I also moved the renderer.js implementation into the `backend/fiber`
folder. These are at the same level as `backend/legacy`. This clarifies
that anything outside of this folder ideally shouldn't refer to a
"Fiber".

console.js and profilingHooks.js unfortunately use Fibers a lot which
needs further refactoring. The profiler frontend also uses the term
alot.
2024-07-29 14:29:52 -04:00
Sebastian Markbåge
43dac1ee8d [DevTools] Implement Owner Stacks (#30417)
Stacked on #30410.

Use "owner stacks" as the appended component stack if it is available on
the Fiber. This will only be available if the enableOwnerStacks flag is
on. Otherwise it fallback to parent stacks. In prod, there's no owner so
it's never added there.

I was going back and forth on whether to inject essentially
`captureOwnerStack` as part of the DevTools hooks or replicate the
implementation but decided to replicate the implementation.

The DevTools needs all the same information from internals to implement
owner views elsewhere in the UI anyway so we're not saving anything in
terms of the scope of internals. Additionally, we really need this
information for non-current components as well like "rendered by" views
of the currently selected component.

It can also be useful if we need to change the format after the fact
like we did for parent stacks in:
https://github.com/facebook/react/pull/30289

Injecting the implementation would lock us into specifics both in terms
of what the core needs to provide and what the DevTools can use.

The implementation depends on the technique used in #30369 which tags
frames to strip out with `react-stack-bottom-frame`. That's how the
implementation knows how to materialize the error if it hasn't already.

Firefox:

<img width="487" alt="Screenshot 2024-07-21 at 11 33 37 PM"
src="https://github.com/user-attachments/assets/d3539b53-4578-4fdd-af25-25698b2bcc7d">

Follow up: One thing about this view is that it doesn't include the
current actual synchronous stack. When I used to append these I would
include both the real current stack and the owner stack. That's because
the owner stack doesn't include the name of the currently executing
component. I'll probably inject the current stack too in addition to the
owner stack. This is similar to how native Async Stacks are basically
just appended onto the current stack rather than its own.
2024-07-22 18:49:44 -04:00
Ruslan Lesiutin
572ded3762 React DevTools 5.3.0 -> 5.3.1 (#30199)
## Summary

Full list of changes, mostly fixes:
* chore[react-devtools/renderer]: dont show strict mode warning for prod
renderer builds ([hoxyq](https://github.com/hoxyq) in
[#30158](https://github.com/facebook/react/pull/30158))
* chore[react-devtools/ui]: fix strict mode badge styles
([hoxyq](https://github.com/hoxyq) in
[#30159](https://github.com/facebook/react/pull/30159))
* fix[react-devtools]: restore original args when recording errors
([hoxyq](https://github.com/hoxyq) in
[#30091](https://github.com/facebook/react/pull/30091))
* Read constructor name more carefully
([LoganDark](https://github.com/LoganDark) in
[#29954](https://github.com/facebook/react/pull/29954))
* refactor[react-devtools/extensions]: dont debounce cleanup logic on
navigation ([hoxyq](https://github.com/hoxyq) in
[#30027](https://github.com/facebook/react/pull/30027))
* lint: enable reportUnusedDisableDirectives and remove unused
suppressions ([kassens](https://github.com/kassens) in
[#28721](https://github.com/facebook/react/pull/28721))
* fix[react-devtools/extensions]: propagate globals from env
([hoxyq](https://github.com/hoxyq) in
[#29963](https://github.com/facebook/react/pull/29963))
* refactor[react-devtools/tests]: use registered marks instead of
cleared in tests ([hoxyq](https://github.com/hoxyq) in
[#29929](https://github.com/facebook/react/pull/29929))
2024-07-03 11:46:46 +01:00
Ruslan Lesiutin
7608516479 refactor[react-devtools/extensions]: dont debounce cleanup logic on navigation (#30027)
## Summary
There is a race condition in the way we poll if React is on the page and
when we actually clear this polling instance. When user navigates to a
different page, we will debounce a callback for 500ms, which will:
1. Cleanup previous React polling instance
2. Start a new React polling instance

Since the cleanup logic is debounced, there is a small chance that by
the time we are going to clean up this polling instance, it will be
`eval`-ed on the page, that is using React. For example, when user is
navigating from the page which doesn't have React running, to a page
that has React running.

Next, we incorrectly will try to mount React DevTools panels twice,
which will result into conflicts in the Store, and the error will be
shown to the user

## How did you test this change?
Since this is a race condition, it is hard to reproduce consistently,
but you can try this flow:
1. Open a page that is using React, open browser DevTools and React
DevTools components panel
2. Open a page that is NOT using React, like google.com, wait ~5 seconds
until you see `"Looks like this page doesn't have React, or it hasn't
been loaded yet"` message in RDT panel
3. Open a page that is using React, observe the error `"Uncaught Error:
Cannot add node "1" because a node with that id is already in the
Store."`

Couldn't been able to reproduce this with these changes.
2024-06-24 13:28:17 +01:00
Jan Kassens
b565373afd lint: enable reportUnusedDisableDirectives and remove unused suppressions (#28721)
This enables linting against unused suppressions and removes the ones
that were unused.
2024-06-21 12:24:32 -04:00
Ruslan Lesiutin
b15c8492ca fix[react-devtools/extensions]: propagate globals from env (#29963)
Somehow missed this while working on
https://github.com/facebook/react/pull/29869.

With these changes, manual inspection of the
`react_devtools_backend_compact.js` doesn't have any occurences of
`__IS_FIREFOX__` flag.
2024-06-20 09:29:05 +01:00
Ruslan Lesiutin
1434af3d22 React DevTools 5.2.0 -> 5.3.0 (#29918)
Full list of changes:

* chore[react-devtools]: improve console arguments formatting before
passing it to original console ([hoxyq](https://github.com/hoxyq) in
[#29873](https://github.com/facebook/react/pull/29873))
* chore[react-devtools]: unify console patching and default to ansi
escape symbols ([hoxyq](https://github.com/hoxyq) in
[#29869](https://github.com/facebook/react/pull/29869))
* chore[react-devtools/backend]: remove
consoleManagedByDevToolsDuringStrictMode
([hoxyq](https://github.com/hoxyq) in
[#29856](https://github.com/facebook/react/pull/29856))
* chore[react-devtools/extensions]: make source maps url relative
([hoxyq](https://github.com/hoxyq) in
[#29886](https://github.com/facebook/react/pull/29886))
* fix[react-devtools] divided inspecting elements between inspecting do…
([vzaidman](https://github.com/vzaidman) in
[#29885](https://github.com/facebook/react/pull/29885))
* [Fiber] Create virtual Fiber when an error occurs during reconcilation
([sebmarkbage](https://github.com/sebmarkbage) in
[#29804](https://github.com/facebook/react/pull/29804))
* fix[react-devtools] component badge in light mode is now not invisible
([vzaidman](https://github.com/vzaidman) in
[#29852](https://github.com/facebook/react/pull/29852))
* Remove Warning: prefix and toString on console Arguments
([sebmarkbage](https://github.com/sebmarkbage) in
[#29839](https://github.com/facebook/react/pull/29839))
* Add jest lint rules ([rickhanlonii](https://github.com/rickhanlonii)
in [#29760](https://github.com/facebook/react/pull/29760))
* [Fiber] Track the Real Fiber for Key Warnings
([sebmarkbage](https://github.com/sebmarkbage) in
[#29791](https://github.com/facebook/react/pull/29791))
* fix[react-devtools/store-test]: fork the test to represent current be…
([hoxyq](https://github.com/hoxyq) in
[#29777](https://github.com/facebook/react/pull/29777))
* Default native inspections config false
([vzaidman](https://github.com/vzaidman) in
[#29784](https://github.com/facebook/react/pull/29784))
* fix[react-devtools] remove native inspection button when it can't be
used ([vzaidman](https://github.com/vzaidman) in
[#29779](https://github.com/facebook/react/pull/29779))
* chore[react-devtools]: ip => internal-ip
([hoxyq](https://github.com/hoxyq) in
[#29772](https://github.com/facebook/react/pull/29772))
* Fix #29724: `ip` dependency update for CVE-2024-29415
([Rekl0w](https://github.com/Rekl0w) in
[#29725](https://github.com/facebook/react/pull/29725))
* cleanup[react-devtools]: remove unused supportsProfiling flag from
store config ([hoxyq](https://github.com/hoxyq) in
[#29193](https://github.com/facebook/react/pull/29193))
* [Fiber] Enable Native console.createTask Stacks When Available
([sebmarkbage](https://github.com/sebmarkbage) in
[#29223](https://github.com/facebook/react/pull/29223))
* Move createElement/JSX Warnings into the Renderer
([sebmarkbage](https://github.com/sebmarkbage) in
[#29088](https://github.com/facebook/react/pull/29088))
* Set the current fiber to the source of the error during error
reporting ([sebmarkbage](https://github.com/sebmarkbage) in
[#29044](https://github.com/facebook/react/pull/29044))
* Unify ReactFiberCurrentOwner and ReactCurrentFiber
([sebmarkbage](https://github.com/sebmarkbage) in
[#29038](https://github.com/facebook/react/pull/29038))
* Dim `console` calls on additional Effect invocations due to
`StrictMode` ([eps1lon](https://github.com/eps1lon) in
[#29007](https://github.com/facebook/react/pull/29007))
* refactor[react-devtools]: rewrite context menus
([hoxyq](https://github.com/hoxyq) in
[#29049](https://github.com/facebook/react/pull/29049))
2024-06-18 12:12:27 +01:00
Ruslan Lesiutin
ff6e05a705 chore[react-devtools]: unify console patching and default to ansi escape symbols (#29869)
Stacked on https://github.com/facebook/react/pull/29856.

## Summary

By default, React DevTools will apply dimming with ANSI escape symbols,
so it works for both terminals and browser consoles.

For Firefox, which doesn't support ANSI escape symbols console stylings,
we fallback to css properties, like we used to do before.

## How did you test this change?

| Environment | Dark mode | Light mode |
|--------|--------|--------|
| Terminal | ![Screenshot 2024-06-12 at 19 39
46](https://github.com/facebook/react/assets/28902667/2d470eee-ec5f-4362-be7d-8d80c6c72d09)
| ![Screenshot 2024-06-12 at 19 39
09](https://github.com/facebook/react/assets/28902667/616f2c58-a251-406b-aee6-841e07d652ba)
|
| Fusebox&nbsp;console | ![Screenshot 2024-06-12 at 21 03
14](https://github.com/facebook/react/assets/28902667/6050f730-8e82-4aa1-acbc-7179aac3a8aa)
| ![Screenshot 2024-06-12 at 21 02
48](https://github.com/facebook/react/assets/28902667/6708b938-8a90-476f-a057-427963d58caa)
|
| Firefox&nbsp;console | ![Screenshot 2024-06-12 at 21 40
29](https://github.com/facebook/react/assets/28902667/4721084f-bbfa-438c-b61b-395da8ded590)
| ![Screenshot 2024-06-12 at 21 40
42](https://github.com/facebook/react/assets/28902667/72bbf001-2d3d-49e7-91c9-20a4f0914d4d)
|
| Chrome&nbsp;console | ![Screenshot 2024-06-12 at 21 43
09](https://github.com/facebook/react/assets/28902667/93c47881-a0dd-44f8-8dc2-8710149774e5)
| ![Screenshot 2024-06-12 at 21 43
00](https://github.com/facebook/react/assets/28902667/07ea4ff5-4322-4db9-9c12-4321d9577c9d)
|
2024-06-17 16:31:36 +01:00
Ruslan Lesiutin
d7bb6039de chore[react-devtools/extensions]: make source maps url relative (#29886)
This adds few changes:
1. We are going to ship source maps only for 2 artifacts:
`installHook.js` and `react_devtools_backend_compact.js`, because it is
only these modules that can patch console and be visible to the user via
stack traces in console. We need to ship source maps to be able to use
`ignoreList` feature in source maps, so we can actually hide these from
stack traces.

| Before | After |
|--------|--------|
| ![Screenshot 2024-06-13 at 17 44
25](https://github.com/facebook/react/assets/28902667/464e097b-a95e-47eb-967c-0579daad316b)
| ![Screenshot 2024-06-13 at 17 39
53](https://github.com/facebook/react/assets/28902667/e4afe642-d65b-4296-a2cf-26c0b925ebf2)
|
 
2. The `"sources"` field in source map will have relative urls listed,
instead of absolute with `webpack://` protocol. This will move the
sources to the `React Developer Tools` frame in `Sources` panel, instead
of `webpack://`.
 
 | Before | After |
|--------|--------|
| ![Screenshot 2024-06-13 at 17 48
24](https://github.com/facebook/react/assets/28902667/a18edad2-5b4e-4ad7-8a7a-8b389c2edf92)
| ![Screenshot 2024-06-13 at 17 49
41](https://github.com/facebook/react/assets/28902667/5db491f7-5d1d-4155-9910-16ac4384d34e)
|

> [!NOTE]  
> I still have 1 unresolved issue with shipping source maps in extension
build, and it is related to Firefox, which can't find them in the
extension bundle and returns 404, even though urls are relative and I
can actually open them via unique address like
`moz-extension://<extension-id>/build/intallHook.js.map` ¯\\\_(ツ)\_/¯
2024-06-17 11:58:19 +01:00
Vitali Zaidman
d9a5b6393a fix[react-devtools] divided inspecting elements between inspecting do… (#29885)
# **before**
* nav to dom element from devtools
* nav to devtools element from page
are enabled on extension and disabled on the rest of the flavors.

## extension:
* nav to dom element from devtools **enabled** and working
* nav to devtools element from page **enabled** and working
![Screenshot 2024-06-13 at 11 15
11](https://github.com/facebook/react/assets/5188459/fef78b70-d22c-4405-8871-8b0449b51937)

## inline:
* nav to dom element from devtools **disabled**
* nav to devtools element from page **disabled**

![before-inline](https://github.com/facebook/react/assets/5188459/24020dc2-baec-4d0a-84d4-45c96d653843)

## standalone:
* nav to dom element from devtools **disabled**
* nav to devtools element from page **disabled**

![before-standalone](https://github.com/facebook/react/assets/5188459/19b4cb34-9d1f-412e-baea-59ea85f99d04)

## fusebox:
* nav to dom element from devtools **disabled**
* nav to devtools element from page **disabled**

![before-fusebox](https://github.com/facebook/react/assets/5188459/1a18fda4-04b8-40f4-ae8b-e059889fca93)

# **after**
same:
* nav to dom element from devtools
* nav to devtools element from page
are enabled on extension and disabled on inline.

change:
standalone and fusebox can nav to devtools element from page

## extension:
* nav to dom element from devtools **enabled** and working
* nav to devtools element from page **enabled** and working
![Screenshot 2024-06-13 at 10 50
25](https://github.com/facebook/react/assets/5188459/f4679c72-b211-43d6-b3ea-6380e0d1edf0)

## inline:
* nav to dom element from devtools **disabled**
* nav to devtools element from page **disabled**

![after-inline](https://github.com/facebook/react/assets/5188459/fdfdd87b-9bc3-47f3-b1e0-730239f6485d)

## standalone:
* nav to dom element from devtools **disabled**
* nav to devtools element from page **enabled** and working

![after-standalone](https://github.com/facebook/react/assets/5188459/b25e3c63-a697-4b0c-8ad2-0e12ec5c3e9c)

## fusebox:
* nav to dom element from devtools **disabled**
* nav to devtools element from page **enabled** and working

![after-fusebox](https://github.com/facebook/react/assets/5188459/f14147d8-9831-4909-a164-52f892c875e5)
2024-06-13 15:37:51 +01:00
Vitali Zaidman
fd6e130b00 Default native inspections config false (#29784)
## Summary

To make the config `supportsNativeInspection` explicit, set it to
default to `false` and only allow it in the extension.

## How did you test this change?
When disabled on **React DevTools extension**
<img width="419" alt="Screenshot 2024-06-06 at 17 34 02"
src="https://github.com/facebook/react/assets/5188459/0052b645-2214-475c-8b41-4f9207ca3343">

When enabled on **React DevTools extension** (the chosen config)
<img width="425" alt="Screenshot 2024-06-06 at 17 34 53"
src="https://github.com/facebook/react/assets/5188459/df34ec8e-2039-4984-86c8-74feaf89bbdd">

When enabled on **React DevTools in Fusebox**
<img width="1170" alt="Screenshot 2024-06-06 at 17 29 24"
src="https://github.com/facebook/react/assets/5188459/ae52274b-583d-463c-8482-2323d502f4c0">

When disabled on **React DevTools in Fusebox** (the chosen config)
<img width="1453" alt="Screenshot 2024-06-06 at 17 30 31"
src="https://github.com/facebook/react/assets/5188459/cba5b51b-c973-412d-8ad0-382a4f9bf115">

When enabled on **React DevTools Inline**
<img width="915" alt="Screenshot 2024-06-06 at 17 24 20"
src="https://github.com/facebook/react/assets/5188459/f0d61d99-2b75-4a87-a19e-db431be697e3">

When disabled on **React DevTools Inline** (the chosen config)
<img width="844" alt="Screenshot 2024-06-06 at 17 19 39"
src="https://github.com/facebook/react/assets/5188459/d3bcc8a7-535d-4656-844d-f9f89bb2b248">

When enabled on **React DevTools standalone**
<img width="1227" alt="Screenshot 2024-06-06 at 17 23 16"
src="https://github.com/facebook/react/assets/5188459/174fbae6-1412-4539-bbe6-e1d0e8baa7d5">

When disabled on **React DevTools standalone** (the chosen config)
<img width="844" alt="Screenshot 2024-06-06 at 17 19 39"
src="https://github.com/facebook/react/assets/5188459/00c46907-e3a6-4766-a1b4-dd088cac2157">
2024-06-06 17:48:44 +01:00
Ruslan Lesiutin
6f23540c7d cleanup[react-devtools]: remove unused supportsProfiling flag from store config (#29193)
Looks like this is unused
2024-05-28 11:07:31 +01:00
Ruslan Lesiutin
1717ab0171 React DevTools 5.1.0 -> 5.2.0 (#29022)
Full list of changes (not a public changelog):
* fix[react-devtools/ci]: fix configurations for e2e testing
([hoxyq](https://github.com/hoxyq) in
[#29016](https://github.com/facebook/react/pull/29016))
* feat[react-devtools]: display forget badge for components in profiling
session ([hoxyq](https://github.com/hoxyq) in
[#29014](https://github.com/facebook/react/pull/29014))
* fix[react-devtools]: add backwards compat with legacy element type
symbol ([hoxyq](https://github.com/hoxyq) in
[#28982](https://github.com/facebook/react/pull/28982))
* Expose "view source" options to Fusebox integration
([motiz88](https://github.com/motiz88) in
[#28973](https://github.com/facebook/react/pull/28973))
* Enable inspected element context menu in Fusebox
([motiz88](https://github.com/motiz88) in
[#28972](https://github.com/facebook/react/pull/28972))
* Check in `frontend.d.ts` for react-devtools-fusebox, include in build
output ([motiz88](https://github.com/motiz88) in
[#28970](https://github.com/facebook/react/pull/28970))
* Devtools: Fix build-for-devtools
([eps1lon](https://github.com/eps1lon) in
[#28976](https://github.com/facebook/react/pull/28976))
* Move useMemoCache hook to react/compiler-runtime
([kassens](https://github.com/kassens) in
[#28954](https://github.com/facebook/react/pull/28954))
* warn -> error for Test Renderer deprecation
([acdlite](https://github.com/acdlite) in
[#28904](https://github.com/facebook/react/pull/28904))
* [react-dom] move all client code to `react-dom/client`
([gnoff](https://github.com/gnoff) in
[#28271](https://github.com/facebook/react/pull/28271))
* Rename the react.element symbol to react.transitional.element
([sebmarkbage](https://github.com/sebmarkbage) in
[#28813](https://github.com/facebook/react/pull/28813))
* Rename Forget badge ([jbonta](https://github.com/jbonta) in
[#28858](https://github.com/facebook/react/pull/28858))
* Devtools: Add support for useFormStatus
([eps1lon](https://github.com/eps1lon) in
[#28413](https://github.com/facebook/react/pull/28413))
2024-05-08 13:26:14 +01:00
Sebastian Silbermann
14f71db6b6 Devtools: Fix build-for-devtools (#28976) 2024-05-02 21:58:51 +02:00
Ruslan Lesiutin
2d128ff041 React DevTools 5.0.2 -> 5.1.0 (#28840)
Full list of changes:
* Look for a ReactMemoCacheSentinel on state
([gsathya](https://github.com/gsathya) in
[#28831](https://github.com/facebook/react/pull/28831))
* Use use() in the Cache if available
([sebmarkbage](https://github.com/sebmarkbage) in
[#28793](https://github.com/facebook/react/pull/28793))
* feat[devtools-fusebox]: support theme option
([hoxyq](https://github.com/hoxyq) in
[#28832](https://github.com/facebook/react/pull/28832))
* feat[devtools]: add package for fusebox integration
([hoxyq](https://github.com/hoxyq) in
[#28553](https://github.com/facebook/react/pull/28553))
* feat[devtools]: add method for connecting backend with custom
messaging protocol ([hoxyq](https://github.com/hoxyq) in
[#28552](https://github.com/facebook/react/pull/28552))
* Rename SECRET INTERNALS to
`__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE`
([sebmarkbage](https://github.com/sebmarkbage) in
[#28789](https://github.com/facebook/react/pull/28789))
* Flatten ReactSharedInternals
([sebmarkbage](https://github.com/sebmarkbage) in
[#28783](https://github.com/facebook/react/pull/28783))
* feat[devtools]: ship source maps for content scripts and ignore list
installHook script ([hoxyq](https://github.com/hoxyq) in
[#28730](https://github.com/facebook/react/pull/28730))
* Track Owner for Server Components in DEV
([sebmarkbage](https://github.com/sebmarkbage) in
[#28753](https://github.com/facebook/react/pull/28753))
* Move ReactDOMLegacy implementation into RootFB
([sebmarkbage](https://github.com/sebmarkbage) in
[#28656](https://github.com/facebook/react/pull/28656))
* Reland #28672: Remove IndeterminateComponent
([gnoff](https://github.com/gnoff) in
[#28681](https://github.com/facebook/react/pull/28681))
* Remove reference to deleted <Cache> in un-linted file
([josephsavona](https://github.com/josephsavona) in
[#28715](https://github.com/facebook/react/pull/28715))
* [be] Remove unshipped experimental <Cache> element type
([josephsavona](https://github.com/josephsavona) in
[#28698](https://github.com/facebook/react/pull/28698))
* Revert "Remove module pattern function component support"
([rickhanlonii](https://github.com/rickhanlonii) in
[#28670](https://github.com/facebook/react/pull/28670))
* Remove module pattern function component support
([gnoff](https://github.com/gnoff) in
[#27742](https://github.com/facebook/react/pull/27742))
* [RTR] Enable warning flag ([jackpope](https://github.com/jackpope) in
[#28419](https://github.com/facebook/react/pull/28419))
* Update error messages ([rickhanlonii](https://github.com/rickhanlonii)
in [#28652](https://github.com/facebook/react/pull/28652))
* fix[devtools/ci]: split profiling cache test for different react
versions and toEqual checker ([hoxyq](https://github.com/hoxyq) in
[#28628](https://github.com/facebook/react/pull/28628))
* Guard against legacy context not being supported in DevTools fixture
([eps1lon](https://github.com/eps1lon) in
[#28596](https://github.com/facebook/react/pull/28596))
* Use `declare const` instead of `declare var`
([kassens](https://github.com/kassens) in
[#28599](https://github.com/facebook/react/pull/28599))
* Update isConcurrent RTR option usage
([jackpope](https://github.com/jackpope) in
[#28546](https://github.com/facebook/react/pull/28546))
* Disable legacy context ([kassens](https://github.com/kassens) in
[#27991](https://github.com/facebook/react/pull/27991))
* Remove invokeGuardedCallback and replay trick
([sebmarkbage](https://github.com/sebmarkbage) in
[#28515](https://github.com/facebook/react/pull/28515))
* Remove remaining usages of ReactTestUtils in tests unrelated to
`react-dom/test-util` ([eps1lon](https://github.com/eps1lon) in
[#28534](https://github.com/facebook/react/pull/28534))
* fix[devtools/e2e]: fixed source inspection in e2e tests
([hoxyq](https://github.com/hoxyq) in
[#28518](https://github.com/facebook/react/pull/28518))
* Devtools: Display actual pending state when inspecting `useTransition`
([eps1lon](https://github.com/eps1lon) in
[#28499](https://github.com/facebook/react/pull/28499))
2024-04-15 14:56:57 +01:00
Ruslan Lesiutin
6de7733e73 feat[devtools]: ship source maps for content scripts and ignore list installHook script (#28730)
## Summary

1. RDT browser extension's content scripts will now ship source maps
(without source in prod, to save some bundle size).
2. `installHook` content script will be ignore listed via `ignoreList`
field in the corresponding source map.
3. Previously, source map for backend file used `x_google_ignoreList`
naming, now `ignoreList`.

## How did you test this change?

1. `ignoreList-test.js`
2. Tested manually that I don't see `installHook` in stack traces when
`console.error` is called.
2024-04-08 18:10:09 +01:00
Jan Kassens
6708115937 Use declare const instead of declare var (#28599)
Use `declare const` instead of `declare var`
2024-03-22 11:20:18 -04:00
Ruslan Lesiutin
966d17483c React DevTools 5.0.1 -> 5.0.2 (#28496)
* feat[devtools]: symbolicate source for inspected element
([hoxyq](https://github.com/hoxyq) in
[#28471](https://github.com/facebook/react/pull/28471))
* refactor[devtools]: lazily define source for fiber based on component
stacks ([hoxyq](https://github.com/hoxyq) in
[#28351](https://github.com/facebook/react/pull/28351))
* fix[devtools/tree/element]: onClick -> onMouseDown to handle first
click correctly ([hoxyq](https://github.com/hoxyq) in
[#28486](https://github.com/facebook/react/pull/28486))
* [DOM] disable legacy mode behind flag
([gnoff](https://github.com/gnoff) in
[#28468](https://github.com/facebook/react/pull/28468))
* Fix Broken Links In Documentation
([justindhillon](https://github.com/justindhillon) in
[#28321](https://github.com/facebook/react/pull/28321))
* Update /link URLs to react.dev
([rickhanlonii](https://github.com/rickhanlonii) in
[#28477](https://github.com/facebook/react/pull/28477))
* [tests] add support for @gate pragma
([gnoff](https://github.com/gnoff) in
[#28479](https://github.com/facebook/react/pull/28479))
* Devtools: Unwrap Promise in useFormState
([eps1lon](https://github.com/eps1lon) in
[#28319](https://github.com/facebook/react/pull/28319))
* Add support for rendering BigInt
([eps1lon](https://github.com/eps1lon) in
[#24580](https://github.com/facebook/react/pull/24580))
* Include server component names in the componentStack in DEV
([sebmarkbage](https://github.com/sebmarkbage) in
[#28415](https://github.com/facebook/react/pull/28415))
2024-03-05 14:11:30 +00:00
Ruslan Lesiutin
e5287287aa feat[devtools]: symbolicate source for inspected element (#28471)
Stacked on https://github.com/facebook/react/pull/28351, please review
only the last commit.

Top-level description of the approach:
1. Once user selects an element from the tree, frontend asks backend to
return the inspected element, this is where we simulate an error
happening in `render` function of the component and then we parse the
error stack. As an improvement, we should probably migrate from custom
implementation of error stack parser to `error-stack-parser` from npm.
2. When frontend receives the inspected element and this object is being
propagated, we create a Promise for symbolicated source, which is then
passed down to all components, which are using `source`.
3. These components use `use` hook for this promise and are wrapped in
Suspense.

Caching:
1. For browser extension, we cache Promises based on requested resource
+ key + column, also added use of
`chrome.devtools.inspectedWindow.getResource` API.
2. For standalone case (RN), we cache based on requested resource url,
we cache the content of it.
2024-03-05 12:32:11 +00:00
Ruslan Lesiutin
288cf747c9 React DevTools 5.0.0 -> 5.0.1 (#28418)
Full list of changes (not a public CHANGELOG):

* feature[REMOVED][devtools]: turn off / hide location based component
filters ([hoxyq](https://github.com/hoxyq) in
[#28417](https://github.com/facebook/react/pull/28417))
* Add useSyncExternalStore and useTransition to getPrimitiveStackCache
([jamesbvaughan](https://github.com/jamesbvaughan) in
[#28399](https://github.com/facebook/react/pull/28399))
* chore[devtools]: use react-window from npm and bump
react-virtualized-auto-sizer to ^1.0.23
([hoxyq](https://github.com/hoxyq) in
[#28408](https://github.com/facebook/react/pull/28408))
* Pass ref as normal prop ([acdlite](https://github.com/acdlite) in
[#28348](https://github.com/facebook/react/pull/28348))
* Combine createElement and JSX modules
([acdlite](https://github.com/acdlite) in
[#28320](https://github.com/facebook/react/pull/28320))
* [Debug Tools] Always use includeHooksSource option
([sebmarkbage](https://github.com/sebmarkbage) in
[#28309](https://github.com/facebook/react/pull/28309))
* Revert "[Tests] Reset modules by default"
([acdlite](https://github.com/acdlite) in
[#28318](https://github.com/facebook/react/pull/28318))
* Switch <Context> to mean <Context.Provider>
([gaearon](https://github.com/gaearon) in
[#28226](https://github.com/facebook/react/pull/28226))
* [Debug Tools] Introspect Promises in use()
([sebmarkbage](https://github.com/sebmarkbage) in
[#28297](https://github.com/facebook/react/pull/28297))
* fix[devtools/useModalDismissSignal]: use getRootNode for shadow root
case support ([hoxyq](https://github.com/hoxyq) in
[#28145](https://github.com/facebook/react/pull/28145))
* fix: define IS_ACT_ENVIRONMENT global for tests with concurrent mode
and synchronous act ([hoxyq](https://github.com/hoxyq) in
[#28296](https://github.com/facebook/react/pull/28296))
* chore: gate legacy apis for react-devtools-shell
([hoxyq](https://github.com/hoxyq) in
[#28273](https://github.com/facebook/react/pull/28273))
* DevTools: Add support for use(Context)
([eps1lon](https://github.com/eps1lon) in
[#28233](https://github.com/facebook/react/pull/28233))
* Remove __self and __source location from elements
([sebmarkbage](https://github.com/sebmarkbage) in
[#28265](https://github.com/facebook/react/pull/28265))
* chore: use versioned render in inspectedElement test
([hoxyq](https://github.com/hoxyq) in
[#28246](https://github.com/facebook/react/pull/28246))
* chore: use versioned render in TimelineProfiler test and gate some for
legacy rendering ([hoxyq](https://github.com/hoxyq) in
[#28218](https://github.com/facebook/react/pull/28218))
* [Tests] Reset modules by default
([rickhanlonii](https://github.com/rickhanlonii) in
[#28254](https://github.com/facebook/react/pull/28254))
* chore: use versioned render in preprocessData test and gate some for …
([hoxyq](https://github.com/hoxyq) in
[#28219](https://github.com/facebook/react/pull/28219))
* chore: use versioned render in storeStressSync test and gate them for
legacy rendering ([hoxyq](https://github.com/hoxyq) in
[#28216](https://github.com/facebook/react/pull/28216))
* Patch devtools before running useMemo function in strict mode
([gsathya](https://github.com/gsathya) in
[#28249](https://github.com/facebook/react/pull/28249))
* chore: use versioned render in storeComponentFilters test
([hoxyq](https://github.com/hoxyq) in
[#28241](https://github.com/facebook/react/pull/28241))
* chore: use versioned render in profilerContext test
([hoxyq](https://github.com/hoxyq) in
[#28243](https://github.com/facebook/react/pull/28243))
* chore: use versioned render in profilingCommitTreeBuilder test and
gate some for legacy rendering ([hoxyq](https://github.com/hoxyq) in
[#28236](https://github.com/facebook/react/pull/28236))
* chore: use versioned render in profilingHostRoot test and gate some
for legacy rendering ([hoxyq](https://github.com/hoxyq) in
[#28237](https://github.com/facebook/react/pull/28237))
* chore: use versioned render in profilingCache test
([hoxyq](https://github.com/hoxyq) in
[#28242](https://github.com/facebook/react/pull/28242))
* chore: use versioned render in ownersListContext test
([hoxyq](https://github.com/hoxyq) in
[#28240](https://github.com/facebook/react/pull/28240))
* chore: use versioned render in editing test
([hoxyq](https://github.com/hoxyq) in
[#28239](https://github.com/facebook/react/pull/28239))
* chore: use versioned render in treeContext test
([hoxyq](https://github.com/hoxyq) in
[#28245](https://github.com/facebook/react/pull/28245))
* chore: use versioned render in store test
([hoxyq](https://github.com/hoxyq) in
[#28244](https://github.com/facebook/react/pull/28244))
* chore: use versioned render in profilerStore test
([hoxyq](https://github.com/hoxyq) in
[#28238](https://github.com/facebook/react/pull/28238))
* chore: use versioned render in profilingCharts test
([hoxyq](https://github.com/hoxyq) in
[#28235](https://github.com/facebook/react/pull/28235))
* chore: use versioned render in profilerChangeDescriptions test
([hoxyq](https://github.com/hoxyq) in
[#28221](https://github.com/facebook/react/pull/28221))
* chore: use versioned render in storeOwners test
([hoxyq](https://github.com/hoxyq) in
[#28215](https://github.com/facebook/react/pull/28215))
* chore: use versioned render in componentStacks test
([hoxyq](https://github.com/hoxyq) in
[#28214](https://github.com/facebook/react/pull/28214))
* chore: use versioned render in console test
([hoxyq](https://github.com/hoxyq) in
[#28213](https://github.com/facebook/react/pull/28213))
* chore: use versioned render in useEditableValue test
([hoxyq](https://github.com/hoxyq) in
[#28212](https://github.com/facebook/react/pull/28212))
* chore: use versioned render in FastRefreshDevToolsIntegration test
([hoxyq](https://github.com/hoxyq) in
[#28211](https://github.com/facebook/react/pull/28211))
* chore: add versioned render implementation for DevTools tests
([hoxyq](https://github.com/hoxyq) in
[#28210](https://github.com/facebook/react/pull/28210))
* chore: add single versioned implementation of act for DevTools tests
([hoxyq](https://github.com/hoxyq) in
[#28186](https://github.com/facebook/react/pull/28186))
* DevTools: Add support for useFormState
([eps1lon](https://github.com/eps1lon) in
[#28232](https://github.com/facebook/react/pull/28232))
* DevTools: Add support for useOptimistic Hook
([eps1lon](https://github.com/eps1lon) in
[#27982](https://github.com/facebook/react/pull/27982))
* Add stable React.act export ([acdlite](https://github.com/acdlite) in
[#28160](https://github.com/facebook/react/pull/28160))
* [flow] upgrade to 0.225.1 ([kassens](https://github.com/kassens) in
[#27871](https://github.com/facebook/react/pull/27871))
* fix[devtools/e2e]: add fallback for act in integration tests
([hoxyq](https://github.com/hoxyq) in
[#27842](https://github.com/facebook/react/pull/27842))
* Add stable concurrent option to react-test-renderer
([jackpope](https://github.com/jackpope) in
[#27804](https://github.com/facebook/react/pull/27804))
* Update act references in tests ([gnoff](https://github.com/gnoff) in
[#27805](https://github.com/facebook/react/pull/27805))
* Flow: make more objects exact ([kassens](https://github.com/kassens)
in [#27790](https://github.com/facebook/react/pull/27790))
2024-02-22 19:45:55 +00:00
Ruslan Lesiutin
87cb0bf182 React DevTools 4.28.5 -> 5.0.0 (#27759)
### Breaking
* refactor[devtools]: highlight an array of elements for native
([hoxyq](https://github.com/hoxyq) in
[#27734](https://github.com/facebook/react/pull/27734))

### Features
* feat[devtools]: display Forget badge for the relevant components
([hoxyq](https://github.com/hoxyq) in
[#27709](https://github.com/facebook/react/pull/27709))

### Other
* Added windows powershell syntax to build scripts
([PrathamLalwani](https://github.com/PrathamLalwani) in
[#27692](https://github.com/facebook/react/pull/27692))
* refactor[react-devtools-shared]: minor parsing improvements and
modifications ([hoxyq](https://github.com/hoxyq) in
[#27661](https://github.com/facebook/react/pull/27661))
2023-11-29 18:27:53 +00:00
PrathamLalwani
2c338b16fd Added windows powershell syntax to build scripts (#27692)
## Summary

I had to change the commands to be windows specific so that it doesn't
cause any crashes

## How did you test this change?

I successfully built the different types of devtools extenstions on my
personal computer. In future may need to add a github action with
windows config to test these errors

 #27193
2023-11-16 11:35:43 +00:00
Ruslan Lesiutin
20c91b6534 React DevTools 4.28.4 -> 4.28.5 (#27538)
Changes:
* fix[devtools/useMemoCache]: add stub for useMemoCache in
ReactDebugHook ([hoxyq](https://github.com/hoxyq) in
[#27472](https://github.com/facebook/react/pull/27472))
* useDeferredValue should skip initialValue if it suspends
([acdlite](https://github.com/acdlite) in
[#27509](https://github.com/facebook/react/pull/27509))
* feat[react-devtools-extensions/logging]: initialize session id on the
client for logging ([hoxyq](https://github.com/hoxyq) in
[#27517](https://github.com/facebook/react/pull/27517))
* refactor[react-devtools-extensions]: use globals to eliminate dead
code ([hoxyq](https://github.com/hoxyq) in
[#27516](https://github.com/facebook/react/pull/27516))
* fix[devtools/inspectElement]: dont pause initial inspectElement call
when user switches tabs ([hoxyq](https://github.com/hoxyq) in
[#27488](https://github.com/facebook/react/pull/27488))
2023-10-18 14:08:23 +01:00
Ruslan Lesiutin
18a9dd1c60 refactor[react-devtools-extensions]: use globals to eliminate dead code (#27516)
Small change to eliminate dead code in builds for different browsers.

Tested by inspecting production sources.
2023-10-16 14:54:25 +01:00
Ruslan Lesiutin
94d5b5b2bf React DevTools 4.28.3 -> 4.28.4 (#27419)
* refactor[devtools/extension]: refactored messaging logic across
different parts of the extension ([hoxyq](https://github.com/hoxyq) in
[#27417](https://github.com/facebook/react/pull/27417))
* fix[devtools/extension]: added a workaround for proxy content script
injection in firefox ([hoxyq](https://github.com/hoxyq) in
[#27375](https://github.com/facebook/react/pull/27375))
* fix[devtools/useTransition]: don't check for dispatch property when
determining if hook is stateful ([hoxyq](https://github.com/hoxyq) in
[#27365](https://github.com/facebook/react/pull/27365))
* feat[devtools/extension]: show disclaimer when page doesnt run react
and refactor react polling logic ([hoxyq](https://github.com/hoxyq) in
[#27373](https://github.com/facebook/react/pull/27373))
* feat:-Added a delete all filters action and added title to the add
filter a… ([Biki-das](https://github.com/Biki-das) in
[#27332](https://github.com/facebook/react/pull/27332))
* fix[devtools/extension]: unregister dynamically injected content
scripts instead of filtering ([hoxyq](https://github.com/hoxyq) in
[#27369](https://github.com/facebook/react/pull/27369))
* refactor[devtools/extension]: more stable element updates polling to
avoid timed out errors ([hoxyq](https://github.com/hoxyq) in
[#27357](https://github.com/facebook/react/pull/27357))
* feat[devtools/extension]: add dark theme for popup
([rakleed](https://github.com/rakleed) in
[#27330](https://github.com/facebook/react/pull/27330))
2023-09-25 13:24:52 -04:00
Ruslan Lesiutin
09285d5a7f refactor[devtools/extension]: refactored messaging logic across different parts of the extension (#27417)
1.
9fc04eaf3f (diff-2c5e1f5e80e74154e65b2813cf1c3638f85034530e99dae24809ab4ad70d0143)
introduced a vulnerability: we listen to `'fetch-file-with-cache'` event
from `window` to fetch sources of the file, in which we want to parse
hook names. We send this event via `window`, which means any page can
also use this and manipulate the extension to perform some `fetch()`
calls. With these changes, instead of transporting message via `window`,
we have a distinct content script, which is responsible for fetching
sources. It is notified via `chrome.runtime.sendMessage` api, so it
can't be manipulated.
2. Consistent structure of messages `{source: string, payload: object}`
in different parts of the extension
3. Added some wrappers around `chrome.scripting.executeScript` API in
`packages/react-devtools-extensions/src/background/executeScript.js`,
which support custom flow for Firefox, to simulate support of
`ExecutionWorld.MAIN`.
2023-09-25 12:02:13 -04:00
Ruslan Lesiutin
f9d75e32ba fix[devtools/extension]: added a workaround for proxy content script injection in firefox (#27375)
Changes:
1. [Firefox-only] For some reason, Firefox might try to inject
dynamically registered content script in pages like `about:blank`. I
couldn't find a way to change this behaviour, `about:` is not a valid
scheme, so we can't exclude it and `match_about_blank` flag is not
supported in `chrome.scripting.registerContentScripts`.
2. While navigating the history in Firefox, some content scripts might
not be re-injected and still be alive. To handle this, we are now
patching `window` with `__REACT_DEVTOOLS_PROXY_INJECTED__` flag, to make
sure that proxy is injected and only once. This flag is cleared on
`pagehide` event.
2023-09-22 19:36:03 +01:00
Ruslan Lesiutin
1b1dcb8a40 feat[devtools/extension]: show disclaimer when page doesnt run react and refactor react polling logic (#27373)
Changes:
1. Refactored react polling logic, now each `.eval()` call is wrapped in
Promise, so we can chain them properly.
2. When user has browser DevTools opened and React DevTools panels were
mounted, user might navigate to the page, which doesn't have React
running. Previously, we would show just blank white page, now we will
show disclaimer. Disclaimer appears after 5 failed attempts to find
React. We will also show this disclaimer if it takes too long to load
the page, but once any React instance is loaded and registered, we will
update the panels.
3. Dark theme support for this disclaimer and popups in Firefox &
Chromium-based browsers

**Important**: this is only valid for case when React DevTools panels
were already created, like when user started debugging React app and
then switched to non-React page. If user starts to debug non-React app
(by opening browser DevTools for it), we will not create these panels,
just like before.

Q: "Why do we poll to get information about react?"
A: To handle case when react is loaded after the page has been loaded,
some sandboxes for example.

| Before | After |
| --- | --- |
| <img width="1840" alt="Screenshot 2023-09-14 at 15 37 37"
src="https://github.com/facebook/react/assets/28902667/2e6ffb39-5698-461d-bfd6-be2defb41aad">
| <img width="1840" alt="Screenshot 2023-09-14 at 15 26 16"
src="https://github.com/facebook/react/assets/28902667/1c8ad2b7-0955-41c5-b8cc-d0fdb03e13ca">
|
2023-09-20 13:30:50 +01:00
Ruslan Lesiutin
54c2f2a346 fix[devtools/extension]: unregister dynamically injected content scripts instead of filtering (#27369)
Same as https://github.com/facebook/react/pull/26765.
Related bug report -
https://bugs.chromium.org/p/chromium/issues/detail?id=1393762.

This was changed in https://github.com/facebook/react/pull/27215, when I
have refactored background logic in the extension. I've missed this
case, because the extension was working in incognito mode.

Turns out, it stops working after the first reload, and it stops only in
incognito mode, so I am rolling out back the previous workaround.

Tested on Chrome that it fixes the extension in incognito mode and that
it doesn't affect default mode.
2023-09-14 15:21:28 +01:00
Ruslan Lesiutin
2eed132847 refactor[devtools/extension]: more stable element updates polling to avoid timed out errors (#27357)
Some context:
- When user selects an element in tree inspector, we display current
state of the component. In order to display really current state, we
start polling the backend to get available updates for the element.

Previously:
- Straight-forward sending an event to get element updates each second.
Potential race condition is not handled in any form.
- If user navigates from the page, timeout wouldn't be cleared and we
would potentially throw "Timed out ..." error.
- Bridge disconnection is not handled in any form, if it was shut down,
we could spam with "Timed out ..." errors.

With these changes:
- Requests are now chained, so there can be a single request at a time.
- Handling both navigation and shut down events.

This should reduce the number of "Timed out ..." errors that we see in
our logs for the extension. Other surfaces will also benefit from it,
but not to the full extent, as long as they utilize
"resumeElementPolling" and "pauseElementPolling" events.

Tested this on Chrome, running React DevTools on multiple tabs,
explicitly checked the case when service worker is in idle state and we
return back to the tab.
2023-09-12 15:05:39 +01:00
Pavel
627b7abd62 feat[devtools/extension]: add dark theme for popup (#27330)
## Summary

If the system/browser uses a dark theme, then the extension popup still
remains with a light background. And so that the eyes do not hurt in a
dark room, you need a dark theme.

## How did you test this change?

Make sure the dark theme is enabled on your system/browser.

**Before:**

![Screenshot 2023-09-02 at 22 20
56](https://github.com/facebook/react/assets/19418601/f7166ea7-f562-4d11-8851-be08fa9629a7)

**After:**

![Screenshot 2023-09-02 at 22 21
30](https://github.com/facebook/react/assets/19418601/e51ecd5f-3e71-4193-83ff-a548bce76bd4)
2023-09-11 14:02:54 +01:00
Ruslan Lesiutin
a374287fea React DevTools 4.28.2 -> 4.28.3 (#27337)
This is a patch version to fix some bugs in a previous internal release.
I am expecting this one also to be internal-only, need to make sure that
extension is stable in Chrome. Some changes and improvements are
expected for Firefox, though, before going public.

* refactor[devtools/extension]: handle ports disconnection, instead of
frequent reconnection ([hoxyq](https://github.com/hoxyq) in
[#27336](https://github.com/facebook/react/pull/27336))
* refactor[devtools/extension]: migrate from using setInterval for
polling if react is loaded ([hoxyq](https://github.com/hoxyq) in
[#27323](https://github.com/facebook/react/pull/27323))
* fix[devtools/extension]: fixed duplicating panels in firefox
([hoxyq](https://github.com/hoxyq) in
[#27320](https://github.com/facebook/react/pull/27320))
2023-09-05 18:58:27 +01:00
Ruslan Lesiutin
a27df56a5c refactor[devtools/extension]: handle ports disconnection, instead of frequent reconnection (#27336)
- Instead of reconnecting ports from devtools page and proxy content
script, now handling their disconnection properly
- `proxy.js` is now dynamically registered as a content script, which
loaded for each page. This will probably not work well for Firefox,
since we are still on manifest v2, I will try to fix this in the next
few PRs.
- Handling the case when devtools page port was reconnected and bridge
is still present. This could happen if user switches the tab and Chrome
decides to kill service worker, devtools page port gets disconnected,
and then user returns back to the tab. When port is reconnected, we
check if bridge message listener is present, connecting them if so.
- Added simple debounce when evaluating if page has react application
running. We start this check in `chrome.network.onNavigated` listener,
which is asynchronous. Also, this check itself is asynchronous, so
previously we could mount React DevTools multiple times if navigates
multiple times while `chrome.devtools.inspectedWindow.eval` (which is
also asynchronous) can be executed.
00b7c43318/packages/react-devtools-extensions/src/main/index.js (L575-L583)



https://github.com/facebook/react/assets/28902667/9d519a77-145e-413c-b142-b5063223d073
2023-09-05 18:41:39 +01:00
Ruslan Lesiutin
9b4f847d93 refactor[devtools/extension]: migrate from using setInterval for polling if react is loaded (#27323)
`chrome.devtools.inspectedWindow.eval` is asynchronous, so using it in
`setInterval` is a mistake.
Sometimes this results into mounting React DevTools twice, and user sees
errors about duplicated fibers in store.

With these changes, `executeIfReactHasLoaded` executed recursively with
a threshold (in case if page doesn't have react).

Although we minimize the risk of mounting DevTools twice here, this
approach is not the best way to have this problem solved. Dumping some
thoughts and ideas that I've tried, but which are out of the scope for
this release, because they can be too risky and time-consuming.
Potential changes:
- Have 2 content scripts:
  - One `prepareInjection` to notify service worker on renderer attached
- One which runs on `document_idle` to finalize check, in case if there
is no react
- Service worker will notify devtools page that it is ready to mount
React DevTools panels or should show that there is no React to be found
- Extension port from devtools page should be persistent and connected
when `main.js` is executed
- Might require refactoring the logic of how we connect devtools and
proxy ports
  
  
Some corner cases:
- Navigating to restricted pages, like `chrome://<something>` and back
- When react is lazily loaded, like in an attached iframe, or just
opened modal
- In-tab navigation with pre-cached pages, I think only Chrome does it
- Firefox is still on manifest v2 and it doesn't allow running content
scripts in ExecutionWorld.MAIN, so it requires a different approach
2023-09-01 16:23:04 +01:00
Ruslan Lesiutin
7022e8d6a3 fix[devtools/extension]: fixed duplicating panels in firefox (#27320)
Multiple `chrome.panels.create` calls result into having duplicate
panels created in Firefox, these changes fix that.

Now calling `chrome.panels.create` only if there are no panels created
yet.
2023-08-31 18:24:26 +01:00
Ruslan Lesiutin
3808b01b3a React DevTools 4.28.1 -> 4.28.2 (#27318)
List of changes:
* fix[devtools/extension]: handle tab navigation events before react is
loaded ([hoxyq](https://github.com/hoxyq) in
[#27316](https://github.com/facebook/react/pull/27316))
2023-08-30 19:47:08 +01:00