Compare commits

...
Author SHA1 Message Date
Distiller fe6c65169c [0.70.14] Bump version numbers 2023-10-24 17:32:08 +00:00
Riccardo Cipolleschi 603d2b2299 Revert "[LOCAL] For targeting SDK 34 - Added RECEIVER_EXPORTED/RECEIVER_NOT_EXPORTED flag support in DevSupportManagerBase"
This reverts commit ffbec5b73f.
2023-10-12 17:57:46 +01:00
Riccardo Cipolleschi 977f03ae9d [LOCAL] Fix CI 2023-10-12 17:14:10 +01:00
Riccardo Cipolleschi b1496be007 [LOCAL] Remove generate yarn.lock for react-native-codegen 2023-10-12 17:05:31 +01:00
Riccardo Cipolleschi d0eb4218cd [LOCAL] Bump published packages 2023-10-12 17:02:02 +01:00
Riccardo Cipolleschi 9f53ea7aca [LOCAL] Bump iOS executor as CircleCI removed the one we used for 0.70 2023-10-12 16:56:30 +01:00
Riccardo CipolleschiandRiccardo Cipolleschi a1a220b6ac Fix Gemfile, setting Active support to < 7.1.0 (#39828)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39828

Active Suppert released a new Gem which is incompatible with Cocoapods 1.13.0, the latest release, as they removed a method used by cocoapods.

This fix ensures that we install compatible versions of the Gem.

[iOS][Fixed] - Set the max version of Active support to 7.0.8

Reviewed By: hoxyq

Differential Revision: D49949782

fbshipit-source-id: 278097502d3a416567cc8c0b90090fee4fb21503
2023-10-12 16:50:28 +01:00
Riccardo Cipolleschi 735d06c01f [LOCAL] Update Xcode 15 patches to be more robust 2023-10-12 16:39:11 +01:00
Riccardo Cipolleschi 964872d936 [LOCAL] update yarn.lock 2023-10-12 16:27:01 +01:00
Stian JensenandRiccardo Cipolleschi 5a695dd17c Bump jscodeshift to 0.14 (#35356)
Summary:
Jscodeshift has become maintained again in the past year, and has gotten rid of quite a good chunk of old dependencies that are no longer needed!

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Internal] [Changed] - update jscodeshift

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

Reviewed By: cipolleschi

Differential Revision: D41325527

Pulled By: rshest

fbshipit-source-id: 666b25c9bb3b1720479e9e098968b3b983adc2b4
2023-10-12 16:24:16 +01:00
Riccardo Cipolleschi ffbec5b73f [LOCAL] For targeting SDK 34 - Added RECEIVER_EXPORTED/RECEIVER_NOT_EXPORTED flag support in DevSupportManagerBase 2023-10-12 16:21:13 +01:00
Riccardo CipolleschiandThibault Malbranche 5f4a091a2f Add ld_classic flag to Hermes when building for Xcode 15 (#39516)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39516

With Xcode15, Apple rewrote the C++ linker.
This is a breaking change that does not work with weak symbols.
As a workaround, apple is suggesting to add `-ld_classic` to the linker in order to readd support for weak symbols. The flag does not exists for Xcode 14.3 or lower, so we need to add it conditionally.

With this change, we introduce a couple of checks in the Hermes build logic:
1. Detect the version of Xcode that is used
2. Add the new flag to `HERMES_EXTRA_LINKER_FLAGS` if Xcode version is 15.

[Internal] - Make hermes build properly with Xcode 15

Reviewed By: cortinico, dmytrorykun

Differential Revision: D49368675

fbshipit-source-id: 62d8ed81855c426f56ed94b6a2d6da2eb882b355
2023-09-19 13:46:13 +02:00
Riccardo CipolleschiandThibault Malbranche 740c40187f Fix Xcode 15 RC issues (#39474)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39474

When it comes to Xcode 15 RC, we are aware of two issues:
1. `unary_function` and `binary_function` not available in Cxx17
2. [Weak linking](https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#Linking) is not supported anymore.

This change should fix both of the issues, adding the flags to allow for `unary_function`and `binary_function` to be called and adding the `-Wl -ld_classic` flag to `OTHER_LDFLAGS` in case Xcode 15 is detected.

[Internal] - add the `_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION` and the `-Wl -ld_classic` flags to projects when needed

Reviewed By: dmytrorykun

Differential Revision: D49319256

fbshipit-source-id: bb895f1e60db915db79684f71fa436ce80b42111
2023-09-19 13:40:17 +02:00
Riccardo CipolleschiandThibault Malbranche b8b9b609a1 Bump IPHONEOS_DEPLOYMENT_TARGET to 13.4 for 3rd party pods (#39478)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39478

When testing Xcode 15, we realized that a few pods we do not control directly have the IPHONEOS_DEPLOYMENT_TARGET set to old versions of iOS.
We can update that setting to silence the warning with Cocoapods and this is what this script does.

Notice that bumping that setting generated other warning as some APIs have been deprecated.

[Internal] - Bump min IPHONEOS_DEPLOYMENT_TARGET for 3rd party pods

Reviewed By: dmytrorykun

Differential Revision: D49274837

fbshipit-source-id: 584d105c76d654daa2ecf5eb2f1b9381e70f567a
2023-09-19 13:39:03 +02:00
Lorenzo SciandraandGitHub be89d2af54 chore(releases): rename bump-oss script to align with newer versions (#38892) 2023-08-21 09:58:28 +01:00
Distiller 0bccf2b616 [0.70.13] Bump version numbers 2023-07-28 08:24:59 +00:00
Thibault MalbrancheandGitHub 549ff6380a fix: bumped CLI to address broken backward compatibility (#38572) 2023-07-24 13:49:20 +02:00
Distiller 3481eba79a [0.70.12] Bump version numbers 2023-07-05 09:35:43 +00:00
Rob HoganandLorenzo Sciandra 1363b0a36f Use Content-Location header in bundle response as JS source URL (#37501)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37501

This is the iOS side of the fix for https://github.com/facebook/react-native/issues/36794.

That issue aside for the moment, the high-level idea here is to conceptually separate the bundle *request URL*, which represents a request for the *latest* bundle, from the *source URL* passed to JS engines, which should represent the code actually being executed. In future, we'd like to use this to refer to a point-in-time snapshot of the bundle, so that stack traces more often refer to the code that was actually run, even if it's since been updated on disk (actually implementing this isn't planned at the moment, but it helps describe the distinction).

Short term, this separation gives us a way to address the issue with JSC on iOS 16.4 by allowing Metro to provide the client with a [JSC-safe URL](https://github.com/react-native-community/discussions-and-proposals/pull/646) to pass to the JS engine, even where the request URL isn't JSC-safe.

We'll deliver that URL to the client on HTTP bundle requests via the [`Content-Location`](https://www.rfc-editor.org/rfc/rfc9110#name-content-location) header, which is a published standard for communicating a location for the content provided in a successful response (typically used to provide a direct URL to an asset after content negotiation, but I think it fits here too).

For the long-term goal we should follow up with the same functionality on Android and out-of-tree platforms, but it's non-essential for anything other than iOS 16.4 at the moment.

For the issue fix to work end-to-end we'll also need to update Metro, but the two pieces are decoupled and non-breaking so it doesn't matter which lands first.

Changelog:
[iOS][Changed] Prefer `Content-Location` header in bundle response as JS source URL

Reviewed By: huntie

Differential Revision: D45950661

fbshipit-source-id: 170fcd63a098f81bdcba55ebde0cf3569dceb88d
2023-07-05 09:39:28 +01:00
Distiller 90d0f938e1 [0.70.11] Bump version numbers 2023-07-04 10:28:13 +00:00
Lorenzo Sciandra 2a9d71dc34 [LOCAL] bump CLI to 9.3.3 and Metro do 0.72.4 2023-07-03 13:40:20 +01:00
Distiller 3364cd1c01 [0.70.10] Bump version numbers 2023-06-08 15:37:39 +00:00
Riccardo Cipolleschi c5e549e694 [LOCAL] Make 0.70 compatible with Xcode 15 (thanks to @AlexanderEggers for the commit in main) 2023-06-08 12:28:43 +01:00
Harry YuandLorenzo Sciandra 51bbfe1c60 Prevent crash in runAnimationStep on OnePlus and Oppo devices (#37487)
Summary:
We've been encountering a crash in `runAnimationStep` with "Calculated frame index should never be lower than 0" https://github.com/facebook/react-native/issues/35766 with OnePlus/Oppo devices as well, but don't have one on hand to test.

This just works around the issue: if the time is before the start time of an animation, we shouldn't do anything anyways, so we just log a message instead of throwing while in production. We still throw in debug mode though for easier debugging.

### Hypothesis of the root cause

Based on stacktrace in https://github.com/facebook/react-native/issues/35766 (which is the same one we see)

Normally, this should happen

1. Choreographer.java constructs a FrameDisplayEventReceiver
2. FrameDisplayEventReceiver.onVSync gets called, which sets the `mTimestampNanos`
3. FrameDisplayEventReceiver.run gets called, which then eventually calls our `doFrame` callback with `mTimestampNanos`. This then causes `FrameBasedAnimationDriver.runAnimationStep` to be called with the same timestamp

I suspect what's happening on OnePlus devices is that the `onVSync` call either doesn't happen or happens rarely enough that the `mTimestampNanos` when `run` is called is sometime in the past

### Fix

1. Add logging so we get the parameters to debug more if we end up getting this error
2. In production, just ignore past times instead of throwing an Error

## Changelog:

Pick one each for the category and type tags:

[ANDROID] [FIXED] - Prevent crash on OnePlus/Oppo devices in runAnimationStep

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

Test Plan: Ran our app using patched version and verified no issues showed up when using it

Reviewed By: cipolleschi

Differential Revision: D46102968

Pulled By: cortinico

fbshipit-source-id: bcb36a0c2aed0afdb8e7e68b141a3db4eb02695a
2023-06-08 11:56:31 +01:00
Dmitry RykunandLorenzo Sciandra bad39493b9 Cleanup temporary files after source map generation.
Summary:
Changelog:
[iOS][Fixed] - When source maps are enabled, clean up temporary files from the build directory. Reduces bundle size by at least 1MB.

Reviewed By: cipolleschi

Differential Revision: D38866158

fbshipit-source-id: 0f46faf4e767bb7417b24f283fbe19cfa022941a
2023-06-08 11:56:24 +01:00
Dmitry RykunandLorenzo Sciandra 4108b37438 Fix react-native-xcode.sh build script
Summary:
This diff fixes USE_HERMES checks.

Changelog
[iOS][Fixed] - USE_HERMES envvar check fixed in react-native-xcode.sh.

Reviewed By: cipolleschi

Differential Revision: D38704558

fbshipit-source-id: 90a8648fd1094fcf9ab085f37efce9b811e707bc
2023-06-08 11:56:18 +01:00
Dmitry RykunandLorenzo Sciandra 8ad63714ed Fix USE_HERMES envvar check
Summary:
Hermes is enabled by default. We set `USE_HERMES` envvar to `false` to explicilty disable Hermes. The only valid way to check it would be to compare it against `false`. Everything else will produce invalid results if `USE_HERMES` is not defined. For example `$USE_HERMES != true` will turn into `'' != true`, which evaluates to `true`.
Due to this bug source maps were not generated by default.

Changelog:
[iOS][Fixed] - USE_HERMES envvar check fixed in react-native-xcode.sh. Now source maps are generated by default.

Reviewed By: cipolleschi

Differential Revision: D38571971

fbshipit-source-id: bc6b505c225c56d62ee773b401b66d821965e106
2023-06-08 11:56:11 +01:00
Peter VelkovandLorenzo Sciandra 2b2e4f0ca2 Fix HBC_SOURCEMAP_FILE in scripts/react-native-xcode.sh (#34111)
Summary:
## Summary

Fixes https://github.com/facebook/react-native/issues/32497
Fixes https://github.com/facebook/react-native/issues/34212

The assigned HBC_SOURCEMAP_FILE path is incorrect as it does not reference the hermes bundle source map file

See: https://github.com/facebook/react-native/issues/32497#issuecomment-1171379674

## Changelog
[General] [Fixed] - using SOURCEMAP_FILE during xcode build phase with Hermes enabled

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

Test Plan:
1. In a blank react-native project
1. Enable Hermes
1. Go to xCode -> Project -> Build Phases -> Bundle React Native code and images
3. Add `export SOURCEMAP_FILE="$(pwd)/../ios.jsbundle.map"` before `react-native-xcode.sh`
   e.g.
   ```sh
   export NODE_BINARY=node
   export SOURCEMAP_FILE="$(pwd)/../ios.jsbundle.map"

   ../node_modules/react-native/scripts/react-native-xcode.sh
   ```
4. Make a release build `npx react-native run-ios --configuration Release` or `CMD + I` in xCode
5. Verify the build is successful
6. Verify the `.map` file is outputted at the specified path (`ios.jsbundle.map` in project root for the example above)

Reviewed By: cipolleschi

Differential Revision: D38460586

Pulled By: dmitryrykun

fbshipit-source-id: 54c1594b37fa2253896ce9739c1a9a712deecd0f
2023-06-08 11:56:04 +01:00
Riccardo Cipolleschi e0ad535ea6 [LOCAL] restore with_hermes_sdk_cache_span job 2023-06-08 10:38:16 +01:00
Riccardo Cipolleschi 227f4233fe [LOCAL] restore the right hermes cache keys for 0.70 2023-06-08 10:35:04 +01:00
Riccardo Cipolleschi 190fc5be87 [LOCAL] restore the right hermes keys for 0.70 2023-06-08 10:32:38 +01:00
Riccardo CipolleschiandRiccardo Cipolleschi 40e8bb9a43 Make CircleCI caches for hermesc be version dependent (#37452)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37452

Fixes #37428

We do have cache poisoning for hermesc on Windows and Linux due to reusing the same cache key among different
React Native version. This fixes it by specifying a cache key which is version dependent + it invalidates the
caches by defining a new key.

Changelog:
[Internal] [Fixed] - Make CircleCI caches for hermesc be version dependent

Reviewed By: cortinico

Differential Revision: D45909178

fbshipit-source-id: 830c87ae45739c7053342a68dac2ee7581945c1d
2023-06-08 10:13:42 +01:00
Marek FořtandGitHub 8c90612925 Fix test e2e script (#37081) 2023-04-25 15:36:33 +01:00
Distiller 6bba507895 [0.70.9] Bump version numbers 2023-04-19 09:51:57 +00:00
Nicola CortiandLorenzo Sciandra 260a9c720e Fix test_buck by providing exported deps for textinput target (#34436)
Summary:
This is an attempt to fix the broken `test_buck` as the `/textinput` target now needs to access the Kotlin stdlib dependencies

## Changelog

[Internal] - Fix test_buck by providing exported deps for textinput target

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

Test Plan: Will wait for a CircleCI result

Reviewed By: cipolleschi

Differential Revision: D38782473

Pulled By: cortinico

fbshipit-source-id: 72265c34092372189d75df732b64a1e370453472
2023-04-17 15:38:08 +01:00
Pieter De BaetsandLorenzo Sciandra da1d82bcb4 Fix TextView alignment being reset on state updates
Summary: Changelog: [Android][Fixed] Resolved bug with Text components in new arch losing text alignment state.

Reviewed By: mdvacca

Differential Revision: D34108943

fbshipit-source-id: 3992e9406345be919b5e3595fc1f9e61cf67a699

# Conflicts:
#	ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java
#	ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java
2023-04-17 13:13:49 +01:00
Lorenzo Sciandra 1df92c6948 manual backport of "Use RN Build Utils for Building Hermes Artifacts" fix 2023-04-17 11:34:17 +01:00
Lorenzo SciandraandGitHub 124547ef26 Merge pull request #36875 from facebook/kelset/070-backport-textinput-fixes 2023-04-17 11:19:04 +01:00
Luna Wei 7b1441730b Update Hermes tag 2023-04-13 10:59:04 -07:00
Nick GerlemanandLorenzo Sciandra 5339e95cb9 Mimimize EditText Spans 9/9: Remove addSpansForMeasurement() (#36575)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36575

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.

D23670779 addedd a previous mechanism to add spans for measurement caching, like we needed to do as part of this change. It is called in more specific cases (e.g. when there is a text hint but no text), but it edits the live EditText spannable instead of the cache copy, and does not handle nested text at all.

We are already adding spans back to the input after this, behind everything else, and can replace it with the code we have been adding.

Changelog:
[Android][Fixed] - Mimimize EditText Spans 9/9: Remove `addSpansForMeasurement()`

Reviewed By: javache

Differential Revision: D44298159

fbshipit-source-id: 1af44a39de7550b7e66e45db9ebc3523ae9ff002

# Conflicts:
#	ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java
2023-04-11 16:02:08 +01:00
Joshua GrossandLorenzo Sciandra 62364d00ca Support MapBuffer in TextInput State
Summary:
Support MapBuffer in TextInput State.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D38546271

fbshipit-source-id: 93e7fd79d9d8473dd646410f3047fcfafa8516f1
2023-04-11 16:01:59 +01:00
Nick GerlemanandLorenzo Sciandra 322f721c4a Minimize EditText Spans 8/9: CustomStyleSpan (#36577)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36577

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 allows us to strip CustomStyleSpan. We already set all but `fontVariant` on the underlying EditText, so we just need to route that through as well.

Note that because this span is non-parcelable, it is seemingly not subject to the buggy behavior on Samsung devices of infinitely cloning the spans, but non-parcelable spans have different issues on the devices (they disappear), so moving `fontVariant` to the top-level makes sense here.

Changelog:
[Android][Fixed] - Minimize EditText Spans 8/N: CustomStyleSpan

Reviewed By: javache

Differential Revision: D44297384

fbshipit-source-id: ed4c000e961dd456a2a8f4397e27c23a87defb6e
2023-04-11 15:57:18 +01:00
Nick GerlemanandLorenzo Sciandra 471cc514a8 Minimize EditText Spans 7/9: Avoid temp list (#36576)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36576

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 addresses some minor CR feedback and removes the temporary list of spans in favor of applying them directly.

Changelog:
[Internal]

Reviewed By: javache

Differential Revision: D44295190

fbshipit-source-id: bd784e2c514301d45d0bacd8ee6de5c512fc565c
2023-04-11 15:57:12 +01:00
Nick GerlemanandLorenzo Sciandra ab822c41f1 Minimize EditText Spans 6/9: letterSpacing (#36548)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36548

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 lets us set `letterSpacing` on the EditText instead of using our custom span.

Changelog:
[Android][Fixed] - Minimize EditText Spans 6/N: letterSpacing

Reviewed By: rshest

Differential Revision: D44240777

fbshipit-source-id: 9bd10c3261257037d8cacf37971011aaa94d1a77
2023-04-11 15:57:12 +01:00
Nick GerlemanandLorenzo Sciandra f1c33b9e15 Minimize EditText Spans 5/9: Strikethrough and Underline (#36544)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36544

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 makes us apply strikethrough and underline as paint flags to the underlying EditText, instead of just the spans. We then opt ReactUnderlineSpan and ReactStrikethroughSpan into being strippable.

This does actually create visual behavior changes, where child text will inherit any underline or strikethrough of the root EditText (including if the child specifies `textDecorationLine: "none"`. The new behavior is consistent with both iOS and web though, so it seems like more of a bugfix than a regression.

Changelog:
[Android][Fixed] - Minimize Spans 5/N: Strikethrough and Underline

Reviewed By: rshest

Differential Revision: D44240778

fbshipit-source-id: d564dfc0121057a5e3b09bb71b8f5662e28be17e
2023-04-11 15:57:07 +01:00
Nick GerlemanandLorenzo Sciandra 205623cbe8 Minimize EditText Spans 4/9: ReactForegroundColorSpan (#36545)
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
2023-04-11 15:57:07 +01:00
Nick GerlemanandLorenzo Sciandra 62d992019e Minimize EditText Spans 3/9: ReactBackgroundColorSpan (#36547)
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
2023-04-11 15:57:07 +01:00
Nick GerlemanandLorenzo Sciandra ff991aa15b Minimize EditText Spans 2/9: Make stripAttributeEquivalentSpans generic (#36546)
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

# Conflicts:
#	ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java
2023-04-11 15:57:02 +01:00
Nick GerlemanandLorenzo Sciandra 6d8868b2d8 Minimize EditText Spans 1/9: Fix precedence (#36543)
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
2023-04-11 15:56:09 +01:00
Nick GerlemanandLorenzo Sciandra 2ddef56902 Fix measurement of uncontrolled TextInput after edit
Summary:
D42721684 (https://github.com/facebook/react-native/commit/be69c8b5a77ae60cced1b2af64e48b90d9955be5) left a pretty bad bug when using Fabric for Android. I missed that in Fabric specifically, on edit we will cache the Spannable backing the EditText for use in future measurement.

Because we've stripped the sizing spans, Spannable measurement has incorrect font size, and the TextInput size will change (collapsing) after the first edit. This effectively breaks any uncontrolled TextInput which does not have explicit dimensions set.

Changelog:
[Android][Fixed] - Fix measurement of uncontrolled TextInput after edit

Reviewed By: sammy-SC

Differential Revision: D43158407

fbshipit-source-id: 51602eab06c9a50e2b60ef0ed87bdb4df025e51e
2023-04-11 15:56:00 +01:00
Lorenzo Sciandra d89542e474 [LOCAL] fix move mockfs to the right package.json (see #35476) 2023-04-11 13:49:09 +01:00
Distiller 99c097917b [0.70.8] Bump version numbers 2023-04-04 09:13:23 +00:00
Lorenzo SciandraandGitHub 34f3794f18 fix(xcode): backport Xcode 14.3 fix to 70 (#36768) 2023-04-03 14:49:28 +01:00
Alec WinogradandLorenzo Sciandra ea11efa262 Prevent native blob resource from being de-allocated prematurely (#31392)
Summary:
This PR prevents blob data from being prematurely de-allocated in native code when using slice to create views into an existing blob. Currently, whenever a new blob is created via createFromOptions, BlobManager.js creates a new blobCollector object since options.__collector is never provided.

https://github.com/facebook/react-native/blob/dc80b2dcb52fadec6a573a9dd1824393f8c29fdc/Libraries/Blob/BlobManager.js#L115-L123

When the reference to a blobCollector is garbage collected, the corresponding native memory for the blob data is de-allocated.

https://github.com/facebook/react-native/blob/27651720b40cab564a0cbd41be56a02584e0c73a/Libraries/Blob/RCTBlobCollector.mm#L19-L25

Since, `blob.slice()` is supposed to create a new view onto the same binary data as the original blob, we need to re-use the same collector object when slicing so that it is not GC'd until the last reference to the binary data is no longer reachable. Currently, since each blob slice gets a new blobCollector object, the memory is de-allocated when the first blob is GC'd.

Fixes https://github.com/facebook/react-native/issues/29970
Fixes https://github.com/facebook/react-native/issues/27857

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fixed] - Blob data is no longer prematurely deallocated when using blob.slice

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

Test Plan: I could use help coming up with a test plan here. I could add a referential equality check for the blob.data.__collector in `Blob-test` but it doesn't seem quite right to be testing the implementation detail there.

Reviewed By: javache

Differential Revision: D41730782

Pulled By: cortinico

fbshipit-source-id: 5671ae2c69908f4c9acb5d203ba198b41b421294
2023-04-03 11:14:19 +01:00
e3a5fbe72f chore: remove Ruby Pinning from 0.70 (#36422)
* chore: remove Ruby Pinning from 0.70

* Update Gemfile

* Update Gemfile

---------

Co-authored-by: Riccardo Cipolleschi <cipolleschi@fb.com>
2023-03-10 10:54:59 +00:00
Distiller b177489eb3 [0.70.7] Bump version numbers 2023-01-31 14:24:48 +00:00
Nick GerlemanandRiccardo Cipolleschi 616fca2fd2 Mitigation for Samsung TextInput Hangs (#35967)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/35967

In https://github.com/facebook/react-native/issues/35936 we observed that the presence of AbsoluteSizeSpan may lead to hangs when using the Grammarly keyboard on Samsung.

This mitigation makes it so that we do not emit this span in any case where it is sufficient to rely on already set EditText textSize. In simple cases, tested on two devices, it causes typing into the TextInput to no longer hang.

This does not fully resolve the issue for TextInputs which meaningfully use layout-effecting spans (or at least font size), such as non-uniform text size within the input. We instead just try to reduce to minimum AbsoluteSizeSpan possible.

Testing the first commit was able to resolve hangs in some simpler inputs tested, by me and cortinico.

Changelog:
[Android][Fixed] - Mitigation for Samsung TextInput Hangs

Reviewed By: cortinico

Differential Revision: D42721684

fbshipit-source-id: e0388dfb4617f0217bc1d0b71752c733e10261dd
2023-01-30 11:34:44 +00:00
wood1986andRiccardo Cipolleschi 279fb52e03 fix: fix the potential race condition when dismissing and presentating modal (#35705)
Summary:
`react-native-screens` has a bug about `UIViewControllerHierarchyInconsistency` when dismissing a `react-native` `<Modal>`. Here is the bug https://github.com/software-mansion/react-native-screens/issues/944

After adding `dispatch_async` block, it solves the issue. But I do not know if this is right.

Here is the example repo https://github.com/wood1986/react-native-modal-crash

You can revert my last commit https://github.com/wood1986/react-native-modal-crash/commit/86e7bc1adf444c1645c0d6078b0d6d427cdf6a36 to reproduce the issue

## 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
-->

[IOS] [FIXED] - fixed the potential race condition when dismissing and presentating modal

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

Reviewed By: cipolleschi

Differential Revision: D42253488

Pulled By: makovkastar

fbshipit-source-id: 3e98fa9e719ecdeddeb2a367b0cd364e15136d56
2023-01-30 11:33:59 +00:00
David AnguloandRiccardo Cipolleschi b5280bbc93 Rename POST_NOTIFICATION to POST_NOTIFICATIONS (#35533)
Summary:
After adding `<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>` on my `AndroidManifest.xml`, I expected to use `PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS` but `POST_NOTIFICATIONS` is `undefined` and is named `POST_NOTIFICATION` instead.

Every other Android permission is 1:1 in spelling except this one where it lacks `S`.

Not sure if this is a welcome change since this can be breaking. Or maybe we can include both with and without `S` to not be a breaking change. Or just keep it as is and close this PR.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Changed] - Rename `POST_NOTIFICATION` to `POST_NOTIFICATIONS`

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

Test Plan: `PermissionsAndroid.PERMISSIONS.POST_NOTIFICATIONS` should not be `undefined`.

Reviewed By: cortinico

Differential Revision: D41705866

Pulled By: philIip

fbshipit-source-id: a0328b174f0196421565f0cd2b2f1eb509428553
2023-01-30 11:33:14 +00:00
Oleksandr MelnykovandRiccardo Cipolleschi 9a469c433d Add POST_NOTIFICATION runtime permission to Catalyst and RNTester for Android
Summary:
Android 13 adds a new `POST_NOTIFICATION` runtime permission, which can only be requested if the `targetSdkVersion` of the app is set to 33. Since we upgrading Catalyst to SDK 33, let's add it as one of the permission examples.

Changelog:
[Android][Changed] - Add POST_NOTIFICATION runtime permission to RNTester

Reviewed By: fkgozali

Differential Revision: D38850138

fbshipit-source-id: 4cf7a5f60dd0891d7ada40aca37f0489d9d0d190
2023-01-30 11:33:07 +00:00
Nicola CortiandLorenzo Sciandra fdd8002f19 Remove PAT_TOKEN and PAT_USERNAME from CircleCI (#35808)
Summary:
This is a cleanup change needed after the CircleCI security incident.
We should be using the `Authorization: Bearer` header to trigger `rn-diff-purge` instead of using username & password authentication.

Source: https://docs.github.com/rest/reference/repos#create-a-repository-dispatch-event

## Changelog

[INTERNAL] - Remove PAT_TOKEN and PAT_USERNAME from CircleCI

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

Test Plan:
I've tested this locally with:

```
curl -X POST https://api.github.com/repos/react-native-community/rn-diff-purge/dispatches \
                    -H "Accept: application/vnd.github.v3+json" \
                    -H "Authorization: Bearer [...]" \
                    -d "{\"event_type\": \"publish\", \"client_payload\": { \"version\": \"test.test.test\" }}"
```

and the run was succesfully fired by react-native-bot:
https://github.com/react-native-community/rn-diff-purge/actions/runs/3894079133

Reviewed By: lunaleaps

Differential Revision: D42456065

Pulled By: cortinico

fbshipit-source-id: 475e9ca80760522cc08bad37d85c5af6727922d3
2023-01-13 15:57:14 +00:00
Nicola CortiandLorenzo Sciandra fb653a13bc Update fingerprint for SSH deploy key (#35791)
Summary:
Rotating a private SSH key we had left to rotate.

## Changelog

[INTERNAL] - Update fingerprint for SSH deploy key

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

Test Plan: n/a

Reviewed By: cipolleschi

Differential Revision: D42413025

Pulled By: cortinico

fbshipit-source-id: 571f304e8cc2dad19c41e5413ed3c7d4c078ba60

# Conflicts:
#	.circleci/config.yml
2023-01-09 14:21:46 +00:00
Distiller 49dd38f133 [0.70.6] Bump version numbers 2022-11-15 15:30:19 +00:00
Lorenzo Sciandra fb0e88beb9 [LOCAL] correct fix: bring back jest cache but on the right version 2022-11-15 15:18:12 +00:00
Lorenzo Sciandra c56375994c [LOCAL] Bump git checkout cache key 2022-11-15 15:16:35 +00:00
Lorenzo Sciandra 69ce989307 Revert "[0.70.6] Bump version numbers"
This reverts commit 02a388f050.
2022-11-15 15:12:45 +00:00
Distiller 02a388f050 [0.70.6] Bump version numbers 2022-11-15 14:38:31 +00:00
Lorenzo Sciandra ef29c9b608 [LOCAL] remove regression: unwanted @jest/create-cache-key-function dependency 2022-11-14 16:31:55 +00:00
Lorenzo Sciandra 9bcc5e0373 [LOCAL] Bump CLI to 9.3.2 2022-11-14 16:29:56 +00:00
DavidandLorenzo Sciandra 11473c388e Add support Promise.any out of box (#35080)
Summary:
`promise` module diff: [`8.2.0...8.3.0`](https://npmfs.com/compare/promise/8.2.0/8.3.0/)
- Hermes issue: https://github.com/facebook/hermes/issues/766

## Changelog

[General] [Added] - Added support `Promise.any`

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

Test Plan:
Release notes [`promise@8.3.0`](https://github.com/then/promise/releases/tag/8.3.0)

```tsx
typeof Promise.any // function
```

Reviewed By: cortinico

Differential Revision: D40681373

Pulled By: jacdebug

fbshipit-source-id: ecd589186483f3aa0f48da28a1f6dfcb1e26c8bc

# Conflicts:
#	package.json
#	yarn.lock
2022-11-14 16:27:27 +00:00
Riccardo CipolleschiandLorenzo Sciandra 3f1c55ba5b Update ruby codegen to cleanup build folder. (#34398)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34398

This Diff cleans up the codegen folder for iOS when we install the pods. This is useful to start from a clean situation. The codegen runs after this step and we make sure that the file system is clean

## Changelog
[iOS][Changed] - Cleanup codegen build folder before installing the pods

Reviewed By: cortinico

Differential Revision: D38657027

fbshipit-source-id: 8a914457d7963521d6d8dc7819eba864736f50a0
2022-11-14 16:23:03 +00:00
Distiller 35fa47b382 [0.70.5] Bump version numbers 2022-11-06 20:06:48 +00:00
Nicola Corti 59407a4d34 Force dependencies resolution to minor series for 0.70 2022-11-06 19:44:58 +00:00
Distiller 54e666205b [0.70.4] Bump version numbers 2022-10-25 14:20:44 +00:00
Lorenzo SciandraandDmitry Rykun f5ebb692ab chore: bump CLI to 9.2.1 (#35022)
Summary:
A super small PR to bump CLI to latest available of the 9.x stream, to make available in main the asset image fix (https://github.com/react-native-community/cli/pull/1290) and to be able to cherry pick it back in 0.70 branch.

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[General] [Changed] - bump CLI to 9.2.1

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

Test Plan: CI is green

Reviewed By: dmytrorykun

Differential Revision: D40507344

Pulled By: huntie

fbshipit-source-id: 7c3753e9df154eb5835f021cdfe1b476499afb9a
2022-10-19 17:17:54 +01:00
Samuel SuslaandDmitry Rykun 72c940b384 Center text if line height isn't 0
Summary: changelog: Fix vertical text alignment in new architecture when line height is not 0.

Reviewed By: javache

Differential Revision: D40346225

fbshipit-source-id: f6282cb8df80e9a543e5602fddcca1a1a82377e3
2022-10-19 16:56:53 +01:00
Krystof WoldrichandDmitry Rykun 93bb2d6fa8 Fix rn config file load codegen (#34895)
Summary:
Resolves https://github.com/facebook/react-native/issues/34894

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[General][Fixed] - Load react-native.config.js from correct path during codegen

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

Test Plan:
Command line output after fix with extra console logs to show the correctness ( hopefully :) ) of the fix.

```bash
 ~/repos/sentry-react-native � � krystofwoldrich/multipleRNsamples ± �node node_modules/react-native/scripts/generate-artifacts.js --path sample-new-architecture --outputPath codegen
[Codegen] Processing react-native core libraries
[Codegen] Found react-native

[Codegen] >>>>> Searching for codegen-enabled libraries in /Users/krystofwoldrich/repos/sentry-react-native/node_modules

[Codegen] >>>>> Searching for codegen-enabled libraries in react-native.config.js
cwd /Users/krystofwoldrich/repos/sentry-react-native
rnConfigFilePath sample-new-architecture/react-native.config.js
rnConfigFilePath - resolved /Users/krystofwoldrich/repos/sentry-react-native/sample-new-architecture/react-native.config.js
[Codegen] Found sentry/react-native

[Codegen] >>>>> Searching for codegen-enabled libraries in the app

[Codegen] >>>>> Processing FBReactNativeSpec
[Codegen] Generated schema: /var/folders/tl/jddrmdy97gj0cljrcwb_qkzc0000gn/T/FBReactNativeSpecrHeknw/schema.json
[Codegen] Generated artifacts: codegen/build/generated/ios

[Codegen] >>>>> Processing rncore
[Codegen] Generated schema: /var/folders/tl/jddrmdy97gj0cljrcwb_qkzc0000gn/T/rncorehCjmlJ/schema.json
[Codegen] Generated artifacts: codegen/build/generated/ios

[Codegen] >>>>> Processing RNSentrySpec
[Codegen] Generated schema: /var/folders/tl/jddrmdy97gj0cljrcwb_qkzc0000gn/T/RNSentrySpectMmDpf/schema.json
[Codegen] Generated artifacts: codegen/build/generated/ios

>>>>> Creating component provider
Generated schema list: /var/folders/tl/jddrmdy97gj0cljrcwb_qkzc0000gn/T/rn-tmp-schema-list.json
Generated provider in: codegen/build/generated/ios

[Codegen] Done.
```

Reviewed By: rshest

Differential Revision: D40177746

Pulled By: rshest

fbshipit-source-id: 970f016db26fda003ee3b47d50e80549fdb88415
2022-10-19 16:56:13 +01:00
Dmitry Rykun 866021b58c Bump react-native-codegen to 0.70.6 2022-10-19 16:55:18 +01:00
Gianluca SpadaandDmitry Rykun c4b094fd24 Fix: Codegen template error in RCTThirdPartyFabricComponentsProvider (#34738)
Summary:
When `GenerateRCTThirdPartyFabricComponentsProviderCpp.js` generates `RCTThirdPartyFabricComponentsProvider.mm` an edge case happens in the following situation:
- The same library exports multiple modules with one component each (i.e. one component per file);
- The **first component** is excluded for iOS via the `excludedPlatforms` property in *codegenNativeComponent*.

A "loose" comma appears in the generated template, breaking the code.

```c++
Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char *name) {
  static std::unordered_map<std::string, Class (*)(void)> sFabricComponentsClassMap = {
, // <-- the offending comma
    {"NativeComponent2", NativeComponent2Cls}, // rnmylibrary
  };
}
```

At some point, `GenerateRCTThirdPartyFabricComponentsProviderCpp.js` does not properly filter out empty arrays resulting from excluded components. This does not seem to be a problem when the excluded component is not the first being processed, as the comma gets added at the end of the previous line, after the comment with the name of the library.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[iOS] [Fixed] - Fix error in the Codegen template for ThirdPartyFabricComponentsProvider

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

Test Plan:
<!-- Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes the user interface. -->

This is the schema that leads to the bug. Notice that the first component was excluded for iOS.
```json
{
  "modules": {
    "ComponentFile1": {
      "type": "Component",
      "components": {
        "NativeComponent1": {
          "excludedPlatforms": ["iOS"]
          "extendsProps": [
            {
              "type": "ReactNativeBuiltInType",
              "knownTypeName": "ReactNativeCoreViewProps"
            }
          ],
          "events": [],
          "props": [],
          "commands": []
        }
      }
    },
    "ComponentFile2": {
      "type": "Component",
      "components": {
        "NativeComponent2": {
          "extendsProps": [
            {
              "type": "ReactNativeBuiltInType",
              "knownTypeName": "ReactNativeCoreViewProps"
            }
          ],
          "events": [],
          "props": [],
          "commands": []
        }
      }
    }
  }
```

`GenerateRCTThirdPartyFabricComponentsProviderCpp.js` should generate a template without the comma in the wrong position (before NativeComponent2).

I also added an additional test case to cover this problem. All the other tests passed.

Reviewed By: sammy-SC

Differential Revision: D39686573

Pulled By: cipolleschi

fbshipit-source-id: 6054464d024218eb0b2e02974aa5cc7c8aebbbc9
2022-10-19 16:51:07 +01:00
Distiller 917e97b996 [0.70.3] Bump version numbers 2022-10-12 13:15:51 +00:00
Pieter De BaetsandLorenzo Sciandra fe8f0fb09f Apply Animated initialProps handling to Fabric only (#34927)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34927

The changes made in D36902220 (https://github.com/facebook/react-native/commit/a04195167bbd8f27c6141c0239a61a345cac5a88) and D36958882 (https://github.com/facebook/react-native/commit/d8c25ca1b62df2b93f70bbb1f7b379643ab9ccd4) attempted to reduce flickering and consistency issues when using Animated.

In the old renderer, we explicitly reset all animated props, and wait for the subsequent React commit to set the props to the right state, but if `initialProps` are used, the React reconciliation may not be able to identify the prop-update is required and will leave out the value. This behaviour is different in the new renderer, where we do not explicitly `restoreDefaultValues` on detaching the animated node, and instead rely on the latest state being correct(?).

Changelog:
[General][Fixed] Stop styles from being reset when detaching Animated.Values in old renderer

Fixes #34665

Reviewed By: rshest

Differential Revision: D40194072

fbshipit-source-id: 1b3fb1d1f4a39036a501a8a21e57002035dd5659

# Conflicts:
#	Libraries/Animated/createAnimatedComponent.js
2022-10-11 13:25:39 +01:00
Lorenzo Sciandra 37790e4507 fix(ios): add xcode 14 workaround (turn off signing resource bundles) for pods (#34826)
Summary:
This is inspired by the Expo workaround https://github.com/expo/expo/commit/d970a9ecbb15b554b6fa23e8d43006fd15152028 to address an issue that cocoapods has with Xcode 14: https://github.com/CocoaPods/CocoaPods/issues/11402

This wants to address this https://github.com/facebook/react-native/issues/34673 in a way that we can also cherry-pick on the 0.70 branch.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[iOS] [Fixed] - add xcode 14 workaround (turn off signing resource bundles) for `React-Core`

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

Test Plan:
Tested locally by opening RNTester via Xcode 14.0.1, and targetting my iPhone as device. After applying the patch, the error for React Core AccessibilityResources disappears.

Also, added ruby test for new patch.

Reviewed By: hramos

Differential Revision: D40063828

Pulled By: hramos

fbshipit-source-id: e10d5b6a917a6a7cbacd14ecfdac55e60e46c6f8
2022-10-11 13:24:14 +01:00
Anandraj GovindanandLorenzo Sciandra ebf746b1f9 Use NMake generator for Hermes build on Windows (#34790)
Summary:
CMake on Windows uses "Visual Studio **" generators are [multi-configuration](https://cgold.readthedocs.io/en/latest/glossary/multi-config.html),

which requires the hermes cli and hermes runtime build flavors to be compatible. Using the "MakeFile" generator will avoid the requirement and keeps the gradle script simpler. Please note that the "Makefile" generator is the default when only "Visual Studio Community edition" with default packages is available.

Use NMake generator for Hermes build on Windows

## Changelog
CMake on Windows uses "Visual Studio **" generators are [multi-configuration](https://cgold.readthedocs.io/en/latest/glossary/multi-config.html),

which requires the hermes cli and hermes runtime build flavors to be compatible. Using the "MakeFile" generator will avoid the requirement and keeps the gradle script simpler. Please note that the "Makefile" generator is the default when only "Visual Studio Community edition"  with default packages  is available.

[Android] [Fixed] - Use NMake generator for Hermes build on Windows

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

Test Plan: Verified that RN build on Windows with multiple SKUs of Visual studio.d

Reviewed By: cortinico

Differential Revision: D39889332

Pulled By: cortinico

fbshipit-source-id: f2d39d981e7c58c8cb93a4322155c844cb6bded3
2022-10-11 13:24:05 +01:00
Anandraj GovindanandLorenzo Sciandra 0c2f55d05f Fixing failure building RN codegen CLI on Windows (#34791)
Summary:
Ensuring the file paths uses forward slashes as separator to avoid the characters from being interpreted as ASCII escape characters.

## Changelog

Fixing build failure building RN codegen CLI on Windows. Ensuring the file paths uses forward slashes as separator to avoid the characters from being interpreted as ASCII escape characters.

[Android] [Fixed] - Fixing failure building RN codegen CLI on Windows

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

Test Plan: Ensured RN main branch builds on Windows with new architecture turned on.

Reviewed By: cipolleschi

Differential Revision: D39889468

Pulled By: cipolleschi

fbshipit-source-id: 7d79eac9f433908cc86dd7ca2eec841739ef6365

# Conflicts:
#	ReactAndroid/cmake-utils/ReactNative-application.cmake
2022-10-11 13:23:51 +01:00
Garrett Forbes MonroeandLorenzo Sciandra e2645a59f6 Revert D37801394: Multisect successfully blamed D37801394 for test or build failures
Summary:
This diff is reverting D37801394 (https://github.com/facebook/react-native/commit/51f49ca9982f24de08f5a5654a5210e547bb5b86)
D37801394 (https://github.com/facebook/react-native/commit/51f49ca9982f24de08f5a5654a5210e547bb5b86) has been identified to be causing the following test or build failures:
Tests affected:
- https://www.internalfb.com/intern/test/844424989736255/

Here's the Multisect link:
https://www.internalfb.com/intern/testinfra/multisect/1062919
Here are the tasks that are relevant to this breakage:
T116036972: 105 tests started failing for oncall bridgeless_jest_e2e_tests in the last 2 weeks
We're generating a revert to back out the changes in this diff, please note the backout may land if someone accepts it.

**To Address Land blocker from previous version (see pic):**
{F752642767}

```
Changelog:
[General][Change] - Revert breaking change in MPay order creation screen (user input in duplicated, and then not deletable. See T126127801 for more details)
```

Reviewed By: philIip

Differential Revision: D37863306

fbshipit-source-id: 24f2448d7bc9761ec31edd6f6b97c668171027d3
2022-10-11 13:20:57 +01:00
Distiller b9c297537a [0.70.2] Bump version numbers 2022-10-04 09:34:54 +00:00
Paige SunandLorenzo Sciandra 13a2b117be Minor: Rename AccessibilityInfo.sendAccessibilityEvent_unstable to sendAccessibilityEvent
Summary:
Changelog:
[Internal] Rename AccessibilityInfo.sendAccessibilityEvent_unstable to sendAccessibilityEvent

In Fabric, we want people to use `AccessibilityInfo.sendAccessibilityEvent` instead of `UIManager.sendAccessibilityEvent` for Android. The API is not unstable. There is a test in [AccessibilityExample.js](https://github.com/facebook/react-native/blob/c940eb0c49518b82a3999dcac3027aa70018c763/packages/rn-tester/js/examples/Accessibility/AccessibilityExample.js#L959) in RNTester to confirm that it works.

A search for [`AccessibilityInfo.sendAccessibilityEvent_unstable` in Github](https://github.com/search?q=AccessibilityInfo.sendAccessibilityEvent_unstable&type=Code) shows that it's not being used yet, which makes sense because it's an Fabric API. Therefore it's safe to rename it.

Reviewed By: sammy-SC

Differential Revision: D37901006

fbshipit-source-id: 73f35b09ca8f9337f4d66a431f0a3f815da38249
2022-10-03 13:31:17 +01:00
Lorenzo Sciandra 2de4cf03cf chore(deps): bump CLI to 9.1.3 and Metro to 0.72.3 (#34803)
Summary:
This PR bumps the dep version of Metro and the RN CLI to latest, and realigns them to avoid the issue we currently have in 0.70: https://github.com/facebook/react-native/issues/34714 (this commit will be cherry-picked there)

Also, it pins it all down to precise version. See comments for reasoning.

While at it, I gave a cleanup pass to the yarn.lock with [`yarn deduplicate`](https://github.com/scinos/yarn-deduplicate#readme).

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[General] [Changed] - bump CLI to 9.1.3 and Metro to 0.72.3

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

Test Plan: CI is green

Reviewed By: dmytrorykun

Differential Revision: D39967392

Pulled By: dmytrorykun

fbshipit-source-id: 799dd745834c9ba349362f70afb4bdbd1a48260e

# Conflicts:
#	package.json
#	template/package.json
#	yarn.lock
2022-10-03 13:12:17 +01:00
Kudo ChienandLorenzo Sciandra 7b53a244cd Fix port as -1 if dev server without specifying port on Android (#34705)
Summary:
when specifying dev server without port, e.g. http://www.example.com/, there are some issues.

1. redbox error
<img src="https://user-images.githubusercontent.com/46429/190540390-8ee420f2-7642-427b-9f2e-e0c6d31015f8.png" width="30%">

2. showing -1 in loading view

<img src="https://user-images.githubusercontent.com/46429/190540727-158f35ad-359f-443a-a4b0-768dd2f7e400.png" width="50%">

the root cause is coming from [`java.net.URL.getPort()` will return -1 when the url doesn't have a port](https://developer.android.com/reference/java/net/URL#getPort()). this pr replaces the parser to [`okhttp3.HttpUrl`](https://square.github.io/okhttp/4.x/okhttp/okhttp3/-http-url/#port) that it will have default port 80 for http or port 443 for https. the two call paths should only serve http/https address, not file:// address. it should be safe to change from java.net.URL to okhttp3.HttpUrl.

not fully related, in the case above, android will connect to `ws://www.example.com/:8097` for react-devtools
we should strip the trailing slash in *setUpReactDevTools.js*

## Changelog

[Android] [Fixed] - Fix port as -1 if dev server without specifying port on Android

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

Test Plan:
test on rn-tester with the following steps

1. `yarn start`
2. open another terminal and run `ngrok http 8081` and it will return a tunnel url, e.g. `71a1-114-36-194-97.jp.ngrok.io`
3. open dev setting in app and change the dev server to `71a1-114-36-194-97.jp.ngrok.io`
5. reload the app

Reviewed By: cipolleschi

Differential Revision: D39573988

Pulled By: cortinico

fbshipit-source-id: 397df90ab30533207bd87a3f069132d97c22c7fd
2022-10-03 13:10:33 +01:00
Gabriel Donadel Dall'AgnolandLorenzo Sciandra b03f536279 fix: KeyboardAvoidingView height when "Prefer Cross-Fade Transitions" is enabled (#34503)
Summary:
Fix `KeyboardAvoidingView`  height on iOS when "Prefer Cross-Fade Transitions" is enabled by adding an additional check to `_relativeKeyboardHeight` verifying if `prefersCrossFadeTransitions()` is true and `keyboardFrame.screenY` is `0` and treating this special case. The issue was caused  by the native RCTKeyboardObserver where the `endFrame` reported by `UIKeyboardWillChangeFrameNotification` returns `height = 0` when Prefer Cross-Fade Transitions" is enabled
and unfortunelly there isn't much we can do on the native side to fix it.

Closes https://github.com/facebook/react-native/issues/31484
Closes https://github.com/facebook/react-native/issues/29974

## Changelog

[iOS] [Fixed] - Fix KeyboardAvoidingView height when "Prefer Cross-Fade Transitions" is enabled

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

Test Plan:
**On iOS 14+**

1.  Access Settings > "General" > "Accessibility" > "Reduce Motion", enable "Reduce Motion" then enable "Prefer Cross-Fade Transitions".
2. Open the RNTester app and navigate to the KeyboardAvoidingView page
3. Focus and blur inputs and observe the keyboard behaving correctly

https://user-images.githubusercontent.com/11707729/186822671-801872be-7db1-4c5c-904b-1987441c1326.mov

Reviewed By: jacdebug

Differential Revision: D39055213

Pulled By: cipolleschi

fbshipit-source-id: fac17cbe02867e0fe522397f6cb59a8b51c1840f
2022-10-03 13:09:49 +01:00
Nick GerlemanandLorenzo Sciandra 764f584615 Let ScrollView Know About Keyboard Opened Before Mount
Summary:
ScrollView has special behavior when the keyboard is open, but starts listening to keyboard events on mount. This means a ScrollView mounted after the keyboard is already up (e.g. for a typeahead) is not initialized to the keyboard being up.

This change adds `Keyboard.isVisible()` and `Keyboard.metrics()` APIs to allow seeding initial keyboard metrics.

Changelog:
[General][Fixed] - Inform ScrollView of Keyboard Events Before Mount

Reviewed By: JoshuaGross, yungsters

Differential Revision: D38701976

fbshipit-source-id: 42b354718fbf5001ca4b90de0442eeab0be91e7a
2022-10-03 13:09:47 +01:00
Gabriel Donadel Dall'AgnolandLorenzo Sciandra 75d5679701 feat: Add support for "Prefer Cross-Fade Transitions" into AccessibilityInfo (#34406)
Summary:
This PR adds `prefersCrossFadeTransitions()` to AccessibilityInfo in order to add support for "Prefer Cross-Fade Transitions", exposing the iOS settings option as proposed here https://github.com/react-native-community/discussions-and-proposals/issues/452.
I believe this would be especially helpful for solving https://github.com/facebook/react-native/issues/31484

#### TODO
- [ ]  Submit react-native-web PR updating AccessibilityInfo documentation.

## Changelog

[iOS] [Added] - Add support for "Prefer Cross-Fade Transitions" into AccessibilityInfo

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

Test Plan:
**On iOS 14+**

1.  Access Settings > "General" > "Accessibility" > "Reduce Motion", enable "Reduce Motion" then enable "Prefer Cross-Fade Transitions".
2. Open the RNTester app and navigate to the Accessibility page

https://user-images.githubusercontent.com/11707729/154588402-7d050858-3c2d-4d86-9585-928b8c66941b.mov

Reviewed By: cipolleschi

Differential Revision: D38711316

Pulled By: makovkastar

fbshipit-source-id: b9965cd4285f1aa0f1fa927080370a22329c2f62
2022-10-03 13:08:32 +01:00
Luna WeiandLorenzo Sciandra 73e55334b0 Add a pseudo flow declaration for AccessibilityInfo
Summary: Changelog: [Internal] - Create a type declaration for AccsesibilityInfo for clearer signal when our public API types change

Reviewed By: yungsters

Differential Revision: D38712552

fbshipit-source-id: cc7c727d41fb03ca714cb05fd10dc32038374fd0
2022-10-03 13:08:28 +01:00
Lorenzo Sciandra 9fd764388a Revert "fix: KeyboardAvoidingView height when "Prefer Cross-Fade Transitions" is enabled (#34503)"
This reverts commit ec0049b008.
2022-10-03 13:07:13 +01:00
Distiller a54ba33305 [0.70.1] Bump version numbers 2022-09-15 15:23:57 +00:00
Dmitry Rykun e33633644c Bump react-native-gradle-plugin to 0.70.3 2022-09-14 17:08:53 +01:00
Dmitry Rykun 6a8c38eef2 Bump react-native-codegen to 0.70.5 2022-09-14 17:06:19 +01:00
Roman MelnykandDmitry Rykun eaa32f9f65 #34610 Fix invalid range "t-5" in string transliteration [iOS] (#34636)
Summary:
Fix invalid range "t-5" in string transliteration [iOS] for M1 pod install issue.

This should fix pod install error for M1 machines.

## Changelog
[iOS] [Fixed] - Fix ios pod install error

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

Test Plan: Run pod install on M1 machine.

Reviewed By: sammy-SC

Differential Revision: D39423276

Pulled By: cipolleschi

fbshipit-source-id: 4ec95af7103395792facba0f93fd8de05a3fe78d
2022-09-14 16:56:29 +01:00
Danilo BürgerandDmitry Rykun c401334e04 Support PlatformColor in borderColor on Android (#33544)
Summary:
PlatformColor should work on all *color style attributes on all platform.

Partially fixes https://github.com/facebook/react-native/issues/32942

## Changelog

[Android] [Fixed] - Support PlatformColor in borderColor

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

Test Plan: Open rn tester (USE_FABRIC=false) platform color api examples. Without the changes to ViewProps.java, it will error out.

Reviewed By: lunaleaps

Differential Revision: D39413519

Pulled By: NickGerleman

fbshipit-source-id: 58962ba2956aa3df45144108eec194aedf23886b
2022-09-14 16:56:16 +01:00
Satyajit SahooandDmitry Rykun f0ffd2291c feat: support custom library paths in react-native.config.js for codegen on iOS (#34580)
Summary:
Currently for codegen to work for a library on iOS, it needs to be located
inside `node_modules`. This patch adds support for libraries defined in
`react-native.config.js`.

This is useful when developing libraries as well as monorepos where the library
may exist outside of the `node_modules`.

Example:

```js
// react-native.config.js
const path = require('path');

module.exports = {
  dependencies: {
    'react-native-library-name': {
      root: path.join(__dirname, '..'),
    },
  },
};
```

## Changelog

[Internal] [Added] - Support custom library paths in `react-native.config.js` for codegen on iOS

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

Test Plan:
Tested on a test application and ensured that codegen finds the library specified in `react-native.config.js`

https://user-images.githubusercontent.com/1174278/188141056-bce03730-2a13-4648-8889-9727aaf2c3c4.mp4

I have also added a basic test case for this scenario.

Reviewed By: jacdebug, cortinico

Differential Revision: D39257919

Pulled By: cipolleschi

fbshipit-source-id: 131189f1941128a59b9b1e28af61a9038eb4536b
2022-09-14 16:56:01 +01:00
Kudo ChienandDmitry Rykun ad582f5e8a add debugging settings (#34489)
Summary:
For brownfield apps, it is possible to have multiple hermes runtimes serving different JS bundles. Hermes inspector currently only supports single JS bundle. The latest loaded JS bundle will overwrite previous JS bundle. This is because we always use the ["Hermes React Native" as the inspector page name](https://github.com/facebook/react-native/blob/de75a7a22eebbe6b7106377bdd697a2d779b91b0/ReactCommon/hermes/executor/HermesExecutorFactory.cpp#L157) and [the latest page name will overwrite previous one](https://github.com/facebook/react-native/blob/de75a7a22eebbe6b7106377bdd697a2d779b91b0/ReactCommon/hermes/inspector/chrome/ConnectionDemux.cpp#L77-L86).

This PR adds more customization for HermesExecutorFactory:
- `setEnableDebugger`: provide a way to disable debugging features for the hermes runtime
- `setDebuggerName`: provide a way to customize inspector page name other than the default "Hermes React Native"

[General] [Added] - Add more debugging settings for *HermesExecutorFactory*

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

Test Plan:
Verify the features by RNTester.

1. `setEnableDebugger`

```diff
 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java
+++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java
@@ -10,10 +10,12 @@ package com.facebook.react.uiapp;
 import android.app.Application;
 import androidx.annotation.NonNull;
 import com.facebook.fbreact.specs.SampleTurboModule;
+import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
 import com.facebook.react.ReactApplication;
 import com.facebook.react.ReactNativeHost;
 import com.facebook.react.ReactPackage;
 import com.facebook.react.TurboReactPackage;
+import com.facebook.react.bridge.JavaScriptExecutorFactory;
 import com.facebook.react.bridge.NativeModule;
 import com.facebook.react.bridge.ReactApplicationContext;
 import com.facebook.react.config.ReactFeatureFlags;
@@ -50,6 +52,13 @@ public class RNTesterApplication extends Application implements ReactApplication
           return BuildConfig.DEBUG;
         }

+        Override
+        protected JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
+          HermesExecutorFactory factory = new HermesExecutorFactory();
+          factory.setEnableDebugger(false);
+          return factory;
+        }
+
         Override
         public List<ReactPackage> getPackages() {
           return Arrays.<ReactPackage>asList(
```

after app launched, the metro inspector should return empty array.
Run `curl http://localhost:8081/json` and returns `[]`

2. `setDebuggerName`

```diff
 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java
+++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterApplication.java
@@ -10,10 +10,12 @@ package com.facebook.react.uiapp;
 import android.app.Application;
 import androidx.annotation.NonNull;
 import com.facebook.fbreact.specs.SampleTurboModule;
+import com.facebook.hermes.reactexecutor.HermesExecutorFactory;
 import com.facebook.react.ReactApplication;
 import com.facebook.react.ReactNativeHost;
 import com.facebook.react.ReactPackage;
 import com.facebook.react.TurboReactPackage;
+import com.facebook.react.bridge.JavaScriptExecutorFactory;
 import com.facebook.react.bridge.NativeModule;
 import com.facebook.react.bridge.ReactApplicationContext;
 import com.facebook.react.config.ReactFeatureFlags;
@@ -50,6 +52,13 @@ public class RNTesterApplication extends Application implements ReactApplication
           return BuildConfig.DEBUG;
         }

+        Override
+        protected JavaScriptExecutorFactory getJavaScriptExecutorFactory() {
+          HermesExecutorFactory factory = new HermesExecutorFactory();
+          factory.setDebuggerName("Custom Hermes Debugger");
+          return factory;
+        }
+
         Override
         public List<ReactPackage> getPackages() {
           return Arrays.<ReactPackage>asList(
```

after app launched, the metro inspector should return an entry with *Custom Hermes Debugger*
Run `curl http://localhost:8081/json` and returns

```json
[
  {
    "id": "2-1",
    "description": "com.facebook.react.uiapp",
    "title": "Custom Hermes Debugger",
    "faviconUrl": "https://reactjs.org/favicon.ico",
    "devtoolsFrontendUrl": "devtools://devtools/bundled/js_app.html?experiments=true&v8only=true&ws=%5B%3A%3A1%5D%3A8081%2Finspector%2Fdebug%3Fdevice%3D2 (https://github.com/facebook/react-native/commit/e5c5dcd9e26e9443f59864d9763b049e0bda98e7)%26page%3D1 (https://github.com/facebook/react-native/commit/ea93151f21003df6f65dd173dd5dcb3135b0ae94)",
    "type": "node",
    "webSocketDebuggerUrl": "ws://[::1]:8081/inspector/debug?device=2&page=1",
    "vm": "Hermes"
  }
]
```

Reviewed By: mdvacca

Differential Revision: D38982104

Pulled By: cipolleschi

fbshipit-source-id: 78003c173db55448a751145986985b3e1d1c71bb
2022-09-14 16:55:24 +01:00
Gabriel Donadel Dall'AgnolandDmitry Rykun ec0049b008 fix: KeyboardAvoidingView height when "Prefer Cross-Fade Transitions" is enabled (#34503)
Summary:
Fix `KeyboardAvoidingView`  height on iOS when "Prefer Cross-Fade Transitions" is enabled by adding an additional check to `_relativeKeyboardHeight` verifying if `prefersCrossFadeTransitions()` is true and `keyboardFrame.screenY` is `0` and treating this special case. The issue was caused  by the native RCTKeyboardObserver where the `endFrame` reported by `UIKeyboardWillChangeFrameNotification` returns `height = 0` when Prefer Cross-Fade Transitions" is enabled
and unfortunelly there isn't much we can do on the native side to fix it.

Closes https://github.com/facebook/react-native/issues/31484
Closes https://github.com/facebook/react-native/issues/29974

[iOS] [Fixed] - Fix KeyboardAvoidingView height when "Prefer Cross-Fade Transitions" is enabled

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

Test Plan:
**On iOS 14+**

1.  Access Settings > "General" > "Accessibility" > "Reduce Motion", enable "Reduce Motion" then enable "Prefer Cross-Fade Transitions".
2. Open the RNTester app and navigate to the KeyboardAvoidingView page
3. Focus and blur inputs and observe the keyboard behaving correctly

https://user-images.githubusercontent.com/11707729/186822671-801872be-7db1-4c5c-904b-1987441c1326.mov

Reviewed By: jacdebug

Differential Revision: D39055213

Pulled By: cipolleschi

fbshipit-source-id: fac17cbe02867e0fe522397f6cb59a8b51c1840f
2022-09-14 16:08:10 +01:00
Rasmus EnemanandDmitry Rykun 047a149279 fix: Crash if WebView is disabled (#34483)
Summary:
When the webview is updated by play store, all apps that has loaded webview gets killed. For background see https://issuetracker.google.com/issues/228611949?pli=1

We have a long-running app and don't want this to happen and while we are not using webview anywhere, we are using websockets that loads it for reading cookies, however we are not using cookies to authenticate the websocket and thus want to disable the webview to avoid loading it unnecessarily and then getting killed unnecessarily.

The webview has support for beeing disabled https://developer.android.com/reference/android/webkit/WebView#disableWebView() however as-is this crashes React Native. It seems to me like this case is very similar to not having web view installed and should be handled in the same way.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Fixed] - Avoid crash in ForwardingCookieHandler if webview is disabled

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

Test Plan: Add `WebView.disableWebView();` as the first line in `MainActivity.onCreate`.

Reviewed By: christophpurrer

Differential Revision: D38981827

Pulled By: cipolleschi

fbshipit-source-id: 335a8420568ad0c80b834ae8a3b164e55ebe26f3
2022-09-14 15:52:23 +01:00
Kudo ChienandDmitry Rykun b15199f195 Fix React module build error with swift integration on new architecture mode (#34527)
Summary:
when integrates with swift, the compiler will build clang module based on the *React-Core-umbrella.h*.  however, the include chain reaches some c++ headers that are not available from swift. it will cause build error.

![Screen Shot 2022-08-29 at 8 25 08 PM](https://user-images.githubusercontent.com/46429/187200668-2a1f12c9-61e5-4d8b-9531-69ff5c1a5741.png)

this pr adds `#ifdef __cplusplus` guard for it.

## Changelog

[iOS] [Fixed] - Fix React module build error with swift integration on new architecture mode

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

Test Plan:
one thing we didn't figure out is that we require reanimated to repro the build error.

1.  `npx react-native init RN070 --version 0.70.0-rc.4`. # can also repro this issue on 0.69
2.  `cd RN070`
3. `yarn add react-native-reanimated@next`
4. `cd ios && rm -rf Pods build && RCT_NEW_ARCH_ENABLED=1 pod install`
5. add `import React;` in `main.m` for clang module generation

```diff
 --- a/ios/RN070/main.m
+++ b/ios/RN070/main.m
@@ -1,5 +1,6 @@
 #import <UIKit/UIKit.h>

+@import React;
 #import "AppDelegate.h"

 int main(int argc, char *argv[])
```

6. `yarn ios`

Reviewed By: cipolleschi

Differential Revision: D39128716

Pulled By: jacdebug

fbshipit-source-id: d9e9130f99e3b9e5f7807c475a24cdd84880e720
2022-09-14 15:52:10 +01:00
Janic DuplessisandDmitry Rykun 2483bc089a Fix hermes profiler (#34129)
Summary:
The hermes profiler doesn't work currently, I tracked down the problem to a couple of things.

- Need to call `registerForProfiling` to enable profiling for a specific runtime. I added the call at the same place where we enable the debugger.
- `runInExecutor` didn't work and call its callback. Not sure exactly why, but using `executor_->add` like we do in a lot of other places to run code on the executor works.
- `GetHeapUsageRequest` seems to cause some deadlocks. JS contexts were not detected reliably, I suspect this is related to deadlocks when trying to run on inspector executor. `GetHeapUsageRequest` doesn't actually need any data from the inspector so there is no need to run it on that queue. To fix it I moved the call to use `runInExecutor` instead.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Fixed] - Fix hermes profiler

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

Reviewed By: cortinico

Differential Revision: D37669469

Pulled By: philIip

fbshipit-source-id: 6cf3b2857ac60b0a1518837b9c56b9c093ed222f
2022-09-14 15:51:45 +01:00
Evan CharltonandDmitry Rykun 98e5134a4f fix: Correctly resolve classes with FindClass(..) (#34533)
Summary:
`JNIEnv`'s `FindClass(..)` function takes the classes in the standard
`foo/bar/Baz` class specification (unless they're special, like arrays).
Specifying them with `Lfoo/bar/Baz;` results in a
`ClassNotFoundException` being raised -- which is especially unhelpful
when intending to re-throw an exception.

The docs for `JNIEnv#FindClass(..)` can be found [here][jnienv].

[jnienv]:
  https://docs.oracle.com/javase/7/docs/technotes/guides/jni/spec/functions.html#:~:text=The%20name%20argument,java/lang/String%22

## Changelog

[Android] [Fixed] - Correctly resolve classes with FindClass(..)

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

Test Plan:
No exact test plan. However, if an exception is thrown during the
rendering process, a fatal `ClassNotFoundException` is raised, rather
than having the error be passed up to the `ReactNativeManager`.

Fixes: facebook/yoga#1120

Reviewed By: amir-shalem

Differential Revision: D39133326

Pulled By: jacdebug

fbshipit-source-id: 86283b7d21aed49ed0e9027b2aef85f0108cdf9a
2022-09-14 15:51:29 +01:00
Kudo ChienandDmitry Rykun 6d50f7e1f0 Only show warning when overwrite existing preprocessor (#34479)
Summary:
from the original design of `StyleSheet.setStyleAttributePreprocessor()` in https://github.com/facebook/react-native/issues/11138, the overwriting warning shows when the existing preprocess is be overwritten.  the behavior changes from https://github.com/facebook/react-native/commit/33b385825c72. This PR revises the logic back to original design.

## Changelog

[Internal] [Fixed] - Show warning only when overwriting existing preprocessor in `StyleSheet.setStyleAttributePreprocessor()`

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

Test Plan:
Unit Test

```
 PASS  Libraries/StyleSheet/__tests__/StyleSheet-test.js
  setStyleAttributePreprocessor
    ✓ should not show warning when set preprocessor first time (2 ms)
    ✓ should show warning when overwrite the preprocessor (1 ms)
```

Reviewed By: dmitryrykun

Differential Revision: D38940676

Pulled By: cipolleschi

fbshipit-source-id: 80cf30fff62f4a02c17f7f42b3260a6011d5fc82
2022-09-14 15:51:00 +01:00
Zihan Chen (MSFT)andDmitry Rykun 521c712bfd Ensure equivalent Flow and TypeScript turbo module definition generates the same output (#34251)
Summary:
Flow and TypeScript are two very similar programming languages. They are both recognizable as inputs for turbo module codegen. It is reasonable to require equivalent Flow and TypeScript turbo module definition generates the same output.

I add some test cases to ensure this. Glad that no functional inconsistency is found here.

## Changelog

[General] [Changed] - codegen: ensure equivalent Flow and TypeScript TM definition generates the same output

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

Test Plan: `yarn jest` passed in `packages/react-native-codegen`

Reviewed By: dmitryrykun

Differential Revision: D38116756

Pulled By: cipolleschi

fbshipit-source-id: 476adbd171a35813923f2020c826d21b1fc2eeed
2022-09-14 15:28:47 +01:00
Zihan Chen (MSFT)andDmitry Rykun 2b3f6de630 Support TypeScript array types for turbo module (component only) (#34216)
Summary:
Turbo module codegen for component parse `readonly T[]` and `readonly Object[][]` incorrectly. In this change, it is fixed, with necessary test cases added.

## Changelog

[General] [Added] - Support TypeScript array types for turbo module (component only)

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

Test Plan: `yarn jest` passed in `packages/react-native-codegen`

Reviewed By: sammy-SC

Differential Revision: D37953004

Pulled By: cipolleschi

fbshipit-source-id: b71ea35eb9c4bd5dc41130f1dcf9201704ec298e
2022-09-14 15:28:33 +01:00
Zihan Chen (MSFT)andDmitry Rykun 53da91c4e1 Accept TypeScript type T | null | undefined as a maybe type of T in turbo module (#34158)
Summary:
According Flow's document, a maybe type of T means `T | null | undefined`, instead of `T | null | void`.
I think keeping TypeScript and Flow being consistent to each other is better.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Changed] - Accept TypeScript type `T | null | undefined` as a maybe type of T in turbo module.

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

Test Plan: `yarn jest` passed in `packages/react-native-codegen`

Reviewed By: yungsters

Differential Revision: D37731169

Pulled By: philIip

fbshipit-source-id: b6d9b7e8991f60e12c1004bed5b937b34fb02c47
2022-09-14 15:28:25 +01:00
Dmitry Rykun 5132211228 Hermes version bump for 0.70.1 2022-09-14 15:15:11 +01:00
Distiller 7fc33cc15a [0.70.0] Bump version numbers 2022-09-05 14:51:43 +00:00
Distiller e044a71f7f [0.70.0-rc.4] Bump version numbers 2022-08-22 14:44:42 +00:00
Lorenzo Sciandra a168c55ba0 [LOCAL] follow up to codegen update 2022-08-22 11:46:53 +01:00
Dmitry Rykun a22ceecc84 Bump react-native-codegen to 0.70.4 2022-08-22 11:27:47 +01:00
Lorenzo Sciandra 05dcebc211 [LOCAL] follow up to metro bump 2022-08-22 10:53:36 +01:00
Michał PierzchałaandLorenzo Sciandra 97782c247b Upgrade RN CLI to v9.0.0 and Metro to 0.72.1 (#34447)
Summary:
Stable v9 of the CLI, no major changes compared to previous alpha releases.

Metro release notes: https://github.com/facebook/metro/releases/tag/v0.72.1

cc kelset huntie

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[General] [Changed] - Upgrade RN CLI to v9.0.0, Metro to 0.72.1

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

Test Plan: CI

Reviewed By: huntie

Differential Revision: D38838499

Pulled By: robhogan

fbshipit-source-id: 552e2e708270557e2b74c1a3b8d3325774fb0c48

# Conflicts:
#	template/package.json
2022-08-22 10:52:24 +01:00
Tommy NguyenandLorenzo Sciandra 7a014449d6 Fix codegen trying to parse .d.ts files (#34439)
Summary:
With react-native 0.70-rc.3 and new arch, codegen may fail if it encounters `.d.ts` files because specs may appear to be unused.

## Changelog

[General] [Fixed] - Codegen should ignore `.d.ts` files

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

Test Plan:
See repro in https://github.com/microsoft/react-native-test-app/pull/1052. The build will fail without manually patching this in.

If you prefer to use your own test app, try adding [react-native-safe-area-context](https://github.com/th3rdwave/react-native-safe-area-context) as a dependency.

Reviewed By: cipolleschi

Differential Revision: D38826388

Pulled By: cortinico

fbshipit-source-id: eb7c9be2d49286bae86b2428862fbf20f6f32ca5
2022-08-22 10:47:05 +01:00
LeoTMandLorenzo Sciandra b640f06e4b Update template to gitignore android/app/.cxx (#34430)
Summary:
CMake gens running debug
- `android/app/.cxx/Debug/*`
- `android/app/.cxx/RelWithDebInfo/*`

Neither/nothing during release.

So probably want the 87 debug files untracked.

Follow-up: https://github.com/facebook/react-native/pull/34354

_macOS 13b, RN 0.70.0-rc.3_

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Added] - Update template to gitignore `android/app/.cxx`

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

Test Plan: Everything builds and runs as expected

Reviewed By: cipolleschi

Differential Revision: D38752097

Pulled By: cortinico

fbshipit-source-id: 61c31317d5e45f831445841f3e14da871b3903e5
2022-08-22 10:46:57 +01:00
Nicola CortiandLorenzo Sciandra 5367459233 Make sure the template project name is helloworld_appmodules (#34417)
Summary:
Make sure the new app template uses the correct project CMake project name: `helloworld_appmodules`, otherwise the app will fail to load the dynamic library.

This was a copy-n-paste error from RNTester.

## Changelog

[Internal] - Make sure the template project name is `helloworld_appmodules`

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

Test Plan: Will test an app created with the New App template

Reviewed By: cipolleschi

Differential Revision: D38698682

Pulled By: cortinico

fbshipit-source-id: b09331a52989b3b131ea8ba627057febcb535ef8
2022-08-22 10:46:48 +01:00
Dmitry Rykun 0b4b7774e2 Hermes version bump for 0.70.0-RC4 2022-08-16 14:08:53 +01:00
Distiller 1aabd099b1 [0.70.0-rc.3] Bump version numbers 2022-08-15 14:15:34 +00:00
Dmitry RykunandGitHub 1518f838b7 Upgrade react-native-gradle-plugin to 0.70.2 (#34390) 2022-08-12 09:16:53 +01:00
Lorenzo Sciandra 6d3b8a2ce8 chore(deps): bump CLI to latest v9 alpha (#34385)
Summary:
Bump CLI to latest v9 alpha so that I can then chery-pick in 0.70-stable branch for next RC

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[General] [Changed] -  bump CLI to latest v9-alpha11

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

Test Plan: N/A

Reviewed By: robhogan

Differential Revision: D38615615

Pulled By: dmitryrykun

fbshipit-source-id: ea5dd7b93f4ed3bb82347fd730b8e65e8a89a6ca

# Conflicts:
#	yarn.lock
2022-08-11 16:10:21 +01:00
Riccardo CipolleschiandLorenzo Sciandra c666fda92c Silence deprecation warning for react-native dependency. (#34368)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34368

When a user runs `RCT_NEW_ARCH_ENABLED=1 pod install` to install the dependencies for the New Architecture, Cocoapods prints a warning because of React Native is still set up with a legacy configuration.

This diff silences these warnings because they can confuse the final user.

**Note:** We need to keep this legacy configuration to support both the legacy and the New Architecture.

## Changelog

[iOS][Changed] - Silence warning due to react-native internal details.

Reviewed By: cortinico

Differential Revision: D38503405

fbshipit-source-id: b89857aa88435b1c64da52875606003239ff2e05
2022-08-11 16:09:57 +01:00
Nicola CortiandLorenzo Sciandra 04990df7a6 Update the new app template to use CMake instead of Android.mk (#34354)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34354

This change simplifies the setup for New Architecture for users on Android.
Instead of using the Android.mk file, users can now use a CMake file which
encapsulate a lot of the complexities and reduces the maintainance cost.

Android.mk support is kept for backward compatibility.

Changelog:
[Android] [Changed] - Update the new app template to use CMake instead of Android.mk

Reviewed By: cipolleschi

Differential Revision: D38460536

fbshipit-source-id: 9d4c3b15be751921d34023b24c174044537e6f02
2022-08-11 16:09:50 +01:00
Muhammad Hur AliandLorenzo Sciandra 33ddb001d8 fix: react android kotlin plugin version conflict (#34255)
Summary:
Fixes https://github.com/facebook/react-native/issues/34229

Basically, the react android conflicts with the kotlin version that's defined in the top level build.gradle. To resolve it, the approach was to get the `kotlinVersion` defined in top level build.gradle and use it. If it's not defined, we use the default(1.6.10 as of now).

The reason behind not using the DSL is that it doesn't allow us to use the variables due to it's constrained syntax.
See [here](https://docs.gradle.org/current/userguide/plugins.html#sec:constrained_syntax)

So the idea was to use the build script to resolve the kotlin plugin and it works 👍 .

Kindly asking for review cortinico :)

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Changed] - refactored usage of kotlin plugin

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

Test Plan: Ran the node ./scripts/run-ci-e2e-tests.js --js --android --ios to verify it doesn't introduce any unexpected issues.

Reviewed By: dmitryrykun

Differential Revision: D38468567

Pulled By: cortinico

fbshipit-source-id: f9ab635fcf033f1d337ed90793ba1667957b8e01
2022-08-11 16:09:43 +01:00
Alexander EggersandLorenzo Sciandra 6a87015a10 Bump Gradle to 7.5.1 (#34359)
Summary:
https://github.com/facebook/react-native/pull/34310 introduced Gradle 7.5.0, but I noticed that the Gradle team actually missed to remove the `Incubating` annotation for the Java 18 support. The latest 7.5.1 is fixing that. More details can be found here: https://github.com/gradle/gradle/releases/tag/v7.5.1

## Changelog

[Android] [Changed] - Bump Gradle to 7.5.1

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

Test Plan: Successfully build on a local project. I can share the actual branch if needed.

Reviewed By: cipolleschi

Differential Revision: D38497804

Pulled By: cortinico

fbshipit-source-id: 792b83707d5b6aaf7ef29531f82a1bc9224b3204
2022-08-11 16:09:34 +01:00
Christoph PurrerandLorenzo Sciandra 9424d2c85c Avoid full copy of large folly::dynamic objects in JSIExecutor#defaultTimeoutInvoker [RFC]
Summary:
Current creation of the errorProcessor lambda does a full copy of folly::dynamic object, which for large objects can cause 1000's of memory allocations, and thus increasing app's memory footprint and speed.

Changelog:
[General][Fixed] - Avoid full copy of large folly::dynamic objects in JSIExecutor#defaultTimeoutInvoker

Reviewed By: sammy-SC

Differential Revision: D38368392

fbshipit-source-id: 88579a7069891828cf6dae130c4964db6b494565
2022-08-11 16:09:27 +01:00
JoseLionandLorenzo Sciandra a0ae1fb525 fix(android): Append .exe to hermesc binary path for Windows users (#34151)
Summary:
Resolves https://github.com/facebook/react-native/issues/34116.

In a nutshell, the problem was a missing `.exe` extension on the `hermesc` binary path when running on Windows OS. The missing extension causes the method `.exists()` of the File instance to always return false, so none of the conditions ever met and an error was thrown whenever a release build with Hermes enabled was run on Windows. More details can be found in the comments on the above issues.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Fixed] - Fix error of release builds with Hermes enabled for Windows users

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

Test Plan:
### Reproduce

Changes on Gradle scrips are better tested on an actual application. To reproduce the issue you can:
1. Create or reuse a React Native application with version `v0.69.1` on a Windows machine
2. Enable Hermes on Android following the steps on the [documentation](https://reactnative.dev/docs/hermes#enabling-hermes)
3. Clean the build folder: `cd android && ./gradlew clean`
4. Bundle the JS and assets for a release version: `./gradlew bundleReleaseJsAndAssets`
5. The build fails with the following error:
```shell
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> java.lang.Exception: Couldn't determine Hermesc location. Please set `project.ext.react.hermesCommand` to the path of the hermesc binary file. node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc
```

### Test the changes

Follow the same steps above using the fix on this PR and the error should disappear 🙂

Reviewed By: NickGerleman

Differential Revision: D37755468

Pulled By: cortinico

fbshipit-source-id: 2ad0ced583555b907259df116f64a45da6d153f3
2022-08-11 16:09:19 +01:00
Distiller d077bdf253 [0.70.0-rc.2] Bump version numbers 2022-08-04 15:18:45 +00:00
Sparsha SahaandLorenzo Sciandra 120b988229 Removing reactnativeutilsjni as it is built from the same sources as reactnativejni (#34339)
Summary:
This Pull Request aims at removing the making of reactnativeutilsjni as it is built from the same sources as reactnativejni. It also replaces references to reactnativeutilsjni with reactnativejni.

This should get rid of `reactnativeutilsjni.so` while reusing `reactnativejni.so` in it's place. This should give us some size improvements in the finally built apk.
## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Changed] - Replaced reactnativeutilsjni with reactnativejni in the build process to reduce size

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

Test Plan:
1. Ran the CMakelist.txt file using CMake and I could see that reactnativeutilsjni.dir is no longer generated with my changes.
2. Built the aar from this branch in Android Studio and build happened successfully.

I am not sure if we could run any more tests. Please let me know in case anymore testing is required and I can do accordingly

Reviewed By: cortinico

Differential Revision: D38400481

Pulled By: genkikondo

fbshipit-source-id: 592736e56441328389ae89135667c336ff8018e6
2022-08-04 11:55:12 +01:00
Oskar KwaśniewskiandLorenzo Sciandra 6450bc6166 Fix accessibilityState overwriting view's disabled state on Android (#34287)
Summary:
While I was working on rewriting `react-native-slider` to Fabric I found a weird bug that prevented the slider to be set as disabled (to be exact: call the method `slider.setEnabled(false)`. As it turned out the `accessibilityState` (with value: `accessibilityState={{disabled: true}}` prop occurred after the `enabled={false}` prop that I was passing to the slider, which lead to both of this props overwrite each other.

Handling of `accessibilityState` props inside view leads to always overwriting the enabled prop to true (even if we explicitly set it to `{disabled: false}`.

Workaround for this was to reorder the props, so that the `accesibilityState` occur before `disabled`, but I think it's better to not set `view.setEnabled(true)` if we are passing a disabled property.

## Changelog

[Android] [Fixed] - Fix accessibilityState overwriting view's disabled state on Android

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

Test Plan:
Change order of props inside native component implementation (that `disabled` occurs before `accesibilityState`). For example: `Libraries/Components/Slider/Slider.js`

<details>
  <summary>Video showing the bug in RNTester (using Switch component)</summary>

https://user-images.githubusercontent.com/52801365/181287547-964f50e2-55dc-450f-b413-0d1c14d4bb83.mp4
</details>

Reviewed By: NickGerleman

Differential Revision: D38209232

Pulled By: dmitryrykun

fbshipit-source-id: 93d423716f89b45251be9d5aefcf01f7bd776f2c
2022-08-04 11:55:03 +01:00
LeoTMandLorenzo Sciandra 23cc0568a0 Bump Gradle to 7.5.0 (#34310)
Summary:
### Follow-up
- https://github.com/facebook/react-native/issues/34103
- https://github.com/facebook/react-native/pull/33823

#### Debug/Release further tested on RN 0.70.0-rc.0-1
- https://github.com/leotm/react-native-template-new-architecture/pull/775
- builds/runtime: locally on `macos-13` b2
- builds: in CI `ubuntu-20.04` latest (not yet beta `ubuntu-22.04`)

cc cortinico dulmandakh

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Android] [Changed] - Bump Gradle to 7.5.0

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

Test Plan: Everything builds and runs as expected.

Reviewed By: cipolleschi

Differential Revision: D38311861

Pulled By: cortinico

fbshipit-source-id: c4e9e7a9052a067ffabae87204d20190ef46b351
2022-08-03 10:23:05 +01:00
Dmitry RykunandGitHub 2176173dcc Upgrade react-native-gradle-plugin to 0.70.1 (#34330) 2022-08-02 14:27:22 +01:00
Lorenzo Sciandra 7c7ba1babd [LOCAL] update a few metro deps as follow up from the commit from main 2022-08-02 12:42:02 +01:00
Michał PierzchałaandLorenzo Sciandra c3e3a19c9e chore: upgrade RN CLI to v9.0.0-alpha.9 (#34322)
Summary:
Upgrades the React Native CLI to v9.0.0-alpha.9 with Metro 0.72 and package size improvements

cc kelset cortinico huntie

## Changelog

[General] [Changed] - Upgrade RN CLI to v9.0.0-alpha.9

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

Test Plan: CI

Reviewed By: huntie

Differential Revision: D38318313

Pulled By: robhogan

fbshipit-source-id: 1a038ba90ae648307c9acb7c0c631511d344689e
2022-08-02 12:31:03 +01:00
Nicola CortiandLorenzo Sciandra ba69e7dab2 Introduce findPackageJsonFile to address issue with GenerateCodegenArtifactsTaskTest (#34321)
Summary:
While doing some testing with cipolleschi on React Native 0.70.0 we realized that custom Java Package is not properly propagated when invoking codegen for external libraries.

This PR fixes it.

## Changelog

[Internal] - Introduce findPackageJsonFile to address issue with GenerateCodegenArtifactsTaskTest

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

Test Plan: Added JUnit tests + Tested locally with cipolleschi

Reviewed By: cipolleschi

Differential Revision: D38314770

Pulled By: cortinico

fbshipit-source-id: ec2de1ba59ffc8fb0644f422521ced642b38d2c7
2022-08-02 12:30:55 +01:00
Nicola CortiandLorenzo Sciandra 91fdd998d3 Improve package.json search mechanism for codegenConfig support (#34298)
Summary:
The `codegenConfig` unified configuration for New Architecture on Android relies on the Gradle plugin finding the package.json correctly. Currently we use the `root` folder to resolve the package.json. This works fine when invoking the codegen for the app module, but it doesn't work well when invoking the codegen for modules.

This extends the algo to make sure we first, look for a `package.json` in `..` and fallback to the one in the root if not found.

## Changelog

[Internal] - Improve package.json search mechanism for codegenConfig support

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

Test Plan: It's hard to write a unit test for this as it's inside a lambda, I'll look into doing this though. I've tested this on RNNewArchitectureApp and it works fine.

Reviewed By: cipolleschi

Differential Revision: D38249663

Pulled By: cortinico

fbshipit-source-id: 3cfd6a31e9f75d7b19b15f77bbd5131af42be9d3
2022-08-02 12:30:46 +01:00
Alex HuntandLorenzo Sciandra 64788cc9fe Upgrade Metro dependencies to 0.72.0
Summary:
Metro release notes:  https://github.com/facebook/metro/releases/tag/v0.72.0

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D38245699

fbshipit-source-id: d14cfda8c694f11ffacfb959cf81aa8906923648
2022-08-02 12:30:33 +01:00
Nicola CortiandLorenzo Sciandra 0fd776d889 Make sure *.ts files are considered for task avoidance in the Gradle Plugin (#34296)
Summary:
I've realized that the gradle plugin is currently looking at `.js` files for task re-execution. This means that, while the *.ts would still be considered when the codegen is invoked, an edit on one of those file, won't retrigger the codegen on Android.

This change fixes it so that we consider both `*.ts` and `*.js` files.

## Changelog

[Android] [Fixed] - Make sure *.ts files are considered for task avoidance in the Gradle Plugin

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

Test Plan: Tests are attached.

Reviewed By: cipolleschi

Differential Revision: D38246125

Pulled By: cortinico

fbshipit-source-id: 80efcc9ef747c598ca040d65b25d270593c8aed2
2022-08-02 12:29:39 +01:00
Nicola CortiandLorenzo Sciandra 1c146bd420 Fix test-manual-e2e on Android/Hermes for New App Template (#34294)
Summary:
The current `test-manual-e2e.sh` script is broken on Android + Hermes + New App Template.

This commit fixes it. Specifically:
- There is no need to generate Maven Artifacts for RN Tester, as RN Tester consumes them from source.
- There is instead a need to generate Maven Artifacts for New App Template, as they need to be included inside the NPM package.
- The `:ReactAndroid:hermes-engine:installArchives` task needs to invoked to also generate the Hermes-engine .aar for bundling.

## Changelog

[Internal] - Fix test-manual-e2e on Android/Hermes for New App Template

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

Test Plan: I've tested this against the `0.70-stable` branch and I was able to run an App from the New Template properly.

Reviewed By: dmitryrykun

Differential Revision: D38239238

Pulled By: cortinico

fbshipit-source-id: b3d95bad21515b12a91e29147e70ba8323896660
2022-08-02 12:29:30 +01:00
Distiller a8bb3d3f20 [0.70.0-rc.1] Bump version numbers 2022-07-28 13:01:01 +00:00
Kudo ChienandLorenzo Sciandra 5fc88e95b5 #34214 for main (#34271)
Summary:
cherry-pick changes from https://github.com/facebook/react-native/issues/34214 to main. because the `react_native_pods.rb` on main is quite different from 0.69, i have separated pr for the change.

## Changelog

[iOS] [Fixed] - Fix React-bridging headers import not found

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

Test Plan: RNTester + pod install and verify pod targets to have `React-bridging` in header search paths.

Reviewed By: cipolleschi

Differential Revision: D38122074

Pulled By: dmitryrykun

fbshipit-source-id: 64569abbfa3a684f0d6b84c9e3222bfc9a171061
2022-07-27 16:34:42 +01:00
Kudo ChienandLorenzo Sciandra 70daa6e728 Fix hermes executor not available when use_frameworks is enabled (#34222)
Summary:
When in `use_frameworks!` + `hermes_enabled` mode, the React podspecs have not dependency to the `React-hermes` podspec. the `HermesExecutorFactory.h` is not available [here](https://github.com/facebook/react-native/blob/1d997ce6d67242b9f667b01365c5e719c3d3f8d7/React/AppSetup/RCTAppSetupUtils.h#L15) and [here](https://github.com/facebook/react-native/blob/1d997ce6d67242b9f667b01365c5e719c3d3f8d7/React/CxxBridge/RCTCxxBridge.mm#L44). The app will fallback to JSCRuntime and crash in release build because the JSCRuntime cannot evaluate Hermes bundles.

The pr tries to add `React-hermes` to Framework Search Paths and make the `HermesExecutorFactory.h` reachable when in use_frameworks mode.

This pr should fix the problem mentioned in [0.70 release discussion](https://github.com/reactwg/react-native-releases/discussions/26#discussioncomment-3166350).

## Changelog

[iOS] [Fixed] - Fix Hermes executor not available when `use_frameworks` is enabled

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

Test Plan:
use patch-package to apply the change to a RN 0.69.1 project with the following test cases:

- old architecture + jsc
- new architecture + hermes
- old architecture + `use_frameworks! :linkage => :static` + hermes
- old architecture +`use_frameworks! :linkage => :static` + hermes + release build

Reviewed By: sammy-SC

Differential Revision: D38112717

Pulled By: cipolleschi

fbshipit-source-id: ee78527f4686400856ab9a055cf30b20900afc17
2022-07-27 16:34:32 +01:00
Lorenzo Sciandra e7461eea11 bump CLI to v9.0.0-alpha.5 (#34275)
Summary:
Bumping main to latest version of CLI available; in particular, we want to ensure to propagate this fix https://github.com/react-native-community/cli/pull/1655.

After merging, we'll cherry-pick in the `0.70-stable` branch.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[General] [Changed] - bump CLI to v9.0.0-alpha.5

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

Test Plan: CI

Reviewed By: NickGerleman

Differential Revision: D38151383

Pulled By: dmitryrykun

fbshipit-source-id: afdafb496a159ad766dd322a4aab4bda6146edf0

# Conflicts:
#	yarn.lock
2022-07-27 16:34:18 +01:00
LeoTMandLorenzo Sciandra bf34be1eca Update Podfile for PRODUCTION=1 pod install (#34234)
Summary:
### Mentioned
- pr[main]: https://github.com/facebook/react-native/pull/33882
- discussion: https://github.com/reactwg/react-native-releases/discussions/21#discussioncomment-2945972
- pr[0.69-stable]: https://github.com/facebook/react-native/pull/34098

Close: https://github.com/facebook/react-native/issues/33764

Saw the issue ago couple wks too: https://github.com/leotm/react-native-template-new-architecture/issues/757
Fixed similarly: https://github.com/leotm/react-native-template-new-architecture/pull/791

## Changelog

[iOS] [Changed] - Update Podfile to allow `PRODUCTION=1 pod install`

[CATEGORY] [TYPE] - Message

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

Test Plan: Everything builds and runs as expected

Reviewed By: cortinico

Differential Revision: D38029117

Pulled By: cipolleschi

fbshipit-source-id: bdb58200a999cb66f1043a2feb670f9037c8e463
2022-07-27 16:32:46 +01:00
Riccardo CipolleschiandLorenzo Sciandra b8b3f2f4e8 Destructure use_react_native! parameters and doc (#34177)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34177

This Diff destructures the parameters of the use_react_native! function. It does that in a backward compatible way, so we there should be no disruptions.

It also adds documentation to the various public method we want to export to our users.

## Changelog
[iOS][Changed] - Destruct use_reactnative parameters and ad ddocumentation

Reviewed By: cortinico

Differential Revision: D37787365

fbshipit-source-id: 27f9030db2e8c6c66b9548b4c1287eb8165ae5fc
2022-07-27 16:32:38 +01:00
Riccardo CipolleschiandLorenzo Sciandra 1ab3f58f43 Extract Codegen code from the react_native_pods to its own file (#34176)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34176

It extracts the code related to the codegen from the main `react_native_pods` script to a dedicated file, adding also tests.

## Changelog

[iOS][Changed] - Move codegen in separate files

Reviewed By: cortinico

Differential Revision: D37755818

fbshipit-source-id: 99760d1def26ddbf065fdd234e0d183c2795513c
2022-07-27 16:32:31 +01:00
Nicola CortiandLorenzo Sciandra d9280e14c3 Fix missing import on New Architecture build script in template (#34230)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34230

The OS static class is accessed inside app/build.gradle but the import is on
the top level Gradle file. This is causing an app created from template to fail
building.

This is needed to be cherry-picked on the 0.70-stable branch.

Changelog:
[Android] [Fixed] - Fix missing import on New Architecture build script in template

Reviewed By: cipolleschi

Differential Revision: D37995897

fbshipit-source-id: aad22100cee004944c4fa0841f5ef0dfc6ea1e94
2022-07-27 16:31:13 +01:00
Mike HardyandLorenzo Sciandra fc06d9c6dd deps(android): bump soloader to 0.10.4 (#34213)
Summary:
soloader 0.10.3 will apparently cause crashes in instrumented tests, 0.10.4 appears to fix these crashes

Related: https://github.com/facebook/SoLoader/issues/94
Related: https://github.com/reactwg/react-native-releases/discussions/26#discussioncomment-3166381

## Changelog

[Android] [Changed] - Bump Soloader to 0.10.4

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

Test Plan: This is hard to test since it's in the AAR etc., I'm hoping CI is sufficient as the previous soloader bump PR went through similarly

Reviewed By: cipolleschi

Differential Revision: D37960320

Pulled By: cortinico

fbshipit-source-id: ce1611d7b30df737c8525a70839b5491a6585c75
2022-07-27 16:31:04 +01:00
Dmitry Rykun d07fae9b23 Update @react-native/eslint-plugin-specs to 0.70.0 2022-07-26 17:13:29 +01:00
Dmitry Rykun afd76f69c7 Bump @react-native/eslint-plugin-specs to 0.70.0 2022-07-26 17:02:45 +01:00
Lorenzo SciandraandDmitry Rykun c40d270fdc fix npm lifecycle hook (#34273)
Summary:
In `0.70-stable` we started seeing `yarn run lint` fail; turns out, this is happening because the latest release of `react-native/eslint-plugin-specs` 0.0.4 (from https://github.com/facebook/react-native/commit/ea8d8e2f49ea3ce15faeab500b661a1cacacf8a8) is faulty: the underlying reason is that since 0.0.2 there was this local workaround in place https://github.com/facebook/react-native/commit/2d06e6a4c9261bb7790cf217b66145415301bc54 (that changes a flag from false to true) but in NPM 8 the lifecycle hook `prepublish` has [been deprecated](https://docs.npmjs.com/cli/v8/using-npm/scripts#life-cycle-scripts) so this pre publishing script to change the flag was not run (you can easily verify by checking the node_module and see `react-native-modules.js` the flag on L17 is set to false).

This PR addresses it by moving to the new lifecycle hook `prepack` (and modifies the other files accordingly).

After this PR is merged, we'll need to cherry pick it into 0.70 and do both a new release from the 0.70 branch and one from the main branch to have new versions of this module with the flag set correctly.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[General] [Fixed] - Fix eslint-plugin-specs prepack npm lifecycle hook now that we use npm 8

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

Test Plan: Go in the `eslint-plugin-specs` folder, run `npm pack`, unzip the generated tar file, go into `package`, verify that L17 of `react-native-modules.js` is correctly changed to `const PACKAGE_USAGE = true;` (instead of false - which is what happen without this fix).

Reviewed By: GijsWeterings

Differential Revision: D38151433

Pulled By: dmitryrykun

fbshipit-source-id: 7c4f13dae70eb731d57cbafa90f7be05c9bb8576
2022-07-26 16:57:24 +01:00
Nicola Corti eb6767813a Hermes version bump for 0.70.0-RC1 2022-07-20 10:55:08 +01:00
Lorenzo Sciandra ccde88f4b0 Hermes pod: change logic to use the hermes tag to set the pod source correctly (#34221)
Summary:
This fix is necessarly to ensure that when working on the codebase in the `0.XX-stable` branches (ex. when you are working on a release) the Hermes podfile is correctly set against the right commit for that branch, and not latest commit from main branch of Hermes repo.

I didn't add a check to verify that the file `.hermesversion` exists because I think it's safe to assume that the file and the tag correctly exists when this step (doing a pod install on the `0.XX-stable` branch).

Once this is merged, we need to cherry pick it on both the 0.69 and 0.70 branches

## Changelog

[iOS] [Fixed] - Hermes pod: change logic to use the hermes tag to set the pod source correctly

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

Test Plan:
* git clone the repo
* checkout 0.69-stable branch
* follow https://reactnative.dev/contributing/release-testing
* without this commit, when testing RNTester + iOS + Hermes the app will insta-crash on opening
* with it, the app gets build successfully

Reviewed By: cortinico

Differential Revision: D37957660

Pulled By: cipolleschi

fbshipit-source-id: 4e50099ed712b1ad8e6439822e3f530142982c1b
2022-07-19 15:37:55 +01:00
Distiller c0127265a1 [0.70.0-rc.0] Bump version numbers 2022-07-15 13:55:58 +00:00
Dmitry Rykun 8c682ddd59 Hermes version bump. 2022-07-15 13:45:19 +01:00
161 changed files with 6567 additions and 2276 deletions
+44 -12
View File
@@ -37,7 +37,7 @@ references:
# The Xcode version used on CircleCI OSS tests must be kept in sync with
# the Xcode version used on Sandcastle OSS tests. See _XCODE_VERSION in
# tools/utd/migrated_nbtd_jobs/react_native_oss.td
xcode_version: &xcode_version "13.3.1"
xcode_version: &xcode_version "14.0.1"
nodelts_image: &nodelts_image "cimg/node:16.14"
nodeprevlts_image: &nodeprevlts_image "cimg/node:14.19"
@@ -48,13 +48,17 @@ references:
cache_keys:
buck_cache_key: &buck_cache_key v3-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }}}
checkout_cache_key: &checkout_cache_key v1-checkout
checkout_cache_key: &checkout_cache_key v2-checkout
gems_cache_key: &gems_cache_key v1-gems-{{ checksum "Gemfile.lock" }}
gradle_cache_key: &gradle_cache_key v1-gradle-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "ReactAndroid/gradle.properties" }}
hermes_workspace_cache_key: &hermes_workspace_cache_key v4-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
hermes_workspace_debug_cache_key: &hermes_workspace_debug_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_workspace_release_cache_key: &hermes_workspace_release_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_linux_cache_key: &hermes_linux_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-linux-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_windows_cache_key: &hermes_windows_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-windows-{{ checksum "/Users/circleci/project/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
hermes_cache_key: &hermes_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
hermes_sdk_cache_key: &hermes_sdk_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "sdks/.hermes-cache-key-file" }}
hermes_windows_cache_key: &hermes_windows_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "tmp/hermes/hermesversion" }}
pods_cache_key: &pods_cache_key v6-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }}
pods_cache_key: &pods_cache_key v8-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }}
windows_yarn_cache_key: &windows_yarn_cache_key v1-win-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }}
yarn_cache_key: &yarn_cache_key v5-yarn-cache-{{ .Environment.CIRCLE_JOB }}
@@ -281,6 +285,30 @@ commands:
name: Report size of RNTester.app (analysis-bot)
command: GITHUB_TOKEN="$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A""$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B" scripts/circleci/report-bundle-size.sh << parameters.platform >> || true
get_react_native_version:
steps:
- run:
name: Get React Native version
command: |
VERSION=$(cat package.json | jq -r '.version')
# Save the react native version we are building in a file so we can use that file as part of the cache key.
echo "$VERSION" > /tmp/react-native-version
echo "React Native Version is $(cat /tmp/react-native-version)"
HERMES_VERSION="$(cat /tmp/hermes/hermesversion)"
echo "Hermes commit is $HERMES_VERSION"
get_react_native_version_windows:
steps:
- run:
name: Get React Native version on Windows
command: |
$VERSION=cat packages/react-native/package.json | jq -r '.version'
# Save the react native version we are building in a file so we can use that file as part of the cache key.
echo "$VERSION" > /tmp/react-native-version
echo "React Native Version is $(cat /tmp/react-native-version)"
$HERMES_VERSION=cat C:\Users\circleci\project\tmp\hermes\hermesversion
echo "Hermes commit is $HERMES_VERSION"
with_hermes_sdk_cache_span:
parameters:
steps:
@@ -498,7 +526,7 @@ jobs:
steps:
- run:
name: Generate RNTesterPods Workspace
command: cd packages/rn-tester && bundle exec pod install --verbose
command: cd packages/rn-tester && bundle install && bundle exec pod install --verbose
# -------------------------
# Runs iOS unit tests
@@ -744,7 +772,7 @@ jobs:
name: Install CocoaPods dependencies
command: |
rm -rf packages/rn-tester/Pods
cd packages/rn-tester && bundle exec pod install
cd packages/rn-tester && bundle install && bundle exec pod install
- run:
name: Build RNTester
@@ -917,17 +945,18 @@ jobs:
docker:
- image: debian:bullseye
resource_class: "xlarge"
working_directory: /root
steps:
- checkout_code_with_cache
- run:
name: Install dependencies
command: |
apt update
apt install -y git openssh-client cmake build-essential \
libreadline-dev libicu-dev zip python3
libreadline-dev libicu-dev jq zip python3
- *attach_hermes_workspace
- get_react_native_version
- restore_cache:
key: *hermes_cache_key
key: *hermes_linux_cache_key
- run:
name: Set up workspace
command: |
@@ -946,7 +975,7 @@ jobs:
cp /tmp/hermes/build/bin/hermesc /tmp/hermes/linux64-bin/.
fi
- save_cache:
key: *hermes_cache_key
key: *hermes_linux_cache_key
paths:
- /tmp/hermes/linux64-bin/
- /tmp/hermes/hermes/destroot/
@@ -972,6 +1001,7 @@ jobs:
mkdir -p /tmp/hermes/osx-bin
mkdir -p ~/react-native/sdks/hermes
cp -r $HERMES_WS_DIR/hermes/* ~/react-native/sdks/hermes/.
cp -r ~/react-native/sdks/hermes-engine/utils/. ~/react-native/sdks/hermes/.
- run:
name: Install dependencies
command: |
@@ -1031,7 +1061,9 @@ jobs:
- MSBUILD_DIR: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin'
- CMAKE_DIR: 'C:\Program Files\CMake\bin'
steps:
- checkout_code_with_cache
- *attach_hermes_workspace
- get_react_native_version_windows
- restore_cache:
key: *hermes_windows_cache_key
- run:
@@ -1112,7 +1144,7 @@ jobs:
- run_yarn
- add_ssh_keys:
fingerprints:
- "1c:98:e0:3a:52:79:95:29:12:cd:b4:87:5b:41:e2:bb"
- "1f:c7:61:c4:e2:ff:77:e3:cc:ca:a7:34:c2:79:e3:3c"
- run:
name: "Set new react-native version and commit changes"
command: |
@@ -1215,7 +1247,7 @@ jobs:
command: |
curl -X POST https://api.github.com/repos/react-native-community/rn-diff-purge/dispatches \
-H "Accept: application/vnd.github.v3+json" \
-u "$PAT_USERNAME:$PAT_TOKEN" \
-H "Authorization: Bearer $REACT_NATIVE_BOT_GITHUB_TOKEN" \
-d "{\"event_type\": \"publish\", \"client_payload\": { \"version\": \"${CIRCLE_TAG:1}\" }}"
- run:
name: Install dependencies
+2
View File
@@ -97,6 +97,8 @@ package-lock.json
# Ruby Gems (Bundler)
/vendor
/template/vendor
.ruby-version
/**/.ruby-version
# iOS / CocoaPods
/template/ios/build/
-1
View File
@@ -1 +0,0 @@
2.7.5
+3 -2
View File
@@ -1,6 +1,7 @@
source 'https://rubygems.org'
# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby '2.7.5'
ruby '>= 2.6.10'
gem 'cocoapods', '~> 1.11', '>= 1.11.2'
gem 'cocoapods', '>= 1.11.3'
gem 'activesupport', '>= 6.1.7.3', '< 7.1.0'
+27 -28
View File
@@ -1,30 +1,29 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.5)
CFPropertyList (3.0.6)
rexml
activesupport (6.1.5)
activesupport (7.0.8)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
claide (1.1.0)
cocoapods (1.11.3)
cocoapods (1.13.0)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.11.3)
cocoapods-core (= 1.13.0)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 1.4.0, < 2.0)
cocoapods-downloader (>= 1.6.0, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.4.0, < 2.0)
cocoapods-trunk (>= 1.6.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
@@ -32,10 +31,10 @@ GEM
gh_inspector (~> 1.0)
molinillo (~> 0.8.0)
nap (~> 1.0)
ruby-macho (>= 1.0, < 3.0)
xcodeproj (>= 1.21.0, < 2.0)
cocoapods-core (1.11.3)
activesupport (>= 5.0, < 7)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.23.0, < 2.0)
cocoapods-core (1.13.0)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
concurrent-ruby (~> 1.1)
@@ -45,7 +44,7 @@ GEM
public_suffix (~> 4.0)
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (1.6.1)
cocoapods-downloader (1.6.3)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.1)
@@ -54,47 +53,47 @@ GEM
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.1.10)
concurrent-ruby (1.2.2)
escape (0.0.4)
ethon (0.15.0)
ethon (0.16.0)
ffi (>= 1.15.0)
ffi (1.15.5)
ffi (1.16.3)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (1.10.0)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.6.1)
minitest (5.15.0)
json (2.6.3)
minitest (5.20.0)
molinillo (0.8.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
public_suffix (4.0.6)
rexml (3.2.5)
public_suffix (4.0.7)
rexml (3.2.6)
ruby-macho (2.5.1)
typhoeus (1.4.0)
ethon (>= 0.9.0)
tzinfo (2.0.4)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.21.0)
xcodeproj (1.23.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)
zeitwerk (2.5.4)
PLATFORMS
ruby
DEPENDENCIES
cocoapods (~> 1.11, >= 1.11.2)
activesupport (>= 6.1.7.3, < 7.1.0)
cocoapods (>= 1.11.3)
RUBY VERSION
ruby 2.7.5p203
ruby 2.7.6p219
BUNDLED WITH
2.3.10
2.3.22
+13 -6
View File
@@ -200,18 +200,25 @@ function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
},
});
render() {
render(): React.Node {
// When rendering in Fabric and an AnimatedValue is used, we keep track of
// the initial value of that Value, to avoid additional prop updates when
// this component re-renders
const initialPropsIfFabric = this._isFabric()
? this._initialAnimatedProps
: null;
const animatedProps =
this._propsAnimated.__getValue(this._initialAnimatedProps) || {};
this._propsAnimated.__getValue(initialPropsIfFabric) || {};
if (!this._initialAnimatedProps) {
this._initialAnimatedProps = animatedProps;
}
const {style = {}, ...props} = animatedProps;
const {style: passthruStyle = {}, ...passthruProps} =
this.props.passthroughAnimatedPropExplicitValues || {};
const mergedStyle = {...style, ...passthruStyle};
if (!this._initialAnimatedProps) {
this._initialAnimatedProps = animatedProps;
}
// Force `collapsable` to be false so that native view is not flattened.
// Flattened views cannot be accurately referenced by a native driver.
return (
+1 -3
View File
@@ -46,9 +46,7 @@ class AnimatedProps extends AnimatedNode {
// as they may not be up to date, so we use the initial value to ensure that values of
// native animated nodes do not impact rerenders.
if (value instanceof AnimatedStyle) {
props[key] = value.__getValue(
initialProps ? initialProps.style : null,
);
props[key] = value.__getValue(initialProps?.style);
} else if (!initialProps || !value.__isNative) {
props[key] = value.__getValue();
} else if (initialProps.hasOwnProperty(key)) {
+6
View File
@@ -105,6 +105,12 @@ class Blob {
blobId: this.data.blobId,
offset,
size,
/* Since `blob.slice()` creates a new view onto the same binary
* data as the original blob, we should re-use the same collector
* object so that the underlying resource gets deallocated when
* the last view into the data is released, not the first.
*/
__collector: this.data.__collector,
});
}
@@ -0,0 +1,208 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
*/
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import type {EventSubscription} from '../../vendor/emitter/EventEmitter';
import type {ElementRef} from 'react';
// Events that are only supported on Android.
type AccessibilityEventDefinitionsAndroid = {
accessibilityServiceChanged: [boolean],
};
// Events that are only supported on iOS.
type AccessibilityEventDefinitionsIOS = {
announcementFinished: [{announcement: string, success: boolean}],
boldTextChanged: [boolean],
grayscaleChanged: [boolean],
invertColorsChanged: [boolean],
reduceTransparencyChanged: [boolean],
};
type AccessibilityEventDefinitions = {
...AccessibilityEventDefinitionsAndroid,
...AccessibilityEventDefinitionsIOS,
change: [boolean], // screenReaderChanged
reduceMotionChanged: [boolean],
screenReaderChanged: [boolean],
};
type AccessibilityEventTypes = 'click' | 'focus';
/**
* Sometimes it's useful to know whether or not the device has a screen reader
* that is currently active. The `AccessibilityInfo` API is designed for this
* purpose. You can use it to query the current state of the screen reader as
* well as to register to be notified when the state of the screen reader
* changes.
*
* See https://reactnative.dev/docs/accessibilityinfo
*/
export interface AccessibilityInfo {
/**
* Query whether bold text is currently enabled.
*
* Returns a promise which resolves to a boolean.
* The result is `true` when bold text is enabled and `false` otherwise.
*
* See https://reactnative.dev/docs/accessibilityinfo#isBoldTextEnabled
*/
isBoldTextEnabled: () => Promise<boolean>;
/**
* Query whether grayscale is currently enabled.
*
* Returns a promise which resolves to a boolean.
* The result is `true` when grayscale is enabled and `false` otherwise.
*
* See https://reactnative.dev/docs/accessibilityinfo#isGrayscaleEnabled
*/
isGrayscaleEnabled: () => Promise<boolean>;
/**
* Query whether inverted colors are currently enabled.
*
* Returns a promise which resolves to a boolean.
* The result is `true` when invert color is enabled and `false` otherwise.
*
* See https://reactnative.dev/docs/accessibilityinfo#isInvertColorsEnabled
*/
isInvertColorsEnabled: () => Promise<boolean>;
/**
* Query whether reduced motion is currently enabled.
*
* Returns a promise which resolves to a boolean.
* The result is `true` when a reduce motion is enabled and `false` otherwise.
*
* See https://reactnative.dev/docs/accessibilityinfo#isReduceMotionEnabled
*/
isReduceMotionEnabled: () => Promise<boolean>;
/**
* Query whether reduce motion and prefer cross-fade transitions settings are currently enabled.
*
* Returns a promise which resolves to a boolean.
* The result is `true` when prefer cross-fade transitions is enabled and `false` otherwise.
*
* See https://reactnative.dev/docs/accessibilityinfo#prefersCrossFadeTransitions
*/
prefersCrossFadeTransitions: () => Promise<boolean>;
/**
* Query whether reduced transparency is currently enabled.
*
* Returns a promise which resolves to a boolean.
* The result is `true` when a reduce transparency is enabled and `false` otherwise.
*
* See https://reactnative.dev/docs/accessibilityinfo#isReduceTransparencyEnabled
*/
isReduceTransparencyEnabled: () => Promise<boolean>;
/**
* Query whether a screen reader is currently enabled.
*
* Returns a promise which resolves to a boolean.
* The result is `true` when a screen reader is enabled and `false` otherwise.
*
* See https://reactnative.dev/docs/accessibilityinfo#isScreenReaderEnabled
*/
isScreenReaderEnabled: () => Promise<boolean>;
/**
* Query whether Accessibility Service is currently enabled.
*
* Returns a promise which resolves to a boolean.
* The result is `true` when any service is enabled and `false` otherwise.
*
* @platform android
*
* See https://reactnative.dev/docs/accessibilityinfo/#isaccessibilityserviceenabled-android
*/
isAccessibilityServiceEnabled: () => Promise<boolean>;
/**
* Add an event handler. Supported events:
*
* - `reduceMotionChanged`: Fires when the state of the reduce motion toggle changes.
* The argument to the event handler is a boolean. The boolean is `true` when a reduce
* motion is enabled (or when "Transition Animation Scale" in "Developer options" is
* "Animation off") and `false` otherwise.
* - `screenReaderChanged`: Fires when the state of the screen reader changes. The argument
* to the event handler is a boolean. The boolean is `true` when a screen
* reader is enabled and `false` otherwise.
*
* These events are only supported on iOS:
*
* - `boldTextChanged`: iOS-only event. Fires when the state of the bold text toggle changes.
* The argument to the event handler is a boolean. The boolean is `true` when a bold text
* is enabled and `false` otherwise.
* - `grayscaleChanged`: iOS-only event. Fires when the state of the gray scale toggle changes.
* The argument to the event handler is a boolean. The boolean is `true` when a gray scale
* is enabled and `false` otherwise.
* - `invertColorsChanged`: iOS-only event. Fires when the state of the invert colors toggle
* changes. The argument to the event handler is a boolean. The boolean is `true` when a invert
* colors is enabled and `false` otherwise.
* - `reduceTransparencyChanged`: iOS-only event. Fires when the state of the reduce transparency
* toggle changes. The argument to the event handler is a boolean. The boolean is `true`
* when a reduce transparency is enabled and `false` otherwise.
* - `announcementFinished`: iOS-only event. Fires when the screen reader has
* finished making an announcement. The argument to the event handler is a
* dictionary with these keys:
* - `announcement`: The string announced by the screen reader.
* - `success`: A boolean indicating whether the announcement was
* successfully made.
*
* See https://reactnative.dev/docs/accessibilityinfo#addeventlistener
*/
addEventListener<K: $Keys<AccessibilityEventDefinitions>>(
eventName: K,
handler: (...$ElementType<AccessibilityEventDefinitions, K>) => void,
): EventSubscription;
/**
* Set accessibility focus to a React component.
*
* See https://reactnative.dev/docs/accessibilityinfo#setaccessibilityfocus
*/
setAccessibilityFocus: (reactTag: number) => void;
/**
* Send a named accessibility event to a HostComponent.
*/
sendAccessibilityEvent: (
handle: ElementRef<HostComponent<mixed>>,
eventType: AccessibilityEventTypes,
) => void;
/**
* Post a string to be announced by the screen reader.
*
* See https://reactnative.dev/docs/accessibilityinfo#announceforaccessibility
*/
announceForAccessibility: (announcement: string) => void;
/**
* Post a string to be announced by the screen reader.
* - `announcement`: The string announced by the screen reader.
* - `options`: An object that configures the reading options.
* - `queue`: The announcement will be queued behind existing announcements. iOS only.
*/
announceForAccessibilityWithOptions: (
announcement: string,
options: {queue?: boolean},
) => void;
/**
* Get the recommended timeout for changes to the UI needed by this user.
*
* See https://reactnative.dev/docs/accessibilityinfo#getrecommendedtimeoutmillis
*/
getRecommendedTimeoutMillis: (originalTimeout: number) => Promise<number>;
}
@@ -17,6 +17,7 @@ import NativeAccessibilityInfoAndroid from './NativeAccessibilityInfo';
import NativeAccessibilityManagerIOS from './NativeAccessibilityManager';
import legacySendAccessibilityEvent from './legacySendAccessibilityEvent';
import type {ElementRef} from 'react';
import type {AccessibilityInfo as AccessibilityInfoType} from './AccessibilityInfo.flow';
// Events that are only supported on Android.
type AccessibilityEventDefinitionsAndroid = {
@@ -73,7 +74,7 @@ const EventNames: Map<
*
* See https://reactnative.dev/docs/accessibilityinfo
*/
const AccessibilityInfo = {
const AccessibilityInfo: AccessibilityInfoType = {
/**
* Query whether bold text is currently enabled.
*
@@ -178,6 +179,34 @@ const AccessibilityInfo = {
});
},
/**
* Query whether reduce motion and prefer cross-fade transitions settings are currently enabled.
*
* Returns a promise which resolves to a boolean.
* The result is `true` when prefer cross-fade transitions is enabled and `false` otherwise.
*
* See https://reactnative.dev/docs/accessibilityinfo#prefersCrossFadeTransitions
*/
prefersCrossFadeTransitions(): Promise<boolean> {
return new Promise((resolve, reject) => {
if (Platform.OS === 'android') {
return Promise.resolve(false);
} else {
if (
NativeAccessibilityManagerIOS?.getCurrentPrefersCrossFadeTransitionsState !=
null
) {
NativeAccessibilityManagerIOS.getCurrentPrefersCrossFadeTransitionsState(
resolve,
reject,
);
} else {
reject(null);
}
}
});
},
/**
* Query whether reduced transparency is currently enabled.
*
@@ -295,6 +324,7 @@ const AccessibilityInfo = {
*/
addEventListener<K: $Keys<AccessibilityEventDefinitions>>(
eventName: K,
// $FlowIssue[incompatible-type] - Flow bug with unions and generics (T128099423)
handler: (...$ElementType<AccessibilityEventDefinitions, K>) => void,
): EventSubscription {
const deviceEventName = EventNames.get(eventName);
@@ -315,7 +345,7 @@ const AccessibilityInfo = {
/**
* Send a named accessibility event to a HostComponent.
*/
sendAccessibilityEvent_unstable(
sendAccessibilityEvent(
handle: ElementRef<HostComponent<mixed>>,
eventType: AccessibilityEventTypes,
) {
@@ -28,6 +28,10 @@ export interface Spec extends TurboModule {
onSuccess: (isReduceMotionEnabled: boolean) => void,
onError: (error: Object) => void,
) => void;
+getCurrentPrefersCrossFadeTransitionsState?: (
onSuccess: (prefersCrossFadeTransitions: boolean) => void,
onError: (error: Object) => void,
) => void;
+getCurrentReduceTransparencyState: (
onSuccess: (isReduceTransparencyEnabled: boolean) => void,
onError: (error: Object) => void,
+28 -3
View File
@@ -24,7 +24,7 @@ export type KeyboardEventEasing =
| 'linear'
| 'keyboard';
export type KeyboardEventCoordinates = $ReadOnly<{|
export type KeyboardMetrics = $ReadOnly<{|
screenX: number,
screenY: number,
width: number,
@@ -36,7 +36,7 @@ export type KeyboardEvent = AndroidKeyboardEvent | IOSKeyboardEvent;
type BaseKeyboardEvent = {|
duration: number,
easing: KeyboardEventEasing,
endCoordinates: KeyboardEventCoordinates,
endCoordinates: KeyboardMetrics,
|};
export type AndroidKeyboardEvent = $ReadOnly<{|
@@ -47,7 +47,7 @@ export type AndroidKeyboardEvent = $ReadOnly<{|
export type IOSKeyboardEvent = $ReadOnly<{|
...BaseKeyboardEvent,
startCoordinates: KeyboardEventCoordinates,
startCoordinates: KeyboardMetrics,
isEventFromThisApp: boolean,
|}>;
@@ -103,6 +103,8 @@ type KeyboardEventDefinitions = {
*/
class Keyboard {
_currentlyShowing: ?KeyboardEvent;
_emitter: NativeEventEmitter<KeyboardEventDefinitions> =
new NativeEventEmitter(
// T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior
@@ -110,6 +112,15 @@ class Keyboard {
Platform.OS !== 'ios' ? null : NativeKeyboardObserver,
);
constructor() {
this.addListener('keyboardDidShow', ev => {
this._currentlyShowing = ev;
});
this.addListener('keyboardDidHide', _ev => {
this._currentlyShowing = null;
});
}
/**
* The `addListener` function connects a JavaScript function to an identified native
* keyboard notification event.
@@ -157,6 +168,20 @@ class Keyboard {
dismissKeyboard();
}
/**
* Whether the keyboard is last known to be visible.
*/
isVisible(): boolean {
return !!this._currentlyShowing;
}
/**
* Return the metrics of the soft-keyboard if visible.
*/
metrics(): ?KeyboardMetrics {
return this._currentlyShowing?.endCoordinates;
}
/**
* Useful for syncing TextInput (or other keyboard accessory view) size of
* position changes with keyboard movements.
@@ -22,7 +22,8 @@ import type {
ViewLayout,
ViewLayoutEvent,
} from '../View/ViewPropTypes';
import type {KeyboardEvent, KeyboardEventCoordinates} from './Keyboard';
import type {KeyboardEvent, KeyboardMetrics} from './Keyboard';
import AccessibilityInfo from '../AccessibilityInfo/AccessibilityInfo';
type Props = $ReadOnly<{|
...ViewProps,
@@ -71,12 +72,24 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
this.viewRef = React.createRef();
}
_relativeKeyboardHeight(keyboardFrame: KeyboardEventCoordinates): number {
async _relativeKeyboardHeight(
keyboardFrame: KeyboardMetrics,
): Promise<number> {
const frame = this._frame;
if (!frame || !keyboardFrame) {
return 0;
}
// On iOS when Prefer Cross-Fade Transitions is enabled, the keyboard position
// & height is reported differently (0 instead of Y position value matching height of frame)
if (
Platform.OS === 'ios' &&
keyboardFrame.screenY === 0 &&
(await AccessibilityInfo.prefersCrossFadeTransitions())
) {
return 0;
}
const keyboardY =
keyboardFrame.screenY - (this.props.keyboardVerticalOffset ?? 0);
@@ -90,7 +103,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
this._updateBottomIfNecessary();
};
_onLayout = (event: ViewLayoutEvent) => {
_onLayout = async (event: ViewLayoutEvent) => {
const wasFrameNull = this._frame == null;
this._frame = event.nativeEvent.layout;
if (!this._initialFrameHeight) {
@@ -99,7 +112,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
}
if (wasFrameNull) {
this._updateBottomIfNecessary();
await this._updateBottomIfNecessary();
}
if (this.props.onLayout) {
@@ -107,14 +120,14 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
}
};
_updateBottomIfNecessary = () => {
_updateBottomIfNecessary = async () => {
if (this._keyboardEvent == null) {
this.setState({bottom: 0});
return;
}
const {duration, easing, endCoordinates} = this._keyboardEvent;
const height = this._relativeKeyboardHeight(endCoordinates);
const height = await this._relativeKeyboardHeight(endCoordinates);
if (this.state.bottom === height) {
return;
+12 -16
View File
@@ -42,7 +42,7 @@ import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
import type {ViewProps} from '../View/ViewPropTypes';
import ScrollViewContext, {HORIZONTAL, VERTICAL} from './ScrollViewContext';
import type {Props as ScrollViewStickyHeaderProps} from './ScrollViewStickyHeader';
import type {KeyboardEvent} from '../Keyboard/Keyboard';
import type {KeyboardEvent, KeyboardMetrics} from '../Keyboard/Keyboard';
import type {EventSubscription} from '../../vendor/emitter/EventEmitter';
import Commands from './ScrollViewCommands';
@@ -731,7 +731,7 @@ class ScrollView extends React.Component<Props, State> {
new Map();
_headerLayoutYs: Map<string, number> = new Map();
_keyboardWillOpenTo: ?KeyboardEvent = null;
_keyboardMetrics: ?KeyboardMetrics = null;
_additionalScrollOffset: number = 0;
_isTouching: boolean = false;
_lastMomentumScrollBeginTime: number = 0;
@@ -769,7 +769,7 @@ class ScrollView extends React.Component<Props, State> {
);
}
this._keyboardWillOpenTo = null;
this._keyboardMetrics = Keyboard.metrics();
this._additionalScrollOffset = 0;
this._subscriptionKeyboardWillShow = Keyboard.addListener(
@@ -1075,8 +1075,8 @@ class ScrollView extends React.Component<Props, State> {
let keyboardScreenY = Dimensions.get('window').height;
const scrollTextInputIntoVisibleRect = () => {
if (this._keyboardWillOpenTo != null) {
keyboardScreenY = this._keyboardWillOpenTo.endCoordinates.screenY;
if (this._keyboardMetrics != null) {
keyboardScreenY = this._keyboardMetrics.screenY;
}
let scrollOffsetY =
top - keyboardScreenY + height + this._additionalScrollOffset;
@@ -1094,8 +1094,8 @@ class ScrollView extends React.Component<Props, State> {
this._preventNegativeScrollOffset = false;
};
if (this._keyboardWillOpenTo == null) {
// `_keyboardWillOpenTo` is set inside `scrollResponderKeyboardWillShow` which
if (this._keyboardMetrics == null) {
// `_keyboardMetrics` is set inside `scrollResponderKeyboardWillShow` which
// is not guaranteed to be called before `_inputMeasureAndScrollToKeyboard` but native has already scheduled it.
// In case it was not called before `_inputMeasureAndScrollToKeyboard`, we postpone scrolling to
// text input.
@@ -1243,32 +1243,28 @@ class ScrollView extends React.Component<Props, State> {
scrollResponderKeyboardWillShow: (e: KeyboardEvent) => void = (
e: KeyboardEvent,
) => {
this._keyboardWillOpenTo = e;
this._keyboardMetrics = e.endCoordinates;
this.props.onKeyboardWillShow && this.props.onKeyboardWillShow(e);
};
scrollResponderKeyboardWillHide: (e: KeyboardEvent) => void = (
e: KeyboardEvent,
) => {
this._keyboardWillOpenTo = null;
this._keyboardMetrics = null;
this.props.onKeyboardWillHide && this.props.onKeyboardWillHide(e);
};
scrollResponderKeyboardDidShow: (e: KeyboardEvent) => void = (
e: KeyboardEvent,
) => {
// TODO(7693961): The event for DidShow is not available on iOS yet.
// Use the one from WillShow and do not assign.
if (e) {
this._keyboardWillOpenTo = e;
}
this._keyboardMetrics = e.endCoordinates;
this.props.onKeyboardDidShow && this.props.onKeyboardDidShow(e);
};
scrollResponderKeyboardDidHide: (e: KeyboardEvent) => void = (
e: KeyboardEvent,
) => {
this._keyboardWillOpenTo = null;
this._keyboardMetrics = null;
this.props.onKeyboardDidHide && this.props.onKeyboardDidHide(e);
};
@@ -1547,7 +1543,7 @@ class ScrollView extends React.Component<Props, State> {
// keyboard, except on Android where setting windowSoftInputMode to
// adjustNone leads to missing keyboard events.
const softKeyboardMayBeOpen =
this._keyboardWillOpenTo != null || Platform.OS === 'android';
this._keyboardMetrics != null || Platform.OS === 'android';
return hasFocusedTextInput && softKeyboardMayBeOpen;
};
@@ -976,8 +976,6 @@ function InternalTextInput(props: Props): React.Node {
const text =
typeof props.value === 'string'
? props.value
: typeof lastNativeText === 'string'
? lastNativeText
: typeof props.defaultValue === 'string'
? props.defaultValue
: '';
+4 -4
View File
@@ -1,17 +1,17 @@
/**
* @generated by scripts/set-rn-version.js
*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @generated by scripts/set-rn-version.js
* @flow strict
*/
exports.version = {
major: 0,
minor: 0,
patch: 0,
minor: 70,
patch: 14,
prerelease: null,
};
+4 -1
View File
@@ -39,7 +39,10 @@ if (__DEV__) {
// Get hostname from development server (packager)
const devServer = getDevServer();
const host = devServer.bundleLoadedFromServer
? devServer.url.replace(/https?:\/\//, '').split(':')[0]
? devServer.url
.replace(/https?:\/\//, '')
.replace(/\/$/, '')
.split(':')[0]
: 'localhost';
// Read the optional global variable for backward compatibility.
@@ -74,7 +74,8 @@ const PERMISSIONS = Object.freeze({
ANSWER_PHONE_CALLS: 'android.permission.ANSWER_PHONE_CALLS',
READ_PHONE_NUMBERS: 'android.permission.READ_PHONE_NUMBERS',
UWB_RANGING: 'android.permission.UWB_RANGING',
POST_NOTIFICATION: 'android.permission.POST_NOTIFICATIONS',
POST_NOTIFICATION: 'android.permission.POST_NOTIFICATIONS', // Remove in 0.72
POST_NOTIFICATIONS: 'android.permission.POST_NOTIFICATIONS',
NEARBY_WIFI_DEVICES: 'android.permission.NEARBY_WIFI_DEVICES',
});
@@ -105,7 +106,8 @@ class PermissionsAndroid {
CAMERA: string,
GET_ACCOUNTS: string,
NEARBY_WIFI_DEVICES: string,
POST_NOTIFICATION: string,
POST_NOTIFICATION: string, // Remove in 0.72
POST_NOTIFICATIONS: string,
PROCESS_OUTGOING_CALLS: string,
READ_CALENDAR: string,
READ_CALL_LOG: string,
+1 -1
View File
@@ -146,7 +146,7 @@ module.exports = {
errorMessageForMethod('setLayoutAnimationEnabledExperimental'),
);
},
// Please use AccessibilityInfo.sendAccessibilityEvent_unstable instead.
// Please use AccessibilityInfo.sendAccessibilityEvent instead.
// See SetAccessibilityFocusExample in AccessibilityExample.js for a migration example.
sendAccessibilityEvent: (reactTag: ?number, eventType: number): void =>
console.error(errorMessageForMethod('sendAccessibilityEvent')),
+6 -1
View File
@@ -347,7 +347,12 @@ module.exports = {
return;
}
if (__DEV__ && typeof value.process === 'function') {
if (
__DEV__ &&
typeof value.process === 'function' &&
typeof ReactNativeStyleAttributes[property]?.process === 'function' &&
value.process !== ReactNativeStyleAttributes[property]?.process
) {
console.warn(`Overwriting ${property} style attribute preprocessor`);
}
@@ -0,0 +1,48 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails oncall+react_native
* @format
*/
import {setStyleAttributePreprocessor} from '../StyleSheet';
describe(setStyleAttributePreprocessor, () => {
const originalConsoleWarn = console.warn;
beforeEach(() => {
jest.resetModules();
console.warn = jest.fn();
});
afterEach(() => {
console.warn = originalConsoleWarn;
});
it('should not show warning when set preprocessor first time', () => {
const spyConsole = jest.spyOn(global.console, 'warn');
setStyleAttributePreprocessor(
'fontFamily',
(fontFamily: string) => fontFamily,
);
expect(spyConsole).not.toHaveBeenCalled();
});
it('should show warning when overwrite the preprocessor', () => {
const spyConsole = jest.spyOn(global.console, 'warn');
setStyleAttributePreprocessor(
'fontFamily',
(fontFamily: string) => fontFamily,
);
setStyleAttributePreprocessor(
'fontFamily',
(fontFamily: string) => `Scoped-${fontFamily}`,
);
expect(spyConsole).toHaveBeenCalledWith(
'Overwriting fontFamily style attribute preprocessor',
);
});
});
+7 -1
View File
@@ -47,7 +47,13 @@ Pod::Spec.new do |s|
s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags
s.header_dir = "React"
s.framework = "JavaScriptCore"
s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\" \"${PODS_ROOT}/Headers/Public/FlipperKit\" \"$(PODS_ROOT)/Headers/Public/ReactCommon\" \"$(PODS_ROOT)/Headers/Public/React-RCTFabric\"", "DEFINES_MODULE" => "YES", "GCC_PREPROCESSOR_DEFINITIONS" => "RCT_METRO_PORT=${RCT_METRO_PORT}", "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" }
s.pod_target_xcconfig = {
"HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\" \"${PODS_ROOT}/Headers/Public/FlipperKit\" \"$(PODS_ROOT)/Headers/Public/ReactCommon\" \"$(PODS_ROOT)/Headers/Public/React-RCTFabric\"",
"FRAMEWORK_SEARCH_PATHS" => "\"${PODS_CONFIGURATION_BUILD_DIR}/React-hermes\"",
"DEFINES_MODULE" => "YES",
"GCC_PREPROCESSOR_DEFINITIONS" => "RCT_METRO_PORT=${RCT_METRO_PORT}",
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17",
}
s.user_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Headers/Private/React-Core\""}
s.default_subspec = "Default"
+11 -7
View File
@@ -9,6 +9,8 @@
#import <React/RCTBridge.h>
#import <React/RCTRootView.h>
#ifdef __cplusplus
#if RCT_NEW_ARCH_ENABLED
#ifndef RCT_USE_HERMES
@@ -28,13 +30,6 @@
#import <ReactCommon/RCTTurboModuleManager.h>
#endif
RCT_EXTERN_C_BEGIN
void RCTAppSetupPrepareApp(UIApplication *application);
UIView *RCTAppSetupDefaultRootView(RCTBridge *bridge, NSString *moduleName, NSDictionary *initialProperties);
RCT_EXTERN_C_END
#if RCT_NEW_ARCH_ENABLED
RCT_EXTERN id<RCTTurboModule> RCTAppSetupDefaultModuleFromClass(Class moduleClass);
@@ -42,3 +37,12 @@ std::unique_ptr<facebook::react::JSExecutorFactory> RCTAppSetupDefaultJsExecutor
RCTBridge *bridge,
RCTTurboModuleManager *turboModuleManager);
#endif
#endif // __cplusplus
RCT_EXTERN_C_BEGIN
void RCTAppSetupPrepareApp(UIApplication *application);
UIView *RCTAppSetupDefaultRootView(RCTBridge *bridge, NSString *moduleName, NSDictionary *initialProperties);
RCT_EXTERN_C_END
+11 -1
View File
@@ -312,7 +312,17 @@ static void attemptAsynchronousLoadOfBundleAtURL(
return;
}
RCTSource *source = RCTSourceCreate(scriptURL, data, data.length);
// Prefer `Content-Location` as the canonical source URL, if given, or fall back to scriptURL.
NSURL *sourceURL = scriptURL;
NSString *contentLocationHeader = headers[@"Content-Location"];
if (contentLocationHeader) {
NSURL *contentLocationURL = [NSURL URLWithString:contentLocationHeader relativeToURL:scriptURL];
if (contentLocationURL) {
sourceURL = contentLocationURL;
}
}
RCTSource *source = RCTSourceCreate(sourceURL, data, data.length);
parseHeaders(headers, source);
onComplete(nil, source);
}
+5 -5
View File
@@ -21,11 +21,11 @@ NSDictionary* RCTGetReactNativeVersion(void)
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^(void){
__rnVersion = @{
RCTVersionMajor: @(0),
RCTVersionMinor: @(0),
RCTVersionPatch: @(0),
RCTVersionPrerelease: [NSNull null],
};
RCTVersionMajor: @(0),
RCTVersionMinor: @(70),
RCTVersionPatch: @(14),
RCTVersionPrerelease: [NSNull null],
};
});
return __rnVersion;
}
@@ -23,6 +23,7 @@ extern NSString *const RCTAccessibilityManagerDidUpdateMultiplierNotification; /
@property (nonatomic, assign) BOOL isGrayscaleEnabled;
@property (nonatomic, assign) BOOL isInvertColorsEnabled;
@property (nonatomic, assign) BOOL isReduceMotionEnabled;
@property (nonatomic, assign) BOOL prefersCrossFadeTransitions;
@property (nonatomic, assign) BOOL isReduceTransparencyEnabled;
@property (nonatomic, assign) BOOL isVoiceOverEnabled;
@@ -358,6 +358,17 @@ RCT_EXPORT_METHOD(getCurrentReduceMotionState
onSuccess(@[ @(_isReduceMotionEnabled) ]);
}
RCT_EXPORT_METHOD(getCurrentPrefersCrossFadeTransitionsState
: (RCTResponseSenderBlock)onSuccess onError
: (__unused RCTResponseSenderBlock)onError)
{
if (@available(iOS 14.0, *)) {
onSuccess(@[ @(UIAccessibilityPrefersCrossFadeTransitions()) ]);
} else {
onSuccess(@[ @(false) ]);
}
}
RCT_EXPORT_METHOD(getCurrentReduceTransparencyState
: (RCTResponseSenderBlock)onSuccess onError
: (__unused RCTResponseSenderBlock)onError)
+9 -4
View File
@@ -473,6 +473,7 @@ struct RCTInstanceCallback : public InstanceCallback {
// Load the source asynchronously, then store it for later execution.
dispatch_group_enter(prepareBridge);
__block NSData *sourceCode;
__block NSURL *sourceURL = self.bundleURL;
#if (RCT_DEV | RCT_ENABLE_LOADING_VIEW) && __has_include(<React/RCTDevLoadingViewProtocol.h>)
{
@@ -488,6 +489,9 @@ struct RCTInstanceCallback : public InstanceCallback {
}
sourceCode = source.data;
if (source.url) {
sourceURL = source.url;
}
dispatch_group_leave(prepareBridge);
}
onProgress:^(RCTLoadingProgress *progressData) {
@@ -502,7 +506,7 @@ struct RCTInstanceCallback : public InstanceCallback {
dispatch_group_notify(prepareBridge, dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0), ^{
RCTCxxBridge *strongSelf = weakSelf;
if (sourceCode && strongSelf.loading) {
[strongSelf executeSourceCode:sourceCode sync:NO];
[strongSelf executeSourceCode:sourceCode withSourceURL:sourceURL sync:NO];
}
});
RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
@@ -1048,7 +1052,7 @@ struct RCTInstanceCallback : public InstanceCallback {
[_displayLink registerModuleForFrameUpdates:module withModuleData:moduleData];
}
- (void)executeSourceCode:(NSData *)sourceCode sync:(BOOL)sync
- (void)executeSourceCode:(NSData *)sourceCode withSourceURL:(NSURL *)url sync:(BOOL)sync
{
// This will get called from whatever thread was actually executing JS.
dispatch_block_t completion = ^{
@@ -1073,12 +1077,13 @@ struct RCTInstanceCallback : public InstanceCallback {
};
if (sync) {
[self executeApplicationScriptSync:sourceCode url:self.bundleURL];
[self executeApplicationScriptSync:sourceCode url:url];
completion();
} else {
[self enqueueApplicationScript:sourceCode url:self.bundleURL onComplete:completion];
[self enqueueApplicationScript:sourceCode url:url onComplete:completion];
}
// Use the original request URL here - HMRClient uses this to derive the /hot URL and entry point.
[self.devSettings setupHMRClientWithBundleURL:self.bundleURL];
}
+16 -12
View File
@@ -75,13 +75,15 @@ RCT_EXPORT_MODULE()
modalHostView.onShow(nil);
}
};
if (_presentationBlock) {
_presentationBlock([modalHostView reactViewController], viewController, animated, completionBlock);
} else {
[[modalHostView reactViewController] presentViewController:viewController
animated:animated
completion:completionBlock];
}
dispatch_async(dispatch_get_main_queue(), ^{
if (self->_presentationBlock) {
self->_presentationBlock([modalHostView reactViewController], viewController, animated, completionBlock);
} else {
[[modalHostView reactViewController] presentViewController:viewController
animated:animated
completion:completionBlock];
}
});
}
- (void)dismissModalHostView:(RCTModalHostView *)modalHostView
@@ -93,11 +95,13 @@ RCT_EXPORT_MODULE()
[[self.bridge moduleForClass:[RCTModalManager class]] modalDismissed:modalHostView.identifier];
}
};
if (_dismissalBlock) {
_dismissalBlock([modalHostView reactViewController], viewController, animated, completionBlock);
} else {
[viewController.presentingViewController dismissViewControllerAnimated:animated completion:completionBlock];
}
dispatch_async(dispatch_get_main_queue(), ^{
if (self->_dismissalBlock) {
self->_dismissalBlock([modalHostView reactViewController], viewController, animated, completionBlock);
} else {
[viewController.presentingViewController dismissViewControllerAnimated:animated completion:completionBlock];
}
});
}
- (RCTShadowView *)shadowView
+8 -1
View File
@@ -5,10 +5,15 @@
* LICENSE file in the root directory of this source tree.
*/
buildscript {
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.hasProperty("kotlinVersion") ? rootProject.ext.kotlinVersion : KOTLIN_VERSION}"
}
}
plugins {
id("com.android.library")
id("com.facebook.react")
id("org.jetbrains.kotlin.android") version "1.6.10"
id("maven-publish")
id("de.undercouch.download")
}
@@ -483,3 +488,5 @@ afterEvaluate {
}
}
}
apply plugin: "org.jetbrains.kotlin.android"
@@ -18,14 +18,19 @@ set(CMAKE_VERBOSE_MAKEFILE on)
include(${REACT_ANDROID_DIR}/cmake-utils/Android-prebuilt.cmake)
file(GLOB input_SRC CONFIGURE_DEPENDS
set(BUILD_DIR ${PROJECT_BUILD_DIR})
if(CMAKE_HOST_WIN32)
string(REPLACE "\\" "/" BUILD_DIR ${BUILD_DIR})
endif()
file(GLOB input_SRC CONFIGURE_DEPENDS
*.cpp
${PROJECT_BUILD_DIR}/generated/rncli/src/main/jni/*.cpp)
${BUILD_DIR}/generated/rncli/src/main/jni/*.cpp)
add_library(${CMAKE_PROJECT_NAME} SHARED ${input_SRC})
target_include_directories(${CMAKE_PROJECT_NAME}
PUBLIC
target_include_directories(${CMAKE_PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${PROJECT_BUILD_DIR}/generated/rncli/src/main/jni)
+5 -2
View File
@@ -1,4 +1,4 @@
VERSION_NAME=1000.0.0-main
VERSION_NAME=0.70.14
GROUP=com.facebook.react
POM_NAME=ReactNative
@@ -22,7 +22,7 @@ OKHTTP_VERSION=4.9.2
POWERMOCK_VERSION=2.0.2
PROGUARD_ANNOTATIONS_VERSION=1.19.0
ROBOLECTRIC_VERSION=4.4
SO_LOADER_VERSION=0.10.3
SO_LOADER_VERSION=0.10.4
SWIPEREFRESH_LAYOUT_VERSION=1.0.0
# Native Dependency Versions
@@ -33,5 +33,8 @@ FOLLY_VERSION=2021.07.22.00
GLOG_VERSION=0.3.5
LIBEVENT_VERSION=2.1.12
# Plugins Versions
KOTLIN_VERSION=1.6.10
android.useAndroidX=true
android.enableJetifier=true
+1 -1
View File
@@ -86,7 +86,7 @@ task unzipHermes(dependsOn: downloadHermes, type: Copy) {
task configureBuildForHermes(type: Exec) {
workingDir(hermesDir)
commandLine(windowsAwareCommandLine(findCmakePath(cmakeVersion), "-S", ".", "-B", hermesBuildDir.toString(), "-DJSI_DIR=" + jsiDir.absolutePath))
commandLine(windowsAwareCommandLine(findCmakePath(cmakeVersion), Os.isFamily(Os.FAMILY_WINDOWS) ? "-GNMake Makefiles" : "", "-S", ".", "-B", hermesBuildDir.toString(), "-DJSI_DIR=" + jsiDir.absolutePath))
}
task buildHermes(dependsOn: configureBuildForHermes, type: Exec) {
@@ -33,8 +33,11 @@ public class HermesExecutor extends JavaScriptExecutor {
}
}
HermesExecutor(@Nullable RuntimeConfig config) {
super(config == null ? initHybridDefaultConfig() : initHybrid(config.heapSizeMB));
HermesExecutor(@Nullable RuntimeConfig config, boolean enableDebugger, String debuggerName) {
super(
config == null
? initHybridDefaultConfig(enableDebugger, debuggerName)
: initHybrid(enableDebugger, debuggerName, config.heapSizeMB));
}
@Override
@@ -51,7 +54,9 @@ public class HermesExecutor extends JavaScriptExecutor {
*/
public static native boolean canLoadFile(String path);
private static native HybridData initHybridDefaultConfig();
private static native HybridData initHybridDefaultConfig(
boolean enableDebugger, String debuggerName);
private static native HybridData initHybrid(long heapSizeMB);
private static native HybridData initHybrid(
boolean enableDebugger, String debuggerName, long heapSizeMB);
}
@@ -15,6 +15,8 @@ public class HermesExecutorFactory implements JavaScriptExecutorFactory {
private static final String TAG = "Hermes";
private final RuntimeConfig mConfig;
private boolean mEnableDebugger = true;
private String mDebuggerName = "";
public HermesExecutorFactory() {
this(null);
@@ -24,9 +26,17 @@ public class HermesExecutorFactory implements JavaScriptExecutorFactory {
mConfig = config;
}
public void setEnableDebugger(boolean enableDebugger) {
mEnableDebugger = enableDebugger;
}
public void setDebuggerName(String debuggerName) {
mDebuggerName = debuggerName;
}
@Override
public JavaScriptExecutor create() {
return new HermesExecutor(mConfig);
return new HermesExecutor(mConfig, mEnableDebugger, mDebuggerName);
}
@Override
@@ -69,26 +69,39 @@ class HermesExecutorHolder
"Lcom/facebook/hermes/reactexecutor/HermesExecutor;";
static jni::local_ref<jhybriddata> initHybridDefaultConfig(
jni::alias_ref<jclass>) {
jni::alias_ref<jclass>,
bool enableDebugger,
std::string debuggerName) {
JReactMarker::setLogPerfMarkerIfNeeded();
std::call_once(flag, []() {
facebook::hermes::HermesRuntime::setFatalHandler(hermesFatalHandler);
});
return makeCxxInstance(
std::make_unique<HermesExecutorFactory>(installBindings));
auto factory = std::make_unique<HermesExecutorFactory>(installBindings);
factory->setEnableDebugger(enableDebugger);
if (!debuggerName.empty()) {
factory->setDebuggerName(debuggerName);
}
return makeCxxInstance(std::move(factory));
}
static jni::local_ref<jhybriddata> initHybrid(
jni::alias_ref<jclass>,
bool enableDebugger,
std::string debuggerName,
jlong heapSizeMB) {
JReactMarker::setLogPerfMarkerIfNeeded();
auto runtimeConfig = makeRuntimeConfig(heapSizeMB);
std::call_once(flag, []() {
facebook::hermes::HermesRuntime::setFatalHandler(hermesFatalHandler);
});
return makeCxxInstance(std::make_unique<HermesExecutorFactory>(
installBindings, JSIExecutor::defaultTimeoutInvoker, runtimeConfig));
auto factory = std::make_unique<HermesExecutorFactory>(
installBindings, JSIExecutor::defaultTimeoutInvoker, runtimeConfig);
factory->setEnableDebugger(enableDebugger);
if (!debuggerName.empty()) {
factory->setDebuggerName(debuggerName);
}
return makeCxxInstance(std::move(factory));
}
static bool canLoadFile(jni::alias_ref<jclass>, const std::string &path) {
@@ -7,9 +7,12 @@
package com.facebook.react.animated;
import com.facebook.common.logging.FLog;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.ReadableType;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.build.ReactBuildConfig;
/**
* Implementation of {@link AnimationDriver} which provides a support for simple time-based
@@ -70,7 +73,17 @@ class FrameBasedAnimationDriver extends AnimationDriver {
long timeFromStartMillis = (frameTimeNanos - mStartFrameTimeNanos) / 1000000;
int frameIndex = (int) Math.round(timeFromStartMillis / FRAME_TIME_MILLIS);
if (frameIndex < 0) {
throw new IllegalStateException("Calculated frame index should never be lower than 0");
String message =
"Calculated frame index should never be lower than 0. Called with frameTimeNanos "
+ frameTimeNanos
+ " and mStartFrameTimeNanos "
+ mStartFrameTimeNanos;
if (ReactBuildConfig.DEBUG) {
throw new IllegalStateException(message);
} else {
FLog.w(ReactConstants.TAG, message);
return;
}
} else if (mHasFinished) {
// nothing to do here
return;
@@ -871,7 +871,7 @@ public class NativeAnimatedModule extends NativeAnimatedModuleSpec
if (ANIMATED_MODULE_DEBUG) {
FLog.d(
NAME,
"queue: disconnectAnimatedNodeFromView: " + animatedNodeTag + " viewTag: " + viewTag);
"queue disconnectAnimatedNodeFromView: " + animatedNodeTag + " viewTag: " + viewTag);
}
decrementInFlightAnimationsForViewTag(viewTag);
@@ -883,7 +883,7 @@ public class NativeAnimatedModule extends NativeAnimatedModuleSpec
if (ANIMATED_MODULE_DEBUG) {
FLog.d(
NAME,
"execute: disconnectAnimatedNodeFromView: "
"execute disconnectAnimatedNodeFromView: "
+ animatedNodeTag
+ " viewTag: "
+ viewTag);
@@ -897,8 +897,7 @@ public class NativeAnimatedModule extends NativeAnimatedModuleSpec
public void restoreDefaultValues(final double animatedNodeTagDouble) {
final int animatedNodeTag = (int) animatedNodeTagDouble;
if (ANIMATED_MODULE_DEBUG) {
FLog.d(
NAME, "queue restoreDefaultValues: disconnectAnimatedNodeFromView: " + animatedNodeTag);
FLog.d(NAME, "queue restoreDefaultValues: " + animatedNodeTag);
}
addPreOperation(
@@ -906,10 +905,7 @@ public class NativeAnimatedModule extends NativeAnimatedModuleSpec
@Override
public void execute(NativeAnimatedNodesManager animatedNodesManager) {
if (ANIMATED_MODULE_DEBUG) {
FLog.d(
NAME,
"execute restoreDefaultValues: disconnectAnimatedNodeFromView: "
+ animatedNodeTag);
FLog.d(NAME, "execute restoreDefaultValues: " + animatedNodeTag);
}
animatedNodesManager.restoreDefaultValues(animatedNodeTag);
}
@@ -69,9 +69,9 @@ public class DevLoadingViewController {
return;
}
int port = parsedURL.getPort() != -1 ? parsedURL.getPort() : parsedURL.getDefaultPort();
showMessage(
context.getString(
R.string.catalyst_loading_from_url, parsedURL.getHost() + ":" + parsedURL.getPort()));
context.getString(R.string.catalyst_loading_from_url, parsedURL.getHost() + ":" + port));
}
public void showForRemoteJSEnabled() {
@@ -703,7 +703,7 @@ public abstract class DevSupportManagerBase implements DevSupportManager {
URL sourceUrl = new URL(getSourceUrl());
String path = sourceUrl.getPath().substring(1); // strip initial slash in path
String host = sourceUrl.getHost();
int port = sourceUrl.getPort();
int port = sourceUrl.getPort() != -1 ? sourceUrl.getPort() : sourceUrl.getDefaultPort();
mCurrentContext
.getJSModule(HMRClient.class)
.setup("android", path, host, port, mDevSettings.isHotModuleReplacementEnabled());
@@ -44,7 +44,7 @@ target_link_libraries(
react_render_uimanager
react_utils
react_config
reactnativeutilsjni
reactnativejni
rrc_image
rrc_modal
rrc_progressbar
@@ -152,7 +152,9 @@ public class ForwardingCookieHandler extends CookieHandler {
|| (message != null
&& (message.contains("WebView provider")
|| message.contains("No WebView installed")
|| message.contains("Cannot load WebView")))) {
|| message.contains("Cannot load WebView")
|| message.contains("disableWebView")
|| message.contains("WebView is disabled")))) {
return null;
} else {
throw exception;
@@ -16,7 +16,7 @@ import java.util.Map;
public class ReactNativeVersion {
public static final Map<String, Object> VERSION = MapBuilder.<String, Object>of(
"major", 0,
"minor", 0,
"patch", 0,
"minor", 70,
"patch", 14,
"prerelease", null);
}
@@ -287,7 +287,9 @@ public abstract class BaseViewManager<T extends View, C extends LayoutShadowNode
view.setSelected(false);
}
view.setTag(R.id.accessibility_state, accessibilityState);
view.setEnabled(true);
if (accessibilityState.hasKey("disabled") && !accessibilityState.getBoolean("disabled")) {
view.setEnabled(true);
}
// For states which don't have corresponding methods in
// AccessibilityNodeInfo, update the view's content description
@@ -278,14 +278,16 @@ public class ViewProps {
}
return true;
case BORDER_LEFT_COLOR:
return !map.isNull(BORDER_LEFT_COLOR) && map.getInt(BORDER_LEFT_COLOR) == Color.TRANSPARENT;
return map.getType(BORDER_LEFT_COLOR) == ReadableType.Number
&& map.getInt(BORDER_LEFT_COLOR) == Color.TRANSPARENT;
case BORDER_RIGHT_COLOR:
return !map.isNull(BORDER_RIGHT_COLOR)
return map.getType(BORDER_RIGHT_COLOR) == ReadableType.Number
&& map.getInt(BORDER_RIGHT_COLOR) == Color.TRANSPARENT;
case BORDER_TOP_COLOR:
return !map.isNull(BORDER_TOP_COLOR) && map.getInt(BORDER_TOP_COLOR) == Color.TRANSPARENT;
return map.getType(BORDER_TOP_COLOR) == ReadableType.Number
&& map.getInt(BORDER_TOP_COLOR) == Color.TRANSPARENT;
case BORDER_BOTTOM_COLOR:
return !map.isNull(BORDER_BOTTOM_COLOR)
return map.getType(BORDER_BOTTOM_COLOR) == ReadableType.Number
&& map.getInt(BORDER_BOTTOM_COLOR) == Color.TRANSPARENT;
case BORDER_WIDTH:
return map.isNull(BORDER_WIDTH) || map.getDouble(BORDER_WIDTH) == 0d;
@@ -37,6 +37,10 @@ public class CustomLetterSpacingSpan extends MetricAffectingSpan implements Reac
apply(paint);
}
public float getSpacing() {
return mLetterSpacing;
}
private void apply(TextPaint paint) {
if (!Float.isNaN(mLetterSpacing)) {
paint.setLetterSpacing(mLetterSpacing);
@@ -71,6 +71,10 @@ public class CustomStyleSpan extends MetricAffectingSpan implements ReactSpan {
return mFontFamily;
}
public @Nullable String getFontFeatureSettings() {
return mFeatureSettings;
}
private static void apply(
Paint paint,
int style,
@@ -31,8 +31,6 @@ public class ReactTextUpdate {
private final int mSelectionEnd;
private final int mJustificationMode;
public boolean mContainsMultipleFragments;
/**
* @deprecated Use a non-deprecated constructor for ReactTextUpdate instead. This one remains
* because it's being used by a unit test that isn't currently open source.
@@ -142,13 +140,11 @@ public class ReactTextUpdate {
int jsEventCounter,
int textAlign,
int textBreakStrategy,
int justificationMode,
boolean containsMultipleFragments) {
int justificationMode) {
ReactTextUpdate reactTextUpdate =
new ReactTextUpdate(
text, jsEventCounter, false, textAlign, textBreakStrategy, justificationMode);
reactTextUpdate.mContainsMultipleFragments = containsMultipleFragments;
return reactTextUpdate;
}
@@ -54,7 +54,6 @@ public class ReactTextView extends AppCompatTextView implements ReactCompoundVie
private boolean mContainsImages;
private final int mDefaultGravityHorizontal;
private final int mDefaultGravityVertical;
private int mTextAlign;
private int mNumberOfLines;
private TextUtils.TruncateAt mEllipsizeLocation;
private boolean mAdjustsFontSizeToFit;
@@ -69,8 +68,7 @@ public class ReactTextView extends AppCompatTextView implements ReactCompoundVie
super(context);
// Get these defaults only during the constructor - these should never be set otherwise
mDefaultGravityHorizontal =
getGravity() & (Gravity.HORIZONTAL_GRAVITY_MASK | Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK);
mDefaultGravityHorizontal = getGravityHorizontal();
mDefaultGravityVertical = getGravity() & Gravity.VERTICAL_GRAVITY_MASK;
initView();
@@ -89,10 +87,10 @@ public class ReactTextView extends AppCompatTextView implements ReactCompoundVie
mReactBackgroundManager = new ReactViewBackgroundManager(this);
mTextAlign = Gravity.NO_GRAVITY;
mNumberOfLines = ViewDefaults.NUMBER_OF_LINES;
mAdjustsFontSizeToFit = false;
mLinkifyMaskType = 0;
mNotifyOnInlineViewLayout = false;
mTextIsSelectable = false;
mEllipsizeLocation = TextUtils.TruncateAt.END;
@@ -392,10 +390,9 @@ public class ReactTextView extends AppCompatTextView implements ReactCompoundVie
}
int nextTextAlign = update.getTextAlign();
if (mTextAlign != nextTextAlign) {
mTextAlign = nextTextAlign;
if (nextTextAlign != getGravityHorizontal()) {
setGravityHorizontal(nextTextAlign);
}
setGravityHorizontal(mTextAlign);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (getBreakStrategy() != update.getTextBreakStrategy()) {
setBreakStrategy(update.getTextBreakStrategy());
@@ -552,6 +549,11 @@ public class ReactTextView extends AppCompatTextView implements ReactCompoundVie
return false;
}
/* package */ int getGravityHorizontal() {
return getGravity()
& (Gravity.HORIZONTAL_GRAVITY_MASK | Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK);
}
/* package */ void setGravityHorizontal(int gravityHorizontal) {
if (gravityHorizontal == 0) {
gravityHorizontal = mDefaultGravityHorizontal;
@@ -8,6 +8,7 @@
package com.facebook.react.views.text;
import android.content.Context;
import android.os.Build;
import android.text.Spannable;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
@@ -24,6 +25,7 @@ import com.facebook.react.uimanager.ReactAccessibilityDelegate;
import com.facebook.react.uimanager.ReactStylesDiffMap;
import com.facebook.react.uimanager.StateWrapper;
import com.facebook.react.uimanager.ThemedReactContext;
import com.facebook.react.uimanager.ViewProps;
import com.facebook.yoga.YogaMeasureMode;
import java.util.HashMap;
import java.util.Map;
@@ -152,15 +154,19 @@ public class ReactTextViewManager
view.setSpanned(spanned);
int textBreakStrategy =
TextAttributeProps.getTextBreakStrategy(paragraphAttributes.getString("textBreakStrategy"));
TextAttributeProps.getTextBreakStrategy(
paragraphAttributes.getString(ViewProps.TEXT_BREAK_STRATEGY));
int currentJustificationMode =
Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? 0 : view.getJustificationMode();
return new ReactTextUpdate(
spanned,
state.hasKey("mostRecentEventCount") ? state.getInt("mostRecentEventCount") : -1,
false, // TODO add this into local Data
TextAttributeProps.getTextAlignment(props, TextLayoutManager.isRTL(attributedString)),
TextAttributeProps.getTextAlignment(
props, TextLayoutManager.isRTL(attributedString), view.getGravityHorizontal()),
textBreakStrategy,
TextAttributeProps.getJustificationMode(props));
TextAttributeProps.getJustificationMode(props, currentJustificationMode));
}
private Object getReactTextUpdate(ReactTextView view, ReactStylesDiffMap props, MapBuffer state) {
@@ -175,15 +181,17 @@ public class ReactTextViewManager
int textBreakStrategy =
TextAttributeProps.getTextBreakStrategy(
paragraphAttributes.getString(TextLayoutManagerMapBuffer.PA_KEY_TEXT_BREAK_STRATEGY));
int currentJustificationMode =
Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? 0 : view.getJustificationMode();
return new ReactTextUpdate(
spanned,
-1, // UNUSED FOR TEXT
false, // TODO add this into local Data
TextAttributeProps.getTextAlignment(
props, TextLayoutManagerMapBuffer.isRTL(attributedString)),
props, TextLayoutManagerMapBuffer.isRTL(attributedString), view.getGravityHorizontal()),
textBreakStrategy,
TextAttributeProps.getJustificationMode(props));
TextAttributeProps.getJustificationMode(props, currentJustificationMode));
}
@Override
@@ -249,35 +249,35 @@ public class TextAttributeProps {
return result;
}
public static int getTextAlignment(ReactStylesDiffMap props, boolean isRTL) {
@Nullable
String textAlignPropValue =
props.hasKey(ViewProps.TEXT_ALIGN) ? props.getString(ViewProps.TEXT_ALIGN) : null;
int textAlignment;
public static int getTextAlignment(ReactStylesDiffMap props, boolean isRTL, int defaultValue) {
if (!props.hasKey(ViewProps.TEXT_ALIGN)) {
return defaultValue;
}
String textAlignPropValue = props.getString(ViewProps.TEXT_ALIGN);
if ("justify".equals(textAlignPropValue)) {
textAlignment = Gravity.LEFT;
return Gravity.LEFT;
} else {
if (textAlignPropValue == null || "auto".equals(textAlignPropValue)) {
textAlignment = Gravity.NO_GRAVITY;
return Gravity.NO_GRAVITY;
} else if ("left".equals(textAlignPropValue)) {
textAlignment = isRTL ? Gravity.RIGHT : Gravity.LEFT;
return isRTL ? Gravity.RIGHT : Gravity.LEFT;
} else if ("right".equals(textAlignPropValue)) {
textAlignment = isRTL ? Gravity.LEFT : Gravity.RIGHT;
return isRTL ? Gravity.LEFT : Gravity.RIGHT;
} else if ("center".equals(textAlignPropValue)) {
textAlignment = Gravity.CENTER_HORIZONTAL;
return Gravity.CENTER_HORIZONTAL;
} else {
throw new JSApplicationIllegalArgumentException("Invalid textAlign: " + textAlignPropValue);
}
}
return textAlignment;
}
public static int getJustificationMode(ReactStylesDiffMap props) {
@Nullable
String textAlignPropValue =
props.hasKey(ViewProps.TEXT_ALIGN) ? props.getString(ViewProps.TEXT_ALIGN) : null;
public static int getJustificationMode(ReactStylesDiffMap props, int defaultValue) {
if (!props.hasKey(ViewProps.TEXT_ALIGN)) {
return defaultValue;
}
String textAlignPropValue = props.getString(ViewProps.TEXT_ALIGN);
if ("justify".equals(textAlignPropValue) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
return Layout.JUSTIFICATION_MODE_INTER_WORD;
}
@@ -106,6 +106,11 @@ public class TextLayoutManagerMapBuffer {
MapBuffer fragment = fragments.getMapBuffer((short) 0);
MapBuffer textAttributes = fragment.getMapBuffer(FR_KEY_TEXT_ATTRIBUTES);
if (!textAttributes.contains(TextAttributeProps.TA_KEY_LAYOUT_DIRECTION)) {
return false;
}
return TextAttributeProps.getLayoutDirection(
textAttributes.getString(TextAttributeProps.TA_KEY_LAYOUT_DIRECTION))
== LayoutDirection.RTL;
@@ -1,4 +1,7 @@
load("//tools/build_defs/oss:rn_defs.bzl", "YOGA_TARGET", "react_native_dep", "react_native_target", "rn_android_library")
load("//tools/build_defs/oss:rn_defs.bzl", "IS_OSS_BUILD", "YOGA_TARGET", "react_native_android_toplevel_dep", "react_native_dep", "react_native_target", "rn_android_library")
# TODO(T115916830): Remove when Kotlin files are used in this module
KOTLIN_STDLIB_DEPS = [react_native_android_toplevel_dep("third-party/kotlin:kotlin-stdlib")] if IS_OSS_BUILD else []
rn_android_library(
name = "textinput",
@@ -9,7 +12,8 @@ rn_android_library(
"pfh:ReactNative_CommonInfrastructurePlaceholder",
"supermodule:xplat/default/public.react_native.infra",
],
language = "JAVA",
language = "KOTLIN",
pure_kotlin = False,
required_for_source_only_abi = True,
visibility = [
"PUBLIC",
@@ -29,8 +33,10 @@ rn_android_library(
react_native_target("java/com/facebook/react/views/imagehelper:imagehelper"),
react_native_target("java/com/facebook/react/views/scroll:scroll"),
react_native_target("java/com/facebook/react/views/text:text"),
react_native_target("java/com/facebook/react/common/mapbuffer:mapbuffer"),
react_native_target("java/com/facebook/react/views/view:view"),
],
react_native_target("java/com/facebook/react/config:config"),
] + KOTLIN_STDLIB_DEPS,
exported_deps = [
react_native_dep("third-party/android/androidx:appcompat"),
],
@@ -11,6 +11,8 @@ import static com.facebook.react.uimanager.UIManagerHelper.getReactContext;
import static com.facebook.react.views.text.TextAttributeProps.UNSET;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
@@ -50,15 +52,19 @@ import com.facebook.react.views.text.CustomLetterSpacingSpan;
import com.facebook.react.views.text.CustomLineHeightSpan;
import com.facebook.react.views.text.CustomStyleSpan;
import com.facebook.react.views.text.ReactAbsoluteSizeSpan;
import com.facebook.react.views.text.ReactBackgroundColorSpan;
import com.facebook.react.views.text.ReactForegroundColorSpan;
import com.facebook.react.views.text.ReactSpan;
import com.facebook.react.views.text.ReactStrikethroughSpan;
import com.facebook.react.views.text.ReactTextUpdate;
import com.facebook.react.views.text.ReactTypefaceUtils;
import com.facebook.react.views.text.ReactUnderlineSpan;
import com.facebook.react.views.text.TextAttributes;
import com.facebook.react.views.text.TextInlineImageSpan;
import com.facebook.react.views.text.TextLayoutManager;
import com.facebook.react.views.view.ReactViewBackgroundManager;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* A wrapper around the EditText that lets us better control what happens when an EditText gets
@@ -82,7 +88,6 @@ public class ReactEditText extends AppCompatEditText
// *TextChanged events should be triggered. This is less expensive than removing the text
// listeners and adding them back again after the text change is completed.
protected boolean mIsSettingTextFromJS;
protected boolean mIsSettingTextFromCacheUpdate = false;
private int mDefaultGravityHorizontal;
private int mDefaultGravityVertical;
@@ -363,7 +368,7 @@ public class ReactEditText extends AppCompatEditText
}
super.onSelectionChanged(selStart, selEnd);
if (!mIsSettingTextFromCacheUpdate && mSelectionWatcher != null && hasFocus()) {
if (mSelectionWatcher != null && hasFocus()) {
mSelectionWatcher.onSelectionChanged(selStart, selEnd);
}
}
@@ -482,6 +487,14 @@ public class ReactEditText extends AppCompatEditText
}
}
@Override
public void setFontFeatureSettings(String fontFeatureSettings) {
if (!Objects.equals(fontFeatureSettings, getFontFeatureSettings())) {
super.setFontFeatureSettings(fontFeatureSettings);
mTypefaceDirty = true;
}
}
public void maybeUpdateTypeface() {
if (!mTypefaceDirty) {
return;
@@ -493,6 +506,17 @@ public class ReactEditText extends AppCompatEditText
ReactTypefaceUtils.applyStyles(
getTypeface(), mFontStyle, mFontWeight, mFontFamily, getContext().getAssets());
setTypeface(newTypeface);
// Match behavior of CustomStyleSpan and enable SUBPIXEL_TEXT_FLAG when setting anything
// nonstandard
if (mFontStyle != UNSET
|| mFontWeight != UNSET
|| mFontFamily != null
|| getFontFeatureSettings() != null) {
setPaintFlags(getPaintFlags() | Paint.SUBPIXEL_TEXT_FLAG);
} else {
setPaintFlags(getPaintFlags() & (~Paint.SUBPIXEL_TEXT_FLAG));
}
}
// VisibleForTesting from {@link TextInputEventsTestCase}.
@@ -554,7 +578,9 @@ public class ReactEditText extends AppCompatEditText
SpannableStringBuilder spannableStringBuilder =
new SpannableStringBuilder(reactTextUpdate.getText());
manageSpans(spannableStringBuilder, reactTextUpdate.mContainsMultipleFragments);
manageSpans(spannableStringBuilder);
stripStyleEquivalentSpans(spannableStringBuilder);
mContainsImages = reactTextUpdate.containsImages();
// When we update text, we trigger onChangeText code that will
@@ -581,7 +607,7 @@ public class ReactEditText extends AppCompatEditText
}
// Update cached spans (in Fabric only).
updateCachedSpannable(false);
updateCachedSpannable();
}
/**
@@ -590,8 +616,7 @@ public class ReactEditText extends AppCompatEditText
* will adapt to the new text, hence why {@link SpannableStringBuilder#replace} never removes
* them.
*/
private void manageSpans(
SpannableStringBuilder spannableStringBuilder, boolean skipAddSpansForMeasurements) {
private void manageSpans(SpannableStringBuilder spannableStringBuilder) {
Object[] spans = getText().getSpans(0, length(), Object.class);
for (int spanIdx = 0; spanIdx < spans.length; spanIdx++) {
Object span = spans[spanIdx];
@@ -619,12 +644,170 @@ public class ReactEditText extends AppCompatEditText
spannableStringBuilder.setSpan(span, spanStart, spanEnd, spanFlags);
}
}
}
// In Fabric only, apply necessary styles to entire span
// If the Spannable was constructed from multiple fragments, we don't apply any spans that could
// impact the whole Spannable, because that would override "local" styles per-fragment
if (!skipAddSpansForMeasurements) {
addSpansForMeasurement(getText());
// TODO: Replace with Predicate<T> and lambdas once Java 8 builds in OSS
interface SpanPredicate<T> {
boolean test(T span);
}
/**
* Remove spans from the SpannableStringBuilder which can be represented by TextAppearance
* attributes on the underlying EditText. This works around instability on Samsung devices with
* the presence of spans https://github.com/facebook/react-native/issues/35936 (S318090)
*/
private void stripStyleEquivalentSpans(SpannableStringBuilder sb) {
stripSpansOfKind(
sb,
ReactAbsoluteSizeSpan.class,
new SpanPredicate<ReactAbsoluteSizeSpan>() {
@Override
public boolean test(ReactAbsoluteSizeSpan span) {
return span.getSize() == mTextAttributes.getEffectiveFontSize();
}
});
stripSpansOfKind(
sb,
ReactBackgroundColorSpan.class,
new SpanPredicate<ReactBackgroundColorSpan>() {
@Override
public boolean test(ReactBackgroundColorSpan span) {
return span.getBackgroundColor() == mReactBackgroundManager.getBackgroundColor();
}
});
stripSpansOfKind(
sb,
ReactForegroundColorSpan.class,
new SpanPredicate<ReactForegroundColorSpan>() {
@Override
public boolean test(ReactForegroundColorSpan span) {
return span.getForegroundColor() == getCurrentTextColor();
}
});
stripSpansOfKind(
sb,
ReactStrikethroughSpan.class,
new SpanPredicate<ReactStrikethroughSpan>() {
@Override
public boolean test(ReactStrikethroughSpan span) {
return (getPaintFlags() & Paint.STRIKE_THRU_TEXT_FLAG) != 0;
}
});
stripSpansOfKind(
sb,
ReactUnderlineSpan.class,
new SpanPredicate<ReactUnderlineSpan>() {
@Override
public boolean test(ReactUnderlineSpan span) {
return (getPaintFlags() & Paint.UNDERLINE_TEXT_FLAG) != 0;
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
stripSpansOfKind(
sb,
CustomLetterSpacingSpan.class,
new SpanPredicate<CustomLetterSpacingSpan>() {
@Override
public boolean test(CustomLetterSpacingSpan span) {
return span.getSpacing() == mTextAttributes.getEffectiveLetterSpacing();
}
});
}
stripSpansOfKind(
sb,
CustomStyleSpan.class,
new SpanPredicate<CustomStyleSpan>() {
@Override
public boolean test(CustomStyleSpan span) {
return span.getStyle() == mFontStyle
&& Objects.equals(span.getFontFamily(), mFontFamily)
&& span.getWeight() == mFontWeight
&& Objects.equals(span.getFontFeatureSettings(), getFontFeatureSettings());
}
});
}
private <T> void stripSpansOfKind(
SpannableStringBuilder sb, Class<T> clazz, SpanPredicate<T> shouldStrip) {
T[] spans = sb.getSpans(0, sb.length(), clazz);
for (T span : spans) {
if (shouldStrip.test(span)) {
sb.removeSpan(span);
}
}
}
/**
* Copy styles represented as attributes to the underlying span, for later measurement or other
* usage outside the ReactEditText.
*/
private void addSpansFromStyleAttributes(SpannableStringBuilder workingText) {
int spanFlags = Spannable.SPAN_INCLUSIVE_INCLUSIVE;
// Set all bits for SPAN_PRIORITY so that this span has the highest possible priority
// (least precedence). This ensures the span is behind any overlapping spans.
spanFlags |= Spannable.SPAN_PRIORITY;
workingText.setSpan(
new ReactAbsoluteSizeSpan(mTextAttributes.getEffectiveFontSize()),
0,
workingText.length(),
spanFlags);
workingText.setSpan(
new ReactForegroundColorSpan(getCurrentTextColor()), 0, workingText.length(), spanFlags);
int backgroundColor = mReactBackgroundManager.getBackgroundColor();
if (backgroundColor != Color.TRANSPARENT) {
workingText.setSpan(
new ReactBackgroundColorSpan(backgroundColor), 0, workingText.length(), spanFlags);
}
if ((getPaintFlags() & Paint.STRIKE_THRU_TEXT_FLAG) != 0) {
workingText.setSpan(new ReactStrikethroughSpan(), 0, workingText.length(), spanFlags);
}
if ((getPaintFlags() & Paint.UNDERLINE_TEXT_FLAG) != 0) {
workingText.setSpan(new ReactUnderlineSpan(), 0, workingText.length(), spanFlags);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
float effectiveLetterSpacing = mTextAttributes.getEffectiveLetterSpacing();
if (!Float.isNaN(effectiveLetterSpacing)) {
workingText.setSpan(
new CustomLetterSpacingSpan(effectiveLetterSpacing),
0,
workingText.length(),
spanFlags);
}
}
if (mFontStyle != UNSET
|| mFontWeight != UNSET
|| mFontFamily != null
|| getFontFeatureSettings() != null) {
workingText.setSpan(
new CustomStyleSpan(
mFontStyle,
mFontWeight,
getFontFeatureSettings(),
mFontFamily,
getContext().getAssets()),
0,
workingText.length(),
spanFlags);
}
float lineHeight = mTextAttributes.getEffectiveLineHeight();
if (!Float.isNaN(lineHeight)) {
workingText.setSpan(new CustomLineHeightSpan(lineHeight), 0, workingText.length(), spanFlags);
}
}
@@ -644,73 +827,6 @@ public class ReactEditText extends AppCompatEditText
return true;
}
// This is hacked in for Fabric. When we delete non-Fabric code, we might be able to simplify or
// clean this up a bit.
private void addSpansForMeasurement(Spannable spannable) {
if (!mFabricViewStateManager.hasStateWrapper()) {
return;
}
boolean originalDisableTextDiffing = mDisableTextDiffing;
mDisableTextDiffing = true;
int start = 0;
int end = spannable.length();
// Remove duplicate spans we might add here
Object[] spans = spannable.getSpans(0, length(), Object.class);
for (Object span : spans) {
int spanFlags = spannable.getSpanFlags(span);
boolean isInclusive =
(spanFlags & Spanned.SPAN_INCLUSIVE_INCLUSIVE) == Spanned.SPAN_INCLUSIVE_INCLUSIVE
|| (spanFlags & Spanned.SPAN_INCLUSIVE_EXCLUSIVE) == Spanned.SPAN_INCLUSIVE_EXCLUSIVE;
if (isInclusive
&& span instanceof ReactSpan
&& spannable.getSpanStart(span) == start
&& spannable.getSpanEnd(span) == end) {
spannable.removeSpan(span);
}
}
List<TextLayoutManager.SetSpanOperation> ops = new ArrayList<>();
if (!Float.isNaN(mTextAttributes.getLetterSpacing())) {
ops.add(
new TextLayoutManager.SetSpanOperation(
start, end, new CustomLetterSpacingSpan(mTextAttributes.getLetterSpacing())));
}
ops.add(
new TextLayoutManager.SetSpanOperation(
start, end, new ReactAbsoluteSizeSpan((int) mTextAttributes.getEffectiveFontSize())));
if (mFontStyle != UNSET || mFontWeight != UNSET || mFontFamily != null) {
ops.add(
new TextLayoutManager.SetSpanOperation(
start,
end,
new CustomStyleSpan(
mFontStyle,
mFontWeight,
null, // TODO: do we need to support FontFeatureSettings / fontVariant?
mFontFamily,
getReactContext(ReactEditText.this).getAssets())));
}
if (!Float.isNaN(mTextAttributes.getEffectiveLineHeight())) {
ops.add(
new TextLayoutManager.SetSpanOperation(
start, end, new CustomLineHeightSpan(mTextAttributes.getEffectiveLineHeight())));
}
int priority = 0;
for (TextLayoutManager.SetSpanOperation op : ops) {
// Actual order of calling {@code execute} does NOT matter,
// but the {@code priority} DOES matter.
op.execute(spannable, priority);
priority++;
}
mDisableTextDiffing = originalDisableTextDiffing;
}
protected boolean showSoftKeyboard() {
return mInputMethodManager.showSoftInput(this, 0);
}
@@ -765,6 +881,11 @@ public class ReactEditText extends AppCompatEditText
}
}
/* package */ int getGravityHorizontal() {
return getGravity()
& (Gravity.HORIZONTAL_GRAVITY_MASK | Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK);
}
/* package */ void setGravityHorizontal(int gravityHorizontal) {
if (gravityHorizontal == 0) {
gravityHorizontal = mDefaultGravityHorizontal;
@@ -975,7 +1096,9 @@ public class ReactEditText extends AppCompatEditText
float effectiveLetterSpacing = mTextAttributes.getEffectiveLetterSpacing();
if (!Float.isNaN(effectiveLetterSpacing)) {
setLetterSpacing(effectiveLetterSpacing);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setLetterSpacing(effectiveLetterSpacing);
}
}
}
@@ -990,7 +1113,7 @@ public class ReactEditText extends AppCompatEditText
* TextLayoutManager.java with some very minor modifications. There's some duplication between
* here and TextLayoutManager, so there might be an opportunity for refactor.
*/
private void updateCachedSpannable(boolean resetStyles) {
private void updateCachedSpannable() {
// Noops in non-Fabric
if (mFabricViewStateManager == null || !mFabricViewStateManager.hasStateWrapper()) {
return;
@@ -1000,12 +1123,6 @@ public class ReactEditText extends AppCompatEditText
return;
}
if (resetStyles) {
mIsSettingTextFromCacheUpdate = true;
addSpansForMeasurement(getText());
mIsSettingTextFromCacheUpdate = false;
}
Editable currentText = getText();
boolean haveText = currentText != null && currentText.length() > 0;
@@ -1063,11 +1180,9 @@ public class ReactEditText extends AppCompatEditText
// Measure something so we have correct height, even if there's no string.
sb.append("I");
}
// Make sure that all text styles are applied when we're measurable the hint or "blank" text
addSpansForMeasurement(sb);
}
addSpansFromStyleAttributes(sb);
TextLayoutManager.setCachedSpannabledForTag(getId(), sb);
}
@@ -1082,7 +1197,7 @@ public class ReactEditText extends AppCompatEditText
private class TextWatcherDelegator implements TextWatcher {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
if (!mIsSettingTextFromCacheUpdate && !mIsSettingTextFromJS && mListeners != null) {
if (!mIsSettingTextFromJS && mListeners != null) {
for (TextWatcher listener : mListeners) {
listener.beforeTextChanged(s, start, count, after);
}
@@ -1096,23 +1211,20 @@ public class ReactEditText extends AppCompatEditText
TAG, "onTextChanged[" + getId() + "]: " + s + " " + start + " " + before + " " + count);
}
if (!mIsSettingTextFromCacheUpdate) {
if (!mIsSettingTextFromJS && mListeners != null) {
for (TextWatcher listener : mListeners) {
listener.onTextChanged(s, start, before, count);
}
if (!mIsSettingTextFromJS && mListeners != null) {
for (TextWatcher listener : mListeners) {
listener.onTextChanged(s, start, before, count);
}
updateCachedSpannable(
!mIsSettingTextFromJS && !mIsSettingTextFromState && start == 0 && before == 0);
}
updateCachedSpannable();
onContentSizeChange();
}
@Override
public void afterTextChanged(Editable s) {
if (!mIsSettingTextFromCacheUpdate && !mIsSettingTextFromJS && mListeners != null) {
if (!mIsSettingTextFromJS && mListeners != null) {
for (TextWatcher listener : mListeners) {
listener.afterTextChanged(s);
}
@@ -13,6 +13,7 @@ import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.BlendMode;
import android.graphics.BlendModeColorFilter;
import android.graphics.Paint;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Build;
@@ -44,6 +45,8 @@ import com.facebook.react.bridge.ReadableType;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeMap;
import com.facebook.react.common.MapBuilder;
import com.facebook.react.common.mapbuffer.MapBuffer;
import com.facebook.react.config.ReactFeatureFlags;
import com.facebook.react.module.annotations.ReactModule;
import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.FabricViewStateManager;
@@ -66,9 +69,11 @@ import com.facebook.react.views.text.DefaultStyleValuesUtil;
import com.facebook.react.views.text.ReactBaseTextShadowNode;
import com.facebook.react.views.text.ReactTextUpdate;
import com.facebook.react.views.text.ReactTextViewManagerCallback;
import com.facebook.react.views.text.ReactTypefaceUtils;
import com.facebook.react.views.text.TextAttributeProps;
import com.facebook.react.views.text.TextInlineImageSpan;
import com.facebook.react.views.text.TextLayoutManager;
import com.facebook.react.views.text.TextLayoutManagerMapBuffer;
import com.facebook.react.views.text.TextTransform;
import com.facebook.yoga.YogaConstants;
import java.lang.reflect.Field;
@@ -83,6 +88,12 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
public static final String TAG = ReactTextInputManager.class.getSimpleName();
public static final String REACT_CLASS = "AndroidTextInput";
// See also ReactTextViewManager
private static final short TX_STATE_KEY_ATTRIBUTED_STRING = 0;
private static final short TX_STATE_KEY_PARAGRAPH_ATTRIBUTES = 1;
private static final short TX_STATE_KEY_HASH = 2;
private static final short TX_STATE_KEY_MOST_RECENT_EVENT_COUNT = 3;
private static final int[] SPACING_TYPES = {
Spacing.ALL, Spacing.LEFT, Spacing.RIGHT, Spacing.TOP, Spacing.BOTTOM,
};
@@ -396,6 +407,11 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
view.setFontStyle(fontStyle);
}
@ReactProp(name = ViewProps.FONT_VARIANT)
public void setFontVariant(ReactEditText view, @Nullable ReadableArray fontVariant) {
view.setFontFeatureSettings(ReactTypefaceUtils.parseFontVariant(fontVariant));
}
@ReactProp(name = ViewProps.INCLUDE_FONT_PADDING, defaultBoolean = true)
public void setIncludeFontPadding(ReactEditText view, boolean includepad) {
view.setIncludeFontPadding(includepad);
@@ -912,6 +928,20 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
view.setAutoFocus(autoFocus);
}
@ReactProp(name = ViewProps.TEXT_DECORATION_LINE)
public void setTextDecorationLine(ReactEditText view, @Nullable String textDecorationLineString) {
view.setPaintFlags(
view.getPaintFlags() & ~(Paint.STRIKE_THRU_TEXT_FLAG | Paint.UNDERLINE_TEXT_FLAG));
for (String token : textDecorationLineString.split(" ")) {
if (token.equals("underline")) {
view.setPaintFlags(view.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
} else if (token.equals("line-through")) {
view.setPaintFlags(view.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
}
}
}
@ReactPropGroup(
names = {
ViewProps.BORDER_WIDTH,
@@ -1284,11 +1314,15 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
stateManager.setStateWrapper(stateWrapper);
ReadableNativeMap state = stateWrapper.getStateData();
if (state == null) {
return null;
if (ReactFeatureFlags.mapBufferSerializationEnabled) {
MapBuffer stateMapBuffer = stateWrapper.getStateDataMapBuffer();
if (stateMapBuffer != null) {
return getReactTextUpdate(view, props, stateMapBuffer);
}
}
if (!state.hasKey("attributedString")) {
ReadableNativeMap state = stateWrapper.getStateData();
if (state == null || !state.hasKey("attributedString")) {
return null;
}
@@ -1302,18 +1336,51 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
TextLayoutManager.getOrCreateSpannableForText(
view.getContext(), attributedString, mReactTextViewManagerCallback);
boolean containsMultipleFragments =
attributedString.getArray("fragments").toArrayList().size() > 1;
int textBreakStrategy =
TextAttributeProps.getTextBreakStrategy(paragraphAttributes.getString("textBreakStrategy"));
TextAttributeProps.getTextBreakStrategy(
paragraphAttributes.getString(ViewProps.TEXT_BREAK_STRATEGY));
int currentJustificationMode =
Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? 0 : view.getJustificationMode();
return ReactTextUpdate.buildReactTextUpdateFromState(
spanned,
state.getInt("mostRecentEventCount"),
TextAttributeProps.getTextAlignment(props, TextLayoutManager.isRTL(attributedString)),
TextAttributeProps.getTextAlignment(
props, TextLayoutManager.isRTL(attributedString), view.getGravityHorizontal()),
textBreakStrategy,
TextAttributeProps.getJustificationMode(props),
containsMultipleFragments);
TextAttributeProps.getJustificationMode(props, currentJustificationMode));
}
public Object getReactTextUpdate(ReactEditText view, ReactStylesDiffMap props, MapBuffer state) {
// If native wants to update the state wrapper but the state data hasn't actually
// changed, the MapBuffer may be empty
if (state.getCount() == 0) {
return null;
}
MapBuffer attributedString = state.getMapBuffer(TX_STATE_KEY_ATTRIBUTED_STRING);
MapBuffer paragraphAttributes = state.getMapBuffer(TX_STATE_KEY_PARAGRAPH_ATTRIBUTES);
if (attributedString == null || paragraphAttributes == null) {
throw new IllegalArgumentException(
"Invalid TextInput State (MapBuffer) was received as a parameters");
}
Spannable spanned =
TextLayoutManagerMapBuffer.getOrCreateSpannableForText(
view.getContext(), attributedString, mReactTextViewManagerCallback);
int textBreakStrategy =
TextAttributeProps.getTextBreakStrategy(
paragraphAttributes.getString(TextLayoutManagerMapBuffer.PA_KEY_TEXT_BREAK_STRATEGY));
int currentJustificationMode =
Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? 0 : view.getJustificationMode();
return ReactTextUpdate.buildReactTextUpdateFromState(
spanned,
state.getInt(TX_STATE_KEY_MOST_RECENT_EVENT_COUNT),
TextAttributeProps.getTextAlignment(
props, TextLayoutManagerMapBuffer.isRTL(attributedString), view.getGravityHorizontal()),
textBreakStrategy,
TextAttributeProps.getJustificationMode(props, currentJustificationMode));
}
}
@@ -19,6 +19,7 @@ public class ReactViewBackgroundManager {
private @Nullable ReactViewBackgroundDrawable mReactBackgroundDrawable;
private View mView;
private int mColor = Color.TRANSPARENT;
public ReactViewBackgroundManager(View view) {
this.mView = view;
@@ -56,6 +57,10 @@ public class ReactViewBackgroundManager {
}
}
public int getBackgroundColor() {
return mColor;
}
public void setBorderWidth(int position, float width) {
getOrCreateReactViewBackground().setBorderWidth(position, width);
}
@@ -147,7 +147,7 @@ static int YGJNILogFunc(
if (*jloggerPtr) {
JNIEnv* env = getCurrentEnv();
jclass cl = env->FindClass("Lcom/facebook/yoga/YogaLogLevel;");
jclass cl = env->FindClass("com/facebook/yoga/YogaLogLevel");
static const jmethodID smethodId =
facebook::yoga::vanillajni::getStaticMethodId(
env, cl, "fromInt", "(I)Lcom/facebook/yoga/YogaLogLevel;");
@@ -386,7 +386,7 @@ static void jni_YGNodeCalculateLayoutJNI(
}
} catch (const std::logic_error& ex) {
env->ExceptionClear();
jclass cl = env->FindClass("Ljava/lang/IllegalStateException;");
jclass cl = env->FindClass("java/lang/IllegalStateException");
static const jmethodID methodId = facebook::yoga::vanillajni::getMethodId(
env, cl, "<init>", "(Ljava/lang/String;)V");
auto throwable = env->NewObject(cl, methodId, env->NewStringUTF(ex.what()));
@@ -15,7 +15,7 @@ namespace yoga {
namespace vanillajni {
YogaJniException::YogaJniException() {
jclass cl = getCurrentEnv()->FindClass("Ljava/lang/RuntimeException;");
jclass cl = getCurrentEnv()->FindClass("java/lang/RuntimeException");
static const jmethodID methodId = facebook::yoga::vanillajni::getMethodId(
getCurrentEnv(), cl, "<init>", "()V");
auto throwable = getCurrentEnv()->NewObject(cl, methodId);
@@ -6,8 +6,6 @@
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)
# TODO Those two libraries are building against the same sources
# and should probably be merged
file(GLOB reactnativejni_SRC CONFIGURE_DEPENDS *.cpp)
add_compile_options(
@@ -17,32 +15,6 @@ add_compile_options(
-std=c++17
-DWITH_INSPECTOR=1)
##########################
### React Native Utils ###
##########################
add_library(
reactnativeutilsjni
SHARED
${reactnativejni_SRC}
)
# TODO This should not be ../../
target_include_directories(reactnativeutilsjni PUBLIC ../../)
target_link_libraries(reactnativeutilsjni
android
callinvokerholder
fb
fbjni
folly_runtime
glog_init
react_render_runtimescheduler
reactnative
runtimeexecutor
yoga
)
######################
### reactnativejni ###
######################
@@ -67,7 +39,6 @@ target_link_libraries(reactnativejni
logger
react_render_runtimescheduler
reactnative
reactnativeutilsjni
runtimeexecutor
yoga
)
+2 -2
View File
@@ -16,8 +16,8 @@ namespace facebook::react {
constexpr struct {
int32_t Major = 0;
int32_t Minor = 0;
int32_t Patch = 0;
int32_t Minor = 70;
int32_t Patch = 14;
std::string_view Prerelease = "";
} ReactNativeVersion;
@@ -155,15 +155,20 @@ class DecoratedRuntime : public jsi::WithRuntimeDecorator<ReentrancyCheck> {
DecoratedRuntime(
std::unique_ptr<Runtime> runtime,
HermesRuntime &hermesRuntime,
std::shared_ptr<MessageQueueThread> jsQueue)
std::shared_ptr<MessageQueueThread> jsQueue,
bool enableDebugger,
const std::string &debuggerName)
: jsi::WithRuntimeDecorator<ReentrancyCheck>(*runtime, reentrancyCheck_),
runtime_(std::move(runtime)),
hermesRuntime_(hermesRuntime) {
#ifdef HERMES_ENABLE_DEBUGGER
auto adapter = std::make_unique<HermesExecutorRuntimeAdapter>(
runtime_, hermesRuntime_, jsQueue);
facebook::hermes::inspector::chrome::enableDebugging(
std::move(adapter), "Hermes React Native");
enableDebugger_ = enableDebugger;
if (enableDebugger_) {
auto adapter = std::make_unique<HermesExecutorRuntimeAdapter>(
runtime_, hermesRuntime_, jsQueue);
facebook::hermes::inspector::chrome::enableDebugging(
std::move(adapter), debuggerName);
}
#else
(void)hermesRuntime_;
#endif
@@ -171,7 +176,9 @@ class DecoratedRuntime : public jsi::WithRuntimeDecorator<ReentrancyCheck> {
~DecoratedRuntime() {
#ifdef HERMES_ENABLE_DEBUGGER
facebook::hermes::inspector::chrome::disableDebugging(*runtime_);
if (enableDebugger_) {
facebook::hermes::inspector::chrome::disableDebugging(*runtime_);
}
#endif
}
@@ -186,10 +193,21 @@ class DecoratedRuntime : public jsi::WithRuntimeDecorator<ReentrancyCheck> {
std::shared_ptr<Runtime> runtime_;
ReentrancyCheck reentrancyCheck_;
HermesRuntime &hermesRuntime_;
#ifdef HERMES_ENABLE_DEBUGGER
bool enableDebugger_;
#endif
};
} // namespace
void HermesExecutorFactory::setEnableDebugger(bool enableDebugger) {
enableDebugger_ = enableDebugger;
}
void HermesExecutorFactory::setDebuggerName(const std::string &debuggerName) {
debuggerName_ = debuggerName;
}
std::unique_ptr<JSExecutor> HermesExecutorFactory::createJSExecutor(
std::shared_ptr<ExecutorDelegate> delegate,
std::shared_ptr<MessageQueueThread> jsQueue) {
@@ -197,7 +215,11 @@ std::unique_ptr<JSExecutor> HermesExecutorFactory::createJSExecutor(
makeHermesRuntimeSystraced(runtimeConfig_);
HermesRuntime &hermesRuntimeRef = *hermesRuntime;
auto decoratedRuntime = std::make_shared<DecoratedRuntime>(
std::move(hermesRuntime), hermesRuntimeRef, jsQueue);
std::move(hermesRuntime),
hermesRuntimeRef,
jsQueue,
enableDebugger_,
debuggerName_);
// So what do we have now?
// DecoratedRuntime -> HermesRuntime
@@ -221,6 +243,12 @@ std::unique_ptr<JSExecutor> HermesExecutorFactory::createJSExecutor(
decoratedRuntime, delegate, jsQueue, timeoutInvoker_, runtimeInstaller_);
}
::hermes::vm::RuntimeConfig HermesExecutorFactory::defaultRuntimeConfig() {
return ::hermes::vm::RuntimeConfig::Builder()
.withEnableSampleProfiling(true)
.build();
}
HermesExecutor::HermesExecutor(
std::shared_ptr<jsi::Runtime> runtime,
std::shared_ptr<ExecutorDelegate> delegate,
@@ -21,21 +21,29 @@ class HermesExecutorFactory : public JSExecutorFactory {
JSIExecutor::RuntimeInstaller runtimeInstaller,
const JSIScopedTimeoutInvoker &timeoutInvoker =
JSIExecutor::defaultTimeoutInvoker,
::hermes::vm::RuntimeConfig runtimeConfig = ::hermes::vm::RuntimeConfig())
::hermes::vm::RuntimeConfig runtimeConfig = defaultRuntimeConfig())
: runtimeInstaller_(runtimeInstaller),
timeoutInvoker_(timeoutInvoker),
runtimeConfig_(std::move(runtimeConfig)) {
assert(timeoutInvoker_ && "Should not have empty timeoutInvoker");
}
void setEnableDebugger(bool enableDebugger);
void setDebuggerName(const std::string &debuggerName);
std::unique_ptr<JSExecutor> createJSExecutor(
std::shared_ptr<ExecutorDelegate> delegate,
std::shared_ptr<MessageQueueThread> jsQueue) override;
private:
static ::hermes::vm::RuntimeConfig defaultRuntimeConfig();
JSIExecutor::RuntimeInstaller runtimeInstaller_;
JSIScopedTimeoutInvoker timeoutInvoker_;
::hermes::vm::RuntimeConfig runtimeConfig_;
bool enableDebugger_ = true;
std::string debuggerName_ = "Hermes React Native";
};
class HermesExecutor : public JSIExecutor {
@@ -139,7 +139,7 @@ class Connection::Impl : public inspector::InspectorObserver,
template <typename C>
void runInExecutor(int id, C callback) {
folly::via(executor_.get(), [cb = std::move(callback)]() { cb(); });
executor_->add([cb = std::move(callback)]() { cb(); });
}
std::shared_ptr<RuntimeAdapter> runtimeAdapter_;
@@ -1411,20 +1411,14 @@ Connection::Impl::makePropsFromValue(
}
void Connection::Impl::handle(const m::runtime::GetHeapUsageRequest &req) {
auto resp = std::make_shared<m::runtime::GetHeapUsageResponse>();
resp->id = req.id;
inspector_
->executeIfEnabled(
"Runtime.getHeapUsage",
[this, req, resp](const debugger::ProgramState &state) {
auto heapInfo = getRuntime().instrumentation().getHeapInfo(false);
resp->usedSize = heapInfo["hermes_allocatedBytes"];
resp->totalSize = heapInfo["hermes_heapSize"];
})
.via(executor_.get())
.thenValue([this, resp](auto &&) { sendResponseToClient(*resp); })
.thenError<std::exception>(sendErrorToClient(req.id));
runInExecutor(req.id, [this, req]() {
auto heapInfo = getRuntime().instrumentation().getHeapInfo(false);
auto resp = std::make_shared<m::runtime::GetHeapUsageResponse>();
resp->id = req.id;
resp->usedSize = heapInfo["hermes_allocatedBytes"];
resp->totalSize = heapInfo["hermes_heapSize"];
sendResponseToClient(*resp);
});
}
void Connection::Impl::handle(const m::runtime::GetPropertiesRequest &req) {
@@ -244,8 +244,7 @@ void JSIExecutor::callFunction(
// by value.
auto errorProducer = [=] {
std::stringstream ss;
ss << "moduleID: " << moduleId << " methodID: " << methodId
<< " arguments: " << folly::toJson(arguments);
ss << "moduleID: " << moduleId << " methodID: " << methodId;
return ss.str();
};
@@ -28,7 +28,7 @@ target_link_libraries(rrc_progressbar
react_render_debug
react_render_graphics
react_render_uimanager
reactnativeutilsjni
reactnativejni
rrc_view
yoga
)
@@ -31,7 +31,7 @@ target_link_libraries(rrc_slider
react_render_imagemanager
react_render_mapbuffer
react_render_uimanager
reactnativeutilsjni
reactnativejni
rrc_image
rrc_view
yoga
@@ -28,7 +28,7 @@ target_link_libraries(
react_render_debug
react_render_graphics
react_render_uimanager
reactnativeutilsjni
reactnativejni
rrc_view
yoga
)
@@ -20,6 +20,15 @@
namespace facebook {
namespace react {
#ifdef ANDROID
// constants for Text State serialization
constexpr static MapBuffer::Key TX_STATE_KEY_ATTRIBUTED_STRING = 0;
constexpr static MapBuffer::Key TX_STATE_KEY_PARAGRAPH_ATTRIBUTES = 1;
// Used for TextInput only
constexpr static MapBuffer::Key TX_STATE_KEY_HASH = 2;
constexpr static MapBuffer::Key TX_STATE_KEY_MOST_RECENT_EVENT_COUNT = 3;
#endif
/*
* State for <Paragraph> component.
* Represents what to render and how to render.
@@ -26,21 +26,13 @@ inline folly::dynamic toDynamic(ParagraphState const &paragraphState) {
return newState;
}
// constants for Text State serialization
constexpr static MapBuffer::Key TX_STATE_KEY_ATTRIBUTED_STRING = 0;
constexpr static MapBuffer::Key TX_STATE_KEY_PARAGRAPH_ATTRIBUTES = 1;
// Used for TextInput
constexpr static MapBuffer::Key TX_STATE_KEY_HASH = 2;
constexpr static MapBuffer::Key TX_STATE_KEY_MOST_RECENT_EVENT_COUNT = 3;
inline MapBuffer toMapBuffer(ParagraphState const &paragraphState) {
auto builder = MapBufferBuilder();
auto attStringMapBuffer = toMapBuffer(paragraphState.attributedString);
builder.putMapBuffer(TX_STATE_KEY_ATTRIBUTED_STRING, attStringMapBuffer);
auto paMapBuffer = toMapBuffer(paragraphState.paragraphAttributes);
builder.putMapBuffer(TX_STATE_KEY_PARAGRAPH_ATTRIBUTES, paMapBuffer);
// TODO: Used for TextInput
builder.putInt(TX_STATE_KEY_HASH, 1234);
builder.putInt(TX_STATE_KEY_HASH, attStringMapBuffer.getInt(AS_KEY_HASH));
return builder.build();
}
#endif
@@ -10,6 +10,11 @@
#include <react/renderer/components/text/conversions.h>
#include <react/renderer/debug/debugStringConvertibleUtils.h>
#ifdef ANDROID
#include <react/renderer/mapbuffer/MapBuffer.h>
#include <react/renderer/mapbuffer/MapBufferBuilder.h>
#endif
#include <utility>
namespace facebook {
@@ -89,6 +94,23 @@ folly::dynamic AndroidTextInputState::getDynamic() const {
}
return newState;
}
MapBuffer AndroidTextInputState::getMapBuffer() const {
auto builder = MapBufferBuilder();
// See comment in getDynamic block.
if (cachedAttributedStringId == 0) {
builder.putInt(TX_STATE_KEY_MOST_RECENT_EVENT_COUNT, mostRecentEventCount);
auto attStringMapBuffer = toMapBuffer(attributedString);
builder.putMapBuffer(TX_STATE_KEY_ATTRIBUTED_STRING, attStringMapBuffer);
auto paMapBuffer = toMapBuffer(paragraphAttributes);
builder.putMapBuffer(TX_STATE_KEY_PARAGRAPH_ATTRIBUTES, paMapBuffer);
builder.putInt(TX_STATE_KEY_HASH, attStringMapBuffer.getInt(AS_KEY_HASH));
}
return builder.build();
}
#endif
} // namespace react
@@ -94,9 +94,7 @@ class AndroidTextInputState final {
AndroidTextInputState const &previousState,
folly::dynamic const &data);
folly::dynamic getDynamic() const;
MapBuffer getMapBuffer() const {
return MapBufferBuilder::EMPTY();
};
MapBuffer getMapBuffer() const;
};
} // namespace react
@@ -40,6 +40,6 @@ target_link_libraries(react_render_textlayoutmanager
react_render_telemetry
react_render_uimanager
react_utils
reactnativeutilsjni
reactnativejni
yoga
)
@@ -305,6 +305,50 @@ NSDictionary<NSAttributedStringKey, id> *RCTNSTextAttributesFromTextAttributes(T
return [attributes copy];
}
static void RCTApplyBaselineOffset(NSMutableAttributedString *attributedText)
{
__block CGFloat maximumLineHeight = 0;
[attributedText enumerateAttribute:NSParagraphStyleAttributeName
inRange:NSMakeRange(0, attributedText.length)
options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired
usingBlock:^(NSParagraphStyle *paragraphStyle, __unused NSRange range, __unused BOOL *stop) {
if (!paragraphStyle) {
return;
}
maximumLineHeight = MAX(paragraphStyle.maximumLineHeight, maximumLineHeight);
}];
if (maximumLineHeight == 0) {
// `lineHeight` was not specified, nothing to do.
return;
}
__block CGFloat maximumFontLineHeight = 0;
[attributedText enumerateAttribute:NSFontAttributeName
inRange:NSMakeRange(0, attributedText.length)
options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired
usingBlock:^(UIFont *font, NSRange range, __unused BOOL *stop) {
if (!font) {
return;
}
maximumFontLineHeight = MAX(font.lineHeight, maximumFontLineHeight);
}];
if (maximumLineHeight < maximumFontLineHeight) {
return;
}
CGFloat baseLineOffset = (maximumLineHeight - maximumFontLineHeight) / 2.0;
[attributedText addAttribute:NSBaselineOffsetAttributeName
value:@(baseLineOffset)
range:NSMakeRange(0, attributedText.length)];
}
NSAttributedString *RCTNSAttributedStringFromAttributedString(const AttributedString &attributedString)
{
static UIImage *placeholderImage;
@@ -357,7 +401,7 @@ NSAttributedString *RCTNSAttributedStringFromAttributedString(const AttributedSt
[nsAttributedString appendAttributedString:nsAttributedStringFragment];
}
RCTApplyBaselineOffset(nsAttributedString);
[nsAttributedString endEditing];
return nsAttributedString;
+1 -1
View File
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+2 -1
View File
@@ -128,11 +128,12 @@ jest
isGrayscaleEnabled: jest.fn(),
isInvertColorsEnabled: jest.fn(),
isReduceMotionEnabled: jest.fn(),
prefersCrossFadeTransitions: jest.fn(),
isReduceTransparencyEnabled: jest.fn(),
isScreenReaderEnabled: jest.fn(() => Promise.resolve(false)),
removeEventListener: jest.fn(),
setAccessibilityFocus: jest.fn(),
sendAccessibilityEvent_unstable: jest.fn(),
sendAccessibilityEvent: jest.fn(),
getRecommendedTimeoutMillis: jest.fn(),
},
}))
+53 -18
View File
@@ -1,7 +1,6 @@
{
"name": "react-native",
"private": true,
"version": "1000.0.0",
"version": "0.70.14",
"bin": "./cli.js",
"description": "A framework for building native apps using React",
"license": "MIT",
@@ -92,20 +91,17 @@
"test-android-instrumentation": "yarn run docker-build-android && yarn run test-android-run-instrumentation",
"test-android-unit": "yarn run docker-build-android && yarn run test-android-run-unit",
"test-android-e2e": "yarn run docker-build-android && yarn run test-android-run-e2e",
"test-ios": "./scripts/objc-test.sh test"
"test-ios": "./scripts/objc-test.sh test",
"trigger-react-native-release": "node ./scripts/trigger-react-native-release.js"
},
"workspaces": [
"packages/!(eslint-config-react-native-community)",
"repo-config"
],
"peerDependencies": {
"react": "18.1.0"
},
"dependencies": {
"@jest/create-cache-key-function": "^27.0.1",
"@react-native-community/cli": "^9.0.0-alpha.3",
"@react-native-community/cli-platform-android": "^9.0.0-alpha.3",
"@react-native-community/cli-platform-ios": "^9.0.0-alpha.3",
"@react-native-community/cli": "9.3.4",
"@react-native-community/cli-platform-android": "9.3.4",
"@react-native-community/cli-platform-ios": "9.3.0",
"@react-native/assets": "1.0.0",
"@react-native/normalize-color": "2.0.0",
"@react-native/polyfills": "2.0.0",
@@ -116,15 +112,15 @@
"invariant": "^2.2.4",
"jsc-android": "^250230.2.1",
"memoize-one": "^5.0.0",
"metro-react-native-babel-transformer": "0.71.3",
"metro-runtime": "0.71.3",
"metro-source-map": "0.71.3",
"metro-react-native-babel-transformer": "0.72.4",
"metro-runtime": "0.72.4",
"metro-source-map": "0.72.4",
"mkdirp": "^0.5.1",
"nullthrows": "^1.1.1",
"pretty-format": "^26.5.2",
"promise": "^8.0.3",
"promise": "^8.3.0",
"react-devtools-core": "4.24.0",
"react-native-gradle-plugin": "^0.70.0",
"react-native-gradle-plugin": "^0.70.3",
"react-refresh": "^0.4.0",
"react-shallow-renderer": "^16.15.0",
"regenerator-runtime": "^0.13.2",
@@ -132,13 +128,52 @@
"stacktrace-parser": "^0.1.3",
"use-sync-external-store": "^1.0.0",
"whatwg-fetch": "^3.0.0",
"ws": "^6.1.4"
"ws": "^6.1.4",
"react-native-codegen": "^0.70.7"
},
"devDependencies": {
"flow-bin": "^0.182.0",
"hermes-eslint": "0.8.0",
"react": "18.1.0",
"react-test-renderer": "^18.1.0"
"react-test-renderer": "18.1.0",
"@babel/core": "^7.14.0",
"@babel/eslint-parser": "^7.18.2",
"@babel/generator": "^7.14.0",
"@babel/plugin-transform-regenerator": "^7.0.0",
"@react-native-community/eslint-plugin": "*",
"@react-native/eslint-plugin-specs": "^0.70.0",
"@reactions/component": "^2.0.2",
"async": "^3.2.2",
"clang-format": "^1.2.4",
"connect": "^3.6.5",
"coveralls": "^3.1.1",
"eslint": "^7.32.0",
"eslint-config-fb-strict": "^26.0.0",
"eslint-config-fbjs": "^3.1.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-flowtype": "^7.0.0",
"eslint-plugin-jest": "^25.2.4",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.26.1",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-react-native": "^3.11.0",
"eslint-plugin-relay": "^1.8.2",
"inquirer": "^7.1.0",
"jest": "^26.6.3",
"jest-junit": "^10.0.0",
"jscodeshift": "^0.14.0",
"metro-babel-register": "0.72.4",
"metro-memory-fs": "0.72.4",
"mock-fs": "^5.1.4",
"mkdirp": "^0.5.1",
"prettier": "^2.4.1",
"shelljs": "^0.8.5",
"signedsource": "^1.0.0",
"ws": "^6.1.4",
"yargs": "^15.3.1"
},
"codegenConfig": {
"libraries": [
@@ -158,4 +193,4 @@
}
]
}
}
}
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@react-native/eslint-plugin-specs",
"version": "0.0.4",
"version": "0.70.0",
"description": "ESLint rules to validate NativeModule and Component Specs",
"main": "index.js",
"repository": {
@@ -9,7 +9,7 @@
"directory": "packages/eslint-plugin-specs"
},
"scripts": {
"prepublish": "node prepublish.js"
"prepack": "node prepack.js"
},
"dependencies": {
"@babel/core": "^7.14.0",
+1 -1
View File
@@ -13,7 +13,7 @@
const path = require('path');
const withBabelRegister = require('./with-babel-register');
// We run yarn prepublish before publishing package which will set this value to true
// We use the prepack hook before publishing package to set this value to true
const PACKAGE_USAGE = false;
const ERRORS = {
misnamedHasteModule(hasteModuleName) {
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "react-native-codegen",
"version": "0.70.3",
"version": "0.70.7",
"description": "⚛️ Code generation tools for React Native",
"homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/react-native-codegen",
"repository": {
@@ -20,7 +20,7 @@
"dependencies": {
"@babel/parser": "^7.14.0",
"flow-parser": "^0.121.0",
"jscodeshift": "^0.13.1",
"jscodeshift": "^0.14.0",
"nullthrows": "^1.1.1"
},
"devDependencies": {
@@ -27,7 +27,9 @@ function filterJSFile(file: string) {
// NativeSampleTurboModule is for demo purpose. It should be added manually to the
// app for now.
!file.endsWith('NativeSampleTurboModule.js') &&
!file.includes('__tests')
!file.includes('__tests') &&
// Ignore TypeScript type declaration files.
!file.endsWith('.d.ts')
);
}
@@ -75,7 +75,7 @@ module.exports = {
return null;
}
return Object.keys(components)
const componentTemplates = Object.keys(components)
.filter(componentName => {
const component = components[componentName];
return !(
@@ -91,6 +91,8 @@ module.exports = {
return replacedTemplate;
});
return componentTemplates.length > 0 ? componentTemplates : null;
})
.filter(Boolean);
})
@@ -1594,6 +1594,53 @@ const EXCLUDE_ANDROID_IOS: SchemaType = {
},
};
const EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES: SchemaType = {
modules: {
ComponentFile1: {
type: 'Component',
components: {
ExcludedIosComponent: {
excludedPlatforms: ['iOS'],
extendsProps: [
{
type: 'ReactNativeBuiltInType',
knownTypeName: 'ReactNativeCoreViewProps',
},
],
events: [],
props: [],
commands: [],
},
},
},
ComponentFile2: {
type: 'Component',
components: {
MultiFileIncludedNativeComponent: {
extendsProps: [
{
type: 'ReactNativeBuiltInType',
knownTypeName: 'ReactNativeCoreViewProps',
},
],
events: [],
props: [
{
name: 'disabled',
optional: true,
typeAnnotation: {
type: 'BooleanTypeAnnotation',
default: true,
},
},
],
commands: [],
},
},
},
},
};
module.exports = {
NO_PROPS_NO_EVENTS,
INTERFACE_ONLY,
@@ -1621,4 +1668,5 @@ module.exports = {
COMMANDS_AND_PROPS,
EXCLUDE_ANDROID,
EXCLUDE_ANDROID_IOS,
EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES,
};
@@ -336,6 +336,35 @@ using ExcludedAndroidIosComponentComponentDescriptor = ConcreteComponentDescript
}
`;
exports[`GenerateComponentDescriptorH can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
Map {
"ComponentDescriptors.h" => "
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateComponentDescriptorH.js
*/
#pragma once
#include <react/renderer/components/EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES/ShadowNodes.h>
#include <react/renderer/core/ConcreteComponentDescriptor.h>
namespace facebook {
namespace react {
using ExcludedIosComponentComponentDescriptor = ConcreteComponentDescriptor<ExcludedIosComponentShadowNode>;
using MultiFileIncludedNativeComponentComponentDescriptor = ConcreteComponentDescriptor<MultiFileIncludedNativeComponentShadowNode>;
} // namespace react
} // namespace facebook
",
}
`;
exports[`GenerateComponentDescriptorH can generate fixture FLOAT_PROPS 1`] = `
Map {
"ComponentDescriptors.h" => "
@@ -430,6 +430,31 @@ NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_END",
}
`;
exports[`GenerateComponentHObjCpp can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
Map {
"RCTComponentViewHelpers.h" => "/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateComponentHObjCpp.js
*/
#import <Foundation/Foundation.h>
#import <React/RCTDefines.h>
#import <React/RCTLog.h>
NS_ASSUME_NONNULL_BEGIN
@protocol RCTMultiFileIncludedNativeComponentViewProtocol <NSObject>
@end
NS_ASSUME_NONNULL_END",
}
`;
@@ -351,6 +351,32 @@ namespace react {
} // namespace react
} // namespace facebook
",
}
`;
exports[`GenerateEventEmitterCpp can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
Map {
"EventEmitters.cpp" => "
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateEventEmitterCpp.js
*/
#include <react/renderer/components/EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES/EventEmitters.h>
namespace facebook {
namespace react {
} // namespace react
} // namespace facebook
",
@@ -390,6 +390,33 @@ namespace react {
} // namespace react
} // namespace facebook
",
}
`;
exports[`GenerateEventEmitterH can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
Map {
"EventEmitters.h" => "
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateEventEmitterH.js
*/
#pragma once
#include <react/renderer/components/view/ViewEventEmitter.h>
#include <jsi/jsi.h>
namespace facebook {
namespace react {
} // namespace react
} // namespace facebook
",
@@ -412,6 +412,46 @@ ExcludedAndroidIosComponentProps::ExcludedAndroidIosComponentProps(
}
`;
exports[`GeneratePropsCpp can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
Map {
"Props.cpp" => "
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsCpp.js
*/
#include <react/renderer/components/EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES/Props.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/propsConversions.h>
namespace facebook {
namespace react {
ExcludedIosComponentProps::ExcludedIosComponentProps(
const PropsParserContext &context,
const ExcludedIosComponentProps &sourceProps,
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps)
{}
MultiFileIncludedNativeComponentProps::MultiFileIncludedNativeComponentProps(
const PropsParserContext &context,
const MultiFileIncludedNativeComponentProps &sourceProps,
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
disabled(convertRawProp(context, rawProps, \\"disabled\\", sourceProps.disabled, {true}))
{}
} // namespace react
} // namespace facebook
",
}
`;
exports[`GeneratePropsCpp can generate fixture FLOAT_PROPS 1`] = `
Map {
"Props.cpp" => "
@@ -660,6 +660,52 @@ class JSI_EXPORT ExcludedAndroidIosComponentProps final : public ViewProps {
}
`;
exports[`GeneratePropsH can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
Map {
"Props.h" => "
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsH.js
*/
#pragma once
#include <jsi/jsi.h>
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
namespace facebook {
namespace react {
class JSI_EXPORT ExcludedIosComponentProps final : public ViewProps {
public:
ExcludedIosComponentProps() = default;
ExcludedIosComponentProps(const PropsParserContext& context, const ExcludedIosComponentProps &sourceProps, const RawProps &rawProps);
#pragma mark - Props
};
class JSI_EXPORT MultiFileIncludedNativeComponentProps final : public ViewProps {
public:
MultiFileIncludedNativeComponentProps() = default;
MultiFileIncludedNativeComponentProps(const PropsParserContext& context, const MultiFileIncludedNativeComponentProps &sourceProps, const RawProps &rawProps);
#pragma mark - Props
bool disabled{true};
};
} // namespace react
} // namespace facebook
",
}
`;
exports[`GeneratePropsH can generate fixture FLOAT_PROPS 1`] = `
Map {
"Props.h" => "
@@ -436,6 +436,69 @@ exports[`GeneratePropsJavaDelegate can generate fixture EXCLUDE_ANDROID 1`] = `M
exports[`GeneratePropsJavaDelegate can generate fixture EXCLUDE_ANDROID_IOS 1`] = `Map {}`;
exports[`GeneratePropsJavaDelegate can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
Map {
"java/com/facebook/react/viewmanagers/ExcludedIosComponentManagerDelegate.java" => "/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsJavaDelegate.js
*/
package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
public class ExcludedIosComponentManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & ExcludedIosComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public ExcludedIosComponentManagerDelegate(U viewManager) {
super(viewManager);
}
@Override
public void setProperty(T view, String propName, @Nullable Object value) {
super.setProperty(view, propName, value);
}
}
",
"java/com/facebook/react/viewmanagers/MultiFileIncludedNativeComponentManagerDelegate.java" => "/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsJavaDelegate.js
*/
package com.facebook.react.viewmanagers;
import android.view.View;
import androidx.annotation.Nullable;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.BaseViewManagerInterface;
public class MultiFileIncludedNativeComponentManagerDelegate<T extends View, U extends BaseViewManagerInterface<T> & MultiFileIncludedNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public MultiFileIncludedNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
}
@Override
public void setProperty(T view, String propName, @Nullable Object value) {
switch (propName) {
case \\"disabled\\":
mViewManager.setDisabled(view, value == null ? true : (boolean) value);
break;
default:
super.setProperty(view, propName, value);
}
}
}
",
}
`;
exports[`GeneratePropsJavaDelegate can generate fixture FLOAT_PROPS 1`] = `
Map {
"java/com/facebook/react/viewmanagers/FloatPropNativeComponentManagerDelegate.java" => "/**
@@ -249,6 +249,45 @@ exports[`GeneratePropsJavaInterface can generate fixture EXCLUDE_ANDROID 1`] = `
exports[`GeneratePropsJavaInterface can generate fixture EXCLUDE_ANDROID_IOS 1`] = `Map {}`;
exports[`GeneratePropsJavaInterface can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
Map {
"java/com/facebook/react/viewmanagers/ExcludedIosComponentManagerInterface.java" => "/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsJavaInterface.js
*/
package com.facebook.react.viewmanagers;
import android.view.View;
public interface ExcludedIosComponentManagerInterface<T extends View> {
// No props
}
",
"java/com/facebook/react/viewmanagers/MultiFileIncludedNativeComponentManagerInterface.java" => "/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GeneratePropsJavaInterface.js
*/
package com.facebook.react.viewmanagers;
import android.view.View;
public interface MultiFileIncludedNativeComponentManagerInterface<T extends View> {
void setDisabled(T view, boolean value);
}
",
}
`;
exports[`GeneratePropsJavaInterface can generate fixture FLOAT_PROPS 1`] = `
Map {
"java/com/facebook/react/viewmanagers/FloatPropNativeComponentManagerInterface.java" => "/**
@@ -474,6 +474,52 @@ exports[`GeneratePropsJavaPojo can generate fixture EXCLUDE_ANDROID 1`] = `Map {
exports[`GeneratePropsJavaPojo can generate fixture EXCLUDE_ANDROID_IOS 1`] = `Map {}`;
exports[`GeneratePropsJavaPojo can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
Map {
"java/com/facebook/react/viewmanagers/ComponentFile1/ExcludedIosComponentProps.java" => "/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated by codegen project: GeneratePropsJavaPojo.js
*/
package com.facebook.react.viewmanagers.ComponentFile1;
import com.facebook.proguard.annotations.DoNotStrip;
@DoNotStrip
public class ExcludedIosComponentProps {
}
",
"java/com/facebook/react/viewmanagers/ComponentFile2/MultiFileIncludedNativeComponentProps.java" => "/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @generated by codegen project: GeneratePropsJavaPojo.js
*/
package com.facebook.react.viewmanagers.ComponentFile2;
import com.facebook.proguard.annotations.DoNotStrip;
@DoNotStrip
public class MultiFileIncludedNativeComponentProps {
private boolean mDisabled;
@DoNotStrip
public boolean getDisabled() {
return mDisabled;
}
}
",
}
`;
exports[`GeneratePropsJavaPojo can generate fixture FLOAT_PROPS 1`] = `
Map {
"java/com/facebook/react/viewmanagers/Switch/FloatPropNativeComponentProps.java" => "/**
@@ -300,6 +300,32 @@ extern const char ExcludedAndroidIosComponentComponentName[] = \\"ExcludedAndroi
}
`;
exports[`GenerateShadowNodeCpp can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
Map {
"ShadowNodes.cpp" => "
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateShadowNodeCpp.js
*/
#include <react/renderer/components/EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES/ShadowNodes.h>
namespace facebook {
namespace react {
extern const char ExcludedIosComponentComponentName[] = \\"ExcludedIosComponent\\";
extern const char MultiFileIncludedNativeComponentComponentName[] = \\"MultiFileIncludedNativeComponent\\";
} // namespace react
} // namespace facebook
",
}
`;
exports[`GenerateShadowNodeCpp can generate fixture FLOAT_PROPS 1`] = `
Map {
"ShadowNodes.cpp" => "
@@ -429,6 +429,51 @@ using ExcludedAndroidIosComponentShadowNode = ConcreteViewShadowNode<
}
`;
exports[`GenerateShadowNodeH can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
Map {
"ShadowNodes.h" => "
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateShadowNodeH.js
*/
#pragma once
#include <react/renderer/components/EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES/Props.h>
#include <react/renderer/components/view/ConcreteViewShadowNode.h>
#include <jsi/jsi.h>
namespace facebook {
namespace react {
JSI_EXPORT extern const char ExcludedIosComponentComponentName[];
/*
* \`ShadowNode\` for <ExcludedIosComponent> component.
*/
using ExcludedIosComponentShadowNode = ConcreteViewShadowNode<
ExcludedIosComponentComponentName,
ExcludedIosComponentProps>;
JSI_EXPORT extern const char MultiFileIncludedNativeComponentComponentName[];
/*
* \`ShadowNode\` for <MultiFileIncludedNativeComponent> component.
*/
using MultiFileIncludedNativeComponentShadowNode = ConcreteViewShadowNode<
MultiFileIncludedNativeComponentComponentName,
MultiFileIncludedNativeComponentProps>;
} // namespace react
} // namespace facebook
",
}
`;
exports[`GenerateShadowNodeH can generate fixture FLOAT_PROPS 1`] = `
Map {
"ShadowNodes.h" => "
@@ -486,6 +486,67 @@ TEST(ExcludedAndroidIosComponentProps_DoesNotDie, etc) {
}
`;
exports[`GenerateTests can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
Map {
"Tests.cpp" => "/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @generated by codegen project: GenerateTests.js
* */
#include <gtest/gtest.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/components/EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES/Props.h>
#include <react/renderer/core/RawProps.h>
#include <react/renderer/core/RawPropsParser.h>
#include <react/renderer/core/propsConversions.h>
using namespace facebook::react;
TEST(ExcludedIosComponentProps_DoesNotDie, etc) {
auto propParser = RawPropsParser();
propParser.prepare<ExcludedIosComponentProps>();
auto const &sourceProps = ExcludedIosComponentProps();
auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\"));
ContextContainer contextContainer{};
PropsParserContext parserContext{-1, contextContainer};
rawProps.parse(propParser, parserContext);
ExcludedIosComponentProps(parserContext, sourceProps, rawProps);
}
TEST(MultiFileIncludedNativeComponentProps_DoesNotDie, etc) {
auto propParser = RawPropsParser();
propParser.prepare<MultiFileIncludedNativeComponentProps>();
auto const &sourceProps = MultiFileIncludedNativeComponentProps();
auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\"));
ContextContainer contextContainer{};
PropsParserContext parserContext{-1, contextContainer};
rawProps.parse(propParser, parserContext);
MultiFileIncludedNativeComponentProps(parserContext, sourceProps, rawProps);
}
TEST(MultiFileIncludedNativeComponentProps_disabled, etc) {
auto propParser = RawPropsParser();
propParser.prepare<MultiFileIncludedNativeComponentProps>();
auto const &sourceProps = MultiFileIncludedNativeComponentProps();
auto const &rawProps = RawProps(folly::dynamic::object(\\"disabled\\", true));
ContextContainer contextContainer{};
PropsParserContext parserContext{-1, contextContainer};
rawProps.parse(propParser, parserContext);
MultiFileIncludedNativeComponentProps(parserContext, sourceProps, rawProps);
}",
}
`;
exports[`GenerateTests can generate fixture FLOAT_PROPS 1`] = `
Map {
"Tests.cpp" => "/**
@@ -51,6 +51,7 @@ Class<RCTComponentViewProtocol> CommandNativeComponentCls(void) __attribute__((u
Class<RCTComponentViewProtocol> CommandNativeComponentCls(void) __attribute__((used)); // COMMANDS_AND_PROPS
Class<RCTComponentViewProtocol> ExcludedAndroidComponentCls(void) __attribute__((used)); // EXCLUDE_ANDROID
Class<RCTComponentViewProtocol> MultiFileIncludedNativeComponentCls(void) __attribute__((used)); // EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES
#ifdef __cplusplus
}
@@ -74,6 +74,8 @@ Class<RCTComponentViewProtocol> RCTThirdPartyFabricComponentsProvider(const char
{\\"ExcludedAndroidComponent\\", ExcludedAndroidComponentCls}, // EXCLUDE_ANDROID
{\\"MultiFileIncludedNativeComponent\\", MultiFileIncludedNativeComponentCls}, // EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES
};
auto p = sFabricComponentsClassMap.find(name);
@@ -509,6 +509,50 @@ export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL
}
`;
exports[`GenerateViewConfigJs can generate fixture EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILES 1`] = `
Map {
"EXCLUDE_IOS_TWO_COMPONENTS_DIFFERENT_FILESNativeViewConfig.js" => "
/**
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
* @flow
*
* @generated by codegen project: GenerateViewConfigJs.js
*/
'use strict';
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'ExcludedIosComponent';
export const __INTERNAL_VIEW_CONFIG = {
uiViewClassName: 'ExcludedIosComponent',
validAttributes: {},
};
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
let nativeComponentName = 'MultiFileIncludedNativeComponent';
export const __INTERNAL_VIEW_CONFIG = {
uiViewClassName: 'MultiFileIncludedNativeComponent',
validAttributes: {
disabled: true,
},
};
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);
",
}
`;
exports[`GenerateViewConfigJs can generate fixture FLOAT_PROPS 1`] = `
Map {
"FLOAT_PROPSNativeViewConfig.js" => "
@@ -0,0 +1,22 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails oncall+react_native
* @format
*/
'use strict';
const {compareSnaps, compareTsArraySnaps} = require('../compareSnaps.js');
const flowFixtures = require('../../flow/components/__test_fixtures__/fixtures.js');
const flowSnaps = require('../../../../src/parsers/flow/components/__tests__/__snapshots__/component-parser-test.js.snap');
const tsFixtures = require('../../typescript/components/__test_fixtures__/fixtures.js');
const tsSnaps = require('../../../../src/parsers/typescript/components/__tests__/__snapshots__/typescript-component-parser-test.js.snap');
const tsExtraCases = ['ARRAY2_PROP_TYPES_NO_EVENTS'];
compareSnaps(flowFixtures, flowSnaps, [], tsFixtures, tsSnaps, tsExtraCases);
compareTsArraySnaps(tsSnaps, tsExtraCases);
@@ -0,0 +1,27 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails oncall+react_native
* @format
*/
'use strict';
const {compareSnaps, compareTsArraySnaps} = require('../compareSnaps.js');
const flowFixtures = require('../../flow/modules/__test_fixtures__/fixtures.js');
const flowSnaps = require('../../../../src/parsers/flow/modules/__tests__/__snapshots__/module-parser-snapshot-test.js.snap');
const tsFixtures = require('../../typescript/modules/__test_fixtures__/fixtures.js');
const tsSnaps = require('../../../../src/parsers/typescript/modules/__tests__/__snapshots__/typescript-module-parser-snapshot-test.js.snap');
const tsExtraCases = [
'NATIVE_MODULE_WITH_ARRAY2_WITH_ALIAS',
'NATIVE_MODULE_WITH_ARRAY2_WITH_UNION_AND_TOUPLE',
'NATIVE_MODULE_WITH_BASIC_ARRAY2',
'NATIVE_MODULE_WITH_COMPLEX_ARRAY2',
];
compareSnaps(flowFixtures, flowSnaps, [], tsFixtures, tsSnaps, tsExtraCases);
compareTsArraySnaps(tsSnaps, tsExtraCases);

Some files were not shown because too many files have changed in this diff Show More