Commit Graph

13127 Commits

Author SHA1 Message Date
Dominic Gannaway
58c895e59c Revert focus event PRs (#18655)
* Revert "Further cleanup to before/after blur (#18649)"

This reverts commit e2ccbf0358.

* Revert "Unify Flare FocusWithin responder with useFocusWithin (#18636)"

This reverts commit f24a9e7098.
2020-04-17 16:27:19 +01:00
Dominic Gannaway
e2ccbf0358 Further cleanup to before/after blur (#18649) 2020-04-17 11:52:29 +01:00
Brian Vaughn
c5c25d35a3 Fixed DevTools extension build:dev command (#18648) 2020-04-16 17:39:16 -07:00
dependabot[bot]
f8b084276d Bump https-proxy-agent from 2.2.1 to 2.2.4 in /scripts/release (#18642)
Bumps [https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-agent) from 2.2.1 to 2.2.4.
- [Release notes](https://github.com/TooTallNate/node-https-proxy-agent/releases)
- [Commits](https://github.com/TooTallNate/node-https-proxy-agent/compare/2.2.1...2.2.4)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-04-16 16:06:13 -07:00
dependabot[bot]
0f9b30f7b5 Bump https-proxy-agent from 2.2.2 to 2.2.4 (#18643)
Bumps [https-proxy-agent](https://github.com/TooTallNate/node-https-proxy-agent) from 2.2.2 to 2.2.4.
- [Release notes](https://github.com/TooTallNate/node-https-proxy-agent/releases)
- [Commits](https://github.com/TooTallNate/node-https-proxy-agent/compare/2.2.2...2.2.4)

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-04-16 16:06:06 -07:00
Dominic Gannaway
32bb44c80a Clean up modern plugins to remove dead code (#18639) 2020-04-16 20:10:23 +01:00
Dan Abramov
0301f3e24f Statically disable factory components for WWW (#18641) 2020-04-16 19:42:30 +01:00
Dominic Gannaway
f24a9e7098 Unify Flare FocusWithin responder with useFocusWithin (#18636) 2020-04-16 19:35:41 +01:00
Dominic Gannaway
b1a083183c Revert legacy plugin modules (#18638) 2020-04-16 18:46:24 +01:00
Dominic Gannaway
31977d1bb3 Create copy of Legacy event plugins for Modern system (#18637) 2020-04-16 16:09:05 +01:00
Andrew Clark
c12c2c4c8c Run error replay test again new reconciler (#18628)
This is one of our few tests of an internal function. Need to import
the module that corresponds to the reconciler that's being tested.
2020-04-16 08:08:22 -07:00
Boris Serdiuk
7b4403cecd Fix requiring timers module with non standard require (#18632)
fixes #18589
2020-04-16 12:36:09 +01:00
Thomas Brown
5f6b75dd26 ADD: disableRemotePlayback attribute for HTML5 videos (#18619)
* Add support for disableremoteplayback

* Order attributes alphabetically

Co-authored-by: Tom Brown <Thomas.Brown-CIC-UK@ibm.com>
2020-04-16 10:23:48 +01:00
Brian Vaughn
71964c0346 Fix CI (#18626) 2020-04-15 22:27:24 -07:00
Andrew Clark
50b9f154c1 Fix wrong command in config.yml (#18624) 2020-04-15 21:44:38 -07:00
Brian Vaughn
22dc2e42bd Add experimental DebugTracing logger for internal use (#18531) 2020-04-15 19:10:15 -07:00
Andrew Clark
dbd2626855 Update nvmrc to the same one used in CI (#18623) 2020-04-15 16:03:02 -07:00
Andrew Clark
b680174841 Delete mutableSourceFirstPendingUpdateTime (#18613) 2020-04-15 07:47:37 -07:00
Andrew Clark
cbafbf4f32 Fix typo in TestFlags
Copypasta when setting up `old` and `new` aliases. `old` should mean
that `enableNewReconciler` is off.
2020-04-14 23:32:53 -07:00
Dominic Gannaway
d53988a9d1 ReactDOM.useEvent: add useEvent interaction hook (#18604) 2020-04-14 22:06:46 +01:00
Dominic Gannaway
bf55ea7434 Move beforeblur phase to prepareForCommit (#18609) 2020-04-14 21:30:54 +01:00
Andrew Clark
843b50cbe1 Remove .internal from more test suites (#18597) 2020-04-14 07:43:00 -07:00
BetaSu
1d7bd52688 remove unnecessary variable comparation (#18598)
Since it will continue when the props are equal in line 767, there is no need to compare whether they are not equal.
2020-04-14 14:53:47 +01:00
Andrew Clark
b928fc030a Delete flushSuspenseFallbacksInTests flag (#18596)
* Move renderer `act` to work loop

* Delete `flushSuspenseFallbacksInTests`

This was meant to be a temporary hack to unblock the `act` work, but it
quickly spread throughout our tests.

What it's meant to do is force fallbacks to flush inside `act` even in
Concurrent Mode. It does this by wrapping the `setTimeout` call in a
check to see if it's in an `act` context. If so, it skips the delay and
immediately commits the fallback.

Really this is only meant for our internal React tests that need to
incrementally render. Nobody outside our team (and Relay) needs to do
that, yet. Even if/when we do support that, it may or may not be with
the same `flushAndYield` pattern we use internally.

However, even for our internal purposes, the behavior isn't right
because a really common reason we flush work incrementally is to make
assertions on the "suspended" state, before the fallback has committed.
There's no way to do that from inside `act` with the behavior of this
flag, because it causes the fallback to immediately commit. This has led
us to *not* use `act` in a lot of our tests, or to write code that
doesn't match what would actually happen in a real environment.

What we really want is for the fallbacks to be flushed at the *end` of
the `act` scope. Not within it.

This only affects the noop and test renderer versions of `act`, which
are implemented inside the reconciler. Whereas `ReactTestUtils.act` is
implemented in "userspace" for backwards compatibility. This is fine
because we didn't have any DOM Suspense tests that relied on this flag;
they all use test renderer or noop.

In the future, we'll probably want to move always use the reconciler
implementation of `act`. It will not affect the prod bundle, because we
currently only plan to support `act` in dev. Though we still haven't
completely figured that out. However, regardless of whether we support a
production `act` for users, we'll still need to write internal React
tests in production mode. For that use case, we'll likely add our own
internal version of `act` that assumes a mock Scheduler and might rely
on hacks that don't 100% align up with the public one.
2020-04-13 20:02:18 -07:00
Andrew Clark
f3f3d77c20 Fix www tests not running in prod (#18593)
I made a mistake when setting these up a while ago. Setting the NODE_ENV
in the CircleCI config doesn't work because it's also set in the node
script command.

The number of test commands is getting out of control. Might need to fix
it at some point. Not today for me.
2020-04-13 15:53:13 -07:00
Andrew Clark
bec7599067 Migrate conditional tests to gate pragma (#18585)
* Migrate conditional tests to gate pragma

I searched through the codebase for this pattern:

```js
describe('test suite', () => {
  if (!__EXPERIMENTAL__) { // or some other condition
    test("empty test so Jest doesn't complain", () => {});
    return;
  }

  // Unless we're in experimental mode, none of the tests in this block
  // will run.
})
```

and converted them to the `@gate` pragma instead.

The reason this pattern isn't preferred is because you end up disabling
more tests than you need to.

* Add flag for www release channels

Using a heuristic where I check a flag that is known to only be enabled
in www. I left a TODO to instead set the release channel explicitly in
each test config.
2020-04-13 14:45:52 -07:00
Chris Dobson
6c43a62c0f DevTools: Switch between "Rendered At" renders using keyboard arrow keys (#18586)
* Add keyboard navigation to fibre info sidebar

Co-authored-by: Brian Vaughn <brian.david.vaughn@gmail.com>
2020-04-13 13:00:13 -07:00
Andrew Clark
0c3c27a718 Fix "missing flag" error for non-boolean types (#18592)
Not all test flags are booleans, e.g. the build type
2020-04-13 12:57:31 -07:00
Andrew Clark
65237a237e Codemod it.experimental to gate pragma (#18582)
* Codemod it.experimental to gate pragma

Find-and-replace followed by Prettier

* Delete it.experimental

Removes the API from our test setup script
2020-04-13 10:28:59 -07:00
Andrew Clark
42d7c2e8f7 Add pragma for feature testing: @gate (#18581)
* Add pragma for feature testing: @gate

The `@gate` pragma declares under which conditions a test is expected to
pass.

If the gate condition passes, then the test runs normally (same as if
there were no pragma).

If the conditional fails, then the test runs and is *expected to fail*.

An alternative to `it.experimental` and similar proposals.

Examples
--------

Basic:

```js
// @gate enableBlocksAPI
test('passes only if Blocks API is available', () => {/*...*/})
```

Negation:

```js
// @gate !disableLegacyContext
test('depends on a deprecated feature', () => {/*...*/})
```

Multiple flags:

```js
// @gate enableNewReconciler
// @gate experimental
test('needs both useEvent and Blocks', () => {/*...*/})
```

Logical operators (yes, I'm sorry):

```js
// @gate experimental && (enableNewReconciler || disableSchedulerTimeoutBasedOnReactExpirationTime)
test('concurrent mode, doesn\'t work in old fork unless Scheduler timeout flag is disabled', () => {/*...*/})
```

Strings, and comparion operators

No use case yet but I figure eventually we'd use this to gate on
different release channels:

```js
// @gate channel ===  "experimental" || channel === "modern"
test('works in OSS experimental or www modern', () => {/*...*/})
```

How does it work?

I'm guessing those last two examples might be controversial. Supporting
those cases did require implementing a mini-parser.

The output of the transform is very straightforward, though.

Input:
```js
// @gate a && (b || c)
test('some test', () => {/*...*/})
```

Output:

```js
_test_gate(ctx => ctx.a && (ctx.b || ctx.c, 'some test'), () => {/*...*/});
```

It also works  with `it`, `it.only`, and `fit`. It leaves `it.skip` and
`xit` alone because those tests are disabled anyway.

`_test_gate` is a global method that I set up in our Jest config. It
works about the same as the existing `it.experimental` helper.

The context (`ctx`) argument is whatever we want it to be. I set it up
so that it throws if you try to access a flag that doesn't exist. I also
added some shortcuts for common gating conditions, like `old`
and `new`:

```js
// @gate experimental
test('experimental feature', () => {/*...*/})

// @gate new
test('only passes in new reconciler', () => {/*...*/})
```

Why implement this as a pragma instead of a runtime API?

- Doesn't require monkey patching built-in Jest methods. Instead it
  compiles to a runtime function that composes Jest's API.
- Will be easy to upgrade if Jest ever overhauls their API or we switch
  to a different testing framework (unlikely but who knows).
- It feels lightweight so hopefully people won't feel gross using it.
  For example, adding or removing a gate pragma will never affect the
  indentation of the test, unlike if you wrapped the test in a
  conditional block.

* Compatibility with console error/warning tracking

We patch console.error and console.warning to track unexpected calls
in our tests. If there's an unexpected call, we usually throw inside
an `afterEach` hook. However, that's too late for tests that we
expect to fail, because our `_test_gate` runtime can't capture the
error. So I also check for unexpected calls inside `_test_gate`.

* Move test flags to dedicated file

Added some instructions for how the flags are set up and how to
use them.

* Add dynamic version of gate API

Receives same flags as the pragma.

If we ever decide to revert the pragma, we can codemod them to use
this instead.
2020-04-13 10:14:34 -07:00
Sebastian Markbåge
72d00ab623 Fix Component Stacks for IE and Native Classes in Safari (#18575)
* Add more edge cases to fixture

Also adjust some expectations. I think the column should ideally be 1 but varies.
The Example row is one line off because it throws on the hook but should ideally be the component.
Similarly class components with constructors may have the line in the constructor.

* Account for the construct call taking a stack frame

We do this by first searching for the first different frame, then find
the same frames and then find the first different frame again.

* Throw controls

Otherwise they don't get a stack frame associated with them in IE.

* Protect against generating stacks failing

Errors while generating stacks will bubble to the root. Since this technique
is a bit sketchy, we should probably protect against it.

* Don't construct the thing that throws

Instead, we pass the prototype as the "this". It's new every time anyway.
2020-04-10 19:39:02 -07:00
Sebastian Markbåge
98d410f500 Build Component Stacks from Native Stack Frames (#18561)
* Implement component stack extraction hack

* Normalize errors in tests

This drops the requirement to include owner to pass the test.

* Special case tests

* Add destructuring to force toObject which throws before the side-effects

This ensures that we don't double call yieldValue or advanceTime in tests.

Ideally we could use empty destructuring but ES lint doesn't like it.

* Cache the result in DEV

In DEV it's somewhat likely that we'll see many logs that add component
stacks. This could be slow so we cache the results of previous components.

* Fixture

* Add Reflect to lint

* Log if out of range.

* Fix special case when the function call throws in V8

In V8 we need to ignore the first line. Normally we would never get there
because the stacks would differ before that, but the stacks are the same if
we end up throwing at the same place as the control.
2020-04-10 13:32:12 -07:00
Brian Vaughn
8e13f099ab Overhauled release scripts and docs (#18569)
* Overhauled release scripts and docs
2020-04-10 12:28:40 -07:00
Andrew Clark
af1b039bdd ESLint rule to forbid cross fork imports (#18568)
Modules that belong to one fork should not import modules that belong to
the other fork.

Helps make sure you correctly update imports when syncing changes across
implementations.

Also could help protect against code size regressions that might happen
if one of the forks accidentally depends on two copies of the same
module.
2020-04-09 18:11:34 -07:00
Sebastian Markbåge
50bdd75a60 Bubble errors if processing the error itself errors (#18567)
If we've tried completing an incomplete boundary once and failed, we don't
need to try again.
2020-04-09 17:40:11 -07:00
Sebastian Markbåge
348ed0e93f Don't return from perform/completeUnitOfWork (#18566)
* Remove unnecessary workInProgress line

* Mutate workInProgress instead of returning

We were ambivalent about this before.

* Make handleError a void method too
2020-04-09 17:12:04 -07:00
Andrew Clark
b04c7fa28c Decouple expiration times and transition timeouts (#17920)
We currently use the expiration time to represent the timeout of a
transition. Since we intend to stop treating work priority as a
timeline, we can no longer use this trick.

In this commit, I've changed it to store the event time on the update
object instead. Long term, we will store event time on the root as a map
of transition -> event time. I'm only storing it on the update object
as a temporary workaround to unblock the rest of the changes.
2020-04-09 15:09:36 -07:00
Andrew Clark
dc630d3374 Fork ReactFiberExpirationTime
I had thought I wouldn't fork this one because the new "lanes" module
will be pretty different, but I need it to make some
incremental changes.
2020-04-09 15:09:34 -07:00
Dan Abramov
e5d06e34b6 Revert "Clear more Fiber fields in detachFiber (#18556)" (#18562)
This reverts commit d48dbb8249.
2020-04-09 20:45:02 +01:00
Sebastian Markbåge
cbab25bb51 Exclude forwardRef and memo from stack frames (#18559)
We can't patch the row. We could give these their own "built-in" stack
frame since they're conceptually HoCs. However, from a debugging
perspective this is not very useful meta data and quite noisy. So I'm
just going to exclude them.
2020-04-09 11:42:22 -07:00
Andrew Clark
26fc16484e Script for syncing changes between forks (#18550)
Adds command `yarn merge-fork`.

```sh
yarn merge-fork --base-dir=packages/react-reconciler/src ReactFiberWorkLoop
```

This will take all the changes in `ReactFiberWorkLoop.new.js` and apply
them to `ReactFiberWorkLoop.old.js`.

You can merge multiple modules at a time:

```sh
yarn merge-fork \
  --base-dir=packages/react-reconciler/src \
  ReactFiberWorkLoop \
  ReactFiberBeginWork \
  ReactFiberCompleteWork \
  ReactFiberCommitWork
```

You can provide explicit "old" and "new" file names. This only works
for one module at a time:

```sh
yarn merge-fork \
  --base-dir=packages/react-reconciler/src \
  --old=ReactFiberExpirationTime.js \
  --new=ReactFiberLane.js
```

The default is to merge changes from the new module to the old one. To
merge changes in the opposite direction, use `--reverse`.

```sh
yarn merge-fork \
  --reverse \
  --base-dir=packages/react-reconciler/src \
  ReactFiberWorkLoop
```

By default, the changes are compared to HEAD. You can use `--base-ref`
to compare to any rev. For example, while working on a PR, you might
make multiple commits to the new fork before you're ready to backport
them to the old one. In that case, you want to compare to the merge
base of your PR branch:

```sh
yarn merge-fork \
  --base-ref=$(git merge-base HEAD origin/master)
  --base-dir=packages/react-reconciler/src \
  ReactFiberWorkLoop
```
2020-04-09 11:37:13 -07:00
Sebastian Markbåge
11ac10b44e Port error boundaries test to yieldValue (#18558) 2020-04-09 11:13:01 -07:00
Dominic Gannaway
d48dbb8249 Clear more Fiber fields in detachFiber (#18556) 2020-04-09 18:31:34 +01:00
Dominic Gannaway
0566b706ee Fix fiber memory leak with runAllPassiveEffectDestroysBeforeCreates (#18554) 2020-04-09 15:35:07 +01:00
Dominic Gannaway
ca1a703d21 Make enableLegacyFBSupport flag dynamic for www (#18551) 2020-04-09 15:31:36 +01:00
Dominic Gannaway
8cbce05be1 Move plugins into their own directory (#18553) 2020-04-09 14:18:33 +01:00
Dan Abramov
c74f0b0646 Update stale.yml 2020-04-09 13:36:11 +01:00
Andrew Clark
4c6470cb3b Point ReactDOMForked to the new implementation
Updates Rollup, Jest, and Flow configuration to point to the new
entry points.
2020-04-09 00:03:35 -07:00
Andrew Clark
17f582e045 Add forked copies of reconciler modules
All changes in this commit were generated by the following commands.

Copy each module that ends with `.old` to a new file that ends
with `.new`:

```sh
for f in packages/react-reconciler/src/*.old.js; do cp "$f" "$(echo "$f" | sed s/\.old/\.new/)"; done
```

Then transform the internal imports:

```sh
grep -rl --include="*.new.js" '.old' packages/react-reconciler/src/| xargs sed -i '' "s/\.old\'/\.new\'/g"
```
2020-04-09 00:03:35 -07:00
Andrew Clark
376d5c1b5a Split cross-package types from implementation
Some of our internal reconciler types have leaked into other packages.
Usually, these types are treated as opaque; we don't read and write
to its fields. This is good.

However, the type is often passed back to a reconciler method. For
example, React DOM creates a FiberRoot with `createContainer`, then
passes that root to `updateContainer`. It doesn't do anything with the
root except pass it through, but because `updateContainer` expects a
full FiberRoot, React DOM is still coupled to all its fields.

I don't know if there's an idiomatic way to handle this in Flow. Opaque
types are simlar, but those only work within a single file. AFAIK,
there's no way to use a package as the boundary for opaqueness.

The immediate problem this presents is that the reconciler refactor will
involve changes to our internal data structures. I don't want to have to
fork every single package that happens to pass through a Fiber or
FiberRoot, or access any one of its fields. So my current plan is to
share the same Flow type across both forks. The shared type will be a
superset of each implementation's type, e.g. Fiber will have both an
`expirationTime` field and a `lanes` field. The implementations will
diverge, but not the types.

To do this, I lifted the type definitions into a separate module.
2020-04-08 23:49:23 -07:00