Compare commits

..
Author SHA1 Message Date
Nicola Corti 5983edd21b Migrate ClipboardModuleTest to use BridgelessReactContext (#53131)
Summary:
This test was still using the old `BridgeReactContext`, I'm migrating it to `BridgelessReactContext`.

## Changelog:

[INTERNAL] -


Test Plan: CI

Reviewed By: mdvacca

Differential Revision: D79801564

Pulled By: cortinico
2025-08-07 09:35:26 -07:00
272 changed files with 4737 additions and 7438 deletions
@@ -0,0 +1,32 @@
name: setup-xcode-build-cache
description: Add caching to iOS jobs to speed up builds
inputs:
hermes-version:
description: The version of hermes
required: true
flavor:
description: The flavor that is going to be built
default: Debug
use-frameworks:
description: Whether we are bulding with DynamicFrameworks or StaticLibraries
default: StaticLibraries
ruby-version:
description: The ruby version we are going to use
default: 2.6.10
runs:
using: composite
steps:
- name: See commands.yml with_xcodebuild_cache
shell: bash
run: echo "See commands.yml with_xcodebuild_cache"
- name: Cache podfile lock
uses: actions/cache@v4
with:
path: packages/rn-tester/Podfile.lock
key: v13-podfilelock-${{ github.job }}-NewArch-${{ inputs.flavor }}-${{ inputs.use-frameworks }}-${{ inputs.ruby-version }}-${{ hashfiles('packages/rn-tester/Podfile') }}-${{ inputs.hermes-version }}
- name: Cache cocoapods
uses: actions/cache@v4
with:
path: packages/rn-tester/Pods
key: v15-cocoapods-${{ github.job }}-NewArch-${{ inputs.flavor }}-${{ inputs.use-frameworks }}-${{ inputs.ruby-version }}-${{ hashfiles('packages/rn-tester/Podfile.lock') }}-${{ hashfiles('packages/rn-tester/Podfile') }}-${{ inputs.hermes-version}}
@@ -102,6 +102,13 @@ runs:
- name: Print ReactCore folder
shell: bash
run: ls -lR /tmp/ReactCore
- name: Setup xcode build cache
uses: ./.github/actions/setup-xcode-build-cache
with:
hermes-version: ${{ inputs.hermes-version }}
use-frameworks: ${{ inputs.use-frameworks }}
flavor: ${{ inputs.flavor }}
ruby-version: ${{ inputs.ruby-version }}
- name: Install CocoaPods dependencies
shell: bash
run: |
@@ -46,7 +46,9 @@ describe('FirebaseClient', () => {
expect(client.password).toBe('testpassword');
expect(client.apiKey).toBe('test-api-key');
expect(client.projectId).toBe('test-project');
expect(client.databaseUrl).toBe('test-project.firebaseio.com');
expect(client.databaseUrl).toBe(
'test-project-default-rtdb.firebaseio.com',
);
expect(client.idToken).toBeNull();
});
});
@@ -228,7 +230,7 @@ describe('FirebaseClient', () => {
expect(result).toEqual(mockData);
expect(global.fetch).toHaveBeenCalledWith(
'https://test-project.firebaseio.com/nightly-results/2023-12-01.json?auth=existing-token',
'https://test-project-default-rtdb.firebaseio.com/nightly-results/2023-12-01.json?auth=existing-token',
{
method: 'GET',
headers: {
@@ -273,7 +275,7 @@ describe('FirebaseClient', () => {
await client.makeDatabaseRequest('2023-12-01', 'PUT', testData);
expect(global.fetch).toHaveBeenCalledWith(
'https://test-project.firebaseio.com/nightly-results/2023-12-01.json?auth=existing-token',
'https://test-project-default-rtdb.firebaseio.com/nightly-results/2023-12-01.json?auth=existing-token',
{
method: 'PUT',
headers: {
@@ -299,7 +301,7 @@ describe('FirebaseClient', () => {
await client.storeResults('2023-12-01', results);
expect(global.fetch).toHaveBeenCalledWith(
'https://test-project.firebaseio.com/nightly-results/2023-12-01.json?auth=existing-token',
'https://test-project-default-rtdb.firebaseio.com/nightly-results/2023-12-01.json?auth=existing-token',
{
method: 'PUT',
headers: {
+1 -1
View File
@@ -15,7 +15,7 @@ class FirebaseClient {
this.password = process.env.FIREBASE_APP_PASS;
this.apiKey = process.env.FIREBASE_APP_APIKEY;
this.projectId = process.env.FIREBASE_APP_PROJECTNAME;
this.databaseUrl = `${this.projectId}.firebaseio.com`;
this.databaseUrl = `${this.projectId}-default-rtdb.firebaseio.com`;
this.idToken = null;
}
+73 -20
View File
@@ -1,6 +1,71 @@
# Changelog
## v0.81.0
## v0.81.0-rc.5
### Fixed
#### Android specific
- **Runtime:** Fixed `ReactHostImpl.nativeModules` always returning an empty list ([2f46a49](https://github.com/facebook/react-native/commit/2f46a49b8d8a11d5cf4342eee83c469b545c6779) by [@lukmccall](https://github.com/lukmccall))
## v0.81.0-rc.4 - Burned
## v0.81.0-rc.3
### Changed
- **Metro:** Metro to ^0.83.1 ([e247be793c](https://github.com/facebook/react-native/commit/e247be793c70a374955d798d8cbbc6eba58080ec) by [@motiz88](https://github.com/motiz88))
### Fixed
#### Android specific
- **rngp:** Fix a race condition with codegen libraries missing sources ([9013a9e666](https://github.com/facebook/react-native/commit/9013a9e66629677c47e1b69703f9fc8f4cbc1c2c) by [@cortinico](https://github.com/cortinico))
- **API:** Make accessors inside HeadlessJsTaskService open again ([7ef57163cb](https://github.com/facebook/react-native/commit/7ef57163cb016317e43e563da7ea181989f6abca) by [@cortinico](https://github.com/cortinico))
## v0.81.0-rc.2
### Changed
- **API:** `NewAppScreen` no longer internally handles device safe area, use optional `safeAreaInsets` prop (aligned in 0.81 template) ([732bd12dc2](https://github.com/facebook/react-native/commit/732bd12dc21460641ef01b23f2eb722f26b060d5) by [@huntie](https://github.com/huntie))
- **Babel:** Added support to `react-native/babel-preset` for a `hermesParserOptions` option, that expects an object that enables overriding `hermes-parser` options. ([0508eddfe6](https://github.com/facebook/react-native/commit/0508eddfe60df60cb3bfa4074ae199bd0e492d5f) by [@yungsters](https://github.com/yungsters))
### Fixed
#### iOS specific
- **Podspec:** Fixed issue with RNDeps release/debug switch failing ([4ee2b60a1e](https://github.com/facebook/react-native/commit/4ee2b60a1eacca744d58a7ad336ca9d3714289f6) by [@chrfalch](https://github.com/chrfalch))
- **Podspec:** Fixed missing script for resolving prebuilt xcframework when switching between release/debug ([2e55241a90](https://github.com/facebook/react-native/commit/2e55241a901b4cd95917de68ce9078928820a208) by [@chrfalch](https://github.com/chrfalch))
## v0.81.0-rc.1
### Added
#### iOS specific
- **CocoaPods** Add the `ENTERPRISE_REPOSITORY` env variable to cocoapods infra ([23f3bf9239](https://github.com/facebook/react-native/commit/23f3bf9239a849590f1c72b25732d0090780128c) by [@cipolleschi](https://github.com/cipolleschi))
- **Prebuild:** Add release/debug switch script for React-Core-prebuilt ([42d1a7934c](https://github.com/facebook/react-native/commit/42d1a7934cad4b2c92653e3fa7781c2af8f44df4) by [@chrfalch](https://github.com/chrfalch))
- **Prebuild:** Added support for using USE_FRAMEWORKS with prebuilt React Native Core ([40e45f5366](https://github.com/facebook/react-native/commit/40e45f53661ce80c3a6fbbf07f52dc900afcad52) by [@chrfalch](https://github.com/chrfalch))
### Changed
- **Metro:** Bump Metro to 0.83.0 ([6b9f5d622f](https://github.com/facebook/react-native/commit/6b9f5d622ffbe79da8f4e7b7d8094504a480425e) by [@robhogan](https://github.com/robhogan))
#### Android specific
- **Gradle:** Gradle to 8.14.3 ([6892dde363](https://github.com/facebook/react-native/commit/6892dde36373bbef2d0afe535ae818b1a7164f08) by [@cortinico](https://github.com/cortinico))
- **Gradle:** Expose `react_renderer_bridging` headers via prefab ([d1730ff960](https://github.com/facebook/react-native/commit/d1730ff960fcb9a01ee94b9e46e5a9fbb7d73f4a) by [@tomekzaw](https://github.com/tomekzaw))
- **Legacy Arch:** Introduce more deprecation warnings for Legacy Arch classes ([625f69f284](https://github.com/facebook/react-native/commit/625f69f284ddfd9c6beecaa4052a871d092053ef) by [@cortinico](https://github.com/cortinico))
### Fixed
- **Yoga:** Fixed nodes with `display: contents` set being cloned with the wrong owner ([d4b36b0300](https://github.com/facebook/react-native/commit/d4b36b03003eb2de9eaf5b57bb639bae8cc12f20) by [@j-piasecki](https://github.com/j-piasecki))
#### iOS specific
- **Podspec:** Fixed premature return in header file generation from podspec globs ([f2b064c2d4](https://github.com/facebook/react-native/commit/f2b064c2d40c39017ac2a31bf3caf8acef23038c) by [@chrfalch](https://github.com/chrfalch))
## v0.81.0-rc.0
### Breaking
@@ -61,7 +126,6 @@
#### iOS specific
- **borderWidth:** Add support for different `borderWidth`s ([70962ef3ed](https://github.com/facebook/react-native/commit/70962ef3ed06a76a96cb2e72c374dc028628c829) by [@a-klotz-p8](https://github.com/a-klotz-p8))
- **CocoaPods:** Add the `ENTERPRISE_REPOSITORY` env variable to cocoapods infra ([23f3bf9239](https://github.com/facebook/react-native/commit/23f3bf9239a849590f1c72b25732d0090780128c) by [@cipolleschi](https://github.com/cipolleschi))
- **Modal:** Allow to interactively swipe down `Modal`s. ([28986a7599](https://github.com/facebook/react-native/commit/28986a7599952a77b8b8e433f72ca837afde310e) by [@okwasniewski](https://github.com/okwasniewski))
- **Package.swift:** Added missing search path to `Package.swift` ([592b09781b](https://github.com/facebook/react-native/commit/592b09781bb94fe6dc00ba49c7a86649980fed5d) by [@chrfalch](https://github.com/chrfalch))
- **Prebuild:** Add more logging around `computeNightlyTarballURL` in ios pre-build ([1a6887bd70](https://github.com/facebook/react-native/commit/1a6887bd70cdefb8fbc421467de841ece74d5c6b) by [@cortinico](https://github.com/cortinico))
@@ -72,17 +136,13 @@
- **Prebuild:** Added building `XCFframework` from the prebuild script ([55534f518a](https://github.com/facebook/react-native/commit/55534f518aab53bcdc3fe12d987ab7ef6e620c77) by [@chrfalch](https://github.com/chrfalch))
- **Prebuild:** Added building swift package from the prebuild script ([3c01b1b6f0](https://github.com/facebook/react-native/commit/3c01b1b6f04d285c97bb182131135903b0c1cdd5) by [@chrfalch](https://github.com/chrfalch))
- **Prebuild:** Added downloading of hermes artifacts when pre-building for iOS. ([41d2b5de0a](https://github.com/facebook/react-native/commit/41d2b5de0af21c72227ef030dcddf208e2eb221a) by [@chrfalch](https://github.com/chrfalch))
- **Prebuild:** Add release/debug switch script for React-Core-prebuilt ([42d1a7934c](https://github.com/facebook/react-native/commit/42d1a7934cad4b2c92653e3fa7781c2af8f44df4) by [@chrfalch](https://github.com/chrfalch))
- **Prebuild:** Added support for using USE_FRAMEWORKS with prebuilt React Native Core ([40e45f5366](https://github.com/facebook/react-native/commit/40e45f53661ce80c3a6fbbf07f52dc900afcad52) by [@chrfalch](https://github.com/chrfalch))
- **runtime:** Added `HERMES_ENABLE_DEBUGGER` to debug configuration for the `reactRuntime` target. ([560ac23001](https://github.com/facebook/react-native/commit/560ac23001b02f19d4c6ca4ea493c17060cfaf5f) by [@chrfalch](https://github.com/chrfalch))
### Changed
- **API:** `NewAppScreen` no longer internally handles device safe area, use optional `safeAreaInsets` prop (aligned in 0.81 template) ([732bd12dc2](https://github.com/facebook/react-native/commit/732bd12dc21460641ef01b23f2eb722f26b060d5) by [@huntie](https://github.com/huntie))
- **Animated:** Animated now always flattens `props.style`, which fixes an error that results from `props.style` objects in which `AnimatedNode` instances are shadowed (i.e. flattened to not exist in the resulting `props.style` object). ([da520848c9](https://github.com/facebook/react-native/commit/da520848c931f356d013623c412af11dce7ff114) by [@yungsters](https://github.com/yungsters))
- **Animated:** Creates a feature flag that changes `Animated` to no longer produce invalid `props.style` if every `AnimatedNode` instance is shadowed via style flattening. ([5c8c5388fc](https://github.com/facebook/react-native/commit/5c8c5388fc53ef2430b0bb6bbbc628479819e23d) by [@yungsters](https://github.com/yungsters))
- **Animated:** Enabled a feature flag that optimizes `Animated` to reduce memory usage. ([2a13d20085](https://github.com/facebook/react-native/commit/2a13d200850e4f161a29b252a0ccedc158e53937) by [@yungsters](https://github.com/yungsters))
- **Babel:** Added support to `react-native/babel-preset` for a `hermesParserOptions` option, that expects an object that enables overriding `hermes-parser` options. ([0508eddfe6](https://github.com/facebook/react-native/commit/0508eddfe60df60cb3bfa4074ae199bd0e492d5f) by [@yungsters](https://github.com/yungsters))
- **Error handling:** Errors will no longer have the "js engine" suffix. ([a293925280](https://github.com/facebook/react-native/commit/a2939252803d5cd4b68340da08820174c30a53e6) by [@yungsters](https://github.com/yungsters))
- **Fibers:** Reduces memory usage, by improving memory management of parent alternate fibers. (Previously, a parent fiber might retain memory associated with shadow nodes from a previous commit.) ([0411c43b3a](https://github.com/facebook/react-native/commit/0411c43b3a239384c778baad22c7b4c501008449) by [@yungsters](https://github.com/yungsters))
- **infoLog:** Removed `infoLog` from `react-native` package ([8a0cfec815](https://github.com/facebook/react-native/commit/8a0cfec81584e966c9e6ea0f5e438022e0129bcd) by [@coado](https://github.com/coado))
@@ -90,26 +150,24 @@
- **Jest:** Improved default mocking for Jest unit tests. ([1fd9508ecc](https://github.com/facebook/react-native/commit/1fd9508ecc499df89b086e0c46035f43f6f78ad9) by [@yungsters](https://github.com/yungsters))
- **LegacyArchitecture:** Raise loglevel for assertion of `LegacyArchitecture` classes ([38a4b62211](https://github.com/facebook/react-native/commit/38a4b6221164d36eb4ac95c9f3bc7f7e7235e383) by [@mdvacca](https://github.com/mdvacca))
- **LegacyArchitecture:** Raise logLevel of `LegacyArchitecture` classes when minimizing of legacy architecture is enabled ([0d1cde7f36](https://github.com/facebook/react-native/commit/0d1cde7f36e9de72c997fc812bba023694c2a369) by [@mdvacca](https://github.com/mdvacca))
- **Metro:** Metro to ^0.83.1 ([e247be793c](https://github.com/facebook/react-native/commit/e247be793c70a374955d798d8cbbc6eba58080ec) by [@motiz88](https://github.com/motiz88))
- **Metro:** Bump Metro to `^0.82.5` ([083644647e](https://github.com/facebook/react-native/commit/083644647eff502f484b3ba24f9d361d5df56546) by [@robhogan](https://github.com/robhogan))
- **React DevTools:** Bumped React DevTools to `6.1.5` ([c302902b1d](https://github.com/facebook/react-native/commit/c302902b1db7e8f8ac5b61472c095dc0755d6d1c) by [@hoxyq](https://github.com/hoxyq))
- **RuntimeExecutor:** `RuntimeExecutor`: Remove noexcept from sync ui thread utils ([7ef278af50](https://github.com/facebook/react-native/commit/7ef278af505deba6b8a47876c6824f9a7fefa427) by [@RSNara](https://github.com/RSNara))
- **Typescript:** Bump `types/react` to `19.1` ([3ae9328571](https://github.com/facebook/react-native/commit/3ae932857174e9c39cd5d9c53922f849aa1401b1) by [@gabrieldonadel](https://github.com/gabrieldonadel))
#### Android specific
- **Android SDK:** Updated targetSdk to 36 in Android. ([477d8df312](https://github.com/facebook/react-native/commit/477d8df3126b325b8cc9b410f1eaeb56b727d4d9) by [@kikoso](https://github.com/kikoso))
- **APIs:** Deprecate `DefaultNewArchitectureEntryPoint.load(Boolean, Boolean, Boolean)` ([efdf73983c](https://github.com/facebook/react-native/commit/efdf73983cef1f371511b6e1efa5e01835ebcabb) by [@cortinico](https://github.com/cortinico))
- **APIs:** Make `com.facebook.react.views.common.ContextUtils` internal ([d1ef8f1fa3](https://github.com/facebook/react-native/commit/d1ef8f1fa36cbfc34d05c409abf693e4e1cac3de) by [@cortinico](https://github.com/cortinico))
- **deps:** Bump `AGP` to `8.11.0` ([04858ecbab](https://github.com/facebook/react-native/commit/04858ecbab808ddca80e20e76f1359619bb5e865) by [@cortinico](https://github.com/cortinico))
- **deps:** Bump `Gradle` to 8.14.3 ([6892dde363](https://github.com/facebook/react-native/commit/6892dde36373bbef2d0afe535ae818b1a7164f08) by [@cortinico](https://github.com/cortinico))
- **Gradle:** Expose `react_renderer_bridging` headers via prefab ([d1730ff960](https://github.com/facebook/react-native/commit/d1730ff960fcb9a01ee94b9e46e5a9fbb7d73f4a) by [@tomekzaw](https://github.com/tomekzaw))
- **deps:** Bump `Gradle` to `8.14.2` ([e20bb56f3b](https://github.com/facebook/react-native/commit/e20bb56f3b4db0d3e69154b95b952b1fe8e29959) by [@cortinico](https://github.com/cortinico))
- **JS FPS:** Hide JS FPS on performance overlay as not accurate ([feec8d0148](https://github.com/facebook/react-native/commit/feec8d014877b2177f1c7dded7eb9664f53ee471) by [@cortinico](https://github.com/cortinico))
- Updated targetSdk to 36 in Android. ([477d8df312](https://github.com/facebook/react-native/commit/477d8df3126b325b8cc9b410f1eaeb56b727d4d9) by [@kikoso](https://github.com/kikoso))
- **Kotlin:** Convert `UIManagerModuleConstantsHelper` to Kotlin ([45fd7feb9f](https://github.com/facebook/react-native/commit/45fd7feb9f083e5c8afc916732aed9795d344e09) by [@cortinico](https://github.com/cortinico))
- **Kotlin:** Migrate `ThemedReactContext` to Kotlin ([78c9671c24](https://github.com/facebook/react-native/commit/78c9671c241a86bedb17862e549842b7e36d77ea) by [@cortinico](https://github.com/cortinico))
- **Kotlin:** Convert `ReactViewGroup` to Kotlin ([48395d346b](https://github.com/facebook/react-native/commit/48395d346bc89f63d38889e58508304df0088e4f) by [@cortinico](https://github.com/cortinico))
- **Kotlin:** Migrate `com.facebook.react.LazyReactPackage` to Kotlin. ([b4ae5c1de1](https://github.com/facebook/react-native/commit/b4ae5c1de1003c343d43c3be1b59ee2b800b9258) by [@Xintre](https://github.com/Xintre))
- **Kotlin:** Apply Collections Kotlin DSL helpers in `ReactAndroid` package ([b2ffd34a39](https://github.com/facebook/react-native/commit/b2ffd34a392de2bddba5ee13248796ccc2db6039) by [@l2hyunwoo](https://github.com/l2hyunwoo))
- **Legacy Arch:** Introduce more deprecation warnings for Legacy Arch classes ([625f69f284](https://github.com/facebook/react-native/commit/625f69f284ddfd9c6beecaa4052a871d092053ef) by [@cortinico](https://github.com/cortinico))
#### iOS specific
@@ -165,21 +223,19 @@
- **Typescript:** Add `ImageSource` type to TypeScript ([42ca46b95c](https://github.com/facebook/react-native/commit/42ca46b95cf9938de00b76dc61948a4ae7116e2b) by [@okwasniewski](https://github.com/okwasniewski))
- **Typescript:** Devtools TS Types ([8f189fce03](https://github.com/facebook/react-native/commit/8f189fce03db367abdceca6ad57ae28b613fdd7d) by [@krystofwoldrich](https://github.com/krystofwoldrich))
- **Yoga:** Fix possible invalid measurements with width or height is zero pixels ([5cc4d0a086](https://github.com/facebook/react-native/commit/5cc4d0a086d450e0f9d8ab6194013348f9de1f58) by [@NickGerleman](https://github.com/NickGerleman))
- **Yoga:** Fixed nodes with `display: contents` set being cloned with the wrong owner ([d4b36b0300](https://github.com/facebook/react-native/commit/d4b36b03003eb2de9eaf5b57bb639bae8cc12f20) by [@j-piasecki](https://github.com/j-piasecki))
#### Android specific
- **API:** Make accessors inside HeadlessJsTaskService open again ([7ef57163cb](https://github.com/facebook/react-native/commit/7ef57163cb016317e43e563da7ea181989f6abca) by [@cortinico](https://github.com/cortinico))
- **BaseViewManager:** Remove focus change listener when dropping/recycling view instances ([94cbf206d6](https://github.com/facebook/react-native/commit/94cbf206d607477257c65039d97565a79e94c7dd) by [@Abbondanzo](https://github.com/Abbondanzo))
- **BoringLayout:** Include fallback line spacing in `BoringLayout` ([2fe6c1a947](https://github.com/facebook/react-native/commit/2fe6c1a94758223a5342fdfa90163971eb588e6a) by [@NickGerleman](https://github.com/NickGerleman))
- **Bridgeless:** Adding `shouldForwardToReactInstance` check in `ReactDelegate` for Bridgeless ([0f7bf66bba](https://github.com/facebook/react-native/commit/0f7bf66bba8498c89384e96ad9219cdad0107b0c) by [@arushikesarwani94](https://github.com/arushikesarwani94))
- **Codegen:** Fix combining schema in Codegen process to exclude platforms correctly ([6104ccdc6e](https://github.com/facebook/react-native/commit/6104ccdc6ef89c2d4da25e60dcc55d73038e023f) by [@arushikesarwani94](https://github.com/arushikesarwani94))
- **Edge To Edge:** Fix `Dimensions` `window` values on Android < 15 when edge-to-edge is enabled ([85d10ed904](https://github.com/facebook/react-native/commit/85d10ed90401a13de1f74aeddd773736195da285) by [@zoontek](https://github.com/zoontek))
- **FBReactNativeSpec:** Extract out `FBReactNativeSpec`'s core components including Unimplemented from auto-generated registry ([b417b0c2d5](https://github.com/facebook/react-native/commit/b417b0c2d56dc37f824c0e77e98d1014d21cd8f8) by [@arushikesarwani94](https://github.com/arushikesarwani94))
- **Gradle:** Fix Gradle v8.0 builds by using .set() for Property ([777397667c](https://github.com/facebook/react-native/commit/777397667c2625aab3fc907b9ef4bd564963d8bb) by [@meghancampbel9](https://github.com/meghancampbel9))
- **ImageFetcher:** Change `free` to `delete` to call destructor of `ImageFetcher` and release `contextContainer`. ([90da666691](https://github.com/facebook/react-native/commit/90da666691745ab9bf3930dc3347d8e51683099f) by [@WoLewicki](https://github.com/WoLewicki))
- **Modal:** Fix `Modal` first frame being rendered on top-left corner ([b950fa2afb](https://github.com/facebook/react-native/commit/b950fa2afb20e2213ff6c733cb1c2465b90406ef) by [@cortinico](https://github.com/cortinico))
- **onTextLayout:** Fix `onTextLayout` metrics not incorporating `ReactTextViewManagerCallback` ([a6a2884d63](https://github.com/facebook/react-native/commit/a6a2884d63717a42ac2bafd2054991ce8b32a2e9) by [@NickGerleman](https://github.com/NickGerleman))
- **RNGP:** Fix a race condition with codegen libraries missing sources ([9013a9e666](https://github.com/facebook/react-native/commit/9013a9e66629677c47e1b69703f9fc8f4cbc1c2c) by [@cortinico](https://github.com/cortinico))
- **Runtime:** Fixed `ReactHostImpl.nativeModules` always returning an empty list ([2f46a49](https://github.com/facebook/react-native/commit/2f46a49b8d8a11d5cf4342eee83c469b545c6779) by [@lukmccall](https://github.com/lukmccall))
- **Text:** Fix more text rounding bugs ([1fe3ff86c3](https://github.com/facebook/react-native/commit/1fe3ff86c364fad023ad1e426f26608699314339) by [@NickGerleman](https://github.com/NickGerleman))
- **Text:** Fix `TextLayoutManager` `MeasureMode` Regression ([99119a2104](https://github.com/facebook/react-native/commit/99119a210487af18983145fd374ff7ebc88931f3) by [@NickGerleman](https://github.com/NickGerleman))
- **TextInput:** Fix bug where focus would jump to top text input upon clearing a separate text input. ([79c47987b7](https://github.com/facebook/react-native/commit/79c47987b74ab044574fc542fd4b13a9f11aa491) by [@joevilches](https://github.com/joevilches))
@@ -187,13 +243,10 @@
#### iOS specific
- **Gradient**: Gradient interpolation for transparent colors ([097d482446](https://github.com/facebook/react-native/commit/097d482446b7a03ca0f8c7e0254f4d770e05c79c) by [@intergalacticspacehighway](https://github.com/intergalacticspacehighway))
- **Package.swift:** Add missing `React-RCTSettings` to `Package.swift` ([e40c1d265a](https://github.com/facebook/react-native/commit/e40c1d265a2045730dcf751eed4ebf32e099f0c7) by [@chrfalch](https://github.com/chrfalch))
- **Package.swift:** Fixed defines in `Package.swift` ([e2f6ce4ddf](https://github.com/facebook/react-native/commit/e2f6ce4ddfbea5814fc5d8632df14daeae3636d1) by [@chrfalch](https://github.com/chrfalch))
- **Podspec:** Fixed premature return in header file generation from podspec globs ([f2b064c2d4](https://github.com/facebook/react-native/commit/f2b064c2d40c39017ac2a31bf3caf8acef23038c) by [@chrfalch](https://github.com/chrfalch))
- **Podspec:** Fixed issue with RNDeps release/debug switch failing ([4ee2b60a1e](https://github.com/facebook/react-native/commit/4ee2b60a1eacca744d58a7ad336ca9d3714289f6) by [@chrfalch](https://github.com/chrfalch))
- **Podspec:** Fixed missing script for resolving prebuilt xcframework when switching between release/debug ([2e55241a90](https://github.com/facebook/react-native/commit/2e55241a901b4cd95917de68ce9078928820a208) by [@chrfalch](https://github.com/chrfalch))
- **Prebuild:** Fixed wrong path in prebuild hermes check ([be11f2ee77](https://github.com/facebook/react-native/commit/be11f2ee77fd793efe0a1aa225897a1924163925) by [@chrfalch](https://github.com/chrfalch))
- **Prebuild:** Fixed resolving build type when downloading hermes artifacts ([9371e20192](https://github.com/facebook/react-native/commit/9371e201927fd105e797bf06e43943dd21e04381) by [@chrfalch](https://github.com/chrfalch))
- **Package.swift:** Add missing `React-RCTSettings` to `Package.swift` ([e40c1d265a](https://github.com/facebook/react-native/commit/e40c1d265a2045730dcf751eed4ebf32e099f0c7) by [@chrfalch](https://github.com/chrfalch))
- **Package.swift:** Fixed defines in `Package.swift` ([e2f6ce4ddf](https://github.com/facebook/react-native/commit/e2f6ce4ddfbea5814fc5d8632df14daeae3636d1) by [@chrfalch](https://github.com/chrfalch))
- **RCTImage:** Allow for consuming `RCTImage` in Swift codebase by enabling "Defines Module" option ([1d80586730](https://github.com/facebook/react-native/commit/1d8058673085580f402ec3a320fce810db7ad2ef) by [@kkafar](https://github.com/kkafar))
- **RCTImageComponentView:** Fix `RCTImageComponentView` image loading after source props change with no layout invalidation ([cd5d74518b](https://github.com/facebook/react-native/commit/cd5d74518becb3355519373211d2f54ff7dbd208) by Nick Lefever)
- **RCTScreenSize:** Make `RCTScreenSize` take horizontal orientation into account ([50ce8c77a7](https://github.com/facebook/react-native/commit/50ce8c77a74f2f2574030db04dc88c6092e68ba8) by [@okwasniewski](https://github.com/okwasniewski))
@@ -91,14 +91,7 @@ declare module 'tinybench' {
beforeEach?: (this: Task) => void | Promise<void>,
};
export interface FnReturnedObject {
overriddenDuration?: number;
}
export type Fn = () =>
| Promise<void | FnReturnedObject>
| void
| FnReturnedObject;
export type Fn = () => Promise<mixed> | mixed;
declare export class Bench extends EventTarget {
concurrency: null | 'task' | 'bench';
+2 -2
View File
@@ -75,7 +75,7 @@
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-ft-flow": "^2.0.1",
"eslint-plugin-jest": "^29.0.1",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-jsx-a11y": "^6.6.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-native": "^4.0.0",
@@ -110,7 +110,7 @@
"signedsource": "^1.0.0",
"supports-color": "^7.1.0",
"temp-dir": "^2.0.0",
"tinybench": "^4.1.0",
"tinybench": "^3.1.0",
"typescript": "5.8.3",
"ws": "^6.2.3"
},
@@ -1,58 +1,58 @@
#!/usr/bin/env dotslash
// @generated SignedSource<<14de73ea0ed751d80c7c687c6aeb123f>>
// @generated SignedSource<<686df5695b32a90cd465412d979a1a3f>>
{
"name": "React Native DevTools",
"platforms": {
"linux-aarch64": {
"size": 116120331,
"size": 113511487,
"hash": "sha256",
"digest": "5a1747bdb50f8140d96e99b31f9a603ceaf52e777e5dd59f65edacd87f8c6348",
"digest": "c22f7d5e029357f05055ce7c56cc284a0d441d558e103a7b7ebae118c67d0b95",
"providers": [
{
"type": "http",
"url": "https://scontent.xx.fbcdn.net/mci_ab/uap/?ab_b=m&ab_page=react_native_devtools_binaries&ab_entry=AQMRq1ou56GjpsIRFHpozEYiPfCuVvgWQVwiMMPBbwKyBnebit8HDGKof5XgDHbAKCqAZSgC8L22eJETnqIUM3kEAMYNXcHviIGy41rsXKVDYDgyWlGFB1zP2WzHrjWagfD062Pt4q5GqvCG5RVlhz656BOsutU7B4pDXGFCIdry7FveKn0PXGxvd1E"
"url": "https://scontent.xx.fbcdn.net/mci_ab/uap/?ab_b=m&ab_page=react_native_devtools_binaries&ab_entry=AQPRilWDJV8xyKEv9lqYn7Hf2kyZg6nqW8KctGZCXsU95lS_MTFyAmEULrB3J6hGCjqBY2Zl-uq_FjERAIgzbZFWX2eceacTbutBSOKEj6QTZzkVN_L1zPh2lGh24x29MHpkwUzw4E-kAXV43f-11QxqD7orI1QicyOnsmUqeRNKE_QjM9rNRsw6iE8"
}
],
"format": "tar.gz",
"path": "React Native DevTools-linux-arm64/React Native DevTools"
},
"linux-x86_64": {
"size": 116056146,
"size": 113244728,
"hash": "sha256",
"digest": "b48a3e392ac482de8058917879cf07fd5934dcb84aa901d4fe0d29273b503f54",
"digest": "d749aee18d6c969f033511ed631b439c578068cc20786974bc0ee707c6c2f177",
"providers": [
{
"type": "http",
"url": "https://scontent.xx.fbcdn.net/mci_ab/uap/?ab_b=m&ab_page=react_native_devtools_binaries&ab_entry=AQOyyb_LXrME2ubBGSkEi1vDw-2hwuHgHwnR-kAGQyhJK7lnELQDXKX1xW_u0joDwbTOhmiptwenq07G2NFkrY3t_AXefb_xTu2qHzpmrsX2YcwJlewbprgbuX7Uvdhqncb_IRAnJ4ogYKHUg6CZBNmLCQsyDsoqmkXtJ9ikJcQeDu2aiqbb-RWJ"
"url": "https://scontent.xx.fbcdn.net/mci_ab/uap/?ab_b=m&ab_page=react_native_devtools_binaries&ab_entry=AQP8NAAXjHJ-9NJThip1nnmVim4yiS1tdYAXmWl2Remiluq5f13nXA8YEadsmGRLWxXz2WJouHXSK47ea4a30fxewyKeTt0niFn3T-lr_91m3Ve5ZS-FOZ_9CRVCkv5zC-Z1FlXJGOnphfWetIU10Pw9tho3IzjdSNlXle0XTrkJ2AyKSl4cKPaX"
}
],
"format": "tar.gz",
"path": "React Native DevTools-linux-x64/React Native DevTools"
},
"macos-aarch64": {
"size": 110957864,
"size": 108805847,
"hash": "sha256",
"digest": "7964d83c857f12bb741abf4377771f3f3697b81df6283dd88d75ae43991afb73",
"digest": "dc4a6cfa3d2d8646db8793ef497e43ad72be54bb14ed96345d059880ff72ce1e",
"providers": [
{
"type": "http",
"url": "https://scontent.xx.fbcdn.net/mci_ab/uap/?ab_b=m&ab_page=react_native_devtools_binaries&ab_entry=AQM7USVzavWxZkjOO6CasnSfPIfE08jJAkwfVO0qWiYBli136vpzA_HS89ZqsIsAC_GXeT7K-K9BxdON7z5qBoRMUygAay7z4DGT5OZ9YSf9MDCd0JOzah5_6s3ijw2j4eeRu8ZNYzI3aTutDXtPMJAb2KfBHGx2lEiSW5YK9idcB5Y2boAWeDXXX5nb"
"url": "https://scontent.xx.fbcdn.net/mci_ab/uap/?ab_b=m&ab_page=react_native_devtools_binaries&ab_entry=AQPuZx9G4h30mUDM0hZ8y74LbzAi7-S6jnOqq8uyfDdIptLwIgpb8CKB8F2tduvaBFMGd7obwXd2NVy01r6XKVdgAK5-QTp8PYUPUE7VSCi6QAqobXcQ2uq_lY-jgyj8XkV4Ua4gA6KR609Bmh-beSTOrSqMymqVodaGqoGjB_9jVwfD99_PfFlex-Ta"
}
],
"format": "tar.gz",
"path": "React Native DevTools.app/Contents/MacOS/React Native DevTools"
},
"macos-x86_64": {
"size": 117827315,
"size": 113766610,
"hash": "sha256",
"digest": "bab2fac43def4a82fb88300aac05180eeda24f31cc00402a3ff7ca2e612bd532",
"digest": "74178859ce6a1c26c32055e192b1b123822c76c827ea86a6dfdb5463b89b1ace",
"providers": [
{
"type": "http",
"url": "https://scontent.xx.fbcdn.net/mci_ab/uap/?ab_b=m&ab_page=react_native_devtools_binaries&ab_entry=AQPYS0ZRQ7RV1S-yy3tut6pRqcKdPcOiKfekrA5AXdd_M-HDaXLwJS57iAFU2K2X-EA_cyg25C3L-5L7O3eyNKPMToZHbV282GiojnNSKFNjsjj9_B737lOwHI_XqbDQEIiNJZ7NjbkZ8_iMKK-LNL-Ydha2ORWWqytuzP4sWQ6sm0XIxsdyQ6bOLw"
"url": "https://scontent.xx.fbcdn.net/mci_ab/uap/?ab_b=m&ab_page=react_native_devtools_binaries&ab_entry=AQN6DjGhr8_L7N_cwrh8pi3cfNcbn9dot_QQpgwe3Vv-780FDgi6JUeMvbo_wbFoT2rogxfHZ0-NbXbKdWYwhGUoGeQuikT57QnVMOYuPUTjlQUgYy0Ng9XPhq3iSEYwlMV1XsUJuPFRUg-hIHcgaaA55JoTLXZ1fLYydhHnmgRxGHc4pxaHvSpTtQ"
}
],
"format": "tar.gz",
+2 -2
View File
@@ -27,11 +27,11 @@
"license": "MIT",
"engines": {
"node": ">= 20.19.4",
"electron": ">=37.2.4"
"electron": ">=36.3.0"
},
"dependencies": {
"cross-spawn": "^7.0.6",
"electron": "37.2.4"
"electron": "36.3.0"
},
"devDependencies": {
"semver": "^7.1.3"
@@ -28,7 +28,7 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-eslint-comments": "^3.2.0",
"eslint-plugin-ft-flow": "^2.0.1",
"eslint-plugin-jest": "^29.0.1",
"eslint-plugin-jest": "^27.9.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^5.2.0",
"eslint-plugin-react-native": "^4.0.0"
@@ -29,6 +29,7 @@ import com.facebook.react.utils.JdkConfiguratorUtils.configureJavaToolChains
import com.facebook.react.utils.JsonUtils
import com.facebook.react.utils.NdkConfiguratorUtils.configureReactNativeNdk
import com.facebook.react.utils.ProjectUtils.needsCodegenFromPackageJson
import com.facebook.react.utils.PropertyUtils
import com.facebook.react.utils.findPackageJsonFile
import java.io.File
import kotlin.system.exitProcess
@@ -42,6 +43,7 @@ import org.gradle.internal.jvm.Jvm
class ReactPlugin : Plugin<Project> {
override fun apply(project: Project) {
checkJvmVersion(project)
checkLegacyArchProperty(project)
val extension = project.extensions.create("react", ReactExtension::class.java, project)
// We register a private extension on the rootProject so that project wide configs
@@ -114,6 +116,30 @@ class ReactPlugin : Plugin<Project> {
}
}
private fun checkLegacyArchProperty(project: Project) {
if ((project.hasProperty(PropertyUtils.NEW_ARCH_ENABLED) &&
!project.property(PropertyUtils.NEW_ARCH_ENABLED).toString().toBoolean()) ||
(project.hasProperty(PropertyUtils.SCOPED_NEW_ARCH_ENABLED) &&
!project.property(PropertyUtils.SCOPED_NEW_ARCH_ENABLED).toString().toBoolean())) {
project.logger.error(
"""
********************************************************************************
WARNING: Setting `newArchEnabled=false` in your `gradle.properties` file is not
supported anymore since React Native 0.82.
You can remove the line from your `gradle.properties` file.
The application will run with the New Architecture enabled by default.
********************************************************************************
"""
.trimIndent())
}
}
/** This function configures Android resources - in this case just the bundle */
private fun configureResources(project: Project, reactExtension: ReactExtension) {
project.extensions.getByType(ApplicationAndroidComponentsExtension::class.java).finalizeDsl {
@@ -7,10 +7,8 @@
package com.facebook.react
import com.facebook.react.utils.PropertyUtils
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.plugin.extraProperties
/**
* Gradle plugin applied to the `android/build.gradle` file.
@@ -20,25 +18,13 @@ import org.jetbrains.kotlin.gradle.plugin.extraProperties
*/
class ReactRootProjectPlugin : Plugin<Project> {
override fun apply(project: Project) {
checkLegacyArchProperty(project)
project.subprojects { subproject ->
project.subprojects {
// As the :app project (i.e. ReactPlugin) configures both namespaces and JVM toolchains
// for libraries, its evaluation must happen before the libraries' evaluation.
// Eventually the configuration of namespace/JVM toolchain can be moved inside this plugin.
if (subproject.path != ":app") {
subproject.evaluationDependsOn(":app")
if (it.path != ":app") {
it.evaluationDependsOn(":app")
}
// We set the New Architecture properties to true for all subprojects. So that
// libraries don't need to be modified and can keep on using the isNewArchEnabled()
// function to check if property is set.
if (subproject.hasProperty(PropertyUtils.SCOPED_NEW_ARCH_ENABLED)) {
subproject.setProperty(PropertyUtils.SCOPED_NEW_ARCH_ENABLED, "true")
}
if (subproject.hasProperty(PropertyUtils.NEW_ARCH_ENABLED)) {
subproject.setProperty(PropertyUtils.NEW_ARCH_ENABLED, "true")
}
subproject.extraProperties.set(PropertyUtils.NEW_ARCH_ENABLED, "true")
subproject.extraProperties.set(PropertyUtils.SCOPED_NEW_ARCH_ENABLED, "true")
}
// We need to make sure that `:app:preBuild` task depends on all other subprojects' preBuild
// tasks. This is necessary in order to have all the codegen generated code before the CMake
@@ -57,27 +43,4 @@ class ReactRootProjectPlugin : Plugin<Project> {
}
}
}
private fun checkLegacyArchProperty(project: Project) {
if ((project.hasProperty(PropertyUtils.NEW_ARCH_ENABLED) &&
!project.property(PropertyUtils.NEW_ARCH_ENABLED).toString().toBoolean()) ||
(project.hasProperty(PropertyUtils.SCOPED_NEW_ARCH_ENABLED) &&
!project.property(PropertyUtils.SCOPED_NEW_ARCH_ENABLED).toString().toBoolean())) {
project.logger.error(
"""
********************************************************************************
WARNING: Setting `newArchEnabled=false` in your `gradle.properties` file is not
supported anymore since React Native 0.82.
You can remove the line from your `gradle.properties` file.
The application will run with the New Architecture enabled by default.
********************************************************************************
"""
.trimIndent())
}
}
}
@@ -717,7 +717,7 @@ InterfaceOnlyNativeComponentViewProps::InterfaceOnlyNativeComponentViewProps(
const InterfaceOnlyNativeComponentViewProps &sourceProps,
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
title(convertRawProp(context, rawProps, \\"title\\", sourceProps.title, {std::string{\\"\\"}})) {}
title(convertRawProp(context, rawProps, \\"title\\", sourceProps.title, {\\"\\"})) {}
#ifdef RN_SERIALIZABLE_STATE
ComponentName InterfaceOnlyNativeComponentViewProps::getDiffPropsImplementationTarget() const {
@@ -1060,7 +1060,7 @@ StringPropNativeComponentViewProps::StringPropNativeComponentViewProps(
const StringPropNativeComponentViewProps &sourceProps,
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
placeholder(convertRawProp(context, rawProps, \\"placeholder\\", sourceProps.placeholder, {std::string{\\"\\"}})),
placeholder(convertRawProp(context, rawProps, \\"placeholder\\", sourceProps.placeholder, {\\"\\"})),
defaultValue(convertRawProp(context, rawProps, \\"defaultValue\\", sourceProps.defaultValue, {})) {}
#ifdef RN_SERIALIZABLE_STATE
@@ -18,7 +18,6 @@ Object {
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/graphicsConversions.h>
#include <react/renderer/core/propsConversions.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/Color.h>
#include <react/renderer/graphics/Point.h>
#include <react/renderer/graphics/RectangleEdges.h>
@@ -90,7 +89,6 @@ static inline std::string toString(const ArrayPropsNativeComponentViewSizesMaskW
struct ArrayPropsNativeComponentViewObjectStruct {
std::string prop{};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ArrayPropsNativeComponentViewObjectStruct&) const = default;
@@ -135,7 +133,6 @@ struct ArrayPropsNativeComponentViewArrayOfObjectsStruct {
Float prop1{0.0};
int prop2{0};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ArrayPropsNativeComponentViewArrayOfObjectsStruct&) const = default;
@@ -206,8 +203,6 @@ class ArrayPropsNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -230,7 +225,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -249,8 +243,6 @@ class BooleanPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -273,7 +265,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/Color.h>
namespace facebook::react {
@@ -292,8 +283,6 @@ class ColorPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -317,7 +306,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/graphicsConversions.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <yoga/Yoga.h>
namespace facebook::react {
@@ -336,8 +324,6 @@ class DimensionPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -360,7 +346,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -378,8 +363,6 @@ class EdgeInsetsPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -402,7 +385,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -486,8 +468,6 @@ class EnumPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -510,7 +490,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -528,8 +507,6 @@ class EventNestedObjectPropsNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -552,7 +529,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -570,8 +546,6 @@ class EventPropsNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -594,7 +568,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -618,8 +591,6 @@ class FloatPropsNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -642,7 +613,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/imagemanager/primitives.h>
namespace facebook::react {
@@ -661,8 +631,6 @@ class ImagePropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -685,7 +653,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -705,8 +672,6 @@ class IntegerPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -729,7 +694,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -740,15 +704,13 @@ class InterfaceOnlyNativeComponentViewProps final : public ViewProps {
#pragma mark - Props
std::string title{std::string{\\"\\"}};
std::string title{\\"\\"};
#ifdef RN_SERIALIZABLE_STATE
ComponentName getDiffPropsImplementationTarget() const override;
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -771,7 +733,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -789,8 +750,6 @@ class MixedPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -813,7 +772,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/Color.h>
#include <react/renderer/graphics/Point.h>
#include <react/renderer/imagemanager/primitives.h>
@@ -837,8 +795,6 @@ class MultiNativePropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -861,7 +817,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -879,8 +834,6 @@ class NoPropsNoEventsNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -905,7 +858,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/propsConversions.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/Color.h>
#include <react/renderer/graphics/Point.h>
#include <react/renderer/imagemanager/primitives.h>
@@ -966,14 +918,13 @@ static inline folly::dynamic toDynamic(const ObjectPropsNativeComponentIntEnumPr
}
#endif
struct ObjectPropsNativeComponentObjectPropStruct {
std::string stringProp{std::string{\\"\\"}};
std::string stringProp{\\"\\"};
bool booleanProp{false};
Float floatProp{0.0};
int intProp{0};
ObjectPropsNativeComponentStringEnumProp stringEnumProp{ObjectPropsNativeComponentStringEnumProp::Small};
ObjectPropsNativeComponentIntEnumProp intEnumProp{ObjectPropsNativeComponentIntEnumProp::IntEnumProp0};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ObjectPropsNativeComponentObjectPropStruct&) const = default;
@@ -1032,7 +983,6 @@ static inline folly::dynamic toDynamic(const ObjectPropsNativeComponentObjectPro
struct ObjectPropsNativeComponentObjectArrayPropStruct {
std::vector<std::string> array{};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ObjectPropsNativeComponentObjectArrayPropStruct&) const = default;
@@ -1068,7 +1018,6 @@ struct ObjectPropsNativeComponentObjectPrimitiveRequiredPropStruct {
SharedColor color{};
Point point{};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ObjectPropsNativeComponentObjectPrimitiveRequiredPropStruct&) const = default;
@@ -1124,8 +1073,6 @@ class ObjectPropsNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -1148,7 +1095,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/Point.h>
namespace facebook::react {
@@ -1167,8 +1113,6 @@ class PointPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -1191,7 +1135,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -1202,7 +1145,7 @@ class StringPropNativeComponentViewProps final : public ViewProps {
#pragma mark - Props
std::string placeholder{std::string{\\"\\"}};
std::string placeholder{\\"\\"};
std::string defaultValue{};
#ifdef RN_SERIALIZABLE_STATE
@@ -1210,8 +1153,6 @@ class StringPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -20,7 +20,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class ArrayPropsNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ArrayPropsNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public ArrayPropsNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -95,7 +94,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class BooleanPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & BooleanPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public BooleanPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -138,7 +136,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class ColorPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ColorPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public ColorPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -178,7 +175,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class DimensionPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & DimensionPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public DimensionPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -217,7 +213,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class EdgeInsetsPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & EdgeInsetsPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public EdgeInsetsPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -250,7 +245,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class EnumPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & EnumPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public EnumPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -292,7 +286,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class EventNestedObjectPropsNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & EventNestedObjectPropsNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public EventNestedObjectPropsNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -331,7 +324,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class EventPropsNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & EventPropsNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public EventPropsNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -370,7 +362,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class FloatPropsNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & FloatPropsNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public FloatPropsNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -428,7 +419,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class ImagePropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ImagePropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public ImagePropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -467,7 +457,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class IntegerPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & IntegerPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public IntegerPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -512,7 +501,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class InterfaceOnlyNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & InterfaceOnlyNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public InterfaceOnlyNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -552,7 +540,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class MixedPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & MixedPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public MixedPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -593,7 +580,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class MultiNativePropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & MultiNativePropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public MultiNativePropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -641,7 +627,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class NoPropsNoEventsNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & NoPropsNoEventsNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public NoPropsNoEventsNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -675,7 +660,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class ObjectPropsNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ObjectPropsNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public ObjectPropsNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -721,7 +705,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class PointPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & PointPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public PointPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -760,7 +743,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class StringPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & StringPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public StringPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -717,7 +717,7 @@ InterfaceOnlyNativeComponentViewProps::InterfaceOnlyNativeComponentViewProps(
const InterfaceOnlyNativeComponentViewProps &sourceProps,
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
title(convertRawProp(context, rawProps, \\"title\\", sourceProps.title, {std::string{\\"\\"}})) {}
title(convertRawProp(context, rawProps, \\"title\\", sourceProps.title, {\\"\\"})) {}
#ifdef RN_SERIALIZABLE_STATE
ComponentName InterfaceOnlyNativeComponentViewProps::getDiffPropsImplementationTarget() const {
@@ -1060,7 +1060,7 @@ StringPropNativeComponentViewProps::StringPropNativeComponentViewProps(
const StringPropNativeComponentViewProps &sourceProps,
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
placeholder(convertRawProp(context, rawProps, \\"placeholder\\", sourceProps.placeholder, {std::string{\\"\\"}})),
placeholder(convertRawProp(context, rawProps, \\"placeholder\\", sourceProps.placeholder, {\\"\\"})),
defaultValue(convertRawProp(context, rawProps, \\"defaultValue\\", sourceProps.defaultValue, {})) {}
#ifdef RN_SERIALIZABLE_STATE
@@ -18,7 +18,6 @@ Object {
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/graphicsConversions.h>
#include <react/renderer/core/propsConversions.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/Color.h>
#include <react/renderer/graphics/Point.h>
#include <react/renderer/graphics/RectangleEdges.h>
@@ -90,7 +89,6 @@ static inline std::string toString(const ArrayPropsNativeComponentViewSizesMaskW
struct ArrayPropsNativeComponentViewObjectStruct {
std::string prop{};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ArrayPropsNativeComponentViewObjectStruct&) const = default;
@@ -135,7 +133,6 @@ struct ArrayPropsNativeComponentViewArrayOfObjectsStruct {
Float prop1{0.0};
int prop2{0};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ArrayPropsNativeComponentViewArrayOfObjectsStruct&) const = default;
@@ -206,8 +203,6 @@ class ArrayPropsNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -230,7 +225,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -249,8 +243,6 @@ class BooleanPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -273,7 +265,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/Color.h>
namespace facebook::react {
@@ -292,8 +283,6 @@ class ColorPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -317,7 +306,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/graphicsConversions.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <yoga/Yoga.h>
namespace facebook::react {
@@ -336,8 +324,6 @@ class DimensionPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -360,7 +346,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -378,8 +363,6 @@ class EdgeInsetsPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -402,7 +385,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -486,8 +468,6 @@ class EnumPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -510,7 +490,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -528,8 +507,6 @@ class EventNestedObjectPropsNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -552,7 +529,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -570,8 +546,6 @@ class EventPropsNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -594,7 +568,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -618,8 +591,6 @@ class FloatPropsNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -642,7 +613,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/imagemanager/primitives.h>
namespace facebook::react {
@@ -661,8 +631,6 @@ class ImagePropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -685,7 +653,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -705,8 +672,6 @@ class IntegerPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -729,7 +694,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -740,15 +704,13 @@ class InterfaceOnlyNativeComponentViewProps final : public ViewProps {
#pragma mark - Props
std::string title{std::string{\\"\\"}};
std::string title{\\"\\"};
#ifdef RN_SERIALIZABLE_STATE
ComponentName getDiffPropsImplementationTarget() const override;
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -771,7 +733,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -789,8 +750,6 @@ class MixedPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -813,7 +772,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/Color.h>
#include <react/renderer/graphics/Point.h>
#include <react/renderer/imagemanager/primitives.h>
@@ -837,8 +795,6 @@ class MultiNativePropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -861,7 +817,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -879,8 +834,6 @@ class NoPropsNoEventsNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -905,7 +858,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/propsConversions.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/Color.h>
#include <react/renderer/graphics/Point.h>
#include <react/renderer/imagemanager/primitives.h>
@@ -966,14 +918,13 @@ static inline folly::dynamic toDynamic(const ObjectPropsNativeComponentIntEnumPr
}
#endif
struct ObjectPropsNativeComponentObjectPropStruct {
std::string stringProp{std::string{\\"\\"}};
std::string stringProp{\\"\\"};
bool booleanProp{false};
Float floatProp{0.0};
int intProp{0};
ObjectPropsNativeComponentStringEnumProp stringEnumProp{ObjectPropsNativeComponentStringEnumProp::Small};
ObjectPropsNativeComponentIntEnumProp intEnumProp{ObjectPropsNativeComponentIntEnumProp::IntEnumProp0};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ObjectPropsNativeComponentObjectPropStruct&) const = default;
@@ -1032,7 +983,6 @@ static inline folly::dynamic toDynamic(const ObjectPropsNativeComponentObjectPro
struct ObjectPropsNativeComponentObjectArrayPropStruct {
std::vector<std::string> array{};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ObjectPropsNativeComponentObjectArrayPropStruct&) const = default;
@@ -1068,7 +1018,6 @@ struct ObjectPropsNativeComponentObjectPrimitiveRequiredPropStruct {
SharedColor color{};
Point point{};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ObjectPropsNativeComponentObjectPrimitiveRequiredPropStruct&) const = default;
@@ -1124,8 +1073,6 @@ class ObjectPropsNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -1148,7 +1095,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/Point.h>
namespace facebook::react {
@@ -1167,8 +1113,6 @@ class PointPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -1191,7 +1135,6 @@ Object {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -1202,7 +1145,7 @@ class StringPropNativeComponentViewProps final : public ViewProps {
#pragma mark - Props
std::string placeholder{std::string{\\"\\"}};
std::string placeholder{\\"\\"};
std::string defaultValue{};
#ifdef RN_SERIALIZABLE_STATE
@@ -1210,8 +1153,6 @@ class StringPropNativeComponentViewProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -20,7 +20,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class ArrayPropsNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ArrayPropsNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public ArrayPropsNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -95,7 +94,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class BooleanPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & BooleanPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public BooleanPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -138,7 +136,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class ColorPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ColorPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public ColorPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -178,7 +175,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class DimensionPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & DimensionPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public DimensionPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -217,7 +213,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class EdgeInsetsPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & EdgeInsetsPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public EdgeInsetsPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -250,7 +245,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class EnumPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & EnumPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public EnumPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -292,7 +286,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class EventNestedObjectPropsNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & EventNestedObjectPropsNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public EventNestedObjectPropsNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -331,7 +324,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class EventPropsNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & EventPropsNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public EventPropsNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -370,7 +362,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class FloatPropsNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & FloatPropsNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public FloatPropsNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -428,7 +419,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class ImagePropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ImagePropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public ImagePropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -467,7 +457,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class IntegerPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & IntegerPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public IntegerPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -512,7 +501,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class InterfaceOnlyNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & InterfaceOnlyNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public InterfaceOnlyNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -552,7 +540,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class MixedPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & MixedPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public MixedPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -593,7 +580,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class MultiNativePropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & MultiNativePropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public MultiNativePropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -641,7 +627,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class NoPropsNoEventsNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & NoPropsNoEventsNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public NoPropsNoEventsNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -675,7 +660,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class ObjectPropsNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ObjectPropsNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public ObjectPropsNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -721,7 +705,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class PointPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & PointPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public PointPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -760,7 +743,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class StringPropNativeComponentViewManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & StringPropNativeComponentViewManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public StringPropNativeComponentViewManagerDelegate(U viewManager) {
super(viewManager);
@@ -46,17 +46,9 @@ try {
} catch (err) {
throw new Error(`Can't parse schema to JSON. ${schemaPath}`);
}
const includeGetDebugPropsImplementation: boolean =
libraryName.includes('FBReactNativeSpec');
RNCodegen.generate(
{
libraryName,
schema,
outputDirectory,
packageName,
assumeNonnull,
includeGetDebugPropsImplementation,
},
{libraryName, schema, outputDirectory, packageName, assumeNonnull},
{
generators: [
'descriptors',
@@ -81,7 +81,6 @@ export type GenerateFunction = (
packageName?: string,
assumeNonnull: boolean,
headerPrefix?: string,
includeGetDebugPropsImplementation?: boolean,
) => FilesOutput;
export type LibraryGeneratorsFunctions = $ReadOnly<{
@@ -95,7 +94,6 @@ export type LibraryOptions = $ReadOnly<{
packageName?: string, // Some platforms have a notion of package, which should be configurable.
assumeNonnull: boolean,
useLocalIncludePaths?: boolean,
includeGetDebugPropsImplementation?: boolean,
libraryGenerators?: LibraryGeneratorsFunctions,
}>;
@@ -257,7 +255,6 @@ module.exports = {
packageName,
assumeNonnull,
useLocalIncludePaths,
includeGetDebugPropsImplementation = false,
libraryGenerators = LIBRARY_GENERATORS,
}: LibraryOptions,
{generators, test}: LibraryConfig,
@@ -302,7 +299,6 @@ module.exports = {
packageName,
assumeNonnull,
headerPrefix,
includeGetDebugPropsImplementation,
).forEach((contents: string, fileName: string) => {
generatedFiles.push({
name: fileName,
@@ -190,7 +190,7 @@ function convertDefaultTypeToString(
if (typeAnnotation.default == null) {
return '';
}
return `std::string{"${typeAnnotation.default}"}`;
return `"${typeAnnotation.default}"`;
case 'Int32TypeAnnotation':
return String(typeAnnotation.default);
case 'DoubleTypeAnnotation':
@@ -61,7 +61,6 @@ module.exports = {
packageName?: string,
assumeNonnull: boolean = false,
headerPrefix?: string,
includeGetDebugPropsImplementation?: boolean = false,
): FilesOutput {
const fileName = 'ComponentDescriptors.cpp';
@@ -63,7 +63,6 @@ module.exports = {
packageName?: string,
assumeNonnull: boolean = false,
headerPrefix?: string,
includeGetDebugPropsImplementation?: boolean = false,
): FilesOutput {
const fileName = 'ComponentDescriptors.h';
@@ -381,7 +381,6 @@ module.exports = {
packageName?: string,
assumeNonnull: boolean = false,
headerPrefix?: string,
includeGetDebugPropsImplementation?: boolean = false,
): FilesOutput {
const fileName = 'RCTComponentViewHelpers.h';
@@ -413,7 +413,6 @@ module.exports = {
packageName?: string,
assumeNonnull: boolean = false,
headerPrefix?: string,
includeGetDebugPropsImplementation?: boolean = false,
): FilesOutput {
const moduleComponents: ComponentCollection = Object.keys(schema.modules)
.map(moduleName => {
@@ -320,7 +320,6 @@ module.exports = {
packageName?: string,
assumeNonnull: boolean = false,
headerPrefix?: string,
includeGetDebugPropsImplementation?: boolean = false,
): FilesOutput {
const moduleComponents: ComponentCollection = Object.keys(schema.modules)
.map(moduleName => {
@@ -77,8 +77,6 @@ function generatePropsDiffString(
className: string,
componentName: string,
component: ComponentShape,
debugProps: string = '',
includeGetDebugPropsImplementation?: boolean = false,
) {
const diffProps = component.props
.map(prop => {
@@ -136,12 +134,6 @@ function generatePropsDiffString(
})
.join('\n' + ' ');
const getDebugPropsString = `#if RN_DEBUG_STRING_CONVERTIBLE
SharedDebugStringConvertibleList ${className}::getDebugProps() const {
return ViewProps::getDebugProps()${debugProps && debugProps.length > 0 ? ` +\n\t\tSharedDebugStringConvertibleList{${debugProps}\n\t}` : ''};
}
#endif`;
return `
#ifdef RN_SERIALIZABLE_STATE
ComponentName ${className}::getDiffPropsImplementationTarget() const {
@@ -161,11 +153,8 @@ folly::dynamic ${className}::getDiffProps(
${diffProps}
return result;
}
#endif
${includeGetDebugPropsImplementation ? getDebugPropsString : ''}
`;
#endif`;
}
function generatePropsString(componentName: string, component: ComponentShape) {
return component.props
.map(prop => {
@@ -181,24 +170,6 @@ function generatePropsString(componentName: string, component: ComponentShape) {
.join(',\n' + ' ');
}
function generateDebugPropsString(
componentName: string,
component: ComponentShape,
) {
return component.props
.map(prop => {
if (prop.typeAnnotation.type === 'ObjectTypeAnnotation') {
// Skip ObjectTypeAnnotation because there is no generic `toString`
// method for it. We would have to define an interface that the structs implement.
return '';
}
const defaultValue = convertDefaultTypeToString(componentName, prop);
return `\n\t\t\tdebugStringConvertibleItem("${prop.name}", ${prop.name}${defaultValue ? `, ${defaultValue}` : ''})`;
})
.join(',');
}
function getClassExtendString(component: ComponentShape): string {
const extendString =
' ' +
@@ -231,7 +202,6 @@ module.exports = {
packageName?: string,
assumeNonnull: boolean = false,
headerPrefix?: string,
includeGetDebugPropsImplementation?: boolean = false,
): FilesOutput {
const fileName = 'Props.cpp';
const allImports: Set<string> = new Set([
@@ -239,13 +209,6 @@ module.exports = {
'#include <react/renderer/core/PropsParserContext.h>',
]);
if (includeGetDebugPropsImplementation) {
allImports.add('#include <react/renderer/core/graphicsConversions.h>');
allImports.add(
'#include <react/renderer/debug/debugStringConvertibleUtils.h>',
);
}
const componentProps = Object.keys(schema.modules)
.map(moduleName => {
const module = schema.modules[moduleName];
@@ -266,15 +229,10 @@ module.exports = {
const propsString = generatePropsString(componentName, component);
const extendString = getClassExtendString(component);
const debugProps = includeGetDebugPropsImplementation
? generateDebugPropsString(componentName, component)
: '';
const diffPropsString = generatePropsDiffString(
newName,
componentName,
component,
debugProps,
includeGetDebugPropsImplementation,
);
const imports = getImports(component.props);
@@ -65,20 +65,14 @@ const ClassTemplate = ({
className,
props,
extendClasses,
includeGetDebugPropsImplementation,
}: {
enums: string,
structs: string,
className: string,
props: string,
extendClasses: string,
includeGetDebugPropsImplementation: boolean,
}) => {
const getDebugPropsString = `#if RN_DEBUG_STRING_CONVERTIBLE
SharedDebugStringConvertibleList getDebugProps() const override;
#endif`;
return `
}) =>
`
${enums}
${structs}
class ${className} final${extendClasses} {
@@ -95,11 +89,8 @@ class ${className} final${extendClasses} {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
${includeGetDebugPropsImplementation ? getDebugPropsString : ''}
};
`.trim();
};
const EnumTemplate = ({
enumName,
@@ -187,7 +178,6 @@ const StructTemplate = ({
`struct ${structName} {
${fields}
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ${structName}&) const = default;
@@ -546,7 +536,6 @@ function getExtendsImports(
const imports: Set<string> = new Set();
imports.add('#include <react/renderer/core/PropsParserContext.h>');
imports.add('#include <react/renderer/debug/DebugStringConvertible.h>');
extendsProps.forEach(extendProps => {
switch (extendProps.type) {
@@ -794,7 +783,6 @@ module.exports = {
packageName?: string,
assumeNonnull: boolean = false,
headerPrefix?: string,
includeGetDebugPropsImplementation?: boolean = false,
): FilesOutput {
const fileName = 'Props.h';
@@ -843,7 +831,6 @@ module.exports = {
className: newName,
extendClasses: extendString,
props: propsString,
includeGetDebugPropsImplementation,
});
return replacedTemplate;
@@ -55,7 +55,6 @@ package ${packageName};
${imports}
@SuppressWarnings("deprecation")
public class ${className}<T extends ${extendClasses}, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ${interfaceClassName}<T>> extends BaseViewManagerDelegate<T, U> {
public ${className}(U viewManager) {
super(viewManager);
@@ -300,7 +299,6 @@ module.exports = {
packageName?: string,
assumeNonnull: boolean = false,
headerPrefix?: string,
includeGetDebugPropsImplementation?: boolean = false,
): FilesOutput {
// TODO: This doesn't support custom package name yet.
const normalizedPackageName = 'com.facebook.react.viewmanagers';
@@ -238,7 +238,6 @@ module.exports = {
packageName?: string,
assumeNonnull: boolean = false,
headerPrefix?: string,
includeGetDebugPropsImplementation?: boolean = false,
): FilesOutput {
// TODO: This doesn't support custom package name yet.
const normalizedPackageName = 'com.facebook.react.viewmanagers';
@@ -54,7 +54,6 @@ module.exports = {
packageName?: string,
assumeNonnull: boolean = false,
headerPrefix?: string,
includeGetDebugPropsImplementation?: boolean = false,
): FilesOutput {
const fileName = 'ShadowNodes.cpp';
@@ -74,7 +74,6 @@ module.exports = {
packageName?: string,
assumeNonnull: boolean = false,
headerPrefix?: string,
includeGetDebugPropsImplementation?: boolean = false,
): FilesOutput {
const fileName = 'ShadowNodes.h';
@@ -50,7 +50,6 @@ module.exports = {
packageName?: string,
assumeNonnull: boolean = false,
headerPrefix?: string,
includeGetDebugPropsImplementation?: boolean = false,
): FilesOutput {
const fileName = 'States.cpp';
@@ -57,7 +57,6 @@ module.exports = {
packageName?: string,
assumeNonnull: boolean = false,
headerPrefix?: string,
includeGetDebugPropsImplementation?: boolean = false,
): FilesOutput {
const fileName = 'States.h';
@@ -347,7 +347,7 @@ CommandNativeComponentProps::CommandNativeComponentProps(
const CommandNativeComponentProps &sourceProps,
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
accessibilityHint(convertRawProp(context, rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {std::string{\\"\\"}})) {}
accessibilityHint(convertRawProp(context, rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {\\"\\"})) {}
#ifdef RN_SERIALIZABLE_STATE
ComponentName CommandNativeComponentProps::getDiffPropsImplementationTarget() const {
@@ -1168,7 +1168,7 @@ InterfaceOnlyComponentProps::InterfaceOnlyComponentProps(
const InterfaceOnlyComponentProps &sourceProps,
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
accessibilityHint(convertRawProp(context, rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {std::string{\\"\\"}})) {}
accessibilityHint(convertRawProp(context, rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {\\"\\"})) {}
#ifdef RN_SERIALIZABLE_STATE
ComponentName InterfaceOnlyComponentProps::getDiffPropsImplementationTarget() const {
@@ -1554,7 +1554,7 @@ StringPropComponentProps::StringPropComponentProps(
const StringPropComponentProps &sourceProps,
const RawProps &rawProps): ViewProps(context, sourceProps, rawProps),
accessibilityHint(convertRawProp(context, rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {std::string{\\"\\"}})),
accessibilityHint(convertRawProp(context, rawProps, \\"accessibilityHint\\", sourceProps.accessibilityHint, {\\"\\"})),
accessibilityRole(convertRawProp(context, rawProps, \\"accessibilityRole\\", sourceProps.accessibilityRole, {})) {}
#ifdef RN_SERIALIZABLE_STATE
@@ -18,7 +18,6 @@ Map {
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/graphicsConversions.h>
#include <react/renderer/core/propsConversions.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/Color.h>
#include <react/renderer/graphics/Point.h>
#include <react/renderer/imagemanager/primitives.h>
@@ -87,8 +86,7 @@ static inline std::string toString(const ArrayPropsNativeComponentSizesMaskWrapp
return result;
}
struct ArrayPropsNativeComponentObjectStruct {
std::string stringProp{std::string{\\"\\"}};
std::string stringProp{\\"\\"};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ArrayPropsNativeComponentObjectStruct&) const = default;
@@ -131,8 +129,7 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
struct ArrayPropsNativeComponentArrayObjectStruct {
std::string stringProp{std::string{\\"\\"}};
std::string stringProp{\\"\\"};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ArrayPropsNativeComponentArrayObjectStruct&) const = default;
@@ -177,7 +174,6 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
struct ArrayPropsNativeComponentArrayStruct {
std::vector<ArrayPropsNativeComponentArrayObjectStruct> object{};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ArrayPropsNativeComponentArrayStruct&) const = default;
@@ -219,8 +215,7 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
struct ArrayPropsNativeComponentArrayOfArrayOfObjectStruct {
std::string stringProp{std::string{\\"\\"}};
std::string stringProp{\\"\\"};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ArrayPropsNativeComponentArrayOfArrayOfObjectStruct&) const = default;
@@ -291,8 +286,6 @@ class ArrayPropsNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -317,7 +310,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/propsConversions.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/Color.h>
#include <react/renderer/graphics/Point.h>
#include <react/renderer/imagemanager/primitives.h>
@@ -330,7 +322,6 @@ struct ArrayPropsNativeComponentNativePrimitivesStruct {
std::vector<ImageSource> srcs{};
std::vector<Point> points{};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ArrayPropsNativeComponentNativePrimitivesStruct&) const = default;
@@ -394,8 +385,6 @@ class ArrayPropsNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -418,7 +407,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -436,8 +424,6 @@ class BooleanPropNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -460,7 +446,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/Color.h>
namespace facebook::react {
@@ -479,8 +464,6 @@ class ColorPropNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -503,7 +486,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -521,8 +503,6 @@ class CommandNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -545,7 +525,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -556,15 +535,13 @@ class CommandNativeComponentProps final : public ViewProps {
#pragma mark - Props
std::string accessibilityHint{std::string{\\"\\"}};
std::string accessibilityHint{\\"\\"};
#ifdef RN_SERIALIZABLE_STATE
ComponentName getDiffPropsImplementationTarget() const override;
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -588,7 +565,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/graphicsConversions.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <yoga/Yoga.h>
namespace facebook::react {
@@ -607,8 +583,6 @@ class DimensionPropNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -631,7 +605,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -654,8 +627,6 @@ class DoublePropNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -678,7 +649,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -696,8 +666,6 @@ class EventsNestedObjectNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -720,7 +688,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -738,8 +705,6 @@ class EventsNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -762,7 +727,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -780,8 +744,6 @@ class InterfaceOnlyComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -804,7 +766,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -822,8 +783,6 @@ class ExcludedAndroidComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -846,7 +805,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -864,8 +822,6 @@ class ExcludedAndroidIosComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -888,7 +844,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -906,8 +861,6 @@ class ExcludedIosComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
class MultiFileIncludedNativeComponentProps final : public ViewProps {
@@ -924,8 +877,6 @@ class MultiFileIncludedNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -948,7 +899,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -971,8 +921,6 @@ class FloatPropNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -995,7 +943,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/imagemanager/primitives.h>
namespace facebook::react {
@@ -1014,8 +961,6 @@ class ImagePropNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -1038,7 +983,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/RectangleEdges.h>
namespace facebook::react {
@@ -1057,8 +1001,6 @@ class InsetsPropNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -1081,7 +1023,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -1136,8 +1077,6 @@ class Int32EnumPropsNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -1160,7 +1099,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -1180,8 +1118,6 @@ class IntegerPropNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -1204,7 +1140,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -1215,15 +1150,13 @@ class InterfaceOnlyComponentProps final : public ViewProps {
#pragma mark - Props
std::string accessibilityHint{std::string{\\"\\"}};
std::string accessibilityHint{\\"\\"};
#ifdef RN_SERIALIZABLE_STATE
ComponentName getDiffPropsImplementationTarget() const override;
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -1246,7 +1179,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -1264,8 +1196,6 @@ class MixedPropNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -1288,7 +1218,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/Color.h>
#include <react/renderer/graphics/Point.h>
#include <react/renderer/imagemanager/primitives.h>
@@ -1312,8 +1241,6 @@ class ImageColorPropNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -1336,7 +1263,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -1354,8 +1280,6 @@ class NoPropsNoEventsComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -1380,7 +1304,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/core/propsConversions.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/Color.h>
#include <react/renderer/graphics/Point.h>
#include <react/renderer/imagemanager/primitives.h>
@@ -1436,7 +1359,6 @@ static inline folly::dynamic toDynamic(const ObjectPropsIntEnumProp &value) {
struct ObjectPropsObjectPropObjectArrayPropStruct {
std::vector<std::string> array{};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ObjectPropsObjectPropObjectArrayPropStruct&) const = default;
@@ -1472,7 +1394,6 @@ struct ObjectPropsObjectPropObjectPrimitiveRequiredPropStruct {
SharedColor color{};
Point point{};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ObjectPropsObjectPropObjectPrimitiveRequiredPropStruct&) const = default;
@@ -1514,8 +1435,7 @@ static inline folly::dynamic toDynamic(const ObjectPropsObjectPropObjectPrimitiv
#endif
struct ObjectPropsObjectPropNestedPropANestedPropBStruct {
std::string nestedPropC{std::string{\\"\\"}};
std::string nestedPropC{\\"\\"};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ObjectPropsObjectPropNestedPropANestedPropBStruct&) const = default;
@@ -1550,7 +1470,6 @@ static inline folly::dynamic toDynamic(const ObjectPropsObjectPropNestedPropANes
struct ObjectPropsObjectPropNestedPropAStruct {
ObjectPropsObjectPropNestedPropANestedPropBStruct nestedPropB{};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ObjectPropsObjectPropNestedPropAStruct&) const = default;
@@ -1582,8 +1501,7 @@ static inline folly::dynamic toDynamic(const ObjectPropsObjectPropNestedPropAStr
#endif
struct ObjectPropsObjectPropNestedArrayAsPropertyArrayPropStruct {
std::string stringProp{std::string{\\"\\"}};
std::string stringProp{\\"\\"};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ObjectPropsObjectPropNestedArrayAsPropertyArrayPropStruct&) const = default;
@@ -1628,7 +1546,6 @@ static inline void fromRawValue(const PropsParserContext& context, const RawValu
struct ObjectPropsObjectPropNestedArrayAsPropertyStruct {
std::vector<ObjectPropsObjectPropNestedArrayAsPropertyArrayPropStruct> arrayProp{};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ObjectPropsObjectPropNestedArrayAsPropertyStruct&) const = default;
@@ -1660,11 +1577,11 @@ static inline folly::dynamic toDynamic(const ObjectPropsObjectPropNestedArrayAsP
#endif
struct ObjectPropsObjectPropStruct {
std::string stringProp{std::string{\\"\\"}};
std::string stringProp{\\"\\"};
bool booleanProp{false};
Float floatProp{0.0};
int intProp{0};
std::string stringUserDefaultProp{std::string{\\"user_default\\"}};
std::string stringUserDefaultProp{\\"user_default\\"};
bool booleanUserDefaultProp{true};
Float floatUserDefaultProp{3.14};
int intUserDefaultProp{9999};
@@ -1675,7 +1592,6 @@ struct ObjectPropsObjectPropStruct {
ObjectPropsObjectPropNestedPropAStruct nestedPropA{};
ObjectPropsObjectPropNestedArrayAsPropertyStruct nestedArrayAsProperty{};
#ifdef RN_SERIALIZABLE_STATE
bool operator==(const ObjectPropsObjectPropStruct&) const = default;
@@ -1784,8 +1700,6 @@ class ObjectPropsProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -1808,7 +1722,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
#include <react/renderer/graphics/Point.h>
namespace facebook::react {
@@ -1827,8 +1740,6 @@ class PointPropNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -1851,7 +1762,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -1893,8 +1803,6 @@ class StringEnumPropsNativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -1917,7 +1825,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -1928,7 +1835,7 @@ class StringPropComponentProps final : public ViewProps {
#pragma mark - Props
std::string accessibilityHint{std::string{\\"\\"}};
std::string accessibilityHint{\\"\\"};
std::string accessibilityRole{};
#ifdef RN_SERIALIZABLE_STATE
@@ -1936,8 +1843,6 @@ class StringPropComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -1960,7 +1865,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -1978,8 +1882,6 @@ class MultiFile1NativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
class MultiFile2NativeComponentProps final : public ViewProps {
@@ -1996,8 +1898,6 @@ class MultiFile2NativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -2020,7 +1920,6 @@ Map {
#include <react/renderer/components/view/ViewProps.h>
#include <react/renderer/core/PropsParserContext.h>
#include <react/renderer/debug/DebugStringConvertible.h>
namespace facebook::react {
@@ -2038,8 +1937,6 @@ class MultiComponent1NativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
class MultiComponent2NativeComponentProps final : public ViewProps {
@@ -2056,8 +1953,6 @@ class MultiComponent2NativeComponentProps final : public ViewProps {
folly::dynamic getDiffProps(const Props* prevProps) const override;
#endif
};
} // namespace facebook::react
@@ -20,7 +20,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class ArrayPropsNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ArrayPropsNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public ArrayPropsNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -96,7 +95,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class ArrayPropsNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ArrayPropsNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public ArrayPropsNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -135,7 +133,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class BooleanPropNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & BooleanPropNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public BooleanPropNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -175,7 +172,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class ColorPropNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ColorPropNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public ColorPropNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -215,7 +211,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class CommandNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & CommandNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public CommandNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -261,7 +256,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class CommandNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & CommandNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public CommandNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -316,7 +310,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class DimensionPropNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & DimensionPropNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public DimensionPropNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -355,7 +348,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class DoublePropNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & DoublePropNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public DoublePropNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -409,7 +401,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class EventsNestedObjectNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & EventsNestedObjectNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public EventsNestedObjectNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -448,7 +439,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class EventsNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & EventsNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public EventsNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -487,7 +477,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class InterfaceOnlyComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & InterfaceOnlyComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public InterfaceOnlyComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -524,7 +513,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class ExcludedIosComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ExcludedIosComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public ExcludedIosComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -552,7 +540,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class MultiFileIncludedNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & MultiFileIncludedNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public MultiFileIncludedNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -591,7 +578,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class FloatPropNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & FloatPropNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public FloatPropNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -646,7 +632,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class ImagePropNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ImagePropNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public ImagePropNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -686,7 +671,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class InsetsPropNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & InsetsPropNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public InsetsPropNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -725,7 +709,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class Int32EnumPropsNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & Int32EnumPropsNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public Int32EnumPropsNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -764,7 +747,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class IntegerPropNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & IntegerPropNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public IntegerPropNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -809,7 +791,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class InterfaceOnlyComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & InterfaceOnlyComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public InterfaceOnlyComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -849,7 +830,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class MixedPropNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & MixedPropNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public MixedPropNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -890,7 +870,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class ImageColorPropNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ImageColorPropNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public ImageColorPropNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -938,7 +917,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class NoPropsNoEventsComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & NoPropsNoEventsComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public NoPropsNoEventsComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -972,7 +950,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class ObjectPropsManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & ObjectPropsManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public ObjectPropsManagerDelegate(U viewManager) {
super(viewManager);
@@ -1012,7 +989,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class PointPropNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & PointPropNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public PointPropNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -1051,7 +1027,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class StringEnumPropsNativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & StringEnumPropsNativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public StringEnumPropsNativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -1090,7 +1065,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class StringPropComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & StringPropComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public StringPropComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -1132,7 +1106,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class MultiFile1NativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & MultiFile1NativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public MultiFile1NativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -1166,7 +1139,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class MultiFile2NativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & MultiFile2NativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public MultiFile2NativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -1205,7 +1177,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class MultiComponent1NativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & MultiComponent1NativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public MultiComponent1NativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -1239,7 +1210,6 @@ import com.facebook.react.uimanager.BaseViewManager;
import com.facebook.react.uimanager.BaseViewManagerDelegate;
import com.facebook.react.uimanager.LayoutShadowNode;
@SuppressWarnings(\\"deprecation\\")
public class MultiComponent2NativeComponentManagerDelegate<T extends View, U extends BaseViewManager<T, ? extends LayoutShadowNode> & MultiComponent2NativeComponentManagerInterface<T>> extends BaseViewManagerDelegate<T, U> {
public MultiComponent2NativeComponentManagerDelegate(U viewManager) {
super(viewManager);
@@ -150,11 +150,12 @@ export default class Animation {
if (value != null) {
animatedValue.__onAnimatedValueUpdateReceived(value, offset);
const isJsSyncRemoved =
ReactNativeFeatureFlags.cxxNativeAnimatedEnabled() &&
!ReactNativeFeatureFlags.disableFabricCommitInCXXAnimated() &&
ReactNativeFeatureFlags.cxxNativeAnimatedRemoveJsSync();
if (!isJsSyncRemoved) {
if (
!(
ReactNativeFeatureFlags.cxxNativeAnimatedEnabled() &&
ReactNativeFeatureFlags.cxxNativeAnimatedRemoveJsSync()
)
) {
if (this.__isLooping === true) {
return;
}
@@ -146,12 +146,6 @@ using namespace facebook::react;
#if RN_DISABLE_OSS_PLUGIN_HEADER
return RCTTurboModulePluginClassProvider(name);
#else
if ([_delegate respondsToSelector:@selector(getModuleClassFromName:)]) {
Class moduleClass = [_delegate getModuleClassFromName:name];
if (moduleClass != nil) {
return moduleClass;
}
}
return RCTCoreModulesClassProvider(name);
#endif
}
@@ -182,12 +176,7 @@ using namespace facebook::react;
format:@"Delegate must provide a valid dependencyProvider"];
}
#endif
if ([_delegate respondsToSelector:@selector(getModuleInstanceFromClass:)]) {
id<RCTTurboModule> moduleInstance = [_delegate getModuleInstanceFromClass:moduleClass];
if (moduleInstance != nil) {
return moduleInstance;
}
}
return RCTAppSetupDefaultModuleFromClass(moduleClass, self.delegate.dependencyProvider);
}
@@ -1,196 +0,0 @@
/**
* 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
* @oncall react_native
*/
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
import type {AccessibilityProps, HostInstance} from 'react-native';
import * as Fantom from '@react-native/fantom';
import * as React from 'react';
import {createRef} from 'react';
import {Pressable} from 'react-native';
import {Text} from 'react-native';
import accessibilityPropsSuite from 'react-native/src/private/__tests__/utilities/accessibilityPropsSuite';
import ensureInstance from 'react-native/src/private/__tests__/utilities/ensureInstance';
import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement';
describe('<Pressable>', () => {
describe('props', () => {
describe('style', () => {
it('can be set with ViewStyle', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(
<Pressable
style={{
width: 100,
height: 50,
backgroundColor: 'blue',
borderColor: 'red',
borderWidth: 3,
opacity: 40,
}}
/>,
);
});
expect(root.getRenderedOutput().toJSX()).toEqual(
<rn-view
accessible="true"
accessibilityState="{disabled:false,selected:false,checked:None,busy:false,expanded:null}"
backgroundColor="rgba(0, 0, 255, 1)"
borderWidth="3.000000"
height="50.000000"
opacity="40"
width="100.000000"
/>,
);
});
it('function that receives a boolean reflecting whether the component is currently pressed ', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(
<Pressable
style={({pressed}) => ({
backgroundColor: pressed ? 'red' : 'gray',
})}
/>,
);
});
expect(root.getRenderedOutput().toJSX()).toEqual(
<rn-view
accessible="true"
accessibilityState="{disabled:false,selected:false,checked:None,busy:false,expanded:null}"
backgroundColor="rgba(128, 128, 128, 1)"
/>,
);
});
});
describe('onPress', () => {
it('triggers callback when the element is pressed', () => {
const elementRef = createRef<HostInstance>();
const onPressCallback = jest.fn();
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(
<Pressable
ref={elementRef}
onPress={onPressCallback}
style={{height: 100}}
/>,
);
});
const element = ensureInstance(elementRef.current, ReactNativeElement);
Fantom.dispatchNativeEvent(element, 'click');
expect(onPressCallback).toHaveBeenCalledTimes(1);
});
});
describe('disabled', () => {
it('cannot be pressed', () => {
const elementRef = createRef<HostInstance>();
const root = Fantom.createRoot();
const onPressCallback = jest.fn();
Fantom.runTask(() => {
root.render(
<Pressable
ref={elementRef}
onPress={onPressCallback}
disabled={true}
/>,
);
});
const element = ensureInstance(elementRef.current, ReactNativeElement);
Fantom.dispatchNativeEvent(element, 'change', {value: true});
expect(onPressCallback).toHaveBeenCalledTimes(0);
});
});
describe('children', () => {
it('adds children to the component', () => {
const elementRef = createRef<HostInstance>();
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(
<Pressable ref={elementRef}>
<Text>the quick brown fox</Text>
</Pressable>,
);
});
const element = ensureInstance(elementRef.current, ReactNativeElement);
expect(element.childNodes.length).toBe(1);
expect(root.getRenderedOutput().toJSX()).toEqual(
<rn-view
accessible="true"
accessibilityState="{disabled:false,selected:false,checked:None,busy:false,expanded:null}">
<rn-paragraph
allowFontScaling="true"
ellipsizeMode="tail"
fontSize="NaN"
fontSizeMultiplier="NaN"
foregroundColor="rgba(0, 0, 0, 0)">
the quick brown fox
</rn-paragraph>
</rn-view>,
);
});
});
component ComponentWithAccessibilityProps(...props: AccessibilityProps) {
return <Pressable {...props} />;
}
accessibilityPropsSuite(ComponentWithAccessibilityProps);
});
describe('ref', () => {
describe('instance', () => {
it('is an element node', () => {
const elementRef = createRef<HostInstance>();
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Pressable ref={elementRef} />);
});
expect(elementRef.current).toBeInstanceOf(ReactNativeElement);
});
it('uses the "RN:View" tag name', () => {
const elementRef = createRef<HostInstance>();
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Pressable ref={elementRef} />);
});
const element = ensureInstance(elementRef.current, ReactNativeElement);
// Pressable is implemented with a <View> under the hood
expect(element.tagName).toBe('RN:View');
});
});
});
});
@@ -1,47 +0,0 @@
/**
* 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 '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
import type {HostInstance} from 'react-native';
import * as Fantom from '@react-native/fantom';
import * as React from 'react';
import {createRef} from 'react';
import {Switch} from 'react-native';
import ensureInstance from 'react-native/src/private/__tests__/utilities/ensureInstance';
import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement';
describe('<ExampleComponent>', () => {
describe('props', () => {
describe('exampleProp', () => {
// more describe('<context>') or tests with it('<behaviour>')
});
// ... more props
});
describe('ref', () => {
describe('exampleMethod()', () => {
// more describe('<context>') or tests with it('<behaviour>')
});
// ... more methods
describe('instance', () => {
it('uses the "RN:Switch" tag name', () => {
const elementRef = createRef<HostInstance>();
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Switch ref={elementRef} />);
});
expect(elementRef.current).toBeInstanceOf(ReactNativeElement);
const element = ensureInstance(elementRef.current, ReactNativeElement);
expect(element.tagName).toBe('RN:Switch');
});
});
});
});
@@ -1,92 +0,0 @@
/**
* 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 '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
import type {AccessibilityProps} from 'react-native';
import * as Fantom from '@react-native/fantom';
import * as React from 'react';
import {Text, TouchableWithoutFeedback, View} from 'react-native';
import accessibilityPropsSuite from 'react-native/src/private/__tests__/utilities/accessibilityPropsSuite';
import ensureInstance from 'react-native/src/private/__tests__/utilities/ensureInstance';
import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement';
describe('<TouchableWithoutFeedback>', () => {
describe('props', () => {
describe('empty props', () => {
it('renders without any props', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(
<TouchableWithoutFeedback>
<Text>Touchable</Text>
</TouchableWithoutFeedback>,
);
});
expect(
root.getRenderedOutput({props: ['isPressable']}).toJSX(),
).toEqual(<rn-paragraph isPressable="true">Touchable</rn-paragraph>);
});
});
component ComponentWithAccessibilityProps(...props: AccessibilityProps) {
return (
<TouchableWithoutFeedback {...props}>
<Text>Touchable</Text>
</TouchableWithoutFeedback>
);
}
accessibilityPropsSuite(ComponentWithAccessibilityProps);
});
describe('ref', () => {
describe('instance', () => {
it('is backed by its child', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(
<TouchableWithoutFeedback>
<Text>Touchable</Text>
</TouchableWithoutFeedback>,
);
});
expect(
ensureInstance(
root.document.documentElement.firstElementChild,
ReactNativeElement,
).tagName,
).toBe('RN:Paragraph');
Fantom.runTask(() => {
root.render(
<TouchableWithoutFeedback>
<View>
<Text>Touchable</Text>
</View>
</TouchableWithoutFeedback>,
);
});
expect(
ensureInstance(
root.document.documentElement.firstElementChild,
ReactNativeElement,
).tagName,
).toBe('RN:View');
});
});
});
});
@@ -1,60 +0,0 @@
/**
* 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 '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
import measureRenderTime from '../../../../src/private/__tests__/utilities/measureRenderTime';
import ViewNativeComponent from '../ViewNativeComponent';
import * as Fantom from '@react-native/fantom';
import * as React from 'react';
import {View} from 'react-native';
let root;
let testViews: React.MixedElement;
const NUMBER_OF_VIEWS = 100;
const NUMBER_OF_ITERATIONS = 1000;
component Noop(children: React.Node, style?: mixed) {
return children;
}
Noop.displayName = 'Noop';
Fantom.unstable_benchmark
.suite('View vs. ViewNativeComponent', {minIterations: NUMBER_OF_ITERATIONS})
.test.each(
[Noop, ViewNativeComponent, View],
Component =>
`render ${NUMBER_OF_VIEWS} views (${Component.displayName ?? Component.name ?? 'ViewNativeComponent'})`,
() => {
return {
overriddenDuration: measureRenderTime(root, testViews),
};
},
Component => ({
beforeAll: () => {
let views: React.Node = null;
for (let i = 0; i < NUMBER_OF_VIEWS; i++) {
views = (
<Component style={{width: i + 1, height: i + 1}}>{views}</Component>
);
}
// $FlowExpectedError[incompatible-type]
testViews = views;
},
beforeEach: () => {
root = Fantom.createRoot();
},
afterEach: () => {
root.destroy();
},
}),
);
+88 -212
View File
@@ -10,15 +10,13 @@
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
import type {AccessibilityProps, HostInstance} from 'react-native';
import type {HostInstance} from 'react-native';
import * as Fantom from '@react-native/fantom';
import * as React from 'react';
import {createRef} from 'react';
import {Image} from 'react-native';
import accessibilityPropsSuite from 'react-native/src/private/__tests__/utilities/accessibilityPropsSuite';
import ensureInstance from 'react-native/src/private/__tests__/utilities/ensureInstance';
import NativeFantom from 'react-native/src/private/testing/fantom/specs/NativeFantom';
import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement';
const LOGO_SOURCE = {uri: 'https://reactnative.dev/img/tiny_logo.png'};
@@ -35,13 +33,7 @@ describe('<Image>', () => {
});
expect(root.getRenderedOutput().toJSX()).toEqual(
<rn-image
accessibilityState="{disabled:false,selected:false,checked:None,busy:false,expanded:null}"
overflow="hidden"
resizeMode="cover"
source-scale="1"
source-type="remote"
/>,
<rn-image overflow="hidden" source-scale="1" source-type="remote" />,
);
Fantom.runTask(() => {
@@ -49,17 +41,75 @@ describe('<Image>', () => {
});
expect(root.getRenderedOutput().toJSX()).toEqual(
<rn-image
accessibilityState="{disabled:false,selected:false,checked:None,busy:false,expanded:null}"
overflow="hidden"
resizeMode="cover"
source-scale="1"
source-type="remote"
/>,
<rn-image overflow="hidden" source-scale="1" source-type="remote" />,
);
});
});
describe('accessibility', () => {
describe('accessible', () => {
it('indicates that image is an accessibility element', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Image accessible={true} />);
});
expect(
root.getRenderedOutput({props: ['accessible']}).toJSX(),
).toEqual(<rn-image accessible="true" />);
});
});
describe('accessibilityLabel', () => {
it('provides information for screen reader', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Image accessibilityLabel="React Native Logo" />);
});
expect(
root.getRenderedOutput({props: ['accessibilityLabel']}).toJSX(),
).toEqual(<rn-image accessibilityLabel="React Native Logo" />);
});
});
describe('alt', () => {
it('provides information for screen reader', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Image alt="React Native Logo" />);
});
expect(root.getRenderedOutput({props: ['^access']}).toJSX()).toEqual(
<rn-image
accessible="true"
accessibilityLabel="React Native Logo"
/>,
);
});
it('can be set alongside accessibilityLabel, but accessibilityLabel has higher priority', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(
<Image
alt="React Native Logo"
accessibilityLabel="React Native"
/>,
);
});
expect(root.getRenderedOutput({props: ['^access']}).toJSX()).toEqual(
<rn-image accessible="true" accessibilityLabel="React Native" />,
);
});
});
});
describe('blurRadius', () => {
it('provides blur radius for image', () => {
const root = Fantom.createRoot();
@@ -262,47 +312,35 @@ describe('<Image>', () => {
});
expect(root.getRenderedOutput({props: ['resizeMode']}).toJSX()).toEqual(
<rn-image resizeMode="cover" />,
<rn-image />,
);
});
it('can be set to "cover" explicitly', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Image resizeMode="cover" source={LOGO_SOURCE} />);
});
expect(root.getRenderedOutput({props: ['resizeMode']}).toJSX()).toEqual(
<rn-image resizeMode="cover" />,
);
});
it('can be set to "stretch", which is the same as not setting it', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Image resizeMode="stretch" source={LOGO_SOURCE} />);
});
expect(root.getRenderedOutput({props: ['resizeMode']}).toJSX()).toEqual(
<rn-image />,
);
});
(['contain', 'repeat', 'center'] as const).forEach(resizeMode => {
it(`can be set to "${resizeMode}"`, () => {
const root = Fantom.createRoot();
(['stretch', 'contain', 'repeat', 'center'] as const).forEach(
resizeMode => {
it(`can be set to "${resizeMode}"`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Image resizeMode={resizeMode} source={LOGO_SOURCE} />);
Fantom.runTask(() => {
root.render(
<Image resizeMode={resizeMode} source={LOGO_SOURCE} />,
);
});
expect(
root.getRenderedOutput({props: ['resizeMode']}).toJSX(),
).toEqual(<rn-image resizeMode={resizeMode} />);
});
expect(
root.getRenderedOutput({props: ['resizeMode']}).toJSX(),
).toEqual(<rn-image resizeMode={resizeMode} />);
});
});
},
);
});
describe('source', () => {
@@ -544,15 +582,15 @@ describe('<Image>', () => {
);
});
expect(
root
.getRenderedOutput({props: ['width', 'height', 'resizeMode']})
.toJSX(),
).toEqual(
expect(root.getRenderedOutput().toJSX()).toEqual(
<rn-image
height="100.000000"
overflow="hidden"
resizeMode="contain"
width="100.000000"
source-scale="1"
source-type="remote"
source-uri="https://reactnative.dev/img/tiny_logo.png"
/>,
);
});
@@ -585,12 +623,6 @@ describe('<Image>', () => {
);
});
});
component ComponentWithAccessibilityProps(...props: AccessibilityProps) {
return <Image {...props} source={LOGO_SOURCE} />;
}
accessibilityPropsSuite(ComponentWithAccessibilityProps, false);
});
describe('ref', () => {
@@ -621,160 +653,4 @@ describe('<Image>', () => {
});
});
});
describe('static methods', () => {
afterEach(() => {
NativeFantom.clearAllImages();
});
describe('getSize', () => {
it('returns the size of the image when image is loaded', () => {
const uri = 'https://reactnative.dev/img/tiny_logo.png';
NativeFantom.setImageResponse(uri, {
width: 100,
height: 100,
});
let size;
Fantom.runTask(() => {
Image.getSize(uri, (width, height) => {
size = {width, height};
});
});
expect(size).toEqual({width: 100, height: 100});
});
it('fails when image is not loaded', () => {
const uri = 'https://reactnative.dev/img/tiny_logo.png';
let size;
let err: ?Error;
Fantom.runTask(async () => {
Image.getSize(
uri,
(width, height) => {
size = {width, height};
},
(e: mixed) => {
if (e instanceof Error) {
err = e;
}
},
);
});
expect(size).toBeUndefined();
expect(err).toBeInstanceOf(Error);
expect(err?.message).toBe('image not loaded');
});
});
describe('getSizeWithHeaders', () => {
afterEach(() => {
NativeFantom.clearAllImages();
});
it('returns the size of the image when image is loaded', () => {
const uri = 'https://reactnative.dev/img/tiny_logo.png';
NativeFantom.setImageResponse(uri, {
width: 100,
height: 100,
});
let size;
Fantom.runTask(() => {
Image.getSizeWithHeaders(
uri,
{
Authorization: 'Basic RandomString',
},
(width: number, height: number) => {
size = {width, height};
},
);
});
expect(size).toEqual({width: 100, height: 100});
});
});
describe('prefetch', () => {
it('prefetches the image', () => {
const uri = 'https://reactnative.dev/img/tiny_logo.png';
NativeFantom.setImageResponse(uri, {
width: 100,
height: 100,
});
let result;
Fantom.runTask(async () => {
result = await Image.prefetch(uri);
});
expect(result).toEqual(true);
});
it('can fail to prefetch image', () => {
const uri = 'https://reactnative.dev/img/tiny_logo.png';
NativeFantom.setImageResponse(uri, {
width: 100,
height: 100,
errorMessage: 'Failed to prefetch image',
});
let result;
let error;
Fantom.runTask(async () => {
try {
result = await Image.prefetch(uri);
} catch (e) {
error = e;
}
});
expect(result).toEqual(undefined);
expect(error).toBeInstanceOf(Error);
expect(error?.message).toBe('Failed to prefetch image');
});
});
describe('queryCache', () => {
it('returns empty when image is not cached', () => {
const uri = 'https://reactnative.dev/img/tiny_logo.png';
let result;
Fantom.runTask(async () => {
result = await Image.queryCache([uri]);
});
expect(result).toEqual({});
});
(['disk', 'memory', 'disk/memory'] as const).forEach(cacheStatus => {
it(`returns the '${cacheStatus}' record when image is cached`, () => {
const uri = 'https://reactnative.dev/img/tiny_logo.png';
NativeFantom.setImageResponse(uri, {
width: 100,
height: 100,
cacheStatus,
});
let result;
Fantom.runTask(async () => {
result = await Image.queryCache([uri]);
});
expect(result).toEqual({
[uri]: cacheStatus,
});
});
});
});
});
});
@@ -1,370 +0,0 @@
/**
* 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 '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
import type {HostInstance} from 'react-native';
import * as Fantom from '@react-native/fantom';
import * as React from 'react';
import {createRef} from 'react';
import {Modal} from 'react-native';
import ensureInstance from 'react-native/src/private/__tests__/utilities/ensureInstance';
import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement';
const DEFAULT_MODAL_CHILD_VIEW = (
<rn-view
backgroundColor="rgba(255, 255, 255, 1)"
flex="1.000000"
left="0.000000"
top="0.000000"
/>
);
describe('<Modal>', () => {
describe('props', () => {
it('renders a Modal with the default values when no props are passed', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal />);
});
expect(root.getRenderedOutput().toJSX()).toEqual(
<rn-modalHostView positionType="absolute" visible="true">
{DEFAULT_MODAL_CHILD_VIEW}
</rn-modalHostView>,
);
});
describe('animationType', () => {
it('renders a Modal with animationType="none" by default', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal animationType="none" />);
});
expect(
root.getRenderedOutput({props: ['animationType']}).toJSX(),
).toEqual(
<rn-modalHostView>
<rn-view />
</rn-modalHostView>,
);
});
(['slide', 'fade'] as const).forEach(animationType => {
it(`renders a Modal with animationType="${animationType}"`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal animationType={animationType} />);
});
expect(
root.getRenderedOutput({props: ['animationType']}).toJSX(),
).toEqual(
<rn-modalHostView animationType={animationType}>
<rn-view />
</rn-modalHostView>,
);
});
});
});
describe('presentationStyle', () => {
it('renders a Modal with presentationStyle="fullScreen" by default', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal presentationStyle="fullScreen" />);
});
expect(
root.getRenderedOutput({props: ['presentationStyle']}).toJSX(),
).toEqual(
<rn-modalHostView>
<rn-view />
</rn-modalHostView>,
);
});
(['pageSheet', 'formSheet', 'overFullScreen'] as const).forEach(
presentationStyle => {
it(`renders a Modal with presentationStyle="${presentationStyle}"`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal presentationStyle={presentationStyle} />);
});
expect(
root.getRenderedOutput({props: ['presentationStyle']}).toJSX(),
).toEqual(
<rn-modalHostView presentationStyle={presentationStyle}>
<rn-view />
</rn-modalHostView>,
);
});
},
);
});
describe('transparent', () => {
it('renders a Modal with transparent="true"', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal transparent={true} />);
});
expect(
root
.getRenderedOutput({props: ['transparent', 'presentationStyle']})
.toJSX(),
).toEqual(
<rn-modalHostView
transparent="true"
presentationStyle="overFullScreen">
<rn-view />
</rn-modalHostView>,
);
});
it('renders a Modal with transparent="false"', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal transparent={false} />);
});
expect(
root
.getRenderedOutput({props: ['transparent', 'presentationStyle']})
.toJSX(),
).toEqual(
<rn-modalHostView>
<rn-view />
</rn-modalHostView>,
);
});
});
describe('statusBarTranslucent', () => {
it('renders a Modal with statusBarTranslucent="true"', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal statusBarTranslucent={true} />);
});
expect(
root.getRenderedOutput({props: ['statusBarTranslucent']}).toJSX(),
).toEqual(
<rn-modalHostView statusBarTranslucent="true">
<rn-view />
</rn-modalHostView>,
);
});
it('renders a Modal with statusBarTranslucent="false"', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal statusBarTranslucent={false} />);
});
expect(
root.getRenderedOutput({props: ['statusBarTranslucent']}).toJSX(),
).toEqual(
<rn-modalHostView>
<rn-view />
</rn-modalHostView>,
);
});
});
describe('navigationBarTranslucent', () => {
it('renders a Modal with navigationBarTranslucent="true" and statusBarTranslucent="true"', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
// navigationBarTranslucent=true with statusBarTranslucent=false is not supported
// and it emits a warning.
root.render(
<Modal
navigationBarTranslucent={true}
statusBarTranslucent={true}
/>,
);
});
expect(
root
.getRenderedOutput({
props: ['navigationBarTranslucent', 'statusBarTranslucent'],
})
.toJSX(),
).toEqual(
<rn-modalHostView
navigationBarTranslucent="true"
statusBarTranslucent="true">
<rn-view />
</rn-modalHostView>,
);
});
it('renders a Modal with navigationBarTranslucent="false"', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal navigationBarTranslucent={false} />);
});
expect(
root
.getRenderedOutput({
props: ['navigationBarTranslucent', 'statusBarTranslucent'],
})
.toJSX(),
).toEqual(
<rn-modalHostView>
<rn-view />
</rn-modalHostView>,
);
});
});
describe('hardwareAccelerated', () => {
it('renders a Modal with hardwareAccelerated="true"', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal hardwareAccelerated={true} />);
});
expect(
root.getRenderedOutput({props: ['hardwareAccelerated']}).toJSX(),
).toEqual(
<rn-modalHostView hardwareAccelerated="true">
<rn-view />
</rn-modalHostView>,
);
});
it('renders a Modal with hardwareAccelerated="false"', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal hardwareAccelerated={false} />);
});
expect(
root.getRenderedOutput({props: ['hardwareAccelerated']}).toJSX(),
).toEqual(
<rn-modalHostView>
<rn-view />
</rn-modalHostView>,
);
});
});
describe('visible', () => {
it('renders a Modal with visible="true"', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal visible={true} />);
});
expect(root.getRenderedOutput({props: ['visible']}).toJSX()).toEqual(
<rn-modalHostView visible="true">
<rn-view />
</rn-modalHostView>,
);
});
it('renders nothing when visible="false"', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal visible={false} />);
});
expect(root.getRenderedOutput({props: ['visible']}).toJSX()).toBeNull();
});
});
describe('allowSwipeDismissal', () => {
it('renders a Modal with allowSwipeDismissal="true"', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal allowSwipeDismissal={true} />);
});
expect(
root.getRenderedOutput({props: ['allowSwipeDismissal']}).toJSX(),
).toEqual(
<rn-modalHostView allowSwipeDismissal="true">
<rn-view />
</rn-modalHostView>,
);
});
it('renders a Modal with allowSwipeDismissal="false"', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal allowSwipeDismissal={false} />);
});
expect(
root.getRenderedOutput({props: ['allowSwipeDismissal']}).toJSX(),
).toEqual(
<rn-modalHostView>
<rn-view />
</rn-modalHostView>,
);
});
});
describe('animated', () => {
[true, false].forEach(animated => {
// The 'animated' prop is deprecated and ignored when the Modal is rendered
// Users should use the 'animationType' prop instead.
it(`[DEPRECATED] renders a Modal with animated="${animated ? 'true' : 'false'}"`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal animated={animated} />);
});
expect(root.getRenderedOutput({props: ['animated']}).toJSX()).toEqual(
<rn-modalHostView>
<rn-view />
</rn-modalHostView>,
);
});
});
});
// ... more props
});
describe('ref', () => {
describe('exampleMethod()', () => {
// more describe('<context>') or tests with it('<behaviour>')
});
// ... more methods
describe('instance', () => {
it('uses the "RN:ModalHostView" tag name', () => {
const elementRef = createRef<HostInstance>();
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Modal ref={elementRef} />);
});
expect(elementRef.current).toBeInstanceOf(ReactNativeElement);
const element = ensureInstance(elementRef.current, ReactNativeElement);
expect(element.tagName).toBe('RN:ModalHostView');
});
});
});
});
+10 -409
View File
@@ -11,412 +11,18 @@
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
import type {Role} from '../../Components/View/ViewAccessibility';
import type {AccessibilityProps, HostInstance} from 'react-native';
import type {HostInstance} from 'react-native';
import ensureInstance from '../../../src/private/__tests__/utilities/ensureInstance';
import * as Fantom from '@react-native/fantom';
import * as React from 'react';
import {createRef} from 'react';
import {Text} from 'react-native';
import accessibilityPropsSuite from 'react-native/src/private/__tests__/utilities/accessibilityPropsSuite';
import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement';
import ReadOnlyText from 'react-native/src/private/webapis/dom/nodes/ReadOnlyText';
const TEST_TEXT = 'the text';
describe('<Text>', () => {
describe('props', () => {
describe('empty props', () => {
it('renders an empty element when there are no props', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text>{TEST_TEXT}</Text>);
});
expect(root.getRenderedOutput().toJSX()).toEqual(
<rn-paragraph
allowFontScaling="true"
ellipsizeMode="tail"
fontSize="NaN"
fontSizeMultiplier="NaN"
foregroundColor="rgba(0, 0, 0, 0)">
{TEST_TEXT}
</rn-paragraph>,
);
});
});
describe('adjustsFontSizeToFit', () => {
it(`can be set to "true"`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text adjustsFontSizeToFit={true}>{TEST_TEXT}</Text>);
});
expect(
root.getRenderedOutput({props: ['adjustsFontSizeToFit']}).toJSX(),
).toEqual(
<rn-paragraph adjustsFontSizeToFit="true">{TEST_TEXT}</rn-paragraph>,
);
});
it(`has 'false' as default`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text>{TEST_TEXT}</Text>);
});
expect(
root.getRenderedOutput({props: ['adjustsFontSizeToFit']}).toJSX(),
).toEqual(<rn-paragraph>{TEST_TEXT}</rn-paragraph>);
});
});
describe('allowFontScaling', () => {
([true, false] as const).forEach(propVal => {
it(`can be set to "${propVal.toString()}"`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text allowFontScaling={propVal}>{TEST_TEXT}</Text>);
});
expect(
root.getRenderedOutput({props: ['allowFontScaling']}).toJSX(),
).toEqual(
<rn-paragraph allowFontScaling={propVal.toString()}>
{TEST_TEXT}
</rn-paragraph>,
);
});
});
it(`has 'true' as default`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text>{TEST_TEXT}</Text>);
});
expect(
root.getRenderedOutput({props: ['allowFontScaling']}).toJSX(),
).toEqual(
<rn-paragraph allowFontScaling={'true'}>{TEST_TEXT}</rn-paragraph>,
);
});
});
describe('ellipsizeMode', () => {
it(`has 'tail' as default on JS side`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text>{TEST_TEXT}</Text>);
});
expect(
root.getRenderedOutput({props: ['ellipsizeMode']}).toJSX(),
).toEqual(
<rn-paragraph ellipsizeMode="tail">{TEST_TEXT}</rn-paragraph>,
);
});
it(`has 'clip' as default on C++ side`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text ellipsizeMode="clip">{TEST_TEXT}</Text>);
});
expect(
root.getRenderedOutput({props: ['ellipsizeMode']}).toJSX(),
).toEqual(<rn-paragraph>{TEST_TEXT}</rn-paragraph>);
});
(['head', 'middle', 'tail'] as const).forEach(propVal => {
it(`can be set to "${propVal}"`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text ellipsizeMode={propVal}>{TEST_TEXT}</Text>);
});
expect(
root.getRenderedOutput({props: ['ellipsizeMode']}).toJSX(),
).toEqual(
<rn-paragraph ellipsizeMode={propVal}>{TEST_TEXT}</rn-paragraph>,
);
});
});
});
describe('id and nativeID', () => {
it(`has 'id' propagated correctly`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text id="alpha">{TEST_TEXT}</Text>);
});
expect(root.getRenderedOutput({props: ['nativeID']}).toJSX()).toEqual(
<rn-paragraph nativeID={'alpha'}>{TEST_TEXT}</rn-paragraph>,
);
});
it(`has 'nativeID' propagated correctly`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text nativeID="alpha">{TEST_TEXT}</Text>);
});
expect(root.getRenderedOutput({props: ['nativeID']}).toJSX()).toEqual(
<rn-paragraph nativeID={'alpha'}>{TEST_TEXT}</rn-paragraph>,
);
});
it(`has a precedence of 'id' over 'nativeID'`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(
<Text id="alpha" nativeID="gamma">
{TEST_TEXT}
</Text>,
);
});
expect(
root.getRenderedOutput({props: ['id', 'nativeID']}).toJSX(),
).toEqual(<rn-paragraph nativeID={'alpha'}>{TEST_TEXT}</rn-paragraph>);
});
});
describe('maxFontSizeMultiplier', () => {
it(`propagates valid numbers correctly`, () => {
const root = Fantom.createRoot();
[-1, 0, 1, 3, 1000].forEach(val => {
Fantom.runTask(() => {
root.render(<Text maxFontSizeMultiplier={val}>{TEST_TEXT}</Text>);
});
expect(
root.getRenderedOutput({props: ['maxFontSizeMultiplier']}).toJSX(),
).toEqual(
<rn-paragraph maxFontSizeMultiplier={val.toString()}>
{TEST_TEXT}
</rn-paragraph>,
);
});
});
});
describe('numberOfLines', () => {
let originalConsoleError = null;
afterEach(() => {
if (originalConsoleError != null) {
// $FlowExpectedError[cannot-write]
console.error = originalConsoleError;
originalConsoleError = null;
}
});
it(`doesn't allow negative numbers`, () => {
originalConsoleError = console.error;
// $FlowExpectedError[cannot-write]
console.error = jest.fn();
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text numberOfLines={-1}>{TEST_TEXT}</Text>);
});
expect(
// NB. "numberOfLines" is mapped to "maximumNumberOfLines" in C++
root.getRenderedOutput({props: ['maximumNumberOfLines']}).toJSX(),
).toEqual(<rn-paragraph>{TEST_TEXT}</rn-paragraph>);
});
it(`has 0 as defult`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text numberOfLines={0}>{TEST_TEXT}</Text>);
});
expect(
root.getRenderedOutput({props: ['maximumNumberOfLines']}).toJSX(),
).toEqual(<rn-paragraph>{TEST_TEXT}</rn-paragraph>);
});
it(`propagates valid numbers correctly`, () => {
const root = Fantom.createRoot();
[3, 1000].forEach(val => {
Fantom.runTask(() => {
root.render(<Text numberOfLines={val}>{TEST_TEXT}</Text>);
});
expect(
root.getRenderedOutput({props: ['maximumNumberOfLines']}).toJSX(),
).toEqual(
<rn-paragraph maximumNumberOfLines={val.toString()}>
{TEST_TEXT}
</rn-paragraph>,
);
});
});
});
describe('role', () => {
it(`has none by default`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text>{TEST_TEXT}</Text>);
});
expect(root.getRenderedOutput({props: ['role']}).toJSX()).toEqual(
<rn-paragraph>{TEST_TEXT}</rn-paragraph>,
);
});
it(`maps invalid values to 'none'`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
// $FlowExpectedError[incompatible-type]
root.render(<Text role="__some_invalid_value">{TEST_TEXT}</Text>);
});
expect(root.getRenderedOutput({props: ['role']}).toJSX()).toEqual(
<rn-paragraph role="none">{TEST_TEXT}</rn-paragraph>,
);
});
it(`propagates correctly all possible values`, () => {
const root = Fantom.createRoot();
(
[
'alert',
'alertdialog',
'application',
'article',
'banner',
'button',
'cell',
'checkbox',
'columnheader',
'combobox',
'complementary',
'contentinfo',
'definition',
'dialog',
'directory',
'document',
'feed',
'figure',
'form',
'grid',
'group',
'heading',
'img',
'link',
'list',
'listitem',
'log',
'main',
'marquee',
'math',
'menu',
'menubar',
'menuitem',
'meter',
'navigation',
'none',
'note',
'option',
'presentation',
'progressbar',
'radio',
'radiogroup',
'region',
'row',
'rowgroup',
'rowheader',
'scrollbar',
'searchbox',
'separator',
'slider',
'spinbutton',
'status',
'summary',
'switch',
'tab',
'table',
'tablist',
'tabpanel',
'term',
'timer',
'toolbar',
'tooltip',
'tree',
'treegrid',
'treeitem',
'treeitem',
] as Array<Role>
).forEach(propVal => {
Fantom.runTask(() => {
root.render(<Text role={propVal}>{TEST_TEXT}</Text>);
});
expect(root.getRenderedOutput({props: ['role']}).toJSX()).toEqual(
<rn-paragraph role={propVal}>{TEST_TEXT}</rn-paragraph>,
);
});
});
});
describe('selectable', () => {
it(`can be set to "true"`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text selectable={true}>{TEST_TEXT}</Text>);
});
expect(root.getRenderedOutput({props: ['selectable']}).toJSX()).toEqual(
<rn-paragraph selectable={'true'}>{TEST_TEXT}</rn-paragraph>,
);
});
it(`has 'false' as default`, () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text>{TEST_TEXT}</Text>);
});
expect(root.getRenderedOutput({props: ['selectable']}).toJSX()).toEqual(
<rn-paragraph>{TEST_TEXT}</rn-paragraph>,
);
Fantom.runTask(() => {
root.render(<Text selectable={false}>{TEST_TEXT}</Text>);
});
expect(root.getRenderedOutput({props: ['selectable']}).toJSX()).toEqual(
<rn-paragraph>{TEST_TEXT}</rn-paragraph>,
);
});
});
describe('style', () => {
describe('writingDirection', () => {
it('propagates to mounting layer', () => {
@@ -424,38 +30,38 @@ describe('<Text>', () => {
Fantom.runTask(() => {
root.render(
<Text style={{writingDirection: 'rtl'}}>{TEST_TEXT}</Text>,
<Text style={{writingDirection: 'rtl'}}>dummy text</Text>,
);
});
expect(
root.getRenderedOutput({props: ['writingDirection']}).toJSX(),
).toEqual(
<rn-paragraph writingDirection="rtl">{TEST_TEXT}</rn-paragraph>,
<rn-paragraph writingDirection="rtl">dummy text</rn-paragraph>,
);
Fantom.runTask(() => {
root.render(
<Text style={{writingDirection: 'ltr'}}>{TEST_TEXT}</Text>,
<Text style={{writingDirection: 'ltr'}}>dummy text</Text>,
);
});
expect(
root.getRenderedOutput({props: ['writingDirection']}).toJSX(),
).toEqual(
<rn-paragraph writingDirection="ltr">{TEST_TEXT}</rn-paragraph>,
<rn-paragraph writingDirection="ltr">dummy text</rn-paragraph>,
);
Fantom.runTask(() => {
root.render(
<Text style={{writingDirection: 'auto'}}>{TEST_TEXT}</Text>,
<Text style={{writingDirection: 'auto'}}>dummy text</Text>,
);
});
expect(
root.getRenderedOutput({props: ['writingDirection']}).toJSX(),
).toEqual(
<rn-paragraph writingDirection="auto">{TEST_TEXT}</rn-paragraph>,
<rn-paragraph writingDirection="auto">dummy text</rn-paragraph>,
);
});
});
@@ -469,7 +75,7 @@ describe('<Text>', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text ref={elementRef}>{TEST_TEXT}</Text>);
root.render(<Text ref={elementRef}>Some text</Text>);
});
const element = ensureInstance(elementRef.current, ReactNativeElement);
@@ -482,14 +88,14 @@ describe('<Text>', () => {
const root = Fantom.createRoot();
Fantom.runTask(() => {
root.render(<Text ref={elementRef}>{TEST_TEXT}</Text>);
root.render(<Text ref={elementRef}>Some text</Text>);
});
const element = ensureInstance(elementRef.current, ReactNativeElement);
expect(element.childNodes.length).toBe(1);
const textChild = ensureInstance(element.childNodes[0], ReadOnlyText);
expect(textChild.textContent).toBe(TEST_TEXT);
expect(textChild.textContent).toBe('Some text');
});
it('has text and element child nodes when nested', () => {
@@ -525,9 +131,4 @@ describe('<Text>', () => {
expect(secondChildText.textContent).toBe('also in bold');
});
});
component ComponentWithAccessibilityProps(...props: AccessibilityProps) {
return <Text {...props}>{TEST_TEXT}</Text>;
}
accessibilityPropsSuite(ComponentWithAccessibilityProps, false);
});
@@ -40,7 +40,6 @@ using namespace facebook::react;
// attaching and detaching of a pull-to-refresh view to a scroll view.
// The pull-to-refresh view is not a subview of this view.
self.hidden = YES;
_props = PullToRefreshViewShadowNode::defaultSharedProps();
_recycled = NO;
[self _initializeUIRefreshControl];
}
@@ -13,8 +13,6 @@
#import <React/RCTScrollableProtocol.h>
#import <React/RCTViewComponentView.h>
#import "RCTVirtualViewContainerProtocol.h"
NS_ASSUME_NONNULL_BEGIN
/*
@@ -25,8 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
* keyboard-avoiding functionality and so on. All that complexity must be implemented inside those components in order
* to keep the complexity of this component manageable.
*/
@interface RCTScrollViewComponentView
: RCTViewComponentView <RCTMountingTransactionObserving, RCTVirtualViewContainerProtocol>
@interface RCTScrollViewComponentView : RCTViewComponentView <RCTMountingTransactionObserving>
/*
* Finds and returns the closet RCTScrollViewComponentView component to the given view
@@ -24,7 +24,6 @@
#import "RCTCustomPullToRefreshViewProtocol.h"
#import "RCTEnhancedScrollView.h"
#import "RCTFabricComponentsPlugins.h"
#import "RCTVirtualViewContainerState.h"
using namespace facebook::react;
@@ -118,12 +117,6 @@ RCTSendScrollEventForNativeAnimations_DEPRECATED(UIScrollView *scrollView, NSInt
// It is not restored to the default value in prepareForRecycle.
// Once an accessibility API is used, view culling will be disabled for the entire session.
BOOL _isAccessibilityAPIUsed;
// Flag to temporarily disable maintainVisibleContentPosition adjustments during immediate state updates
// to prevent conflicts between immediate content offset updates and visible content position logic
BOOL _avoidAdjustmentForMaintainVisibleContentPosition;
RCTVirtualViewContainerState *_virtualViewContainerState;
}
+ (RCTScrollViewComponentView *_Nullable)findScrollViewComponentViewForView:(UIView *)view
@@ -644,11 +637,6 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
return;
}
BOOL enableImmediateUpdateModeForContentOffsetChanges =
ReactNativeFeatureFlags::enableImmediateUpdateModeForContentOffsetChanges();
_avoidAdjustmentForMaintainVisibleContentPosition = enableImmediateUpdateModeForContentOffsetChanges;
auto contentOffset = RCTPointFromCGPoint(_scrollView.contentOffset);
BOOL isAccessibilityAPIUsed = _isAccessibilityAPIUsed;
_state->updateState(
@@ -664,10 +652,9 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
UIAccessibilityIsVoiceOverRunning() || UIAccessibilityIsSwitchControlRunning() || isAccessibilityAPIUsed;
return std::make_shared<const ScrollViewShadowNode::ConcreteState::Data>(newData);
},
enableImmediateUpdateModeForContentOffsetChanges ? EventQueue::UpdateMode::unstable_Immediate
: EventQueue::UpdateMode::Asynchronous);
_avoidAdjustmentForMaintainVisibleContentPosition = NO;
ReactNativeFeatureFlags::enableImmediateUpdateModeForContentOffsetChanges()
? EventQueue::UpdateMode::unstable_Immediate
: EventQueue::UpdateMode::Asynchronous);
}
- (void)prepareForRecycle
@@ -691,7 +678,6 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
_contentView = nil;
_prevFirstVisibleFrame = CGRectZero;
_firstVisibleView = nil;
_virtualViewContainerState = nil;
}
#pragma mark - UIScrollViewDelegate
@@ -1067,7 +1053,7 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
- (void)_adjustForMaintainVisibleContentPosition
{
const auto &props = static_cast<const ScrollViewProps &>(*_props);
if (!props.maintainVisibleContentPosition || _avoidAdjustmentForMaintainVisibleContentPosition) {
if (!props.maintainVisibleContentPosition) {
return;
}
@@ -1104,16 +1090,6 @@ static inline UIViewAnimationOptions animationOptionsWithCurve(UIViewAnimationCu
}
}
#pragma mark - RCTVirtualViewContainerProtocol
- (RCTVirtualViewContainerState *)virtualViewContainerState
{
if (!_virtualViewContainerState) {
_virtualViewContainerState = [[RCTVirtualViewContainerState alloc] initWithScrollView:self];
}
return _virtualViewContainerState;
}
@end
Class<RCTComponentViewProtocol> RCTScrollViewCls(void)
@@ -1,14 +0,0 @@
/*
* 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.
*/
@class RCTVirtualViewContainerState;
@protocol RCTVirtualViewContainerProtocol
- (RCTVirtualViewContainerState *)virtualViewContainerState;
@end
@@ -1,25 +0,0 @@
/*
* 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.
*/
#import <Foundation/Foundation.h>
#import "RCTVirtualViewProtocol.h"
@class RCTScrollViewComponentView;
NS_ASSUME_NONNULL_BEGIN
@interface RCTVirtualViewContainerState : NSObject
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)new NS_UNAVAILABLE;
- (instancetype)initWithScrollView:(RCTScrollViewComponentView *)scrollView NS_DESIGNATED_INITIALIZER;
- (void)onChange:(id<RCTVirtualViewProtocol>)virtualView;
- (void)remove:(id<RCTVirtualViewProtocol>)virtualView;
@end
NS_ASSUME_NONNULL_END
@@ -1,193 +0,0 @@
/*
* 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.
*/
#import <React/RCTLog.h>
#import <React/RCTScrollViewComponentView.h>
#import <React/RCTVirtualViewMode.h>
#import <UIKit/UIKit.h>
#import <react/featureflags/ReactNativeFeatureFlags.h>
#import "RCTVirtualViewContainerState.h"
using namespace facebook;
using namespace facebook::react;
#if RCT_DEBUG
static void debugLog(NSString *msg, ...)
{
auto debugEnabled = ReactNativeFeatureFlags::enableVirtualViewDebugFeatures();
if (!debugEnabled) {
return;
}
va_list args;
va_start(args, msg);
NSString *msgString = [[NSString alloc] initWithFormat:msg arguments:args];
RCTLogInfo(@"%@", msgString);
va_end(args); // Don't forget to call va_end to clean up
}
#endif
/**
* Checks whether one CGRect overlaps with another CGRect.
*
* This is different from CGRectIntersectsRect because a CGRect representing
* a line or a point is considered to overlap with another CGRect if the line
* or point is within the rect bounds. However, two CGRects are not considered
* to overlap if they only share a boundary.
*/
static BOOL CGRectOverlaps(CGRect rect1, CGRect rect2)
{
CGFloat minY1 = CGRectGetMinY(rect1);
CGFloat maxY1 = CGRectGetMaxY(rect1);
CGFloat minY2 = CGRectGetMinY(rect2);
CGFloat maxY2 = CGRectGetMaxY(rect2);
if (minY1 >= maxY2 || minY2 >= maxY1) {
// No overlap on the y-axis.
return NO;
}
CGFloat minX1 = CGRectGetMinX(rect1);
CGFloat maxX1 = CGRectGetMaxX(rect1);
CGFloat minX2 = CGRectGetMinX(rect2);
CGFloat maxX2 = CGRectGetMaxX(rect2);
if (minX1 >= maxX2 || minX2 >= maxX1) {
// No overlap on the x-axis.
return NO;
}
return YES;
}
@interface RCTVirtualViewContainerState () <UIScrollViewDelegate>
@end
@interface RCTVirtualViewContainerState () {
NSMutableSet<id<RCTVirtualViewProtocol>> *_virtualViews;
CGRect _emptyRect;
CGRect _prerenderRect;
__weak RCTScrollViewComponentView *_scrollViewComponentView;
CGFloat _prerenderRatio;
}
@end
@implementation RCTVirtualViewContainerState
- (instancetype)initWithScrollView:(RCTScrollViewComponentView *)scrollView
{
self = [super init];
if (self != nil) {
_virtualViews = [NSMutableSet set];
_emptyRect = CGRectZero;
_prerenderRect = CGRectZero;
_scrollViewComponentView = scrollView;
_prerenderRatio = ReactNativeFeatureFlags::virtualViewPrerenderRatio();
[_scrollViewComponentView addScrollListener:self];
#if RCT_DEBUG
debugLog(@"initWithScrollView");
#endif
}
return self;
}
- (void)dealloc
{
#if RCT_DEBUG
debugLog(@"dealloc");
#endif
if (_scrollViewComponentView != nil) {
[_scrollViewComponentView removeScrollListener:self];
_scrollViewComponentView = nil;
}
[_virtualViews removeAllObjects];
}
#pragma mark - Public API
- (void)onChange:(id<RCTVirtualViewProtocol>)virtualView
{
if (![_virtualViews containsObject:virtualView]) {
[_virtualViews addObject:virtualView];
#if RCT_DEBUG
debugLog(@"Add virtualViewID=%@", virtualView.virtualViewID);
#endif
} else {
#if RCT_DEBUG
debugLog(@"Update virtualViewID=%@", virtualView.virtualViewID);
#endif
}
[self _updateModes:virtualView];
}
- (void)remove:(id<RCTVirtualViewProtocol>)virtualView
{
if (![_virtualViews containsObject:virtualView]) {
RCTLogError(@"Attempting to remove non-existent VirtualView: %@", virtualView.virtualViewID);
}
[_virtualViews removeObject:virtualView];
#if RCT_DEBUG
debugLog(@"Remove virtualViewID=%@", virtualView.virtualViewID);
#endif
}
#pragma mark - Private Helpers
- (void)_updateModes:(id<RCTVirtualViewProtocol>)virtualView
{
auto scrollView = _scrollViewComponentView.scrollView;
CGRect visibleRect = CGRectMake(
scrollView.contentOffset.x,
scrollView.contentOffset.y,
scrollView.frame.size.width,
scrollView.frame.size.height);
_prerenderRect = visibleRect;
_prerenderRect = CGRectInset(
_prerenderRect, -_prerenderRect.size.width * _prerenderRatio, -_prerenderRect.size.height * _prerenderRatio);
NSArray<id<RCTVirtualViewProtocol>> *virtualViewsIt =
(virtualView != nullptr) ? @[ virtualView ] : [_virtualViews allObjects];
for (id<RCTVirtualViewProtocol> vv = nullptr in virtualViewsIt) {
CGRect rect = [vv containerRelativeRect:scrollView];
RCTVirtualViewMode mode = RCTVirtualViewModeHidden;
CGRect thresholdRect = _emptyRect;
if (CGRectIsEmpty(rect)) {
mode = RCTVirtualViewModeHidden;
thresholdRect = _emptyRect;
} else if (CGRectOverlaps(rect, visibleRect)) {
thresholdRect = visibleRect;
mode = RCTVirtualViewModeVisible;
} else if (CGRectOverlaps(rect, _prerenderRect)) {
mode = RCTVirtualViewModePrerender;
thresholdRect = _prerenderRect;
}
#if RCT_DEBUG
debugLog(
@"UpdateModes virtualView=%@ mode=%ld rect=%@ thresholdRect=%@",
vv.virtualViewID,
(long)mode,
NSStringFromCGRect(rect),
NSStringFromCGRect(thresholdRect));
#endif
[vv onModeChange:mode targetRect:rect thresholdRect:thresholdRect];
}
}
#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
[self _updateModes:nil];
}
@end
@@ -1,20 +0,0 @@
/*
* 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.
*/
#import <React/RCTVirtualViewMode.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@protocol RCTVirtualViewProtocol <NSObject>
- (NSString *)virtualViewID;
- (CGRect)containerRelativeRect:(UIView *)view;
- (void)onModeChange:(RCTVirtualViewMode)newMode targetRect:(CGRect)targetRect thresholdRect:(CGRect)thresholdRect;
@end
NS_ASSUME_NONNULL_END
@@ -22,7 +22,6 @@
#import "RCTTextInputNativeCommands.h"
#import "RCTTextInputUtils.h"
#import <limits>
#import "RCTFabricComponentsPlugins.h"
/** Native iOS text field bottom keyboard offset amount */
@@ -451,7 +450,7 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
}
}
if (props.maxLength < std::numeric_limits<int>::max()) {
if (props.maxLength) {
NSInteger allowedLength = props.maxLength - _backedTextInputView.attributedText.string.length + range.length;
if (allowedLength > 0 && text.length > allowedLength) {
@@ -571,7 +571,7 @@ const CGFloat BACKGROUND_COLOR_ZPOSITION = -1024.0f;
_backgroundColorLayer.frame = CGRectMake(0, 0, self.layer.bounds.size.width, self.layer.bounds.size.height);
}
if ((_props->transformOrigin.isSet() || !_props->transform.operations.empty()) &&
if ((_props->transformOrigin.isSet() || _props->transform.operations.size() > 0) &&
layoutMetrics.frame.size != oldLayoutMetrics.frame.size) {
auto newTransform = _props->resolveTransform(layoutMetrics);
self.layer.transform = RCTCATransform3DFromTransformMatrix(newTransform);
@@ -8,11 +8,10 @@
#import <UIKit/UIKit.h>
#import <React/RCTViewComponentView.h>
#import <React/RCTVirtualViewProtocol.h>
NS_ASSUME_NONNULL_BEGIN
@interface RCTVirtualViewExperimentalComponentView : RCTViewComponentView <RCTVirtualViewProtocol>
@interface RCTVirtualViewExperimentalComponentView : RCTViewComponentView
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
@@ -11,8 +11,6 @@
#import <React/RCTConversions.h>
#import <React/RCTScrollViewComponentView.h>
#import <React/RCTScrollableProtocol.h>
#import <React/RCTVirtualViewContainerProtocol.h>
#import <React/RCTVirtualViewContainerState.h>
#import <React/UIView+React.h>
#import <jsi/jsi.h>
@@ -30,30 +28,50 @@
using namespace facebook;
using namespace facebook::react;
@interface RCTVirtualViewExperimentalComponentView () {
NSString *_virtualViewID;
/**
* Checks whether one CGRect overlaps with another CGRect.
*
* This is different from CGRectIntersectsRect because a CGRect representing
* a line or a point is considered to overlap with another CGRect if the line
* or point is within the rect bounds. However, two CGRects are not considered
* to overlap if they only share a boundary.
*/
static BOOL CGRectOverlaps(CGRect rect1, CGRect rect2)
{
CGFloat minY1 = CGRectGetMinY(rect1);
CGFloat maxY1 = CGRectGetMaxY(rect1);
CGFloat minY2 = CGRectGetMinY(rect2);
CGFloat maxY2 = CGRectGetMaxY(rect2);
if (minY1 >= maxY2 || minY2 >= maxY1) {
// No overlap on the y-axis.
return NO;
}
CGFloat minX1 = CGRectGetMinX(rect1);
CGFloat maxX1 = CGRectGetMaxX(rect1);
CGFloat minX2 = CGRectGetMinX(rect2);
CGFloat maxX2 = CGRectGetMaxX(rect2);
if (minX1 >= maxX2 || minX2 >= maxX1) {
// No overlap on the x-axis.
return NO;
}
return YES;
}
@interface RCTVirtualViewExperimentalComponentView () <UIScrollViewDelegate>
@end
@implementation RCTVirtualViewExperimentalComponentView {
id<RCTVirtualViewContainerProtocol> _parentVirtualViewContainer;
RCTScrollViewComponentView *_lastParentScrollViewComponentView;
std::optional<RCTVirtualViewMode> _mode;
RCTVirtualViewRenderState _renderState;
std::optional<CGRect> _targetRect;
NSString *_nativeId;
BOOL _didLayout;
}
#pragma mark - Public API
- (instancetype)initWithFrame:(CGRect)frame
{
if ((self = [super initWithFrame:frame]) != nil) {
_props = VirtualViewExperimentalShadowNode::defaultSharedProps();
_renderState = RCTVirtualViewRenderStateUnknown;
_virtualViewID = [[NSUUID UUID] UUIDString];
_didLayout = NO;
}
return self;
@@ -85,13 +103,21 @@ using namespace facebook::react;
}
}
const auto &newBaseViewProps = static_cast<const ViewProps &>(*props);
const auto nativeId = RCTNSStringFromStringNilIfEmpty(newBaseViewProps.nativeId);
_virtualViewID = nativeId == nil ? _virtualViewID : nativeId;
[super updateProps:props oldProps:oldProps];
}
- (RCTScrollViewComponentView *)getParentScrollViewComponentView
{
UIView *view = self.superview;
while (view != nil) {
if ([view isKindOfClass:[RCTScrollViewComponentView class]]) {
return (RCTScrollViewComponentView *)view;
}
view = view.superview;
}
return nil;
}
/**
* Static flag that tracks whether accessibility services are being used.
* When accessibility is detected, virtual views will remain visible even when
@@ -100,6 +126,18 @@ using namespace facebook::react;
*/
static BOOL sIsAccessibilityUsed = NO;
- (void)_unhideIfNeeded
{
if (!sIsAccessibilityUsed) {
// accessibility is detected for the first time. Make views visible.
sIsAccessibilityUsed = YES;
}
if (self.hidden) {
self.hidden = NO;
}
}
- (NSInteger)accessibilityElementCount
{
// From empirical testing, method `accessibilityElementCount` is called lazily only
@@ -116,23 +154,19 @@ static BOOL sIsAccessibilityUsed = NO;
return [super focusItemsInRect:rect];
}
- (NSString *)virtualViewID
{
// Return a unique identifier for this virtual view
// Using the tag as a unique identifier since it's already unique per view
return _virtualViewID;
}
- (void)prepareForRecycle
{
[super prepareForRecycle];
[[_parentVirtualViewContainer virtualViewContainerState] remove:self];
// No need to remove the scroll listener here since the view is always removed from window before being recycled and
// we do that in didMoveToWindow, which gets called when the view is removed from window.
RCTAssert(
_lastParentScrollViewComponentView == nil,
@"_lastParentScrollViewComponentView should already have been cleared in didMoveToWindow.");
self.hidden = NO;
_didLayout = NO;
_mode.reset();
_targetRect.reset();
_parentVirtualViewContainer = nil;
}
// Handles case when sibling changes size.
@@ -142,41 +176,84 @@ static BOOL sIsAccessibilityUsed = NO;
oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
{
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:_layoutMetrics];
_didLayout = YES;
[self updateState];
}
- (void)updateState
{
[[_parentVirtualViewContainer virtualViewContainerState] onChange:self];
[self dispatchOnModeChangeIfNeeded:YES];
}
- (void)didMoveToWindow
{
[super didMoveToWindow];
// here we will set the pointer to the virtualView container
// and if there was a layout, update
_parentVirtualViewContainer = [self _getParentVirtualViewContainer];
if (_parentVirtualViewContainer != nil && self.window != nil && _didLayout) {
[self updateState];
if (_lastParentScrollViewComponentView != nil) {
[_lastParentScrollViewComponentView removeScrollListener:self];
_lastParentScrollViewComponentView = nil;
}
if (RCTScrollViewComponentView *parentScrollViewComponentView = [self getParentScrollViewComponentView]) {
if (self.window != nil) {
// TODO(T202601695): We also want the ScrollView to emit layout changes from didLayoutSubviews so that any event
// that may affect visibily of this view notifies the listeners.
[parentScrollViewComponentView addScrollListener:self];
_lastParentScrollViewComponentView = parentScrollViewComponentView;
// We want to dispatch the event immediately when the view is added to the window before any scrolling occurs.
[self dispatchOnModeChangeIfNeeded:NO];
}
}
}
- (CGRect)containerRelativeRect:(UIView *)scrollView
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
// Return the view's position relative to its container (the scroll view)
return [self convertRect:self.bounds toView:scrollView];
[self dispatchOnModeChangeIfNeeded:NO];
}
- (void)onModeChange:(RCTVirtualViewMode)newMode targetRect:(CGRect)targetRect thresholdRect:(CGRect)thresholdRect
- (void)dispatchOnModeChangeIfNeeded:(BOOL)checkForTargetRectChange
{
if (_lastParentScrollViewComponentView == nullptr) {
return;
}
UIScrollView *scrollView = _lastParentScrollViewComponentView.scrollView;
CGRect targetRect = [self convertRect:self.bounds toView:scrollView];
// While scrolling, the `targetRect` does not change, so we don't check for changed `targetRect` in that case.
if (checkForTargetRectChange) {
if (_targetRect.has_value() && CGRectEqualToRect(targetRect, _targetRect.value())) {
return;
}
_targetRect = targetRect;
}
RCTVirtualViewMode newMode;
CGRect thresholdRect = CGRectMake(
scrollView.contentOffset.x,
scrollView.contentOffset.y,
scrollView.frame.size.width,
scrollView.frame.size.height);
if (CGRectOverlaps(targetRect, thresholdRect)) {
newMode = RCTVirtualViewModeVisible;
} else {
auto prerender = false;
const CGFloat prerenderRatio = ReactNativeFeatureFlags::virtualViewPrerenderRatio();
if (prerenderRatio > 0) {
thresholdRect = CGRectInset(
thresholdRect, -thresholdRect.size.width * prerenderRatio, -thresholdRect.size.height * prerenderRatio);
prerender = CGRectOverlaps(targetRect, thresholdRect);
}
if (prerender) {
newMode = RCTVirtualViewModePrerender;
} else {
newMode = RCTVirtualViewModeHidden;
thresholdRect = CGRectZero;
}
}
if (_mode.has_value() && newMode == _mode.value()) {
return;
}
// NOTE: Make sure to keep these props in sync with dispatchSyncModeChange below where we have to explicitly copy
// all props.
// NOTE: Make sure to keep these props in sync with dispatchSyncModeChange below where we have to explicitly copy all
// props.
VirtualViewEventEmitter::OnModeChange event = {
.mode = (int)newMode,
.targetRect =
@@ -198,24 +275,24 @@ static BOOL sIsAccessibilityUsed = NO;
case RCTVirtualViewModeVisible:
if (_renderState == RCTVirtualViewRenderStateUnknown) {
// Feature flag is disabled, so use the former logic.
[self _dispatchSyncModeChange:event];
[self dispatchSyncModeChange:event];
} else {
// If the previous mode was prerender and the result of dispatching that event was committed, we do not need
// to dispatch an event for visible.
// If the previous mode was prerender and the result of dispatching that event was committed, we do not need to
// dispatch an event for visible.
const auto wasPrerenderCommitted = oldMode.has_value() && oldMode == RCTVirtualViewModePrerender &&
_renderState == RCTVirtualViewRenderStateRendered;
if (!wasPrerenderCommitted) {
[self _dispatchSyncModeChange:event];
[self dispatchSyncModeChange:event];
}
}
break;
case RCTVirtualViewModePrerender:
if (!oldMode.has_value() || oldMode != RCTVirtualViewModeVisible) {
[self _dispatchAsyncModeChange:event];
[self dispatchAsyncModeChange:event];
}
break;
case RCTVirtualViewModeHidden:
[self _dispatchAsyncModeChange:event];
[self dispatchAsyncModeChange:event];
break;
}
@@ -234,33 +311,7 @@ static BOOL sIsAccessibilityUsed = NO;
}
}
#pragma mark - Private API
- (void)_unhideIfNeeded
{
if (!sIsAccessibilityUsed) {
// accessibility is detected for the first time. Make views visible.
sIsAccessibilityUsed = YES;
}
if (self.hidden) {
self.hidden = NO;
}
}
- (id<RCTVirtualViewContainerProtocol>)_getParentVirtualViewContainer
{
UIView *view = self.superview;
while (view != nil) {
if ([view respondsToSelector:@selector(virtualViewContainerState)]) {
return (id<RCTVirtualViewContainerProtocol>)view;
}
view = view.superview;
}
return nil;
}
- (void)_dispatchAsyncModeChange:(VirtualViewEventEmitter::OnModeChange &)event
- (void)dispatchAsyncModeChange:(VirtualViewEventEmitter::OnModeChange &)event
{
if (!_eventEmitter) {
return;
@@ -271,7 +322,7 @@ static BOOL sIsAccessibilityUsed = NO;
emitter->onModeChange(event);
}
- (void)_dispatchSyncModeChange:(VirtualViewEventEmitter::OnModeChange &)event
- (void)dispatchSyncModeChange:(VirtualViewEventEmitter::OnModeChange &)event
{
if (!_eventEmitter) {
return;
@@ -3348,8 +3348,10 @@ public final class com/facebook/react/uimanager/DisplayMetricsHolder {
public static final fun getDisplayMetricsWritableMap (D)Lcom/facebook/react/bridge/WritableMap;
public static final fun getScreenDisplayMetrics ()Landroid/util/DisplayMetrics;
public static final fun getWindowDisplayMetrics ()Landroid/util/DisplayMetrics;
public static final fun initDisplayMetrics (Landroid/content/Context;)V
public static final fun initDisplayMetricsIfNotInitialized (Landroid/content/Context;)V
public static final fun initScreenDisplayMetrics (Landroid/content/Context;)V
public static final fun initScreenDisplayMetricsIfNotInitialized (Landroid/content/Context;)V
public static final fun initWindowDisplayMetrics (Landroid/content/Context;)V
public static final fun initWindowDisplayMetricsIfNotInitialized (Landroid/content/Context;)V
public static final fun setScreenDisplayMetrics (Landroid/util/DisplayMetrics;)V
public static final fun setWindowDisplayMetrics (Landroid/util/DisplayMetrics;)V
}
@@ -3613,30 +3615,30 @@ public final class com/facebook/react/uimanager/PointerEvents$Companion {
}
public class com/facebook/react/uimanager/ReactAccessibilityDelegate : androidx/customview/widget/ExploreByTouchHelper {
public static final field Companion Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Companion;
public static final field TOP_ACCESSIBILITY_ACTION_EVENT Ljava/lang/String;
public static final field sActionIdMap Ljava/util/HashMap;
public fun <init> (Landroid/view/View;ZI)V
public static final fun createNodeInfoFromView (Landroid/view/View;)Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;
public static fun createNodeInfoFromView (Landroid/view/View;)Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;
public fun getAccessibilityNodeProvider (Landroid/view/View;)Landroidx/core/view/accessibility/AccessibilityNodeProviderCompat;
protected final fun getHostView ()Landroid/view/View;
public static final fun getTalkbackDescription (Landroid/view/View;Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;)Ljava/lang/CharSequence;
protected fun getHostView ()Landroid/view/View;
public static fun getTalkbackDescription (Landroid/view/View;Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;)Ljava/lang/CharSequence;
protected fun getVirtualViewAt (FF)I
protected fun getVisibleVirtualViews (Ljava/util/List;)V
public static final fun hasNonActionableSpeakingDescendants (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;Landroid/view/View;)Z
public static final fun hasText (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;)Z
public static final fun hasValidRangeInfo (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;)Z
public static final fun isAccessibilityFocusable (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;Landroid/view/View;)Z
public static final fun isActionableForAccessibility (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;)Z
public static final fun isSpeakingNode (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;Landroid/view/View;)Z
public static fun hasNonActionableSpeakingDescendants (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;Landroid/view/View;)Z
public static fun hasText (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;)Z
public static fun hasValidRangeInfo (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;)Z
public static fun isAccessibilityFocusable (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;Landroid/view/View;)Z
public static fun isActionableForAccessibility (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;)Z
public static fun isSpeakingNode (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;Landroid/view/View;)Z
public fun onInitializeAccessibilityEvent (Landroid/view/View;Landroid/view/accessibility/AccessibilityEvent;)V
public fun onInitializeAccessibilityNodeInfo (Landroid/view/View;Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;)V
protected fun onPerformActionForVirtualView (IILandroid/os/Bundle;)Z
protected fun onPopulateNodeForVirtualView (ILandroidx/core/view/accessibility/AccessibilityNodeInfoCompat;)V
public fun performAccessibilityAction (Landroid/view/View;ILandroid/os/Bundle;)Z
public static final fun resetDelegate (Landroid/view/View;ZI)V
public static final fun setDelegate (Landroid/view/View;ZI)V
public static final fun setRole (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;Landroid/content/Context;)V
protected final fun superGetAccessibilityNodeProvider (Landroid/view/View;)Landroidx/core/view/accessibility/AccessibilityNodeProviderCompat;
public static fun resetDelegate (Landroid/view/View;ZI)V
public static fun setDelegate (Landroid/view/View;ZI)V
public static fun setRole (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;Landroid/content/Context;)V
public fun superGetAccessibilityNodeProvider (Landroid/view/View;)Landroidx/core/view/accessibility/AccessibilityNodeProviderCompat;
}
public final class com/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole : java/lang/Enum {
@@ -3645,7 +3647,6 @@ public final class com/facebook/react/uimanager/ReactAccessibilityDelegate$Acces
public static final field BUTTON Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public static final field CHECKBOX Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public static final field COMBOBOX Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public static final field Companion Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole$Companion;
public static final field DRAWERLAYOUT Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public static final field DROPDOWNLIST Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public static final field GRID Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
@@ -3680,36 +3681,14 @@ public final class com/facebook/react/uimanager/ReactAccessibilityDelegate$Acces
public static final field TOOLBAR Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public static final field VIEWGROUP Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public static final field WEBVIEW Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public static final fun fromRole (Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;)Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public static final fun fromValue (Ljava/lang/String;)Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public static final fun fromViewTag (Landroid/view/View;)Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static final fun getValue (Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;)Ljava/lang/String;
public static fun fromRole (Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;)Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public static fun fromValue (Ljava/lang/String;)Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public static fun fromViewTag (Landroid/view/View;)Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public static fun getValue (Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;)Ljava/lang/String;
public static fun valueOf (Ljava/lang/String;)Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public static fun values ()[Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
}
public final class com/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole$Companion {
public final fun fromRole (Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;)Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public final fun fromValue (Ljava/lang/String;)Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public final fun fromViewTag (Landroid/view/View;)Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public final fun getValue (Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;)Ljava/lang/String;
}
public final class com/facebook/react/uimanager/ReactAccessibilityDelegate$Companion {
public final fun createNodeInfoFromView (Landroid/view/View;)Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;
public final fun getTalkbackDescription (Landroid/view/View;Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;)Ljava/lang/CharSequence;
public final fun hasNonActionableSpeakingDescendants (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;Landroid/view/View;)Z
public final fun hasText (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;)Z
public final fun hasValidRangeInfo (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;)Z
public final fun isAccessibilityFocusable (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;Landroid/view/View;)Z
public final fun isActionableForAccessibility (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;)Z
public final fun isSpeakingNode (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;Landroid/view/View;)Z
public final fun resetDelegate (Landroid/view/View;ZI)V
public final fun setDelegate (Landroid/view/View;ZI)V
public final fun setRole (Landroidx/core/view/accessibility/AccessibilityNodeInfoCompat;Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;Landroid/content/Context;)V
}
public final class com/facebook/react/uimanager/ReactAccessibilityDelegate$Role : java/lang/Enum {
public static final field ALERT Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
public static final field ALERTDIALOG Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
@@ -3723,7 +3702,6 @@ public final class com/facebook/react/uimanager/ReactAccessibilityDelegate$Role
public static final field COMBOBOX Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
public static final field COMPLEMENTARY Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
public static final field CONTENTINFO Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
public static final field Companion Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role$Companion;
public static final field DEFINITION Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
public static final field DIALOG Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
public static final field DIRECTORY Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
@@ -3777,16 +3755,11 @@ public final class com/facebook/react/uimanager/ReactAccessibilityDelegate$Role
public static final field TREE Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
public static final field TREEGRID Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
public static final field TREEITEM Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
public static final fun fromValue (Ljava/lang/String;)Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun fromValue (Ljava/lang/String;)Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
public static fun valueOf (Ljava/lang/String;)Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
public static fun values ()[Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
}
public final class com/facebook/react/uimanager/ReactAccessibilityDelegate$Role$Companion {
public final fun fromValue (Ljava/lang/String;)Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
}
public final class com/facebook/react/uimanager/ReactAxOrderHelper {
public static final field INSTANCE Lcom/facebook/react/uimanager/ReactAxOrderHelper;
public final fun buildAxOrderList (Landroid/view/View;Landroid/view/View;Ljava/util/List;[Landroid/view/View;)V
@@ -6041,7 +6014,6 @@ public final class com/facebook/react/views/text/DefaultStyleValuesUtil {
}
public abstract class com/facebook/react/views/text/ReactBaseTextShadowNode : com/facebook/react/uimanager/LayoutShadowNode {
public static final field Companion Lcom/facebook/react/views/text/ReactBaseTextShadowNode$Companion;
public static final field DEFAULT_TEXT_SHADOW_COLOR I
public static final field PROP_SHADOW_COLOR Ljava/lang/String;
public static final field PROP_SHADOW_OFFSET Ljava/lang/String;
@@ -6049,86 +6021,61 @@ public abstract class com/facebook/react/views/text/ReactBaseTextShadowNode : co
public static final field PROP_SHADOW_OFFSET_WIDTH Ljava/lang/String;
public static final field PROP_SHADOW_RADIUS Ljava/lang/String;
public static final field PROP_TEXT_TRANSFORM Ljava/lang/String;
protected field mAccessibilityRole Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
protected field mAdjustsFontSizeToFit Z
protected field mBackgroundColor I
protected field mColor I
protected field mContainsImages Z
protected field mFontFamily Ljava/lang/String;
protected field mFontFeatureSettings Ljava/lang/String;
protected field mFontStyle I
protected field mFontWeight I
protected field mHyphenationFrequency I
protected field mIncludeFontPadding Z
protected field mInlineViews Ljava/util/Map;
protected field mIsBackgroundColorSet Z
protected field mIsColorSet Z
protected field mIsLineThroughTextDecorationSet Z
protected field mIsUnderlineTextDecorationSet Z
protected field mJustificationMode I
protected field mMinimumFontScale F
protected field mNumberOfLines I
protected field mReactTextViewManagerCallback Lcom/facebook/react/views/text/ReactTextViewManagerCallback;
protected field mRole Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
protected field mTextAlign I
protected field mTextAttributes Lcom/facebook/react/views/text/TextAttributes;
protected field mTextBreakStrategy I
protected field mTextShadowColor I
protected field mTextShadowOffsetDx F
protected field mTextShadowOffsetDy F
protected field mTextShadowRadius F
public fun <init> ()V
public fun <init> (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;)V
public synthetic fun <init> (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
protected final fun getAccessibilityRole ()Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
protected final fun getAdjustsFontSizeToFit ()Z
protected final fun getBackgroundColor ()I
protected final fun getColor ()I
protected final fun getContainsImages ()Z
protected final fun getFontFamily ()Ljava/lang/String;
protected final fun getFontFeatureSettings ()Ljava/lang/String;
protected final fun getFontStyle ()I
protected final fun getFontWeight ()I
protected final fun getHyphenationFrequency ()I
protected final fun getIncludeFontPadding ()Z
protected final fun getInlineViews ()Ljava/util/Map;
protected final fun getJustificationMode ()I
protected final fun getMinimumFontScale ()F
protected final fun getNumberOfLines ()I
protected final fun getReactTextViewManagerCallback ()Lcom/facebook/react/views/text/ReactTextViewManagerCallback;
protected final fun getRole ()Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
protected final fun getTextAlign ()I
protected final fun getTextAttributes ()Lcom/facebook/react/views/text/TextAttributes;
protected final fun getTextBreakStrategy ()I
protected final fun getTextShadowColor ()I
protected final fun getTextShadowOffsetDx ()F
protected final fun getTextShadowOffsetDy ()F
protected final fun getTextShadowRadius ()F
protected final fun isBackgroundColorSet ()Z
protected final fun isColorSet ()Z
protected final fun isLineThroughTextDecorationSet ()Z
protected final fun isUnderlineTextDecorationSet ()Z
protected final fun setAccessibilityRole (Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;)V
public final fun setAccessibilityRole (Ljava/lang/String;)V
public final fun setAdjustFontSizeToFit (Z)V
protected final fun setAdjustsFontSizeToFit (Z)V
public final fun setAllowFontScaling (Z)V
protected final fun setBackgroundColor (I)V
public final fun setBackgroundColor (Ljava/lang/Integer;)V
protected final fun setBackgroundColorSet (Z)V
protected final fun setColor (I)V
public final fun setColor (Ljava/lang/Integer;)V
protected final fun setColorSet (Z)V
protected final fun setContainsImages (Z)V
public final fun setFontFamily (Ljava/lang/String;)V
protected final fun setFontFeatureSettings (Ljava/lang/String;)V
public final fun setFontSize (F)V
protected final fun setFontStyle (I)V
public final fun setFontStyle (Ljava/lang/String;)V
public final fun setFontVariant (Lcom/facebook/react/bridge/ReadableArray;)V
protected final fun setFontWeight (I)V
public final fun setFontWeight (Ljava/lang/String;)V
protected final fun setHyphenationFrequency (I)V
public final fun setIncludeFontPadding (Z)V
protected final fun setInlineViews (Ljava/util/Map;)V
protected final fun setJustificationMode (I)V
public final fun setLetterSpacing (F)V
public final fun setLineHeight (F)V
protected final fun setLineThroughTextDecorationSet (Z)V
public final fun setMaxFontSizeMultiplier (F)V
public final fun setMinimumFontScale (F)V
public final fun setNumberOfLines (I)V
protected final fun setReactTextViewManagerCallback (Lcom/facebook/react/views/text/ReactTextViewManagerCallback;)V
protected final fun setRole (Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;)V
public final fun setRole (Ljava/lang/String;)V
public final fun setTextAlign (Ljava/lang/String;)V
protected final fun setTextAttributes (Lcom/facebook/react/views/text/TextAttributes;)V
protected final fun setTextBreakStrategy (I)V
public fun setAccessibilityRole (Ljava/lang/String;)V
public fun setAdjustFontSizeToFit (Z)V
public fun setAllowFontScaling (Z)V
public fun setBackgroundColor (Ljava/lang/Integer;)V
public fun setColor (Ljava/lang/Integer;)V
public fun setFontFamily (Ljava/lang/String;)V
public fun setFontSize (F)V
public fun setFontStyle (Ljava/lang/String;)V
public fun setFontVariant (Lcom/facebook/react/bridge/ReadableArray;)V
public fun setFontWeight (Ljava/lang/String;)V
public fun setIncludeFontPadding (Z)V
public fun setLetterSpacing (F)V
public fun setLineHeight (F)V
public fun setMaxFontSizeMultiplier (F)V
public fun setMinimumFontScale (F)V
public fun setNumberOfLines (I)V
public fun setRole (Ljava/lang/String;)V
public fun setTextAlign (Ljava/lang/String;)V
public fun setTextBreakStrategy (Ljava/lang/String;)V
public final fun setTextDecorationLine (Ljava/lang/String;)V
public final fun setTextShadowColor (I)V
public final fun setTextShadowOffset (Lcom/facebook/react/bridge/ReadableMap;)V
protected final fun setTextShadowOffsetDx (F)V
protected final fun setTextShadowOffsetDy (F)V
public final fun setTextShadowRadius (F)V
public final fun setTextTransform (Ljava/lang/String;)V
protected final fun setUnderlineTextDecorationSet (Z)V
protected final fun spannedFromShadowNode (Lcom/facebook/react/views/text/ReactBaseTextShadowNode;Ljava/lang/String;ZLcom/facebook/react/uimanager/NativeViewHierarchyOptimizer;)Landroid/text/Spannable;
}
public final class com/facebook/react/views/text/ReactBaseTextShadowNode$Companion {
public fun setTextDecorationLine (Ljava/lang/String;)V
public fun setTextShadowColor (I)V
public fun setTextShadowOffset (Lcom/facebook/react/bridge/ReadableMap;)V
public fun setTextShadowRadius (F)V
public fun setTextTransform (Ljava/lang/String;)V
protected fun spannedFromShadowNode (Lcom/facebook/react/views/text/ReactBaseTextShadowNode;Ljava/lang/String;ZLcom/facebook/react/uimanager/NativeViewHierarchyOptimizer;)Landroid/text/Spannable;
}
public final class com/facebook/react/views/text/ReactFontManager {
@@ -6266,74 +6213,97 @@ public final class com/facebook/react/views/text/ReactTypefaceUtils {
public static final fun parseFontWeight (Ljava/lang/String;)I
}
public final class com/facebook/react/views/text/TextAttributeProps {
public static final field Companion Lcom/facebook/react/views/text/TextAttributeProps$Companion;
public static final field TA_KEY_ACCESSIBILITY_ROLE I
public static final field TA_KEY_ALIGNMENT I
public static final field TA_KEY_ALLOW_FONT_SCALING I
public static final field TA_KEY_BACKGROUND_COLOR I
public static final field TA_KEY_BEST_WRITING_DIRECTION I
public static final field TA_KEY_FONT_FAMILY I
public static final field TA_KEY_FONT_SIZE I
public static final field TA_KEY_FONT_SIZE_MULTIPLIER I
public static final field TA_KEY_FONT_STYLE I
public static final field TA_KEY_FONT_VARIANT I
public static final field TA_KEY_FONT_WEIGHT I
public static final field TA_KEY_FOREGROUND_COLOR I
public static final field TA_KEY_IS_HIGHLIGHTED I
public static final field TA_KEY_LAYOUT_DIRECTION I
public static final field TA_KEY_LETTER_SPACING I
public static final field TA_KEY_LINE_BREAK_STRATEGY I
public static final field TA_KEY_LINE_HEIGHT I
public static final field TA_KEY_MAX_FONT_SIZE_MULTIPLIER I
public static final field TA_KEY_OPACITY I
public static final field TA_KEY_ROLE I
public static final field TA_KEY_TEXT_DECORATION_COLOR I
public static final field TA_KEY_TEXT_DECORATION_LINE I
public static final field TA_KEY_TEXT_DECORATION_STYLE I
public static final field TA_KEY_TEXT_SHADOW_COLOR I
public static final field TA_KEY_TEXT_SHADOW_OFFSET_DX I
public static final field TA_KEY_TEXT_SHADOW_OFFSET_DY I
public static final field TA_KEY_TEXT_SHADOW_RADIUS I
public static final field TA_KEY_TEXT_TRANSFORM I
public class com/facebook/react/views/text/TextAttributeProps {
public static final field TA_KEY_ACCESSIBILITY_ROLE S
public static final field TA_KEY_ALIGNMENT S
public static final field TA_KEY_ALLOW_FONT_SCALING S
public static final field TA_KEY_BACKGROUND_COLOR S
public static final field TA_KEY_BEST_WRITING_DIRECTION S
public static final field TA_KEY_FONT_FAMILY S
public static final field TA_KEY_FONT_SIZE S
public static final field TA_KEY_FONT_SIZE_MULTIPLIER S
public static final field TA_KEY_FONT_STYLE S
public static final field TA_KEY_FONT_VARIANT S
public static final field TA_KEY_FONT_WEIGHT S
public static final field TA_KEY_FOREGROUND_COLOR S
public static final field TA_KEY_IS_HIGHLIGHTED S
public static final field TA_KEY_LAYOUT_DIRECTION S
public static final field TA_KEY_LETTER_SPACING S
public static final field TA_KEY_LINE_BREAK_STRATEGY S
public static final field TA_KEY_LINE_HEIGHT S
public static final field TA_KEY_MAX_FONT_SIZE_MULTIPLIER S
public static final field TA_KEY_OPACITY S
public static final field TA_KEY_ROLE S
public static final field TA_KEY_TEXT_DECORATION_COLOR S
public static final field TA_KEY_TEXT_DECORATION_LINE S
public static final field TA_KEY_TEXT_DECORATION_STYLE S
public static final field TA_KEY_TEXT_SHADOW_COLOR S
public static final field TA_KEY_TEXT_SHADOW_OFFSET_DX S
public static final field TA_KEY_TEXT_SHADOW_OFFSET_DY S
public static final field TA_KEY_TEXT_SHADOW_RADIUS S
public static final field TA_KEY_TEXT_TRANSFORM S
public static final field UNSET I
public final fun getAccessibilityRole ()Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public final fun getAllowFontScaling ()Z
public final fun getBackgroundColor ()Ljava/lang/Integer;
public final fun getColor ()Ljava/lang/Integer;
public final fun getEffectiveLetterSpacing ()F
public final fun getEffectiveLineHeight ()F
public final fun getFontFamily ()Ljava/lang/String;
public final fun getFontFeatureSettings ()Ljava/lang/String;
public final fun getFontSize ()I
public final fun getFontStyle ()I
public final fun getFontWeight ()I
public final fun getLayoutDirection ()I
public final fun getLetterSpacing ()F
public final fun getLineHeight ()F
public final fun getMaxFontSizeMultiplier ()F
public final fun getNumberOfLines ()I
public final fun getOpacity ()F
public final fun getRole ()Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
public final fun getTextShadowColor ()I
public final fun getTextShadowOffsetDx ()F
public final fun getTextShadowOffsetDy ()F
public final fun getTextShadowRadius ()F
public final fun isBackgroundColorSet ()Z
public final fun isColorSet ()Z
public final fun isLineThroughTextDecorationSet ()Z
public final fun isUnderlineTextDecorationSet ()Z
}
public final class com/facebook/react/views/text/TextAttributeProps$Companion {
public final fun fromMapBuffer (Lcom/facebook/react/common/mapbuffer/MapBuffer;)Lcom/facebook/react/views/text/TextAttributeProps;
public final fun fromReadableMap (Lcom/facebook/react/uimanager/ReactStylesDiffMap;)Lcom/facebook/react/views/text/TextAttributeProps;
public final fun getEllipsizeMode (Ljava/lang/String;)Landroid/text/TextUtils$TruncateAt;
public final fun getHyphenationFrequency (Ljava/lang/String;)I
public final fun getJustificationMode (Lcom/facebook/react/uimanager/ReactStylesDiffMap;I)I
public final fun getLayoutDirection (Ljava/lang/String;)I
public final fun getTextAlignment (Lcom/facebook/react/uimanager/ReactStylesDiffMap;ZI)I
public final fun getTextBreakStrategy (Ljava/lang/String;)I
protected field mAccessibilityRole Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
protected field mAllowFontScaling Z
protected field mBackgroundColor I
protected field mColor I
protected field mContainsImages Z
protected field mFontFamily Ljava/lang/String;
protected field mFontFeatureSettings Ljava/lang/String;
protected field mFontSize I
protected field mFontSizeInput F
protected field mFontStyle I
protected field mFontWeight I
protected field mHeightOfTallestInlineImage F
protected field mIncludeFontPadding Z
protected field mIsBackgroundColorSet Z
protected field mIsColorSet Z
protected field mIsLineThroughTextDecorationSet Z
protected field mIsUnderlineTextDecorationSet Z
protected field mLayoutDirection I
protected field mLetterSpacingInput F
protected field mLineHeight F
protected field mLineHeightInput F
protected field mMaxFontSizeMultiplier F
protected field mNumberOfLines I
protected field mOpacity F
protected field mRole Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
protected field mTextAlign I
protected field mTextShadowColor I
protected field mTextShadowOffsetDx F
protected field mTextShadowOffsetDy F
protected field mTextShadowRadius F
protected field mTextTransform Lcom/facebook/react/views/text/TextTransform;
public static fun fromMapBuffer (Lcom/facebook/react/common/mapbuffer/MapBuffer;)Lcom/facebook/react/views/text/TextAttributeProps;
public static fun fromReadableMap (Lcom/facebook/react/uimanager/ReactStylesDiffMap;)Lcom/facebook/react/views/text/TextAttributeProps;
public fun getAccessibilityRole ()Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$AccessibilityRole;
public fun getBackgroundColor ()I
public fun getColor ()I
public fun getEffectiveFontSize ()I
public fun getEffectiveLetterSpacing ()F
public fun getEffectiveLineHeight ()F
public static fun getEllipsizeMode (Ljava/lang/String;)Landroid/text/TextUtils$TruncateAt;
public fun getFontFamily ()Ljava/lang/String;
public fun getFontFeatureSettings ()Ljava/lang/String;
public fun getFontStyle ()I
public fun getFontWeight ()I
public static fun getHyphenationFrequency (Ljava/lang/String;)I
public static fun getJustificationMode (Lcom/facebook/react/uimanager/ReactStylesDiffMap;I)I
public static fun getLayoutDirection (Ljava/lang/String;)I
public fun getLetterSpacing ()F
public fun getOpacity ()F
public fun getRole ()Lcom/facebook/react/uimanager/ReactAccessibilityDelegate$Role;
public static fun getTextAlignment (Lcom/facebook/react/uimanager/ReactStylesDiffMap;ZI)I
public static fun getTextBreakStrategy (Ljava/lang/String;)I
public fun getTextShadowColor ()I
public fun getTextShadowOffsetDx ()F
public fun getTextShadowOffsetDy ()F
public fun getTextShadowRadius ()F
public fun getTextTransform ()Lcom/facebook/react/views/text/TextTransform;
public fun isBackgroundColorSet ()Z
public fun isColorSet ()Z
public fun isLineThroughTextDecorationSet ()Z
public fun isUnderlineTextDecorationSet ()Z
}
public final class com/facebook/react/views/text/TextAttributes {
@@ -630,6 +630,7 @@ dependencies {
api(libs.androidx.autofill)
api(libs.androidx.swiperefreshlayout)
api(libs.androidx.tracing)
api(libs.androidx.window)
api(libs.fbjni)
api(libs.fresco)
@@ -30,6 +30,7 @@ import com.facebook.react.modules.debug.DevSettingsModule
import com.facebook.react.modules.debug.SourceCodeModule
import com.facebook.react.modules.deviceinfo.DeviceInfoModule
import com.facebook.react.modules.systeminfo.AndroidInfoModule
import com.facebook.react.uimanager.UIManagerModule
import com.facebook.react.uimanager.ViewManager
import com.facebook.react.uimanager.ViewManagerResolver
import com.facebook.systrace.Systrace
@@ -37,7 +38,6 @@ import com.facebook.systrace.Systrace
/**
* This is the basic module to support React Native. The debug modules are now in DebugCorePackage.
*/
@Suppress("DEPRECATION")
@ReactModuleList(
// WARNING: If you modify this list, ensure that the list below in method
// getReactModuleInfoByInitialization is also updated
@@ -53,11 +53,9 @@ import com.facebook.systrace.Systrace
HeadlessJsTaskSupportModule::class,
SourceCodeModule::class,
TimingModule::class,
com.facebook.react.uimanager.UIManagerModule::class])
UIManagerModule::class])
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING)
@Suppress("DEPRECATION")
internal class CoreModulesPackage(
private val reactInstanceManager: ReactInstanceManager,
private val hardwareBackBtnHandler: DefaultHardwareBackBtnHandler,
@@ -105,7 +103,7 @@ internal class CoreModulesPackage(
HeadlessJsTaskSupportModule::class.java,
SourceCodeModule::class.java,
TimingModule::class.java,
com.facebook.react.uimanager.UIManagerModule::class.java,
UIManagerModule::class.java,
)
val reactModuleInfoMap: MutableMap<String, ReactModuleInfo> = HashMap<String, ReactModuleInfo>()
@@ -142,7 +140,7 @@ internal class CoreModulesPackage(
HeadlessJsTaskSupportModule.NAME -> HeadlessJsTaskSupportModule(reactContext)
SourceCodeModule.NAME -> SourceCodeModule(reactContext)
TimingModule.NAME -> TimingModule(reactContext, reactInstanceManager.devSupportManager)
com.facebook.react.uimanager.UIManagerModule.NAME -> createUIManager(reactContext)
UIManagerModule.NAME -> createUIManager(reactContext)
DeviceInfoModule.NAME -> DeviceInfoModule(reactContext)
else ->
throw IllegalArgumentException(
@@ -150,9 +148,7 @@ internal class CoreModulesPackage(
}
}
private fun createUIManager(
reactContext: ReactApplicationContext
): com.facebook.react.uimanager.UIManagerModule {
private fun createUIManager(reactContext: ReactApplicationContext): UIManagerModule {
ReactMarker.logMarker(ReactMarkerConstants.CREATE_UI_MANAGER_MODULE_START)
Systrace.beginSection(Systrace.TRACE_TAG_REACT, "createUIManagerModule")
@@ -169,10 +165,9 @@ internal class CoreModulesPackage(
}
}
return com.facebook.react.uimanager.UIManagerModule(
reactContext, resolver, minTimeLeftInFrameForNonBatchedOperationMs)
return UIManagerModule(reactContext, resolver, minTimeLeftInFrameForNonBatchedOperationMs)
} else {
return com.facebook.react.uimanager.UIManagerModule(
return UIManagerModule(
reactContext,
reactInstanceManager.getOrCreateViewManagers(reactContext),
minTimeLeftInFrameForNonBatchedOperationMs)
@@ -5,8 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react
import com.facebook.react.bridge.ModuleHolder
@@ -18,9 +16,6 @@ import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger
/** Helper class to build NativeModuleRegistry. */
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING)
public class NativeModuleRegistryBuilder(
private val reactApplicationContext: ReactApplicationContext,
) {
@@ -262,7 +262,11 @@ public class ReactInstanceManager {
FLog.d(TAG, "ReactInstanceManager.ctor()");
initializeSoLoaderIfNecessary(applicationContext);
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(applicationContext);
DisplayMetricsHolder.initScreenDisplayMetricsIfNotInitialized(applicationContext);
if (currentActivity != null) {
DisplayMetricsHolder.initWindowDisplayMetricsIfNotInitialized(currentActivity);
}
// See {@code ReactInstanceManagerBuilder} for description of all flags here.
mApplicationContext = applicationContext;
@@ -927,6 +931,13 @@ public class ReactInstanceManager {
ReactContext currentReactContext = getCurrentReactContext();
if (currentReactContext != null) {
DisplayMetricsHolder.initScreenDisplayMetrics(currentReactContext);
Activity currentActivity = currentReactContext.getCurrentActivity();
if (currentActivity != null) {
DisplayMetricsHolder.initWindowDisplayMetrics(currentActivity);
}
AppearanceModule appearanceModule =
currentReactContext.getNativeModule(AppearanceModule.class);
@@ -136,9 +136,8 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
setRootViewTag(ReactRootViewTagGenerator.getNextRootViewTag());
setClipChildren(false);
if (ReactNativeFeatureFlags.enableFontScaleChangesUpdatingLayout()) {
DisplayMetricsHolder.initDisplayMetrics(getContext().getApplicationContext());
}
DisplayMetricsHolder.initScreenDisplayMetrics(getContext());
DisplayMetricsHolder.initWindowDisplayMetrics(getContext());
}
@Override
@@ -883,7 +882,8 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
private int mDeviceRotation = 0;
/* package */ CustomGlobalLayoutListener() {
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(getContext().getApplicationContext());
DisplayMetricsHolder.initScreenDisplayMetricsIfNotInitialized(getContext());
DisplayMetricsHolder.initWindowDisplayMetricsIfNotInitialized(getContext());
mVisibleViewArea = new Rect();
mMinKeyboardHeightDetected = (int) PixelUtil.toPixelFromDIP(60);
}
@@ -1006,7 +1006,8 @@ public class ReactRootView extends FrameLayout implements RootView, ReactRoot {
return;
}
mDeviceRotation = rotation;
DisplayMetricsHolder.initDisplayMetrics(getContext().getApplicationContext());
DisplayMetricsHolder.initScreenDisplayMetrics(getContext());
DisplayMetricsHolder.initWindowDisplayMetrics(getContext());
emitOrientationChanged(rotation);
}
@@ -28,6 +28,7 @@ import com.facebook.react.modules.core.ReactChoreographer
import com.facebook.react.uimanager.GuardedFrameCallback
import com.facebook.react.uimanager.UIBlock
import com.facebook.react.uimanager.UIManagerHelper
import com.facebook.react.uimanager.UIManagerModule
import com.facebook.react.uimanager.common.UIManagerType
import com.facebook.react.uimanager.common.ViewUtil
import java.util.ArrayList
@@ -73,9 +74,9 @@ import kotlin.concurrent.Volatile
* that coordinates all the action: [NativeAnimatedNodesManager]. Since all the methods from
* [NativeAnimatedNodesManager] need to be called from the UI thread, we we create a queue of
* animated graph operations that is then enqueued to be executed in the UI Thread at the end of the
* batch of JS->native calls (similarly to how it's handled in
* [com.facebook.react.uimanager.UIManagerModule]). This isolates us from the problems that may be
* caused by concurrent updates of animated graph while UI thread is "executing" the animation loop.
* batch of JS->native calls (similarly to how it's handled in [UIManagerModule]). This isolates us
* from the problems that may be caused by concurrent updates of animated graph while UI thread is
* "executing" the animation loop.
*/
@OptIn(UnstableReactNativeAPI::class)
@ReactModule(name = NativeAnimatedModuleSpec.NAME)
@@ -305,7 +306,6 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
}
// For non-FabricUIManager only
@Suppress("DEPRECATION")
@UiThread
override fun willDispatchViewUpdates(uiManager: UIManager) {
if (operations.isEmpty && preOperations.isEmpty) {
@@ -325,8 +325,8 @@ public class NativeAnimatedModule(reactContext: ReactApplicationContext) :
val operationsUIBlock = UIBlock { operations.executeBatch(frameNo, nodesManager) }
assert(uiManager is com.facebook.react.uimanager.UIManagerModule)
val uiManagerModule = uiManager as com.facebook.react.uimanager.UIManagerModule
assert(uiManager is UIManagerModule)
val uiManagerModule = uiManager as UIManagerModule
uiManagerModule.prependUIBlock(preOperationsUIBlock)
uiManagerModule.addUIBlock(operationsUIBlock)
}
@@ -40,8 +40,7 @@ import java.util.Objects;
*/
@VisibleForTesting
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
since = "This class is part of Legacy Architecture and will be removed in a future release")
@Deprecated
@Nullsafe(Nullsafe.Mode.LOCAL)
public class BridgeReactContext extends ReactApplicationContext {
static {
@@ -7,9 +7,15 @@
package com.facebook.react.bridge
import com.facebook.react.common.annotations.internal.LegacyArchitecture
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger
import com.facebook.soloader.SoLoader
internal object ReactNativeJNISoLoader {
@LegacyArchitecture
internal object BridgeSoLoader {
init {
LegacyArchitectureLogger.assertLegacyArchitecture("BridgeSoLoader")
}
@JvmStatic
@Synchronized
@@ -5,8 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react.bridge
import com.facebook.react.common.annotations.internal.LegacyArchitecture
@@ -15,9 +13,6 @@ import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger
/** Implementation of javascript callback function that uses Bridge to schedule method execution. */
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING)
internal class CallbackImpl(private val jsInstance: JSInstance, private val callbackId: Int) :
Callback {
private var invoked = false
@@ -5,8 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react.bridge
import com.facebook.proguard.annotations.DoNotStrip
@@ -48,11 +48,9 @@ import java.util.concurrent.atomic.AtomicInteger;
*/
@DoNotStrip
@LegacyArchitecture
@Deprecated(
since = "This class is part of Legacy Architecture and will be removed in a future release")
public class CatalystInstanceImpl implements CatalystInstance {
static {
ReactNativeJNISoLoader.staticInit();
BridgeSoLoader.staticInit();
LegacyArchitectureLogger.assertLegacyArchitecture(
"CatalystInstanceImpl", LegacyArchitectureLogLevel.WARNING);
}
@@ -50,7 +50,7 @@ protected constructor(
private companion object {
init {
ReactNativeJNISoLoader.staticInit()
BridgeSoLoader.staticInit()
LegacyArchitectureLogger.assertLegacyArchitecture(
"CxxModuleWrapperBase", LegacyArchitectureLogLevel.WARNING)
}
@@ -49,7 +49,7 @@ private constructor(@Suppress("NoHungarianNotation") private val mHybridData: Hy
public companion object {
init {
ReactNativeJNISoLoader.staticInit()
BridgeSoLoader.staticInit()
}
@JvmStatic
@@ -17,9 +17,6 @@ import com.facebook.systrace.SystraceMessage
import java.lang.reflect.InvocationTargetException
import java.lang.reflect.Method
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING)
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
internal class JavaMethodWrapper(
private val moduleWrapper: JavaModuleWrapper,
@@ -29,7 +26,6 @@ internal class JavaMethodWrapper(
private abstract class ArgumentExtractor<T> {
open fun getJSArgumentsNeeded(): Int = 1
@Suppress("DEPRECATION")
abstract fun extractArgument(
jsInstance: JSInstance,
jsArguments: ReadableArray,
@@ -161,7 +157,6 @@ internal class JavaMethodWrapper(
"$startIndex"
}
@Suppress("DEPRECATION")
override fun invoke(jsInstance: JSInstance, parameters: ReadableArray) {
val traceName = moduleWrapper.name + "." + method.name
SystraceMessage.beginSection(TRACE_TAG_REACT, "callJavaModuleMethod")
@@ -245,7 +240,6 @@ internal class JavaMethodWrapper(
private val ARGUMENT_EXTRACTOR_BOOLEAN: ArgumentExtractor<Boolean> =
object : ArgumentExtractor<Boolean>() {
@Suppress("DEPRECATION")
override fun extractArgument(
jsInstance: JSInstance,
jsArguments: ReadableArray,
@@ -255,7 +249,6 @@ internal class JavaMethodWrapper(
private val ARGUMENT_EXTRACTOR_DOUBLE: ArgumentExtractor<Double> =
object : ArgumentExtractor<Double>() {
@Suppress("DEPRECATION")
override fun extractArgument(
jsInstance: JSInstance,
jsArguments: ReadableArray,
@@ -265,7 +258,6 @@ internal class JavaMethodWrapper(
private val ARGUMENT_EXTRACTOR_FLOAT: ArgumentExtractor<Float> =
object : ArgumentExtractor<Float>() {
@Suppress("DEPRECATION")
override fun extractArgument(
jsInstance: JSInstance,
jsArguments: ReadableArray,
@@ -275,7 +267,6 @@ internal class JavaMethodWrapper(
private val ARGUMENT_EXTRACTOR_INTEGER: ArgumentExtractor<Int> =
object : ArgumentExtractor<Int>() {
@Suppress("DEPRECATION")
override fun extractArgument(
jsInstance: JSInstance,
jsArguments: ReadableArray,
@@ -285,7 +276,6 @@ internal class JavaMethodWrapper(
private val ARGUMENT_EXTRACTOR_STRING: ArgumentExtractor<String> =
object : ArgumentExtractor<String>() {
@Suppress("DEPRECATION")
override fun extractArgument(
jsInstance: JSInstance,
jsArguments: ReadableArray,
@@ -295,7 +285,6 @@ internal class JavaMethodWrapper(
private val ARGUMENT_EXTRACTOR_ARRAY: ArgumentExtractor<ReadableArray> =
object : ArgumentExtractor<ReadableArray>() {
@Suppress("DEPRECATION")
override fun extractArgument(
jsInstance: JSInstance,
jsArguments: ReadableArray,
@@ -305,7 +294,6 @@ internal class JavaMethodWrapper(
private val ARGUMENT_EXTRACTOR_DYNAMIC: ArgumentExtractor<Dynamic> =
object : ArgumentExtractor<Dynamic>() {
@Suppress("DEPRECATION")
override fun extractArgument(
jsInstance: JSInstance,
jsArguments: ReadableArray,
@@ -315,7 +303,6 @@ internal class JavaMethodWrapper(
private val ARGUMENT_EXTRACTOR_MAP: ArgumentExtractor<ReadableMap> =
object : ArgumentExtractor<ReadableMap>() {
@Suppress("DEPRECATION")
override fun extractArgument(
jsInstance: JSInstance,
jsArguments: ReadableArray,
@@ -325,7 +312,6 @@ internal class JavaMethodWrapper(
private val ARGUMENT_EXTRACTOR_CALLBACK: ArgumentExtractor<Callback> =
object : ArgumentExtractor<Callback>() {
@Suppress("DEPRECATION")
override fun extractArgument(
jsInstance: JSInstance,
jsArguments: ReadableArray,
@@ -335,7 +321,7 @@ internal class JavaMethodWrapper(
null
} else {
val id = jsArguments.getDouble(atIndex).toInt()
@Suppress("DEPRECATION") CallbackImpl(jsInstance, id)
CallbackImpl(jsInstance, id)
}
}
@@ -343,7 +329,6 @@ internal class JavaMethodWrapper(
object : ArgumentExtractor<Promise>() {
override fun getJSArgumentsNeeded(): Int = 2
@Suppress("DEPRECATION")
override fun extractArgument(
jsInstance: JSInstance,
jsArguments: ReadableArray,
@@ -25,11 +25,11 @@ import java.lang.reflect.Method
@DoNotStrip
@InteropLegacyArchitecture
internal class JavaModuleWrapper(
@Suppress("DEPRECATION") private val jsInstance: JSInstance,
private val jsInstance: JSInstance,
private val moduleHolder: ModuleHolder
) {
interface NativeMethod {
@Suppress("DEPRECATION") fun invoke(jsInstance: JSInstance, parameters: ReadableArray)
fun invoke(jsInstance: JSInstance, parameters: ReadableArray)
val type: String
}
@@ -74,7 +74,6 @@ internal class JavaModuleWrapper(
targetMethod.getAnnotation(ReactMethod::class.java)?.let { annotation ->
val methodName = targetMethod.name
val md = MethodDescriptor()
@Suppress("DEPRECATION")
val method = JavaMethodWrapper(this, targetMethod, annotation.isBlockingSynchronousMethod)
md.name = methodName
md.type = method.type
@@ -13,9 +13,6 @@ import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger
/** Exception thrown when a native module method call receives unexpected arguments from JS. */
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING)
internal class NativeArgumentsParseException : JSApplicationCausedNativeException {
constructor(detailMessage: String) : super(detailMessage)
@@ -5,8 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react.bridge
import com.facebook.react.bridge.ReactMarker.logMarker
@@ -21,9 +19,6 @@ import com.facebook.systrace.Systrace.endSection
/** A set of Java APIs to expose to a particular JavaScript instance. */
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING)
public class NativeModuleRegistry(
private val reactApplicationContext: ReactApplicationContext,
private val modules: MutableMap<String, ModuleHolder>
@@ -12,9 +12,6 @@ import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel
/** Interface for a module that will be notified when a batch of JS->Java calls has finished. */
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING)
public fun interface OnBatchCompleteListener {
public fun onBatchComplete()
}
@@ -16,9 +16,6 @@ import java.lang.reflect.Method
@DoNotStrip
@LegacyArchitecture
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING)
internal object ReactCxxErrorHandler {
init {
LegacyArchitectureLogger.assertLegacyArchitecture(
@@ -5,8 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react.bridge
import com.facebook.jni.HybridData
@@ -19,9 +17,6 @@ import java.util.concurrent.Executor
@DoNotStripAny
@LegacyArchitecture
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING)
internal class ReactInstanceManagerInspectorTarget(delegate: TargetDelegate) : AutoCloseable {
@DoNotStripAny
@@ -68,7 +63,7 @@ internal class ReactInstanceManagerInspectorTarget(delegate: TargetDelegate) : A
init {
LegacyArchitectureLogger.assertLegacyArchitecture(
"ReactInstanceManagerInspectorTarget", LegacyArchitectureLogLevel.WARNING)
ReactNativeJNISoLoader.staticInit()
BridgeSoLoader.staticInit()
}
}
}
@@ -15,9 +15,6 @@ import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel
* Native.
*/
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING)
public fun interface UIManagerProvider {
/* Provides a [com.facebook.react.bridge.UIManager] for the context received as a parameter. */
@@ -46,9 +46,6 @@ import com.facebook.react.packagerconnection.RequestHandler
* when all the views has been detached from the instance (through `setDevSupportEnabled` method).
*/
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING)
public class BridgeDevSupportManager(
applicationContext: Context,
reactInstanceManagerHelper: ReactInstanceDevHelper,
@@ -70,7 +70,6 @@ import com.facebook.react.internal.featureflags.ReactNativeNewArchitectureFeatur
import com.facebook.react.internal.interop.InteropEventEmitter;
import com.facebook.react.modules.core.ReactChoreographer;
import com.facebook.react.modules.i18nmanager.I18nUtil;
import com.facebook.react.uimanager.DisplayMetricsHolder;
import com.facebook.react.uimanager.GuardedFrameCallback;
import com.facebook.react.uimanager.IllegalViewOperationException;
import com.facebook.react.uimanager.PixelUtil;
@@ -98,7 +97,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -727,23 +725,6 @@ public class FabricUIManager
return true;
}
/**
* This method is used to get the encoded screen size without vertical insets for a given surface.
* It's used by the Modal component to determine the size of the screen without vertical insets.
* The method is private as it's accessed via JNI from C++.
*
* @param surfaceId The surface ID of the surface for which the Modal is going to render.
* @return The encoded screen size as a long (both width and height) are represented without
* vertical insets.
*/
private long getEncodedScreenSizeWithoutVerticalInsets(int surfaceId) {
SurfaceMountingManager surfaceMountingManager = mMountingManager.getSurfaceManager(surfaceId);
Objects.requireNonNull(surfaceMountingManager);
ThemedReactContext context = Objects.requireNonNull(surfaceMountingManager.getContext());
return DisplayMetricsHolder.getEncodedScreenSizeWithoutVerticalInsets(
context.getCurrentActivity());
}
@Override
public void addUIManagerEventListener(UIManagerListener listener) {
mListeners.add(listener);
@@ -935,14 +916,14 @@ public class FabricUIManager
if (shouldSchedule) {
Assertions.assertNotNull(mountItem, "MountItem is null");
mMountItemDispatcher.addMountItem(mountItem);
Runnable runnable =
new GuardedRunnable(mReactApplicationContext) {
@Override
public void runGuarded() {
mMountItemDispatcher.tryDispatchMountItems();
}
};
if (UiThreadUtil.isOnUiThread()) {
Runnable runnable =
new GuardedRunnable(mReactApplicationContext) {
@Override
public void runGuarded() {
mMountItemDispatcher.tryDispatchMountItems();
}
};
runnable.run();
}
}
@@ -5,8 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react.fabric
import com.facebook.react.bridge.ReactApplicationContext
@@ -22,9 +20,6 @@ import com.facebook.systrace.Systrace
* @param [componentFactory] The factory for creating components.
* @param [viewManagerRegistry] The registry of view managers.
*/
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING)
public class FabricUIManagerProviderImpl(
private val componentFactory: ComponentFactory,
private val viewManagerRegistry: ViewManagerRegistry
@@ -11,6 +11,7 @@ import android.view.Choreographer
import com.facebook.react.bridge.ReactContext
import com.facebook.react.bridge.UiThreadUtil
import com.facebook.react.common.build.ReactBuildConfig
import com.facebook.react.uimanager.UIManagerModule
/**
* Each time a frame is drawn, records whether it should have expected any more callbacks since the
@@ -61,8 +62,7 @@ internal class FpsDebugFrameCallback(private val reactContext: ReactContext) :
// removeBridgeIdleDebugListener for Bridgeless
@Suppress("DEPRECATION")
if (!ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE) {
val uiManagerModule =
reactContext.getNativeModule(com.facebook.react.uimanager.UIManagerModule::class.java)
val uiManagerModule = reactContext.getNativeModule(UIManagerModule::class.java)
if (!reactContext.isBridgeless) {
reactContext.catalystInstance.addBridgeIdleDebugListener(didJSUpdateUiDuringFrameDetector)
isRunningOnFabric = false
@@ -83,8 +83,7 @@ internal class FpsDebugFrameCallback(private val reactContext: ReactContext) :
fun stop() {
@Suppress("DEPRECATION")
if (!ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE) {
val uiManagerModule =
reactContext.getNativeModule(com.facebook.react.uimanager.UIManagerModule::class.java)
val uiManagerModule = reactContext.getNativeModule(UIManagerModule::class.java)
if (!reactContext.isBridgeless) {
reactContext.catalystInstance.removeBridgeIdleDebugListener(
didJSUpdateUiDuringFrameDetector)
@@ -15,7 +15,8 @@ import com.facebook.react.bridge.ReactSoftExceptionLogger
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.module.annotations.ReactModule
import com.facebook.react.uimanager.DisplayMetricsHolder.getDisplayMetricsWritableMap
import com.facebook.react.uimanager.DisplayMetricsHolder.initDisplayMetricsIfNotInitialized
import com.facebook.react.uimanager.DisplayMetricsHolder.initScreenDisplayMetricsIfNotInitialized
import com.facebook.react.uimanager.DisplayMetricsHolder.initWindowDisplayMetricsIfNotInitialized
import com.facebook.react.views.view.isEdgeToEdgeFeatureFlagOn
/** Module that exposes Android Constants to JS. */
@@ -26,7 +27,8 @@ internal class DeviceInfoModule(reactContext: ReactApplicationContext) :
private var previousDisplayMetrics: ReadableMap? = null
init {
initDisplayMetricsIfNotInitialized(reactContext)
initScreenDisplayMetricsIfNotInitialized(reactContext)
reactContext.currentActivity?.let { initWindowDisplayMetricsIfNotInitialized(it) }
reactContext.addLifecycleEventListener(this)
}
@@ -61,6 +61,7 @@ import com.facebook.react.runtime.internal.bolts.Task
import com.facebook.react.runtime.internal.bolts.TaskCompletionSource
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder
import com.facebook.react.uimanager.DisplayMetricsHolder
import com.facebook.react.uimanager.UIManagerModule
import com.facebook.react.uimanager.events.BlackHoleEventDispatcher
import com.facebook.react.uimanager.events.EventDispatcher
import com.facebook.react.views.imagehelper.ResourceDrawableIdHelper
@@ -522,10 +523,9 @@ public class ReactHostImpl(
internal val nativeModules: Collection<NativeModule>
get() = reactInstance?.nativeModules ?: listOf()
@Suppress("DEPRECATION")
internal fun <T : NativeModule> getNativeModule(nativeModuleInterface: Class<T>): T? {
if (!ReactBuildConfig.UNSTABLE_ENABLE_MINIFY_LEGACY_ARCHITECTURE &&
nativeModuleInterface == com.facebook.react.uimanager.UIManagerModule::class.java) {
nativeModuleInterface == UIManagerModule::class.java) {
ReactSoftExceptionLogger.logSoftExceptionVerbose(
TAG,
ReactNoCrashSoftException(
@@ -625,9 +625,8 @@ public class ReactHostImpl(
override fun onConfigurationChanged(context: Context) {
val currentReactContext = this.currentReactContext
if (currentReactContext != null) {
if (ReactNativeFeatureFlags.enableFontScaleChangesUpdatingLayout()) {
DisplayMetricsHolder.initDisplayMetrics(currentReactContext)
}
DisplayMetricsHolder.initScreenDisplayMetrics(currentReactContext)
currentReactContext.currentActivity?.let { DisplayMetricsHolder.initWindowDisplayMetrics(it) }
val appearanceModule = currentReactContext.getNativeModule(AppearanceModule::class.java)
appearanceModule?.onConfigurationChanged(context)
@@ -918,6 +917,7 @@ public class ReactHostImpl(
val instance =
ReactInstance(
reactContext,
currentActivity,
reactHostDelegate,
componentFactory,
devSupportManager,
@@ -7,6 +7,7 @@
package com.facebook.react.runtime
import android.app.Activity
import android.content.res.AssetManager
import android.view.View
import com.facebook.common.logging.FLog
@@ -88,6 +89,7 @@ import kotlin.jvm.JvmStatic
@UnstableReactNativeAPI
internal class ReactInstance(
private val context: BridgelessReactContext,
private val activity: Activity?,
delegate: ReactHostDelegate,
componentFactory: ComponentFactory,
devSupportManager: DevSupportManager,
@@ -240,7 +242,8 @@ internal class ReactInstance(
FabricUIManager(context, ViewManagerRegistry(viewManagerResolver), eventBeatManager)
// Misc initialization that needs to be done before Fabric init
DisplayMetricsHolder.initDisplayMetricsIfNotInitialized(context)
DisplayMetricsHolder.initScreenDisplayMetricsIfNotInitialized(context)
activity?.let { DisplayMetricsHolder.initWindowDisplayMetricsIfNotInitialized(it) }
val binding = FabricUIManagerBinding()
binding.register(
@@ -56,7 +56,9 @@ import com.facebook.react.views.scroll.ReactScrollViewManager
import com.facebook.react.views.swiperefresh.SwipeRefreshLayoutManager
import com.facebook.react.views.switchview.ReactSwitchManager
import com.facebook.react.views.text.PreparedLayoutTextViewManager
import com.facebook.react.views.text.ReactRawTextManager
import com.facebook.react.views.text.ReactTextViewManager
import com.facebook.react.views.text.ReactVirtualTextViewManager
import com.facebook.react.views.text.frescosupport.FrescoBasedReactTextInlineImageViewManager
import com.facebook.react.views.textinput.ReactTextInputManager
import com.facebook.react.views.unimplementedview.ReactUnimplementedViewManager
@@ -131,7 +133,6 @@ constructor(private val config: MainPackageConfig? = null) :
else -> null
}
@Suppress("DEPRECATION")
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> =
listOf(
ReactDrawerLayoutManager(),
@@ -146,19 +147,18 @@ constructor(private val config: MainPackageConfig? = null) :
FrescoBasedReactTextInlineImageViewManager(),
ReactImageManager(),
ReactModalHostManager(),
com.facebook.react.views.text.ReactRawTextManager(),
ReactRawTextManager(),
ReactTextInputManager(),
if (ReactNativeFeatureFlags.enablePreparedTextLayout()) PreparedLayoutTextViewManager()
else ReactTextViewManager(),
ReactViewManager(),
com.facebook.react.views.text.ReactVirtualTextViewManager(),
ReactVirtualTextViewManager(),
ReactUnimplementedViewManager())
/**
* A map of view managers that should be registered with
* [com.facebook.react.uimanager.UIManagerModule]
*/
@Suppress("DEPRECATION")
@SuppressLint("VisibleForTests")
public val viewManagersMap: Map<String, ModuleSpec> =
mapOf(
@@ -182,8 +182,7 @@ constructor(private val config: MainPackageConfig? = null) :
ReactImageManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactImageManager() },
ReactModalHostManager.REACT_CLASS to
ModuleSpec.viewManagerSpec { ReactModalHostManager() },
com.facebook.react.views.text.ReactRawTextManager.REACT_CLASS to
ModuleSpec.viewManagerSpec { com.facebook.react.views.text.ReactRawTextManager() },
ReactRawTextManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactRawTextManager() },
ReactTextInputManager.REACT_CLASS to
ModuleSpec.viewManagerSpec { ReactTextInputManager() },
ReactTextViewManager.REACT_CLASS to
@@ -193,10 +192,8 @@ constructor(private val config: MainPackageConfig? = null) :
else ReactTextViewManager()
},
ReactViewManager.REACT_CLASS to ModuleSpec.viewManagerSpec { ReactViewManager() },
com.facebook.react.views.text.ReactVirtualTextViewManager.REACT_CLASS to
ModuleSpec.viewManagerSpec {
com.facebook.react.views.text.ReactVirtualTextViewManager()
},
ReactVirtualTextViewManager.REACT_CLASS to
ModuleSpec.viewManagerSpec { ReactVirtualTextViewManager() },
ReactUnimplementedViewManager.REACT_CLASS to
ModuleSpec.viewManagerSpec { ReactUnimplementedViewManager() })
@@ -20,7 +20,7 @@ import com.facebook.yoga.YogaConstants
* every view should support, such as rotation, background color, etc.
*/
public abstract class BaseViewManagerDelegate<
T : View, @Suppress("DEPRECATION") U : BaseViewManager<T, out LayoutShadowNode>>(
T : View, U : BaseViewManager<T, out LayoutShadowNode>>(
@Suppress("NoHungarianNotation") @JvmField protected val mViewManager: U
) : ViewManagerDelegate<T> {
@Suppress("ACCIDENTAL_OVERRIDE", "DEPRECATION")
@@ -13,17 +13,20 @@ import android.util.DisplayMetrics
import android.view.WindowManager
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.window.layout.WindowMetricsCalculator
import com.facebook.react.bridge.WritableMap
import com.facebook.react.bridge.WritableNativeMap
import com.facebook.react.uimanager.PixelUtil.pxToDp
import com.facebook.react.views.view.isEdgeToEdgeFeatureFlagOn
/**
* Holds an instance of the current DisplayMetrics so we don't have to thread it through all the
* classes that need it.
*/
public object DisplayMetricsHolder {
private const val INITIALIZATION_MISSING_MESSAGE =
"DisplayMetricsHolder must be initialized with initDisplayMetricsIfNotInitialized or initDisplayMetrics"
private const val SCREEN_INITIALIZATION_MISSING_MESSAGE =
"DisplayMetricsHolder must be initialized with initScreenDisplayMetricsIfNotInitialized or initScreenDisplayMetrics"
private const val WINDOW_INITIALIZATION_MISSING_MESSAGE =
"DisplayMetricsHolder must be initialized with initWindowDisplayMetricsIfNotInitialized or initWindowDisplayMetrics"
@JvmStatic private var windowDisplayMetrics: DisplayMetrics? = null
@JvmStatic private var screenDisplayMetrics: DisplayMetrics? = null
@@ -31,7 +34,7 @@ public object DisplayMetricsHolder {
/** The metrics of the window associated to the Context used to initialize ReactNative */
@JvmStatic
public fun getWindowDisplayMetrics(): DisplayMetrics {
checkNotNull(windowDisplayMetrics) { INITIALIZATION_MISSING_MESSAGE }
checkNotNull(windowDisplayMetrics) { WINDOW_INITIALIZATION_MISSING_MESSAGE }
return windowDisplayMetrics as DisplayMetrics
}
@@ -43,7 +46,7 @@ public object DisplayMetricsHolder {
/** Screen metrics returns the metrics of the default screen on the device. */
@JvmStatic
public fun getScreenDisplayMetrics(): DisplayMetrics {
checkNotNull(screenDisplayMetrics) { INITIALIZATION_MISSING_MESSAGE }
checkNotNull(screenDisplayMetrics) { SCREEN_INITIALIZATION_MISSING_MESSAGE }
return screenDisplayMetrics as DisplayMetrics
}
@@ -53,33 +56,58 @@ public object DisplayMetricsHolder {
}
@JvmStatic
public fun initDisplayMetricsIfNotInitialized(context: Context) {
if (screenDisplayMetrics != null) {
return
public fun initScreenDisplayMetricsIfNotInitialized(context: Context) {
if (screenDisplayMetrics == null) {
initScreenDisplayMetrics(context)
}
initDisplayMetrics(context)
}
@JvmStatic
public fun initDisplayMetrics(context: Context) {
val displayMetrics = context.resources.displayMetrics
windowDisplayMetrics = displayMetrics
val screenDisplayMetrics = DisplayMetrics()
screenDisplayMetrics.setTo(displayMetrics)
public fun initWindowDisplayMetricsIfNotInitialized(context: Context) {
if (windowDisplayMetrics == null) {
initWindowDisplayMetrics(context)
}
}
@JvmStatic
public fun initScreenDisplayMetrics(context: Context) {
val displayMetrics = DisplayMetrics()
displayMetrics.setTo(context.resources.displayMetrics)
val wm = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
// Get the real display metrics if we are using API level 17 or higher.
// The real metrics include system decor elements (e.g. soft menu bar).
//
// See:
// http://developer.android.com/reference/android/view/Display.html#getRealMetrics(android.util.DisplayMetrics)
@Suppress("DEPRECATION") wm.defaultDisplay.getRealMetrics(screenDisplayMetrics)
DisplayMetricsHolder.screenDisplayMetrics = screenDisplayMetrics
@Suppress("DEPRECATION") wm.defaultDisplay.getRealMetrics(displayMetrics)
screenDisplayMetrics = displayMetrics
}
/*
* NOTE: Unlike [initScreenDisplayMetrics], this method needs a UiContext (Activity of
* InputMethodService) else WindowMetircsCalculator will throw an exception.
*/
@JvmStatic
public fun initWindowDisplayMetrics(context: Context) {
val displayMetrics = DisplayMetrics()
displayMetrics.setTo(context.resources.displayMetrics)
if (isEdgeToEdgeFeatureFlagOn) {
WindowMetricsCalculator.getOrCreate().computeCurrentWindowMetrics(context).let { windowMetrics
->
displayMetrics.widthPixels = windowMetrics.bounds.width()
displayMetrics.heightPixels = windowMetrics.bounds.height()
}
}
windowDisplayMetrics = displayMetrics
}
@JvmStatic
public fun getDisplayMetricsWritableMap(fontScale: Double): WritableMap {
checkNotNull(windowDisplayMetrics) { INITIALIZATION_MISSING_MESSAGE }
checkNotNull(screenDisplayMetrics) { INITIALIZATION_MISSING_MESSAGE }
checkNotNull(windowDisplayMetrics) { WINDOW_INITIALIZATION_MISSING_MESSAGE }
checkNotNull(screenDisplayMetrics) { SCREEN_INITIALIZATION_MISSING_MESSAGE }
return WritableNativeMap().apply {
putMap(
@@ -112,33 +140,4 @@ public object DisplayMetricsHolder {
WindowInsetsCompat.Type.displayCutout())
.top
}
/**
* Returns the encoded screen size without vertical insets.
*
* This is needed to render components that needs to be correctly positioned on the screen on
* their first frame. Modal is one of such components.
*
* @param activity the [Activity] to get the insets from.
* @return the encoded screen size as a [Long] value, where the first 32 bits represent the width
* and the last 32 bits represent the height in dp (density-independent pixels).
*/
// This annotation can be removed once FabricUIManager is migrated to Kotlin
@JvmName("getEncodedScreenSizeWithoutVerticalInsets")
@JvmStatic
internal fun getEncodedScreenSizeWithoutVerticalInsets(activity: Activity?): Long {
val windowInsets = activity?.window?.decorView?.let(ViewCompat::getRootWindowInsets) ?: return 0
val insets =
windowInsets.getInsets(
WindowInsetsCompat.Type.statusBars() or
WindowInsetsCompat.Type.navigationBars() or
WindowInsetsCompat.Type.displayCutout())
val verticalInsets = insets.top + insets.bottom
return encodeFloatsToLong(
(checkNotNull(screenDisplayMetrics).widthPixels).toFloat().pxToDp(),
(checkNotNull(screenDisplayMetrics).heightPixels - verticalInsets).toFloat().pxToDp())
}
internal fun encodeFloatsToLong(width: Float, height: Float): Long =
(width.toRawBits().toLong()) shl 32 or (height.toRawBits().toLong())
}
@@ -14,9 +14,6 @@ import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger
import com.facebook.yoga.YogaDirection
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING)
internal object LayoutDirectionUtil {
init {
LegacyArchitectureLogger.assertLegacyArchitecture(
@@ -38,8 +38,6 @@ import com.facebook.yoga.YogaWrap;
* explored, namely using the VirtualText class in JS and setting the correct set of validAttributes
*/
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
since = "This class is part of Legacy Architecture and will be removed in a future release")
public class LayoutShadowNode extends ReactShadowNodeImpl {
static {
LegacyArchitectureLogger.assertLegacyArchitecture(
@@ -14,9 +14,6 @@ import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel
// - `kind == PARENT` checks whether the node can host children in the native tree.
// - `kind != NONE` checks whether the node appears in the native tree.
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING)
internal enum class NativeKind {
// Node is in the native hierarchy and the HierarchyOptimizer should assume it can host children
// (e.g. because it's a ViewGroup). Note that it's okay if the node doesn't support children. When
@@ -68,8 +68,6 @@ import javax.annotation.concurrent.NotThreadSafe;
*/
@NotThreadSafe
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
since = "This class is part of Legacy Architecture and will be removed in a future release")
public class NativeViewHierarchyManager {
static {
@@ -49,8 +49,6 @@ import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger;
* depending on where the views being added/removed are attached in the optimized hierarchy
*/
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
since = "This class is part of Legacy Architecture and will be removed in a future release")
public class NativeViewHierarchyOptimizer {
static {
@@ -16,9 +16,6 @@ import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger
* associated with it.
*/
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING)
internal class NoSuchNativeViewException(detailMessage: String) :
IllegalViewOperationException(detailMessage) {
@@ -5,8 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react.uimanager
import androidx.core.util.Pools.SynchronizedPool
@@ -22,9 +20,6 @@ import com.facebook.react.uimanager.events.Event
/** Event used to notify JS component about changes of its position or dimensions. */
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.WARNING)
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
level = DeprecationLevel.WARNING)
public class OnLayoutEvent private constructor() : Event<OnLayoutEvent>() {
@VisibleForTesting internal var x: Int = 0
@VisibleForTesting internal var y: Int = 0
@@ -20,7 +20,7 @@ public object PixelUtil {
}
return TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, value, DisplayMetricsHolder.getWindowDisplayMetrics())
TypedValue.COMPLEX_UNIT_DIP, value, DisplayMetricsHolder.getScreenDisplayMetrics())
}
/** Convert from DIP to PX */
@@ -37,7 +37,7 @@ public object PixelUtil {
return Float.NaN
}
val displayMetrics = DisplayMetricsHolder.getWindowDisplayMetrics()
val displayMetrics = DisplayMetricsHolder.getScreenDisplayMetrics()
val scaledValue = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, value, displayMetrics)
if (maxFontScale >= 1) {
@@ -60,13 +60,13 @@ public object PixelUtil {
return Float.NaN
}
return value / DisplayMetricsHolder.getWindowDisplayMetrics().density
return value / DisplayMetricsHolder.getScreenDisplayMetrics().density
}
/** @return [Float] that represents the density of the display metrics for device screen. */
@JvmStatic
public fun getDisplayMetricDensity(): Float =
DisplayMetricsHolder.getWindowDisplayMetrics().density
DisplayMetricsHolder.getScreenDisplayMetrics().density
/* Kotlin extensions */
public fun Int.dpToPx(): Float = toPixelFromDIP(this.toFloat())
@@ -1,992 +0,0 @@
/*
* 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.
*/
package com.facebook.react.uimanager
import android.content.Context
import android.graphics.Rect
import android.os.Bundle
import android.os.Handler
import android.os.Message
import android.view.View
import android.view.ViewGroup
import android.view.accessibility.AccessibilityEvent
import android.widget.EditText
import androidx.core.view.ViewCompat
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat.AccessibilityActionCompat
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat.CollectionItemInfoCompat
import androidx.core.view.accessibility.AccessibilityNodeInfoCompat.RangeInfoCompat
import androidx.core.view.accessibility.AccessibilityNodeProviderCompat
import androidx.customview.widget.ExploreByTouchHelper
import com.facebook.infer.annotation.Assertions
import com.facebook.react.R
import com.facebook.react.bridge.Arguments.createMap
import com.facebook.react.bridge.ReactContext
import com.facebook.react.bridge.ReactNoCrashSoftException
import com.facebook.react.bridge.ReactSoftExceptionLogger.logSoftException
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.bridge.ReadableType
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.UIManagerHelper.getSurfaceId
import com.facebook.react.uimanager.UIManagerHelper.getUIManager
import com.facebook.react.uimanager.common.ViewUtil.getUIManagerType
import com.facebook.react.uimanager.events.Event
import com.facebook.react.uimanager.util.ReactFindViewUtil.findView
/**
* Utility class that handles the addition of a "role" for accessibility to either a View or
* AccessibilityNodeInfo.
*/
public open class ReactAccessibilityDelegate( // The View this delegate is attached to
protected val hostView: View,
originalFocus: Boolean,
originalImportantForAccessibility: Int
) : ExploreByTouchHelper(hostView) {
@Suppress("DEPRECATION") // TODO: Replace with handler tied to host view's context
private val accessibilityEventHandler: Handler =
object : Handler() {
override fun handleMessage(msg: Message) {
val host = msg.obj as View?
host?.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED)
}
}
private val accessibilityActionsMap = HashMap<Int, String?>()
private var accessibilityLabelledBy: View? = null
init {
// We need to reset these two properties, as ExploreByTouchHelper sets focusable to "true" and
// importantForAccessibility to "Yes" (if it is Auto). If we don't reset these it would force
// every element that has this delegate attached to be focusable, and not allow for
// announcement coalescing.
hostView.isFocusable = originalFocus
hostView.importantForAccessibility = originalImportantForAccessibility
}
override fun onInitializeAccessibilityNodeInfo(host: View, info: AccessibilityNodeInfoCompat) {
super.onInitializeAccessibilityNodeInfo(host, info)
if (host.getTag(R.id.accessibility_state_expanded) != null) {
val accessibilityStateExpanded = host.getTag(R.id.accessibility_state_expanded) as Boolean
info.addAction(
if (accessibilityStateExpanded) AccessibilityNodeInfoCompat.ACTION_COLLAPSE
else AccessibilityNodeInfoCompat.ACTION_EXPAND)
}
val accessibilityRole = AccessibilityRole.fromViewTag(host)
val accessibilityHint = host.getTag(R.id.accessibility_hint) as String?
if (accessibilityRole != null) {
setRole(info, accessibilityRole, host.context)
}
if (accessibilityHint != null) {
info.tooltipText = accessibilityHint
}
val accessibilityLabelledBy = host.getTag(R.id.labelled_by)
if (accessibilityLabelledBy != null) {
this.accessibilityLabelledBy = findView(host.rootView, accessibilityLabelledBy as String)
if (this.accessibilityLabelledBy != null) {
info.setLabeledBy(this.accessibilityLabelledBy)
}
}
// state is changeable.
val accessibilityState = host.getTag(R.id.accessibility_state) as ReadableMap?
if (accessibilityState != null) {
setState(info, accessibilityState)
}
val accessibilityActions = host.getTag(R.id.accessibility_actions) as ReadableArray?
val accessibilityCollectionItem =
host.getTag(R.id.accessibility_collection_item) as ReadableMap?
if (accessibilityCollectionItem != null) {
val rowIndex = accessibilityCollectionItem.getInt("rowIndex")
val columnIndex = accessibilityCollectionItem.getInt("columnIndex")
val rowSpan = accessibilityCollectionItem.getInt("rowSpan")
val columnSpan = accessibilityCollectionItem.getInt("columnSpan")
val heading = accessibilityCollectionItem.getBoolean("heading")
val collectionItemCompat =
CollectionItemInfoCompat.obtain(rowIndex, rowSpan, columnIndex, columnSpan, heading)
info.setCollectionItemInfo(collectionItemCompat)
}
if (accessibilityActions != null) {
for (i in 0..<accessibilityActions.size()) {
val action = accessibilityActions.getMap(i)
require(!(action == null || !action.hasKey("name"))) { "Unknown accessibility action." }
val actionName = action.getString("name")
// AccessibilityActionCompat actionLabel must be non-null
val actionLabel =
if (action.hasKey("label")) Assertions.assertNotNull(action.getString("label")) else ""
val actionId: Int =
actionIdMap.get(actionName)
?: customActionIdMap.getOrPut(actionName) { customActionCounter++ }
accessibilityActionsMap[actionId] = actionName
val accessibilityAction = AccessibilityActionCompat(actionId, actionLabel)
info.addAction(accessibilityAction)
}
}
// Process accessibilityValue
val accessibilityValue = host.getTag(R.id.accessibility_value) as ReadableMap?
if (accessibilityValue != null &&
accessibilityValue.hasKey("min") &&
accessibilityValue.hasKey("now") &&
accessibilityValue.hasKey("max")) {
val minDynamic = accessibilityValue.getDynamic("min")
val nowDynamic = accessibilityValue.getDynamic("now")
val maxDynamic = accessibilityValue.getDynamic("max")
if (minDynamic.type == ReadableType.Number &&
nowDynamic.type == ReadableType.Number &&
maxDynamic.type == ReadableType.Number) {
val min = minDynamic.asInt()
val now = nowDynamic.asInt()
val max = maxDynamic.asInt()
if (max > min && now >= min && max >= now) {
info.rangeInfo =
RangeInfoCompat.obtain(
RangeInfoCompat.RANGE_TYPE_INT, min.toFloat(), max.toFloat(), now.toFloat())
}
}
}
// Expose the testID prop as the resource-id name of the view. Black-box E2E/UI testing
// frameworks, which interact with the UI through the accessibility framework, do not have
// access to view tags. This allows developers/testers to avoid polluting the
// content-description with test identifiers.
val testId = host.getTag(R.id.react_test_id) as String?
if (testId != null) {
info.viewIdResourceName = testId
}
val missingContentDescription = info.contentDescription.isNullOrEmpty()
val missingText = info.text.isNullOrEmpty()
val missingTextAndDescription = missingContentDescription && missingText
val hasContentToAnnounce =
accessibilityActions != null ||
accessibilityState != null ||
accessibilityLabelledBy != null ||
accessibilityRole != null
if (missingTextAndDescription && hasContentToAnnounce) {
info.contentDescription = getTalkbackDescription(host, info)
}
}
override fun onInitializeAccessibilityEvent(host: View, event: AccessibilityEvent) {
super.onInitializeAccessibilityEvent(host, event)
// Set item count and current item index on accessibility events for adjustable
// in order to make Talkback announce the value of the adjustable
val accessibilityValue = host.getTag(R.id.accessibility_value) as ReadableMap?
if (accessibilityValue != null &&
accessibilityValue.hasKey("min") &&
accessibilityValue.hasKey("now") &&
accessibilityValue.hasKey("max")) {
val minDynamic = accessibilityValue.getDynamic("min")
val nowDynamic = accessibilityValue.getDynamic("now")
val maxDynamic = accessibilityValue.getDynamic("max")
if (minDynamic.type == ReadableType.Number &&
nowDynamic.type == ReadableType.Number &&
maxDynamic.type == ReadableType.Number) {
val min = minDynamic.asInt()
val now = nowDynamic.asInt()
val max = maxDynamic.asInt()
if (max > min && now >= min && max >= now) {
event.itemCount = max - min
event.currentItemIndex = now
}
}
}
}
override fun performAccessibilityAction(host: View, action: Int, args: Bundle?): Boolean {
if (action == AccessibilityNodeInfoCompat.ACTION_COLLAPSE) {
host.setTag(R.id.accessibility_state_expanded, false)
}
if (action == AccessibilityNodeInfoCompat.ACTION_EXPAND) {
host.setTag(R.id.accessibility_state_expanded, true)
}
if (accessibilityActionsMap.containsKey(action)) {
val eventData = createMap()
eventData.putString("actionName", accessibilityActionsMap[action])
val reactContext = host.context as ReactContext
if (reactContext.hasActiveReactInstance()) {
val reactTag = host.id
val surfaceId = getSurfaceId(reactContext)
val uiManager = getUIManager(reactContext, getUIManagerType(reactTag))
if (uiManager != null) {
uiManager.eventDispatcher.dispatchEvent(
AccessibilityActionEvent(eventData, surfaceId, reactTag))
}
} else {
logSoftException(
TAG, ReactNoCrashSoftException("Cannot get RCTEventEmitter, no CatalystInstance"))
}
// In order to make Talkback announce the change of the adjustable's value,
// schedule to send a TYPE_VIEW_SELECTED event after performing the scroll actions.
val accessibilityRole = host.getTag(R.id.accessibility_role) as AccessibilityRole
val accessibilityValue = host.getTag(R.id.accessibility_value) as ReadableMap?
if (accessibilityRole == AccessibilityRole.ADJUSTABLE &&
(action == AccessibilityActionCompat.ACTION_SCROLL_FORWARD.id ||
(action == AccessibilityActionCompat.ACTION_SCROLL_BACKWARD.id))) {
if (accessibilityValue != null && !accessibilityValue.hasKey("text")) {
scheduleAccessibilityEventSender(host)
}
return super.performAccessibilityAction(host, action, args)
}
return true
}
return super.performAccessibilityAction(host, action, args)
}
/**
* Schedule a command for sending an accessibility event. Note: A command is used to ensure that
* accessibility events are sent at most one in a given time frame to save system resources while
* the progress changes quickly.
*/
private fun scheduleAccessibilityEventSender(host: View) {
if (accessibilityEventHandler.hasMessages(SEND_EVENT, host)) {
accessibilityEventHandler.removeMessages(SEND_EVENT, host)
}
val msg = accessibilityEventHandler.obtainMessage(SEND_EVENT, host)
accessibilityEventHandler.sendMessageDelayed(msg, TIMEOUT_SEND_ACCESSIBILITY_EVENT.toLong())
}
override fun getVirtualViewAt(x: Float, y: Float): Int {
return INVALID_ID
}
override fun getVisibleVirtualViews(virtualViewIds: MutableList<Int>): Unit = Unit
override fun onPopulateNodeForVirtualView(virtualViewId: Int, node: AccessibilityNodeInfoCompat) {
node.contentDescription = ""
@Suppress("DEPRECATION") // TODO: Remove this
node.setBoundsInParent(Rect(0, 0, 1, 1))
}
override fun onPerformActionForVirtualView(
virtualViewId: Int,
action: Int,
arguments: Bundle?
): Boolean {
return false
}
override fun getAccessibilityNodeProvider(host: View): AccessibilityNodeProviderCompat? {
return null
}
// This exists so classes that extend this can properly call super's impl of this method while
// still being able to override it properly for this class
protected fun superGetAccessibilityNodeProvider(host: View): AccessibilityNodeProviderCompat? {
return super.getAccessibilityNodeProvider(host)
}
/**
* An ARIA Role representable by View's `role` prop. Ordinals should be kept in sync with
* `facebook::react::Role`.
*/
public enum class Role {
ALERT,
ALERTDIALOG,
APPLICATION,
ARTICLE,
BANNER,
BUTTON,
CELL,
CHECKBOX,
COLUMNHEADER,
COMBOBOX,
COMPLEMENTARY,
CONTENTINFO,
DEFINITION,
DIALOG,
DIRECTORY,
DOCUMENT,
FEED,
FIGURE,
FORM,
GRID,
GROUP,
HEADING,
IMG,
LINK,
LIST,
LISTITEM,
LOG,
MAIN,
MARQUEE,
MATH,
MENU,
MENUBAR,
MENUITEM,
METER,
NAVIGATION,
NONE,
NOTE,
OPTION,
PRESENTATION,
PROGRESSBAR,
RADIO,
RADIOGROUP,
REGION,
ROW,
ROWGROUP,
ROWHEADER,
SCROLLBAR,
SEARCHBOX,
SEPARATOR,
SLIDER,
SPINBUTTON,
STATUS,
SUMMARY,
SWITCH,
TAB,
TABLE,
TABLIST,
TABPANEL,
TERM,
TIMER,
TOOLBAR,
TOOLTIP,
TREE,
TREEGRID,
TREEITEM;
public companion object {
@JvmStatic
public fun fromValue(value: String?): Role? {
for (role in entries) {
if (role.name.equals(value, ignoreCase = true)) {
return role
}
}
return null
}
}
}
private class AccessibilityActionEvent(
private val accessibilityEventData: WritableMap,
surfaceId: Int,
viewId: Int
) : Event<AccessibilityActionEvent>(surfaceId, viewId) {
override fun getEventName(): String {
return TOP_ACCESSIBILITY_ACTION_EVENT
}
public override fun getEventData(): WritableMap? {
return accessibilityEventData
}
}
/**
* These roles are defined by Google's TalkBack screen reader, and this list should be kept up to
* date with their implementation. Details can be seen in their source code here:
*
* https://github.com/google/talkback/blob/master/utils/src/main/java/Role.java
*/
public enum class AccessibilityRole {
NONE,
BUTTON,
DROPDOWNLIST,
TOGGLEBUTTON,
LINK,
SEARCH,
IMAGE,
IMAGEBUTTON,
KEYBOARDKEY,
TEXT,
ADJUSTABLE,
SUMMARY,
HEADER,
ALERT,
CHECKBOX,
COMBOBOX,
MENU,
MENUBAR,
MENUITEM,
PROGRESSBAR,
RADIO,
RADIOGROUP,
SCROLLBAR,
SPINBUTTON,
SWITCH,
TAB,
TABLIST,
TIMER,
LIST,
GRID,
PAGER,
SCROLLVIEW,
HORIZONTALSCROLLVIEW,
VIEWGROUP,
WEBVIEW,
DRAWERLAYOUT,
SLIDINGDRAWER,
ICONMENU,
TOOLBAR;
public companion object {
@JvmStatic
public fun getValue(role: AccessibilityRole): String {
return when (role) {
BUTTON -> "android.widget.Button"
DROPDOWNLIST -> "android.widget.Spinner"
TOGGLEBUTTON -> "android.widget.ToggleButton"
SEARCH -> "android.widget.EditText"
IMAGE -> "android.widget.ImageView"
IMAGEBUTTON -> "android.widget.ImageButton"
KEYBOARDKEY -> "android.inputmethodservice.Keyboard\$Key"
TEXT -> "android.widget.TextView"
ADJUSTABLE -> "android.widget.SeekBar"
CHECKBOX -> "android.widget.CheckBox"
RADIO -> "android.widget.RadioButton"
SPINBUTTON -> "android.widget.SpinButton"
SWITCH -> "android.widget.Switch"
LIST -> "android.widget.AbsListView"
GRID -> "android.widget.GridView"
SCROLLVIEW -> "android.widget.ScrollView"
HORIZONTALSCROLLVIEW -> "android.widget.HorizontalScrollView"
PAGER -> "androidx.viewpager.widget.ViewPager"
DRAWERLAYOUT -> "androidx.drawerlayout.widget.DrawerLayout"
SLIDINGDRAWER -> "android.widget.SlidingDrawer"
ICONMENU -> "com.android.internal.view.menu.IconMenuView"
VIEWGROUP -> "android.view.ViewGroup"
WEBVIEW -> "android.webkit.WebView"
NONE,
LINK,
SUMMARY,
HEADER,
ALERT,
COMBOBOX,
MENU,
MENUBAR,
MENUITEM,
PROGRESSBAR,
RADIOGROUP,
SCROLLBAR,
TAB,
TABLIST,
TIMER,
TOOLBAR -> "android.view.View"
}
}
@JvmStatic
public fun fromValue(value: String?): AccessibilityRole {
if (value == null) {
return NONE
}
for (role in entries) {
if (role.name.equals(value, ignoreCase = true)) {
return role
}
}
throw IllegalArgumentException("Invalid accessibility role value: $value")
}
@JvmStatic
public fun fromRole(role: Role): AccessibilityRole? {
return when (role) {
Role.ALERT -> ALERT
Role.BUTTON -> BUTTON
Role.CHECKBOX -> CHECKBOX
Role.COMBOBOX -> COMBOBOX
Role.GRID -> GRID
Role.HEADING -> HEADER
Role.IMG -> IMAGE
Role.LINK -> LINK
Role.LIST -> LIST
Role.MENU -> MENU
Role.MENUBAR -> MENUBAR
Role.MENUITEM -> MENUITEM
Role.NONE -> NONE
Role.PROGRESSBAR -> PROGRESSBAR
Role.RADIO -> RADIO
Role.RADIOGROUP -> RADIOGROUP
Role.SCROLLBAR -> SCROLLBAR
Role.SEARCHBOX -> SEARCH
Role.SLIDER -> ADJUSTABLE
Role.SPINBUTTON -> SPINBUTTON
Role.SUMMARY -> SUMMARY
Role.SWITCH -> SWITCH
Role.TAB -> TAB
Role.TABLIST -> TABLIST
Role.TIMER -> TIMER
Role.TOOLBAR -> TOOLBAR
else -> // No mapping from ARIA role to AccessibilityRole
null
}
}
@JvmStatic
public fun fromViewTag(view: View): AccessibilityRole? {
val role = view.getTag(R.id.role) as Role?
return if (role != null) {
fromRole(role)
} else {
view.getTag(R.id.accessibility_role) as AccessibilityRole?
}
}
}
}
public companion object {
public const val TOP_ACCESSIBILITY_ACTION_EVENT: String = "topAccessibilityAction"
private val actionIdMap =
mapOf<String, Int>(
"activate" to AccessibilityActionCompat.ACTION_CLICK.id,
"longpress" to AccessibilityActionCompat.ACTION_LONG_CLICK.id,
"increment" to AccessibilityActionCompat.ACTION_SCROLL_FORWARD.id,
"decrement" to AccessibilityActionCompat.ACTION_SCROLL_BACKWARD.id,
"expand" to AccessibilityActionCompat.ACTION_EXPAND.id,
"collapse" to AccessibilityActionCompat.ACTION_COLLAPSE.id,
)
private const val TAG = "ReactAccessibilityDelegate"
private var customActionCounter = 0x3f000000
private val customActionIdMap: MutableMap<String?, Int> = HashMap()
private const val TIMEOUT_SEND_ACCESSIBILITY_EVENT = 200
private const val SEND_EVENT = 1
private const val delimiter = ", "
private const val delimiterLength = delimiter.length
// State constants for states which have analogs in AccessibilityNodeInfo
private const val STATE_DISABLED = "disabled"
private const val STATE_SELECTED = "selected"
private const val STATE_CHECKED = "checked"
@JvmStatic
public fun setDelegate(
view: View,
originalFocus: Boolean,
originalImportantForAccessibility: Int
) {
// if a view already has an accessibility delegate, replacing it could cause
// problems, so leave it alone.
if (!ViewCompat.hasAccessibilityDelegate(view) &&
(view.getTag(R.id.accessibility_role) != null ||
view.getTag(R.id.accessibility_state) != null ||
view.getTag(R.id.accessibility_actions) != null ||
view.getTag(R.id.react_test_id) != null ||
view.getTag(R.id.accessibility_collection_item) != null ||
view.getTag(R.id.accessibility_links) != null ||
view.getTag(R.id.role) != null)) {
ViewCompat.setAccessibilityDelegate(
view,
ReactAccessibilityDelegate(view, originalFocus, originalImportantForAccessibility))
}
}
// Explicitly re-set the delegate, even if one has already been set.
@JvmStatic
public fun resetDelegate(
view: View,
originalFocus: Boolean,
originalImportantForAccessibility: Int
) {
ViewCompat.setAccessibilityDelegate(
view, ReactAccessibilityDelegate(view, originalFocus, originalImportantForAccessibility))
}
private fun setState(
info: AccessibilityNodeInfoCompat,
accessibilityState: ReadableMap,
) {
val i = accessibilityState.keySetIterator()
while (i.hasNextKey()) {
val state = i.nextKey()
val value = accessibilityState.getDynamic(state)
if (state == STATE_SELECTED && value.type == ReadableType.Boolean) {
info.isSelected = value.asBoolean()
} else if (state == STATE_DISABLED && value.type == ReadableType.Boolean) {
info.isEnabled = !value.asBoolean()
} else if (state == STATE_CHECKED && value.type == ReadableType.Boolean) {
val boolValue = value.asBoolean()
info.isCheckable = true
info.isChecked = boolValue
}
}
}
// TODO: Eventually support for other languages on talkback
@JvmStatic
public fun setRole(
nodeInfo: AccessibilityNodeInfoCompat,
role: AccessibilityRole?,
context: Context
) {
val resolvedRole = role ?: AccessibilityRole.NONE
nodeInfo.className = AccessibilityRole.getValue(resolvedRole)
when (resolvedRole) {
AccessibilityRole.LINK -> {
nodeInfo.roleDescription = context.getString(R.string.link_description)
}
AccessibilityRole.IMAGE -> {
nodeInfo.roleDescription = context.getString(R.string.image_description)
}
AccessibilityRole.IMAGEBUTTON -> {
nodeInfo.roleDescription = context.getString(R.string.imagebutton_description)
nodeInfo.isClickable = true
}
AccessibilityRole.BUTTON -> {
nodeInfo.isClickable = true
}
AccessibilityRole.TOGGLEBUTTON -> {
nodeInfo.isClickable = true
nodeInfo.isCheckable = true
}
AccessibilityRole.SUMMARY -> {
nodeInfo.roleDescription = context.getString(R.string.summary_description)
}
AccessibilityRole.HEADER -> {
nodeInfo.isHeading = true
}
AccessibilityRole.ALERT -> {
nodeInfo.roleDescription = context.getString(R.string.alert_description)
}
AccessibilityRole.COMBOBOX -> {
nodeInfo.roleDescription = context.getString(R.string.combobox_description)
}
AccessibilityRole.MENU -> {
nodeInfo.roleDescription = context.getString(R.string.menu_description)
}
AccessibilityRole.MENUBAR -> {
nodeInfo.roleDescription = context.getString(R.string.menubar_description)
}
AccessibilityRole.MENUITEM -> {
nodeInfo.roleDescription = context.getString(R.string.menuitem_description)
}
AccessibilityRole.PROGRESSBAR -> {
nodeInfo.roleDescription = context.getString(R.string.progressbar_description)
}
AccessibilityRole.RADIOGROUP -> {
nodeInfo.roleDescription = context.getString(R.string.radiogroup_description)
}
AccessibilityRole.SCROLLBAR -> {
nodeInfo.roleDescription = context.getString(R.string.scrollbar_description)
}
AccessibilityRole.SPINBUTTON -> {
nodeInfo.roleDescription = context.getString(R.string.spinbutton_description)
}
AccessibilityRole.TAB -> {
nodeInfo.roleDescription = context.getString(R.string.rn_tab_description)
}
AccessibilityRole.TABLIST -> {
nodeInfo.roleDescription = context.getString(R.string.tablist_description)
}
AccessibilityRole.TIMER -> {
nodeInfo.roleDescription = context.getString(R.string.timer_description)
}
AccessibilityRole.TOOLBAR -> {
nodeInfo.roleDescription = context.getString(R.string.toolbar_description)
}
else -> {
// TODO: Add support for other roles
}
}
}
/**
* Determines if the supplied [View] and [AccessibilityNodeInfoCompat] has any children which
* are not independently accessibility focusable and also have a spoken description.
*
* NOTE: Accessibility services will include these children's descriptions in the closest
* focusable ancestor.
*
* @param view The [View] to evaluate
* @param node The [AccessibilityNodeInfoCompat] to evaluate
* @return `true` if it has any non-actionable speaking descendants within its subtree
*/
@JvmStatic
public fun hasNonActionableSpeakingDescendants(
node: AccessibilityNodeInfoCompat?,
view: View?
): Boolean {
if (node == null || view == null || (view !is ViewGroup)) {
return false
}
val viewGroup = view
var i = 0
val count = viewGroup.childCount
while (i < count) {
val childView = viewGroup.getChildAt(i)
if (childView == null) {
i++
continue
}
val childNode = AccessibilityNodeInfoCompat.obtain()
@Suppress("DEPRECATION") // TODO: Replace with direct invocation on view
ViewCompat.onInitializeAccessibilityNodeInfo(childView, childNode)
if (!childNode.isVisibleToUser) {
i++
continue
}
if (isAccessibilityFocusable(childNode, childView)) {
i++
continue
}
if (isSpeakingNode(childNode, childView)) {
return true
}
i++
}
return false
}
/**
* Returns whether the node has valid RangeInfo.
*
* @param node The node to check.
* @return Whether the node has valid RangeInfo.
*/
@JvmStatic
public fun hasValidRangeInfo(node: AccessibilityNodeInfoCompat?): Boolean {
if (node == null) {
return false
}
val rangeInfo = node.rangeInfo ?: return false
val maxProgress = rangeInfo.max
val minProgress = rangeInfo.min
val currentProgress = rangeInfo.current
val diffProgress = maxProgress - minProgress
return (diffProgress > 0.0f) &&
(currentProgress >= minProgress) &&
(currentProgress <= maxProgress)
}
/**
* Returns whether the specified node has state description.
*
* @param node The node to check.
* @return `true` if the node has state description.
*/
private fun hasStateDescription(node: AccessibilityNodeInfoCompat?): Boolean {
return node != null &&
(!node.stateDescription.isNullOrEmpty() || node.isCheckable || hasValidRangeInfo(node))
}
/**
* Returns whether the supplied [View] and [AccessibilityNodeInfoCompat] would produce spoken
* feedback if it were accessibility focused. NOTE: not all speaking nodes are focusable.
*
* @param view The [View] to evaluate
* @param node The [AccessibilityNodeInfoCompat] to evaluate
* @return `true` if it meets the criterion for producing spoken feedback
*/
@Suppress("DEPRECATION") // TODO: Replace ViewCompat with direct invocation on view
@JvmStatic
public fun isSpeakingNode(node: AccessibilityNodeInfoCompat?, view: View?): Boolean {
if (node == null || view == null) {
return false
}
val important = ViewCompat.getImportantForAccessibility(view)
if (important == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS ||
(important == ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO && node.childCount <= 0)) {
return false
}
return hasText(node) ||
hasStateDescription(node) ||
node.isCheckable ||
hasNonActionableSpeakingDescendants(node, view)
}
@JvmStatic
public fun hasText(node: AccessibilityNodeInfoCompat?): Boolean {
return node != null &&
node.collectionInfo == null &&
(!node.text.isNullOrEmpty() ||
!node.contentDescription.isNullOrEmpty() ||
!node.hintText.isNullOrEmpty())
}
/**
* Determines if the provided [View] and [AccessibilityNodeInfoCompat] meet the criteria for
* gaining accessibility focus.
*
* Note: this is evaluating general focusability by accessibility services, and does not mean
* this view will be guaranteed to be focused by specific services such as Talkback. For
* Talkback focusability, see [isTalkbackFocusable(View)]
*
* @param view The [View] to evaluate
* @param node The [AccessibilityNodeInfoCompat] to evaluate
* @return `true` if it is possible to gain accessibility focus
*/
@JvmStatic
public fun isAccessibilityFocusable(node: AccessibilityNodeInfoCompat?, view: View?): Boolean {
if (node == null || view == null) {
return false
}
// Never focus invisible nodes.
if (!node.isVisibleToUser) {
return false
}
// Always focus "actionable" nodes.
return node.isScreenReaderFocusable || isActionableForAccessibility(node)
}
/**
* Returns whether a node is actionable. That is, the node supports one of
* [AccessibilityNodeInfoCompat#isClickable()], [AccessibilityNodeInfoCompat#isFocusable()], or
* [AccessibilityNodeInfoCompat#isLongClickable()].
*
* @param node The [AccessibilityNodeInfoCompat] to evaluate
* @return `true` if node is actionable.
*/
@JvmStatic
public fun isActionableForAccessibility(node: AccessibilityNodeInfoCompat?): Boolean {
if (node == null) {
return false
}
if (node.isClickable || node.isLongClickable || node.isFocusable) {
return true
}
return node.actionList.any { action ->
action == AccessibilityActionCompat.ACTION_CLICK ||
action == AccessibilityActionCompat.ACTION_LONG_CLICK ||
action == AccessibilityActionCompat.ACTION_FOCUS
}
}
/**
* Returns a cached instance if such is available otherwise a new one.
*
* @param view The [View] to derive the AccessibilityNodeInfo properties from.
* @return [FlipperObject] containing the properties.
*/
@JvmStatic
public fun createNodeInfoFromView(view: View?): AccessibilityNodeInfoCompat? {
if (view == null) {
return null
}
val nodeInfo = AccessibilityNodeInfoCompat.obtain()
try {
@Suppress("DEPRECATION") // TODO: Replace with direct invocation on view
ViewCompat.onInitializeAccessibilityNodeInfo(view, nodeInfo)
} catch (e: NullPointerException) {
// For some unknown reason, Android seems to occasionally throw a NPE from
// onInitializeAccessibilityNodeInfo.
return null
}
return nodeInfo
}
/**
* Creates the text that Google's TalkBack screen reader will read aloud for a given [View].
* This may be any combination of the [View]'s `text`, `contentDescription`, and the `text` and
* `contentDescription` of any ancestor [View].
*
* This description is generally ported over from Google's TalkBack screen reader, and this
* should be kept up to date with their implementation (as much as necessary). Details can be
* seen in their source code here:
*
* https://github.com/google/talkback/compositor/src/main/res/raw/compositor.json - search for
* "get_description_for_tree", "append_description_for_tree", "description_for_tree_nodes"
*
* @param view The [View] to evaluate.
* @param info The default [AccessibilityNodeInfoCompat].
* @return `String` representing what talkback will say when a [View] is focused.
*/
@JvmStatic
public fun getTalkbackDescription(
view: View,
info: AccessibilityNodeInfoCompat?
): CharSequence? {
val node =
if (info == null) createNodeInfoFromView(view)
else AccessibilityNodeInfoCompat.obtain(info)
if (node == null) {
return null
}
val contentDescription = node.contentDescription
val nodeText = node.text
val hasNodeText = !nodeText.isNullOrEmpty()
val isEditText = view is EditText
val talkbackSegments = StringBuilder()
// EditText's prioritize their own text content over a contentDescription so skip this
if (!contentDescription.isNullOrEmpty() && (!isEditText || !hasNodeText)) {
// next add content description
talkbackSegments.append(contentDescription)
return talkbackSegments
}
// TextView
if (hasNodeText) {
talkbackSegments.append(nodeText)
return talkbackSegments
}
// If there are child views and no contentDescription the text of all non-focusable
// children,
// comma separated, becomes the description.
if (view is ViewGroup) {
val concatChildDescription = StringBuilder()
val viewGroup = view
var i = 0
val count = viewGroup.childCount
while (i < count) {
val child = viewGroup.getChildAt(i)
val childNodeInfo = AccessibilityNodeInfoCompat.obtain()
@Suppress("DEPRECATION") // TODO: Replace with direct invocation on view
ViewCompat.onInitializeAccessibilityNodeInfo(child, childNodeInfo)
if (isSpeakingNode(childNodeInfo, child) &&
!isAccessibilityFocusable(childNodeInfo, child)) {
val childNodeDescription = getTalkbackDescription(child, null)
if (!childNodeDescription.isNullOrEmpty()) {
concatChildDescription.append(childNodeDescription.toString() + delimiter)
}
}
i++
}
return removeFinalDelimiter(concatChildDescription)
}
return null
}
private fun removeFinalDelimiter(builder: StringBuilder): String {
val end = builder.length
if (end > 0) {
builder.delete(end - delimiterLength, end)
}
return builder.toString()
}
}
}
@@ -46,8 +46,6 @@ import com.facebook.yoga.YogaWrap;
* NativeViewHierarchyOptimizer} for more information.
*/
@LegacyArchitecture
@Deprecated(
since = "This class is part of Legacy Architecture and will be removed in a future release")
public interface ReactShadowNode<T extends ReactShadowNode> {
/**

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