Commit Graph

14720 Commits

Author SHA1 Message Date
Brian Vaughn a637084320
DevTools: Add Jest snapshot serializer for number formatting (#23139)
Numbers in JavaScript can have precision issues due to how they are encoded. This shows up in snapshot tests sometimes with values like 0.0009999999999999992, which makes the tests hard to read and visually diff.

This PR adds a new snapshot serializers which clamps numbers at 3 decimal points (e.g. the above number 0.0009999999999999992 is serialized as 0.001). This new serializer does not impact non-numeric values, integers, and special numbers like NaN and Infinity.
2022-01-20 15:52:17 -05:00
Brian Vaughn 505c15c9ef
Don't inject timeline hooks unless React supports profiling (#23151)
This gives DevTools a way to detect whether the current React renderer supports Timeline profiling. (Version alone isn't enough to detect this, neither is general profiling support– since these two are controlled by different feature flags.)
2022-01-20 11:11:26 -05:00
Douglas Armstrong e12a9dfc96
Fix production-only updateSyncExternalStore() crash when doing setState in render (#23150)
* Update ReactFiberHooks.new.js

* Add regression test + replace-fork

* Prettier

Co-authored-by: Dan Abramov <dan.abramov@me.com>
2022-01-20 15:22:17 +00:00
Ives van Hoorne 3fba8d64f1
Include other build types when building for CodeSandbox CI (#23152) 2022-01-20 15:20:02 +00:00
Dan Abramov e489402557
Warn when a callback ref returns a function (#23145) 2022-01-20 15:18:38 +00:00
Joey Arhar 05a55a4b09
Fix change events for custom elements (#22938)
* Bypass react event system for custom elements

* Going to try fixing react event system instead

* finally got it to call onChange, but perhaps too many times

* update test

* Removed ReactDOMComponent changes, now works but still doubles for bubbles

* Maybe i should only support bubbling events

* removed some old stuff

* cleaned up changeeventplugin stuff

* prettier, lint

* removed changeeventplugin stuff

* remove unneeded gate for onInput test

* Go back to using ChangeEventPlugin

* Add input+change test

* lint

* Move logic to shouldUseChangeEvent

* use memoizedProps instead of pendingProps

* Run form control behavior before custom element behavior

* add bubbling test

* forgot to append container to body

* add child event target test

* expand <input is=...> test expectations

* Make tests more realistic

* Add extra test

* Add missing gating

* Actually fix gating

Co-authored-by: Dan Abramov <dan.abramov@me.com>
2022-01-19 19:34:07 +00:00
Dan Abramov d8cfeaf221
Fix context propagation for offscreen/fallback trees (#23095)
* Failing test for Context.Consumer in suspended Suspense

See issue #19701.

* Fix context propagation for offscreen trees

* Address nits

* Specify propagation root for Suspense too

* Pass correct propagation root

* Harden test coverage

This test will fail if we remove propagation, or if we propagate with a root node like fiber.return or fiber.return.return. The additional DEV-only error helps detect a different kind of mistake, like if the thing being passed hasn't actually been encountered on the way up. However, we still leave the actual production loop to check against null so that there is no way we loop forever if the propagation root is wrong.

* Remove superfluous warning

Co-authored-by: overlookmotel <theoverlookmotel@gmail.com>
2022-01-19 16:30:34 +00:00
Brian Vaughn d504824780
Enable scheduling profiler flag in react-dom/testing builds (#23142) 2022-01-19 11:20:42 -05:00
Dan Abramov 790b5246f6
Fix setState ignored in Safari when iframe is added to DOM in the same commit (#23111)
* Fix setState being ignored in Safari

* Add a regression test

* Add comment
2022-01-18 18:25:34 +00:00
Brian Vaughn 51947a14bb
Refactored how React/DevTools log Timeline performance data (#23102)
Until now, DEV and PROFILING builds of React recorded Timeline profiling data using the User Timing API. This commit changes things so that React records this data by calling methods on the DevTools hook. (For now, DevTools still records that data using the User Timing API, to match previous behavior.)

This commit is large but most of it is just moving things around:

* New methods have been added to the DevTools hook (in "backend/profilingHooks") for recording the Timeline performance events.
* Reconciler's "ReactFiberDevToolsHook" has been updated to call these new methods (when they're present).
* User Timing method calls in "SchedulingProfiler" have been moved to DevTools "backend/profilingHooks" (to match previous behavior, for now).
* The old reconciler tests, "SchedulingProfiler-test" and "SchedulingProfilerLabels-test", have been moved into DevTools "TimelineProfiler-test" to ensure behavior didn't change unexpectedly.
* Two new methods have been added to the injected renderer interface: injectProfilingHooks() and getLaneLabelMap().

Relates to #22529.
2022-01-13 14:55:54 -05:00
Moti Zilberman c09596cc60
Add RN_FB bundles for react-is (#23101)
* Add RN_FB bundles for react-is

* Update packaging.js

* Add ReactNativeInternalFeatureFlags to externals
2022-01-12 21:53:50 +00:00
Joey Arhar a87adefecd
Allow functions to be passed to custom element setters (#23042)
This is part of the new custom element features that were implemented
here:
24dd07bd26

When a custom element has a setter for a property and passes the `in`
heuristic, the value passed to the react property should be assigned
directly to the custom element's property, regardless of the type of the
value. However, it was discovered that this isn't working with
functions. This patch makes it work with functions.

Fixes https://github.com/facebook/react/issues/23041
2022-01-12 20:12:07 +00:00
Stefan Sundin 9a7e6bf0d0
Add --no-show-signature to "git show" commands (#23038)
* Add --no-show-signature to "git show" commands.

This fixes errors if the user has configured the following in their ~/.gitconfig:
[log]
showSignature = true

* yarn prettier-all
2022-01-11 12:14:08 -05:00
Gray Zhang 2f26eb85d6
Add exports field to react-refresh's package.json (#23087)
* Add exports field to react-refresh's package.json

* Update package.json

* Add runtime to exports
2022-01-11 16:48:09 +00:00
Luna Ruan 811634762a
add enableTransitionTracing feature flag (#23079)
This PR adds the enableTransitionTracing feature flag
2022-01-10 12:32:40 -08:00
Jack Works fe905f152f
Update package.json (#22954) 2022-01-07 12:59:47 -08:00
Andrew Covenant fe419346da
Console message fixed for devtools (#23067) 2022-01-05 11:45:45 -05:00
Borja Paz Rodríguez 42c30e8b12
Correct typing errors detected in several files (#22965)
* Correct spelling errors in several files
* Correct typos in devtools-shared package files
2022-01-04 10:30:07 -05:00
Brian Vaughn 9724e18004
Run DevTools e2e tests on Circle CI (#23019) 2022-01-04 10:28:03 -05:00
btea 3dc41d8a25
fix: parseExportNamesInto specifiers typo (#22537) 2021-12-23 13:08:56 -05:00
BIKI DAS 20212349ad
Fix variable name (#23021) 2021-12-23 08:35:54 -05:00
BIKI DAS a8e9bbe0fe
Made the variable name more meaningful (#23017) 2021-12-22 15:58:06 -05:00
Brian Vaughn bcd24a6706
DevTools: Only show StrictMode badge on root elements (#23012)
* DevTools: Only show StrictMode badge on root elements

Showing an inline non-compliance badge for every element in the tree is noisy. This commit changes it so that we only show inline icons for root elements (although we continue to show an icon for inspected elements regardless).
2021-12-21 15:26:42 -05:00
Vitalie bd0a5dd682
#22988 - Fix Bug: @license header in React 18 bundles contains vundefined (#23004)
* Fix Bug: @license header in React 18 bundles contains vundefined
* Remove React version from the header comment
2021-12-21 12:27:59 -05:00
Brian Vaughn a4ead704ba
Use ReactDOM Test Selector API in DevTools e2e tests (#22978)
Builds on top of the existing Playwright tests to plug in the test selector API: https://gist.github.com/bvaughn/d3c8b8842faf2ac2439bb11773a19cec

My goals in doing this are to...
1. Experiment with the new API to see what works and what doesn't.
2. Add some test selector attributes (and remove DOM-structure based selectors).
3. Focus the tests on DevTools itself (rather than the test app).

I also took this opportunity to add a few new test cases– like named hooks, editable props, component search, and profiling- just to play around more with the Playwright API.

Relates to issue #22646
2021-12-21 11:58:04 -05:00
Sebastian Markbåge ceee524a8f
Remove unnecessary clearContainer call (#22979)
This was added when we added error recovery for hydration errors. However,
when the fix up pass happens later on, it'll still call clearContainer in
the commit phase. So this call is unnecessary.
2021-12-17 09:40:39 -08:00
Brian Vaughn aa8f2bdbce
Refactored DevTools test shell for e2e (#22968)
Fixes a regression in the e2e target and makes things easier (hopefully) going forward when adding new e2e tests.
2021-12-15 11:42:59 -05:00
Brian Vaughn e59233aa85
react-devtools-inline README updates (#22967) 2021-12-15 10:44:14 -05:00
Brian Vaughn 5b69c94eed
React DevTools 4.22.0 -> 4.22.1 (#22962) 2021-12-14 23:52:50 -05:00
Brian Vaughn b10c378024
Revert changes to react-devtools-inline Webpack config from PR #22760 (#22961) 2021-12-14 23:45:46 -05:00
Brian Vaughn 3f45b68141
Re-added deleted files array to react-devtools package.json (#22960) 2021-12-14 23:28:57 -05:00
Sebastian Markbåge cd1a3e9b55
Build both a partial renderer and fizz renderer of the legacy API for FB (#22933)
This lets us test how the new architecture performs without comparing it to
other infra changes related to streaming.

I renamed the streaming one to ReactDOMServerStreaming so the references
in www need to be updated.

I'll open an adhoc sync with just those files.
2021-12-14 16:19:19 -08:00
Brian Vaughn 75d34aa083
Updated DevTools changelog 2021-12-14 16:50:17 -05:00
jstejada 0229baee21
React DevTools 4.21.0 -> 4.22.0 (#22951) 2021-12-14 14:19:21 -05:00
Brian Vaughn 911f92a44d
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
jstejada 5757919256
DevTools: Correctly log errors reported from the store (#22950) 2021-12-13 12:02:14 -05:00
jstejada a049aa0155
[DevTools] Log errors occurring or reported to the frontend (#22948) 2021-12-13 11:38:45 -05:00
Brian Vaughn 3b3daf5573
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
Brian Vaughn 2c1cf5618a
DevTools should inject itself for XHTML pages too (not just HTML) (#22932) 2021-12-09 15:32:11 -05:00
salazarm f2a59df48b
Remove unstableAvoidThisFallback from OSS (#22884)
* avoidThisFallbackFlag

* avoidThisFallback flag

* missed a spot

* rm gating
2021-12-08 08:21:02 -08:00
Andrew Clark d3001fb6f1
Use `next` as prerelease label
Instead of `rc`, which is redundant since it's in the next version
number already.
2021-12-08 10:57:25 -05:00
Andrew Clark 29d2bef9f5
Bump beta -> rc 2021-12-08 10:51:41 -05:00
Joey Arhar 24dd07bd26
Add custom element property support behind a flag (#22184)
* custom element props

* custom element events

* use function type for on*

* tests, htmlFor

* className

* fix ReactDOMComponent-test

* started on adding feature flag

* added feature flag to all feature flag files

* everything passes

* tried to fix getPropertyInfo

* used @gate and __experimental__

* remove flag gating for test which already passes

* fix onClick test

* add __EXPERIMENTAL__ to www flags, rename eventProxy

* Add innerText and textContent to reservedProps

* Emit warning when assigning to read only properties in client

* Revert "Emit warning when assigning to read only properties in client"

This reverts commit 1a093e584c.

* Emit warning when assigning to read only properties during hydration

* yarn prettier-all

* Gate hydration warning test on flag

* Fix gating in hydration warning test

* Fix assignment to boolean properties

* Replace _listeners with random suffix matching

* Improve gating for hydration warning test

* Add outerText and outerHTML to server warning properties

* remove nameLower logic

* fix capture event listener test

* Add coverage for changing custom event listeners

* yarn prettier-all

* yarn lint --fix

* replace getCustomElementEventHandlersFromNode with getFiberCurrentPropsFromNode

* Remove previous value when adding event listener

* flow, lint, prettier

* Add dispatchEvent to make sure nothing crashes

* Add state change to reserved attribute tests

* Add missing feature flag test gate

* Reimplement SSR changes in ReactDOMServerFormatConfig

* Test hydration for objects and functions

* add missing test gate

* remove extraneous comment

* Add attribute->property test
2021-12-08 15:11:42 +00:00
Andrew Clark 72e48b8e16
Fix: Don't skip writing updated package.json
Another fix to previous commit. The special case for
use-sync-external-store still needs to write out the updated
package.json, because we also use that branch to update the
version field.
2021-12-08 02:56:43 -05:00
Andrew Clark e39b2c8998
Fix peer deps for use-sync-external-store
Merged last PR too quickly
2021-12-08 02:45:57 -05:00
Andrew Clark ec78b135fb
Don't override use-sync-external-store peerDeps (#22882)
Usually the build script updates transitive React dependencies so that
they refer to the corresponding release version.

For use-sync-external-store, though, we also want to support older
versions of React, too. So the normal behavior of the build script
isn't sufficient.

For now, to unblock, I hardcoded a special case, but we should consider
a better way to handle this in the future.
2021-12-07 23:26:12 -08:00
Andrew Clark 06f403481f
Add CI job to check npm dependencies (#22881)
Checks that if one React package depends on another, the current
version satisfies the given dependency range.

That way we don't forget to bump dependencies when we release a
new version.
2021-12-07 23:09:00 -08:00
Brian Vaughn ad607469c5
StyleX plug-in for resolving atomic styles to values for props.xstyle (#22808)
Adds the concept of "plugins" to the inspected element payload. Also adds the first plugin, one that resolves StyleX atomic style names to their values and displays them as a unified style object (rather than a nested array of objects and booleans).

Source file names are displayed first, in dim color, followed by an ordered set of resolved style values.

For builds with the new feature flag disabled, there is no observable change.

A next step to build on top of this could be to make the style values editable, but change the logic such that editing one directly added an inline style to the item (rather than modifying the stylex class– which may be shared between multiple other components).
2021-12-07 20:04:12 -05:00
salazarm 5041c37d27
Remove hydrate option from createRoot (#22878)
* remove hydrate: true option

* remove missed comment

* lint

* warning

* circumvent flow
2021-12-07 16:10:00 -05:00
salazarm c7917fe769
Test showing that a mismatch at the root recovers with client render but shows loading state (#22873)
* rm console.log

* gate test

* move test

* show fallback state
2021-12-06 12:36:02 -05:00