Commit Graph
14506 Commits
Author SHA1 Message Date
Andrew ClarkandGitHub 1056269c71 Add back useMutableSource temporarily (#22396)
Recoil uses useMutableSource behind a flag. I thought this was fine
because Recoil isn't used in any concurrent roots, so the behavior
would be the same, but it turns out that it is used by concurrent
roots in a few places.

I'm not expecting it to be hard to migrate to useSyncExternalStore, but
to de-risk the change I'm going to roll it out gradually with a flag. In
the meantime, I've added back the useMutableSource API.
2021-09-21 20:38:24 -07:00
Andrew ClarkandGitHub 2baf525eab Scrape warning messages in CI (#22393)
There's a downstream workflow that runs the `print-warnings` command. We
can make it faster by scraping the warnings in CI and storing the
result as a build artifact.
2021-09-21 19:03:01 -07:00
Andrew ClarkandGitHub 7b6c5fee84 Fix sizebot mistakenly detecting deleted files (#22394) 2021-09-21 18:55:47 -07:00
Andrew ClarkandGitHub 33027b6c2a Increase polling threshold for publish-prereleases (#22392)
The publish-preleases command prints the URL of the publish workflow
so that you can visit the page and follow along.

But it can take a few seconds before the workflow ID is available, after
you create the pipeline. So the script polls the workflow endpoint
until it's available.

The current polling limit is too low so I increased it.

I also updated the error message to provide more info.
2021-09-21 18:43:59 -07:00
Luna RuanandGitHub 72bbc8c6c4 [Draft] don't patch console during first render (#22308)
Previously, DevTools always overrode the native console to dim or supress StrictMode double logging. It also overrode console.log (in addition to console.error and console.warn). However, this changes the location shown by the browser console, which causes a bad developer experience. There is currently a TC39 proposal that would allow us to extend console without breaking developer experience, but in the meantime this PR changes the StrictMode console override behavior so that we only patch the console during the StrictMode double render so that, during the first render, the location points to developer code rather than our DevTools console code.
2021-09-21 15:00:11 -07:00
Andrew ClarkandGitHub e67b1c6469 Delete all but one build2 reference (#22391)
This removes all the remaining references to the `build2` directory
except for the CI job that stores the artifacts. We'll keep the
`build2` artifact until downstream scripts are migrated to `build`.
2021-09-21 13:15:41 -07:00
Andrew Clark 02e416a806 [build2 -> build] Local scripts
Update all our local scripts to use `build` instead of `build2`.

There are still downstream scripts that depend on `build2`, though, so
we can't remove it yet.
2021-09-21 15:14:09 -04:00
Andrew Clark 27970a6b59 [build -> build2] Sizebot 2021-09-21 15:07:16 -04:00
Andrew Clark 1ac97fa7f9 Delete unused CI jobs
These were replaced by the `build_combined` job.
2021-09-21 15:06:09 -04:00
Andrew Clark 290eeb6897 [build2 -> build] -> download-build-artifacts 2021-09-21 13:47:40 -04:00
Andrew Clark 3b961b7b75 Add COMMIT_SHA to build directory 2021-09-21 13:41:58 -04:00
Andrew Clark 9be7b05af3 Write artifacts to build instead of build2
Now that all the CI jobs have been migrated to the new build script,
we can start renaming the `build2` directory to `build`.

Since there are lots of scripts that reference `build2`, including
downstream scripts that live outside this repo, I'm going to keep
the `build2` directory around as a copy of `build`.

Then once all the references are updated, I will delete the copy.
2021-09-21 12:23:48 -04:00
Andrew ClarkandGitHub 03dc7111e1 Move build_devtools_and_process_artifacts (#22388)
This is the last CI job that needs to be migrated to the new workflow.
2021-09-21 08:51:51 -07:00
Andrew ClarkandGitHub 4a71519f08 Move lint job to new, combined CI workflow (#22386)
* Move lint job to new, combined CI workflow

Moves the lint job our new, combined CI workflow.

After this, there is only one job remaining to be migrated. Then we
can delete the old workflow and build script.

* Remove "stable" CI workflow

This workflow is now empty so we can remove it
2021-09-21 08:16:26 -07:00
salazarmandGitHub 4bfa3f7219 useSyncExternalStore React Native version (#22367) 2021-09-21 11:07:56 -04:00
d6d02354d2 correct typos (#22294)
Co-authored-by: Bowen Li <[email protected]>
2021-09-21 11:05:41 -04:00
Andrew ClarkandGitHub 895e7f639c Move DOM fixtures test job to main CI workflow (#22385)
Moves the RELEASE_CHANNEL_stable_yarn_test_dom_fixtures job to our new,
combined CI workflow.

After this, there are only two jobs remaining to be migrated. Then we
can delete the old workflow and build script.
2021-09-21 08:00:28 -07:00
Sebastian SilbermannandGitHub 38fc787487 Remove Fiber fields that were used for hydrating useMutableSource (#22368) 2021-09-20 21:12:30 +01:00
salazarmandGitHub bc55431c09 [Fizz] add avoidThisFallback support (#22318) 2021-09-20 15:44:48 -04:00
38elementsandGitHub 03d4d78443 Fix links in packages/react-devtools/README.md (#22356) 2021-09-20 15:10:29 -04:00
Konstantin PopovandGitHub ac8fe668f3 Fix typo in types.js (react-devtools-shared) (#22299)
Fix typo:

becuase -> because
2021-09-20 15:09:59 -04:00
BIKI DASandGitHub ee814ff109 react-devtools\OVERVIEW.md --> fixed typos (#22372) 2021-09-20 15:09:37 -04:00
Brian VaughnandGitHub a1ba3e97a6 Enabled enableProfilerChangedHookIndices feature flag for all builds (#22365) 2021-09-20 13:10:50 -04:00
Sebastian SilbermannandGitHub 154d6230b0 devtools: Display actual ReactDOM API name in root type (#22363) 2021-09-20 11:44:21 -04:00
Andrew ClarkandGitHub 4221366c7b Implement getServerSnapshot in userspace shim (#22359)
* Convert useSES shim tests to use React DOM

Idea is that eventually we'll run these tests against an actual build of
React DOM 17 to test backwards compatibility.

* Implement getServerSnapshot in userspace shim

If the DOM is not present, we assume that we are running in a server
environment and return the result of `getServerSnapshot`.

This heuristic doesn't work in React Native, so we'll need to provide
a separate native build (using the `.native` extension). I've left this
for a follow-up.

We can't call `getServerSnapshot` on the client, because in versions of
React before 18, there's no built-in mechanism to detect whether we're
hydrating. To avoid a server mismatch warning, users must account for
this themselves and return the correct value inside `getSnapshot`.

Note that none of this is relevant to the built-in API that is being
added in 18. This only affects the userspace shim that is provided
for backwards compatibility with versions 16 and 17.
2021-09-20 08:32:13 -07:00
Andrew ClarkandGitHub 6f0f50c53b Implement useSyncExternalStore on server (#22347)
Adds a third argument called `getServerSnapshot`.

On the server, React calls this one instead of the normal `getSnapshot`.
We also call it during hydration.

So it represents the snapshot that is used to generate the initial,
server-rendered HTML. The purpose is to avoid server-client mismatches.
What we render during hydration needs to match up exactly with what we
render on the server.

The pattern is for the server to send down a serialized copy of the
store that was used to generate the initial HTML. On the client, React
will call either `getSnapshot` or `getServerSnapshot` on the client as
appropriate, depending on whether it's currently hydrating.

The argument is optional for fully client rendered use cases. If the
user does attempt to omit `getServerSnapshot`, and the hook is called
on the server, React will abort that subtree on the server and
revert to client rendering, up to the nearest Suspense boundary.

For the userspace shim, we will need to use a heuristic (canUseDOM)
to determine whether we are in a server environment. I'll do that in
a follow up.
2021-09-20 08:31:02 -07:00
Brian VaughnandGitHub 3bf2bb4866 replace-fork: Cleanup after failure if no unstaged changes (#22364) 2021-09-20 11:10:17 -04:00
Andrew ClarkandGitHub 719a15957b replace-fork should not clear uncommitted changes (#22348)
The replace-fork script depends on ESLint to fix the reconciler imports
— `.old` -> `.new` or vice versa. If ESLint crashes, it can leave the
imports in an incorrect state.

As a convenience, @bvaughn updated the script to automatically run
`git checkout -- .` if the ESLint command fails. An unintended
consequence of the strategy is that if the working directory is not
clean, then any uncommitted changes will be lost.

We need a better strategy for this that prevents the accidental loss of
work. One option is to exit early if the working directory is not clean
before you run the script, though that affects the usability of
the script.

An ideal solution would reset the working directory back to whatever
state it was in before the script ran, perhaps by stashing all the
changes and restoring them if the script aborts.

Until we think of something better, I've commmented out the branch.
2021-09-20 10:07:25 -04:00
Andrew ClarkandGitHub 096f26225b Delete useMutableSource implementation (#22292)
This API was replaced by useSyncExternalStore
2021-09-19 21:11:50 -07:00
Brian VaughnandGitHub c76e229f21 DevTools: Fix memory leak via alternate Fiber pointer (#22346) 2021-09-17 12:53:07 -04:00
Brian VaughnandGitHub b87d923685 Clear performance marks after measuring (#22345) 2021-09-17 10:46:42 -04:00
JuanandGitHub 2cea2a653d [DevTools] Enable hook names in standalone app (#22320) 2021-09-17 10:21:54 -04:00
Brian VaughnandGitHub ffff2c4036 Updated the utfDecodeString() method to avoid call stack exceeded error (#22330) 2021-09-17 09:52:52 -04:00
BIKI DASandGitHub f2726b65ac VerticalScrollView -> fixed typos (#22341) 2021-09-17 09:05:09 -04:00
Ikko AshimineandGitHub 93a9933f6f Scheduling profiler: Fix typo in View.js (#22337) 2021-09-17 09:04:51 -04:00
JuanandGitHub 637c91068a [DevTools] Fix runtime error when inspecting an element times out (#22329) 2021-09-15 17:19:10 -04:00
Abhay GuptaandGitHub 7ee74d943c Fixed issue for better bundles,chunks and workers name in devtools-extensions. (#22322) 2021-09-15 13:51:33 -04:00
Brian VaughnandGitHub a5ae504402 Fixed broken build script --unsafe-partial flag (#22324)
This flag was broken due to a buggy race case in the ncp() command. The fix is amittedly a hack but improves on the existing behavior (of leaving the workspace in a broken state).
2021-09-15 13:32:09 -04:00
Dan AbramovandGitHub a53b907c61 [Experiment] Warn if callback ref returns a function (#22313) 2021-09-15 13:51:39 +01:00
JuanandGitHub b43d3a26ab [DevTools] Add initial APIs for logging instrumentation events under feature flag (#22276) 2021-09-14 11:10:24 -04:00
RickyandGitHub 9a4cfc4005 [Experimental] Add useInsertionEffect (#21913) 2021-09-14 10:27:09 -04:00
Andrew ClarkandGitHub 58f89d4b26 [useSES shim] Import prefixed native API (#22310)
Until useSyncExternalStore is finalized, the shim should import the
prefixed version (unstable_useSyncExternalStore), which is available
in the experimental builds. That way our early testers can start
using it.
2021-09-13 21:55:18 -07:00
Andrew ClarkandGitHub bf6f1d1ed5 [useSES/extra] Reuse old selection if possible (#22307)
When you pass an unmemoized selector to useSyncExternalStoreExtra, we
have to reevaluate it on every render because we don't know whether
it depends on new props.

However, after reevalutating it, we should still compare the result
to the previous selection with `isEqual` and reuse the old one if it
hasn't changed.

Originally I did not implement this, because if the selector changes due
to new props or state, the component is going to have to re-render
anyway. However, it's still useful to return a memoized selection
when possible, because it may be the input to a downstream memoization.

In the test I wrote, the example I chose is selecting a list of
items from the store, and passing the list as a prop to a memoized
component. If the list prop is memoized, we can bail out.
2021-09-13 14:26:41 -07:00
Andrew ClarkandGitHub 236de9548d Check for store mutations before commit (#22290)
* [useSyncExternalStore] Remove extra hook object

Because we already track `getSnapshot` and `value` on the store
instance, we don't need to also track them as effect dependencies. And
because the effect doesn't require any clean-up, we don't need to track
a `destroy` function.

So, we don't need to store any additional state for this effect. We can
call `pushEffect` directly, and only during renders where something
has changed.

This saves some memory, but my main motivation is because I plan to use
this same logic to schedule a pre-commit consistency check. (See the
inline comments for more details.)

* Split shouldTimeSlice into two separate functions

Lanes that are blocking (SyncLane, and DefaultLane inside a blocking-
by-default root) are always blocking for a given root. Whereas expired
lanes can expire while the render phase is already in progress.

I want to check if a lane is blocking without checking whether it
expired, so I split `shouldTimeSlice` into two separate functions.

I'll use this in the next step.

* Check for store mutations before commit

When a store is read for the first time, or when `subscribe` or
`getSnapshot` changes, during a concurrent render, we have to check
at the end of the render phase whether the store was mutated by
an concurrent event.

In the userspace shim, we perform this check in a layout effect, and
patch up any inconsistencies by scheduling another render + commit.
However, even though we patch them up in the next render, the parent
layout effects that fire in the original render will still observe an
inconsistent tree.

In the native implementation, we can instead check for inconsistencies
right after the root is completed, before entering the commit phase. If
we do detect a mutaiton, we can discard the tree and re-render before
firing any effects. The re-render is synchronous to block further
concurrent mutations (which is also what we do to recover from tearing
bugs that result in an error). After the synchronous re-render, we can
assume the tree the tree is consistent and continue with the normal
algorithm for finishing a completed root (i.e. either suspend
or commit).

The result is that layout effects will always observe a consistent tree.
2021-09-13 08:07:46 -07:00
Konstantin PopovandGitHub 7dfa07e72b Fix link (#22296)
Fix link (branch master was renamed to main): 

master -> main
2021-09-12 11:09:53 -04:00
RickyandGitHub b21fb71e83 Clean up my "hard to read" code (#22295) 2021-09-11 15:05:54 -04:00
Brian VaughnandGitHub f4f89ffb5b DevTools: Add missing param to fetchFromPage() (#22291) 2021-09-10 16:26:46 -04:00
Brian VaughnandGitHub 2ff67158c6 Replaced network.onRequestFinished() caching with network.getHAR() (#22285)
Replaced network.onRequestFinished() caching with network.getHAR() so that we can avoid redundantly (pre) caching JavaScript content. In the event that the HAR log doesn't contain a match, we'll fall back to fetching from the Network (and hoping for a cache hit from that layer).

I've tested both internally (internal Facebook DEV server) and externally (Code Sandbox) and it seems like this approach results in cache hits, so long as DevTools is opened when the page loads. (Otherwise it falls back to fetch().)
2021-09-10 15:11:18 -04:00
539291c8d3 update error message to include useLayoutEffect or useEffect on bad e… (#22279)
* update error message to include useLayoutEffect or useEffect on bad effect return

* Update packages/react-reconciler/src/ReactFiberCommitWork.new.js

Co-authored-by: Ricky <[email protected]>

* use existing import

Co-authored-by: Ricky <[email protected]>
2021-09-10 12:19:51 -04:00
Luna RuanandGitHub 605e66f5f4 [DevTools] Add React Devtools Extension Startup and File Structure to OVERVIEW.md (#22283) 2021-09-09 15:58:27 -07:00