Commit Graph
16470 Commits
Author SHA1 Message Date
mofeiZ cb70b73d5a feat(babel-plugin-react-compiler): support satisfies operator (#32742)
Solve https://github.com/facebook/react/pull/29818

---------

Co-authored-by: Rodrigo Faria <rodrigo.faria@cartrack.com>

DiffTrain build for [ef4bc8b4f9](https://github.com/facebook/react/commit/ef4bc8b4f91023afac437be9179beef350b32db3)
2025-03-28 08:16:33 -07:00
mofeiZ 0c1b2bf6d6 [compiler] Fix inferEffectDependencies lint false positives (#32769)
Currently, inferred effect dependencies are considered a
"compiler-required" feature. This means that untransformed callsites
should escalate to a build error.

`ValidateNoUntransformedReferences` iterates 'special effect' callsites
and checks that the compiler was able to successfully transform them.
Prior to this PR, this relied on checking the number of arguments passed
to this special effect.

This obviously doesn't work with `noEmit: true`, which is used for our
eslint plugin (this avoids mutating the babel program as other linters
run with the same ast). This PR adds a set of `babel.SourceLocation`s to
do best effort matching in this mode.

DiffTrain build for [8039f1b2a0](https://github.com/facebook/react/commit/8039f1b2a05d00437cd29707761aeae098c80adc)
2025-03-27 09:24:40 -07:00
sebmarkbage d587415660 Mark shouldStartViewTransition as true when there's an enter animation (#32764)
Typically we mark the name of things that might animate in the snapshot
phase. At the same time we track that should call startViewTransition
too. However, we don't do this for "enter" since they're only marked
later. Leading to having just an "enter" not to animate unless there's
at least another update too.

This tracks if there's a ViewTransitionComponent in the tree that
enters. Luckily we know that from the static flag so we don't have to
traverse it.

DiffTrain build for [4280563b04](https://github.com/facebook/react/commit/4280563b04898baad423dc7d0f8b0dfea3b1797a)
2025-03-26 15:18:39 -07:00
rickhanlonii 473ee29cdb s/HTML/text for text hydration mismatches (#32763)
DiffTrain build for [3e88e97c11](https://github.com/facebook/react/commit/3e88e97c116c7a1535976f2d4486bbf345476443)
2025-03-26 14:45:27 -07:00
sebmarkbage c06bad4f71 Add getComputedStyle helper to ViewTransition refs (#32751)
This is also sometimes useful to read the style of the pseudo-element
itself without an animation.

DiffTrain build for [f134b3993a](https://github.com/facebook/react/commit/f134b3993a84d53cc99fe66b426ba13548f142ec)
2025-03-26 13:00:00 -07:00
poteto 204d73a37e Add "auto" class to mean the built-in should run (#32761)
Stacked on https://github.com/facebook/react/pull/32734

In React a ViewTransition class of `"none"` doesn't just mean that it
has no class but also that it has no ViewTransition name. The default
(`null | undefined`) means that it has no specific class but should run
with the default built-in animation. This adds this as an explicit
string called `"auto"` as well.

That way you can do `<ViewTransition default="foo" enter="auto">` to
override the "foo" just for the "enter" trigger to be the default
built-in animation. Where as if you just specified `null` it would be
like not specifying enter at all which would trigger "foo".

DiffTrain build for [fceb0f80bc](https://github.com/facebook/react/commit/fceb0f80bc729d061bcb5031801cfc824adc07a9)
2025-03-26 12:52:56 -07:00
sebmarkbage 86c53b445d Rename <ViewTransition className="..."> to <ViewTransition default="..."> (#32734)
It was always confusing that this is not a CSS class but a
view-transition-class.

The `className` sticks out a bit among its siblings `enter`, `exit`,
`update` and `share`. The idea is that the most specific definition
override is the class name that gets applied and this prop is really
just the fallback, catch-all or "any" that is applied if you didn't
specify a more specific one.

It has also since evolved not just to take a string but also a map of
Transition Type to strings.

The "class" is really the type of the value. We could add a suffix to
all of them like `defaultClass`, `enterClass`, `exitClass`,
`updateClass` and `shareClass`. However, this doesn't necessarily make
sense with the mapping of Transition Type to string. It also makes it a
bit too DOM centric. In React Native this might still be called a
"class" but it might be represented by an object definition. We might
even allow some kind of inline style form for the DOM too. Really this
is about picking which "animation" that runs which can be a string or
instance. "Animation" is too broad because there's also a concept of a
CSS Animation and these are really sets of CSS animations (group,
image-pair, old, new). It could maybe be `defaultTransition`,
`enterTransition`, etc but that seems unnecessarily repetitive and still
doesn't say anything about it being a class.

We also already have the name "default" in the map of Transition Types.
In fact you can now specify a default for default:

```
<ViewTransition default={{"navigation-back": "slide-out", "default": "fade-in"}}>
```

One thing I don't like about the name `"default"` is that it might be
common to just apply a named class that does it matching to
enter/exit/update in the CSS selectors (such as the `:only-child` rule)
instead of doing that mapping to each one using React. In that can you
end up specifying only `default={...}` a lot and then what is it the
"default" for? It's more like "all". I think it's likely that you end up
with either "default" or the specific forms instead of both at once.

DiffTrain build for [e0c99c4ea1](https://github.com/facebook/react/commit/e0c99c4ea1cae566ad8040180cf180ae058cb8bf)
2025-03-26 12:12:23 -07:00
sebmarkbage 7c2bf8c31d Don't flush synchronous work if we're in the middle of a ViewTransition async sequence (#32760)
Starting a View Transition is an async sequence. Since React can get a
sync update in the middle of sequence we sometimes interrupt that
sequence.

Currently, we don't actually cancel the View Transition so it can just
run as a partial. This ensures that we fully skip it when that happens,
as well as warn.

However, it's very easy to trigger this with just a setState in
useLayoutEffect right now. Therefore if we're inside the preparing
sequence of a startViewTransition, this delays work that would've
normally flushed in a microtask. ~Maybe we want to do the same for
Default work already scheduled through a scheduler Task.~ Edit: This was
already done.

`flushSync` currently will still lead to an interrupted View Transition
(with a warning). There's a tradeoff here whether we want to try our
best to preserve the guarantees of `flushSync` or favor the animation.
It's already possible to suspend at the root with `flushSync` which
means it's not always 100% guaranteed to commit anyway. We could treat
it as suspended. But let's see how much this is a problem in practice.

DiffTrain build for [a5297ece62](https://github.com/facebook/react/commit/a5297ece6217f5495cbe38ba58f928b2697b0f99)
2025-03-26 11:50:22 -07:00
mofeiZ 574b2c4d1d [compiler][be] Playground now uses tsup bundled plugin (#32759)
Followup to https://github.com/facebook/react/pull/32758.

This moves playground to use the tsup bundled plugin instead of
webpack-built `babel-plugin-react-compiler`.

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32759).
* __->__ #32759
* #32758

DiffTrain build for [254114616a](https://github.com/facebook/react/commit/254114616a24e0ed66468570b00d34bfabf9f73b)
2025-03-26 11:38:23 -07:00
mofeiZ 7ec3133d86 [compiler][be] Test runner (snap) now uses tsup bundled plugin (#32758)
Currently, `babel-plugin-react-compiler` is bundled with (almost) all
external dependencies. This is because babel traversal and ast logic is
not forward-compatible. Since `babel-plugin-react-compiler` needs to be
compatible with babel pipelines across a wide semvar range, we (1) set
this package's babel dependency to an early version and (2) inline babel
libraries into our bundle.

A few other packages in `react/compiler` depend on the compiler. This PR
moves `snap`, our test fixture compiler and evaluator, to use the
bundled version of `babel-plugin-react-compiler`. This decouples the
babel version used by `snap` with the version used by
`babel-plugin-react-compiler`, which means that `snap` now can test
features from newer babel versions (see
https://github.com/facebook/react/pull/32742).

---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32758).
* #32759
* __->__ #32758

DiffTrain build for [33999c4317](https://github.com/facebook/react/commit/33999c43177e13580730c2fad94a77f4b0e08ef2)
2025-03-26 11:35:39 -07:00
poteto 5dd6f3faaf [crud] Revert CRUD overload (#32741)
Cleans up this experiment. After some internal experimentation we are
deprioritizing this project for now and may revisit it at a later point.

DiffTrain build for [313332d111](https://github.com/facebook/react/commit/313332d111a2fba2db94c584334d8895e8d73c61)
2025-03-26 09:15:37 -07:00
jackpope 2057aaeae8 Fix ownerStackLimit feature gating for tests (#32726)
https://github.com/facebook/react/pull/32529 added a dynamic flag for
this, but that breaks tests since the flags are not defined everywhere.

However, this is a static value and the flag is only for supporting
existing tests. So we can override it in the test config, and make it
static at built time instead.

DiffTrain build for [f99c9feaf7](https://github.com/facebook/react/commit/f99c9feaf786fbdad0ad8d2d81196a247302dd3c)
2025-03-26 09:09:00 -07:00
sebmarkbage 3f7455b1b6 Warn for duplicate ViewTransition names (#32752)
This adds early logging when two ViewTransitions with the same name are
mounted at the same time. Whether they're part of a View Transition or
not.

This lets us include the owner stack of each one. I do two logs so that
you can get the stack trace of each one of the duplicates.

It currently only logs once for each name which also avoids the scenario
when you have many hits for the same name in one commit. However, we
could also possibly log a stack for each of them but seems noisy.

Currently we don't log if a SwipeTransition is the first time the pair
gets mounted which could lead to a View Transition error before we've
warned. That could be a separate improvement.

DiffTrain build for [8ac25e5201](https://github.com/facebook/react/commit/8ac25e5201579c65d115d91c211ac719a235d982)
2025-03-25 19:08:55 -07:00
sebmarkbage be61447cca Avoid double logging component render time (#32749)
This got moved into the functional component and class component case
statements here:
https://github.com/facebook/react/commit/0de1233fd180969f7ffdfc98151922f2466ceb1f.
So that we could separate the error case for class components.

However, due to a faulty rebase this got restored at the top as well.
Leading to double component renders being logged.

In the other offscreen reconnect passes we don't do this in each case
statement but still once at the top. The reason this doesn't matter is
because use the PerformedWork flag and that is only set for function and
class components. Although maybe it should be set for expensive DOM
components too and then we have to remember this.

DiffTrain build for [f9e1b16098](https://github.com/facebook/react/commit/f9e1b16098f2ff4ed483285219b07066525796b6)
2025-03-25 18:03:19 -07:00
poteto 0c45045456 [ci] Fix param casing (#32748)
Casing was incorrect.

Tested by running locally with a PAT.

```
$ scripts/release/download-experimental-build.js --commit=2d40460cf768071d3a70b4cdc16075d23ca1ff25
Command failed: gh attestation verify artifacts_combined.zip --repo=facebook/react

Error: failed to fetch attestations from facebook/react: HTTP 404: Not Found (https://api.github.com/repos/facebook/react/attestations/sha256:23d05644f9e49e02cbb441e3932cc4366b261826e58ce222ea249a6b786f0b5f?per_page=30)
`gh attestation verify artifacts_combined.zip --repo=facebook/react` (exited with error code 1)

$ scripts/release/download-experimental-build.js --commit=2d40460cf768071d3a70b4cdc16075d23ca1ff25 --noVerify
⠼ Downloading artifacts from GitHub for commit 2d40460cf7)  5%                  0.1m, estimated 1.6m
✓ Downloading artifacts from GitHub for commit 2d40460cf7) 9.5 secs
An experimental build has been downloaded!

You can download this build again by running:
  scripts/download-experimental-build.js --commit=2d40460cf768071d3a70b4cdc16075d23ca1ff25
```

DiffTrain build for [4845e16c22](https://github.com/facebook/react/commit/4845e16c22caf27334a1eab712ed258a9ae09752)
2025-03-25 13:13:00 -07:00
hoxyq ca4475cd53 [DevTools] Add fb local build command (#32644)
<!--
  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 test --debug --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
1. Having a development build for FB will be convenient for fb internal
feature development
2. Add a new checkbox to toggle new internal features added to React
Devtools.

## How did you test this change?
1. yarn test
2. set extra env variables in bash profile and build an internal version
with the new script.
3. toggle on/off the new checkbox, the value is stored in local storage
correctly.

---------

Co-authored-by: Aohua Mu <muaohua@fb.com>

DiffTrain build for [dc9b74647e](https://github.com/facebook/react/commit/dc9b74647e093b531dc876a2438f12dac776e480)
2025-03-25 06:52:04 -07:00
SamChou19815 a6ff86e36f [flow] Replace $PropertyType with indexed access type in ReactNativeTypes (#32733)
DiffTrain build for [b59f186011](https://github.com/facebook/react/commit/b59f18601179bb06a2c32a76547fd4929aa1ce9c)
2025-03-24 20:06:19 -07:00
poteto fb1fb125e2 [ci] Fix missing permissions for prereleases (#32729)
Missed these earlier.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32729).
* __->__ #32729
* #32728

DiffTrain build for [ee0855f427](https://github.com/facebook/react/commit/ee0855f427832e899767f7659c5289364218ab9e)
2025-03-24 15:33:53 -07:00
poteto f5f1e49b86 [scripts] Verify artifact integrity when downloading (#32728)
Uses https://cli.github.com/manual/gh_attestation_verify to verify that
the downloaded artifact matches the attestation generated during the
build process in runtime_commit_artifacts.

Example:

On a workflow run of runtime_build_and_test.yml with no attestations:
```
$ scripts/release/download-experimental-build.js --commit=ea5f065745b777cb41cc9e54a3b29ed8c727a574

Command failed: gh attestation verify artifacts_combined.zip --repo=facebook/react

Error: failed to fetch attestations from facebook/react: HTTP 404: Not Found (https://api.github.com/repos/facebook/react/attestations/sha256:7adba0992ba477a927aad5a07f95ee2deb7d18427c84279d33fc40a3bc28ebaa?per_page=30)
`gh attestation verify artifacts_combined.zip --repo=facebook/react` (exited with error code 1)
```

On one which does:

```
$ scripts/release/download-experimental-build.js --commit=12e85d74c1c233cdc2f3228a97473a4435d50c3b

✓ Downloading artifacts from GitHub for commit 12e85d74c1) 10.5 secs
An experimental build has been downloaded!

You can download this build again by running:
  scripts/download-experimental-build.js --commit=12e85d74c1c233cdc2f3228a97473a4435d50c3b
```
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32728).
* #32729
* __->__ #32728

DiffTrain build for [7e4c258e16](https://github.com/facebook/react/commit/7e4c258e160d3a2ca690b44a5938271873919ee1)
2025-03-24 15:31:29 -07:00
poteto 8e00114460 [ci] Add artifact attestation to build (#32711)
Adds a signed build provenance attestations via
https://github.com/actions/attest-build-provenance
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32711).
* #32729
* #32728
* __->__ #32711

DiffTrain build for [07276b8682](https://github.com/facebook/react/commit/07276b8682059cd310cedf574c7f3ecddce68f5c)
2025-03-24 15:21:59 -07:00
mofeiZ 2c83cca631 [compiler][bugfix] Fix hoisting of let declarations (#32724)
(Found when compiling Meta React code)

Let variable declarations and reassignments are currently rewritten to
`StoreLocal <varName>` instructions, which each translates to a new
`const varName` declaration in codegen.

```js
// Example input
function useHook() {
  const getX = () => x;
  let x = CONSTANT1;
  if (cond) {
    x += CONSTANT2;
  }
  return <Stringify getX={getX} />
}

// Compiled output, prior to this PR
import { c as _c } from "react/compiler-runtime";
function useHook() {
  const $ = _c(1);
  let t0;
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
    const getX = () => x;
    let x = CONSTANT1;
    if (cond) {
      let x = x + CONSTANT2;
      x;
    }

    t0 = <Stringify getX={getX} />;
    $[0] = t0;
  } else {
    t0 = $[0];
  }
  return t0;
}
```

This also manifests as a babel internal error when replacing the
original function declaration with the compiler output. The below
compilation output fails with `Duplicate declaration "x" (This is an
error on an internal node. Probably an internal error.)`.
```js
// example input
let x = CONSTANT1;
if (cond) {
  x += CONSTANT2;
  x = CONSTANT3;
}

// current output
let x = CONSTANT1;
if (playheadDragState) {
  let x = x + CONSTANT2
  x;
  let x = CONSTANT3;
}
```

DiffTrain build for [254dc4d9f3](https://github.com/facebook/react/commit/254dc4d9f37eb512d4ee8bad6a0fae7ae491caef)
2025-03-24 11:36:37 -07:00
sebmarkbage 1f2af3a1aa Merge ViewTransition layout/onLayout props into update/onUpdate (#32723)
We currently have the ability to have a separate animation for a
ViewTransition that relayouts but doesn't actually have any internal
mutations. This can be useful if you want to separate just a move from
for example flashing an update.

However, we're concerned that this might be more confusion than its
worth because subtle differences in mutations can cause it to trigger
the other case. The existence of the property name might also make you
start looking for it to solve something that it's not meant for.

We already fallback to using the "update" property if it exists but
layout doesn't. So if we ever decide to add this back it would backwards
compatible. We've also shown in implementation that it can work.

DiffTrain build for [42a57ea802](https://github.com/facebook/react/commit/42a57ea8027de8af55e6f4483c3b9a8f4cba31fb)
2025-03-24 11:10:55 -07:00
jackpope 39e4e7bdb3 Add getRootNode to fragment instances (#32682)
This implements `getRootNode(options)` on fragment instances as the
equivalent of calling `getRootNode` on the fragment's parent host node.

The parent host instance will also be used to proxy dispatchEvent in an
upcoming PR.

DiffTrain build for [04bf10e6a9](https://github.com/facebook/react/commit/04bf10e6a9526ea2600005a714c957c47dd8551d)
2025-03-24 07:26:29 -07:00
mofeiZ ac9e62b123 [compiler] Avoid failing builds when import specifiers conflict or shadow vars (#32663)
Avoid failing builds when imported function specifiers conflict by using
babel's `generateUid`. Failing a build is very disruptive, as it usually
presents to developers similar to a javascript parse error.
```js
import {logRender as _logRender} from 'instrument-runtime';

const logRender = () => { /* local conflicting implementation */ }

function Component_optimized() {
  _logRender(); // inserted by compiler
}
```

Currently, we fail builds (even in `panicThreshold:none` cases) when
import specifiers are detected to conflict with existing local
variables. The reason we destructively throw (instead of bailing out) is
because (1) we first generate identifier references to the conflicting
name in compiled functions, (2) replaced original functions with
compiled functions, and then (3) finally check for conflicts.

When we finally check for conflicts, it's too late to bail out.
```js
// import {logRender} from 'instrument-runtime';

const logRender = () => { /* local conflicting implementation */ }

function Component_optimized() {
  logRender(); // inserted by compiler
}
```

DiffTrain build for [c61e75b76d](https://github.com/facebook/react/commit/c61e75b76d5ff6707ad75c8beb777e721d982207)
2025-03-24 06:38:02 -07:00
mofeiZ 7f9b639eec [compiler][optim] Add Effect.ConditionallyMutateIterator (#32698)
Adds Effect.ConditionallyMutateIterator, which has the following
effects:
- capture for known array, map, and sets
- mutate for all other values

An alternative to this approach could be to add polymorphic shape
definitions

DiffTrain build for [7c908bcf4e](https://github.com/facebook/react/commit/7c908bcf4e6b46135164be961972f0d756378517)
2025-03-23 20:31:44 -07:00
mofeiZ 9744c3a5b5 [compiler][optim] Add map and set constructors (#32697)
* Adds `isConstructor: boolean` to `FunctionType`. With this PR, each
typed function can either be a constructor (currently only known
globals) or non constructor. Alternatively, we prefer to encode
polymorphic types / effects (and match the closest subtype)

* Add Map and Set globals + built-ins
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32697).
* #32698
* __->__ #32697

DiffTrain build for [a8e503dce0](https://github.com/facebook/react/commit/a8e503dce0ec386eef752a1219dd6ef861c48ced)
2025-03-23 20:25:23 -07:00
mofeiZ 8e83d8c66f [compiler][be] Refactor similar CallExpression and MethodCall effect handling (#32696)
Simplify InferReferenceEffect function signature matching logic for next
PRs in stack
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32696).
* #32698
* #32697
* __->__ #32696
* #32695

DiffTrain build for [45463ab3ac](https://github.com/facebook/react/commit/45463ab3ac3ed0e65dfdbbfd5e53a50a8384e909)
2025-03-23 20:14:08 -07:00
eps1lon fbcf5309d2 Stop creating Owner Stacks if many have been created recently (#32529)
Co-authored-by: Jack Pope <jackpope1@gmail.com>

DiffTrain build for [4a9df08157](https://github.com/facebook/react/commit/4a9df08157f001c01b078d259748512211233dcf)
2025-03-23 15:52:49 -07:00
josephsavona 8ca918c4b6 fix(react-compiler): optimize components declared with arrow function and implicit return and compilationMode: 'infer' (#31792)
fixes https://github.com/facebook/react/issues/31601
https://github.com/facebook/react/issues/31639 cc @josephsavona

DiffTrain build for [6b1a2c1d81](https://github.com/facebook/react/commit/6b1a2c1d81630a5f385c5be0f758365b63d92eae)
2025-03-21 16:51:56 -07:00
poteto e64ab31335 [ci] Add missing permissions to runtime_commit_artifacts.yml (#32710)
Turns out we need permissions to write to `contents` after all.
---
[//]: # (BEGIN SAPLING FOOTER)
Stack created with [Sapling](https://sapling-scm.com). Best reviewed
with [ReviewStack](https://reviewstack.dev/facebook/react/pull/32710).
* #32711
* __->__ #32710

DiffTrain build for [de4aad5ba6](https://github.com/facebook/react/commit/de4aad5ba693be099b215b5819b5f25d05051a84)
2025-03-21 15:07:04 -07:00
sebmarkbage eb1bd2e372 Force layout before startViewTransition (#32699)
This works around this Safari bug.
https://bugs.webkit.org/show_bug.cgi?id=290146

This unfortunate because it may cause additional layouts if there's more
updates to the tree coming by manual mutation before it gets painted
naturally. However, we might end up wanting to read layout early anyway.

This affects the fixture because we clone the `<link>` from the `<head>`
which is itself another bug. However, it should be possible to have
`<link>` tags inserted into the new tree so this is still relevant.

DiffTrain build for [e1e740717b](https://github.com/facebook/react/commit/e1e740717ba85597f03fd837a36c7bab5803a0d2)
2025-03-21 07:12:05 -07:00
mofeiZ 40af6fd39b [compiler][bugfix] Don't insert hook guards in retry pipeline (#32665)
Fixing bug from https://github.com/facebook/react/pull/32164 -- prior to
this PR, we inserted hook guards even for functions that bailed out of
compilation.

DiffTrain build for [0962f684a0](https://github.com/facebook/react/commit/0962f684a066df4fd2a7db7489cb1984799ad674)
2025-03-20 14:45:02 -07:00
rickhanlonii 56171beb3b [refactor] move isValidElementType to react-is (#32518)
DiffTrain build for [b630219b13](https://github.com/facebook/react/commit/b630219b1377f3117036b1c6118676c16fdb21b7)
2025-03-20 14:01:01 -07:00
josephsavona f846612902 [compiler] Refactor validations to return Result and log where appropriate
Updates ~all of our validations to return a Result, and then updates callers to either unwrap() if they should bailout or else just log.

ghstack-source-id: 418b5f5aa2
Pull Request resolved: https://github.com/facebook/react/pull/32688

DiffTrain build for [e3c06424ae](https://github.com/facebook/react/commit/e3c06424ae1162319d786a76371d649dee412c29)
2025-03-20 11:09:13 -07:00
poteto ddb820e3b4 [ci] Fix Will commit these changes www step (#32681)
Unlike the fbsource version of the step, www doesn't add any changes so
the `force` input doesn't actually work

DiffTrain build for [ff8f6f21f7](https://github.com/facebook/react/commit/ff8f6f21f756c81fba284557357eb6e6ce765149)
2025-03-19 15:37:38 -07:00
poteto 11071c3740 Minor Fixes to View Transition Fixture (#32664)
Follow up to #32656.

Remove touchAction from SwipeRecognizer. I was under the wrong
impression that this was only the touch-action applied to this
particular element, but that parents would still win but in fact this
blocks the parent from scrolling in the other direction. By specifying a
fixed direction it also blocked rage-swiping in the other direction
early on.

Disable pointer-events on view-transition so that the scroll can be hit.
This means that touches hit below the items animating above. This allows
swiping to happen again before momentum scroll has finished. Previously
they were ignored. This only works as long as the SwipeRecognizer is
itself not animating. This means you can now rage-swipe in both
directions quickly.

DiffTrain build for [c2a1961747](https://github.com/facebook/react/commit/c2a196174763e0b4f16ed1c512ed4442b062395e)

DiffTrain build for [646835fb59](https://github.com/facebook/react/commit/646835fb59f9ad8557b9f3641515697c153e3faa)

DiffTrain build for [db7dfe0550](https://github.com/facebook/react/commit/db7dfe05508392ba3bdf7bc24717fe71f9b84a29)
2025-03-19 08:57:41 -07:00
poteto dd465cbbb2 Minor Fixes to View Transition Fixture (#32664)
Follow up to #32656.

Remove touchAction from SwipeRecognizer. I was under the wrong
impression that this was only the touch-action applied to this
particular element, but that parents would still win but in fact this
blocks the parent from scrolling in the other direction. By specifying a
fixed direction it also blocked rage-swiping in the other direction
early on.

Disable pointer-events on view-transition so that the scroll can be hit.
This means that touches hit below the items animating above. This allows
swiping to happen again before momentum scroll has finished. Previously
they were ignored. This only works as long as the SwipeRecognizer is
itself not animating. This means you can now rage-swipe in both
directions quickly.

DiffTrain build for [c2a1961747](https://github.com/facebook/react/commit/c2a196174763e0b4f16ed1c512ed4442b062395e)

DiffTrain build for [646835fb59](https://github.com/facebook/react/commit/646835fb59f9ad8557b9f3641515697c153e3faa)
2025-03-19 08:56:34 -07:00
sebmarkbage e2d679e6c2 Minor Fixes to View Transition Fixture (#32664)
Follow up to #32656.

Remove touchAction from SwipeRecognizer. I was under the wrong
impression that this was only the touch-action applied to this
particular element, but that parents would still win but in fact this
blocks the parent from scrolling in the other direction. By specifying a
fixed direction it also blocked rage-swiping in the other direction
early on.

Disable pointer-events on view-transition so that the scroll can be hit.
This means that touches hit below the items animating above. This allows
swiping to happen again before momentum scroll has finished. Previously
they were ignored. This only works as long as the SwipeRecognizer is
itself not animating. This means you can now rage-swipe in both
directions quickly.

DiffTrain build for [c2a1961747](https://github.com/facebook/react/commit/c2a196174763e0b4f16ed1c512ed4442b062395e)
2025-03-18 17:11:05 -07:00
jackpope ee09677f9c Add getClientRects to fragment instances (#32660)
Adds  to fragment instances with a fixture test case.
 returns a collection of s (see example
of multiline span returning two  boxes).
 here flattens those collections into
an array of rects.

DiffTrain build for [476f53879e](https://github.com/facebook/react/commit/476f53879e80d4ee976ed036a0e8986126fa3117)
2025-03-18 11:01:44 -07:00
jackpope 3687fd2e6b Add blur() and focusLast() to fragment instances (#32654)
was added in https://github.com/facebook/react/pull/32465.
Here we add  and . I also extended  to take
options.

 will focus the first focusable element.  will focus
the last focusable element. We could consider a  naming or
even the  used by test selector APIs as well.

 will only have an effect if the current
is one of the fragment children.

DiffTrain build for [c69a5fc53a](https://github.com/facebook/react/commit/c69a5fc53a5135136668ca878f99b634d2374837)
2025-03-18 09:07:57 -07:00
sebmarkbage 1e13b4243c Measure Updated ViewTransition Boundaries (#32653)
This does the same thing for  that we did
for  in
https://github.com/facebook/react/pull/32612/commits/e3cbaffef05c7b476c07f7495e06788a9503e636.
If a boundary hasn't mutated and didn't change in size, we mark it for
cancellation. Otherwise we add names to it. The different from the
CommitViewTransition path is that the old names are added to the
clones so this is the first time the new names.

Now we also cancel any boundaries that were unchanged. So now the root
no longer animates. We still have to clone them. There are other
optimizations that can avoid cloning but once we've done all the layouts
we can still cancel the running animation and let them just be the
regular content if they didn't change. Just like the regular
fire-and-forget path.

This also fixes the measurement so that we measure clones by adjusting
their position back into the viewport.

This actually surfaces a bug in Safari that was already in #32612. It
turns out that the old names aren't picked up for some reason and so in
Safari they looked more like a cross-fade than what #32612 was supposed
to fix. However, now that bug is even more apparent because they
actually just disappear in Safari. I'm not sure what that bug is but
it's unrelated to this PR so will fix that separately.

DiffTrain build for [3c3696d554](https://github.com/facebook/react/commit/3c3696d5548c8a67f2332fd78332b9366abaf2f9)
2025-03-17 18:45:36 -07:00
mofeiZ 952df7fd1d fix(react-compiler): implement NumericLiteral as ObjectPropertyKey (#31791)
DiffTrain build for [90b511ec7a](https://github.com/facebook/react/commit/90b511ec7a9f2f3fd2b7f0039d8fc52c23f573a1)
2025-03-17 16:37:52 -07:00
sebmarkbage f8c51fc6a3 Don't auto-start browser in SSR fixtures (#32652)
I end up restarting these a lot and it's annoying to have it open
another tab each time.

The flight fixture already doesn't auto-start.

DiffTrain build for [02372952e4](https://github.com/facebook/react/commit/02372952e4f24fa02dcb9b32af26cb2472617cef)
2025-03-17 14:32:46 -07:00
sebmarkbage 9d5f469c0f Materialize the tree ID when ViewTransition name=auto consumes one (#32651)
ViewTransition uses the  algorithm to auto-assign names. This
ensures that we could animate between SSR content and client content by
ensuring that the names line up.

However, I missed that we need to bump the id (materialize it) when we
do that. This is what function components do if they use one or more
. This caused duplicate names when two ViewTransitions were
nested without any siblings since they would share name.

DiffTrain build for [9fde224a53](https://github.com/facebook/react/commit/9fde224a53693101a4d15e038d6db37e7a3596ff)
2025-03-17 13:23:53 -07:00
acdliteandacdlite edc6b1ccb9 Fix COMMIT_SHA when generating PR artifacts (#32647)
Follow-up to #31850. We want to build using the original commit SHA, not
the merge commit that GitHub Actions creates behind the scenes. We were
already checking out the correct commit object, but the COMMIT_SHA
artifact was still pointing to the merge commit.

This should fix the sizebot links to point to working URLs, too.

DiffTrain build for [9320a0139d](https://github.com/facebook/react/commit/9320a0139df876509c8ebb6f6fd950a6690bd5d9)
2025-03-17 09:53:26 -07:00
rickhanloniiandrickhanlonii 92ce7b2d07 [devtools] add filters for internal builds (#32646)
We don't have an experimental-only build of devtools, but we can at
least add these filters to the internal build.

A better way would be to use feature detection, but I'm not sure how and
this isn't a very heavily used feautre.

DiffTrain build for [fbcda19a23](https://github.com/facebook/react/commit/fbcda19a23da819889afdd7164b29c556fbcfc7a)
2025-03-17 09:21:25 -07:00
jackpopeandjackpope 9f32c445a6 Add observer methods to fragment instances (#32619)
This implements `observeUsing(observer)` and `unobserverUsing(observer)`
on fragment instances. IntersectionObservers and ResizeObservers can be
passed to observe each host child of the fragment. This is the
equivalent to calling `observer.observe(child)` or
`observer.unobserve(child)` for each child target.

Just like the addEventListener, the observer is held on the fragment
instance and applied to any newly mounted child. So you can do things
like wrap a paginated list in a fragment and have each child
automatically observed as they commit in.

Unlike, the event listeners though, we don't `unobserve` when a child is
removed. If a removed child is currently intersecting, the observer
callback will be called when it is removed with an empty rect. This lets
you track all the currently intersecting elements by setting state from
the observer callback and either adding or removing them from your list
depending on the intersecting state. If you want to track the removal of
items offscreen, you'd have to maintain that state separately and append
intersecting data to it in the observer callback. This is what the
fixture example does.

There could be more convenient ways of managing the state of multiple
child intersections, but basic examples are able to be modeled with the
simple implementation. Let's see how the usage goes as we integrate this
with more advanced loggers and other features.

For now you can only attach one observer to an instance. This could
change based on usage but the fragments are composable and could be
stacked as one way to apply multiple observers to the same elements.

In practice, one pattern we expect to enable is more composable logging
such as

```javascript
function Feed({ items }) {
  return (
    <ImpressionLogger>
      {items.map((item) => (
        <FeedItem />
      ))}
    </ImpressionLogger>
  );
}
```

where `ImpressionLogger` would set up the IntersectionObserver using a
fragment ref with the required business logic and various components
could layer it wherever the logging is needed. Currently most callsites
use a hook form, which can require wiring up refs through the tree and
merging refs for multiple loggers.

DiffTrain build for [cd28a946d5](https://github.com/facebook/react/commit/cd28a946d57695a025581c0ff851bde08ea6ca27)
2025-03-17 08:47:17 -07:00
rickhanloniiandrickhanlonii 4392bb2dbb [bug] Fix component name for Portal and add tests (#32640)
Based off: https://github.com/facebook/react/pull/32499

While looking into `React.lazy` issues for built-ins, I noticed we
already error for `lazy` with build-ins, but we don't have any tests for
`getComponentNameFromType` using all the built-ins. This may be
something we should handle, but for now we should at least have tests.

Here's why: while writing tests, I noticed we check `type` instead of
`$$typeof` for portals:

https://github.com/facebook/react/blob/9cdf8a99edcfd94d7420835ea663edca04237527/packages/react-reconciler/src/ReactPortal.js#L25-L32

This PR adds tests for all the built-ins and fixes the portal bug.

[Commit to
review](https://github.com/facebook/react/pull/32640/commits/e068c167d48d4df01e79db8f13276bb46d7ab439)

DiffTrain build for [8243f3f063](https://github.com/facebook/react/commit/8243f3f0631698e819c690710a7f18f767068981)
2025-03-17 08:30:29 -07:00
rickhanloniiandrickhanlonii 0c392217e9 Remove offscreen type (#32639)
Based off https://github.com/facebook/react/pull/32499

This is no longer used.

[Review
commit](https://github.com/facebook/react/commit/88c297d12f8b2562be3982fba867f03a137551cb)

DiffTrain build for [df31952275](https://github.com/facebook/react/commit/df319522758b7fdfed3ddfa517cc1cc298ef1602)
2025-03-17 06:44:19 -07:00
rickhanloniiandrickhanlonii d5e4d11666 [refactor] Add element type for Activity (#32499)
This PR separates Activity to it's own element type separate from
Offscreen. The goal is to allow us to add Activity element boundary
semantics during hydration similar to Suspense semantics, without
impacting the Offscreen behavior in suspended children.

DiffTrain build for [1a191701fe](https://github.com/facebook/react/commit/1a191701fe5000098d23328b2ea9d70457fea1f8)
2025-03-17 06:27:21 -07:00