Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36545
This is part of a series of changes to minimize the number of spans committed to EditText, as a mitigation for platform issues on Samsung devices. See this [GitHub thread]( https://github.com/facebook/react-native/issues/35936#issuecomment-1411437789) for greater context on the platform behavior.
This adds ReactForegroundColorSpan to the list of spans eligible to be stripped.
Changelog:
[Android][Fixed] - Minimize Spans 4/N: ReactForegroundColorSpan
Reviewed By: javache
Differential Revision: D44240780
fbshipit-source-id: d86939cc2d7ed9116a4167026c7d48928fc51757
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36547
This is part of a series of changes to minimize the number of spans committed to EditText, as a mitigation for platform issues on Samsung devices. See this [GitHub thread]( https://github.com/facebook/react-native/issues/35936#issuecomment-1411437789) for greater context on the platform behavior.
This adds `ReactBackgroundColorSpan` to the list of spans eligible to be stripped.
Changelog:
[Android][Fixed] - Minimize Spans 3/N: ReactBackgroundColorSpan
Reviewed By: javache
Differential Revision: D44240782
fbshipit-source-id: 2ded1a1687a41cf6d5f83e89ffadd2d932089969
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36546
This is part of a series of changes to minimize the number of spans committed to EditText, as a mitigation for platform issues on Samsung devices. See this [GitHub thread]( https://github.com/facebook/react-native/issues/35936#issuecomment-1411437789) for greater context on the platform behavior.
This change generalizes `stripAttributeEquivalentSpans()` to allow plugging in different spans.
Changelog:
[Internal]
Reviewed By: rshest
Differential Revision: D44240781
fbshipit-source-id: 89005266020f216368e9ad9ce382699bd8db85a8
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36543
This is part of a series of changes to minimize the number of spans committed to EditText, as a mitigation for platform issues on Samsung devices. See this [GitHub thread]( https://github.com/facebook/react-native/issues/35936#issuecomment-1411437789) for greater context on the platform behavior.
We cache the backing EditText span on text change to later measure. To measure outside of a TextInput we need to restore any spans we removed. Spans may overlap, so base attributes should be behind everything else.
The logic here for dealing with precedence is incorrect, and we should instead accomplish this by twiddling with the `SPAN_PRIORITY` bits.
Changelog:
[Android][Fixed] - Minimize Spans 1/N: Fix precedence
Reviewed By: javache
Differential Revision: D44240779
fbshipit-source-id: f731b353587888faad946b8cf1e868095cdeced3
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36621
After D44302691 enabled textShadow, there was a subtle 1px shadow on any new text which I did't spot, but screenshot tests did (after commit which is non-ideal, but there is more work to make these land blocking).
This is because unlike `ReactBaseTextShadowNode` in paper which defaults to a radius of zero (no shadow), `TextAttributes` in Fabric defaults to a radius of 1px. Just previously never displayed.
Without shadow:
https://pxl.cl/2z2wX
With shadow:
https://pxl.cl/2z2x0
This changes the default to zero, which will cause us to skip adding the span, and matches previous behavior in Paper.
I double-checked the other props are defaulted the same way between `BaseTextShadowNode` (Paper) and `TextAttributes` (Fabric).
Changelog:
[Android][Fixed] - Fix default shadow radius in TextAttributeProps
Reviewed By: javache
Differential Revision: D44364446
fbshipit-source-id: d207367608291048001403d292f881c0842113f9
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36541
We only know where the last focused cell lives after it is rendered. Apart from dead refs handled in D43835135, this means items added or removed before the focused cell will lead to a stale last index for the next state update.
We don't have a good way to correlate cells after data change. This effects the implementation for [`maintainVisibleContentPosition`](https://github.com/facebook/react-native/pull/35993) as well, but needs some thought on the right way to handle it. For now, we bail when we don't know where the last focused cell lives.
Changelog:
[General][Fixed] - Bail on realizing region around last focused cell if we don't know where it is
Reviewed By: yungsters
Differential Revision: D44221162
fbshipit-source-id: 8fc7e726fe13c62b98870600563857bb89290280
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36585
1. We don't add `ShadowStyleSpan` unless an offset is set. This is incorrect, and less permissive than `BaseTextShadowNode` in Paper.
2. We don't serialize textShadowOffset to MapBuffer
Changelog:
[Android][Fixed] - Fix textShadow on Android Fabric
Reviewed By: javache
Differential Revision: D44302691
fbshipit-source-id: 2cfd3bff3d0e4f329c98d1ed2defff94ad3b7dc3
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36582
This change should fix the path to run packager.sh directly from Xcode, this was broken after the Monorepo work.
## Changelog:
[internal] - update path to run packager.sh
Reviewed By: huntie, hoxyq
Differential Revision: D44292167
fbshipit-source-id: 90e0291aa7a15189c72cae99c5d38c84c7243a80
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36609
Some random cleanup as I prepare to make these classes a better injection point for future experiments.
* Forward-declare classes where possible to reduce header import
* Return references to shared_ptr instead of copies when there are no lifetime concerns
* Use a shared JClass instance in JFabricUIManager
Changelog: [Internal]
Reviewed By: rshest
Differential Revision: D44221018
fbshipit-source-id: 1660cac964abd10ce798473e26841503430efdfe
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36591
If any of the properties used in event-emitter codegen conflict with `event` or `payload`, the generated code will fail to build, even if this generated code isn't used. Since these are quite common keys, prefix them with `$` (still valid C++) to avoid conflicts.
Changelog: [General][Fixed] Resolved property name conflicts in event-emitter codegen
Reviewed By: cipolleschi
Differential Revision: D44274619
fbshipit-source-id: 45e67850c49e082d8f9b1f85bb632d45a9fd4f1d
Summary:
X-link: https://github.com/facebook/metro/pull/955
Pull Request resolved: https://github.com/facebook/react-native/pull/36584
Changelog:
[General][Changed] - Default condition set for experimental Package Exports is now `['require', 'react-native']`
The [Exports RFC](https://github.com/react-native-community/discussions-and-proposals/blob/main/proposals/0534-metro-package-exports-support.md) had assumed that supporting the `"import"` condition was a syntax-only difference, given we are not in a Node.js environment — and so was worthwhile to support for maximal ecosystem compatibility.
{F915841105}
This assumption is similar to [`--moduleResolution bundler` in TypeScript 5.0](https://github.com/microsoft/TypeScript/pull/51669):
> bundlers and runtimes that include a range of Node-like resolution features and ESM syntax, but do not enforce the strict resolution rules that accompany ES modules in Node or in the browser
> -- https://github.com/microsoft/TypeScript/pull/51669#issue-1467004047
However, robhogan has rightly pointed out that **we should not do this!**
- ESM (once transpiled) is **not** simply a stricter subset of in-scope features supported by CJS. For example, it supports top-level async, which would be breaking at runtime.
- We recently made the same change for our Jest environment:
- https://github.com/facebook/react-native/commit/681d7f8113d2b5e9d6966255ee6c72b50a7d488a
As such, we are erring on the side of correctness and supporting only `['require', 'react-native']` in our defaults. At runtime, all code run by React Native is anticipated to be CommonJS. `"exports"` will instead allow React Native to correctly select the CommonJS versions of modules from all npm packages.
Metro changelog: [Experimental] Package Exports `unstable_conditionNames` now defaults to `['require']`
Reviewed By: robhogan
Differential Revision: D44303559
fbshipit-source-id: 0077e547e7775e53d1e4e9c3a9d01347f4fb7d4a
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36581
Found that the current codegen did not properly handle a return type of `?bool` because the branch of `constexpr (is_optional_v<T>)` assumed that T was always a JSI value that needed conversion, and `supportsToJs<bool, bool>` is false.
Changelog: [General][Fixed] Issue with TurboModule C++ codegen with optional return types
Reviewed By: christophpurrer
Differential Revision: D44302352
fbshipit-source-id: 0863de06da4e5e3c18f8a1ced7179d76d8e87b99
Summary:
Task from https://github.com/facebook/react-native/issues/34872
> [Codegen 80] Convert the emitCommonTypes implementation from a switch based implementation to a dictionary based one
## Changelog:
[Internal] [Changed] - Convert the emitCommonTypes implementation from a switch based implementation to a dictionary based one
Pull Request resolved: https://github.com/facebook/react-native/pull/36549
Test Plan: `yarn test react-native-codegen`
Reviewed By: NickGerleman
Differential Revision: D44244901
Pulled By: rshest
fbshipit-source-id: 50712724c72aad3bd1dae3e7c381242c4913a236
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36571
Changelog: [Internal]
The problem is related to the way we use `js_srcs_dir` & `output_dir` options, one requires just relative path from current ruby script, other requires relative path from iOS root project (where the Podfile located)
output_dir was introduced in D43304641
resulted into the issue, described in https://discord.com/channels/514829729862516747/1087736932953509958
allow-large-files
Reviewed By: cipolleschi
Differential Revision: D44294112
fbshipit-source-id: 47fcf510e203d0880e1f92ab6ead09f4b79cb4dd
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36570
I'm doing some preparations to implement this proposal to bring some DOM APIs to React Native refs: https://github.com/react-native-community/discussions-and-proposals/pull/607
To make it easier to iterate on the proposal, and to improve the separation of concerns between React and React Native, I'm moving the definition of `ReactFabricHostComponent` (the public instance provided by React when using refs on host conmponents) to the `react-native` package.
I already did some steps in the React repository to simplify this:
* Removing unused imperative events that caused increased coupling: https://github.com/facebook/react/pull/26282
* Extracting the definition of the public instance to a separate module: https://github.com/facebook/react/pull/26291
In this case, in order to be able to move the definition from React to React Native, we need to:
1. Create the definition in React Native and export it through `ReactNativePrivateInterface`.
2. Update React to use that definition instead of the one in its own module.
This diff implements the first step.
`ReactNativeAttributePayload` is required by this definition and by the one for Paper that still exists in React. I moved it here so we only define it where we use it when we remove Paper. Paper will access it through `ReactNativePrivateInterface` as well. That will also allow us to remove a few other fields in that interface.
Changelog: [Internal]
bypass-github-export-checks
Reviewed By: yungsters
Differential Revision: D43772356
fbshipit-source-id: 78dac152f415f19316ec90887127bf9861fe3110
Summary:
## Changelog:
[Internal] -
Update the pods, which appear to be out of date, due to the corresponding OSS jobs being broken,
allow-large-files
Reviewed By: christophpurrer
Differential Revision: D44282378
fbshipit-source-id: 1d182361f26e692ba83ac6ec3d557e01e7281a29
Summary:
Changelog: [General][Removed] Remove experimental support for loading bytecode from Metro
Removes the experimental bundling strategy that offloads Hermes bytecode compilation to the packager server. The React Native parts of this experiment were never part of the public API, and the Metro parts never fully shipped in open source.
Followup from D43597007.
Reviewed By: robhogan
Differential Revision: D43604705
fbshipit-source-id: db3be553750ccbf286d876f75858299c5b750f19
Summary:
Changelog: [General][Removed] Remove internal DevSplitBundleLoader native module
`DevSplitBundleLoader` was part of an experimental bundling strategy that offloaded Hermes bytecode compilation to the packager server. The React Native parts of this experiment were never part of the public API, and the Metro parts never fully shipped in open source.
As part of implementing the simpler and more general [lazy bundling RFC](https://github.com/react-native-community/discussions-and-proposals/pull/605), we are removing `DevSplitBundleLoader` and associated code from React Native's internals.
Reviewed By: robhogan
Differential Revision: D43597007
fbshipit-source-id: 1460e9045cd7a0f5ef43144b10afb932172e223c
Summary:
We made some changes to the new instance format, so need to adapt this again after D43980374.
The previous format was never synced so we don't need to keep compatibility.
Changelog: [internal]
Reviewed By: javache
Differential Revision: D44137324
fbshipit-source-id: bb08141674e2385934772f241acb863f9050b671
Summary:
Changelog:
[General][Added] - Add `react-native/metro-config` package
Pull Request resolved: https://github.com/facebook/react-native/pull/36502
## Context
### React Native Metro config → React Native repo (https://github.com/facebook/react-native/pull/36502)
We (the React Native team) are aiming to relocate the default Metro config for React Native out of `react-native-community/cli-plugin-metro` and **into the React Native repo + app template** as a new `react-native/metro-config` package.
This is the first (and minimum viable) phase we can ship to separate the release process of Metro from RN CLI in order to reduce coupling and iterate faster for our users.
**See full motivation, design, and test plan here: https://github.com/facebook/react-native/pull/36502**
## Changes
- This PR adds the new `react-native/metro-config` package, reproduces all static values previously defined in RN CLI. The values which remain in RN CLI are dynamic values derived from CLI options passed by the user.
{F906910591}
Reviewed By: cortinico
Differential Revision: D44099692
fbshipit-source-id: 672a67e19d866ac2c64fc84983b5d82c604918c6
Summary:
Changelog: [Internal]
React Native requires React 18 which includes `useSyncExternalStore`, so we can remove the shim. It was only used in one place (`useColorScheme`).
Reviewed By: motiz88
Differential Revision: D44163914
fbshipit-source-id: 3a94466b3d5ae8aa43e9236acb8c92fbefd04180
Summary:
changelog: [internal]
`setNativeProps` have been implemented in Fabric but require a React change to be accessible from JavaScript components. For React sync to be imported in OSS builds, React needs to have have a new release in NPM.
To work around this limitation, I manually copied over lines of code that glue together setNativeProps to OSS build.
Reviewed By: cortinico, cipolleschi
Differential Revision: D44216496
fbshipit-source-id: b34b598c1a317bdc03cc5a4cadb3f7c610059709
Summary:
This diff optimizes text measurement by adding a layer of caching per shadow node.
When ReactFeatureFlags.enableTextMeasureCachePerShadowNode is enabled, we will cache and reused measurements per shadow node.
This optimization showed a 2x improvement on text rendearing when a screen contains a big amount of text components.
Changelog: [Internal] Internal
Reviewed By: sammy-SC
Differential Revision: D44221170
fbshipit-source-id: c3e7ba1ad216929826a99585874981717c90e13b
Summary:
Right now RNTestePage either adds a large spacer to the end of content, unless `noSpacer` is added. But with `noSpacer`, scrolling content may not be reachable because we are putting padding on the wrong container.
This fixes that and removes a few cases where we had multi hundred px empty space in favor of uniformly taking up the parent, and a 10px padding. This also moves the constant margin at the top of RNTesterBlock to the container, so that in the E2E container we can save the 30px.
Changelog:
[Internal]
Reviewed By: javache
Differential Revision: D44197303
fbshipit-source-id: 8dc67f3588bc28316e2fee8d25a0bc59995f1728
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36537
##Changelog:
[Internal] -
This popped up when I was landing D44172494.
Order of arguments evaluation to a function call in C++ is unspecified, therefore there was a potential danger of use after move in two places in `Differentiator.cpp`
This diff fixes it.
Reviewed By: javache
Differential Revision: D44215210
fbshipit-source-id: 828ca379e2ba5a40506f1ff3136150af63ea1ff7
Summary:
> [Codegen 92] The getCommandOptions function in parsers/typescript/components/options.js and parsers/flow/components/options.js is the same. move it in parser-commons and use it in the original files. If the file two options.js files are empty, delete them.
> [Codegen 93] The getOptions function in parsers/typescript/components/options.js and parsers/flow/components/options.js is the same. move it in parser-commons and use it in the original files. If the file two options.js files are empty, delete them.
Part of Issue https://github.com/facebook/react-native/issues/34872
## Changelog:
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal][Changed] - Move getCommandOptions and getOptions to parsers commons from parsers components options
Pull Request resolved: https://github.com/facebook/react-native/pull/36413
Test Plan: `yarn jest react-native-codegen`
Reviewed By: rshest
Differential Revision: D43957023
Pulled By: cipolleschi
fbshipit-source-id: 4f8bf6f8fe69b20d0fb976afee7da244ef634e12
Summary:
> [Codegen 78 - Assigned to Pranav-yadav] It depends on [Codegen 75][Codegen 76][Codegen 77] Extract the logic that emits Partial values in an emitPartial function, which takes the Parsers as parameter.
>[Codegen 79 - Assigned to Pranav-yadav] It depends on [Codegen 78] Extract the basic cases logics (case Stringish, case Int32, case Double, ..., case Partial. `Flow` lines and `TypeScript` lines into a function emitCommonTypes in `parsers-primitives.js`. Make sure that the default case returns `null`. Call this function in the default: case `Flow`, `TypeScript` of the `index.js` file: if the function return something, return that from the default case; otherwise if the `emitCommonTypes` returns `null`, keep the current default implementation (throw the error).
### Changes
- merged TS & Flow parsers' logic for `Partial` case to `emitPatial` fn
- merged TS & Flow parsers' logic for below cases:
- `Stringish`
- `Int32`
- `Double`
- `Float`
- `UnsafeObject`
- `Object`
- `Partial`
- into an `emitCommonTypes` fn into `parsers-primitives.js`
- add **_tests_** for `emitPartial` and `emitCommonTypes` fn's
- add `getAnnotatedElementProperties` fn to parser & impl to both TS & Flow parsers
## Changelog:
[INTERNAL] [CHANGED] - Merge TS & Flow parsers' logic for `Partial` case to `emitPatial` fn & `commonTypes` cases into `emitCommonTypes` fn
Pull Request resolved: https://github.com/facebook/react-native/pull/36450
Test Plan: - `yarn lint && yarn run flow && yarn jest react-native` ⇒ �
Reviewed By: rshest
Differential Revision: D44132308
Pulled By: cipolleschi
fbshipit-source-id: f965e85ecc5d94e57ad85334ce565a55c512fde4
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36533
Changelog: [Internal]
Its better to have one source of truth, so we won't loose any changes if one of the files will be updated
Reviewed By: cortinico
Differential Revision: D44138311
fbshipit-source-id: 9bd938c1abe33ea1f791f7624efd57f1b37e813b
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36531
Changelog: [Internal]
In order to make `react-native/tester` imports work, adding this package to `xplat/js/public`
Also moving devDependecies from `react-native/tester/package.json` to root package json to avoid checking in dev dependencies in `xplat/js/public/node_modules`
Reviewed By: cortinico
Differential Revision: D44030539
fbshipit-source-id: b06e49869cdad6e511b1675d1063a1ceac56e3e6
Summary:
This change does two things:
1) Moves RNTester on iOS to use an `.xctestplan` to configure its tests. This moves the test configuration out of the `.xcscheme` file, and into a new json file that Xcode likes. It also allows you to run the same tests multiple times with different configurations. This was done by clicking the focused button below.

Note: this is partially me upstreaming a change from React Native macOS (https://github.com/microsoft/react-native-macos/pull/190/), though at some point our Xcode project got messed up and we were no longer referencing them ��.
2) Enables Address Sanitizer and Udefined Behavior Sanitizer through the xctestplan
This should help catch some extra vulnerabilities should they ever show up while our tests run.
Notably, I did not _also_ add a configuration to run Thread Sanitizer, because tests start failing with that enabled 😅.
## Changelog:
[IOS] [SECURITY] - Enable Address and Undefined Behavior Sanitizers on RNTester
Pull Request resolved: https://github.com/facebook/react-native/pull/36443
Test Plan: CI should pass
Reviewed By: cortinico
Differential Revision: D44213517
Pulled By: cipolleschi
fbshipit-source-id: 0646174c4b416413a563e8178aa2cfca230b5e66
Summary:
This just creates the class structure for `ReadOnlyNode`, `ReadOnlyElement` and `ReactNativeElement`, with all methods throwing as unimplemented.
These classes will be gated behind a feature flag, so merging incomplete work is ok.
This doesn't add the future setters that will log warnings / throw errors when used.
See: https://github.com/react-native-community/discussions-and-proposals/pull/607
Changelog: [internal]
Reviewed By: rickhanlonii, yungsters
Differential Revision: D44060539
fbshipit-source-id: e489532fd365d9aa2bb8308847a35eb715d675e7
Summary:
This implements a basic version of DOMRectList that's close to the spec but diverges in some things (e.g.: methods could be called with an instance created through `Object.create`, etc.).
This will be used soon to implement `ReadOnlyelement.getClientRects()` (behind a flag).
See: https://github.com/react-native-community/discussions-and-proposals/pull/607
Changelog: [internal]
Reviewed By: yungsters
Differential Revision: D44060540
fbshipit-source-id: ad29b5c41f2778864e7dd7ece9223dcf73cd5d6c
Summary:
This implements a basic version of NodeList that's close to the spec but diverges in some things (e.g.: methods could be called with an instance created through `Object.create`, etc.).
This will be used soon to implement `ReadOnlyNode.childNodes` (behind a flag).
See: https://github.com/react-native-community/discussions-and-proposals/pull/607
Changelog: [internal]
Reviewed By: yungsters
Differential Revision: D44055911
fbshipit-source-id: 10b435b06ea6f75eaead85f01c2703e05bb3bd37
Summary:
This implements a basic version of HTMLCollection that's close to the spec but diverges in some things (e.g.: methods could be called with an instance created through `Object.create`, etc.).
This will be used soon to implement `ReadOnlyElement.children` (behind a flag).
See: https://github.com/react-native-community/discussions-and-proposals/pull/607
Changelog: [internal]
Reviewed By: yungsters
Differential Revision: D44055912
fbshipit-source-id: 37bcd7c12916b95a258e6b2e5717a642f478abdf
Summary:
These 3 methods are defined in the binding in native, but not in the type definition in JS.
Changelog: [internal]
Reviewed By: yungsters
Differential Revision: D44139730
fbshipit-source-id: 5ce74c61a424ece8091046425b9cd5598f14bbf1
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36523
`jest/private/preprocessor.js` is only used to run tests on the workspace itself, it's not part of our exported Jest preset and is specifically excluded from publication in the `react-native` package.
Now that we have the monorepo setup, this belongs at the workspace root.
- `metro-react-native-babel-transformer` moved from RN `dependencies` to root `devDependencies` because it's only used by the preprocessor
- `jest/create-cache-key-function` added to `devDependencies` - it's also used by the `assetTransformer` in the public preset.
Changelog: [Internal]
Reviewed By: hoxyq
Differential Revision: D44197879
fbshipit-source-id: 0bbd9e2f500f53fa4f16562f05374dc601b67df6