Commit Graph

50 Commits

Author SHA1 Message Date
Sebastian Markbåge
60016c448b Export React as Named Exports instead of CommonJS (#18106)
* Add options for forked entry points

We currently fork .fb.js entry points. This adds a few more options.

.modern.fb.js - experimental FB builds
.classic.fb.js - stable FB builds
.fb.js - if no other FB build, use this for FB builds
.experimental.js - experimental builds
.stable.js - stable builds
.js - used if no other override exists

This will be used to have different ES exports for different builds.

* Switch React to named exports

* Export named exports from the export point itself

We need to re-export the Flow exported types so we can use them in our code.

We don't want to use the Flow types from upstream since it doesn't have the non-public APIs that we have.

This should be able to use export * but I don't know why it doesn't work.

This actually enables Flow typing of React which was just "any" before.
This exposed some Flow errors that needs fixing.

* Create forks for the react entrypoint

None of our builds expose all exports and they all differ in at least one
way, so we need four forks.

* Set esModule flag to false

We don't want to emit the esModule compatibility flag on our CommonJS
output. For now we treat our named exports as if they're CommonJS.

This is a potentially breaking change for scheduler (but all those apis
are unstable), react-is and use-subscription. However, it seems unlikely
that anyone would rely on this since these only have named exports.

* Remove unused Feature Flags

* Let jest observe the stable fork for stable tests

This lets it do the negative test by ensuring that the right tests fail.

However, this in turn will make other tests that are not behind
__EXPERIMENTAL__ fail. So I need to do that next.

* Put all tests that depend on exports behind __EXPERIMENTAL__

Since there's no way to override the exports using feature flags
in .intern.js anymore we can't use these APIs in stable.

The tradeoff here is that we can either enable the negative tests on
"stable" that means experimental are expected to fail, or we can disable
tests on stable. This is unfortunate since some of these APIs now run on
a "stable" config at FB instead of the experimental.

* Switch ReactDOM to named exports

Same strategy as React.

I moved the ReactDOMFB runtime injection to classic.fb.js

Since we only fork the entrypoint, the `/testing` entrypoint needs to
be forked too to re-export the same things plus `act`. This is a bit
unfortunate. If it becomes a pattern we can consider forking in the
module resolution deeply.

fix flow

* Fix ReactDOM Flow Types

Now that ReactDOM is Flow type checked we need to fix up its types.

* Configure jest to use stable entry for ReactDOM in non-experimental

* Remove additional FeatureFlags that are no longer needed

These are only flagging the exports and no implementation details so we
can control them fully through the export overrides.
2020-02-25 13:54:27 -08:00
Sebastian Markbåge
09348798a9 Codemod to import * as React from "react"; (#18102)
* import * as React from "react";

This is the correct way to import React from an ES module since the ES
module will not have a default export. Only named exports.

* import * as ReactDOM from "react-dom"
2020-02-21 19:45:20 -08:00
Brian Vaughn
7e770dae93 Profiler tooltip tweaks (#18082)
* Moved Profiler views into Profiler folder

* Tweaked Profiler tooltip CSS styles

* Tweaked Tooltip positioning code
2020-02-19 10:58:45 -08:00
Moji Izadmehr
44e5f5e645 Add fiber summary tooltip to devtools profiling (#18048)
* Add tooltip component

* Separate logic of ProfilerWhatChanged to a component

* Add hovered Fiber info tooltip component

* Add flame graph chart tooltip

* Add commit ranked list tooltip

* Fix flow issues

* Minor improvement in filter

* Fix flickering issue

* Resolved issues on useCallbacks and mouse event listeners

* Fix lints

* Remove unnecessary useCallback
2020-02-19 09:44:31 -08:00
cutjavascript
901d76bc5c dataForRoots.set duplicate removal (#17993)
dataForRoots.set duplicate removal
2020-02-06 11:48:02 -08:00
Murat ÇATAL
cddde45806 apply changes on editablevalue on blur feature implemented (#17062)
* apply changes on editablevalue on blur feature implemented

* Removed "Undo" button and unnecessary event.preventDefault()

Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-02-04 11:05:01 -08:00
Dan Abramov
e706721490 Update Flow to 0.84 (#17805)
* Update Flow to 0.84

* Fix violations

* Use inexact object syntax in files from fbsource

* Fix warning extraction to use a modern parser

* Codemod inexact objects to new syntax

* Tighten types that can be exact

* Revert unintentional formatting changes from codemod
2020-01-09 14:50:44 +00:00
Dan Abramov
b979db4e72 Bump Prettier (#17811)
* Bump Prettier

* Reformat

* Use non-deprecated option
2020-01-09 13:54:11 +00:00
Brian Vaughn
c1b573bf2f Merge branch 'scope-devtools-styles' of https://github.com/GasimGasimzada/react into GasimGasimzada-scope-devtools-styles 2020-01-06 10:13:35 -08:00
Brian Vaughn
24f824250f DevTools Profiler: Improve how empty commits are filtered (#17771)
Previously, DevTools filtered empty commits on the backend, while profiling, through the use of a bailout heuristic that React currently happens to use. This approach was brittle and may have exacerbated the long-standing Profiler bug #16446.

This PR removes that heuristic and adds as a post-processing filtering pass instead. This removes the coupling between DevTools and a React internal implementation detail that may change.

I believe DevTools has two choices of criteria for this filtering:
* Filter commits that have no actual duration metadata.
* Filter commits that have no recorded operations (no mutations to the tree, no changed tree base durations).

I chose the first option, filtering by commits that have no reported metadata. It will miss an edge case, e.g. , but we would have nothing meaningful to show in the Profiler for those cases anyway. (This particular edge case is why one of the snapshots changed with this commit.)

The second option, filtering by recorded operations, could potentially miss a more important edge case: where a component *did* render, but its  didn't change. (In that event, there would be no operations to send.)
2020-01-04 16:50:39 -08:00
Gasim Gasimzada
9cc094a19a Scope dev tools wildcard styles within DevTools CSS class 2020-01-04 14:04:15 +04:00
Brian Vaughn
7e2ab87a61 DevTools: Replaced unsafe hasOwnProperty() calls (#17768)
DevTools previously called  in several places with user-defined values. This could lead to runtime errors if those values had an overriden  attribute. This commit replaces those callse with  instead.

New test cases have been added.
2020-01-03 09:34:12 -08:00
Brian Vaughn
cca994c6a1 DevTools Profiler commit selector wraps around (#17760)
I used to disable the <- and -> buttons when you reached the beginning or end of the profiler data. This can be kind of annoying though when you just want to get to the last commit, and I don't think there's a good reason to enforce it anyway, so I backed that change out. The buttons now wrap around at the beginning or end of the list.
2020-01-02 14:44:07 -08:00
Chris Watson
9357a483e9 Fix for the standalone devtools not responding to clicks. (#17584) 2019-12-29 13:46:27 -08:00
Brian Vaughn
22ef96ae63 Devtools renable copy attr context menu for firefox (#17740)
* Use exportFunction() to share clipboard copy with JS running in document/page context.

* Remove no-longer-used option to disable copy operation.
2019-12-29 13:27:44 -08:00
Brian Vaughn
0eac01abcd Added missing Flow type coverage to DevTools context menu (#17733)
The  param should probably be a generic type, but I'm not sure how to satisfy Flow with the current top-level  Map. At least this adds basic coverage (which was missing before, oops).
2019-12-29 08:44:24 -08:00
Brian Vaughn
1959671d45 Add tooltip to interaction name in DevTools Profiler sidebar (#17689) 2019-12-22 08:52:53 -08:00
Maxime Bouveron
6215e1c2db Add Shift+Enter to go to previous search result (#17005) 2019-12-22 08:38:14 -08:00
Brian Vaughn
79734771cd Disable "copy to clipboard" and "go to definition" context menu options for Firefox addon (#17668) 2019-12-20 08:31:38 -08:00
Brian Vaughn
933f6a07ca DevTools context menu (#17608)
* Added rudimentary context menu hook and menu UI

* Added backend support for copying a value at a specific path for the inspected element

* Added backend support for storing a value (at a specified path) as a global variable

* Added special casing to enable copying undefined/unserializable values to the clipboard

* Added copy and store-as-global context menu options to selected element props panel

* Store global variables separately, with auto-incremented name (like browsers do)

* Added tests for new copy and store-as-global backend functions

* Fixed some ownerDocument/contentWindow edge cases

* Refactored context menu to support dynamic options

Used this mechanism to add a conditional menu option for inspecting the current value (if it's a function)

* Renamed "safeSerialize" to "serializeToString" and added inline comment
2019-12-18 12:12:34 -08:00
Brian Vaughn
bb75a4fa89 Improved selection and toggling for props/hooks/state (#17588)
1. Enable nested values to be expanded/collapsed by clicking on values as well as keys.
2. Enable keys and values to be selectable (for copy-pasting purposes)
2019-12-17 11:28:37 -08:00
Brian Vaughn
12c000412d Improved inspected element props with inline previews (#17579)
* Improved inspected element props with inline previews

This mimics the inline preview shown by the brower console and dramatically improves the UX when inspecting deep values. I also updated tests to add more coverage for this new functionality.

* Cleaned up the DataView vs typed array check

* Added early bailouts to DevTools when generating preview strings for iterables/objects/arrays, to avoid doing unnecessary work
2019-12-11 17:52:17 -08:00
Brian Vaughn
031a5aaffb Show component location for selected element in bottom/right of props panel (#17567)
* Show component location info for selected element in bottom/right of props panel

* Moved RegExp declaration into function basedon PR feedback
2019-12-10 09:24:34 -08:00
Farhad Yasir
5235d193d7 fix: make serializable data in react-devtools (#17233)
* fix: make serializable data for bridge in react-devtools

* fix: add bigint data type in hydration

* refactor: remove console.log

* test: update unit tests for bigint in react-devtools
2019-12-04 15:53:00 +00:00
Brian Vaughn
3452706308 DevTools cleanup (#17283)
1. Add a Store test for memo, lazy, and forwardRef components
2. Remove dead code for React.lazy
3. Update DT tests to include HOC badge names in the serialized store
2019-11-05 22:19:10 -08:00
Brian Vaughn
5faf377df5 Fixed a style bug in props editor (#17162) 2019-10-21 15:08:55 -07:00
Brian Vaughn
0545f366d4 Added trace updates feature (DOM only) (#16989)
* Added trace updates feature (DOM only)
* Updated DevTools CHANGELOG
2019-10-03 11:07:18 -07:00
Brian Vaughn
d4278663c6 Replaced === check with Object.is() to support values like NaN (#16934) 2019-09-27 16:54:53 -07:00
Brian Vaughn
b6606ecba8 DevTools shows unsupported renderer version dialog (#16897)
* DevTools shows unsupported renderer version dialog

* Optimistic CHANGELOG udpate
2019-09-26 08:41:46 -07:00
Brian Vaughn
fa1a326227 Update useEditableValue hook to sync external value changes (#16878)
* Update useEditableValue to mirror value cahnges

Previously, the hook initialized local state (in useState) to mirror the prop/state value. Updates to the value were ignored though. (Once the state was initialized, it was never updated.) The new hook updates the local/editable state to mirror the external value unless there are already pending, local edits being made.

* Optimistic CHANGELOG update

* Added additional useEditableValue() unit test cases
2019-09-25 10:46:27 -07:00
Brian Vaughn
9b3cde9b62 Fix DevTools v4.1 editable hook regression (#16867)
* Fixed a regression in hooks editor from a recent EditableValue change

* Fixed a reset/state bug in useEditableValue() hook and removed unnecessary useMemo()
2019-09-23 12:56:01 -07:00
Dan Abramov
4ddcb8e134 [DevTools] Remove Welcome dialog (#16834) 2019-09-19 08:41:18 -07:00
Brian Vaughn
2c98af77c3 DevTools: Props editing interface tweaks (#16740)
* Fix DevTools new prop input size
* Don't allow adding new values unless an overridePropsFn function has been provided.
* Do not show empty 'none' label ablve a new prop input
2019-09-10 14:57:33 -07:00
Hristo Kanchev
709baf1fec [DevTools] Support for adding props | Improved state/props value editing (#16700)
* Extracted sanitizeForParse

* Added canAddEntries flag to InspectedElementTree

* Added EditableKey component.

* Added support to add an additional entry.

* Added support to add more complex data structures in the EditableValue component. Added support to change the dataType of the value that is being changed.

* Fixed flow error.

* Removed unneeded fragment.

* Renamed EditableKey -> EditableName

* Removed unneeded dependency

* Removed problematic props to state hook.

* Prettified changes.

* Removed unused import.

* Fixed shouldStringify check.

* Removed testing props from EditableProps.

* Made some inline tweaks
2019-09-10 13:30:43 -07:00
Hristo Kanchev
4ef6387d6e [DevTools] [Context] Legacy Context (#16617)
* Added hasLegacyContext check.

* Passed hasLegacyContext as prop to SelectedElement

* Changing context labels based on hasLegacyContext

* Fixed flow types.

* Fixed typos.

* Added tests for hasLegacyContext.

* Renamed test.

* Removed test imports.
2019-09-10 13:30:20 -07:00
Hristo Kanchev
4905590e1e Fixed font family issue in FF. (#16701) 2019-09-09 16:21:04 -07:00
Alex Rohleder
206d61f722 fix typos on react-devtools comments (#16681) 2019-09-06 07:47:44 -07:00
Hristo Kanchev
77bb102398 [DevTools] [Profiler]: Save profile now working in Firefox (#16612)
* Added anchor dom element in order to successfully download profiling data.
* Reworked downloadFile to accept a DOMElement in order for FF to successfully download profiling data.
* Prettify downloadFile changes.
2019-09-03 08:35:12 -07:00
Brian Vaughn
7153dd516f Fixed a StyleEditor variable resolution regression 2019-08-27 12:53:38 -07:00
Brian Vaughn
8e1434e80e Added FB copyright header 2019-08-27 10:54:01 -07:00
Brian Vaughn
8c684bf7e1 Removed forked DevTools Flow types 2019-08-27 10:42:02 -07:00
Brian Vaughn
66c9fedc34 Flow fixes 2019-08-20 13:33:33 -07:00
Brian Vaughn
4da836af71 Merged changes from 4.0.0 -> 4.0.5 from DevTools fork 2019-08-20 11:34:51 -07:00
Brian Vaughn
4078167255 Removed (no longer necessary) node->node-events mapping 2019-08-14 11:43:59 -07:00
Brian Vaughn
30b8ef3756 Iterated on Webpack configs until I got the inline and shell packages seemingly working 2019-08-14 09:24:35 -07:00
Brian Vaughn
ac2e861fbe Fixed a bunch of Lint issues 2019-08-13 21:59:07 -07:00
Brian Vaughn
183f96f2ac Prettier 2019-08-13 17:58:03 -07:00
Brian Vaughn
edc46d7be7 Misc Flow and import fixes
1. Fixed all reported Flow errors
2. Added a few missing package declarations
3. Deleted ReactDebugHooks fork in favor of react-debug-tools
2019-08-13 17:53:28 -07:00
Brian Vaughn
08743b1a8e Reorganized folders into packages/* 2019-08-13 15:59:43 -07:00
Brian Vaughn
ec7ef50e8b Reorganized things again into packages 2019-08-13 11:37:25 -07:00