Commit Graph
192 Commits
Author SHA1 Message Date
Mengdi ChenandGitHub 7b3cfd4847 remove flow check in electron app.js (#26184)
When we were upgrading flow in
https://github.com/facebook/react/commit/1aa5d9cf568c24119e839488691483ac89aa1fd8
we added `$FlowFixMe` for some parameters in this file. However, this
file is not compiled at all, and the `:` syntax breaks the code.

This PR removes the flow check in this file
2023-02-17 11:54:43 -05:00
Mengdi ChenandGitHub 95a88d8052 React DevTools 4.27.1 -> 4.27.2 (#26185) 2023-02-16 16:46:23 -05:00
Jan KassensandGitHub 1aa5d9cf56 [flow] enable LTI inference mode (#26104)
This is the next generation inference mode for Flow.
2023-02-09 17:07:39 -05:00
Jan KassensandGitHub 77a81a7182 Upgrade prettier (#26081)
The old version of prettier we were using didn't support the Flow syntax
to access properties in a type using `SomeType['prop']`. This updates
`prettier` and `rollup-plugin-prettier` to the latest versions.

I added the prettier config `arrowParens: "avoid"` to reduce the diff
size as the default has changed in Prettier 2.0. The largest amount of
changes comes from function expressions now having a space. This doesn't
have an option to preserve the old behavior, so we have to update this.
2023-01-31 08:25:05 -05:00
Mengdi ChenandGitHub 5205484af2 React DevTools 4.27.0 -> 4.27.1 (#25835)
patch for devtools bug
2022-12-07 12:23:52 -05:00
lushevolandGitHub 4b40bc897e fix invalid link to react-devtools-extensions/src/__tests__ (#25816) 2022-12-06 21:21:01 +01:00
Mengdi ChenandGitHub cfff136000 React DevTools 4.26.1 -> 4.27.0 (#25753) 2022-11-30 19:14:11 -05:00
Mengdi ChenandGitHub ab700c88ba [DevTools] upgrade to Manifest V3 (#25145)
## Summary

resolves #24522

To upgrade to Manifest V3, one of the biggest issue is that we are no
longer allowed to add a script element with code in textContent so that
it would run synchronously. It's necessary for us because we need to
inject a global hook for react reconciler to detect whether devtools
exist.
To do that, we'll leverage a new API
`chrome.scripting.registerContentScripts` in V3. Particularly, we rely
on the "world" option (added in Chrome v102
[commit](https://chromium.googlesource.com/chromium/src/+/e5ad3451c17b21341b0b9019b074801c44c92c9f))
to run it in the "main world" on the page.

This PR also renames a few content script files so that it's easier to
tell them apart from other extension scripts and understand the purpose
of each of them.

Manifest V3 is not yet ready for Firefox, so we need to keep some code
for compatibility.

## How did you test this change?

`yarn build:chrome && yarn test:chrome`
`yarn build:edge && yarn test:edge`
`yarn build:firefox && yarn test:firefox`
2022-10-21 22:52:18 -04:00
Andrew ClarkandGitHub 6dd316c347 [Codemod] Update copyright header to Meta (#25315)
* Facebook -> Meta in copyright

rg --files | xargs sed -i 's#Copyright (c) Facebook, Inc. and its affiliates.#Copyright (c) Meta Platforms, Inc. and affiliates.#g'

* Manual tweaks
2022-10-18 11:19:24 -04:00
Tianyu YaoandGitHub 67c749c827 React DevTools 4.26.0 -> 4.26.1 (#25478) 2022-10-14 10:36:52 -07:00
Jan Kassens d80db31367 Flow upgrade to 0.146
This upgrade made more expressions invalidate refinements. In some
places this lead to a large number of suppressions that I automatically
suppressed and should be followed up on when the code is touched.
I think most of them might require either manual annotations or moving
a value into a const to allow refinement.

ghstack-source-id: a45b40abf0
Pull Request resolved: https://github.com/facebook/react/pull/25410
2022-10-04 11:01:50 -04:00
Alexandru TasicaandJan Kassens feebd1ff2b Fix devtools typos and grammar (#24587)
Closes #24587
2022-10-03 10:11:40 -04:00
585abd12e7 Fix: Documentation typos (#24471)
* fix: typo

Co-authored-by: Jan Kassens <[email protected]>
2022-09-29 12:46:53 -04:00
Brandon ChanandGitHub ad11b99bfa Updated the URL link for serve (#25296) 2022-09-19 13:13:38 -04:00
Tianyu YaoandGitHub f7955b3bc6 React DevTools 4.25.0 -> 4.26.0 (#25283) 2022-09-16 12:35:00 -07:00
Robert BalickiandGitHub a8faa941e6 [easy] Clarify folders in react devtools readme #25077
Clarify the folder from which we run various commands in the react-devtools readme
2022-08-11 19:47:02 -04:00
Mengdi ChenandGitHub 71cef664e5 React DevTools 4.24.7 -> 4.25.0 (#24919) 2022-07-13 15:57:50 -04:00
Luna RuanandGitHub 86d4faada3 React DevTools 4.24.6 -> 4.24.7 (#24646) 2022-05-31 16:16:07 -04:00
Mengdi "Monday" ChenandGitHub 01aabd512a React DevTools 4.24.5 -> 4.24.6 (#24547) 2022-05-12 10:52:55 -04:00
Brian VaughnandGitHub 1205345106 React DevTools 4.24.4 -> 4.24.5 (#24503) 2022-05-05 10:19:08 -07:00
Brian VaughnandGitHub d1a0e70c85 React DevTools 4.24.3 -> 4.24.4 (#24315) 2022-04-08 11:38:07 -04:00
Mengdi "Monday" ChenandGitHub e8ffbb8267 React DevTools 4.24.2 -> 4.24.3 (#24198) 2022-03-29 14:44:32 -04:00
Brian VaughnandGitHub 2098114314 React DevTools 4.24.1 -> 4.24.2 (#24150) 2022-03-24 09:06:10 -04:00
Brian VaughnandGitHub 5504b61246 Update DevTools READMEs (#24105) 2022-03-16 11:37:10 -04:00
Brian VaughnandGitHub 4723500335 Update CHANGELOG.md 2022-03-15 14:21:21 -04:00
Luna RuanandGitHub d4fa9c597b React DevTools 4.24.0 -> 4.24.1 (#24100) 2022-03-15 14:13:00 -04:00
Brian VaughnandGitHub 2b6d78ba4c React DevTools 4.23.0 -> 4.24.0 (#24066)
* Revert "React DevTools 4.23.0 -> 4.24.0 (#23400)"

This reverts commit 4098ff783d.

* React DevTools 4.23.0 -> 4.24.0

* Added additional, pending bugfixes to CHANGELOG

* Updated DevTools build and release script to fix header format
2022-03-10 13:37:01 -05:00
Brian VaughnandGitHub 4098ff783d React DevTools 4.23.0 -> 4.24.0 (#23400)
* React DevTools 4.23.0 -> 4.24.0

* Fixed CHANGELOG header format

* Add separator line beween header version numbers
2022-03-02 13:28:42 -05:00
Brian VaughnandGitHub 59ed5cf00e Show DevTools backend and frontend versions in UI (#23399)
This information can help with bug investigation for renderers (like React Native) that embed the DevTools backend into their source (separately from the DevTools frontend, which gets run by the user).

If the DevTools backend is too old to report a version, or if the version reported is the same as the frontend (as will be the case with the browser extension) then only a single version string will be shown, as before. If a different version is reported, then both will be shown separately.
2022-03-02 12:26:48 -05:00
Brian Vaughn 0c4ce4bd0f React DevTools 4.22.1 -> 4.23.0 2022-01-24 09:29:18 -05:00
Brian VaughnandGitHub ea88b49dd3 React DevTools 4.22.0 -> 4.22.1 (#22962) 2021-12-14 23:52:50 -05:00
Brian VaughnandGitHub 3c404bacfa Re-added deleted files array to react-devtools package.json (#22960) 2021-12-14 23:28:57 -05:00
Brian VaughnandGitHub e6768c0ade Updated DevTools changelog 2021-12-14 16:50:17 -05:00
jstejadaandGitHub 63616af98f React DevTools 4.21.0 -> 4.22.0 (#22951) 2021-12-14 14:19:21 -05:00
Brian VaughnandGitHub 2da79c6f8d DevTools: Support mulitple DevTools instances per page (#22949)
This is being done so that we can embed DevTools within the new React (beta) docs.

The primary changes here are to `react-devtools-inline/backend`:
* Add a new `createBridge` API
* Add an option to the `activate` method to support passing in the custom bridge object.

The `react-devtools-inline` README has been updated to include these new methods.

To verify these changes, this commit also updates the test shell to add a new entry-point for multiple DevTools.

This commit also replaces two direct calls to `window.postMessage()` with `bridge.send()` (and adds the related Flow types).
2021-12-14 12:16:16 -05:00
Brian VaughnandGitHub 7e6e7f32f0 Advocate for StrictMode usage within Components tree (#22886)
Adds the concept of subtree modes to DevTools to bridge protocol as follows:
1. Add-root messages get two new attributes: one specifying whether the root is running in strict mode and another specifying whether the root (really the root's renderer) supports the concept of strict mode.
2. A new backend message type (TREE_OPERATION_SET_SUBTREE_MODE). This type specifies a subtree root (id) and a mode (bitmask). For now, the only mode this message deals with is strict mode.

The DevTools frontend has been updated as well to highlight non-StrictMode compliant components.

The changes to the bridge protocol require incrementing the bridge protocol version number, which will also require updating the version of react-devtools-core backend that is shipped with React Native.
2021-12-10 11:05:18 -05:00
Mert CiflikliandGitHub 620d2417ce fix typos (#22288) 2021-11-15 10:59:35 -05:00
JuanandGitHub a0b40b9f80 React DevTools 4.20.2 -> 4.21.0 (#22661) 2021-10-31 19:19:02 -04:00
JuanandGitHub 659f8b18ed React DevTools 4.20.1 -> 4.20.2 (#22605) 2021-10-20 16:00:13 -04:00
JuanandGitHub 2bb87d09ca React DevTools 4.20.0 -> 4.20.1 (#22583) 2021-10-19 10:55:39 -04:00
JuanandGitHub e8b35bff63 React DevTools 4.19.2 -> 4.20.2 (#22569) 2021-10-15 12:50:17 -04:00
Gabriel TrompizandGitHub 101be40f95 Reattachment of the splash page event listeners (#22558) (#22560) 2021-10-15 09:16:43 -04:00
JuanandGitHub 415d45dbba Prevent errors/crashing when multiple installs of DevTools are present (#22517)
## Summary

This commit is a proposal for handling duplicate installation of DevTools, in particular scoped to duplicates such as a dev build or the internal versions of DevTools installed alongside the Chrome Web Store extension.

Specifically, this commit makes it so when another instance of the DevTools extension is installed alongside the extension installed from the Chrome Web Store, we don't produce a stream of errors or crash Chrome, which is what would usually happen in this case. 


### Detecting Duplicate Installations

- First, we check what type of installation the extension is: from the Chrome Web Store, the internal build of the extension, or a local development build.
- If the extension is from the **Chrome Web Store**:
  - During initialization, we first check if the internal or local builds of the extension have already been installed and are enabled. To do this, we send a [cross-extension message](https://developer.chrome.com/docs/extensions/mv3/messaging/#external) to the internal and local builds of the extension using their extension IDs.  
    - We can do this because the extension ID for the internal build (and for the Chrome Web Store) is a stable ID.
    - For the local build, at build time we hardcode a [`key` in the `manifest.json`](https://developer.chrome.com/docs/extensions/mv2/manifest/key/) which allows us to have a stable ID even for local builds.
  - If we detect that the internal or local extensions are already installed, then we skip initializing the current extension altogether so as to not conflict with the other versions. This means we don't initialize the frontend or the backend at all.
- If the extension is the **Internal Build**:
  - During initialization, we first check if the local builds of the extension has already been installed and is enabled. To do this, we send a [cross-extension message](https://developer.chrome.com/docs/extensions/mv3/messaging/#external) to the local build of the extension using its extension ID.  
    - We can do this for the local build because at build time we hardcode a [`key` in the `manifest.json`](https://developer.chrome.com/docs/extensions/mv2/manifest/key/) which allows us to have a stable ID even for local builds.
  - If we detect that the local extension is already installed, then we skip initializing the current extension altogether so as to not conflict with the that  version. This means we don't initialize the frontend or the backend at all.
- If the extension is a **Local Dev Build**:
  - Since other extensions check for the existence of this extension and disable themselves if they detect it, we don't need any special handling during initialization and assume that there are no duplicate extensions. This means that we will generally prefer keeping this extension enabled.

This behavior means that the order of priority for keeping an extension enabled is the following:

1. Local build
2. Internal build
3. Public build


### Preventing duplicate backend initialization

Note that the backend is injected and initialized by the content script listening to a message posted to the inspected window (via `postMessage`). Since the content script will be injected twice, once each by each instance of the extension, even if we initialize the extension once, both content scripts would still receive the single message posted from the single frontend, and it would then still inject and initialize the backend twice. 

In order to prevent this, we also add the extension ID to the message for injecting the backend. That way each content script can check if the message comes from its own extension, and if not it can ignore the message and avoid double injecting the backend.
  
### Other approaches

- I considered using the [`chrome.management`](https://developer.chrome.com/docs/extensions/reference/management/) API generally to detect other installations, but that requires adding additional permissions to our production extension, which didn't seem ideal.
- I also considered a few options of writing a special flag to the inspected window and checking for it before initializing the extension. However, it's hard to avoid race conditions in that case, and it seemed more reliable to check specifically for the WebStore extension, which is realistically where we would encounter the overlap.
  
### Rollout

- This commit needs to be published and rolled out to the Chrome Web Store first.
- After this commit is published to the Chrome Web Store, any duplicate instances of the extension that are built and installed after this commit will no longer conflict with the Chrome Web Store version.
  
### Next Steps

- In a subsequent PR, I will extend this code to show a warning when duplicate extensions have been detected.

Part of #22486

## How did you test this change?

### Basic Testing

- yarn flow
- yarn test
- yarn test-build-devtools

### Double installation testing

Testing double-installed extensions for this commit is tricky because we are relying on the extension ID of the internal and Chrome Web Store extensions, but we obviously can't actually test the Web Store version (since we can't modify the already published version).

In order to simulate duplicate extensions installed, I did the following process:

- Built separate extensions where I hardcoded a constant for whether the extension is internal or public (e.g. `EXTENSION_INSTALLATION_TYPE = 'internal'`). Then I installed these built extensions corresponding to the "internal" and "Web Store" builds.
- Build and run the regular development extension (with `yarn build:chrome:dev && yarn test:chrome`), using the extension IDs of the previously built extensions as the "internal" and "public" extension IDs.

With this set up in place, I tested the following on pages both with and without React:

- When only the local extension enabled, DevTools works normally.
- When only the "internal" extension enabled, DevTools works normally.
- When only the "public" extension enabled, DevTools works normally.
- When "internal" and "public" extensions are installed, "public" extension is disabled and "internal" extension works normally.
- When the local extension runs alongside the other extensions, other extensions disable themselves and local build works normally.
- When we can't recognize what type of build the extension corresponds to, we show an error.
- When all 3 extensions are installed and enabled in all different combinations, DevTools no longer produces errors or crashes Chrome, and works normally.
2021-10-14 17:15:31 -04:00
Gabriel TrompizandGitHub 18ec2f8890 Allow to use the Profiler when no client is connected in standalone DevTools (#22551) 2021-10-14 08:31:45 -04:00
Brian Vaughn 322de665f8 React DevTools 4.19.1 -> 4.19.2 2021-10-08 13:51:25 -04:00
Brian VaughnandGitHub bedaa94843 React DevTools 4.19.0 -> 4.19.1 (#22480) 2021-10-01 11:50:05 -04:00
Luna RuanandGitHub ec38aa815a React DevTools 4.18.0 -> 4.19.0 (#22461) 2021-09-29 12:06:13 -04:00
38elementsandGitHub 03d4d78443 Fix links in packages/react-devtools/README.md (#22356) 2021-09-20 15:10:29 -04:00
BIKI DASandGitHub ee814ff109 react-devtools\OVERVIEW.md --> fixed typos (#22372) 2021-09-20 15:09:37 -04:00
JuanandGitHub 2cea2a653d [DevTools] Enable hook names in standalone app (#22320) 2021-09-17 10:21:54 -04:00