21 Commits
Author SHA1 Message Date
Rubén Norte d6adb9f48a Remove React Native deep imports from Fantom (#58605)
Summary:
Pull Request resolved: https://github.com/react/react-native/pull/58605

Use global DOM APIs, supported React Native entry points, and package-relative implementation imports throughout Fantom. Use the renderer-only private interface for the existing public-instance conversion helpers instead of importing Node internals.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D120717572

fbshipit-source-id: 1aae11b7b9434c783d42ca289e2c6edd17aa887c
2026-09-21 11:31:38 -07:00
Sam Zhou fdcce4f673 Turn on experimental.new_this_typing in xplat (#58293)
Summary:
Pull Request resolved: https://github.com/react/react-native/pull/58293

Changelog: [Internal]

Reviewed By: vzaidman

Differential Revision: D118513884

fbshipit-source-id: a33a81eab930ac29663410cf04163aebb87062ad
2026-09-02 13:03:29 -07:00
Ruslan Lesiutin 2bb56dc94b Add enableConditionalUseWarning React feature flag (#57783)
Summary:
Pull Request resolved: https://github.com/react/react-native/pull/57783

# Changelog: [Internal]

Adds the `enableConditionalUseWarning` dynamic React feature flag, which the React renderer reads from `ReactNativeInternalFeatureFlags`. The flag gates the new warning for conditional use of `use()` based on cache state: https://react.dev/warnings/conditional-use-of-use

This is a dev-only warning, I don't see any reasons to control this via gk.

Reviewed By: antonk52

Differential Revision: D114407789

fbshipit-source-id: d63dd09180e6560a82d178610c7ae24b9e31b65e
2026-08-03 05:40:14 -07:00
Pieter De Baets 2bc248c535 Propage startJSSamplingProfiler error (#57587)
Summary:
Pull Request resolved: https://github.com/react/react-native/pull/57587

Adds rethrow in catch blocks when `startJSSamplingProfiler()` fails, preventing the `finally` block from attempting to stop a profiler that was never started.

Changelog: [Internal]

Reviewed By: thegreatercurve

Differential Revision: D112405579

fbshipit-source-id: 4b1cc6746d8ba29df99be57e583ee06ac742c12c
2026-07-17 02:43:24 -07:00
Rubén Norte 2bb7dbb499 Add an interactive REPL for Fantom (yarn fantom-cli) (#57387)
Summary:
Pull Request resolved: https://github.com/react/react-native/pull/57387

Adds `yarn fantom-cli`, an interactive REPL that evaluates JavaScript against the same native tester binary and Hermes runtime that Fantom tests run in. State persists across lines, input goes through Metro/Babel (so `import`, JSX and Flow all work), and the environment is set up the same way tests set it up — `React`, `ReactNative` and the `Fantom` API are available globally, so you can render surfaces and drive them interactively from the prompt.

The native tester gains an `--interactive` mode that loads a warm-up bundle without running tests and then evaluates length-prefixed snippets read from stdin, reporting results, console output and errors back as newline-delimited JSON. A Node driver hosts a Metro server, builds the warm-up bundle, spawns the binary, and bridges each line of input into the live runtime (top-level declarations persist across evaluations).

Features:

- Console-style output: results are printed with an inspector similar to the Chrome DevTools / Node.js consoles (nested objects/arrays up to a depth limit, quoted strings, functions/classes, `Map`/`Set`/`RegExp`/`Date`/`Error`, class instances, circular references, multi-line wrapping), colorized by type when stdout is a terminal. Inspecting a property never aborts the result or leaks into later evaluations: a property whose getter fails renders as `[Thrown: <error>]`, including getters that fail asynchronously through the runtime's global error handler (e.g. accessing a `react-native` export backed by a TurboModule that isn't registered).
- Autocompletion: pressing Tab completes global identifiers, in-scope bindings and object properties (property names are listed without invoking getters).
- Node-like CLI: with no arguments it starts the REPL; `-e <code>` evaluates a snippet and exits; a filename runs that script and exits. In the non-interactive modes the value of a trailing expression is not printed (use `console.log`) and a thrown error exits with a non-zero status code.

Also documents the REPL in the Fantom README.

Changelog: [Internal]

Reviewed By: javache, sammy-SC

Differential Revision: D110187712

fbshipit-source-id: 3e76c498ae04b8b1ce9e0e27e5ce6b6a0cd11e09
2026-07-01 08:18:34 -07:00
Pieter De Baets 610192ed9b Clean up enableEagerAlternateStateNodeCleanup (#57358)
Summary:
Pull Request resolved: https://github.com/react/react-native/pull/57358

The `enableEagerAlternateStateNodeCleanup` flag is no longer read by the renderer, so the feature-flag definition and the two prelude overrides that forced it on become dead code.

[Internal]

Reviewed By: lenaic

Differential Revision: D110043719

fbshipit-source-id: 24a7e2b85ec60da1cb1855f444bba5e1e6fc4288
2026-06-29 06:40:21 -07:00
Zeya Peng d8297f7103 Turn on enableViewTransitionForPersistenceMode
Summary:
## Changelog:

[Internal] [Changed] - Turn on enableViewTransitionForPersistenceMode

Reviewed By: christophpurrer

Differential Revision: D97479631

fbshipit-source-id: 78803db6f7b7742c63a65251a9df3ee777e71f56
2026-03-20 15:39:48 -07:00
Marco Wang 53cd9cec15 transformTypeParamBound codemod 9/9 (#55948)
Summary:
X-link: https://github.com/facebook/metro/pull/1665

Pull Request resolved: https://github.com/facebook/react-native/pull/55948

js1 flow-runner codemod flow/transformTypeParamBound --format-files=false xplat/js

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D95429551

fbshipit-source-id: 6f5694fed74364c6f1c58e28376c86eae6201366
2026-03-05 21:26:42 -08:00
Andrew Datsenko 43278f94d2 Add toMatchInlineSnapshot support (#55892)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55892

Adds `toMatchInlineSnapshot()` to the Fantom custom `expect` implementation,
matching Jest's inline snapshot behavior. On first run, snapshot values are
written directly into the test source file as template literal arguments.
On subsequent runs, values are compared and the test fails on mismatch
unless the `-u` flag is passed to force an update.

The implementation spans the two-process Fantom architecture:

**Runtime (Hermes VM):**
- `snapshotContext.js`: New `toMatchInlineSnapshot` method that compares
  received values against existing inline snapshots, captures stack traces
  for new/mismatched snapshots, and tracks results per test.
- `expect.js`: New `toMatchInlineSnapshot` method on the `Expect` class
  that serializes values with `prettyFormat` and delegates to snapshot context.
- `setup.js`: Plumbs `inlineSnapshotResults` through `TestCaseResult`.

**Runner (Node.js):**
- `snapshotUtils.js`: New `processInlineSnapshotResults` resolves VM stack
  traces back to original source locations via source map symbolication.
  New `saveInlineSnapshotsToSource` directly rewrites the test source file
  by finding each `toMatchInlineSnapshot(...)` call and replacing its
  argument with the formatted template literal. This avoids jest-snapshot's
  `saveInlineSnapshots` which requires Babel and Prettier 2.x.
- `runner.js`: Generates source maps when inline snapshots need updating,
  collects pending snapshots across test configs, and writes them after
  all configs complete.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D95077617

fbshipit-source-id: 6a25c8ce966ed71ecd8977c13c25de5907311c6e
2026-03-05 11:14:41 -08:00
Andrew Datsenko c4a982920d Add LLVM coverage conversion to LCOV format (#55860)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55860

Changelog: [Internal]

This diff adds the ability to convert LLVM coverage JSON output to LCOV format for C++ code coverage in react-native-fantom.

Key additions:
- `convertLLVMCoverage.js`: Converts LLVM coverage data (segments, branches, functions) to LCOV format lines
- `types.flow.js`: Flow type definitions for LLVM coverage data structures
- Test utilities and fixtures for validating the conversion with real coverage data from various C++ files (AppSettings.cpp, Class.h, DevSettingsModule.h, NativeFantom.cpp/h, RawPropsKey.cpp)

This enables reporting C++ code coverage from Fantom tests in a standard format that can be consumed by coverage tools.

Reviewed By: sammy-SC

Differential Revision: D90135000

fbshipit-source-id: 3b22250c4b1665748b6ccb4feb79cc1c20ec7fa6
2026-03-03 09:28:25 -08:00
Jack Pope ba4ed28cb0 Add host instance pointer and text node feature flags (#55614)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55614

- enableFragmentRefsInstanceHandles
  - Enables a pointer on each element back to the FragmentInstances that control it. Needed to implement the common IntersectionObserver pattern of reusing IntersectionObservers across multiple callbacks. See more in https://github.com/facebook/react/pull/34935
- enableFragmentRefsTextNodes
  - This should be a noop on RN as unlike dom, text nodes are considered host components and already handled. Text without a `<Text/>` wrapper throws an error.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D93479122

fbshipit-source-id: 639369893c8aafc1d2bf0ffbdf4bf09fe6dca45c
2026-02-18 09:53:41 -08:00
Marco Wang 894a1f16ef Transform mixed to unknown in xplat/js (#54954)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54954

We are transforming the following utility types to be more consistent with typescript and better AI integration:

* `$NonMaybeType` -> `NonNullable`
* `$ReadOnly` -> `Readonly`
* `$ReadOnlyArray` -> `ReadonlyArray`
* `$ReadOnlyMap` -> `ReadonlyMap`
* `$ReadOnlySet` -> `ReadonlySet`
* `$Keys` -> `keyof`
* `$Values` -> `Values`
* `mixed` -> `unknown`

See details in https://fb.workplace.com/groups/flowlang/permalink/1837907750148213/.
drop-conflicts

Reviewed By: SamChou19815

Differential Revision: D89581744

fbshipit-source-id: 58a6c246629bbe4fb5c0af447dc002c48e10c342
2025-12-22 12:25:44 -08:00
Andrew Datsenko 10a46f7b52 Add support for JS coverage (#53410)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53410

Changelog: [Internal]
Adding babel-istanbul-plugin to instrument bundle code with coverage reporting.
Metro will transform source code only when coverage flag is set up globally in jest.
Coverage map is then provided by runner as part of test result.

Reviewed By: sammy-SC

Differential Revision: D80716433

fbshipit-source-id: 3831f227f8793f874f0d2366759bb6916e747c72
2025-09-04 07:19:56 -07:00
Sam Zhou cf664c65e2 Standardize subtyping error code into incompatible-type in react native and metro (#53312)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53312

Changelog: [Internal]

Reviewed By: jbrown215

Differential Revision: D80400976

fbshipit-source-id: 196af69c0b9621b2a2675b232406639773e04933
2025-08-18 09:04:31 -07:00
Ruslan Shestopalyuk 5fc23d7c62 Add type-safe API for passing around benchmark results (#53143)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53143

# Changelog:
[Internal] -

This refactors the way Fantom benchmark test results are passed to the top level, making it type safe and more maintainable.

Reviewed By: andrewdacenko

Differential Revision: D79812707

fbshipit-source-id: d8bfef7e1b0c11b277a08f5e4c810f8c1efd7f89
2025-08-07 10:46:26 -07:00
Ruslan Shestopalyuk 8ef39b491c Implement benchmark comparison of different feture flag configurations (#52925)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52925

# Changelog:
[Internal] -

This adds an extra "ranking" report when running Fantom benchmark vs different React Feature flag configurations.

It can be very useful when implementing some particular optimization, to streamline the before/after comparison wit this optimization enabled/disabled.

Reviewed By: andrewdacenko

Differential Revision: D79269601

fbshipit-source-id: f29e761e313d6857e5b3ac65faf2a387a84be9df
2025-08-05 08:34:35 -07:00
Rubén Norte b903ed7940 Add support for JS sampling profiler (#52827)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52827

Changelog: [internal]

This adds **support for creating Hermes/JS sampling profiler traces in Fantom**, which is especially useful when running benchmarks.

Usage:
```
FANTOM_PROFILE_JS=1 yarn fantom Animated-benchmark
```

Output:

 {F1980642216}

After this, the trace is fully symbolicated.

Can be opened directly in Google Chrome:
{F1980642229}

Or in the built-in viewer in VSCode:

 {F1980642242} {F1980642240} {F1980642241}

When collapsing frames in the Flame Chart viewer in VSCode, we can quickly identify opportunities for optimizations.

This also supports multi-config environments. In that case, trace file names are created using a short representation of the configuration.

User guide for benchmarks in Fantom, including how to use this, will be done in a future diff.

NOTE: This still doesn't work in OSS because we don't support optimized mode there. In dev mode, there's a segmentation fault coming from this line: `hermesRuntime->sampledTraceToStreamInDevToolsFormat(fileStream)`

Reviewed By: sammy-SC

Differential Revision: D78905646

fbshipit-source-id: 382ddd5034db601309bd118cedde2fe0d57fde98
2025-08-05 05:36:26 -07:00
Rubén Norte af670c8319 Honor ignored frames in errors reported by Fantom (#52765)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52765

Changelog: [internal]

Reported locations for errors in Fantom is wrong, because it seems it's not ignoring "infra" frames.

This was caused by the `stack` property in `ErrorWithCustomBlame` being set on the error objects and shadowing the getter that removes the necessary frames. This fixes that by forcing that property to be deleted.

Reviewed By: christophpurrer

Differential Revision: D78747119

fbshipit-source-id: 81d6ce74041382d7582e2066409e839d28d91052
2025-07-23 04:41:42 -07:00
Rubén Norte 7dc84491e9 Fix reporting of errors without stack traces (#52601)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52601

Changelog: [internal]

Fixes a bug in Fantom when throwing a value that's not an instance of `Error` in a test.

Reviewed By: javache

Differential Revision: D78332756

fbshipit-source-id: 350479dcb7bcea399070c6851aca76a1d1cc2629
2025-07-15 03:45:28 -07:00
Jack Pope d18f1f7ca3 Enable Fragment Refs for intersection observers on Fabric (#52474)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52474

1. Enables the feature flags for fragment refs on fbsource
2. Adds a test with Fantom for usage of `FragmentInstance#observeUsing` and `FragmentInstance#unobserveUsing`.
3. Exposes the `ReactFragmentInstance` type with the common methods that are used on native. We can override the DOM only methods in www libdefs.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D74326262

fbshipit-source-id: e35ee45b23179ad3ba5527763567c9b04c127eff
2025-07-09 16:03:25 -07:00
Tim Yung d6f29c8afd RN: Move {packages => private}/react-native-fantom (#51938)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/51938

Moves `packages/react-native-fantom` to `private/react-native-fantom`.

Changelog:
[Internal]

Reviewed By: huntie

Differential Revision: D76368959

fbshipit-source-id: 8d62f792229c10cd108dc849e8629d3174dc72c1
2025-06-11 23:49:51 -07:00