Commit Graph

15308 Commits

Author SHA1 Message Date
Andrew Clark
9cdf8a99ed
[Codemod] Update copyright header to Meta (#25315)
* Facebook -> Meta in copyright

rg --files | xargs sed -i 's#Copyright (c) Facebook, Inc. and its affiliates.#Copyright (c) Meta Platforms, Inc. and affiliates.#g'

* Manual tweaks
2022-10-18 11:19:24 -04:00
c0dedance
e54015e267
Refactor: fill in the flow missing type (#25496) 2022-10-18 11:06:35 -04:00
bubucuo
3b1fd5767a
refactor: Flow: typing of Scheduler (#25485)
Flow: typing of Scheduler.
2022-10-18 11:05:38 -04:00
Samuel Susla
14072ce648
Add detach to Offscreen component (#25265) 2022-10-18 15:56:41 +01:00
Sebastian Markbåge
3bb71dfd4b
Rename react-server-dom-webpack entry points to /client and /server (#25504) 2022-10-18 10:15:52 -04:00
Josh Story
71f2c8cf15
move resource acquisition to mutation phase (#25500) 2022-10-17 15:21:06 -07:00
Andrew Clark
500bea532d
Add option to load Fizz runtime from external file (#25499)
* Add feature flag for external Fizz runtime

Only enabled for www for now

* Add option to load Fizz runtime from external file

When unstable_externalRuntimeSrc is provided, React will inject a script
tag that points to the provided URL.

Then, instead of emitting inline scripts, the Fizz stream will emit
HTML nodes with data attributes that encode the instructions. The
external runtime will detect these with a mutation observer and
translate them into runtime commands. This part isn't implemented in 
this PR, though — all this does is set up the option to use 
an external runtime, and inject the script tag.

The external runtime is injected at the same time as bootstrap scripts.
2022-10-17 17:57:59 -04:00
Josh Story
4494f2a86f
[Float] add support for scripts and other enhancements (#25480)
* float enhance!!!

Support preinit as script
Support resources from async scripts
Support saving the precedence place when rendering the shell

There was a significant change to the flushing order of resources which follows the general principal of...
1. stuff that blocks display
2. stuff that we know will be used
3. stuff that was explicitly preloaded

As a consequence if you preinit a style now it won't automatically flush in the shell unless you actually depend on it in your tree. To avoid races with precedence order we now emit a tag that saves the place amongst the precedence hierarchy so late insertions still end up where they were intended

There is also a novel hydration pathway for certain tags. If you render an async script with an onLoad or onError it will always treat it like an insertion rather than a hydration.

* restore preinit style flushing behavior and nits
2022-10-17 14:00:20 -07:00
Andrew Clark
9ecf84ed7f
Bugfix: Suspending in shell during discrete update (#25495)
Fixes a bug that happens when you suspend in the shell (the part of the
tree that is not wrapped in a Suspense boundary) during a
discrete update.

There were two underyling issues. One was just a mistake:
RootDidNotComplete needs to be handled in both renderRootConcurrent and
renderRootSync, but it was only handled in renderRootConcurrent. I did
it this way because I thought this path was unreachable during a sync
update, but I neglected to consider that renderRootSync is sometimes
called for non-concurrent lanes, like when recovering from an error, or
patching up a mutation to an external store.

After I fixed that oversight, the other issue is that we intentionally
error if the shell suspends during a sync update. The idea was that you
should either wrap the tree in a Suspense boundary, or you should mark
the update as a transition to allow React to suspend.

However, this did not take into account selective hydration, which can
force a sync render before anything has even committed. There's no way
in that case to wrap the update in startTransition.

Our solution for now is to remove the error that happens when you
suspend in the shell during a sync update — even for discrete updates.

We will likely revisit this in the future. One appealing possibility is
to commit the whole root in an inert state, as if it were a hidden
Offscreen tree.

Co-authored-by: Sebastian Markbåge <sebastian@calyptus.eu>

Co-authored-by: Sebastian Markbåge <sebastian@calyptus.eu>
2022-10-17 14:17:17 -04:00
Jan Kassens
54f297a60c
Enable useMemoCacheHook for ReactNative-fb build (#25498) 2022-10-17 10:40:59 -04:00
c0dedance
9fb581c7cc
Refactor: merge duplicate imports (#25489)
Co-authored-by: Jan Kassens <jan@kassens.net>
2022-10-16 21:58:58 -04:00
Sebastian Markbåge
bc358362a6
[Flight] Improve Error Messages when Invalid Object is Passed to Client/Host Components (#25492)
* Print built-in specific error message for toJSON

This is a better message for Date.

Also, format the message to highlight the affected prop.

* Describe error messages using JSX elements in DEV

We don't have access to the grand parent objects on the stack so we stash
them on weakmaps so we can access them while printing error messages.

Might be a bit slow.

* Capitalize Server/Client Component

* Special case errror messages for children of host components

These are likely meant to be text content if they're not a supported object.

* Update error messages
2022-10-16 21:49:17 -04:00
Andrew Clark
3ba788ff34
Fix download-build script (#25493)
The download-build script works by scraping the CircleCI job number from
the GitHub status API. Yes, I know this is super hacky but last I
checked this was the least bad of not a lot of options. Because the
response is paginated, sometimes the status for the build job exceeds
the page size.

This increases the page size to 100 so this is less likely to happen.

It'd be great to find a better way to download the artifacts. I don't
love how brittle this solution is. I think switching to the GitHub
Checks API might be worth trying, but last I looked into it, it has
other flaws.
2022-10-16 19:17:07 -04:00
Jan Kassens
780eacd408
Flow upgrade to 0.190 (#25483) 2022-10-15 17:33:51 -04:00
Andrew Clark
4e27881cfe
Add Jest entry file for external-server-runtime (#25484)
Follow-up to #25482.

This file is created during build, but we need an entry point for local
development, too.
2022-10-15 15:33:33 -04:00
Andrew Clark
54f0e0f730
Scaffolding for react-dom/unstable_external-server-runtime (#25482)
* Scaffolding for react-dom/unstable_external-server-runtime

Implements a new bundle type for in our build config called
BROWSER_SCRIPT. This is intended for scripts that get delivered straight
to the browser without needing to be processed by a bundler. (And also
doesn't include any extra UMD crap.)

Right now there's only a single use case so I didn't stress about making
it general purpose.

The use case is: a script that loads the Fizz browser runtime, and sets
up a MutationObserver to receive instructions as HTML streams in. This
will be an alternative option to the default Fizz behavior of sending
the runtime down as inline script tags, to accommodate environments
where inline script tags are not allowed.

There's no development version of this bundle because it doesn't contain
any warnings or run any user code.

None of the actual implementation is in this PR; it just sets up the
build infra.

Co-authored-by: Mofei Zhang <feifei0@fb.com>

* Set BUNDLE_SCRIPT's GCC output format to ES5

This removes the automatic 'use strict' directive, which we don't need.

Co-authored-by: Mofei Zhang <feifei0@fb.com>
2022-10-14 23:29:17 -04:00
Andrew Clark
0eaca37565
Add script to generate inline Fizz runtime (#25481)
* Move Fizz inline instructions to unified module

Instead of a separate module per instruction, this exports all of them
from a unified module.

In the next step, I'll add a script to generate this new module.

* Add script to generate inline Fizz runtime

This adds a script to generate the inline Fizz runtime. Previously, the
runtime source was in an inline comment, and a compiled version of the
instructions were hardcoded as strings into the Fizz implementation,
where they are injected into the HTML stream.

I've moved the source for the instructions to a regular JavaScript
module. A script compiles the instructions with Closure, then generates
another module that exports the compiled instructions as strings.

Then the Fizz runtime imports the instructions from the
generated module.

To build the instructions, run:
  yarn generate-inline-fizz-runtime

In the next step, I'll add a CI check to verify that the generated files
are up to date.

* Check in CI if generated Fizz runtime is in sync

The generated Fizz runtime is checked into source. In CI, we'll ensure
it stays in sync by running the script and confirming nothing changed.
2022-10-14 21:00:14 -04:00
Joseph Savona
69c7246d9d
Initialize useMemoCache with sentinel values (#25465)
* Flush out useMemoCache API

* rename symbol

* rename symbol.for string name

* workaround symbol export not working in unit tests
2022-10-14 15:00:31 -07:00
Sebastian Markbåge
3b814327e2
Allow Async Functions to be used in Server Components (#25479)
This is a temporary step until we allow Promises everywhere.

Currently this serializes to a Lazy which can then be consumed in this same
slot by the client.
2022-10-14 15:09:33 -04:00
Tianyu Yao
44e2ca393e
React DevTools 4.26.0 -> 4.26.1 (#25478) 2022-10-14 10:36:52 -07:00
Andrew Clark
a6bf466892
Extract Fizz instruction set to build macro (#25457)
We're adding an option to Fizz to support an alternate output format
that doesn't rely on inline script tags (see #25437). The two outputs
will share the same "instruction set" of functions. These functions are
currently inlined into the source file; to make this a bit more maintainable,
and eventually have a single source of truth, in preparation for the new option,
this commit moves the instruction set to a separate files that are imported.

In the future, we could improve this further by running Closure on the
instruction set and generating it at build time. This isn't an urgent
improvement, though, because we rarely modify the instruction set.

Co-authored-by: Mofei Zhang <feifei0@fb.com>

Co-authored-by: Mofei Zhang <feifei0@fb.com>
2022-10-14 11:00:35 -04:00
Jan Kassens
ea5bc6bac1
[React Native FB] dynamic feature flag for ref access warning (#25471) 2022-10-14 10:11:42 -04:00
Tianyu Yao
fd31724d5d
Stop spamming highlight events when a component is selected (#25448) 2022-10-13 17:38:05 -07:00
Sebastian Markbåge
08d035bc8f
Remove Shallow Renderer Tests (#25475) 2022-10-13 19:02:03 -04:00
Sebastian Markbåge
a8c16a0040
Split Cache into its own Dispatcher (#25474)
* Missing Hooks

* Remove www forks. These can use __SECRET... instead.

* Move cache to separate dispatcher

These will be available in more contexts than just render.
2022-10-12 23:13:39 -04:00
Josh Story
2cf4352e1c
Implement HostSingleton Fiber type (#25426) 2022-10-11 08:42:42 -07:00
Josh Story
aa9988e5e6
Server render fork for react-dom (#25436)
Publish an aliasable entry for `react-dom` top level package exports for use in server environments. This is a stub containing only the exports that we expect to retain in the top level once 19 is released
2022-10-10 11:06:22 -07:00
Tianyu Yao
513417d695
Return lastNonHostInstance in getInspectorDataForInstance for devtools (#25441) 2022-10-07 15:43:02 -07:00
Andrew Clark
5d60a0b840
Bugfix: LegacyHidden shouldn't defer effects (#25442)
In #24967, I changed the behavior of Offscreen so that passive effects
are not fired when the tree is hidden. I accidentally applied this
behavior to the old LegacyHidden API, too, which is a deprecated
internal-only type that www has been using while they wait for Offscreen
to be ready.

This fixes LegacyHidden so that the effects do not get deferred, like
before. The new behavior still remains in the Offscreen API, which is
experimental and not currently in use in www.
2022-10-06 17:23:27 -04:00
Josh Story
e40893d097
add tests for resource emission when rendering no head or just a head (#25433) 2022-10-05 10:14:40 -07:00
dependabot[bot]
792343dd86
Bump css-what from 2.1.0 to 2.1.3 in /fixtures/flight (#25434) 2022-10-05 17:00:21 +00:00
dependabot[bot]
aea1e6fb37
Bump css-what from 2.1.0 to 2.1.3 in /fixtures/expiration (#25431)
Bumps [css-what](https://github.com/fb55/css-what) from 2.1.0 to 2.1.3.
- [Release notes](https://github.com/fb55/css-what/releases)
- [Commits](https://github.com/fb55/css-what/compare/v2.1.0...v2.1.3)

---
updated-dependencies:
- dependency-name: css-what
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-05 12:54:19 -04:00
dependabot[bot]
5aec50533c
Bump css-what from 2.1.0 to 2.1.3 in /fixtures/attribute-behavior (#25429)
Bumps [css-what](https://github.com/fb55/css-what) from 2.1.0 to 2.1.3.
- [Release notes](https://github.com/fb55/css-what/releases)
- [Commits](https://github.com/fb55/css-what/compare/v2.1.0...v2.1.3)

---
updated-dependencies:
- dependency-name: css-what
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-05 12:53:42 -04:00
dependabot[bot]
da876b9809
Bump css-what from 2.1.0 to 2.1.3 in /fixtures/fiber-debugger (#25430)
Bumps [css-what](https://github.com/fb55/css-what) from 2.1.0 to 2.1.3.
- [Release notes](https://github.com/fb55/css-what/releases)
- [Commits](https://github.com/fb55/css-what/compare/v2.1.0...v2.1.3)

---
updated-dependencies:
- dependency-name: css-what
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-05 12:53:32 -04:00
Josh Story
618388bc32
[Float] Support script preloads (#25432)
* support script preloads

* gates
2022-10-05 09:47:35 -07:00
Sebastian Silbermann
65b3449c89
Include install command for devtools-extension build instructions (#25053)
Include install command for devtools-extension build instructions
2022-10-05 11:27:09 -04:00
Josh Story
2872a26e14
track resources in different roots separately (#25388)
* track resources in different roots separately

* flow types

* add test demonstrating portals deep into shadowRoots

* revert hostcontext changes

* lints

* funge style cache key a la ReactDOMComponentTree

* hide hacks in componentTree
2022-10-04 16:11:15 -07:00
Jan Kassens
ea04a486a7
Flow: remove unused suppressions (#25424)
Removes $FlowFixMe's that are no longer needed.

Used flow/tool from the Flow repo:

```
 ~/Developer/flow/tool update-suppressions .
```
2022-10-04 16:18:12 -04:00
Jan Kassens
9813edef29 Flow upgrade to 0.188
ghstack-source-id: 5c359b97cc
Pull Request resolved: https://github.com/facebook/react/pull/25423
2022-10-04 15:49:48 -04:00
Jan Kassens
3b6826ed9e Flow: inference_mode=constrain_writes
This mode is going to be the new default in Flow going forward.
There was an unfortuante large number of suppressions in this update.

More on the changes can be found in this [Flow blog post](https://medium.com/flow-type/new-flow-language-rule-constrained-writes-4c70e375d190).

Added some of the required annotations using the provided codemod:

```sh
node_modules/.bin/flow codemod annotate-declarations --write .
```

ghstack-source-id: 0b168e1b23
Pull Request resolved: https://github.com/facebook/react/pull/25422
2022-10-04 15:49:48 -04:00
lauren
af9afe9b3f
Update safe-string-coercion to handle additions of string literals (#25286)
* Update safe-string-coercion to handle additions of string literals

Adding strings shouldn't trigger a lint violation of this rule, since
adding strings are always safe.
2022-10-04 12:29:36 -07:00
Jan Kassens
aed33a49cc Flow upgrade to 0.185
ghstack-source-id: 8104710c96
Pull Request resolved: https://github.com/facebook/react/pull/25420
2022-10-04 13:50:59 -04:00
Jan Kassens
f02a5f5c79 Flow upgrade to 0.182
ghstack-source-id: b9bb8c1560
Pull Request resolved: https://github.com/facebook/react/pull/25419
2022-10-04 13:37:58 -04:00
Jan Kassens
72593f008e Flow upgrade to 0.176
This upgrade deprecated calling `new` on functions which introduced
the majority of breakages and I suppressed those.

ghstack-source-id: 545363f3c5
Pull Request resolved: https://github.com/facebook/react/pull/25418
2022-10-04 13:37:58 -04:00
Jan Kassens
46d40f306a Flow upgrade to 0.175
ghstack-source-id: 99008118ef
Pull Request resolved: https://github.com/facebook/react/pull/25417
2022-10-04 13:37:58 -04:00
Jan Kassens
1089faf0d8 Flow: run codemod to remove existential type
The existential type `*` was deprecated and a codemod provided to replace it. Ran that and did some manual fixups:

```sh
node_modules/.bin/flow codemod replace-existentials --write .
```

ghstack-source-id: 4c98b8db6a
Pull Request resolved: https://github.com/facebook/react/pull/25416
2022-10-04 13:37:58 -04:00
Lauren Tan
3fd9bd8e74 Add RulesOfHooks support for use
Usage of the new `use` hook needs to conform to the rules of hooks, with
the one exception that it can be called conditionally.

ghstack-source-id: 7ea5beceaf
Pull Request resolved: https://github.com/facebook/react/pull/25370
2022-10-04 12:41:29 -04:00
Jan Kassens
338e6a967c Flow upgrade to 0.155
This version banned use of this in object functions.

ghstack-source-id: f49fd5e1b7
Pull Request resolved: https://github.com/facebook/react/pull/25414
2022-10-04 11:49:15 -04:00
Jan Kassens
8bc95bb3c8 Flow upgrade to 0.154
ghstack-source-id: d84024950a
Pull Request resolved: https://github.com/facebook/react/pull/25413
2022-10-04 11:49:14 -04:00
Jan Kassens
9f8a98a390 Flow upgrade to 0.153
- method unbinding is no longer supported in Flow for soundness, this added a bunch of suppressions
- Flow now prevents objects to be supertypes of interfaces/classes

ghstack-source-id: d7749cbad8
Pull Request resolved: https://github.com/facebook/react/pull/25412
2022-10-04 11:30:06 -04:00