Commit Graph

448 Commits

Author SHA1 Message Date
c0dedance
9fb581c7cc Refactor: merge duplicate imports (#25489)
Co-authored-by: Jan Kassens <jan@kassens.net>
2022-10-16 21:58:58 -04:00
Jan Kassens
ea04a486a7 Flow: remove unused suppressions (#25424)
Removes $FlowFixMe's that are no longer needed.

Used flow/tool from the Flow repo:

```
 ~/Developer/flow/tool update-suppressions .
```
2022-10-04 16:18:12 -04:00
Jan Kassens
9813edef29 Flow upgrade to 0.188
ghstack-source-id: 5c359b97cc
Pull Request resolved: https://github.com/facebook/react/pull/25423
2022-10-04 15:49:48 -04:00
Jan Kassens
3b6826ed9e Flow: inference_mode=constrain_writes
This mode is going to be the new default in Flow going forward.
There was an unfortuante large number of suppressions in this update.

More on the changes can be found in this [Flow blog post](https://medium.com/flow-type/new-flow-language-rule-constrained-writes-4c70e375d190).

Added some of the required annotations using the provided codemod:

```sh
node_modules/.bin/flow codemod annotate-declarations --write .
```

ghstack-source-id: 0b168e1b23
Pull Request resolved: https://github.com/facebook/react/pull/25422
2022-10-04 15:49:48 -04:00
Jan Kassens
f02a5f5c79 Flow upgrade to 0.182
ghstack-source-id: b9bb8c1560
Pull Request resolved: https://github.com/facebook/react/pull/25419
2022-10-04 13:37:58 -04:00
Jan Kassens
72593f008e Flow upgrade to 0.176
This upgrade deprecated calling `new` on functions which introduced
the majority of breakages and I suppressed those.

ghstack-source-id: 545363f3c5
Pull Request resolved: https://github.com/facebook/react/pull/25418
2022-10-04 13:37:58 -04:00
Jan Kassens
1089faf0d8 Flow: run codemod to remove existential type
The existential type `*` was deprecated and a codemod provided to replace it. Ran that and did some manual fixups:

```sh
node_modules/.bin/flow codemod replace-existentials --write .
```

ghstack-source-id: 4c98b8db6a
Pull Request resolved: https://github.com/facebook/react/pull/25416
2022-10-04 13:37:58 -04:00
Jan Kassens
338e6a967c Flow upgrade to 0.155
This version banned use of this in object functions.

ghstack-source-id: f49fd5e1b7
Pull Request resolved: https://github.com/facebook/react/pull/25414
2022-10-04 11:49:15 -04:00
Jan Kassens
8bc95bb3c8 Flow upgrade to 0.154
ghstack-source-id: d84024950a
Pull Request resolved: https://github.com/facebook/react/pull/25413
2022-10-04 11:49:14 -04:00
Jan Kassens
9f8a98a390 Flow upgrade to 0.153
- method unbinding is no longer supported in Flow for soundness, this added a bunch of suppressions
- Flow now prevents objects to be supertypes of interfaces/classes

ghstack-source-id: d7749cbad8
Pull Request resolved: https://github.com/facebook/react/pull/25412
2022-10-04 11:30:06 -04:00
Jan Kassens
adb58f529d Flow upgrade to 0.152
- 0.147 removes access to Object.prototype via the global object.
- 0.149 removed deprecated config options

ghstack-source-id: c77f9b3739
Pull Request resolved: https://github.com/facebook/react/pull/25411
2022-10-04 11:30:06 -04:00
Jan Kassens
64fe791be8 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
Jan Kassens
0a3072278e Flow: complete types first migration (#25389)
This complete the "types first" migration and enables the config everywhere.
2022-10-03 21:59:33 -04:00
Vic Graf
5b59dd6400 Fix duplicate words tests (#25333)
* refactor: removed duplicated words in comments
* refactor: removed duplicate words in tests
2022-09-27 10:07:06 -04:00
Victoria Graf
3d615fc14a Grammar. Removed doubles of the word "the". (#25295) 2022-09-19 10:04:03 -04:00
Jan Kassens
fc16293f3f Flow: well_formed_exports for devtools (#25266) 2022-09-15 16:45:29 -04:00
Jan Kassens
e6a062bd2a Flow: add simple explicit export types to Devtools (#25251) 2022-09-13 12:03:20 -04:00
Robert Balicki
271bf90a94 [react devtools][easy] Centralize calls to patchConsoleUsingWindowValues (#25222)
* Instead of reading from window in two separate places, do this in a single function
* Add some type safety
2022-09-13 11:24:10 -04:00
Jan Kassens
6aa38e74c7 Flow: enable unsafe-addition error (#25242) 2022-09-12 16:22:50 -04:00
Jan Kassens
ba7b6f4183 Flow: upgrade to 0.132 (#25244) 2022-09-12 14:36:02 -04:00
Jan Kassens
8003ab9cf5 Flow: remove explicit object syntax (#25223) 2022-09-09 16:03:48 -04:00
Robert Balicki
425f9fbba0 [react devtools] Don't check for NODE_ENV==='test' because it never is (#25186)
* remove useless condition
2022-09-09 11:31:32 -04:00
Robert Balicki
540ba5b403 [react devtools][easy] Change variable names, etc. (#25211)
* Change variable names, put stuff in constants, etc. in preparation for next diff
2022-09-09 11:09:30 -04:00
Jan Kassens
8a9e7b6cef Flow: implicit-inexact-object=error (#25210)
* implicit-inexact-object=error
* default everything ambiguous to exact object
* inexact where exact causes errors
2022-09-09 10:13:58 -04:00
Jan Kassens
a473d08fce Update to Flow from 0.97 to 0.122 (#25204)
* flow 0.122
* update ReactModel type
2022-09-08 11:46:07 -04:00
Luna Ruan
c80e54116e [DevTools][Bugfix] Don't hide fragment if it has a key (#25197)
resolves #25187

---

We shouldn't hide fragments that have a key because this is important information that the user might want in the future.
2022-09-07 10:21:30 -07:00
Tim Neutkens
a9dc73cfd4 Handle info, group, and groupCollapsed in Strict Mode logging (#25172)
* Handle info, group, and groupCollapsed in Strict Mode logging

While working on the new Next.js router which heavily relies on useReducer I noticed that `group` and `groupCollapsed` which both take labels were showing as-is in the console for the second render/dispatch in Strict Mode logs. While looking at the code I found that `info` was also not instrumented.

I've added additional handling for:
- `info`
- `group`
- `groupCollapsed`

* Remove console.log

* Fix tests
2022-09-06 10:03:27 -07:00
Robert Balicki
7e5322ccf2 run prettier (#25164) 2022-08-31 14:20:01 -04:00
Robert Balicki
47867a772e [react devtools][easy] Fix code highlighting in VSCode (#25155)
* Minor change that fixes code highlighting in VSCode in a particular file
2022-08-31 14:07:37 -04:00
Jan Kassens
a40ddf3124 Fix CI: run yarn prettier-all (#25163) 2022-08-31 18:50:04 +01:00
Robert Balicki
aa80a309b1 [react devtools][easy] Rename LOCAL_STORAGE_SHOULD_PATCH_CONSOLE_KEY to LOCAL_STORAGE_SHOULD_APPEND_COMPONENT_STACK_KEY (#25154)
* This more accurately describes what this constant does
2022-08-30 13:32:52 -04:00
Tianyu Yao
181525338e [DevTools] Highlight RN elements on hover (#25106)
* [DevTools] Highlight RN elements on hover

* Remove unused TODO
2022-08-24 11:25:22 -07:00
Tianyu Yao
26ba5fb2e0 [DevTools] Add events necessary for click to inspect on RN (#25111)
* Add inspectingNative events for RN

* Enable inspection toggle UI for RN

* Add a stopInspectingNative method for agent
2022-08-19 16:18:14 -07:00
Mengdi Chen
5f34b051df [Devtools] add logs for profiler tab switch & settings change (#24966)
* [devtools] add logs for profiler tab switch & settings change

* prettier

* remove unnecessary console.log

* better naming: logEvent -> loggerEvent

* use same object for event and metadata
2022-07-25 11:53:38 -04:00
Sebastian Silbermann
b66936ece7 devtools: Remove ForwardRef/Memo from display name if displayName is set (#21952)
* feat(devtools): Remove ForwardRef/Memo from display name if `displayName` is set

* Avoid potentially wasting work by inlining `functionName`
2022-07-25 09:02:12 +02:00
Mengdi Chen
3ddbedd052 [devtools] log more events + metadata (#24951)
* [devtools] log more events + metadata

* better typing

* consistent string type
2022-07-19 15:22:09 -04:00
Mengdi Chen
992911981b [DevTools] add simple usage events for internal logging (#24888)
* [DevTools] add simple events for internal logging

* fix lint

* fix lint

* better event name

* fix flow

* better way to fix flow

* combine 'select-element'

* use same event name for selecting element by inspecting
2022-07-18 15:52:53 -04:00
Mengdi Chen
4bc83e6821 [DevTools] enable enableProfilerComponentTree flag for all builds (#24921) 2022-07-13 15:21:32 -04:00
Luna Ruan
c3b18571db [DevTools][Bugfix] Fix DevTools Perf Issue When Unmounting Large React Subtrees (#24863)
We've recently had multiple reports where, if React DevTools was installed, unmounting large React subtrees would take a huge performance hit (ex. from 50ms to 7 seconds). 

Digging in more, we realized for every fiber that unmounts, we called `untrackFibers`, which calls `clearTimeout` (and does some work manipulating a set, but this wasn't the bulk of the time). We ten call `recordUnmount`, which adds the timer back. Adding and removing the timer so many times was taking upwards of 50ms per timer add/remove call, which was resulting in exorbitant amounts of time spent in DevTools deleting subtrees.

It looks like we are calling `untrackFibers` so many times to avoid a race condition with Suspense children where we unmount them twice (first a "virtual" unmount when the suspense boundary is toggled from visible to invisible, and then an actual unmount when the new children are rendered) without modifying `fiberIDMap`. We can fix this race condition by using the `untrackFibersSet` as a lock and not calling `recordUnmount` if the fiber is in the set and hasn't been processed yet. This works because the only way fibers are added in the set is via `recordUnmount` anyway.

This PR also adds a test to make sure this change doesn't regress the previous behavior.

**Before**
![image](https://user-images.githubusercontent.com/2735514/177655428-774ee306-0568-49ce-987e-b5213b613265.png)

**After**
![image](https://user-images.githubusercontent.com/2735514/177655604-a217583f-787e-438e-b6f9-18953fe32444.png)
2022-07-07 10:43:25 -04:00
Luna Ruan
4e1fcfa771 [DevTools] Resign Timeline Profiler Sidebar (#24816)
This PR:
* Redesigned the sidebar to resemble the flamegraph profiler sidebar and added title and timestamp to the sidebar
* Added ability to copy the component stack (for places where you're unable to link to source)

https://user-images.githubusercontent.com/2735514/176564897-5301d6d4-429a-4ea3-86cd-74427cff4ce6.mov
2022-06-29 17:54:06 -07:00
Luna Ruan
1974d08c93 [DevTools] Fix Bugs With Component Stacks (#24815)
This PR:
* Simplifies the code in `SidebarEventInfo` by passing it the actual clicked event rather than an index.
* Lightly refactored the `SidebarEventInfo` code so that it can be used for more than just `schedulingEvents`
* Fixes bug. Previously, whenever a state update event was clicked, we updated the `selectedCommitIndex` in the `ProfilerContext`. However, this index is used for the selected commit in the Flamegraph profiler, which caused a bug where if you would change the contents of the event sidebar, the commit sidebar in the Flamegraph profiler would change too. This PR replaces this with the actual event info instead
2022-06-29 16:00:48 -07:00
Luna Ruan
cd80d3274d [DevTools] Add column number to viewSourceLineFunction (#24814)
Add column number for `viewSourceLineFunction` and renamed the function to `viewUrlSourceFunction` to match the other source function naming conventions
2022-06-29 10:38:27 -07:00
Mengdi Chen
f01e119b7d [DevTools] Log page URL in internal build (#24799)
* test log

* fix attribute name

* fix lint

* tabs can be empty

* improve coding style per comments
2022-06-29 13:02:53 -04:00
Blake Friedman
2e1c8841e9 [DevTools] front-end for profiling event stack (#24805)
* [DevTools] front-end for profiling event stack

Adds a side-bar to the profiling tab. Users can now select an update event, and are
shown the callstack from the originating component. When a source path is available
there is now UI to jump to source.

Add FB enabled feature flag: enableProfilerComponentTree for the side-bar.

resolves #24170
2022-06-28 22:15:24 +01:00
Luna Ruan
955cad9bcc [DevTools] Clean Up DevTools Code (#24782)
This PR cleans up the DevTools codebase by:
* Consolidating `normalizeCodeLocInfo` into one place
* Remove unused source argument in the DevTools component stacks code
2022-06-23 15:47:47 -07:00
Luna Ruan
9abe745aa7 [DevTools][Timeline Profiler] Component Stacks Backend (#24776)
This PR adds a component stack field to the `schedule-state-update` event. The algorithm is as follows:
* During profiling, whenever a state update happens collect the parents of the fiber that caused the state update and store it in a map
* After profiling finishes, post process the `schedule-state-update` event and using the parent fibers, generate the component stack by using`describeFiber`, a function that uses error throwing to get the location of the component by calling the component without props.

---

Co-authored-by: Blake Friedman <blake.friedman@gmail.com>
2022-06-23 11:19:23 -07:00
Mengdi Chen
f7b44539ca [DevTools] enable "reload & profile" button for timeline view (#24702) 2022-06-10 10:38:33 -04:00
Mengdi Chen
3e92eb0fce [DevTools] find best renderer when inspecting (#24665)
* [DevTools] find best renderer when inspecting

* fix lint

* fix test

* fix lint

* move logic to agent

* fix lint

* style improvements per review comments

* fix lint & flow

* re-add try catch for safety
2022-06-08 16:01:06 -04:00
Luna Ruan
1328ff70cd [DevTools] Regression-proof e2e Tests (#24620)
This PR:

* Increases test retry count to 2 so that flaky tests have more of a chance to pass
* Ideally most e2e tests will run for all React versions (and ensure DevTools elegantly fails if React doesn't support its features). However, some features aren't supported in older React versions at all (ex. Profiling) Add runOnlyForReactRange function in these cases to skip tests that don't satisfy the correct React semver range
* Fix should allow searching for component by name test, which was flaky because sometimes the Searchbox would be unfocused the second time we try to type in it
* Edited test Should allow elements to be inspected to check that element inspect gracefully fails in older React versions
* Updated config to add a config.use.url field and a config.use.react_version field, which change depending on the React Version (and whether it's specified)
2022-05-25 20:53:44 -04:00
Luna Ruan
1e98682dd3 [DevTools] Fix moduleNameMapper Order in DevTools Config #24602)
We need the regression config moduleNameMapper to come before the current moduleNameMapper so when it tries to map "/^react-dom\/([^/]+)$/ it doesn't get confused. The reason is because order in which the mappings are defined matters. Patterns are checked one by one until one fits, and the most specific rule should be listed first.
2022-05-23 14:18:17 -07:00