Commit Graph

15414 Commits

Author SHA1 Message Date
poteto 562294de06 [DiffTrain] Add REVISION and REVISION_TRANSFORM to output (#25830)
We use these for the sync script, so to preserve option value let's
continue adding these files so the script can still be used for
arbitrary commits.

DiffTrain build for `c961f2f476092a138da5082dfc12916d85509649`
2022-12-06 18:03:38 +00:00
poteto 2b6133e035 [DiffTrain] Strip @license from files (#25821)
We need to remove this for some internal tests. This was previously in
our upgrade script so adding it back here for parity.

Test plan: files were updated correctly
[[1]](https://github.com/facebook/react/commit/1704bbb8268345bf7aa405101313b3639e03e221#diff-80b968e05ce2ceeff6e17c938dc722aff2c1c660f8ef402e6664bc5b2cafa5fbL2)
[[2]](https://github.com/facebook/react/commit/1704bbb8268345bf7aa405101313b3639e03e221#diff-6ecd07a61c8e0e28793dace3f9f62751e4808de9c2965aa1ddeb0157f3c9b4ecL2)

Co-authored-by: Jan Kassens <jkassens@meta.com>

DiffTrain build for `7c39922891bf8e0ce179a78a373a61b3afe3c1c7`
2022-12-06 17:08:46 +00:00
kassens 30bcb2a2eb Bump qs from 6.4.0 to 6.4.1 in /fixtures/attribute-behavior (#25820)
Bumps [qs](https://github.com/ljharb/qs) from 6.4.0 to 6.4.1.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/ljharb/qs/blob/main/CHANGELOG.md">qs's
changelog</a>.</em></p>
<blockquote>
<h2><strong>6.4.1</strong></h2>
<ul>
<li>[Fix] <code>parse</code>: ignore <code>__proto__</code> keys (<a
href="https://github-redirect.dependabot.com/ljharb/qs/issues/428">#428</a>)</li>
<li>[Fix] fix for an impossible situation: when the formatter is called
with a non-string value</li>
<li>[Fix] use <code>safer-buffer</code> instead of <code>Buffer</code>
constructor</li>
<li>[Fix] <code>utils.merge</code>: avoid a crash with a null target and
an array source</li>
<li>[Fix]<code> </code>utils.merge`: avoid a crash with a null target
and a truthy non-array source</li>
<li>[Fix] <code>stringify</code>: fix a crash with
<code>strictNullHandling</code> and a custom
<code>filter</code>/<code>serializeDate</code> (<a
href="https://github-redirect.dependabot.com/ljharb/qs/issues/279">#279</a>)</li>
<li>[Fix] <code>utils</code>: <code>merge</code>: fix crash when
<code>source</code> is a truthy primitive &amp; no options are
provided</li>
<li>[Fix] when <code>parseArrays</code> is false, properly handle keys
ending in <code>[]</code></li>
<li>[Robustness] <code>stringify</code>: avoid relying on a global
<code>undefined</code> (<a
href="https://github-redirect.dependabot.com/ljharb/qs/issues/427">#427</a>)</li>
<li>[Refactor] use cached <code>Array.isArray</code></li>
<li>[Refactor] <code>stringify</code>: Avoid arr = arr.concat(...), push
to the existing instance (<a
href="https://github-redirect.dependabot.com/ljharb/qs/issues/269">#269</a>)</li>
<li>[readme] remove travis badge; add github actions/codecov badges;
update URLs</li>
<li>[Docs] Clarify the need for &quot;arrayLimit&quot; option</li>
<li>[meta] fix README.md (<a
href="https://github-redirect.dependabot.com/ljharb/qs/issues/399">#399</a>)</li>
<li>[meta] Clean up license text so it’s properly detected as
BSD-3-Clause</li>
<li>[meta] add FUNDING.yml</li>
<li>[actions] backport actions from main</li>
<li>[Tests] remove nonexistent tape option</li>
<li>[Dev Deps] backport from main</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/ljharb/qs/commit/486aa46547b4e878d6e87183de95dd26d46fb020"><code>486aa46</code></a>
v6.4.1</li>
<li><a
href="https://github.com/ljharb/qs/commit/727ef5d34605108acb3513f72d5435972ed15b68"><code>727ef5d</code></a>
[Fix] <code>parse</code>: ignore <code>__proto__</code> keys (<a
href="https://github-redirect.dependabot.com/ljharb/qs/issues/428">#428</a>)</li>
<li><a
href="https://github.com/ljharb/qs/commit/cd1874eb179950de3f5b32e708b4a3a2d0619501"><code>cd1874e</code></a>
[Robustness] <code>stringify</code>: avoid relying on a global
<code>undefined</code> (<a
href="https://github-redirect.dependabot.com/ljharb/qs/issues/427">#427</a>)</li>
<li><a
href="https://github.com/ljharb/qs/commit/45e987c6038db47199a560294c20a67da9ab49e3"><code>45e987c</code></a>
[readme] remove travis badge; add github actions/codecov badges; update
URLs</li>
<li><a
href="https://github.com/ljharb/qs/commit/90a3bced518c6ff4a97919d10de9498fea961acf"><code>90a3bce</code></a>
[meta] fix README.md (<a
href="https://github-redirect.dependabot.com/ljharb/qs/issues/399">#399</a>)</li>
<li><a
href="https://github.com/ljharb/qs/commit/9566d25019caae8c4f1a9097bf344238a583d014"><code>9566d25</code></a>
[Fix] fix for an impossible situation: when the formatter is called with
a no...</li>
<li><a
href="https://github.com/ljharb/qs/commit/74227ef022282881f41d37d65adba5d399d2b33a"><code>74227ef</code></a>
Clean up license text so it’s properly detected as BSD-3-Clause</li>
<li><a
href="https://github.com/ljharb/qs/commit/35dfb227e274367e163b3d943fc975f95448685a"><code>35dfb22</code></a>
[actions] backport actions from main</li>
<li><a
href="https://github.com/ljharb/qs/commit/7d4670fca6ed46a1fc6237bccffe0ea82a641411"><code>7d4670f</code></a>
[Dev Deps] backport from main</li>
<li><a
href="https://github.com/ljharb/qs/commit/0485440902d3fc03d1d973d91af5a183fa4e3059"><code>0485440</code></a>
[Fix] use <code>safer-buffer</code> instead of <code>Buffer</code>
constructor</li>
<li>Additional commits viewable in <a
href="https://github.com/ljharb/qs/compare/v6.4.0...v6.4.1">compare
view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=qs&package-manager=npm_and_yarn&previous-version=6.4.0&new-version=6.4.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the
default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as
the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as
the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the
default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/facebook/react/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

DiffTrain build for `2f16409f3a40de334973abdcba08e09284ed1c9d`
2022-12-06 16:59:09 +00:00
poteto 1704bbb826 [DiffTrain] Strip @license from files
DiffTrain build for `29bb7f8a2fbdbb5d8a6e95c4ba6221d9c50d23af`
2022-12-06 16:45:18 +00:00
acdlite 1d718367ec Revert recent hydration changes (#25812)
We're reverting the stack of changes that this code belongs to in order
to unblock the sync to Meta's internal codebase. We will attempt to
re-land once the sync is unblocked.

I have not yet verified that this fixes the error that were reported
internally. I will do that before landing.

DiffTrain build for `d807eb52cfd999cfbcb19078a75b15f844e409bb`
2022-12-05 21:17:13 +00:00
kassens 98926ac94e Fork ReactDOMSharedInternals for www (#25791)
This isn't the right way to do this, but internally we have some
restrictions so we need to add an indirection. Let's land this now so we
can catch up our sync and then fix forward from there.

Co-authored-by: Jan Kassens <jkassens@meta.com>

DiffTrain build for `2ccfa657d9529cab25eaa25144efc64df12b13c7`
2022-12-05 20:33:42 +00:00
poteto cf2ede19b3 [DiffTrain] Use original commit message (#25809)
Instead of the current commit message (which just shows "Build for
<sha>", re-use the commit message from the origin commit instead.

DiffTrain build for `cd23e40c734d758726419c0a3bd91576211bd83f`
2022-12-05 19:03:53 +00:00
poteto f965082ab3 [DiffTrain] Use original commit message
Instead of the current commit message (which just shows "Build for
<sha>", re-use the commit message from the origin commit instead.

Built for DiffTrain for `4b8a8376689cc70225b36a59ea71992e36c3a90f)`
2022-12-05 18:45:21 +00:00
poteto db7a745bd1 (59c2f19acedd7de7fd548bc6921d7174a724165c) [DiffTrain] @nocommit Test that it works
Not to be committed, just for testing
2022-12-05 18:15:31 +00:00
tyao1 3182effe80 Build for f0534ae94a 2022-12-03 01:14:49 +00:00
gaearon c754cbd613 Build for 7fab379d8e 2022-12-02 17:48:30 +00:00
sammy-SC c24199dcca Build for 500c8aa082 2022-12-02 17:47:22 +00:00
sammy-SC 5f0e0d757c Build for 353c30252f 2022-12-02 16:00:45 +00:00
lauren 7dc01b9876 [DiffTrain] Prune all unnecessary files (#25787)
Note that this PR is targeting the `builds/facebook-www` branch. 

Delete all unnecessary folders from this branch since the only files we
are syncing are in the `compiled` folder.
2022-12-02 07:58:57 -08:00
sammy-SC 60be974470 Build for 17f6912a44 2022-12-02 15:38:43 +00:00
kassens 2501112c9d Build for f0bba2d4f5 2022-12-02 15:30:44 +00:00
kassens 46eccb1ee4 Build for 3e151c7d21 2022-12-02 15:30:19 +00:00
kassens 71a0a86c5b Build for f101c2d0d3 2022-12-02 15:29:41 +00:00
kassens a94afbd444 Build for 420f0b7fa1 2022-12-02 15:29:15 +00:00
poteto a831fb42a6 Build for 030dae2f4c 2022-12-01 19:15:23 +00:00
poteto 23411c3083 Build for 383c3227ac9f30164f0472dc0c0553232c016af5 2022-12-01 17:59:49 +00:00
mondaychen 7d2afd7dd1 Build for f197ca997b 2022-12-01 00:28:46 +00:00
mofeiZ bab97155b3 Build for fa11bd6ecc 2022-11-30 19:35:43 +00:00
sammy-SC 5e2daed9d2 Build for e98225485a 2022-11-29 16:48:32 +00:00
tyao1 f90289c91c Build for edbfc6399f 2022-11-28 23:24:29 +00:00
gnoff eabd08126e Build for 15557fa67f 2022-11-28 17:50:00 +00:00
tyao1 2c0264bf44 Build for 8a23def32f 2022-11-28 17:21:27 +00:00
sebmarkbage a71b907ef2 Build for 2655c9354d 2022-11-22 00:39:40 +00:00
poteto e7071f75ad Build for 0077544d2adace114e7d96de9b42535c018559df 2022-11-21 22:46:40 +00:00
poteto d24bf41cc2 Build for 799ee65343 2022-11-21 22:42:46 +00:00
poteto bfc0eb6cd4 Build for a33594bbae0f596b9380d7361bb1febf0767146e 2022-11-21 21:53:23 +00:00
poteto 75dd049c3b Build for 832f07679597aa55b3442645b6429018c67e3540 2022-11-21 21:43:47 +00:00
poteto 1672d0da73 Build for 62e2b1374b 2022-11-21 21:07:57 +00:00
lauren 62e2b1374b [DiffTrain] Fix incorrect build path (#25723) 2022-11-21 13:00:50 -08:00
lauren e58b6c158b Reorganize build folders for DiffTrain (#25722)
Reorganize some files to make the DiffTrain config easier to setup. Also
add unstable_server-external-runtime to sync.
2022-11-21 12:42:49 -08:00
lauren 13681aaf9c Add github action to commit build artifacts for Facebook (#25721)
This PR adds a new GitHub action to commit build artifacts for Facebook
into a new protected branch. This will later be used to setup an
automatic sync to www.

The hacky spinloop is meant to be a temporary implementation until we
can support running a script internally on top of the synced diff
(coming soon). A GitHub token is otherwise required if we want to setup
a pub/sub between cirleci and github but it's not straightforward to
provision one for our org. So this workaround should do for now since we
won't keep it around for too long.

Example of it running and creating a commit on the `builds/facebook-www`
branch:
https://github.com/facebook/react/actions/runs/3516958576/jobs/5894251359
2022-11-21 11:03:23 -08:00
Tianyu Yao c08d8b8041 Revert "Add SyncHydrationLane" (#25708)
Reverts facebook/react#25698
DevTools CI for older version are failing
2022-11-18 15:00:35 -08:00
Colin McDonnell 56ffca8b9e Add Bun streaming server renderer (#25597)
Add support for Bun server renderer
2022-11-17 13:15:56 -08:00
Tianyu Yao f31005d6ad Add SyncHydrationLane (#25698)
<!--
  Thanks for submitting a pull request!
We appreciate you spending the time to work on these changes. Please
provide enough information so that others can review your pull request.
The three fields below are mandatory.

Before submitting a pull request, please make sure the following is
done:

1. Fork [the repository](https://github.com/facebook/react) and create
your branch from `main`.
  2. Run `yarn` in the repository root.
3. If you've fixed a bug or added code that should be tested, add tests!
4. Ensure the test suite passes (`yarn test`). Tip: `yarn test --watch
TestName` is helpful in development.
5. Run `yarn test --prod` to test in the production environment. It
supports the same options as `yarn test`.
6. If you need a debugger, run `yarn debug-test --watch TestName`, open
`chrome://inspect`, and press "Inspect".
7. Format your code with
[prettier](https://github.com/prettier/prettier) (`yarn prettier`).
8. Make sure your code lints (`yarn lint`). Tip: `yarn linc` to only
check changed files.
  9. Run the [Flow](https://flowtype.org/) type checks (`yarn flow`).
  10. If you haven't already, complete the CLA.

Learn more about contributing:
https://reactjs.org/docs/how-to-contribute.html
-->

## Summary

<!--
Explain the **motivation** for making this change. What existing problem
does the pull request solve?
-->
For more context: https://github.com/facebook/react/pull/25692

Based on https://github.com/facebook/react/pull/25695. This PR adds the
`SyncHydrationLane` so we rewind on sync updates during selective
hydration. Also added tests for ContinuouseHydration and
DefaultHydration lanes.


## How did you test this change?

<!--
Demonstrate the code is solid. Example: The exact commands you ran and
their output, screenshots / videos if the pull request changes the user
interface.
How exactly did you verify that your PR solves the issue you wanted to
solve?
  If you leave this empty, your PR will very likely be closed.
-->
yarn test
2022-11-17 12:14:49 -08:00
Andrew Clark f284d9fafa Track ThenableState alongside other hooks
Now that hook state is preserved while the work loop is suspended, we
don't need to track the thenable state in the work loop. We can track
it alongside the rest of the hook state.

This is a nice simplification and also aligns better with how it works
in Fizz and Flight.

The promises will still be cleared when the component finishes rendering
(either complete or unwind). In the future, we could stash the promises
on the fiber and reuse them during an update. However, this would only
work for `use` calls that occur before an prop/state/context is
processed, because `use` calls can only be assumed to execute in the
same order if no other props/state/context have changed. So it might not
be worth doing until we have finer grained memoization.
2022-11-17 14:48:42 -05:00
Andrew Clark 6b4c0314e8 Check thenable instead of thenableState
Now that hook state is preserved while the work loop is suspended, we
don't need to track the thenable state in the work loop. We can track
it alongside the rest of the hook state.

Before deleting the thenable state variable from the work loop, I need
to remove the other places where it's referenced.

One of them is `isThenableStateResolved`. This grabs the last thenable
from the array and checks if it has resolved.

This was a pointless indirection anyway. The thenable is already stored
as `workInProgressThrownValue`. So we can check that directly.
2022-11-17 14:48:42 -05:00
Andrew Clark 33e3d2878e Reuse hooks when replaying a suspended component
When a component suspends, under some conditions, we can wait for the
data to resolve and replay the component without unwinding the stack or
showing a fallback in the interim. When we do this, we reuse the
promises that were unwrapped during the previous attempts, so that if
they aren't memoized, the result can still be used.

We should do the same for all hooks. That way, if you _do_ memoize an
async function call with useMemo, it won't be called again during the
replay. This effectively gives you a local version of the functionality
provided by `cache`, using the normal memoization patterns that have
long existed in React.
2022-11-17 14:48:42 -05:00
Andrew Clark 4387d752da Allow more hooks to be added when replaying mount
Currently, if you call setState in render, you must render the exact
same hooks as during the first render pass.

I'm about to add a behavior where if something suspends, we can reuse
the hooks from the previous attempt. That means during initial render,
if something suspends, we should be able to reuse the hooks that were
already created and continue adding more after that. This will error
in the current implementation because of the expectation that every
render produces the same list of hooks.

In this commit, I've changed the logic to allow more hooks to be added
when replaying. But only during a mount — if there's already a current
fiber, then the logic is unchanged, because we shouldn't add any
additional hooks that aren't in the current fiber's list. Mounts are
special because there's no current fiber to compare to.

I haven't change any other behavior yet. The reason I've put this into
its own step is there are a couple tests that intentionally break the
Hook rule, to assert that React errors in these cases, and those happen
to be coupled to the behavior. This is undefined behavior that is always
accompanied by a warning and/or error. So the change should be safe.
2022-11-17 14:48:42 -05:00
Andrew Clark 5eb78d0a04 Pass ThenableState to replaySuspendedUnitOfWork
Tiny refactor to refine the work loop variable so Flow knows it's not
null when we access it in replaySuspendedUnitOfWork.
2022-11-17 14:48:42 -05:00
Andrew Clark 4a2d86bddb Don't reset work loop until stack is unwound
When replaying a suspended function components, we want to reuse the
hooks that were computed during the original render.

Currently we reset the state of the hooks right after the component 
suspends (or throws an error). This is too early because it doesn't 
give us an opportunity to wait for the promise to resolve.

This refactors the work loop to reset the hooks right before unwinding
instead of right after throwing. It doesn't include any other changes
yet, so there should be no observable behavioral change.
2022-11-17 14:48:42 -05:00
Andrew Clark 9dfbd9fa90 use: Don't suspend if there are pending updates
Before suspending, check if there are other pending updates that might
possibly unblock the suspended component. If so, interrupt the current
render and switch to working on that.

This logic was already implemented for the old "throw a Promise"
Suspense but has to be replicated for `use` because it suspends the
work loop much earlier.

I'm getting a little anxious about the divergence between the two
Suspense patterns. I'm going to look into enabling the new behavior for
the old pattern so that we can unify the implementations.
2022-11-17 14:48:42 -05:00
Andrew Clark 44c4e6f4dd Force unwind work loop during selective hydration (#25695)
When an update flows into a dehydrated boundary, React cannot apply the
update until the boundary has finished hydrating. The way this currently
works is by scheduling a slightly higher priority task on the boundary,
using a special lane that's reserved only for this purpose. Because the
task is slightly higher priority, on the next turn of the work loop, the
Scheduler will force the work loop to yield (i.e. shouldYield starts
returning `true` because there's a higher priority task).

The downside of this approach is that it only works when time slicing is
enabled. It doesn't work for synchronous updates, because the
synchronous work loop does not consult the Scheduler on each iteration.

We plan to add support for selective hydration during synchronous
updates, too, so we need to model this some other way.

I've added a special internal exception that can be thrown to force the
work loop to interrupt the work-in-progress tree. Because it's thrown
from a React-only execution stack, throwing isn't strictly necessary —
we could instead modify some internal work loop state. But using an
exception means we don't need to check for this case on every iteration
of the work loop. So doing it this way moves the check out of the fast
path.

The ideal implementation wouldn't need to unwind the stack at all — we
should be able to hydrate the subtree and then apply the update all
within a single render phase. This is how we intend to implement it in
the future, but this requires a refactor to how we handle "stack"
variables, which are currently pushed to a per-render array. We need to
make this stack resumable, like how context works in Flight and Fizz.
2022-11-17 13:51:33 -05:00
Sebastian Markbåge 7b17f7bbf3 Enable warning for defaultProps on function components for everyone (#25699)
This also fixes a gap where were weren't warning on memo components.
2022-11-17 12:22:23 -05:00
Sebastian Silbermann 6fb8133ed3 Turn on string ref deprecation warning for everybody (not codemoddable) (#25383)
## Summary
 
Alternate to https://github.com/facebook/react/pull/25334 without any
prod runtime changes i.e. the proposed codemod in
https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md#deprecate-string-refs-and-remove-production-mode-_owner-field
would not work.

## How did you test this change?

- [x] CI
- [x] `yarn test` with and without `warnAboutStringRefs`
2022-11-16 19:15:57 -05:00
Sebastian Markbåge 07f46ecf2e Turn on key spread warning in jsx-runtime for everyone (#25697)
This improves the error message a bit and ensures that we recommend
putting the key first, not last, which ensures that the faster
`jsx-runtime` is used.

This only affects the modern "automatic" JSX transform.
2022-11-16 18:57:50 -05:00