Compare commits

..
Author SHA1 Message Date
Devmate Bot 8fafef8365 xplat/js/react-native-github/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/tasks/internal/PreparePrefabHeadersTaskTest.kt
Reviewed By: rshest

Differential Revision: D80786149
2025-08-22 02:29:27 -07:00
Chi Tsai 646945c2f2 Add deleteProperty API (#52911)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52911

Add a new `deleteProperty` API to JSI. As the name implies, allows users
to delete properties from Objects through JSI.

The default implementation uses `Reflect.deleteProperty.` For the
`PropNameID` overload, convert the propNameID to a String and pass into
the `deleteProperty` function.

Changelog: [Internal]

Reviewed By: dannysu

Differential Revision: D79120814

fbshipit-source-id: e30f383247d94bb5971e4909f004c75e8165adda
2025-08-21 17:35:55 -07:00
Marco Wang da9136f587 Turn on null strict comparison check for xplat js (#53379)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53379

X-link: https://github.com/facebook/react/pull/34240

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D80648362

fbshipit-source-id: cc47ae207f29a3ddb68bc0e029b8773f89503c52
2025-08-21 16:46:23 -07:00
Nikita Lutsenko ffe52b75a3 xplat/js/react-native-github/packages/react-native/ReactCommon/react/renderer/mounting/Differentiator.cpp (#53412)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53412

Changelog:
[General][Internal] - Encapsulated internal class into anonymous namespace to ensure no collisions with public symbols.

Differential Revision: D80689084

fbshipit-source-id: 53ebd8a16a3c217efead0bfe91f66bd50bb6dd2f
2025-08-21 14:59:24 -07:00
Ruslan Lesiutin a2a73739d8 fix: use ThreadId when event is captured, not when transformed (#53411)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53411

# Changelog: [Internal]

This regressed after D80263154, when we introduced a local struct for PerforamanceTracerEvent.

We should use id of the thread where event was captured (registered), not where the transform to TraceEvent happened.

This makes sure that events like Event Loop tick or Microtasks phase tick are correctly point to JavaScript thread, not the thread where the transform could've taken place.

Reviewed By: sbuggay

Differential Revision: D80728931

fbshipit-source-id: d3af16e68adece9ebc37368fec2b8a17c1293b4b
2025-08-21 14:18:27 -07:00
Nicola Corti 046ff8e58b Make OnBatchCompleteListener interface internal (#53409)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53409

This interface is public and is part of Legacy Architecture.

Having this interface as `public` was a mistake, as users can't really do much with it.
There is only one old library that is going to be affected by this change:
https://github.com/spoke-ph/react-native-threads
The library appears unmaintained since RN 0.69 + no NewArch support so I won't consider this a breaking change
given this will land in 0.82.

I'm making it internal so we can remove it more easily later.

Changelog:
[Android] [Changed] - Make OnBatchCompleteListener interface internal

Differential Revision: D80715625

fbshipit-source-id: 94fe80eeba95222deab7ca89c5fcafca8fcee0b7
2025-08-21 14:05:47 -07:00
Nicola Corti fb114da8a4 Remove unused internal UIManagerModuleListener (#53404)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53404

This interface is part of Legacy Architecture. No one is using it either internally or externally,
so it's safe to remove now. Interface was also `internal` so this is not a breaking change.

Changelog:
[Internal] [Changed] -

Reviewed By: mdvacca

Differential Revision: D80714721

fbshipit-source-id: 82cc6152af7d7980119d2eda704ae50d8e81fd2b
2025-08-21 12:25:38 -07:00
Umar Mohammad 191ddc1ec7 Fix React Native Commands Export Validation in Coverage Mode (#53381)
Summary:
Changelog: [GENERAL] [FIXED] - Fixed babel plugin validation error when coverage instrumentation is enabled

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

### Problem

[Workplace post](https://fb.workplace.com/groups/235694244595999/permalink/1278937163605030/)

React Native tests were failing **only when coverage collection was enabled** with the error:

`'Commands' is a reserved export and may only be used to export the result of codegenNativeCommands.`

### Root Cause

The React Native Babel plugin's `codegenNativeCommands` validation logic only handled direct `CallExpression` AST nodes. When coverage instrumentation was enabled, it transformed:

**Normal code:**

`export const Commands = codegenNativeCommands<NativeCommands>({...})`

**With coverage:**

`export const Commands = (cov_xxx().s[0]++, codegenNativeCommands<NativeCommands>({...}))`

The plugin failed to recognize the valid `codegenNativeCommands` call wrapped in a `SequenceExpression` by coverage instrumentation.

### **Solution**

Added `isCodegenNativeCommandsDeclaration` function to handle:

1.  **Coverage instrumentation**: `SequenceExpression` nodes containing the function call
2.  **Flow type casts**: `TypeCastExpression` and `AsExpression`
3.  **TypeScript assertions**: `TSAsExpression`
4.  **Direct calls**: Original `CallExpression` (backward compatibility)

Reviewed By: andrewdacenko

Differential Revision: D80572666

fbshipit-source-id: 465f4312a0229d8a92e495c685f46b607ce326e4
2025-08-21 11:33:52 -07:00
Nicola Corti aaa7ba4ab3 HelloWorld should not use ReactNativeHost (#53399)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53399

We currently create application template that are still using `ReactNativeHost`.
As this is a legacy arch class, we should remove it from the template ASAP so that
users can organically migrate away from it.

I will also update https://github.com/react-native-community/template with
the same changes I'm applying here.

Changelog:
[Internal] [Changed] -

Reviewed By: mdvacca

Differential Revision: D80708461

fbshipit-source-id: e0d4a1f817e6fdddd93405decf77fd115956ec51
2025-08-21 11:16:20 -07:00
Nicola Corti 2689d4d372 RNTester should not use ReactNativeHost (#53398)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53398

ReactNativeHost is a legacy architecture class.
This migrates the app away from it and converts it to use DefaultReactHost instead.

Changelog:
[Internal] [Changed] -

Reviewed By: mdvacca

Differential Revision: D80708460

fbshipit-source-id: 7d88c440414c979a2968fc9c910e828f5851195c
2025-08-21 11:16:20 -07:00
Nicola Corti d35ddb5e59 Delete unused DefaultReactHost.getDefaultReactHost() overload (#53396)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53396

This overload for `getDefaultReactHost` is missing the last 2 parameters
and provides the same default as the full method.

In OSS is unused as we used the one with `ReactNativeHost`.
I'm removing it as it's causing an overload resolution failure internally.

This won't be a breaking change for Kotlin users are the signatures are compatibles,
but it will be breaking for Java users. I've verified that there are no OSS users.

Developers should use Kotlin default parameters + the method `getDefaultReactHost()`
with all the params + defaults for ease of use of this API.

Changelog:
[Android] [Removed] - Delete unused `DefaultReactHost.getDefaultReactHost()` overload

Reviewed By: mdvacca

Differential Revision: D80704987

fbshipit-source-id: 0b3a61aad3f18cde77bac78e3ba413d7f9166ede
2025-08-21 11:16:20 -07:00
Nicola Corti 8e514a8a10 Annotate ReactNativeJNISoLoader as InteropLegacyArchitecture (#53406)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53406

The `ReactNativeJNISoLoader` class (previously called BridgeSoLoader)
is actually a Legacy Architecture class.
However is used by `CxxModuleWrapperBase` which is needed by interop, so we need to keep it around.
I'm adding the annotation so we won't forget about it.

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D80710951

fbshipit-source-id: ed353e2b14c742b25962f0b81beba6dc90157709
2025-08-21 10:52:56 -07:00
Nicola Corti e28784d4b6 Remove unnecessary NativeArgumentsParseException (#53408)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53408

This class is internal + legacy arch so can safely be removed now.
I've replaced the throw/catch site with the superclass of this exception.

Changelog:
[Internal] [Changed] -

Reviewed By: mdvacca

Differential Revision: D80710950

fbshipit-source-id: 96615835588ce409de40d31ee83b82c88d3a07a0
2025-08-21 10:52:56 -07:00
Riccardo Cipolleschi 28275a0f7b Fix Crash when rendering Switch component (#53393)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53393

When implementing the changes for the Switch component for iOS 26, I didn't realize that the code in [`RCTIntance.mm`](https://www.internalfb.com/code/fbsource/[a54514baccf4e1f828ef46af8180555754c405d8]/xplat/js/react-native-github/packages/react-native/ReactCommon/react/runtime/platform/ios/ReactCommon/RCTInstance.mm?lines=344-375) was running behind a feature flag.
This means that all the users not in the experiment where the feature flag is turned on will experience a crash as soon as they navigate to a React Native screen that contains a Switch.

This change fixes the problem by adding a jump to the right queue and it also fixes a measurement issue with the Switch.

## Changelog:
[iOS][Fixed] - Fixed a crash when rendering the Switch component

bypass-github-export-checks

Reviewed By: GijsWeterings

Differential Revision: D80702245

fbshipit-source-id: 480ea061233d35e31679b4b30758dbc133ff0a77
2025-08-21 10:13:22 -07:00
Ruslan Shestopalyuk bcf76e8bb0 Add RN feature flag for ScrollView view recycling (#53373)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53373

# Changelog:
[Internal] -

Creates a RN feature flag for enabling/disabling view recycling for ScrollView native component on Android.

Reviewed By: lenaic

Differential Revision: D80625656

fbshipit-source-id: 23eae07512e0ba2ea014404e7afa19db900f7c47
2025-08-21 09:47:23 -07:00
Lauren Tan c2d96d3a5b Add flow suppression for Constant Condition rollout (#34243)
Summary: DiffTrain build for [83c7379b9601f25463826449256f0cd3d283702d](https://github.com/facebook/react/commit/83c7379b9601f25463826449256f0cd3d283702d)

Reviewed By: marcoww6

Differential Revision: D80661139

fbshipit-source-id: 8ccf2dccba9a07ffd38f50da2c1ded8ebfa78c89
2025-08-21 09:35:19 -07:00
Nicola Corti c557311ed8 Ship useNativeEqualsInNativeReadableArrayAndroid and useNativeTransformHelperAndroid to stable (#53372)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53372

We verified that those feature flags are not regressing the experience + we got confirmation from Software Mansion that the fix
is effectively mitigating the regression on Android mounting.

Hence we can ship this to production.

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

Changelog:
[Android] [Fixed] - Fix mounting is very slow on Android by shipping native transform optimizations

Reviewed By: javache

Differential Revision: D80624739

fbshipit-source-id: 2e185434f08b5ea0339d59a6ea006017e5abeff2
2025-08-21 09:32:21 -07:00
Nicola Corti 3f74a87027 Reland: Remove deprecated DefaultReactHost.getDefaultReactHost() overload - part 1 & 2
Summary:
This is a reland of D80622058 + D80623826 + fixes for all the apps.

This method was deprecated in React Native 0.79. We should be able to remove it without impact in 0.82.
I also verified that there are no users of this API in OSS.

There is also a 1:1 replacement for this API which is the other non-deprecated `getDefaultReactHost()` method.

bypass-github-export-checks

Changelog:
[Internal] - Skipping changelog as main already contains a changelog entry

Reviewed By: javache

Differential Revision: D80704320

fbshipit-source-id: c9aa26b83dbd9f4bf97d0a9e9c6dcaa6eb0afdca
2025-08-21 09:31:30 -07:00
Christoph Purrer 9793542555 Align ImageManager and ImageFetcher requestImage API (#53382)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53382

changelog: [internal]

Reviewed By: rshest

Differential Revision: D80679608

fbshipit-source-id: 1a9b5f6a82b1f46e006983f5013272fca4e931bb
2025-08-21 08:46:32 -07:00
Rubén Norte b899e18d1c Do not report mount for mount items with empty surfaceId (#53391)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53391

Changelog: [internal]

Some mount items dispatched to Fabric don't have an associated surface ID (they use -1), which causes some log spam when we try to validate that the surface ID exist when we report mount for those surfaces.

This checks if the surface ID has a valid surface ID before adding it to the list of surfaces to report mount.

Reviewed By: rshest

Differential Revision: D80698363

fbshipit-source-id: 63dc13d53b8bbc2742171b1f444c80ce867e2351
2025-08-21 07:54:00 -07:00
Juan Penaloza aec35b8960 Revert D80622058: Remove deprecated DefaultReactHost.getDefaultReactHost() overload - part 1
Differential Revision:
D80622058

Original commit changeset: 4667683be151

Original Phabricator Diff: D80622058

fbshipit-source-id: c6c119df3b4f849a5c66fbbb619017ae837260c8
2025-08-21 06:26:35 -07:00
Juan Penaloza 3c79d7c18d Revert D80623826: Remove deprecated DefaultReactHost.getDefaultReactHost() overload - part 2
Differential Revision:
D80623826

Original commit changeset: f201e99f7cd4

Original Phabricator Diff: D80623826

fbshipit-source-id: 006bef0883f8cc82b333a68b9260b77afaae060f
2025-08-21 06:26:35 -07:00
Jakub Piasecki 7f051c5470 Change leftover references to hermes.framework (#53390)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53390

Changelog: [General][Fixed] - Change leftover references to `hermes.framework` to `hermesvm.framework`

Reviewed By: cipolleschi

Differential Revision: D80701257

fbshipit-source-id: 9c0e8e49e50f515941e48de2219fb7730d8896bd
2025-08-21 06:24:32 -07:00
Nicola Corti 8bdb34732b Delete internal ReactPackageLogger as no longer necessary (#53387)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53387

This interface was internal and legacy arch only, so it can safely be removed.
I've also removed the logic inside `ReactInstanceManager` that was using it as no longer necessary.

Changelog:
[Internal] [Changed] -

Reviewed By: mdvacca

Differential Revision: D80626639

fbshipit-source-id: b173e71b92e29cebbfc5ed589e01ac295eda2bf0
2025-08-21 05:31:55 -07:00
Nicola Corti 4583fbe052 Deprecate BridgelessReactContext.getCatalystInstance() (#53388)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53388

This method is deprecated and should not be invoked in NewArch, therefore I'm deprecating it now.

Changelog:
[Android] [Deprecated] - Deprecate `BridgelessReactContext.getCatalystInstance()` method

Reviewed By: cipolleschi

Differential Revision: D80626638

fbshipit-source-id: d4ed26021c376f54c732154c153bf60fea2bf5e3
2025-08-21 05:31:55 -07:00
Nicola Corti fbef891573 Fix build race condition with preparePrefab missing 3p headers (#53384)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53384

Occasionally, the `preparePrefab` task might run before other tasks that
are responsible of populating the 3p headers, such as `prepareNative3pDependencies`.

This was evident in the latest nightly which is missing the fast_float headers in the
Android prefab.

Adding a dependsOn fixes it.

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D80695212

fbshipit-source-id: 6e0dd17e5cf8c33d14812e5cb8fdc8b800897816
2025-08-21 05:31:40 -07:00
Nicola Corti bda6acf3b0 Remove deprecated DefaultReactHost.getDefaultReactHost() overload - part 2 (#53374)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53374

This method was deprecated in React Native 0.79. We should be able to remove it without impact in 0.82.
I also verified that there are no users of this API in OSS.

There is also a 1:1 replacement for this API which is the other non-deprecated getDefaultReactHost() method.

Changelog:
[Android] [Removed] - Remove deprecated DefaultReactHost.getDefaultReactHost() overload - part 2

Reviewed By: mdvacca

Differential Revision: D80623826

fbshipit-source-id: f201e99f7cd437a47919c36eced5637481151822
2025-08-21 04:51:13 -07:00
Nicola Corti 474f455a75 Remove deprecated DefaultReactHost.getDefaultReactHost() overload - part 1 (#53371)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53371

This method was deprecated in React Native 0.79. We should be able to remove it without impact in 0.82.
I also verified that there are no users of this API in OSS.

There is also a 1:1 replacement for this API which is the other non-deprecated `getDefaultReactHost()` method.

Changelog:
[Android] [Removed] - Remove deprecated DefaultReactHost.getDefaultReactHost() overload - part 1

Reviewed By: mdvacca

Differential Revision: D80622058

fbshipit-source-id: 4667683be151bc7ef1926a21306e088185695369
2025-08-21 04:51:13 -07:00
generatedunixname89002005287564 2ad87cdc50 Fix CQS signal modernize-use-designated-initializers in xplat/js/react-native-github/packages [A] [B] (#53385)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53385

Reviewed By: rshest

Differential Revision: D80617317

fbshipit-source-id: b06cb66d93b90c571f17184fa78a54f79f43b8a3
2025-08-21 04:32:52 -07:00
generatedunixname89002005287564 5d41129ce1 Fix CQS signal modernize-use-designated-initializers in xplat/js/react-native-github/packages [A] [A] (#53386)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53386

Reviewed By: rshest

Differential Revision: D80617203

fbshipit-source-id: c38c3e69eda4d09b416270d4a672cc087b203b6a
2025-08-21 04:23:44 -07:00
Jakub Piasecki 776fca1e7c Change hermes atrifact names (#53094)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53094

Changelog: [General][Changed] - Changed names of hermes binaries

Reviewed By: cipolleschi, cortinico

Differential Revision: D79163127

fbshipit-source-id: 54be34ba1f6ce90067768394ca9a6e9c4048be90
2025-08-21 04:00:04 -07:00
Alex Hunt 3d1d81cddc Remove Perf Monitor hooks from DevSupport API (#53349)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53349

Follows feedback on D78904767, refactoring how we pass data to `PerfMonitorOverlayViewManager` to avoid API additions on `DevSupport`.

New interfaces under `com.facebook.react.devsupport.perfmonitor`:

- `PerfMonitorUpdateListener` is implemented by the view class to receive updates from the C++ `HostTargetDelegate`.
- `PerfMonitorInspectorTargetBinding` exposes an API on `ReactHostInspectorTarget` to send CDP actions down to C++ (stub for now).
- `PerfMonitorDevHelper` allows us to use the internal `ReactHostImplDevHelper` to expose the `ReactHostInspectorTarget` instance from the runtime.

Changelog: [Internal]

Reviewed By: cortinico, rshest

Differential Revision: D80464093

fbshipit-source-id: b88e270c0211e4adf52c015ac700df7f44945a5a
2025-08-21 03:06:52 -07:00
Alex Hunt 62b8a7b4ef Switch Perf Monitor metric to Long Tasks (#53297)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53297

Pivots our display metric for the V2 Perf Monitor experiment by switching to Long Tasks.

- Implements a new "__ReactNative__LongTask" metrics event (note: prefixed, since this sits outside the Web Vitals spec).

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D79556595

fbshipit-source-id: 239cf44884f67bf62295b92e2262ae1811d17e4a
2025-08-21 03:06:52 -07:00
Nick Lefever 70d5c97ab4 Make Text shadow nodes uncullable on Android (#53376)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53376

When encountering embedded <Text> components, with the parent <Text> component setting event handlers, culling away the child <Text> components will break the assignment of the event handlers to the text spans on Android.

This diff disables view culling on <Text> components so that event handlers would be correctly assigned to the text fragments once rendered.

Changelog: [Internal]

Reviewed By: andrewdacenko

Differential Revision: D80631997

fbshipit-source-id: f835a249fef1b448b884999ccd75ee06041eca70
2025-08-20 17:35:00 -07:00
Sam Zhou 0ef21bf8ad Update prettier-plugin-hermes-parser in fbsource to 0.32.0 (#53380)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53380

Bump prettier-plugin-hermes-parser to 0.32.0.

Changelog: [internal]

Reviewed By: gkz

Differential Revision: D80644889

fbshipit-source-id: 2d3904db1a4d3952e34267cdb748eef021f93a7b
2025-08-20 16:37:19 -07:00
Sam Zhou b23c558a20 Kill $FlowExpectedError as a type across fbsource (#53378)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53378

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D80573556

fbshipit-source-id: 4d8fc85d563977deb83abdd278175c960f54fd13
2025-08-20 13:35:28 -07:00
Sam Zhou 89fd398342 Update hermes-parser and related packages in fbsource to 0.32.0 (#53377)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53377

Bump hermes-parser and related packages to [0.32.0](https://github.com/facebook/hermes/blob/static_h/tools/hermes-parser/js/CHANGELOG.md).

Changelog: [internal]

Reviewed By: gkz

Differential Revision: D80622389

fbshipit-source-id: d35ad5179eacbc83132517e6b9c9436fda972d28
2025-08-20 11:45:16 -07:00
Joe Vilches 9f2389f074 Move enableAccessibilityOrder feature flag to experimental (#53375)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53375

We have seen sufficient internal signal to be confident that we can move this to the experimental release channel. Soon I will publish some experimental documentation and let folks in OSS know about this.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D80560366

fbshipit-source-id: 6a8cce39f823dfa313c8c51090eb88c31f1f9fd3
2025-08-20 10:35:11 -07:00
nishan (o^▽^o) 6da351a5ed fix(iOS)(Fabric) inline view alignment inside of a Text with line height (#53341)
Summary:
Addresses - https://github.com/facebook/react-native/issues/53092

Fixes inline `View` frame calculation that is nested inside of a `Text` with a `lineHeight`. The calculation for inline view frame is correct on [Paper](https://github.com/facebook/react-native/blob/25104de5c47845c0edbdfb38df30f8c406da832e/packages/react-native/Libraries/Text/Text/RCTTextShadowView.mm#L338). This PR uses the same calculation as Paper (use glyph height instead of baseline from layout manager).

jest_e2e[run_all_tests]

## Changelog:

[IOS] [FIXED] - Inline `View` alignment with `lineHeight` in Text

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

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

Test Plan:
Make sure Text render is consistent on iOS and android and the View aligns with Text baseline with the provided [repro](https://github.com/facebook/react-native/issues/53092)

<img width="400" height="766" alt="Screenshot 2025-08-19 at 4 55 01 AM" src="https://github.com/user-attachments/assets/bc4e7473-8fe9-4596-a9ea-fd1204e4b3a3" />

Rollback Plan:

Reviewed By: christophpurrer

Differential Revision: D80525760

Pulled By: cipolleschi

fbshipit-source-id: 0152c35c56d8631942c0186f5dbe33c4a20a48c4
2025-08-20 07:40:54 -07:00
Rubén Norte 2ad845ccb2 Ship DOM APIs to stable (#53360)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53360

Changelog: [General][Breaking] -  Enable DOM APIs in host component refs

This ships DOM APIs to stable now that we have a cohesive API and it's been stable at Meta for a while.

This changes the `HostInstance` type (exported from the `react-native` package and used by all host components) from being an interface to being a class (`ReactNativeElement`).

**The API is backwards compatible** but given we're changing the definition of `HostInstance` from an interface to a class, this can be considered a **breaking change for TypeScript** (not at runtime).

## Previous API

- [`measure`](https://reactnative.dev/docs/the-new-architecture/layout-measurements#measurecallback)
- [`measureInWindow`](https://reactnative.dev/docs/the-new-architecture/layout-measurements#measureinwindowcallback)
- `measureLayout`
- [`setNativeProps`](https://reactnative.dev/docs/the-new-architecture/direct-manipulation-new-architecture#setnativeprops-to-edit-textinput-value)

## New API

From [`HTMLElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement):

- Properties
  - [`offsetHeight`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight)
  - [`offsetLeft`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetLeft)
  - [`offsetParent`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetParent)
  - [`offsetTop`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetTop)
  - [`offsetWidth`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetWidth)
- Methods
  - [`blur`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/blur).
    - This method was also [available](/docs/next/legacy/direct-manipulation#blur) in the legacy architecture.
  - [`focus`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/focus).
    - This method was also [available](/docs/next/legacy/direct-manipulation#focus) in the legacy architecture.
    - The `options` parameter is not supported.

From [`Element`](https://developer.mozilla.org/en-US/docs/Web/API/Element):

- Properties
  - [`childElementCount`](https://developer.mozilla.org/en-US/docs/Web/API/Element/childElementCount)
  - [`children`](https://developer.mozilla.org/en-US/docs/Web/API/Element/children)
  - [`clientHeight`](https://developer.mozilla.org/en-US/docs/Web/API/Element/clientHeight)
  - [`clientLeft`](https://developer.mozilla.org/en-US/docs/Web/API/Element/clientLeft)
  - [`clientTop`](https://developer.mozilla.org/en-US/docs/Web/API/Element/clientTop)
  - [`clientWidth`](https://developer.mozilla.org/en-US/docs/Web/API/Element/clientWidth)
  - [`firstElementChild`](https://developer.mozilla.org/en-US/docs/Web/API/Element/firstElementChild)
  - [`id`](https://developer.mozilla.org/en-US/docs/Web/API/Element/id)
    - Returns the value of the `id` or `nativeID` props.
  - [`lastElementChild`](https://developer.mozilla.org/en-US/docs/Web/API/Element/lastElementChild)
  - [`nextElementSibling`](https://developer.mozilla.org/en-US/docs/Web/API/Element/nextElementSibling)
  - [`nodeName`](https://developer.mozilla.org/en-US/docs/Web/API/Element/nodeName)
  - [`nodeType`](https://developer.mozilla.org/en-US/docs/Web/API/Element/nodeType)
  - [`nodeValue`](https://developer.mozilla.org/en-US/docs/Web/API/Element/nodeValue)
  - [`previousElementSibling`](https://developer.mozilla.org/en-US/docs/Web/API/Element/previousElementSibling)
  - [`scrollHeight`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight)
  - [`scrollLeft`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft)
    - For built-in components, only `ScrollView` instances can return a value other than zero.
  - [`scrollTop`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop)
    - For built-in components, only `ScrollView` instances can return a value other than zero.
  - [`scrollWidth`](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth)
  - [`tagName`](https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName)
    - Returns a normalized native component name prefixed with `RN:`, like `RN:View`.
  - [`textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Element/textContent)
- Methods
  - [`getBoundingClientRect`](https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect)
  - [`hasPointerCapture`](https://developer.mozilla.org/en-US/docs/Web/API/Element/hasPointerCapture)
  - [`setPointerCapture`](https://developer.mozilla.org/en-US/docs/Web/API/Element/setPointerCapture)
  - [`releasePointerCapture`](https://developer.mozilla.org/en-US/docs/Web/API/Element/releasePointerCapture)

From [`Node`](https://developer.mozilla.org/en-US/docs/Web/API/Node):

- Properties
  - [`childNodes`](https://developer.mozilla.org/en-US/docs/Web/API/Node/childNodes)
  - [`firstChild`](https://developer.mozilla.org/en-US/docs/Web/API/Node/firstChild)
  - [`isConnected`](https://developer.mozilla.org/en-US/docs/Web/API/Node/isConnected)
  - [`lastChild`](https://developer.mozilla.org/en-US/docs/Web/API/Node/lastChild)
  - [`nextSibling`](https://developer.mozilla.org/en-US/docs/Web/API/Node/nextSibling)
  - [`nodeName`](https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeName)
  - [`nodeType`](https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType)
  - [`nodeValue`](https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeValue)
  - [`ownerDocument`](https://developer.mozilla.org/en-US/docs/Web/API/Node/ownerDocument)
    - Will return the [document instance](/docs/next/document-instances) where this component was rendered.
  - [`parentElement`](https://developer.mozilla.org/en-US/docs/Web/API/Node/parentElement)
  - [`parentNode`](https://developer.mozilla.org/en-US/docs/Web/API/Node/parentNode)
  - [`previousSibling`](https://developer.mozilla.org/en-US/docs/Web/API/Node/previousSibling)
  - [`textContent`](https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent)
- Methods
  - [`compareDocumentPosition`](https://developer.mozilla.org/en-US/docs/Web/API/Node/compareDocumentPosition)
  - [`contains`](https://developer.mozilla.org/en-US/docs/Web/API/Node/contains)
  - [`getRootNode`](https://developer.mozilla.org/en-US/docs/Web/API/Node/getRootNode)
  - [`hasChildNodes`](https://developer.mozilla.org/en-US/docs/Web/API/Node/hasChildNodes)

### Legacy API

- [`measure`](https://reactnative.dev/docs/the-new-architecture/layout-measurements#measurecallback)
- [`measureInWindow`](https://reactnative.dev/docs/the-new-architecture/layout-measurements#measureinwindowcallback)
- `measureLayout`
- [`setNativeProps`](https://reactnative.dev/docs/the-new-architecture/direct-manipulation-new-architecture#setnativeprops-to-edit-textinput-value)

### New APIs

Additionally, this exposes access to document nodes and text nodes that were not available before.

This will be properly documented on the website at part of the release of 0.82, that will contain this changes.

Reviewed By: GijsWeterings

Differential Revision: D78562721

fbshipit-source-id: 139aee6969f3ecdc65cffcd31cd1754f367d9122
2025-08-20 07:18:00 -07:00
Riccardo Cipolleschi e04bbf0497 Fix E2E Tests by configuring git (#53357)
Summary:
E2E tests on iOS started failing yesterday because of some permission model that has changed in Github.

When creating a new app from the template, we initialize a git repository. The initialization started failing with the error:
```
debug Could not create an empty Git repository, error: , Error: Command failed with exit code 128: git commit -m Initial commit

Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'runner@sat12-jr314_3f88162a-0f3d-4d26-80dc-58f431cca4c6-9A2607311B51.(none)')
```

This change fixes it by setting a default identity for git in the CI jobs that requires it.

## Changelog:
[Internal] -

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

Test Plan: GHA

Reviewed By: cortinico

Differential Revision: D80612345

Pulled By: cipolleschi

fbshipit-source-id: 85816057d910ed3619c5f683fdad724c3df8046b
2025-08-20 06:58:36 -07:00
Rubén Norte 78f089906c Use React Native built-in definitions for Event and EventTarget in Fantom (#53362)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53362

Changelog: [internal]

This just replaces the polyfills for `Event` and `EventTarget` that we're defining inline in Fantom with the implementations that already exist in RN.

Reviewed By: javache

Differential Revision: D80612067

fbshipit-source-id: 047c8f12cbb1f4afea2d05a5a1235d9dff2e25f9
2025-08-20 06:01:22 -07:00
Nicola Corti 8480386d50 Disable running ktfmtCheck due to diverging ktfmt versions (#53359)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53359

A new version of ktfmt broke the OSS CI build for React Native.
That's due to us running still on the older version of ktfmt, as the newer version hasn't been released yet.

I'm temporarly disabling the `ktfmtCheck` jobs because we primarly check formatting from within fbsource.

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D80610450

fbshipit-source-id: 846249780f979788356404205d8b8e37fc54a255
2025-08-20 05:42:32 -07:00
Rubén Norte 9910981d3a Simplify RendererImplementation (#53351)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53351

Changelog: [internal]

This refactors `RendererImplementation` to reduce boilerplate code from exporting existing methods from Fabric or Paper.

Reviewed By: lenaic

Differential Revision: D80532479

fbshipit-source-id: ae70bb50f0d2fbf7aee95efd39d9716f0c3a8a90
2025-08-20 03:53:44 -07:00
Nivaldo Bondança d1a1020a4a Codemod format for trailing commas change
Reviewed By: VladimirMakaev

Differential Revision: D80576929

fbshipit-source-id: 1310f77f5d9d489b780b14875454ebda7f7adfc9
2025-08-19 18:15:18 -07:00
David Vacca fb84932e48 Deprecate ReactInstanceManager and ReactInstanceManagerBuilder (#53150)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53150

ReactInstanceManager and ReactInstanceManagerBuilder are legacy architecture classes that will be deleted in the future, in this diff we are deprecating them

changelog: [Android][Changed] Deprecate legacy architecture classes ReactInstanceManager and ReactInstanceManagerBuilder, these classes will be deleted in a future release

Reviewed By: mlord93

Differential Revision: D79677828

fbshipit-source-id: 2d79736d94a55e44dd24056985f358e3650ddf6c
2025-08-19 16:51:43 -07:00
Alex Hunt 3f848e7a54 Fix test setup for flag used early in HostTarget, restore value (#53355)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53355

Follows D80000286, where this flag was forcibly disabled to fix tests.

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D80545210

fbshipit-source-id: 585122ff73e4979c398be6eb03000936d6bd5ce1
2025-08-19 11:40:24 -07:00
Alex Hunt df748ba083 Implement Perf Monitor event scoring and display timeout (#53169)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53169

Improves the experimental Perf Monitor UI sufficient for the initial MVP.

- Sets minimum duration threshold to display an event to 10ms.
- Impelements [responsiveness scoring](https://web.dev/articles/inp#good-score) linked to UI colour and display timeout.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D79359131

fbshipit-source-id: f08d2b595e885342d841c3a02b9e02456502c926
2025-08-19 11:19:09 -07:00
generatedunixname89002005287564 defefb19e3 Fix CQS signal modernize-use-designated-initializers in xplat/js/react-native-github/packages (#53352)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53352

Reviewed By: cipolleschi

Differential Revision: D80516836

fbshipit-source-id: 28d10e5d1b9d476924c8e73526e164ff98e12be1
2025-08-19 09:53:13 -07:00
Riccardo Cipolleschi ba51aeaa90 Fix Switch layout with iOS26 (#53247)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53247

Apple changed the sizes of the UISwitchComponent and now, if you build an iOs app using the <Switch> component, the layout of the app will be broken because of wrong layout measurements.
This has been reported also by [https://github.com/facebook/react-native/issues/52823](https://github.com/facebook/react-native/issues/52823).

The `<Switch>` component was using hardcoded values for its size.
This change fixes the problem by:
- Using codegen for interface only
- Implementing a custom Sadow Node to ask the platform for the Switch measurements
- Updating the JS layout to wrap the size around the native component.

## Changelog:

[iOS][Fixed] - Fix Switch layout to work with iOS26

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

Test Plan:
Tested locally with RNTester.

| iOS Version | Before | After |
| --- | --- | --- |
| < iOS 26 | https://github.com/user-attachments/assets/91d73ea3-30ba-4a5c-948e-ea5c63aa7c6d | https://github.com/user-attachments/assets/76061bc8-0f14-412a-a8fb-d1c3951772e6 |
| >= iOS 26 | https://github.com/user-attachments/assets/1abc477f-bc0a-4762-938e-98814fb2a054 | https://github.com/user-attachments/assets/77e562e1-b803-46ac-9cf6-102f062a1cd4 |

Rollback Plan:

Reviewed By: sammy-SC

Differential Revision: D79653120

Pulled By: cipolleschi

fbshipit-source-id: d99b353b7b7b5496b148779de4abe3e57dd38156
2025-08-19 06:53:44 -07:00
Rubén Norte 24657ad5c4 Optimize DOM APIs (#53332)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53332

Changelog: [internal]

This implements several optimizations to speed up DOM traversal APIs.

The main changes are:
1. Better caching of renderer methods in `RendererImplementation`.
2. Faster access to public instances from instance handles (avoids `instanceof` checks if the nodes are `ReactNativeElement`, which is the most common case).
3. Avoiding unnecessary function calls in `NativeDOM` but removing the proxy object.
4. Removal of private fields from `HTMLCollection` and `NodeList`, and reuse the object to define object properties.
5. Avoiding unnecessary array copies in `getChildNodes`.

Results:

| Property / method               | Latency before (ns) | Latency after (ns) | Difference |
| ----------------------- | ------------------------- | ------------------------ | ---------- |
| parentNode              | 3996                      | 2203                     | -44.87%   |
| parentElement           | 4347                      | 2524                     | -41.94%   |
| childNodes              | 6590                      | 3886                     | -41.03%   |
| children                | 6950                      | 4126                     | -40.63%   |
| firstChild              | 5008                      | 2975                     | -40.60%   |
| firstElementChild       | 5408                      | 3215                     | -40.55%   |
| lastChild               | 5048                      | 2974                     | -41.09%   |
| lastElementChild        | 5448                      | 3215                     | -40.99%   |
| childElementCount       | 5378                      | 3175                     | -40.96%   |
| previousSibling         | 12118                     | 6780                     | -44.05%   |
| previousElementSibling  | 12148                     | 6850                     | -43.61%   |
| nextSibling             | 12139                     | 6800                     | -43.98%   |
| nextElementSibling      | 12119                     | 6830                     | -43.64%   |
| offsetParent            | 5097                      | 3725                     | -26.92%   |
| isConnected             | 2774                      | 1733                     | -37.53%   |
| ownerDocument           | 691                       | 681                      | -1.45%    |
| getRootNode()           | 3195                      | 2154                     | -32.58%   |
| hasChildNodes()         | 4997                      | 2854                     | -42.89%   |

Reviewed By: mdvacca

Differential Revision: D80449030

fbshipit-source-id: 6b3abecbbf6aa23bc99ab65cf22ed33721dc5459
2025-08-19 06:06:52 -07:00
Rubén Norte b7b83cda0a Remove nullability from NativeDOM.setNativeProps (#53331)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53331

Changelog: [internal]

This change was shipped 3 months ago so we can assume the native method will always have this method and don't need to keep backwards compatibility.

Reviewed By: rshest

Differential Revision: D80449031

fbshipit-source-id: 4ff11b81478701ad712b4e097625e569829f6480
2025-08-19 06:06:52 -07:00
Rubén Norte 9301badec1 Remove nullability from NativePerformance module methods (#53330)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53330

Changelog: [internal]

These methods have been defined for a month, so it's safe to make then non-nullable already.

Reviewed By: GijsWeterings

Differential Revision: D80453413

fbshipit-source-id: 3fde076622dc9d510bad144300364401f2319507
2025-08-19 06:06:52 -07:00
Rubén Norte 14718b20c6 Prepare Flow types for change in HostInstance (#53318)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53318

Changelog: [internal]

This prepares the codebase for an eventual migration of `HostInstance` to `ReactNativeElement`, so the actual migration doesn't need to adjust so much existing code.

Reviewed By: rshest

Differential Revision: D80399739

fbshipit-source-id: 441d3e92ef6dff253343d1058b2027698e8ecb22
2025-08-19 06:06:35 -07:00
Andrew Datsenko e7d89fa53a Add support for perfetto on Windows tracing (#53340)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53340

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D80471173

fbshipit-source-id: 54f24c9c6868dae2042d324c8aed87726ede05a8
2025-08-19 05:38:12 -07:00
Samuel Susla 8197399e43 ship fix to a crash in differentiator (#53346)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53346

changelog: [internal]

ship fix for a rare crash in differentiator.

Reviewed By: rshest

Differential Revision: D80459923

fbshipit-source-id: 308f513fca4787a01250ba25d8ce73db84fa83a5
2025-08-19 04:39:04 -07:00
generatedunixname537391475639613 4a48364639 xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/devsupport/CxxInspectorPackagerConnection.kt (#53348)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53348

Reviewed By: cortinico, rshest

Differential Revision: D80443954

fbshipit-source-id: 4a45508aa0249b86adc96b1ebd62f2e409b3aac2
2025-08-19 04:31:16 -07:00
Christian Falch e3adf47214 fixed copying bundles correctly (#53325)
Summary:
When copying bundle files from the platform folders in the .build output, the script had a bug where all bundles were copied - meaning that only the last one would be in the resulting xcframework output.

This caused an issue when we tried to publish an app built with precompiled binaries to AppStore where the field `CFBundleSupportedPlatforms` was wrong and caused the submission to be rejected. This was caused by the script copying the wrong bundle file into the final xcframework outputs.

This issue is described here:
https://github.com/react-native-community/discussions-and-proposals/discussions/923#discussioncomment-14089245

This commit fixes the above error by using the iOS 15 `vtool` to show the actual platform for a given framework and then making sure we don't copy bundles in the wrong way.

Testing this on my local machine for iOS/iOS-simulator/MacOS/catalyst yields the following results (before/after this fix):

**Before:**

```bash
Copying bundles to the framework...
  ../.build/Build/Products/Debug/ReactNativeDependencies_glog.bundle → ios-arm64
  ../.build/Build/Products/Debug/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-maccatalyst
  ../.build/Build/Products/Debug/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-simulator
  ../.build/Build/Products/Debug/ReactNativeDependencies_glog.bundle → macos-arm64_x86_64
  ../.build/Build/Products/Debug/ReactNativeDependencies_boost.bundle → ios-arm64
  ../.build/Build/Products/Debug/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-maccatalyst
  ../.build/Build/Products/Debug/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-simulator
  ../.build/Build/Products/Debug/ReactNativeDependencies_boost.bundle → macos-arm64_x86_64
  ../.build/Build/Products/Debug/ReactNativeDependencies_folly.bundle → ios-arm64
  ../.build/Build/Products/Debug/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-maccatalyst
  ../.build/Build/Products/Debug/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-simulator
  ../.build/Build/Products/Debug/ReactNativeDependencies_folly.bundle → macos-arm64_x86_64
  ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_glog.bundle → ios-arm64
  ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-maccatalyst
  ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-simulator
  ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_glog.bundle → macos-arm64_x86_64
  ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_boost.bundle → ios-arm64
  ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-maccatalyst
  ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-simulator
  ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_boost.bundle → macos-arm64_x86_64
  ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_folly.bundle → ios-arm64
  ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-maccatalyst
  ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-simulator
  ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_folly.bundle → macos-arm64_x86_64
  ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_glog.bundle → ios-arm64
  ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-maccatalyst
  ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-simulator
  ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_glog.bundle → macos-arm64_x86_64
  ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_boost.bundle → ios-arm64
  ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-maccatalyst
  ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-simulator
  ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_boost.bundle → macos-arm64_x86_64
  ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_folly.bundle → ios-arm64
  ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-maccatalyst
  ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-simulator
  ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_folly.bundle → macos-arm64_x86_64
  ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_glog.bundle → ios-arm64
  ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-maccatalyst
  ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-simulator
  ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_glog.bundle → macos-arm64_x86_64
  ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_boost.bundle → ios-arm64
  ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-maccatalyst
  ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-simulator
  ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_boost.bundle → macos-arm64_x86_64
  ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_folly.bundle → ios-arm64
  ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-maccatalyst
  ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-simulator
  ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_folly.bundle → macos-arm64_x86_64
```

  **After:**

```bash
  Copying bundles to the framework...
  ../.build/Build/Products/Debug/ReactNativeDependencies_glog.bundle → macos-arm64_x86_64
  ../.build/Build/Products/Debug/ReactNativeDependencies_boost.bundle → macos-arm64_x86_64
  ../.build/Build/Products/Debug/ReactNativeDependencies_folly.bundle → macos-arm64_x86_64
  ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_glog.bundle → ios-arm64
  ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_boost.bundle → ios-arm64
  ../.build/Build/Products/Debug-iphoneos/ReactNativeDependencies_folly.bundle → ios-arm64
  ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-simulator
  ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-simulator
  ../.build/Build/Products/Debug-iphonesimulator/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-simulator
  ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_glog.bundle → ios-arm64_x86_64-maccatalyst
  ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_boost.bundle → ios-arm64_x86_64-maccatalyst
  ../.build/Build/Products/Debug-maccatalyst/ReactNativeDependencies_folly.bundle → ios-arm64_x86_64-maccatalyst
```

## Changelog:

[IOS] [FIXED] - Fixed copying bundles correctly to xcframeworks when precompiling ReactNativeDependencies.xcframework

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

Test Plan: Ensure that the info.plist files in the nightlies for the ReactNativeDepdendencies.xcframework has the correct bundles for its targets.

Reviewed By: andrewdacenko

Differential Revision: D80457335

Pulled By: cipolleschi

fbshipit-source-id: aeb4166f66218f72bdd29b6fc579fcc7b6d12844
2025-08-19 02:47:40 -07:00
Nicola Corti 59cc1738d7 Add missing headers from react_performance_cdpmetrics to prefab (#53304)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53304

The headers from `react_performance_cdpmetrics` are currently missing in the libreactnative.so prefab.

They're actually references from `Scheduler.h` and this is causing `react-native-screens` to fail compiling
with:

```
  In file included from /tmp/RNApp/node_modules/react-native-screens/android/src/main/cpp/NativeProxy.cpp:3:
  /home/runner/.gradle/caches/8.14.3/transforms/97716233b9aa00728d9cac038eecaf3d/transformed/react-android-0.82.0-nightly-20250815-41029d8e9-SNAPSHOT-debug/prefab/modules/reactnative/include/react/renderer/scheduler/Scheduler.h:13:10: fatal error: 'react/performance/cdpmetrics/CdpMetricsReporter.h' file not found
     13 | #include <react/performance/cdpmetrics/CdpMetricsReporter.h>
        |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1 error generated.
  [4/6] Building CXX object CMakeFiles/rnscreens.dir/tmp/RNApp/node_modules/react-native-screens/cpp/RNSScreenRemovalListener.cpp.o
  [5/6] Building CXX object CMakeFiles/rnscreens.dir/src/main/cpp/OnLoad.cpp.o
```

See here https://github.com/react-native-community/nightly-tests/actions/runs/16991637594/job/48172255960
I saw this was added on D78904748

Here I'm exposing the headers from `react_performance_cdpmetrics` to the prefab API so users in OSS can
access those headers as well.

Changelog:
[Internal] [Changed] -

Reviewed By: cipolleschi

Differential Revision: D80344762

fbshipit-source-id: 29b09b94370b71a16ecf12d4cca9cd571c588e5c
2025-08-19 02:34:22 -07:00
397 changed files with 4453 additions and 3184 deletions
-1
View File
@@ -76,7 +76,6 @@ module.system.haste.module_ref_prefix=m#
react.runtime=automatic
experimental.error_code_migration=new
suppress_type=$FlowFixMe
ban_spread_key_props=true
@@ -71,17 +71,17 @@ runs:
mv build_"$SLICE" "$FINAL_PATH"
# check whether everything is there
if [[ -d "$FINAL_PATH/API/hermes/hermes.framework" ]]; then
echo "Successfully built hermes.framework for $SLICE in $FLAVOR"
if [[ -d "$FINAL_PATH/lib/hermesvm.framework" ]]; then
echo "Successfully built hermesvm.framework for $SLICE in $FLAVOR"
else
echo "Failed to built hermes.framework for $SLICE in $FLAVOR"
echo "Failed to built hermesvm.framework for $SLICE in $FLAVOR"
exit 1
fi
if [[ -d "$FINAL_PATH/API/hermes/hermes.framework.dSYM" ]]; then
echo "Successfully built hermes.framework.dSYM for $SLICE in $FLAVOR"
if [[ -d "$FINAL_PATH/lib/hermesvm.framework.dSYM" ]]; then
echo "Successfully built hermesvm.framework.dSYM for $SLICE in $FLAVOR"
else
echo "Failed to built hermes.framework.dSYM for $SLICE in $FLAVOR"
echo "Failed to built hermesvm.framework.dSYM for $SLICE in $FLAVOR"
echo "Please try again"
exit 1
fi
@@ -186,7 +186,7 @@ runs:
cd ./packages/react-native/sdks/hermes || exit 1
DSYM_FILE_PATH=API/hermes/hermes.framework.dSYM
DSYM_FILE_PATH=lib/hermesvm.framework.dSYM
cp -r build_macosx/$DSYM_FILE_PATH "$WORKING_DIR/macosx/"
cp -r build_catalyst/$DSYM_FILE_PATH "$WORKING_DIR/catalyst/"
cp -r build_iphoneos/$DSYM_FILE_PATH "$WORKING_DIR/iphoneos/"
@@ -197,10 +197,10 @@ runs:
cp -r build_xrsimulator/$DSYM_FILE_PATH "$WORKING_DIR/xrsimulator/"
DEST_DIR="/tmp/hermes/dSYM/$FLAVOR"
tar -C "$WORKING_DIR" -czvf "hermes.framework.dSYM" .
tar -C "$WORKING_DIR" -czvf "hermesvm.framework.dSYM" .
mkdir -p "$DEST_DIR"
mv "hermes.framework.dSYM" "$DEST_DIR"
mv "hermesvm.framework.dSYM" "$DEST_DIR"
- name: Upload hermes dSYM artifacts
uses: actions/upload-artifact@v4.3.4
with:
+2 -2
View File
@@ -99,8 +99,8 @@ runs:
mkdir -p ./packages/react-native/ReactAndroid/external-artifacts/artifacts/
cp ${{ inputs.hermes-ws-dir }}/hermes-runtime-darwin/hermes-ios-Debug.tar.gz ./packages/react-native/ReactAndroid/external-artifacts/artifacts/hermes-ios-debug.tar.gz
cp ${{ inputs.hermes-ws-dir }}/hermes-runtime-darwin/hermes-ios-Release.tar.gz ./packages/react-native/ReactAndroid/external-artifacts/artifacts/hermes-ios-release.tar.gz
cp ${{ inputs.hermes-ws-dir }}/dSYM/Debug/hermes.framework.dSYM ./packages/react-native/ReactAndroid/external-artifacts/artifacts/hermes-framework-dSYM-debug.tar.gz
cp ${{ inputs.hermes-ws-dir }}/dSYM/Release/hermes.framework.dSYM ./packages/react-native/ReactAndroid/external-artifacts/artifacts/hermes-framework-dSYM-release.tar.gz
cp ${{ inputs.hermes-ws-dir }}/dSYM/Debug/hermesvm.framework.dSYM ./packages/react-native/ReactAndroid/external-artifacts/artifacts/hermes-framework-dSYM-debug.tar.gz
cp ${{ inputs.hermes-ws-dir }}/dSYM/Release/hermesvm.framework.dSYM ./packages/react-native/ReactAndroid/external-artifacts/artifacts/hermes-framework-dSYM-release.tar.gz
- name: Download ReactNativeDependencies
uses: actions/download-artifact@v4
with:
+5
View File
@@ -246,6 +246,11 @@ jobs:
- name: Print ReactCore folder
shell: bash
run: ls -lR /tmp/ReactCore
- name: Configure git
shell: bash
run: |
git config --global user.email "react-native-bot@meta.com"
git config --global user.name "React Native Bot"
- name: Prepare artifacts
run: |
REACT_NATIVE_PKG=$(find /tmp/react-native-tmp -type f -name "*.tgz")
+28 -12
View File
@@ -26,10 +26,12 @@ fun getListReactAndroidProperty(name: String) = reactAndroidProperties.getProper
apiValidation {
ignoredPackages.addAll(
getListReactAndroidProperty("binaryCompatibilityValidator.ignoredPackages"))
getListReactAndroidProperty("binaryCompatibilityValidator.ignoredPackages")
)
ignoredClasses.addAll(getListReactAndroidProperty("binaryCompatibilityValidator.ignoredClasses"))
nonPublicMarkers.addAll(
getListReactAndroidProperty("binaryCompatibilityValidator.nonPublicMarkers"))
getListReactAndroidProperty("binaryCompatibilityValidator.nonPublicMarkers")
)
validationDisabled =
reactAndroidProperties
.getProperty("binaryCompatibilityValidator.validationDisabled")
@@ -37,8 +39,9 @@ apiValidation {
}
version =
if (project.hasProperty("isSnapshot") &&
(project.property("isSnapshot") as? String).toBoolean()) {
if (
project.hasProperty("isSnapshot") && (project.property("isSnapshot") as? String).toBoolean()
) {
"${reactAndroidProperties.getProperty("VERSION_NAME")}-SNAPSHOT"
} else {
reactAndroidProperties.getProperty("VERSION_NAME")
@@ -66,8 +69,10 @@ tasks.register("clean", Delete::class.java) {
description = "Remove all the build files and intermediate build outputs"
dependsOn(gradle.includedBuild("gradle-plugin").task(":clean"))
subprojects.forEach {
if (it.project.plugins.hasPlugin("com.android.library") ||
it.project.plugins.hasPlugin("com.android.application")) {
if (
it.project.plugins.hasPlugin("com.android.library") ||
it.project.plugins.hasPlugin("com.android.application")
) {
dependsOn(it.tasks.named("clean"))
}
}
@@ -77,10 +82,13 @@ tasks.register("clean", Delete::class.java) {
delete(rootProject.file("./packages/react-native/sdks/download/"))
delete(rootProject.file("./packages/react-native/sdks/hermes/"))
delete(
rootProject.file("./packages/react-native/ReactAndroid/src/main/jni/prebuilt/lib/arm64-v8a/"))
rootProject.file("./packages/react-native/ReactAndroid/src/main/jni/prebuilt/lib/arm64-v8a/")
)
delete(
rootProject.file(
"./packages/react-native/ReactAndroid/src/main/jni/prebuilt/lib/armeabi-v7a/"))
"./packages/react-native/ReactAndroid/src/main/jni/prebuilt/lib/armeabi-v7a/"
)
)
delete(rootProject.file("./packages/react-native/ReactAndroid/src/main/jni/prebuilt/lib/x86/"))
delete(rootProject.file("./packages/react-native/ReactAndroid/src/main/jni/prebuilt/lib/x86_64/"))
delete(rootProject.file("./packages/react-native-codegen/lib"))
@@ -98,7 +106,8 @@ tasks.register("publishAllToMavenTempLocal") {
dependsOn(":packages:react-native:ReactAndroid:publishAllPublicationsToMavenTempLocalRepository")
// We don't publish the external-artifacts to Maven Local as ci is using it via workspace.
dependsOn(
":packages:react-native:ReactAndroid:hermes-engine:publishAllPublicationsToMavenTempLocalRepository")
":packages:react-native:ReactAndroid:hermes-engine:publishAllPublicationsToMavenTempLocalRepository"
)
}
tasks.register("publishAndroidToSonatype") {
@@ -120,7 +129,8 @@ if (project.findProperty("react.internal.useHermesNightly")?.toString()?.toBoole
That's fine for local development, but you should not commit this change.
********************************************************************************
"""
.trimIndent())
.trimIndent()
)
allprojects {
configurations.all {
resolutionStrategy.dependencySubstitution {
@@ -152,10 +162,12 @@ allprojects {
"**/build/**",
"**/hermes-engine/**",
"**/internal/featureflags/**",
"**/systeminfo/ReactNativeVersion.kt")
"**/systeminfo/ReactNativeVersion.kt",
)
listOf(
com.ncorti.ktfmt.gradle.tasks.KtfmtCheckTask::class,
com.ncorti.ktfmt.gradle.tasks.KtfmtFormatTask::class)
com.ncorti.ktfmt.gradle.tasks.KtfmtFormatTask::class,
)
.forEach { tasks.withType(it) { exclude(excludePatterns) } }
// Disable the problematic ktfmt script tasks due to symbolic link issues in subprojects
@@ -165,3 +177,7 @@ allprojects {
}
}
}
// We intentionally disable the `ktfmtCheck` tasks as the formatting is primarly handled inside
// fbsource
allprojects { tasks.withType<com.ncorti.ktfmt.gradle.tasks.KtfmtCheckTask>() { enabled = false } }
+5 -5
View File
@@ -63,7 +63,7 @@
"@typescript-eslint/parser": "^8.36.0",
"ansi-styles": "^4.2.1",
"babel-plugin-minify-dead-code-elimination": "^0.5.2",
"babel-plugin-syntax-hermes-parser": "0.31.2",
"babel-plugin-syntax-hermes-parser": "0.32.0",
"babel-plugin-transform-define": "^2.1.4",
"babel-plugin-transform-flow-enums": "^0.0.2",
"clang-format": "^1.8.0",
@@ -81,11 +81,11 @@
"eslint-plugin-react-native": "^4.0.0",
"eslint-plugin-redundant-undefined": "^0.4.0",
"eslint-plugin-relay": "^1.8.3",
"flow-api-translator": "0.31.2",
"flow-api-translator": "0.32.0",
"flow-bin": "^0.279.0",
"glob": "^7.1.1",
"hermes-eslint": "0.31.2",
"hermes-transform": "0.31.2",
"hermes-eslint": "0.32.0",
"hermes-transform": "0.32.0",
"ini": "^5.0.0",
"inquirer": "^7.1.0",
"jest": "^29.7.0",
@@ -102,7 +102,7 @@
"node-fetch": "^2.2.0",
"nullthrows": "^1.1.1",
"prettier": "3.6.2",
"prettier-plugin-hermes-parser": "0.31.1",
"prettier-plugin-hermes-parser": "0.32.0",
"react": "19.1.1",
"react-test-renderer": "19.1.1",
"rimraf": "^3.0.2",
@@ -81,10 +81,147 @@ export {Commands};
export default (codegenNativeComponent<ModuleProps>('Module'): NativeType);
`;
const COMMANDS_WITH_COVERAGE_INVALID = `
// @flow
const codegenNativeComponent = require('codegenNativeComponent');
import type {NativeComponentType} from 'codegenNativeComponent';
import type {ViewProps} from 'ViewPropTypes';
type ModuleProps = $ReadOnly<{|
...ViewProps,
|}>;
type NativeType = NativeComponentType<ModuleProps>;
// Coverage instrumentation of invalid Commands export - should still fail
export const Commands = (cov_1234567890().s[0]++, {
hotspotUpdate: () => {},
scrollTo: () => {},
});
export default (codegenNativeComponent<ModuleProps>('Module'): NativeType);
`;
const COMMANDS_WITH_COVERAGE_WRONG_FUNCTION = `
// @flow
const codegenNativeComponent = require('codegenNativeComponent');
import type {NativeComponentType} from 'codegenNativeComponent';
import type {ViewProps} from 'ViewPropTypes';
type ModuleProps = $ReadOnly<{|
...ViewProps,
|}>;
type NativeType = NativeComponentType<ModuleProps>;
// Coverage instrumentation of wrong function call - should fail
export const Commands = (cov_abcdef123().s[0]++, someOtherFunction({
supportedCommands: ['pause', 'play'],
}));
export default (codegenNativeComponent<ModuleProps>('Module'): NativeType);
`;
const COMMANDS_WITH_COMPLEX_COVERAGE_INVALID = `
// @flow
const codegenNativeComponent = require('codegenNativeComponent');
import type {NativeComponentType} from 'codegenNativeComponent';
import type {ViewProps} from 'ViewPropTypes';
type ModuleProps = $ReadOnly<{|
...ViewProps,
|}>;
type NativeType = NativeComponentType<ModuleProps>;
// Complex coverage instrumentation with invalid nested structure - should fail
export const Commands = (
cov_xyz789().f[1]++,
cov_xyz789().s[2]++,
{
pause: (ref) => {},
play: (ref) => {},
}
);
export default (codegenNativeComponent<ModuleProps>('Module'): NativeType);
`;
const COMMANDS_WITH_COVERAGE_WRONG_NAME = `
// @flow
const codegenNativeCommands = require('codegenNativeCommands');
const codegenNativeComponent = require('codegenNativeComponent');
import type {NativeComponentType} from 'codegenNativeComponent';
import type {ViewProps} from 'ViewPropTypes';
type ModuleProps = $ReadOnly<{|
...ViewProps,
|}>;
type NativeType = NativeComponentType<ModuleProps>;
interface NativeCommands {
+pause: (viewRef: React.ElementRef<NativeType>) => void;
+play: (viewRef: React.ElementRef<NativeType>) => void;
}
// Coverage instrumentation with correct function but wrong export name - should fail
export const WrongName = (cov_wrong123().s[0]++, codegenNativeCommands<NativeCommands>({
supportedCommands: ['pause', 'play'],
}));
export default (codegenNativeComponent<ModuleProps>('Module'): NativeType);
`;
const COMMANDS_WITH_COVERAGE_TYPE_CAST_INVALID = `
// @flow
const codegenNativeComponent = require('codegenNativeComponent');
import type {NativeComponentType} from 'codegenNativeComponent';
import type {ViewProps} from 'ViewPropTypes';
type ModuleProps = $ReadOnly<{|
...ViewProps,
|}>;
type NativeType = NativeComponentType<ModuleProps>;
interface NativeCommands {
+pause: (viewRef: React.ElementRef<NativeType>) => void;
+play: (viewRef: React.ElementRef<NativeType>) => void;
}
// Coverage instrumentation with type cast but wrong function - should fail
export const Commands: NativeCommands = (cov_cast123().s[0]++, invalidFunction({
supportedCommands: ['pause', 'play'],
}));
export default (codegenNativeComponent<ModuleProps>('Module'): NativeType);
`;
module.exports = {
'CommandsExportedWithDifferentNameNativeComponent.js':
COMMANDS_EXPORTED_WITH_DIFFERENT_NAME,
'CommandsExportedWithShorthandNativeComponent.js':
COMMANDS_EXPORTED_WITH_SHORTHAND,
'OtherCommandsExportNativeComponent.js': OTHER_COMMANDS_EXPORT,
'CommandsWithCoverageInvalidNativeComponent.js':
COMMANDS_WITH_COVERAGE_INVALID,
'CommandsWithCoverageWrongFunctionNativeComponent.js':
COMMANDS_WITH_COVERAGE_WRONG_FUNCTION,
'CommandsWithComplexCoverageInvalidNativeComponent.js':
COMMANDS_WITH_COMPLEX_COVERAGE_INVALID,
'CommandsWithCoverageWrongNameNativeComponent.js':
COMMANDS_WITH_COVERAGE_WRONG_NAME,
'CommandsWithCoverageTypeCastInvalidNativeComponent.js':
COMMANDS_WITH_COVERAGE_TYPE_CAST_INVALID,
};
@@ -59,6 +59,92 @@ export default codegenNativeComponent<ModuleProps>('Module', {
});
`;
// Coverage instrumentation test cases - should be recognized as valid
const COMMANDS_WITH_SIMPLE_COVERAGE = `
// @flow
const codegenNativeCommands = require('codegenNativeCommands');
const codegenNativeComponent = require('codegenNativeComponent');
import type {ViewProps} from 'ViewPropTypes';
import type {NativeComponentType} from 'codegenNativeComponent';
type ModuleProps = $ReadOnly<{|
...ViewProps,
|}>;
type NativeType = NativeComponentType<ModuleProps>;
interface NativeCommands {
+pause: (viewRef: React.ElementRef<NativeType>) => void;
+play: (viewRef: React.ElementRef<NativeType>) => void;
}
export const Commands = (cov_1234567890.s[0]++, codegenNativeCommands<NativeCommands>({
supportedCommands: ['pause', 'play'],
}));
export default codegenNativeComponent<ModuleProps>('Module');
`;
const COMMANDS_WITH_COMPLEX_COVERAGE = `
// @flow
const codegenNativeCommands = require('codegenNativeCommands');
const codegenNativeComponent = require('codegenNativeComponent');
import type {ViewProps} from 'ViewPropTypes';
import type {NativeComponentType} from 'codegenNativeComponent';
type ModuleProps = $ReadOnly<{|
...ViewProps,
|}>;
type NativeType = NativeComponentType<ModuleProps>;
interface NativeCommands {
+seek: (viewRef: React.ElementRef<NativeType>, position: number) => void;
+stop: (viewRef: React.ElementRef<NativeType>) => void;
}
export const Commands = (
cov_abcdef123().f[2]++,
cov_abcdef123().s[5]++,
codegenNativeCommands<NativeCommands>({
supportedCommands: ['seek', 'stop'],
})
);
export default codegenNativeComponent<ModuleProps>('Module');
`;
const COMMANDS_WITH_TYPE_CAST_COVERAGE = `
// @flow
const codegenNativeCommands = require('codegenNativeCommands');
const codegenNativeComponent = require('codegenNativeComponent');
import type {ViewProps} from 'ViewPropTypes';
import type {NativeComponentType} from 'codegenNativeComponent';
type ModuleProps = $ReadOnly<{|
...ViewProps,
|}>;
type NativeType = NativeComponentType<ModuleProps>;
interface NativeCommands {
+mute: (viewRef: React.ElementRef<NativeType>) => void;
+unmute: (viewRef: React.ElementRef<NativeType>) => void;
}
export const Commands: NativeCommands = (cov_xyz789().s[1]++, codegenNativeCommands<NativeCommands>({
supportedCommands: ['mute', 'unmute'],
}));
export default codegenNativeComponent<ModuleProps>('Module');
`;
const FULL_NATIVE_COMPONENT_WITH_TYPE_EXPORT = `
// @flow
@@ -107,4 +193,9 @@ module.exports = {
'NotANativeComponent.js': NOT_A_NATIVE_COMPONENT,
'FullNativeComponent.js': FULL_NATIVE_COMPONENT,
'FullTypedNativeComponent.js': FULL_NATIVE_COMPONENT_WITH_TYPE_EXPORT,
'CommandsWithSimpleCoverageNativeComponent.js': COMMANDS_WITH_SIMPLE_COVERAGE,
'CommandsWithComplexCoverageNativeComponent.js':
COMMANDS_WITH_COMPLEX_COVERAGE,
'CommandsWithTypeCastCoverageNativeComponent.js':
COMMANDS_WITH_TYPE_CAST_COVERAGE,
};
@@ -1,5 +1,77 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`Babel plugin inline view configs can inline config for CommandsWithComplexCoverageNativeComponent.js 1`] = `
"// @flow
const codegenNativeCommands = require('codegenNativeCommands');
const codegenNativeComponent = require('codegenNativeComponent');
import type { ViewProps } from 'ViewPropTypes';
import type { NativeComponentType } from 'codegenNativeComponent';
type ModuleProps = $ReadOnly<{|
...ViewProps
|}>;
type NativeType = NativeComponentType<ModuleProps>;
interface NativeCommands {
+seek: (viewRef: React.ElementRef<NativeType>, position: number) => void,
+stop: (viewRef: React.ElementRef<NativeType>) => void,
}
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'Module';
export const __INTERNAL_VIEW_CONFIG = {
uiViewClassName: \\"Module\\",
validAttributes: {}
};
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);"
`;
exports[`Babel plugin inline view configs can inline config for CommandsWithSimpleCoverageNativeComponent.js 1`] = `
"// @flow
const codegenNativeCommands = require('codegenNativeCommands');
const codegenNativeComponent = require('codegenNativeComponent');
import type { ViewProps } from 'ViewPropTypes';
import type { NativeComponentType } from 'codegenNativeComponent';
type ModuleProps = $ReadOnly<{|
...ViewProps
|}>;
type NativeType = NativeComponentType<ModuleProps>;
interface NativeCommands {
+pause: (viewRef: React.ElementRef<NativeType>) => void,
+play: (viewRef: React.ElementRef<NativeType>) => void,
}
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'Module';
export const __INTERNAL_VIEW_CONFIG = {
uiViewClassName: \\"Module\\",
validAttributes: {}
};
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);"
`;
exports[`Babel plugin inline view configs can inline config for CommandsWithTypeCastCoverageNativeComponent.js 1`] = `
"// @flow
const codegenNativeCommands = require('codegenNativeCommands');
const codegenNativeComponent = require('codegenNativeComponent');
import type { ViewProps } from 'ViewPropTypes';
import type { NativeComponentType } from 'codegenNativeComponent';
type ModuleProps = $ReadOnly<{|
...ViewProps
|}>;
type NativeType = NativeComponentType<ModuleProps>;
interface NativeCommands {
+mute: (viewRef: React.ElementRef<NativeType>) => void,
+unmute: (viewRef: React.ElementRef<NativeType>) => void,
}
const NativeComponentRegistry = require('react-native/Libraries/NativeComponent/NativeComponentRegistry');
let nativeComponentName = 'Module';
export const __INTERNAL_VIEW_CONFIG = {
uiViewClassName: \\"Module\\",
validAttributes: {}
};
export default NativeComponentRegistry.get(nativeComponentName, () => __INTERNAL_VIEW_CONFIG);"
`;
exports[`Babel plugin inline view configs can inline config for FullNativeComponent.js 1`] = `
"// @flow
@@ -153,6 +225,61 @@ exports[`Babel plugin inline view configs fails on inline config for CommandsExp
24 |"
`;
exports[`Babel plugin inline view configs fails on inline config for CommandsWithComplexCoverageInvalidNativeComponent.js 1`] = `
"/CommandsWithComplexCoverageInvalidNativeComponent.js: 'Commands' is a reserved export and may only be used to export the result of codegenNativeCommands.
14 |
15 | // Complex coverage instrumentation with invalid nested structure - should fail
> 16 | export const Commands = (
| ^
17 | cov_xyz789().f[1]++,
18 | cov_xyz789().s[2]++,
19 | {"
`;
exports[`Babel plugin inline view configs fails on inline config for CommandsWithCoverageInvalidNativeComponent.js 1`] = `
"/CommandsWithCoverageInvalidNativeComponent.js: 'Commands' is a reserved export and may only be used to export the result of codegenNativeCommands.
14 |
15 | // Coverage instrumentation of invalid Commands export - should still fail
> 16 | export const Commands = (cov_1234567890().s[0]++, {
| ^
17 | hotspotUpdate: () => {},
18 | scrollTo: () => {},
19 | });"
`;
exports[`Babel plugin inline view configs fails on inline config for CommandsWithCoverageTypeCastInvalidNativeComponent.js 1`] = `
"/CommandsWithCoverageTypeCastInvalidNativeComponent.js: 'Commands' is a reserved export and may only be used to export the result of codegenNativeCommands.
19 |
20 | // Coverage instrumentation with type cast but wrong function - should fail
> 21 | export const Commands: NativeCommands = (cov_cast123().s[0]++, invalidFunction({
| ^
22 | supportedCommands: ['pause', 'play'],
23 | }));
24 |"
`;
exports[`Babel plugin inline view configs fails on inline config for CommandsWithCoverageWrongFunctionNativeComponent.js 1`] = `
"/CommandsWithCoverageWrongFunctionNativeComponent.js: 'Commands' is a reserved export and may only be used to export the result of codegenNativeCommands.
14 |
15 | // Coverage instrumentation of wrong function call - should fail
> 16 | export const Commands = (cov_abcdef123().s[0]++, someOtherFunction({
| ^
17 | supportedCommands: ['pause', 'play'],
18 | }));
19 |"
`;
exports[`Babel plugin inline view configs fails on inline config for CommandsWithCoverageWrongNameNativeComponent.js 1`] = `
"/CommandsWithCoverageWrongNameNativeComponent.js: Native commands must be exported with the name 'Commands'
20 |
21 | // Coverage instrumentation with correct function but wrong export name - should fail
> 22 | export const WrongName = (cov_wrong123().s[0]++, codegenNativeCommands<NativeCommands>({
| ^
23 | supportedCommands: ['pause', 'play'],
24 | }));
25 |"
`;
exports[`Babel plugin inline view configs fails on inline config for OtherCommandsExportNativeComponent.js 1`] = `
"/OtherCommandsExportNativeComponent.js: 'Commands' is a reserved export and may only be used to export the result of codegenNativeCommands.
17 | }
+58 -6
View File
@@ -102,6 +102,58 @@ function isCodegenDeclaration(declaration) {
return false;
}
function isCodegenNativeCommandsDeclaration(declaration) {
if (!declaration) {
return false;
}
// Handle direct calls: codegenNativeCommands()
if (
declaration.type === 'CallExpression' &&
declaration.callee &&
declaration.callee.type === 'Identifier' &&
declaration.callee.name === 'codegenNativeCommands'
) {
return true;
}
// Handle coverage instrumentation: (cov_xxx().s[0]++, codegenNativeCommands())
if (declaration.type === 'SequenceExpression' && declaration.expressions) {
// Get the last expression in the sequence (the actual function call)
const lastExpression =
declaration.expressions[declaration.expressions.length - 1];
// Recursively check if the last expression is a valid codegenNativeCommands call
return isCodegenNativeCommandsDeclaration(lastExpression);
}
// Handle Flow type casts: (codegenNativeCommands(): NativeCommands)
if (
(declaration.type === 'TypeCastExpression' ||
declaration.type === 'AsExpression') &&
declaration.expression &&
declaration.expression.type === 'CallExpression' &&
declaration.expression.callee &&
declaration.expression.callee.type === 'Identifier' &&
declaration.expression.callee.name === 'codegenNativeCommands'
) {
return true;
}
// Handle TypeScript assertions: codegenNativeCommands() as NativeCommands
if (
declaration.type === 'TSAsExpression' &&
declaration.expression &&
declaration.expression.type === 'CallExpression' &&
declaration.expression.callee &&
declaration.expression.callee.type === 'Identifier' &&
declaration.expression.callee.name === 'codegenNativeCommands'
) {
return true;
}
return false;
}
module.exports = function ({parse, types: t}) {
return {
pre(state) {
@@ -125,12 +177,12 @@ module.exports = function ({parse, types: t}) {
const firstDeclaration = path.node.declaration.declarations[0];
if (firstDeclaration.type === 'VariableDeclarator') {
if (
firstDeclaration.init &&
firstDeclaration.init.type === 'CallExpression' &&
firstDeclaration.init.callee.type === 'Identifier' &&
firstDeclaration.init.callee.name === 'codegenNativeCommands'
) {
// Check if this is a valid codegenNativeCommands call, handling type annotations
const isValidCommandsExport = isCodegenNativeCommandsDeclaration(
firstDeclaration.init,
);
if (isValidCommandsExport) {
if (
firstDeclaration.id.type === 'Identifier' &&
firstDeclaration.id.name !== 'Commands'
@@ -18,8 +18,8 @@
"bugs": "https://github.com/facebook/react-native/issues",
"main": "index.js",
"devDependencies": {
"babel-plugin-syntax-hermes-parser": "0.31.2",
"hermes-eslint": "0.31.2"
"babel-plugin-syntax-hermes-parser": "0.32.0",
"hermes-eslint": "0.32.0"
},
"engines": {
"node": ">= 20.19.4"
+2 -2
View File
@@ -32,8 +32,8 @@
"source-map-support": "0.5.0"
},
"devDependencies": {
"babel-plugin-syntax-hermes-parser": "0.31.2",
"hermes-eslint": "0.31.2"
"babel-plugin-syntax-hermes-parser": "0.32.0",
"hermes-eslint": "0.32.0"
},
"engines": {
"node": ">= 20.19.4"
+4
View File
@@ -45,3 +45,7 @@ tasks.named("ktfmtFormat") {
":shared:ktfmtFormat",
)
}
// We intentionally disable the `ktfmtCheck` tasks as the formatting is primarly handled inside
// fbsource
allprojects { tasks.withType<com.ncorti.ktfmt.gradle.tasks.KtfmtCheckTask>() { enabled = false } }
@@ -68,7 +68,8 @@ tasks.withType<KotlinCompile>().configureEach {
// See comment above on JDK 11 support
jvmTarget.set(JvmTarget.JVM_11)
allWarningsAsErrors.set(
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false)
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false
)
}
}
@@ -208,7 +208,8 @@ abstract class ReactExtension @Inject constructor(val project: Project) {
} else {
buildTypes.forEach { buildType ->
result.add(
(dependencyConfiguration ?: "${buildType}Implementation") to ":$nameCleansed")
(dependencyConfiguration ?: "${buildType}Implementation") to ":$nameCleansed"
)
}
}
}
@@ -112,7 +112,8 @@ class ReactPlugin : Plugin<Project> {
********************************************************************************
"""
.trimIndent())
.trimIndent()
)
exitProcess(1)
}
}
@@ -186,7 +187,8 @@ class ReactPlugin : Plugin<Project> {
// We want to exclude the build directory, to don't pick them up for execution
// avoidance.
tree.exclude("**/build/**/*")
})
}
)
val needsCodegenFromPackageJson = project.needsCodegenFromPackageJson(rootExtension.root)
it.onlyIf { (isLibrary || needsCodegenFromPackageJson) && !includesGeneratedCode }
@@ -303,7 +305,8 @@ class ReactPlugin : Plugin<Project> {
project.extensions.getByType(ApplicationAndroidComponentsExtension::class.java).apply {
onVariants(selector().all()) { variant ->
variant.sources.java?.addStaticSourceDirectory(
generatedAutolinkingJavaDir.get().asFile.absolutePath)
generatedAutolinkingJavaDir.get().asFile.absolutePath
)
}
}
}
@@ -59,10 +59,12 @@ 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())) {
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(
"""
********************************************************************************
@@ -77,7 +79,8 @@ class ReactRootProjectPlugin : Plugin<Project> {
********************************************************************************
"""
.trimIndent())
.trimIndent()
)
}
}
}
@@ -54,9 +54,11 @@ internal fun Project.configureReactTasks(variant: Variant, config: ReactExtensio
configureNewArchPackagingOptions(project, config, variant)
configureJsEnginePackagingOptions(config, variant, isHermesEnabledInThisVariant, useThirdPartyJSC)
if (!isHermesEnabledInThisVariant &&
!useThirdPartyJSC &&
rootProject.name != "react-native-github") {
if (
!isHermesEnabledInThisVariant &&
!useThirdPartyJSC &&
rootProject.name != "react-native-github"
) {
showJSCRemovalMessage(project)
}
@@ -39,12 +39,15 @@ abstract class PrivateReactExtension @Inject constructor(project: Project) {
// - We're inside a user project, so inside the ./android folder. Default should be
// ../
// User can always override this default by setting a `root =` inside the template.
if (project.rootProject.name == "react-native-github" ||
project.rootProject.name == "react-native-build-from-source") {
if (
project.rootProject.name == "react-native-github" ||
project.rootProject.name == "react-native-build-from-source"
) {
project.rootProject.layout.projectDirectory.dir("../../")
} else {
project.rootProject.layout.projectDirectory.dir("../")
})
}
)
val reactNativeDir: DirectoryProperty =
objects.directoryProperty().convention(root.dir("node_modules/react-native"))
@@ -165,88 +165,88 @@ abstract class GenerateAutolinkingNewArchitecturesFileTask : DefaultTask() {
// language=cmake
val CMAKE_TEMPLATE =
"""
# This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin)
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)
# We set REACTNATIVE_MERGED_SO so libraries/apps can selectively decide to depend on either libreactnative.so
# or link against a old prefab target (this is needed for React Native 0.76 on).
set(REACTNATIVE_MERGED_SO true)
{{ libraryIncludes }}
set(AUTOLINKED_LIBRARIES
{{ libraryModules }}
)
"""
# This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin)
cmake_minimum_required(VERSION 3.13)
set(CMAKE_VERBOSE_MAKEFILE on)
# We set REACTNATIVE_MERGED_SO so libraries/apps can selectively decide to depend on either libreactnative.so
# or link against a old prefab target (this is needed for React Native 0.76 on).
set(REACTNATIVE_MERGED_SO true)
{{ libraryIncludes }}
set(AUTOLINKED_LIBRARIES
{{ libraryModules }}
)
"""
.trimIndent()
// language=cpp
val CPP_TEMPLATE =
"""
/**
* This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
*/
#include "autolinking.h"
{{ autolinkingCppIncludes }}
namespace facebook {
namespace react {
std::shared_ptr<TurboModule> autolinking_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams &params) {
{{ autolinkingCppTurboModuleJavaProviders }}
return nullptr;
}
std::shared_ptr<TurboModule> autolinking_cxxModuleProvider(const std::string moduleName, const std::shared_ptr<CallInvoker>& jsInvoker) {
{{ autolinkingCppTurboModuleCxxProviders }}
return nullptr;
}
void autolinking_registerProviders(std::shared_ptr<ComponentDescriptorProviderRegistry const> providerRegistry) {
{{ autolinkingCppComponentDescriptors }}
return;
}
} // namespace react
} // namespace facebook
"""
/**
* This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
*/
#include "autolinking.h"
{{ autolinkingCppIncludes }}
namespace facebook {
namespace react {
std::shared_ptr<TurboModule> autolinking_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams &params) {
{{ autolinkingCppTurboModuleJavaProviders }}
return nullptr;
}
std::shared_ptr<TurboModule> autolinking_cxxModuleProvider(const std::string moduleName, const std::shared_ptr<CallInvoker>& jsInvoker) {
{{ autolinkingCppTurboModuleCxxProviders }}
return nullptr;
}
void autolinking_registerProviders(std::shared_ptr<ComponentDescriptorProviderRegistry const> providerRegistry) {
{{ autolinkingCppComponentDescriptors }}
return;
}
} // namespace react
} // namespace facebook
"""
.trimIndent()
// language=cpp
val hTemplate =
"""
/**
* This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
*/
#pragma once
#include <ReactCommon/CallInvoker.h>
#include <ReactCommon/JavaTurboModule.h>
#include <ReactCommon/TurboModule.h>
#include <jsi/jsi.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
namespace facebook {
namespace react {
std::shared_ptr<TurboModule> autolinking_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams &params);
std::shared_ptr<TurboModule> autolinking_cxxModuleProvider(const std::string moduleName, const std::shared_ptr<CallInvoker>& jsInvoker);
void autolinking_registerProviders(std::shared_ptr<ComponentDescriptorProviderRegistry const> providerRegistry);
} // namespace react
} // namespace facebook
"""
/**
* This code was generated by [React Native](https://www.npmjs.com/package/@react-native/gradle-plugin).
*
* Do not edit this file as changes may cause incorrect behavior and will be lost
* once the code is regenerated.
*
*/
#pragma once
#include <ReactCommon/CallInvoker.h>
#include <ReactCommon/JavaTurboModule.h>
#include <ReactCommon/TurboModule.h>
#include <jsi/jsi.h>
#include <react/renderer/componentregistry/ComponentDescriptorProviderRegistry.h>
namespace facebook {
namespace react {
std::shared_ptr<TurboModule> autolinking_ModuleProvider(const std::string moduleName, const JavaTurboModule::InitParams &params);
std::shared_ptr<TurboModule> autolinking_cxxModuleProvider(const std::string moduleName, const std::shared_ptr<CallInvoker>& jsInvoker);
void autolinking_registerProviders(std::shared_ptr<ComponentDescriptorProviderRegistry const> providerRegistry);
} // namespace react
} // namespace facebook
"""
.trimIndent()
}
}
@@ -82,6 +82,7 @@ abstract class GenerateCodegenArtifactsTask : Exec() {
libraryName,
"--javaPackageName",
codegenJavaPackageName,
))
)
)
}
}
@@ -69,6 +69,7 @@ abstract class GenerateCodegenSchemaTask : Exec() {
"NativeSampleTurboModule",
generatedSchemaFile.get().asFile.cliPath(workingDir),
jsRootDir.asFile.get().cliPath(workingDir),
))
)
)
}
}
@@ -32,17 +32,19 @@ abstract class GenerateEntryPointTask : DefaultTask() {
JsonUtils.fromAutolinkingConfigJson(autolinkInputFile.get().asFile)
?: error(
"""
RNGP - Autolinking: Could not parse autolinking config file:
${autolinkInputFile.get().asFile.absolutePath}
The file is either missing or not containing valid JSON so the build won't succeed.
"""
.trimIndent())
RNGP - Autolinking: Could not parse autolinking config file:
${autolinkInputFile.get().asFile.absolutePath}
The file is either missing or not containing valid JSON so the build won't succeed.
"""
.trimIndent()
)
val packageName =
model.project?.android?.packageName
?: error(
"RNGP - Autolinking: Could not find project.android.packageName in react-native config output! Could not autolink packages without this field.")
"RNGP - Autolinking: Could not find project.android.packageName in react-native config output! Could not autolink packages without this field."
)
val generatedFileContents = composeFileContent(packageName)
val outputDir = generatedOutputDirectory.get().asFile
@@ -62,45 +64,45 @@ abstract class GenerateEntryPointTask : DefaultTask() {
// language=java
val generatedFileContentsTemplate =
"""
package com.facebook.react;
import android.app.Application;
import android.content.Context;
import android.content.res.Resources;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger;
import com.facebook.react.views.view.WindowUtilKt;
import com.facebook.react.soloader.OpenSourceMergedSoMapping;
import com.facebook.soloader.SoLoader;
import java.io.IOException;
/**
* This class is the entry point for loading React Native using the configuration
* that the users specifies in their .gradle files.
*
* The `loadReactNative(this)` method invocation should be called inside the
* application onCreate otherwise the app won't load correctly.
*/
public class ReactNativeApplicationEntryPoint {
public static void loadReactNative(Context context) {
try {
SoLoader.init(context, OpenSourceMergedSoMapping.INSTANCE);
} catch (IOException error) {
throw new RuntimeException(error);
}
if ({{packageName}}.BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
DefaultNewArchitectureEntryPoint.load();
}
if ({{packageName}}.BuildConfig.IS_EDGE_TO_EDGE_ENABLED) {
WindowUtilKt.setEdgeToEdgeFeatureFlagOn();
package com.facebook.react;
import android.app.Application;
import android.content.Context;
import android.content.res.Resources;
import com.facebook.react.defaults.DefaultNewArchitectureEntryPoint;
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger;
import com.facebook.react.views.view.WindowUtilKt;
import com.facebook.react.soloader.OpenSourceMergedSoMapping;
import com.facebook.soloader.SoLoader;
import java.io.IOException;
/**
* This class is the entry point for loading React Native using the configuration
* that the users specifies in their .gradle files.
*
* The `loadReactNative(this)` method invocation should be called inside the
* application onCreate otherwise the app won't load correctly.
*/
public class ReactNativeApplicationEntryPoint {
public static void loadReactNative(Context context) {
try {
SoLoader.init(context, OpenSourceMergedSoMapping.INSTANCE);
} catch (IOException error) {
throw new RuntimeException(error);
}
if ({{packageName}}.BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
DefaultNewArchitectureEntryPoint.load();
}
if ({{packageName}}.BuildConfig.IS_EDGE_TO_EDGE_ENABLED) {
WindowUtilKt.setEdgeToEdgeFeatureFlagOn();
}
}
}
}
"""
"""
.trimIndent()
}
}
@@ -34,17 +34,19 @@ abstract class GeneratePackageListTask : DefaultTask() {
JsonUtils.fromAutolinkingConfigJson(autolinkInputFile.get().asFile)
?: error(
"""
RNGP - Autolinking: Could not parse autolinking config file:
${autolinkInputFile.get().asFile.absolutePath}
The file is either missing or not containing valid JSON so the build won't succeed.
"""
.trimIndent())
RNGP - Autolinking: Could not parse autolinking config file:
${autolinkInputFile.get().asFile.absolutePath}
The file is either missing or not containing valid JSON so the build won't succeed.
"""
.trimIndent()
)
val packageName =
model.project?.android?.packageName
?: error(
"RNGP - Autolinking: Could not find project.android.packageName in react-native config output! Could not autolink packages without this field.")
"RNGP - Autolinking: Could not find project.android.packageName in react-native config output! Could not autolink packages without this field."
)
val androidPackages = filterAndroidPackages(model)
val packageImports = composePackageImports(packageName, androidPackages)
@@ -134,69 +136,69 @@ abstract class GeneratePackageListTask : DefaultTask() {
// language=java
val generatedFileContentsTemplate =
"""
package com.facebook.react;
import android.app.Application;
import android.content.Context;
import android.content.res.Resources;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainPackageConfig;
import com.facebook.react.shell.MainReactPackage;
import java.util.Arrays;
import java.util.ArrayList;
{{ packageImports }}
@SuppressWarnings("deprecation")
public class PackageList {
private Application application;
private ReactNativeHost reactNativeHost;
private MainPackageConfig mConfig;
public PackageList(ReactNativeHost reactNativeHost) {
this(reactNativeHost, null);
}
public PackageList(Application application) {
this(application, null);
}
public PackageList(ReactNativeHost reactNativeHost, MainPackageConfig config) {
this.reactNativeHost = reactNativeHost;
mConfig = config;
}
public PackageList(Application application, MainPackageConfig config) {
this.reactNativeHost = null;
this.application = application;
mConfig = config;
}
private ReactNativeHost getReactNativeHost() {
return this.reactNativeHost;
}
private Resources getResources() {
return this.getApplication().getResources();
}
private Application getApplication() {
if (this.reactNativeHost == null) return this.application;
return this.reactNativeHost.getApplication();
}
private Context getApplicationContext() {
return this.getApplication().getApplicationContext();
}
public ArrayList<ReactPackage> getPackages() {
return new ArrayList<>(Arrays.<ReactPackage>asList(
new MainReactPackage(mConfig){{ packageClassInstances }}
));
}
}
"""
package com.facebook.react;
import android.app.Application;
import android.content.Context;
import android.content.res.Resources;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainPackageConfig;
import com.facebook.react.shell.MainReactPackage;
import java.util.Arrays;
import java.util.ArrayList;
{{ packageImports }}
@SuppressWarnings("deprecation")
public class PackageList {
private Application application;
private ReactNativeHost reactNativeHost;
private MainPackageConfig mConfig;
public PackageList(ReactNativeHost reactNativeHost) {
this(reactNativeHost, null);
}
public PackageList(Application application) {
this(application, null);
}
public PackageList(ReactNativeHost reactNativeHost, MainPackageConfig config) {
this.reactNativeHost = reactNativeHost;
mConfig = config;
}
public PackageList(Application application, MainPackageConfig config) {
this.reactNativeHost = null;
this.application = application;
mConfig = config;
}
private ReactNativeHost getReactNativeHost() {
return this.reactNativeHost;
}
private Resources getResources() {
return this.getApplication().getResources();
}
private Application getApplication() {
if (this.reactNativeHost == null) return this.application;
return this.reactNativeHost.getApplication();
}
private Context getApplicationContext() {
return this.getApplication().getApplicationContext();
}
public ArrayList<ReactPackage> getPackages() {
return new ArrayList<>(Arrays.<ReactPackage>asList(
new MainReactPackage(mConfig){{ packageClassInstances }}
));
}
}
"""
.trimIndent()
}
}
@@ -54,7 +54,8 @@ abstract class BuildCodegenCLITask : Exec() {
windowsAwareBashCommandLine(
codegenDir.asFile.get().canonicalPath.unixifyPath().plus(BUILD_SCRIPT_PATH),
bashWindowsHome = bashWindowsHome.orNull,
))
)
)
super.exec()
}
@@ -29,8 +29,10 @@ abstract class CustomExecTask : Exec() {
@get:Input @get:Optional abstract val onlyIfProvidedPathDoesNotExists: Property<String>
override fun exec() {
if (onlyIfProvidedPathDoesNotExists.isPresent &&
File(onlyIfProvidedPathDoesNotExists.get()).exists()) {
if (
onlyIfProvidedPathDoesNotExists.isPresent &&
File(onlyIfProvidedPathDoesNotExists.get()).exists()
) {
return
}
if (standardOutputFile.isPresent) {
@@ -64,7 +64,8 @@ abstract class PrepareGflagsTask : DefaultTask() {
.replace(Regex("@GFLAGS_NAMESPACE@"), "gflags")
.replace(
Regex(
"@(HAVE_STDINT_H|HAVE_SYS_TYPES_H|HAVE_INTTYPES_H|GFLAGS_INTTYPES_FORMAT_C99)@"),
"@(HAVE_STDINT_H|HAVE_SYS_TYPES_H|HAVE_INTTYPES_H|GFLAGS_INTTYPES_FORMAT_C99)@"
),
"1",
)
.replace(Regex("@([A-Z0-9_]+)@"), "1")
@@ -61,7 +61,8 @@ abstract class PrepareGlogTask : DefaultTask() {
"ac_cv___attribute___noreturn" to "__attribute__ ((noreturn))",
"ac_cv___attribute___printf_4_5" to
"__attribute__((__format__ (__printf__, 4, 5)))",
)),
)
),
ReplaceTokens::class.java,
)
matchedFile.path = (matchedFile.name.removeSuffix(".in"))
@@ -39,7 +39,8 @@ internal object BackwardCompatUtils {
********************************************************************************
"""
.trimIndent())
.trimIndent()
)
}
}
@@ -55,14 +56,14 @@ internal object BackwardCompatUtils {
val message =
"""
=============== JavaScriptCore is being moved ===============
JavaScriptCore has been extracted from react-native core
and will be removed in a future release. It can now be
installed from `@react-native-community/javascriptcore`
See: https://github.com/react-native-community/javascriptcore
=============================================================
=============== JavaScriptCore is being moved ===============
JavaScriptCore has been extracted from react-native core
and will be removed in a future release. It can now be
installed from `@react-native-community/javascriptcore`
See: https://github.com/react-native-community/javascriptcore
=============================================================
"""
"""
.trimIndent()
project.logger.warn(message)
hasShownJSCRemovalMessage = true
@@ -33,7 +33,8 @@ internal object DependencyUtils {
val exclusiveEnterpriseRepository = project.rootProject.exclusiveEnterpriseRepository()
if (exclusiveEnterpriseRepository != null) {
project.logger.lifecycle(
"Replacing ALL Maven Repositories with: $exclusiveEnterpriseRepository")
"Replacing ALL Maven Repositories with: $exclusiveEnterpriseRepository"
)
}
project.rootProject.allprojects { eachProject ->
@@ -135,26 +136,30 @@ internal object DependencyUtils {
"com.facebook.react:react-native",
"${groupString}:react-android:${versionString}",
"The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210.",
))
)
)
dependencySubstitution.add(
Triple(
"com.facebook.react:hermes-engine",
"${groupString}:hermes-android:${versionString}",
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.",
))
)
)
if (groupString != DEFAULT_INTERNAL_PUBLISHING_GROUP) {
dependencySubstitution.add(
Triple(
"com.facebook.react:react-android",
"${groupString}:react-android:${versionString}",
"The react-android dependency was modified to use the correct Maven group.",
))
)
)
dependencySubstitution.add(
Triple(
"com.facebook.react:hermes-android",
"${groupString}:hermes-android:${versionString}",
"The hermes-android dependency was modified to use the correct Maven group.",
))
)
)
}
return dependencySubstitution
}
@@ -45,7 +45,8 @@ internal object NdkConfiguratorUtils {
}
if (cmakeArgs.none { it.startsWith("-DREACT_ANDROID_DIR") }) {
cmakeArgs.add(
"-DREACT_ANDROID_DIR=${extension.reactNativeDir.file("ReactAndroid").get().asFile}")
"-DREACT_ANDROID_DIR=${extension.reactNativeDir.file("ReactAndroid").get().asFile}"
)
}
if (cmakeArgs.none { it.startsWith("-DANDROID_STL") }) {
cmakeArgs.add("-DANDROID_STL=c++_shared")
@@ -86,7 +87,8 @@ internal object NdkConfiguratorUtils {
"**/libjsi.so",
// AGP will give priority of libc++_shared coming from App modules.
"**/libc++_shared.so",
))
)
)
}
/**
@@ -118,17 +120,17 @@ internal object NdkConfiguratorUtils {
hermesEnabled -> {
excludes.add("**/libjsc.so")
excludes.add("**/libjsctooling.so")
includes.add("**/libhermes.so")
includes.add("**/libhermesvm.so")
includes.add("**/libhermestooling.so")
}
useThirdPartyJSC -> {
excludes.add("**/libhermes.so")
excludes.add("**/libhermesvm.so")
excludes.add("**/libhermestooling.so")
excludes.add("**/libjsctooling.so")
includes.add("**/libjsc.so")
}
else -> {
excludes.add("**/libhermes.so")
excludes.add("**/libhermesvm.so")
excludes.add("**/libhermestooling.so")
includes.add("**/libjsc.so")
includes.add("**/libjsctooling.so")
@@ -105,13 +105,14 @@ private fun detectCliFile(reactNativeRoot: File, preconfiguredCliFile: File?): F
error(
"""
Couldn't determine CLI location!
Couldn't determine CLI location!
Please set `react { cliFile = file(...) }` inside your
build.gradle to the path of the react-native cli.js file.
This file typically resides in `node_modules/react-native/cli.js`
"""
.trimIndent())
Please set `react { cliFile = file(...) }` inside your
build.gradle to the path of the react-native cli.js file.
This file typically resides in `node_modules/react-native/cli.js`
"""
.trimIndent()
)
}
/**
@@ -160,7 +161,8 @@ internal fun detectOSAwareHermesCommand(projectRoot: File, hermesCommand: String
error(
"Couldn't determine Hermesc location. " +
"Please set `react.hermesCommand` to the path of the hermesc binary file. " +
"node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc")
"node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc"
)
}
/**
@@ -186,7 +188,8 @@ internal fun getHermesOSBin(): String {
if (Os.isLinuxAmd64()) return "linux64-bin"
error(
"OS not recognized. Please set project.react.hermesCommand " +
"to the path of a working Hermes compiler.")
"to the path of a working Hermes compiler."
)
}
internal fun projectPathToLibraryName(projectPath: String): String =
@@ -23,11 +23,12 @@ class ReactExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0"
}
"""
.trimIndent())
{
"reactNativeVersion": "1000.0.0"
}
"""
.trimIndent()
)
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps).isEmpty()
@@ -38,23 +39,24 @@ class ReactExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react"
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react"
}
}
}
}
}
}
}
}
"""
.trimIndent())
"""
.trimIndent()
)
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps).containsExactly("implementation" to ":react-native_oss-library-example")
@@ -65,24 +67,25 @@ class ReactExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react",
"dependencyConfiguration": "compileOnly"
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react",
"dependencyConfiguration": "compileOnly"
}
}
}
}
}
}
}
}
"""
.trimIndent())
"""
.trimIndent()
)
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps).containsExactly("compileOnly" to ":react-native_oss-library-example")
@@ -93,24 +96,25 @@ class ReactExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react",
"buildTypes": ["debug", "release"]
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react",
"buildTypes": ["debug", "release"]
}
}
}
}
}
}
}
}
"""
.trimIndent())
"""
.trimIndent()
)
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps)
@@ -125,33 +129,34 @@ class ReactExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react"
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react"
}
}
},
"@react-native/another-library-for-testing": {
"root": "./node_modules/@react-native/another-library-for-testing",
"name": "@react-native/another-library-for-testing",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react"
}
}
}
}
}
},
"@react-native/another-library-for-testing": {
"root": "./node_modules/@react-native/another-library-for-testing",
"name": "@react-native/another-library-for-testing",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react"
}
}
}
}
}
"""
.trimIndent())
"""
.trimIndent()
)
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps)
@@ -166,26 +171,27 @@ class ReactExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/oss-library-example.podspec",
"version": "0.0.0",
"configurations": [],
"scriptPhases": []
},
"android": null
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/oss-library-example.podspec",
"version": "0.0.0",
"configurations": [],
"scriptPhases": []
},
"android": null
}
}
}
}
}
}
}
"""
.trimIndent())
"""
.trimIndent()
)
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps).isEmpty()
@@ -196,34 +202,35 @@ class ReactExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/android-example",
"name": "@react-native/android-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react"
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/android-example",
"name": "@react-native/android-example",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react"
}
}
},
"@react-native/another-library-for-testing": {
"root": "./node_modules/@react-native/cxx-testing",
"name": "@react-native/cxx-testing",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react",
"isPureCxxDependency": true
}
}
}
}
}
},
"@react-native/another-library-for-testing": {
"root": "./node_modules/@react-native/cxx-testing",
"name": "@react-native/cxx-testing",
"platforms": {
"android": {
"sourceDir": "src/main/java",
"packageImportPath": "com.facebook.react",
"isPureCxxDependency": true
}
}
}
}
}
"""
.trimIndent())
"""
.trimIndent()
)
val deps = getGradleDependenciesToApply(validJsonFile)
assertThat(deps).containsExactly("implementation" to ":react-native_android-example")
@@ -41,7 +41,8 @@ class ModelAutolinkingDependenciesJsonTest {
"@this*is~a(more)complicated/example!of~weird)packages",
null,
)
.nameCleansed)
.nameCleansed
)
.isEqualTo("this_is_a_more_complicated_example_of_weird_packages")
}
}
@@ -72,9 +72,11 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
name = "a-dependency",
platforms =
ModelAutolinkingDependenciesPlatformJson(android = null),
)),
)
),
project = null,
))
)
)
assertThat(result).isEmpty()
}
@@ -101,9 +103,11 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
name = "a-dependency",
platforms =
ModelAutolinkingDependenciesPlatformJson(android = android),
)),
)
),
project = null,
))
)
)
assertThat(result).containsExactly(android)
}
@@ -130,7 +134,8 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
)
"""
.trimIndent())
.trimIndent()
)
}
@Test
@@ -160,7 +165,8 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
another_cxxModule
)
"""
.trimIndent())
.trimIndent()
)
}
@Test
@@ -204,7 +210,8 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
} // namespace react
} // namespace facebook
"""
.trimIndent())
.trimIndent()
)
}
@Test
@@ -260,7 +267,8 @@ class GenerateAutolinkingNewArchitecturesFileTaskTest {
} // namespace react
} // namespace facebook
"""
.trimIndent())
.trimIndent()
)
}
@Test
@@ -148,7 +148,8 @@ class GenerateCodegenArtifactsTaskTest {
}
}
"""
.trimIndent())
.trimIndent()
)
}
val task =
@@ -177,7 +178,8 @@ class GenerateCodegenArtifactsTaskTest {
}
}
"""
.trimIndent())
.trimIndent()
)
}
val task =
@@ -86,6 +86,7 @@ class GenerateEntryPointTaskTest {
}
}
"""
.trimIndent())
.trimIndent()
)
}
}
@@ -64,7 +64,8 @@ class GeneratePackageListTaskTest {
// @react-native/another-package
import com.facebook.react.anotherPackage;
"""
.trimIndent())
.trimIndent()
)
}
@Test
@@ -88,7 +89,8 @@ class GeneratePackageListTaskTest {
new APackage(),
new AnotherPackage()
"""
.trimIndent())
.trimIndent()
)
}
@Test
@@ -147,9 +149,11 @@ class GeneratePackageListTaskTest {
name = "a-dependency",
platforms =
ModelAutolinkingDependenciesPlatformJson(android = null),
)),
)
),
project = null,
))
)
)
assertThat(result)
.isEqualTo(emptyMap<String, ModelAutolinkingDependenciesPlatformAndroidJson>())
}
@@ -177,9 +181,11 @@ class GeneratePackageListTaskTest {
name = "a-dependency",
platforms =
ModelAutolinkingDependenciesPlatformJson(android = android),
)),
)
),
project = null,
))
)
)
assertThat(result.entries.size).isEqualTo(1)
assertThat(result["a-dependency"]).isEqualTo(android)
}
@@ -208,9 +214,11 @@ class GeneratePackageListTaskTest {
name = "a-pure-cxx-dependency",
platforms =
ModelAutolinkingDependenciesPlatformJson(android = android),
)),
)
),
project = null,
))
)
)
assertThat(result)
.isEqualTo(emptyMap<String, ModelAutolinkingDependenciesPlatformAndroidJson>())
}
@@ -289,7 +297,8 @@ class GeneratePackageListTaskTest {
}
}
"""
.trimIndent())
.trimIndent()
)
}
@Test
@@ -371,7 +380,8 @@ class GeneratePackageListTaskTest {
}
}
"""
.trimIndent())
.trimIndent()
)
}
private val testDependencies =
@@ -26,7 +26,8 @@ class PrepareBoostTaskTest {
assertThatThrownBy { task.taskAction() }
.isInstanceOf(IllegalStateException::class.java)
.hasMessage(
"Cannot query the value of task ':PrepareBoostTask' property 'boostVersion' because it has no value available.")
"Cannot query the value of task ':PrepareBoostTask' property 'boostVersion' because it has no value available."
)
}
@Test
@@ -125,7 +125,8 @@ typedef unsigned __int64 uint64;
#endif
} // namespace GFLAGS_NAMESPACE
""")
"""
)
}
File(gflagspath, "gflags-1.0.0/src/config.h.in").apply {
parentFile.mkdirs()
@@ -55,7 +55,8 @@ class PreparePrefabHeadersTaskTest {
createTestTask<PreparePrefabHeadersTask>(project = project) {
it.outputDir.set(outputDir)
it.input.set(
listOf(PrefabPreprocessingEntry("sample_library", "input/" to expectedPrefix)))
listOf(PrefabPreprocessingEntry("sample_library", "input/" to expectedPrefix))
)
}
task.taskAction()
@@ -76,7 +77,8 @@ class PreparePrefabHeadersTaskTest {
createTestTask<PreparePrefabHeadersTask>(project = project) {
it.outputDir.set(outputDir)
it.input.set(
listOf(PrefabPreprocessingEntry("sample_library", "input/" to expectedPrefix)))
listOf(PrefabPreprocessingEntry("sample_library", "input/" to expectedPrefix))
)
}
task.taskAction()
@@ -102,7 +104,8 @@ class PreparePrefabHeadersTaskTest {
"sample_library",
listOf("input/component1/" to "", "input/component2/" to ""),
),
))
)
)
}
task.taskAction()
@@ -125,7 +128,8 @@ class PreparePrefabHeadersTaskTest {
listOf(
PrefabPreprocessingEntry("libraryone", "input/lib1/" to ""),
PrefabPreprocessingEntry("librarytwo", "input/lib2/" to ""),
))
)
)
}
task.taskAction()
@@ -155,7 +159,8 @@ class PreparePrefabHeadersTaskTest {
"librarytwo",
listOf("input/lib2/" to "", "input/shared/" to "shared/"),
),
))
)
)
}
task.taskAction()
@@ -181,9 +186,9 @@ class PreparePrefabHeadersTaskTest {
val project = createProject(projectDir = tempFolder.root)
val task =
createTestTask<PreparePrefabHeadersTask>(project = project) {
it.outputDir.set(outputDir)
it.input.set(listOf(PrefabPreprocessingEntry("sample_library", "boost/" to "")))
createTestTask<PreparePrefabHeadersTask>(project = project) { task ->
task.outputDir.set(outputDir)
task.input.set(listOf(PrefabPreprocessingEntry("sample_library", "boost/" to "")))
}
task.taskAction()
@@ -37,7 +37,8 @@ class AgpConfiguratorUtilsTest {
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
"""
.trimIndent())
.trimIndent()
)
}
val actual = getPackageNameFromManifest(manifest)
@@ -55,7 +56,8 @@ class AgpConfiguratorUtilsTest {
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.facebook.react" >
</manifest>
"""
.trimIndent())
.trimIndent()
)
}
val actual = getPackageNameFromManifest(manifest)
@@ -40,7 +40,8 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == localMavenURI
})
}
)
.isNotNull()
}
@@ -54,7 +55,8 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
})
}
)
.isNotNull()
}
@@ -68,7 +70,8 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
})
}
)
.isNotNull()
}
@@ -82,7 +85,8 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
})
}
)
.isNotNull()
}
@@ -96,7 +100,8 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
})
}
)
.isNotNull()
}
@@ -116,7 +121,8 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
})
}
)
.isNotNull()
}
@@ -131,7 +137,8 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
})
}
)
.isNull()
// We test both with scoped and unscoped property
@@ -143,7 +150,8 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
})
}
)
.isNull()
}
@@ -158,7 +166,8 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
})
}
)
.isNotNull()
// We test both with scoped and unscoped property
@@ -170,7 +179,8 @@ class DependencyUtilsTest {
assertThat(
project.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
})
}
)
.isNotNull()
}
@@ -226,12 +236,14 @@ class DependencyUtilsTest {
assertThat(
appProject.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
})
}
)
.isNotNull()
assertThat(
libProject.repositories.firstOrNull {
it is MavenArtifactRepository && it.url == repositoryURI
})
}
)
.isNotNull()
}
@@ -254,7 +266,8 @@ class DependencyUtilsTest {
assertThat(
libProject.repositories.count {
it is MavenArtifactRepository && it.url == repositoryURI
})
}
)
.isEqualTo(2)
}
@@ -332,13 +345,15 @@ class DependencyUtilsTest {
assertThat("com.facebook.react:react-android:0.42.0")
.isEqualTo(dependencySubstitutions[0].second)
assertThat(
"The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210.")
"The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210."
)
.isEqualTo(dependencySubstitutions[0].third)
assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first)
assertThat("com.facebook.react:hermes-android:0.42.0")
.isEqualTo(dependencySubstitutions[1].second)
assertThat(
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.")
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210."
)
.isEqualTo(dependencySubstitutions[1].third)
}
@@ -349,12 +364,14 @@ class DependencyUtilsTest {
assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first)
assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[0].second)
assertThat(
"The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210.")
"The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210."
)
.isEqualTo(dependencySubstitutions[0].third)
assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first)
assertThat("io.github.test:hermes-android:0.42.0").isEqualTo(dependencySubstitutions[1].second)
assertThat(
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.")
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210."
)
.isEqualTo(dependencySubstitutions[1].third)
assertThat("com.facebook.react:react-android").isEqualTo(dependencySubstitutions[2].first)
assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[2].second)
@@ -375,7 +392,8 @@ class DependencyUtilsTest {
VERSION_NAME=1000.0.0
ANOTHER_PROPERTY=true
"""
.trimIndent())
.trimIndent()
)
}
val versionString = readVersionAndGroupStrings(propertiesFile).first
@@ -392,7 +410,8 @@ class DependencyUtilsTest {
VERSION_NAME=0.0.0-20221101-2019-cfe811ab1
ANOTHER_PROPERTY=true
"""
.trimIndent())
.trimIndent()
)
}
val versionString = readVersionAndGroupStrings(propertiesFile).first
@@ -408,7 +427,8 @@ class DependencyUtilsTest {
"""
ANOTHER_PROPERTY=true
"""
.trimIndent())
.trimIndent()
)
}
val versionString = readVersionAndGroupStrings(propertiesFile).first
@@ -424,7 +444,8 @@ class DependencyUtilsTest {
VERSION_NAME=
ANOTHER_PROPERTY=true
"""
.trimIndent())
.trimIndent()
)
}
val versionString = readVersionAndGroupStrings(propertiesFile).first
@@ -440,7 +461,8 @@ class DependencyUtilsTest {
react.internal.publishingGroup=io.github.test
ANOTHER_PROPERTY=true
"""
.trimIndent())
.trimIndent()
)
}
val groupString = readVersionAndGroupStrings(propertiesFile).second
@@ -456,7 +478,8 @@ class DependencyUtilsTest {
"""
ANOTHER_PROPERTY=true
"""
.trimIndent())
.trimIndent()
)
}
val groupString = readVersionAndGroupStrings(propertiesFile).second
@@ -24,8 +24,8 @@ class NdkConfiguratorUtilsTest {
assertThat(excludes).containsExactly("**/libjsc.so", "**/libjsctooling.so")
assertThat(includes).doesNotContain("**/libjsc.so", "**/libjsctooling.so")
assertThat(includes).containsExactly("**/libhermes.so", "**/libhermestooling.so")
assertThat(excludes).doesNotContain("**/libhermes.so", "**/libhermestooling.so")
assertThat(includes).containsExactly("**/libhermesvm.so", "**/libhermestooling.so")
assertThat(excludes).doesNotContain("**/libhermesvm.so", "**/libhermestooling.so")
}
@Test
@@ -39,8 +39,8 @@ class NdkConfiguratorUtilsTest {
assertThat(excludes).containsExactly("**/libjsc.so", "**/libjsctooling.so")
assertThat(includes).doesNotContain("**/libjsc.so", "**/libjsctooling.so")
assertThat(includes).containsExactly("**/libhermes.so", "**/libhermestooling.so")
assertThat(excludes).doesNotContain("**/libhermes.so", "**/libhermestooling.so")
assertThat(includes).containsExactly("**/libhermesvm.so", "**/libhermestooling.so")
assertThat(excludes).doesNotContain("**/libhermesvm.so", "**/libhermestooling.so")
}
@Test
@@ -51,8 +51,8 @@ class NdkConfiguratorUtilsTest {
useThirdPartyJSC = false,
)
assertThat(excludes).containsExactly("**/libhermes.so", "**/libhermestooling.so")
assertThat(includes).doesNotContain("**/libhermes.so", "**/libhermestooling.so")
assertThat(excludes).containsExactly("**/libhermesvm.so", "**/libhermestooling.so")
assertThat(includes).doesNotContain("**/libhermesvm.so", "**/libhermestooling.so")
assertThat(includes).containsExactly("**/libjsc.so", "**/libjsctooling.so")
assertThat(excludes).doesNotContain("**/libjsc.so", "**/libjsctooling.so")
@@ -68,6 +68,6 @@ class NdkConfiguratorUtilsTest {
assertThat(includes).containsExactly("**/libjsc.so")
assertThat(excludes)
.containsExactly("**/libhermes.so", "**/libhermestooling.so", "**/libjsctooling.so")
.containsExactly("**/libhermesvm.so", "**/libhermestooling.so", "**/libjsctooling.so")
}
}
@@ -147,7 +147,8 @@ class PathUtilsTest {
tempFolder.newFolder("node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/")
val expected =
tempFolder.newFile(
"node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc")
"node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc"
)
assertThat(detectOSAwareHermesCommand(tempFolder.root, "")).isEqualTo(expected.toString())
}
@@ -189,7 +190,8 @@ class PathUtilsTest {
tempFolder.newFolder("node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/")
val expected =
tempFolder.newFile(
"node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc")
"node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc"
)
tempFolder.newFolder("node_modules/react-native/sdks/hermesc/osx-bin/")
tempFolder.newFile("node_modules/react-native/sdks/hermesc/osx-bin/hermesc")
@@ -203,7 +205,8 @@ class PathUtilsTest {
File(
tempFolder.root,
"node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc",
))
)
)
}
@Test
@@ -214,7 +217,8 @@ class PathUtilsTest {
File(
tempFolder.root,
"node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/hermesc.exe",
))
)
)
}
@Test
@@ -311,7 +315,8 @@ class PathUtilsTest {
"codegenConfig": {}
}
"""
.trimIndent())
.trimIndent()
)
}
val project = ProjectBuilder.builder().withProjectDir(moduleFolder).build()
project.plugins.apply("com.android.library")
@@ -128,7 +128,8 @@ class ProjectUtilsTest {
"codegenConfig": {}
}
"""
.trimIndent())
.trimIndent()
)
}
extension.root.set(tempFolder.root)
assertThat(project.needsCodegenFromPackageJson(extension.root)).isTrue()
@@ -146,7 +147,8 @@ class ProjectUtilsTest {
"name": "a-library"
}
"""
.trimIndent())
.trimIndent()
)
}
extension.root.set(tempFolder.root)
assertThat(project.needsCodegenFromPackageJson(extension.root)).isFalse()
@@ -58,7 +58,8 @@ tasks.withType<KotlinCompile>().configureEach {
// See comment above on JDK 11 support
jvmTarget.set(JvmTarget.JVM_11)
allWarningsAsErrors.set(
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false)
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false
)
}
}
@@ -158,9 +158,8 @@ abstract class ReactSettingsExtension @Inject constructor(val settings: Settings
logger.error(message)
if (cacheJsonConfig.length() != 0L) {
logger.error(
cacheJsonConfig
.readText()
.substring(0, min(1024, cacheJsonConfig.length().toInt())))
cacheJsonConfig.readText().substring(0, min(1024, cacheJsonConfig.length().toInt()))
)
}
cacheJsonConfig.delete()
throw GradleException(message)
@@ -29,11 +29,12 @@ class ReactSettingsExtensionTest {
val validFile =
createJsonFile(
"""
{
"value": "¯\\_(ツ)_/¯"
}
"""
.trimIndent())
{
"value": "¯\\_(ツ)_/¯"
}
"""
.trimIndent()
)
assertThat(computeSha256(validFile))
.isEqualTo("838aa9a72a16fdd55b0d49b510a82e264a30f59333b5fdd97c7798a29146f6a8")
}
@@ -43,11 +44,12 @@ class ReactSettingsExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0"
}
"""
.trimIndent())
{
"reactNativeVersion": "1000.0.0"
}
"""
.trimIndent()
)
val map = getLibrariesToAutolink(validJsonFile)
assertThat(map.keys).isEmpty()
@@ -58,41 +60,42 @@ class ReactSettingsExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
"version": "0.0.1",
"configurations": [],
"scriptPhases": []
},
"android": {
"sourceDir": "./node_modules/@react-native/oss-library-example/android",
"packageImportPath": "import com.facebook.react.osslibraryexample.OSSLibraryExamplePackage;",
"packageInstance": "new OSSLibraryExamplePackage()",
"buildTypes": ["staging", "debug", "release"],
"libraryName": "OSSLibraryExampleSpec",
"componentDescriptors": [
"SampleNativeComponentComponentDescriptor"
],
"cmakeListsPath": "./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt",
"cxxModuleCMakeListsModuleName": null,
"cxxModuleCMakeListsPath": null,
"cxxModuleHeaderName": null,
"dependencyConfiguration": "implementation",
"isPureCxxDependency": false
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
"version": "0.0.1",
"configurations": [],
"scriptPhases": []
},
"android": {
"sourceDir": "./node_modules/@react-native/oss-library-example/android",
"packageImportPath": "import com.facebook.react.osslibraryexample.OSSLibraryExamplePackage;",
"packageInstance": "new OSSLibraryExamplePackage()",
"buildTypes": ["staging", "debug", "release"],
"libraryName": "OSSLibraryExampleSpec",
"componentDescriptors": [
"SampleNativeComponentComponentDescriptor"
],
"cmakeListsPath": "./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt",
"cxxModuleCMakeListsModuleName": null,
"cxxModuleCMakeListsPath": null,
"cxxModuleHeaderName": null,
"dependencyConfiguration": "implementation",
"isPureCxxDependency": false
}
}
}
}
}
}
}
}
"""
.trimIndent())
"""
.trimIndent()
)
val map = getLibrariesToAutolink(validJsonFile)
assertThat(map.keys).containsExactly(":react-native_oss-library-example")
@@ -105,25 +108,26 @@ class ReactSettingsExtensionTest {
val validJsonFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
"version": "0.0.1",
"configurations": [],
"scriptPhases": []
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
"version": "0.0.1",
"configurations": [],
"scriptPhases": []
}
}
}
}
}
}
}
}
"""
.trimIndent())
"""
.trimIndent()
)
val map = getLibrariesToAutolink(validJsonFile)
assertThat(map.keys).isEmpty()
@@ -258,7 +262,8 @@ class ReactSettingsExtensionTest {
}
}
"""
.trimIndent())
.trimIndent()
)
}
tempFolder.newFile("yarn.lock").apply { writeText("I'm a lockfile") }
val lockfileCollection = project.files("yarn.lock")
@@ -311,7 +316,8 @@ class ReactSettingsExtensionTest {
}
}
"""
.trimIndent())
.trimIndent()
)
}
tempFolder.newFile("yarn.lock").apply { writeText("I'm a lockfile") }
val lockfileCollection = project.files("yarn.lock")
@@ -356,9 +362,10 @@ class ReactSettingsExtensionTest {
val invalidConfigFile =
createJsonFile(
"""
{}
"""
.trimIndent())
{}
"""
.trimIndent()
)
assertThat(ReactSettingsExtension.isCacheDirty(invalidConfigFile, buildFolder, lockfiles))
.isTrue()
@@ -377,11 +384,12 @@ class ReactSettingsExtensionTest {
val invalidConfigFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0"
}
"""
.trimIndent())
{
"reactNativeVersion": "1000.0.0"
}
"""
.trimIndent()
)
assertThat(ReactSettingsExtension.isCacheDirty(invalidConfigFile, buildFolder, lockfiles))
.isTrue()
@@ -400,12 +408,13 @@ class ReactSettingsExtensionTest {
val invalidConfigFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {}
}
"""
.trimIndent())
{
"reactNativeVersion": "1000.0.0",
"dependencies": {}
}
"""
.trimIndent()
)
assertThat(ReactSettingsExtension.isCacheDirty(invalidConfigFile, buildFolder, lockfiles))
.isTrue()
@@ -424,25 +433,26 @@ class ReactSettingsExtensionTest {
val invalidConfigFile =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
"version": "0.0.1",
"configurations": [],
"scriptPhases": []
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
"version": "0.0.1",
"configurations": [],
"scriptPhases": []
}
}
}
}
}
}
}
}
"""
.trimIndent())
"""
.trimIndent()
)
assertThat(ReactSettingsExtension.isCacheDirty(invalidConfigFile, buildFolder, lockfiles))
.isTrue()
@@ -31,7 +31,8 @@ tasks.withType<KotlinCompile>().configureEach {
// See comment above on JDK 11 support
jvmTarget.set(JvmTarget.JVM_11)
allWarningsAsErrors.set(
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false)
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false
)
}
}
@@ -37,7 +37,8 @@ tasks.withType<KotlinCompile>().configureEach {
// See comment above on JDK 11 support
jvmTarget.set(JvmTarget.JVM_11)
allWarningsAsErrors.set(
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false)
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false
)
}
}
@@ -39,20 +39,21 @@ class JsonUtilsTest {
val oldJsonConfig =
createJsonFile(
"""
{
"name": "yet another npm package",
"codegenConfig": {
"libraries": [
{
"name": "an awesome library",
"jsSrcsDir": "../js/",
"android": {}
"name": "yet another npm package",
"codegenConfig": {
"libraries": [
{
"name": "an awesome library",
"jsSrcsDir": "../js/",
"android": {}
}
]
}
}
]
}
}
"""
.trimIndent())
"""
.trimIndent()
)
val parsed = JsonUtils.fromPackageJson(oldJsonConfig)!!
@@ -66,21 +67,22 @@ class JsonUtilsTest {
val validJson =
createJsonFile(
"""
{
"name": "yet another npm package",
"codegenConfig": {
"name": "an awesome library",
"jsSrcsDir": "../js/",
"android": {
"javaPackageName": "com.awesome.library"
},
"ios": {
"other ios only keys": "which are ignored during parsing"
}
}
}
"""
.trimIndent())
{
"name": "yet another npm package",
"codegenConfig": {
"name": "an awesome library",
"jsSrcsDir": "../js/",
"android": {
"javaPackageName": "com.awesome.library"
},
"ios": {
"other ios only keys": "which are ignored during parsing"
}
}
}
"""
.trimIndent()
)
val parsed = JsonUtils.fromPackageJson(validJson)!!
@@ -111,11 +113,12 @@ class JsonUtilsTest {
val validJson =
createJsonFile(
"""
{
"version": "1000.0.0"
}
"""
.trimIndent())
{
"version": "1000.0.0"
}
"""
.trimIndent()
)
val parsed = JsonUtils.fromPackageJson(validJson)!!
assertThat("1000.0.0").isEqualTo(parsed.version)
@@ -133,11 +136,12 @@ class JsonUtilsTest {
val validJson =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0"
}
"""
.trimIndent())
{
"reactNativeVersion": "1000.0.0"
}
"""
.trimIndent()
)
val parsed = JsonUtils.fromAutolinkingConfigJson(validJson)!!
assertThat("1000.0.0").isEqualTo(parsed.reactNativeVersion)
@@ -148,32 +152,33 @@ class JsonUtilsTest {
val validJson =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"project": {
"ios": {
"sourceDir": "./packages/rn-tester",
"xcodeProject": {
"name": "RNTesterPods.xcworkspace",
"isWorkspace": true
},
"automaticPodsInstallation": false
},
"android": {
"sourceDir": "./packages/rn-tester",
"appName": "RN-Tester",
"packageName": "com.facebook.react.uiapp",
"applicationId": "com.facebook.react.uiapp",
"mainActivity": ".RNTesterActivity",
"watchModeCommandParams": [
"--mode HermesDebug"
],
"dependencyConfiguration": "implementation"
}
}
}
"""
.trimIndent())
{
"reactNativeVersion": "1000.0.0",
"project": {
"ios": {
"sourceDir": "./packages/rn-tester",
"xcodeProject": {
"name": "RNTesterPods.xcworkspace",
"isWorkspace": true
},
"automaticPodsInstallation": false
},
"android": {
"sourceDir": "./packages/rn-tester",
"appName": "RN-Tester",
"packageName": "com.facebook.react.uiapp",
"applicationId": "com.facebook.react.uiapp",
"mainActivity": ".RNTesterActivity",
"watchModeCommandParams": [
"--mode HermesDebug"
],
"dependencyConfiguration": "implementation"
}
}
}
"""
.trimIndent()
)
val parsed = JsonUtils.fromAutolinkingConfigJson(validJson)!!
assertThat("./packages/rn-tester").isEqualTo(parsed.project!!.android!!.sourceDir)
@@ -192,36 +197,37 @@ class JsonUtilsTest {
val validJson =
createJsonFile(
"""
> AwesomeProject@0.0.1 npx
> rnc-cli config
{
"reactNativeVersion": "1000.0.0",
"project": {
"ios": {
"sourceDir": "./packages/rn-tester",
"xcodeProject": {
"name": "RNTesterPods.xcworkspace",
"isWorkspace": true
},
"automaticPodsInstallation": false
},
"android": {
"sourceDir": "./packages/rn-tester",
"appName": "RN-Tester",
"packageName": "com.facebook.react.uiapp",
"applicationId": "com.facebook.react.uiapp",
"mainActivity": ".RNTesterActivity",
"watchModeCommandParams": [
"--mode HermesDebug"
],
"dependencyConfiguration": "implementation"
}
}
}
"""
.trimIndent())
> AwesomeProject@0.0.1 npx
> rnc-cli config
{
"reactNativeVersion": "1000.0.0",
"project": {
"ios": {
"sourceDir": "./packages/rn-tester",
"xcodeProject": {
"name": "RNTesterPods.xcworkspace",
"isWorkspace": true
},
"automaticPodsInstallation": false
},
"android": {
"sourceDir": "./packages/rn-tester",
"appName": "RN-Tester",
"packageName": "com.facebook.react.uiapp",
"applicationId": "com.facebook.react.uiapp",
"mainActivity": ".RNTesterActivity",
"watchModeCommandParams": [
"--mode HermesDebug"
],
"dependencyConfiguration": "implementation"
}
}
}
"""
.trimIndent()
)
val parsed = JsonUtils.fromAutolinkingConfigJson(validJson)!!
assertThat("./packages/rn-tester").isEqualTo(parsed.project!!.android!!.sourceDir)
@@ -239,41 +245,42 @@ class JsonUtilsTest {
val validJson =
createJsonFile(
"""
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
"version": "0.0.1",
"configurations": [],
"scriptPhases": []
},
"android": {
"sourceDir": "./node_modules/@react-native/oss-library-example/android",
"packageImportPath": "import com.facebook.react.osslibraryexample.OSSLibraryExamplePackage;",
"packageInstance": "new OSSLibraryExamplePackage()",
"buildTypes": ["staging", "debug", "release"],
"libraryName": "OSSLibraryExampleSpec",
"componentDescriptors": [
"SampleNativeComponentComponentDescriptor"
],
"cmakeListsPath": "./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt",
"cxxModuleCMakeListsModuleName": null,
"cxxModuleCMakeListsPath": null,
"cxxModuleHeaderName": null,
"dependencyConfiguration": "implementation",
"isPureCxxDependency": false
{
"reactNativeVersion": "1000.0.0",
"dependencies": {
"@react-native/oss-library-example": {
"root": "./node_modules/@react-native/oss-library-example",
"name": "@react-native/oss-library-example",
"platforms": {
"ios": {
"podspecPath": "./node_modules/@react-native/oss-library-example/OSSLibraryExample.podspec",
"version": "0.0.1",
"configurations": [],
"scriptPhases": []
},
"android": {
"sourceDir": "./node_modules/@react-native/oss-library-example/android",
"packageImportPath": "import com.facebook.react.osslibraryexample.OSSLibraryExamplePackage;",
"packageInstance": "new OSSLibraryExamplePackage()",
"buildTypes": ["staging", "debug", "release"],
"libraryName": "OSSLibraryExampleSpec",
"componentDescriptors": [
"SampleNativeComponentComponentDescriptor"
],
"cmakeListsPath": "./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt",
"cxxModuleCMakeListsModuleName": null,
"cxxModuleCMakeListsPath": null,
"cxxModuleHeaderName": null,
"dependencyConfiguration": "implementation",
"isPureCxxDependency": false
}
}
}
}
}
}
}
}
"""
.trimIndent())
"""
.trimIndent()
)
val parsed = JsonUtils.fromAutolinkingConfigJson(validJson)!!
assertThat("./node_modules/@react-native/oss-library-example")
@@ -287,73 +294,86 @@ class JsonUtilsTest {
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.sourceDir)
.sourceDir
)
assertThat("import com.facebook.react.osslibraryexample.OSSLibraryExamplePackage;")
.isEqualTo(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.packageImportPath)
.packageImportPath
)
assertThat("new OSSLibraryExamplePackage()")
.isEqualTo(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.packageInstance)
.packageInstance
)
assertThat(listOf("staging", "debug", "release"))
.isEqualTo(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.buildTypes)
.buildTypes
)
assertThat("OSSLibraryExampleSpec")
.isEqualTo(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.libraryName)
.libraryName
)
assertThat(listOf("SampleNativeComponentComponentDescriptor"))
.isEqualTo(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.componentDescriptors)
.componentDescriptors
)
assertThat(
"./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt")
"./node_modules/@react-native/oss-library-example/android/build/generated/source/codegen/jni/CMakeLists.txt"
)
.isEqualTo(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.cmakeListsPath)
.cmakeListsPath
)
assertThat(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.cxxModuleHeaderName)
.cxxModuleHeaderName
)
.isNull()
assertThat(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.cxxModuleCMakeListsPath)
.cxxModuleCMakeListsPath
)
.isNull()
assertThat(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.cxxModuleCMakeListsModuleName)
.cxxModuleCMakeListsModuleName
)
.isNull()
assertThat("implementation")
.isEqualTo(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.dependencyConfiguration)
.dependencyConfiguration
)
assertThat(
parsed.dependencies!!["@react-native/oss-library-example"]!!
.platforms!!
.android!!
.isPureCxxDependency!!)
.isPureCxxDependency!!
)
.isFalse()
}
@@ -67,7 +67,7 @@
"@babel/plugin-transform-unicode-regex": "^7.24.7",
"@babel/template": "^7.25.0",
"@react-native/babel-plugin-codegen": "0.82.0-main",
"babel-plugin-syntax-hermes-parser": "0.31.2",
"babel-plugin-syntax-hermes-parser": "0.32.0",
"babel-plugin-transform-flow-enums": "^0.0.2",
"react-refresh": "^0.14.0"
},
@@ -28,7 +28,7 @@
"dependencies": {
"@babel/core": "^7.25.2",
"@react-native/babel-preset": "0.82.0-main",
"hermes-parser": "0.31.2",
"hermes-parser": "0.32.0",
"nullthrows": "^1.1.1"
},
"peerDependencies": {
+2 -2
View File
@@ -32,7 +32,7 @@
"@babel/core": "^7.25.2",
"@babel/parser": "^7.25.3",
"glob": "^7.1.1",
"hermes-parser": "0.31.2",
"hermes-parser": "0.32.0",
"invariant": "^2.2.4",
"nullthrows": "^1.1.1",
"yargs": "^17.6.2"
@@ -45,7 +45,7 @@
"@babel/plugin-transform-nullish-coalescing-operator": "^7.24.7",
"@babel/plugin-transform-optional-chaining": "^7.24.8",
"@babel/preset-env": "^7.25.3",
"hermes-estree": "0.31.2",
"hermes-estree": "0.32.0",
"micromatch": "^4.0.4",
"prettier": "3.6.2",
"rimraf": "^3.0.2"
@@ -350,6 +350,8 @@ function setDefaultValue(
common.default = ((defaultValue ? defaultValue : 0): number);
break;
case 'FloatTypeAnnotation':
/* $FlowFixMe[invalid-compare] Error discovered during Constant Condition
* roll out. See https://fburl.com/workplace/5whu3i34. */
common.default = ((defaultValue === null
? null
: defaultValue
@@ -357,6 +359,8 @@ function setDefaultValue(
: 0): number | null);
break;
case 'BooleanTypeAnnotation':
/* $FlowFixMe[invalid-compare] Error discovered during Constant Condition
* roll out. See https://fburl.com/workplace/5whu3i34. */
common.default = defaultValue === null ? null : !!defaultValue;
break;
case 'StringTypeAnnotation':
@@ -77,6 +77,8 @@ const ActionSheetIOS = {
callback: (buttonIndex: number) => void,
) {
invariant(
/* $FlowFixMe[invalid-compare] Error discovered during Constant Condition
* roll out. See https://fburl.com/workplace/5whu3i34. */
typeof options === 'object' && options !== null,
'Options must be a valid object',
);
@@ -162,6 +164,8 @@ const ActionSheetIOS = {
successCallback: Function | ((success: boolean, method: ?string) => void),
) {
invariant(
/* $FlowFixMe[invalid-compare] Error discovered during Constant Condition
* roll out. See https://fburl.com/workplace/5whu3i34. */
typeof options === 'object' && options !== null,
'Options must be a valid object',
);
@@ -18,6 +18,8 @@ export class URLSearchParams {
}
constructor(params?: Record<string, string> | string | [string, string][]) {
/* $FlowFixMe[invalid-compare] Error discovered during Constant Condition
* roll out. See https://fburl.com/workplace/5whu3i34. */
if (params === null) {
return;
}
@@ -1503,7 +1503,7 @@ class ScrollView extends React.Component<ScrollViewProps, ScrollViewState> {
keyboardNeverPersistTaps &&
this._keyboardIsDismissible() &&
e.target != null &&
// $FlowFixMe[incompatible-type]
// $FlowFixMe Error supressed during the migration of HostInstance to ReactNativeElement
!TextInputState.isTextInput(e.target)
) {
return true;
@@ -4,7 +4,6 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @fantom_flags enableFixForParentTagDuringReparenting:true
* @fantom_flags enableViewCulling:true
* @flow strict-local
* @format
@@ -18,6 +18,7 @@ import type {
} from '../../Types/CoreEventTypes';
import type {ViewProps} from '../View/ViewPropTypes';
import ReactNativeElement from '../../../src/private/webapis/dom/nodes/ReactNativeElement';
import {type ColorValue, type TextStyleProp} from '../../StyleSheet/StyleSheet';
import * as React from 'react';
@@ -1037,13 +1038,19 @@ export type TextInputProps = $ReadOnly<{
...TextInputBaseProps,
}>;
export interface TextInputInstance extends HostInstance {
+clear: () => void;
+isFocused: () => boolean;
+getNativeRef: () => ?HostInstance;
+setSelection: (start: number, end: number) => void;
/**
* TextInput monkey-patches the native element instance with these methods.
* It isn't technically a class but this is the most elegant way to type it.
*/
declare class _TextInputInstance extends ReactNativeElement {
clear(): void;
isFocused(): boolean;
getNativeRef(): ?ReactNativeElement;
setSelection(start: number, end: number): void;
}
export type TextInputInstance = _TextInputInstance;
/**
* A foundational component for inputting text into the app via a
* keyboard. Props provide configurability for several features, such as
@@ -123,7 +123,7 @@ jest.unmock('../TextInput');
throw new Error('Expected `textInputElement` to be non-null');
}
// $FlowFixMe[prop-missing]
// $FlowFixMe
textInputElement.currentProps = textInputElement.props;
expect(textInputElement.isFocused()).toBe(false);
@@ -58,10 +58,12 @@ export default class ReactFabricHostComponent implements NativeMethods {
}
blur() {
// $FlowFixMe - Error supressed during the migration of HostInstance to ReactNativeElement
TextInputState.blurTextInput(this);
}
focus() {
// $FlowFixMe - Error supressed during the migration of HostInstance to ReactNativeElement
TextInputState.focusTextInput(this);
}
@@ -14,7 +14,6 @@ import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
import type {HostInstance} from 'react-native';
import ReactNativeElement from '../../../../src/private/webapis/dom/nodes/ReactNativeElement';
import {getRawNativeDOMForTests} from '../../../../src/private/webapis/dom/nodes/specs/NativeDOM';
import TextInputState from '../../../Components/TextInput/TextInputState';
import View from '../../../Components/View/View';
import ReactFabricHostComponent from '../ReactFabricHostComponent';
@@ -349,58 +348,5 @@ describe('ReactFabricPublicInstance', () => {
.toJSX(),
).toEqual(<rn-view testID={'second test id'} />);
});
// TODO: delete when NativeDOM.setNativeProps is NOT nullable.
// This logic is to ensure compatibility with old app versions without the native module method.
if (ReactNativeFeatureFlags.enableAccessToHostTreeInFabric()) {
let RawNativeDOM;
let originalSetNativeProps;
beforeAll(() => {
RawNativeDOM = nullthrows(getRawNativeDOMForTests());
originalSetNativeProps = RawNativeDOM.setNativeProps;
});
beforeEach(() => {
// $FlowExpectedError[cannot-write]
RawNativeDOM.setNativeProps = originalSetNativeProps;
});
it('should propagate changes to the host component (when NativeDOM.setNativeProps is not available)', () => {
// $FlowExpectedError[cannot-write]
RawNativeDOM.setNativeProps = null;
expect(RawNativeDOM.setNativeProps).toBeNull();
const root = Fantom.createRoot();
const nodeRef = createRef<HostInstance>();
Fantom.runTask(() => {
root.render(<View ref={nodeRef} testID="first test id" />);
});
expect(
root
.getRenderedOutput({
props: ['testID'],
})
.toJSX(),
).toEqual(<rn-view testID={'first test id'} />);
const element = nullthrows(nodeRef.current);
Fantom.runTask(() => {
element.setNativeProps({testID: 'second test id'});
});
expect(
root
.getRenderedOutput({
props: ['testID'],
})
.toJSX(),
).toEqual(<rn-view testID={'second test id'} />);
});
}
});
});
@@ -9,19 +9,71 @@
*/
import type {HostInstance} from '../../src/private/types/HostInstance';
import type {
InternalInstanceHandle,
Node,
} from '../Renderer/shims/ReactNativeTypes';
import typeof ReactFabricType from '../Renderer/shims/ReactFabric';
import typeof ReactNativeType from '../Renderer/shims/ReactNative';
import type {RootTag} from './RootTag';
import {
onCaughtError,
onRecoverableError,
onUncaughtError,
} from '../../src/private/renderer/errorhandling/ErrorHandlers';
import {type RootTag} from './RootTag';
import * as React from 'react';
let cachedFabricRenderer;
let cachedPaperRenderer;
function getFabricRenderer(): ReactFabricType {
if (cachedFabricRenderer == null) {
cachedFabricRenderer = require('../Renderer/shims/ReactFabric').default;
}
return cachedFabricRenderer;
}
function getPaperRenderer(): ReactNativeType {
if (cachedPaperRenderer == null) {
cachedPaperRenderer = require('../Renderer/shims/ReactNative').default;
}
return cachedPaperRenderer;
}
const getMethod: (<MethodName: $Keys<ReactFabricType>>(
() => ReactFabricType,
MethodName,
) => ReactFabricType[MethodName]) &
(<MethodName: $Keys<ReactNativeType>>(
() => ReactNativeType,
MethodName,
) => ReactNativeType[MethodName]) = (getRenderer, methodName) => {
let cachedImpl;
// $FlowExpectedError
return function (arg1, arg2, arg3, arg4, arg5, arg6) {
if (cachedImpl == null) {
// $FlowExpectedError
cachedImpl = getRenderer()[methodName];
}
// $FlowExpectedError
return cachedImpl(arg1, arg2, arg3, arg4, arg5);
};
};
function getFabricMethod<MethodName: $Keys<ReactFabricType>>(
methodName: MethodName,
): ReactFabricType[MethodName] {
return getMethod(getFabricRenderer, methodName);
}
function getPaperMethod<MethodName: $Keys<ReactNativeType>>(
methodName: MethodName,
): ReactNativeType[MethodName] {
return getMethod(getPaperRenderer, methodName);
}
let cachedFabricRender;
let cachedPaperRender;
export function renderElement({
element,
rootTag,
@@ -34,50 +86,30 @@ export function renderElement({
useConcurrentRoot: boolean,
}): void {
if (useFabric) {
require('../Renderer/shims/ReactFabric').default.render(
element,
rootTag,
null,
useConcurrentRoot,
{
onCaughtError,
onUncaughtError,
onRecoverableError,
},
);
if (cachedFabricRender == null) {
cachedFabricRender = getFabricRenderer().render;
}
cachedFabricRender(element, rootTag, null, useConcurrentRoot, {
onCaughtError,
onUncaughtError,
onRecoverableError,
});
} else {
require('../Renderer/shims/ReactNative').default.render(
element,
rootTag,
undefined,
{
onCaughtError,
onUncaughtError,
onRecoverableError,
},
);
if (cachedPaperRender == null) {
cachedPaperRender = getPaperRenderer().render;
}
cachedPaperRender(element, rootTag, undefined, {
onCaughtError,
onUncaughtError,
onRecoverableError,
});
}
}
export function findHostInstance_DEPRECATED<TElementType: React.ElementType>(
// $FlowFixMe[incompatible-type]
componentOrHandle: ?(React.ElementRef<TElementType> | number),
): ?HostInstance {
return require('../Renderer/shims/ReactNative').default.findHostInstance_DEPRECATED(
// $FlowFixMe[incompatible-type]
componentOrHandle,
);
}
export function findNodeHandle<TElementType: React.ElementType>(
// $FlowFixMe[incompatible-type]
componentOrHandle: ?(React.ElementRef<TElementType> | number),
): ?number {
return require('../Renderer/shims/ReactNative').default.findNodeHandle(
// $FlowFixMe[incompatible-type]
componentOrHandle,
);
}
let cachedFabricDispatchCommand;
let cachedPaperDispatchCommand;
export function dispatchCommand(
handle: HostInstance,
@@ -87,90 +119,58 @@ export function dispatchCommand(
if (global.RN$Bridgeless === true) {
// Note: this function has the same implementation in the legacy and new renderer.
// However, evaluating the old renderer comes with some side effects.
return require('../Renderer/shims/ReactFabric').default.dispatchCommand(
handle,
command,
args,
);
if (cachedFabricDispatchCommand == null) {
cachedFabricDispatchCommand = getFabricRenderer().dispatchCommand;
}
return cachedFabricDispatchCommand(handle, command, args);
} else {
return require('../Renderer/shims/ReactNative').default.dispatchCommand(
handle,
command,
args,
);
if (cachedPaperDispatchCommand == null) {
cachedPaperDispatchCommand = getPaperRenderer().dispatchCommand;
}
return cachedPaperDispatchCommand(handle, command, args);
}
}
export function sendAccessibilityEvent(
handle: HostInstance,
eventType: string,
): void {
return require('../Renderer/shims/ReactNative').default.sendAccessibilityEvent(
handle,
eventType,
);
}
export const findHostInstance_DEPRECATED: <TElementType: React.ElementType>(
// $FlowExpectedError[incompatible-type]
componentOrHandle: ?(React.ElementRef<TElementType> | number),
) => ?HostInstance = getPaperMethod('findHostInstance_DEPRECATED');
export const findNodeHandle: <TElementType: React.ElementType>(
// $FlowExpectedError[incompatible-type]
componentOrHandle: ?(React.ElementRef<TElementType> | number),
) => ?number = getPaperMethod('findNodeHandle');
export const sendAccessibilityEvent: ReactNativeType['sendAccessibilityEvent'] =
getPaperMethod('sendAccessibilityEvent');
/**
* This method is used by AppRegistry to unmount a root when using the old
* React Native renderer (Paper).
*/
export function unmountComponentAtNodeAndRemoveContainer(rootTag: RootTag) {
// $FlowExpectedError[incompatible-type] rootTag is an opaque type so we can't really cast it as is.
const rootTagAsNumber: number = rootTag;
require('../Renderer/shims/ReactNative').default.unmountComponentAtNodeAndRemoveContainer(
rootTagAsNumber,
);
}
export const unmountComponentAtNodeAndRemoveContainer: (
rootTag: RootTag,
) => void =
// $FlowExpectedError[incompatible-type]
getPaperMethod('unmountComponentAtNodeAndRemoveContainer');
export function unstable_batchedUpdates<T>(
fn: T => void,
bookkeeping: T,
): void {
// This doesn't actually do anything when batching updates for a Fabric root.
return require('../Renderer/shims/ReactNative').default.unstable_batchedUpdates(
fn,
bookkeeping,
);
}
export const unstable_batchedUpdates: ReactNativeType['unstable_batchedUpdates'] =
getPaperMethod('unstable_batchedUpdates');
export const isChildPublicInstance: ReactNativeType['isChildPublicInstance'] =
getPaperMethod('isChildPublicInstance');
export const getNodeFromInternalInstanceHandle: ReactFabricType['getNodeFromInternalInstanceHandle'] =
getFabricMethod('getNodeFromInternalInstanceHandle');
export const getPublicInstanceFromInternalInstanceHandle: ReactFabricType['getPublicInstanceFromInternalInstanceHandle'] =
getFabricMethod('getPublicInstanceFromInternalInstanceHandle');
export const getPublicInstanceFromRootTag: ReactFabricType['getPublicInstanceFromRootTag'] =
getFabricMethod('getPublicInstanceFromRootTag');
export function isProfilingRenderer(): boolean {
return Boolean(__DEV__);
}
export function isChildPublicInstance(
parentInstance: HostInstance,
childInstance: HostInstance,
): boolean {
return require('../Renderer/shims/ReactNative').default.isChildPublicInstance(
parentInstance,
childInstance,
);
}
export function getNodeFromInternalInstanceHandle(
internalInstanceHandle: InternalInstanceHandle,
): ?Node {
// This is only available in Fabric
return require('../Renderer/shims/ReactFabric').default.getNodeFromInternalInstanceHandle(
internalInstanceHandle,
);
}
export function getPublicInstanceFromInternalInstanceHandle(
internalInstanceHandle: InternalInstanceHandle,
): mixed /*PublicInstance | PublicTextInstance | null*/ {
// This is only available in Fabric
return require('../Renderer/shims/ReactFabric').default.getPublicInstanceFromInternalInstanceHandle(
internalInstanceHandle,
);
}
export function getPublicInstanceFromRootTag(
rootTag: number,
): mixed /*PublicRootInstance | null*/ {
// This is only available in Fabric
return require('../Renderer/shims/ReactFabric').default.getPublicInstanceFromRootTag(
rootTag,
);
}
@@ -7,7 +7,7 @@
* @noformat
* @nolint
* @flow strict-local
* @generated SignedSource<<83073425aa3f71ced2c8c51f25a25938>>
* @generated SignedSource<<1f7876c0dc0b05685a730513dc410236>>
*/
'use strict';
@@ -82,6 +82,8 @@ export function register(name: string, callback: () => ViewConfig): string {
typeof callback === 'function',
'View config getter callback for component `%s` must be a function (received `%s`)',
name,
/* $FlowFixMe[invalid-compare] Error discovered during Constant Condition
* roll out. See https://fburl.com/workplace/5whu3i34. */
callback === null ? 'null' : typeof callback,
);
viewConfigCallbacks.set(name, callback);
+4
View File
@@ -83,6 +83,8 @@ class Share {
options?: ShareOptions = {},
): Promise<{action: string, activityType: ?string}> {
invariant(
/* $FlowFixMe[invalid-compare] Error discovered during Constant Condition
* roll out. See https://fburl.com/workplace/5whu3i34. */
typeof content === 'object' && content !== null,
'Content to share must be a valid object',
);
@@ -91,6 +93,8 @@ class Share {
'At least one of URL or message is required',
);
invariant(
/* $FlowFixMe[invalid-compare] Error discovered during Constant Condition
* roll out. See https://fburl.com/workplace/5whu3i34. */
typeof options === 'object' && options !== null,
'Options must be a valid object',
);
@@ -165,6 +165,8 @@ const HMRClient: HMRClientNativeInterface = {
// Moving to top gives errors due to NativeModules not being initialized
const DevLoadingView = require('./DevLoadingView').default;
/* $FlowFixMe[invalid-compare] Error discovered during Constant Condition
* roll out. See https://fburl.com/workplace/5whu3i34. */
const serverHost = port !== null && port !== '' ? `${host}:${port}` : host;
const serverScheme = scheme;
@@ -33,6 +33,8 @@ function deepFreezeAndThrowOnMutationInDev<T: {...} | Array<mixed>>(
if (__DEV__) {
if (
typeof object !== 'object' ||
/* $FlowFixMe[invalid-compare] Error discovered during Constant Condition
* roll out. See https://fburl.com/workplace/5whu3i34. */
object === null ||
Object.isFrozen(object) ||
Object.isSealed(object)
@@ -232,6 +232,8 @@ const WebSocketInterceptor = {
_arrayBufferToString(data: string): ArrayBuffer | string {
const value = base64.toByteArray(data).buffer;
/* $FlowFixMe[invalid-compare] Error discovered during Constant Condition
* roll out. See https://fburl.com/workplace/5whu3i34. */
if (value === undefined || value === null) {
return '(no value)';
}
+3 -2
View File
@@ -43,7 +43,7 @@ let reactNativeDependencies = BinaryTarget(
let hermesPrebuilt = BinaryTarget(
name: .hermesPrebuilt,
path: ".build/artifacts/hermes/destroot/Library/Frameworks/universal/hermes.xcframework",
path: ".build/artifacts/hermes/destroot/Library/Frameworks/universal/hermesvm.xcframework",
searchPaths: [".build/artifacts/hermes/destroot/include"]
)
@@ -433,6 +433,7 @@ let reactFabricComponents = RNTarget(
"components/view/platform/android",
"components/view/platform/windows",
"components/view/platform/macos",
"components/switch/iosswitch/react/renderer/components/switch/MacOSSwitchShadowNode.mm",
"components/textinput/platform/android",
"components/text/platform/android",
"components/textinput/platform/macos",
@@ -445,7 +446,7 @@ let reactFabricComponents = RNTarget(
"conponents/rncore", // this was the old folder where RN Core Components were generated. If you ran codegen in the past, you might have some files in it that might make the build fail.
],
dependencies: [.reactNativeDependencies, .reactCore, .reactJsiExecutor, .reactTurboModuleCore, .jsi, .logger, .reactDebug, .reactFeatureFlags, .reactUtils, .reactRuntimeScheduler, .reactCxxReact, .yoga, .reactRendererDebug, .reactGraphics, .reactFabric, .reactTurboModuleBridging],
sources: ["components/inputaccessory", "components/modal", "components/safeareaview", "components/text", "components/text/platform/cxx", "components/textinput", "components/textinput/platform/ios/", "components/unimplementedview", "components/virtualview", "components/virtualviewexperimental", "textlayoutmanager", "textlayoutmanager/platform/ios"]
sources: ["components/inputaccessory", "components/modal", "components/safeareaview", "components/text", "components/text/platform/cxx", "components/textinput", "components/textinput/platform/ios/", "components/unimplementedview", "components/virtualview", "components/virtualviewexperimental", "textlayoutmanager", "textlayoutmanager/platform/ios", "components/switch/iosswitch"]
)
/// React-FabricImage.podspec
@@ -53,6 +53,7 @@ RCT_EXTERN CGFloat RCTScreenScale(void);
RCT_EXTERN CGFloat RCTFontSizeMultiplier(void);
RCT_EXTERN CGSize RCTScreenSize(void);
RCT_EXTERN CGSize RCTViewportSize(void);
RCT_EXTERN CGSize RCTSwitchSize(void);
// Round float coordinates to nearest whole screen pixel (not point)
RCT_EXTERN CGFloat RCTRoundPixelValue(CGFloat value);
@@ -410,6 +410,18 @@ CGSize RCTViewportSize(void)
return window ? window.bounds.size : RCTScreenSize();
}
CGSize RCTSwitchSize(void)
{
static CGSize rctSwitchSize;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
RCTUnsafeExecuteOnMainQueueSync(^{
rctSwitchSize = [UISwitch new].intrinsicContentSize;
});
});
return rctSwitchSize;
}
CGFloat RCTRoundPixelValue(CGFloat value)
{
CGFloat scale = RCTScreenScale();
@@ -134,7 +134,7 @@ using namespace facebook::react;
}
auto imageSource = _state->getData().getImageSource();
imageSource.size = {image.size.width, image.size.height};
imageSource.size = {.width = image.size.width, .height = image.size.height};
static_cast<const ImageEventEmitter &>(*_eventEmitter).onLoad(imageSource);
static_cast<const ImageEventEmitter &>(*_eventEmitter).onLoadEnd();
@@ -9,10 +9,10 @@
#import <React/RCTConversions.h>
#import <react/renderer/components/FBReactNativeSpec/ComponentDescriptors.h>
#import <react/renderer/components/FBReactNativeSpec/EventEmitters.h>
#import <react/renderer/components/FBReactNativeSpec/Props.h>
#import <react/renderer/components/FBReactNativeSpec/RCTComponentViewHelpers.h>
#import <react/renderer/components/switch/AppleSwitchComponentDescriptor.h>
#import "RCTFabricComponentsPlugins.h"
@@ -734,7 +734,7 @@ static NSSet<NSNumber *> *returnKeyTypesSet;
toPosition:selectedTextRange.start];
NSInteger end = [_backedTextInputView offsetFromPosition:_backedTextInputView.beginningOfDocument
toPosition:selectedTextRange.end];
return AttributedString::Range{(int)start, (int)(end - start)};
return AttributedString::Range{.location = (int)start, .length = (int)(end - start)};
}
- (void)_restoreTextSelection
@@ -165,7 +165,8 @@ static Class<RCTComponentViewProtocol> RCTComponentViewClassWithName(const char
auto componentHandle = reinterpret_cast<ComponentHandle>(componentName);
auto constructor = [RCTLegacyViewManagerInteropComponentView componentDescriptorProvider].constructor;
auto provider = ComponentDescriptorProvider{componentHandle, componentName, flavor, constructor};
auto provider = ComponentDescriptorProvider{
.handle = componentHandle, .name = componentName, .flavor = flavor, .constructor = constructor};
_providerRegistry.add(provider);
_componentViewClasses[componentHandle] =
@@ -179,7 +180,8 @@ static Class<RCTComponentViewProtocol> RCTComponentViewClassWithName(const char
auto componentName = ComponentName{flavor->c_str()};
auto componentHandle = reinterpret_cast<ComponentHandle>(componentName);
auto constructor = [RCTUnimplementedViewComponentView componentDescriptorProvider].constructor;
auto provider = ComponentDescriptorProvider{componentHandle, componentName, flavor, constructor};
auto provider = ComponentDescriptorProvider{
.handle = componentHandle, .name = componentName, .flavor = flavor, .constructor = constructor};
_providerRegistry.add(provider);
_componentViewClasses[componentHandle] =
@@ -153,7 +153,7 @@ inline CATransform3D RCTCATransform3DFromTransformMatrix(const facebook::react::
inline facebook::react::Point RCTPointFromCGPoint(const CGPoint &point)
{
return {point.x, point.y};
return {.x = point.x, .y = point.y};
}
inline facebook::react::Float RCTFloatFromCGFloat(CGFloat value)
@@ -166,12 +166,12 @@ inline facebook::react::Float RCTFloatFromCGFloat(CGFloat value)
inline facebook::react::Size RCTSizeFromCGSize(const CGSize &size)
{
return {RCTFloatFromCGFloat(size.width), RCTFloatFromCGFloat(size.height)};
return {.width = RCTFloatFromCGFloat(size.width), .height = RCTFloatFromCGFloat(size.height)};
}
inline facebook::react::Rect RCTRectFromCGRect(const CGRect &rect)
{
return {RCTPointFromCGPoint(rect.origin), RCTSizeFromCGSize(rect.size)};
return {.origin = RCTPointFromCGPoint(rect.origin), .size = RCTSizeFromCGSize(rect.size)};
}
inline facebook::react::EdgeInsets RCTEdgeInsetsFromUIEdgeInsets(const UIEdgeInsets &edgeInsets)
@@ -207,20 +207,20 @@ static std::vector<ProcessedColorStop> processColorTransitionHints(const std::ve
// Position the new color stops
if (leftDist > rightDist) {
for (int y = 0; y < 7; ++y) {
ProcessedColorStop newStop{SharedColor(), offsetLeft + leftDist * ((7.0f + y) / 13.0f)};
ProcessedColorStop newStop{.color = SharedColor(), .position = offsetLeft + leftDist * ((7.0f + y) / 13.0f)};
newStops.push_back(newStop);
}
ProcessedColorStop stop1{SharedColor(), offset + rightDist * (1.0f / 3.0f)};
ProcessedColorStop stop2{SharedColor(), offset + rightDist * (2.0f / 3.0f)};
ProcessedColorStop stop1{.color = SharedColor(), .position = offset + rightDist * (1.0f / 3.0f)};
ProcessedColorStop stop2{.color = SharedColor(), .position = offset + rightDist * (2.0f / 3.0f)};
newStops.push_back(stop1);
newStops.push_back(stop2);
} else {
ProcessedColorStop stop1{SharedColor(), offsetLeft + leftDist * (1.0f / 3.0f)};
ProcessedColorStop stop2{SharedColor(), offsetLeft + leftDist * (2.0f / 3.0f)};
ProcessedColorStop stop1{.color = SharedColor(), .position = offsetLeft + leftDist * (1.0f / 3.0f)};
ProcessedColorStop stop2{.color = SharedColor(), .position = offsetLeft + leftDist * (2.0f / 3.0f)};
newStops.push_back(stop1);
newStops.push_back(stop2);
for (int y = 0; y < 7; ++y) {
ProcessedColorStop newStop{SharedColor(), offset + rightDist * (y / 13.0f)};
ProcessedColorStop newStop{.color = SharedColor(), .position = offset + rightDist * (y / 13.0f)};
newStops.push_back(newStop);
}
}
@@ -297,7 +297,7 @@ static std::vector<ProcessedColorStop> processColorTransitionHints(const std::ve
// largest specified position of any color stop or transition hint before it.
if (newPosition.has_value()) {
newPosition = std::max(newPosition.value(), maxPositionSoFar.value());
fixedColorStops[i] = ProcessedColorStop{colorStop.color, newPosition};
fixedColorStops[i] = ProcessedColorStop{.color = colorStop.color, .position = newPosition};
maxPositionSoFar = newPosition;
} else {
hasNullPositions = true;
@@ -320,8 +320,8 @@ static std::vector<ProcessedColorStop> processColorTransitionHints(const std::ve
if (startPosition.has_value()) {
auto increment = (endPosition.value() - startPosition.value()) / (unpositionedStops + 1);
for (size_t j = 1; j <= unpositionedStops; j++) {
fixedColorStops[lastDefinedIndex + j] =
ProcessedColorStop{colorStops[lastDefinedIndex + j].color, startPosition.value() + increment * j};
fixedColorStops[lastDefinedIndex + j] = ProcessedColorStop{
.color = colorStops[lastDefinedIndex + j].color, .position = startPosition.value() + increment * j};
}
}
}
@@ -75,7 +75,8 @@ RadiusVector RadiusToCorner(
bool isCircle,
RadialGradientSize::SizeKeyword keyword)
{
std::array<CGPoint, 4> corners = {{{0, 0}, {width, 0}, {width, height}, {0, height}}};
std::array<CGPoint, 4> corners = {
{{.x = 0, .y = 0}, {.x = width, .y = 0}, {.x = width, .y = height}, {.x = 0, .y = height}}};
size_t cornerIndex = 0;
CGFloat distance = hypot(centerX - corners[cornerIndex].x, centerY - corners[cornerIndex].y);
@@ -75,6 +75,7 @@ Pod::Spec.new do |s|
"react/renderer/components/scrollview/platform/cxx",
"react/renderer/components/text/platform/cxx",
"react/renderer/components/textinput/platform/ios",
"react/renderer/components/switch/iosswitch",
]);
add_dependency(s, "React-graphics", :additional_framework_paths => ["react/renderer/graphics/platform/ios"])
@@ -119,7 +119,8 @@ using namespace facebook::react;
.props([] {
auto sharedProps = std::make_shared<RootProps>();
auto &props = *sharedProps;
props.layoutConstraints = LayoutConstraints{{0, 0}, {500, 500}};
props.layoutConstraints = LayoutConstraints{
.minimumSize = {.width = 0, .height = 0}, .maximumSize = {.width = 500, .height = 500}};
auto &yogaStyle = props.yogaStyle;
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200));
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(200));
@@ -416,7 +417,8 @@ static ParagraphShadowNode::ConcreteState::Shared stateWithShadowNode(
.props([] {
auto sharedProps = std::make_shared<RootProps>();
auto &props = *sharedProps;
props.layoutConstraints = LayoutConstraints{{0, 0}, {500, 500}};
props.layoutConstraints = LayoutConstraints{
.minimumSize = {.width = 0, .height = 0}, .maximumSize = {.width = 500, .height = 500}};
auto &yogaStyle = props.yogaStyle;
yogaStyle.setDimension(yoga::Dimension::Width, yoga::StyleSizeLength::points(200));
yogaStyle.setDimension(yoga::Dimension::Height, yoga::StyleSizeLength::points(200));
+1 -1
View File
@@ -131,7 +131,7 @@ static UIFont *cachedSystemFont(CGFloat size, RCTFontWeight weight)
RCTFontWeight weight;
};
CacheKey key{size, weight};
CacheKey key{.size = size, .weight = weight};
NSValue *cacheKey = [[NSValue alloc] initWithBytes:&key objCType:@encode(CacheKey)];
UIFont *font = [fontCache objectForKey:cacheKey];
@@ -1018,10 +1018,6 @@ public abstract interface class com/facebook/react/bridge/NotThreadSafeBridgeIdl
public abstract fun onTransitionToBridgeIdle ()V
}
public abstract interface class com/facebook/react/bridge/OnBatchCompleteListener {
public abstract fun onBatchComplete ()V
}
public abstract interface class com/facebook/react/bridge/PerformanceCounter {
public abstract fun getPerformanceCounters ()Ljava/util/Map;
public abstract fun profileNextBatch ()V
@@ -1863,15 +1859,9 @@ public class com/facebook/react/defaults/DefaultReactActivityDelegate : com/face
public final class com/facebook/react/defaults/DefaultReactHost {
public static final field INSTANCE Lcom/facebook/react/defaults/DefaultReactHost;
public static final fun getDefaultReactHost (Landroid/content/Context;Lcom/facebook/react/ReactNativeHost;Lcom/facebook/react/runtime/JSRuntimeFactory;)Lcom/facebook/react/ReactHost;
public static final fun getDefaultReactHost (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/runtime/JSRuntimeFactory;ZLjava/util/List;)Lcom/facebook/react/ReactHost;
public static final fun getDefaultReactHost (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/runtime/JSRuntimeFactory;ZLjava/util/List;Lkotlin/jvm/functions/Function1;Lcom/facebook/react/runtime/BindingsInstaller;)Lcom/facebook/react/ReactHost;
public static final fun getDefaultReactHost (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;)Lcom/facebook/react/ReactHost;
public static final fun getDefaultReactHost (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;Lkotlin/jvm/functions/Function1;Lcom/facebook/react/runtime/BindingsInstaller;)Lcom/facebook/react/ReactHost;
public static synthetic fun getDefaultReactHost$default (Landroid/content/Context;Lcom/facebook/react/ReactNativeHost;Lcom/facebook/react/runtime/JSRuntimeFactory;ILjava/lang/Object;)Lcom/facebook/react/ReactHost;
public static synthetic fun getDefaultReactHost$default (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/runtime/JSRuntimeFactory;ZLjava/util/List;ILjava/lang/Object;)Lcom/facebook/react/ReactHost;
public static synthetic fun getDefaultReactHost$default (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Lcom/facebook/react/runtime/JSRuntimeFactory;ZLjava/util/List;Lkotlin/jvm/functions/Function1;Lcom/facebook/react/runtime/BindingsInstaller;ILjava/lang/Object;)Lcom/facebook/react/ReactHost;
public static synthetic fun getDefaultReactHost$default (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;ILjava/lang/Object;)Lcom/facebook/react/ReactHost;
public static synthetic fun getDefaultReactHost$default (Landroid/content/Context;Ljava/util/List;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ZZLjava/util/List;Lkotlin/jvm/functions/Function1;Lcom/facebook/react/runtime/BindingsInstaller;ILjava/lang/Object;)Lcom/facebook/react/ReactHost;
}
public abstract class com/facebook/react/defaults/DefaultReactNativeHost : com/facebook/react/ReactNativeHost {
@@ -1973,7 +1963,7 @@ public abstract interface class com/facebook/react/devsupport/DevServerHelper$Pa
public abstract fun onPackagerReloadCommand ()V
}
public abstract class com/facebook/react/devsupport/DevSupportManagerBase : com/facebook/react/devsupport/interfaces/DevSupportManager, com/facebook/react/devsupport/interfaces/PerfMonitorV2Handler {
public abstract class com/facebook/react/devsupport/DevSupportManagerBase : com/facebook/react/devsupport/interfaces/DevSupportManager {
public static final field Companion Lcom/facebook/react/devsupport/DevSupportManagerBase$Companion;
public fun <init> (Landroid/content/Context;Lcom/facebook/react/devsupport/ReactInstanceDevHelper;Ljava/lang/String;ZLcom/facebook/react/devsupport/interfaces/RedBoxHandler;Lcom/facebook/react/devsupport/interfaces/DevBundleDownloadListener;ILjava/util/Map;Lcom/facebook/react/common/SurfaceDelegateFactory;Lcom/facebook/react/devsupport/interfaces/DevLoadingViewManager;Lcom/facebook/react/devsupport/interfaces/PausedInDebuggerOverlayManager;)V
public fun addCustomDevOption (Ljava/lang/String;Lcom/facebook/react/devsupport/interfaces/DevOptionHandler;)V
@@ -2031,7 +2021,6 @@ public abstract class com/facebook/react/devsupport/DevSupportManagerBase : com/
public fun startInspector ()V
public fun stopInspector ()V
public fun toggleElementInspector ()V
public fun unstable_updatePerfMonitor (Ljava/lang/String;I)V
}
public abstract interface class com/facebook/react/devsupport/DevSupportManagerBase$CallbackWithBundleLoader {
@@ -4369,7 +4358,6 @@ public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/b
public fun addRootView (Landroid/view/View;Lcom/facebook/react/bridge/WritableMap;)I
public fun addUIBlock (Lcom/facebook/react/uimanager/UIBlock;)V
public fun addUIManagerEventListener (Lcom/facebook/react/bridge/UIManagerListener;)V
public fun addUIManagerListener (Lcom/facebook/react/uimanager/UIManagerModuleListener;)V
public fun clearJSResponder ()V
public fun configureNextLayoutAnimation (Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Callback;Lcom/facebook/react/bridge/Callback;)V
public static fun createConstants (Ljava/util/List;Ljava/util/Map;Ljava/util/Map;)Ljava/util/Map;
@@ -4406,7 +4394,6 @@ public class com/facebook/react/uimanager/UIManagerModule : com/facebook/react/b
public fun receiveEvent (ILjava/lang/String;Lcom/facebook/react/bridge/WritableMap;)V
public fun removeRootView (I)V
public fun removeUIManagerEventListener (Lcom/facebook/react/bridge/UIManagerListener;)V
public fun removeUIManagerListener (Lcom/facebook/react/uimanager/UIManagerModuleListener;)V
public fun resolveCustomDirectEventName (Ljava/lang/String;)Ljava/lang/String;
public fun resolveRootTagFromReactTag (I)I
public fun resolveView (I)Landroid/view/View;
@@ -74,7 +74,14 @@ val GLOG_VERSION = libs.versions.glog.get()
val preparePrefab by
tasks.registering(PreparePrefabHeadersTask::class) {
dependsOn(prepareBoost, prepareDoubleConversion, prepareFolly, prepareGlog)
dependsOn(
prepareBoost,
prepareDoubleConversion,
prepareFastFloat,
prepareFmt,
prepareFolly,
prepareGlog,
)
dependsOn("generateCodegenArtifactsFromSchema")
// To export to a ReactNativePrefabProcessingEntities.kt once all
// libraries have been moved. We keep it here for now as it make easier to
@@ -108,21 +115,25 @@ val preparePrefab by
// react_devtoolsruntimesettings
Pair(
"../ReactCommon/react/devtoolsruntimesettings/",
"react/devtoolsruntimesettings/"),
"react/devtoolsruntimesettings/",
),
// react_renderer_animations
Pair(
"../ReactCommon/react/renderer/animations/",
"react/renderer/animations/"),
"react/renderer/animations/",
),
// react_renderer_bridging
Pair("../ReactCommon/react/renderer/bridging/", "react/renderer/bridging/"),
// react_renderer_componentregistry
Pair(
"../ReactCommon/react/renderer/componentregistry/",
"react/renderer/componentregistry/"),
"react/renderer/componentregistry/",
),
// react_renderer_consistency
Pair(
"../ReactCommon/react/renderer/consistency/",
"react/renderer/consistency/"),
"react/renderer/consistency/",
),
// react_renderer_core
Pair("../ReactCommon/react/renderer/core/", "react/renderer/core/"),
// react_renderer_css
@@ -137,7 +148,8 @@ val preparePrefab by
// react_renderer_imagemanager
Pair(
"../ReactCommon/react/renderer/imagemanager/",
"react/renderer/imagemanager/"),
"react/renderer/imagemanager/",
),
Pair("../ReactCommon/react/renderer/imagemanager/platform/cxx/", ""),
// react_renderer_mounting
Pair("../ReactCommon/react/renderer/mounting/", "react/renderer/mounting/"),
@@ -150,37 +162,45 @@ val preparePrefab by
// rrc_image
Pair(
"../ReactCommon/react/renderer/components/image/",
"react/renderer/components/image/"),
"react/renderer/components/image/",
),
// rrc_view
Pair(
"../ReactCommon/react/renderer/components/view/",
"react/renderer/components/view/"),
"react/renderer/components/view/",
),
Pair("../ReactCommon/react/renderer/components/view/platform/android/", ""),
// rrc_root
Pair(
"../ReactCommon/react/renderer/components/root/",
"react/renderer/components/root/"),
"react/renderer/components/root/",
),
// runtimeexecutor
Pair("../ReactCommon/runtimeexecutor/", ""),
// react_renderer_textlayoutmanager
Pair(
"../ReactCommon/react/renderer/textlayoutmanager/",
"react/renderer/textlayoutmanager/"),
"react/renderer/textlayoutmanager/",
),
Pair("../ReactCommon/react/renderer/textlayoutmanager/platform/android/", ""),
// rrc_text
Pair(
"../ReactCommon/react/renderer/components/text/",
"react/renderer/components/text/"),
"react/renderer/components/text/",
),
Pair(
"../ReactCommon/react/renderer/attributedstring",
"react/renderer/attributedstring"),
"react/renderer/attributedstring",
),
// rrc_textinput
Pair(
"../ReactCommon/react/renderer/components/textinput/",
"react/renderer/components/textinput/"),
"react/renderer/components/textinput/",
),
Pair(
"../ReactCommon/react/renderer/components/textinput/platform/android/",
""),
"",
),
// react_newarchdefaults
Pair("src/main/jni/react/newarchdefaults", ""),
// react_nativemodule_core
@@ -197,20 +217,24 @@ val preparePrefab by
Pair("../ReactCommon/react/nativemodule/core/platform/android/", ""),
Pair(
"../ReactCommon/react/renderer/componentregistry/",
"react/renderer/componentregistry/"),
"react/renderer/componentregistry/",
),
Pair(
"../ReactCommon/react/renderer/components/root/",
"react/renderer/components/root/"),
"react/renderer/components/root/",
),
Pair("../ReactCommon/react/renderer/core/", "react/renderer/core/"),
Pair("../ReactCommon/react/renderer/debug/", "react/renderer/debug/"),
Pair(
"../ReactCommon/react/renderer/leakchecker/",
"react/renderer/leakchecker/"),
"react/renderer/leakchecker/",
),
Pair("../ReactCommon/react/renderer/mapbuffer/", "react/renderer/mapbuffer/"),
Pair("../ReactCommon/react/renderer/mounting/", "react/renderer/mounting/"),
Pair(
"../ReactCommon/react/renderer/runtimescheduler/",
"react/renderer/runtimescheduler/"),
"react/renderer/runtimescheduler/",
),
Pair("../ReactCommon/react/renderer/scheduler/", "react/renderer/scheduler/"),
Pair("../ReactCommon/react/renderer/telemetry/", "react/renderer/telemetry/"),
Pair("../ReactCommon/react/renderer/uimanager/", "react/renderer/uimanager/"),
@@ -222,22 +246,32 @@ val preparePrefab by
// react_performance_timeline
Pair(
"../ReactCommon/react/performance/timeline/",
"react/performance/timeline/"),
"react/performance/timeline/",
),
// react_performance_cdpmetrics
Pair(
"../ReactCommon/react/performance/cdpmetrics/",
"react/performance/cdpmetrics/",
),
// react_renderer_observers_events
Pair(
"../ReactCommon/react/renderer/observers/events/",
"react/renderer/observers/events/"),
"react/renderer/observers/events/",
),
// react_timing
Pair("../ReactCommon/react/timing/", "react/timing/"),
// yoga
Pair("../ReactCommon/yoga/", ""),
Pair("src/main/jni/first-party/yogajni/jni", ""),
)),
),
),
PrefabPreprocessingEntry(
"hermestooling",
// hermes_executor
Pair("../ReactCommon/hermes/inspector-modern/", "hermes/inspector-modern/")),
))
Pair("../ReactCommon/hermes/inspector-modern/", "hermes/inspector-modern/"),
),
)
)
outputDir.set(prefabHeadersDir)
}
@@ -252,7 +286,8 @@ val downloadBoost by
tasks.registering(Download::class) {
dependsOn(createNativeDepsDirectories)
src(
"https://archives.boost.io/release/${BOOST_VERSION.replace("_", ".")}/source/boost_${BOOST_VERSION}.tar.gz")
"https://archives.boost.io/release/${BOOST_VERSION.replace("_", ".")}/source/boost_${BOOST_VERSION}.tar.gz"
)
onlyIfModified(true)
overwrite(false)
retries(5)
@@ -275,7 +310,8 @@ val downloadDoubleConversion by
tasks.registering(Download::class) {
dependsOn(createNativeDepsDirectories)
src(
"https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz")
"https://github.com/google/double-conversion/archive/v${DOUBLE_CONVERSION_VERSION}.tar.gz"
)
onlyIfModified(true)
overwrite(false)
retries(5)
@@ -414,7 +450,8 @@ val buildCodegenCLI by
fileTree(codegenDir) {
include("lib/**/*.js")
include("lib/**/*.js.flow")
})
}
)
rootProjectName.set(rootProject.name)
}
@@ -525,7 +562,8 @@ android {
"-DANDROID_STL=c++_shared",
"-DANDROID_TOOLCHAIN=clang",
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON",
"-DCMAKE_POLICY_DEFAULT_CMP0069=NEW")
"-DCMAKE_POLICY_DEFAULT_CMP0069=NEW",
)
targets(
"reactnative",
@@ -550,11 +588,13 @@ android {
buildCodegenCLI,
"generateCodegenArtifactsFromSchema",
prepareNative3pDependencies,
preparePrefab)
preparePrefab,
)
tasks.getByName("generateCodegenSchemaFromJavaScript").dependsOn(buildCodegenCLI)
prepareKotlinBuildScriptModel.dependsOn("preBuild")
prepareKotlinBuildScriptModel.dependsOn(
":packages:react-native:ReactAndroid:hermes-engine:preBuild")
":packages:react-native:ReactAndroid:hermes-engine:preBuild"
)
sourceSets.getByName("main") {
res.setSrcDirs(
@@ -564,7 +604,9 @@ android {
"src/main/res/views/alert",
"src/main/res/views/modal",
"src/main/res/views/uimanager",
"src/main/res/views/view"))
"src/main/res/views/view",
)
)
java.exclude("com/facebook/react/processing")
java.exclude("com/facebook/react/module/processing")
}
@@ -581,7 +623,7 @@ android {
// we produce. The reason behind this is that we want to allow users to pick the
// JS engine by specifying a dependency on either `hermes-engine` or other engines
// that will include the necessary .so files to load.
jniLibs.excludes.add("**/libhermes.so")
jniLibs.excludes.add("**/libhermesvm.so")
}
buildFeatures {
@@ -122,14 +122,16 @@ val unzipHermes by
// NOTE: ideally, we would like CMake to be installed automatically by the `externalNativeBuild`
// below. To do that, we would need the various `ConfigureCMake*` tasks to run *before*
// `configureBuildForHermes` and `buildHermesC` so that CMake is available for their run. But the
// `ConfigureCMake*` tasks depend upon the `ImportHermesc.cmake` file which is actually generated by
// `ConfigureCMake*` tasks depend upon the `ImportHostCompilers.cmake` file which is actually
// generated by
// the two tasks mentioned before, so we install CMake manually to break the circular dependency.
val installCMake by
tasks.registering(CustomExecTask::class) {
onlyIfProvidedPathDoesNotExists.set(cmakePath)
commandLine(
windowsAwareCommandLine(getSDKManagerPath(), "--install", "cmake;${cmakeVersion}"))
windowsAwareCommandLine(getSDKManagerPath(), "--install", "cmake;${cmakeVersion}")
)
}
val configureBuildForHermes by
@@ -196,7 +198,7 @@ val buildHermesLib by
"--build",
hermesBuildDir.toString(),
"--target",
"libhermes",
"hermesvm",
"-j",
ndkBuildJobs,
)
@@ -257,16 +259,17 @@ android {
"-DANDROID_STL=c++_shared",
"-DANDROID_PIE=True",
"-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON",
"-DIMPORT_HERMESC=${File(hermesBuildDir, "ImportHermesc.cmake").toString()}",
"-DIMPORT_HOST_COMPILERS=${File(hermesBuildDir, "ImportHostCompilers.cmake").toString()}",
"-DJSI_DIR=${jsiDir}",
"-DHERMES_BUILD_SHARED_JSI=True",
"-DHERMES_RELEASE_VERSION=for RN ${version}",
"-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=True",
// We intentionally build Hermes with Intl support only. This is to simplify
// the build setup and to avoid overcomplicating the build-type matrix.
"-DHERMES_ENABLE_INTL=True")
"-DHERMES_ENABLE_INTL=True",
)
targets("libhermes")
targets("hermesvm")
}
}
ndk { abiFilters.addAll(reactNativeArchitectures()) }
@@ -302,7 +305,8 @@ android {
arguments(
"-DCMAKE_BUILD_TYPE=MinSizeRel",
// For release builds, we don't want to enable the Hermes Debugger.
"-DHERMES_ENABLE_DEBUGGER=False")
"-DHERMES_ENABLE_DEBUGGER=False",
)
}
}
}
@@ -343,12 +347,7 @@ android {
}
}
prefab {
create("libhermes") {
headers = prefabHeadersDir.absolutePath
libraryName = "libhermes"
}
}
prefab { create("hermesvm") { headers = prefabHeadersDir.absolutePath } }
}
afterEvaluate {
@@ -29,8 +29,8 @@ public class HermesExecutor internal constructor(enableDebugger: Boolean, debugg
@Throws(UnsatisfiedLinkError::class)
public fun loadLibrary() {
if (mode == null) {
// libhermes must be loaded explicitly to invoke its JNI_OnLoad.
SoLoader.loadLibrary("hermes")
// libhermesvm must be loaded explicitly to invoke its JNI_OnLoad.
SoLoader.loadLibrary("hermesvm")
SoLoader.loadLibrary("hermes_executor")
// libhermes_executor is built differently for Debug & Release so we load the proper mode.
mode = if (ReactBuildConfig.DEBUG) "Debug" else "Release"
@@ -25,7 +25,8 @@ public abstract class BaseReactPackage : ReactPackage {
@Deprecated("Migrate to [BaseReactPackage] and implement [getModule] instead.")
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
throw UnsupportedOperationException(
"createNativeModules method is not supported. Use getModule() method instead.")
"createNativeModules method is not supported. Use getModule() method instead."
)
}
/**
@@ -66,8 +67,10 @@ public abstract class BaseReactPackage : ReactPackage {
// This Iterator is used to create the NativeModule registry. The NativeModule
// registry must not have TurboModules. Therefore, if TurboModules are enabled, and
// the current NativeModule is a TurboModule, we need to skip iterating over it.
if (ReactNativeNewArchitectureFeatureFlags.useTurboModules() &&
reactModuleInfo.isTurboModule) {
if (
ReactNativeNewArchitectureFeatureFlags.useTurboModules() &&
reactModuleInfo.isTurboModule
) {
continue
}
@@ -54,7 +54,8 @@ import com.facebook.systrace.Systrace
SourceCodeModule::class,
TimingModule::class,
com.facebook.react.uimanager.UIManagerModule::class,
])
]
)
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated(
message = "This class is part of Legacy Architecture and will be removed in a future release",
@@ -65,7 +66,7 @@ internal class CoreModulesPackage(
private val hardwareBackBtnHandler: DefaultHardwareBackBtnHandler,
private val lazyViewManagersEnabled: Boolean,
private val minTimeLeftInFrameForNonBatchedOperationMs: Int,
) : BaseReactPackage(), ReactPackageLogger {
) : BaseReactPackage() {
/**
* This method is overridden, since OSS does not run the annotation processor to generate
* [CoreModulesPackage.ReactModuleInfoProvider] class. Here we check if it exists with the method
@@ -153,7 +154,8 @@ internal class CoreModulesPackage(
DeviceInfoModule.NAME -> DeviceInfoModule(reactContext)
else ->
throw IllegalArgumentException(
"In CoreModulesPackage, could not find Native module for $name")
"In CoreModulesPackage, could not find Native module for $name"
)
}
}
@@ -194,14 +196,6 @@ internal class CoreModulesPackage(
}
}
override fun startProcessPackage() {
ReactMarker.logMarker(ReactMarkerConstants.PROCESS_CORE_REACT_PACKAGE_START)
}
override fun endProcessPackage() {
ReactMarker.logMarker(ReactMarkerConstants.PROCESS_CORE_REACT_PACKAGE_END)
}
private companion object {
init {
LegacyArchitectureLogger.assertLegacyArchitecture(
@@ -26,7 +26,8 @@ public class DebugCorePackage public constructor() :
lazy(LazyThreadSafetyMode.NONE) {
mapOf(
DebuggingOverlayManager.REACT_CLASS to
ModuleSpec.viewManagerSpec { DebuggingOverlayManager() })
ModuleSpec.viewManagerSpec { DebuggingOverlayManager() }
)
}
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider = ReactModuleInfoProvider {
@@ -145,7 +145,8 @@ public abstract class HeadlessJsTaskService : Service(), HeadlessJsTaskEventList
invokeStartTask(context, taskConfig)
reactHost.removeReactInstanceEventListener(this)
}
})
}
)
reactHost.start()
} else {
val reactInstanceManager = reactNativeHost.reactInstanceManager
@@ -155,7 +156,8 @@ public abstract class HeadlessJsTaskService : Service(), HeadlessJsTaskEventList
invokeStartTask(context, taskConfig)
reactInstanceManager.removeReactInstanceEventListener(this)
}
})
}
)
reactInstanceManager.createReactContextInBackground()
}
}
@@ -25,8 +25,10 @@ internal class ReactAndroidHWInputDeviceHelper {
fun handleKeyEvent(ev: KeyEvent, context: ReactContext) {
val eventKeyCode = ev.keyCode
val eventKeyAction = ev.action
if ((eventKeyAction == KeyEvent.ACTION_UP || eventKeyAction == KeyEvent.ACTION_DOWN) &&
KEY_EVENTS_ACTIONS.containsKey(eventKeyCode)) {
if (
(eventKeyAction == KeyEvent.ACTION_UP || eventKeyAction == KeyEvent.ACTION_DOWN) &&
KEY_EVENTS_ACTIONS.containsKey(eventKeyCode)
) {
dispatchEvent(context, KEY_EVENTS_ACTIONS[eventKeyCode], lastFocusedViewId, eventKeyAction)
}
}
@@ -59,7 +59,8 @@ public open class ReactDelegate {
* used for New Architecture.
*/
@Deprecated(
"Use one of the other constructors instead to account for New Architecture. Deprecated since 0.75.0")
"Use one of the other constructors instead to account for New Architecture. Deprecated since 0.75.0"
)
public constructor(
activity: Activity,
reactNativeHost: ReactNativeHost?,
@@ -104,11 +105,14 @@ public open class ReactDelegate {
private val devSupportManager: DevSupportManager?
get() =
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost?.devSupportManager != null) {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost?.devSupportManager != null
) {
reactHost?.devSupportManager
} else if (reactNativeHost?.hasInstance() == true &&
reactNativeHost?.reactInstanceManager != null) {
} else if (
reactNativeHost?.hasInstance() == true && reactNativeHost?.reactInstanceManager != null
) {
reactNativeHost?.reactInstanceManager?.devSupportManager
} else {
null
@@ -117,10 +121,12 @@ public open class ReactDelegate {
public fun onHostResume() {
if (activity !is DefaultHardwareBackBtnHandler) {
throw ClassCastException(
"Host Activity `${activity.javaClass.simpleName}` does not implement DefaultHardwareBackBtnHandler")
"Host Activity `${activity.javaClass.simpleName}` does not implement DefaultHardwareBackBtnHandler"
)
}
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
reactHost?.onHostResume(activity, activity as DefaultHardwareBackBtnHandler)
} else {
if (reactNativeHost?.hasInstance() == true) {
@@ -132,8 +138,9 @@ public open class ReactDelegate {
}
public fun onUserLeaveHint() {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
reactHost?.onHostLeaveHint(activity)
} else {
if (reactNativeHost?.hasInstance() == true) {
@@ -143,8 +150,9 @@ public open class ReactDelegate {
}
public fun onHostPause() {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
reactHost?.onHostPause(activity)
} else {
if (reactNativeHost?.hasInstance() == true) {
@@ -155,8 +163,9 @@ public open class ReactDelegate {
public fun onHostDestroy() {
unloadApp()
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
reactHost?.onHostDestroy(activity)
} else {
if (reactNativeHost?.hasInstance() == true) {
@@ -166,8 +175,9 @@ public open class ReactDelegate {
}
public fun onBackPressed(): Boolean {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
reactHost?.onBackPressed()
return true
} else {
@@ -180,8 +190,9 @@ public open class ReactDelegate {
}
public fun onNewIntent(intent: Intent): Boolean {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
reactHost?.onNewIntent(intent)
return true
} else {
@@ -199,9 +210,11 @@ public open class ReactDelegate {
data: Intent?,
shouldForwardToReactInstance: Boolean,
) {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null &&
shouldForwardToReactInstance) {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null &&
shouldForwardToReactInstance
) {
reactHost?.onActivityResult(activity, requestCode, resultCode, data)
} else {
if (reactNativeHost?.hasInstance() == true && shouldForwardToReactInstance) {
@@ -213,8 +226,9 @@ public open class ReactDelegate {
}
public fun onWindowFocusChanged(hasFocus: Boolean) {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
reactHost?.onWindowFocusChange(hasFocus)
} else {
if (reactNativeHost?.hasInstance() == true) {
@@ -224,8 +238,9 @@ public open class ReactDelegate {
}
public fun onConfigurationChanged(newConfig: Configuration?) {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
reactHost?.onConfigurationChanged(checkNotNull(activity))
} else {
if (reactNativeHost?.hasInstance() == true) {
@@ -235,11 +250,13 @@ public open class ReactDelegate {
}
public fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
if (keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD &&
((ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost?.devSupportManager != null) ||
(reactNativeHost?.hasInstance() == true &&
reactNativeHost?.useDeveloperSupport == true))) {
if (
keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD &&
((ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost?.devSupportManager != null) ||
(reactNativeHost?.hasInstance() == true &&
reactNativeHost?.useDeveloperSupport == true))
) {
event.startTracking()
return true
}
@@ -248,8 +265,9 @@ public open class ReactDelegate {
public fun onKeyLongPress(keyCode: Int): Boolean {
if (keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD || keyCode == KeyEvent.KEYCODE_BACK) {
if (ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() &&
reactHost != null) {
if (
ReactNativeNewArchitectureFeatureFlags.enableBridgelessArchitecture() && reactHost != null
) {
val devSupportManager = reactHost?.devSupportManager
// onKeyLongPress is a Dev API and not supported in RELEASE mode.
if (devSupportManager != null && devSupportManager !is ReleaseDevSupportManager) {
@@ -257,8 +275,9 @@ public open class ReactDelegate {
return true
}
} else {
if (reactNativeHost?.hasInstance() == true &&
reactNativeHost?.useDeveloperSupport == true) {
if (
reactNativeHost?.hasInstance() == true && reactNativeHost?.useDeveloperSupport == true
) {
reactNativeHost?.reactInstanceManager?.showDevOptionsDialog()
return true
}
@@ -277,8 +296,10 @@ public open class ReactDelegate {
reactHost?.reload("ReactDelegate.reload()")
} else {
runOnUiThread {
if (reactNativeHost?.hasInstance() == true &&
reactNativeHost?.reactInstanceManager != null) {
if (
reactNativeHost?.hasInstance() == true &&
reactNativeHost?.reactInstanceManager != null
) {
reactNativeHost?.reactInstanceManager?.recreateReactContextInBackground()
}
}
@@ -389,7 +410,8 @@ public open class ReactDelegate {
}
@Deprecated(
"Do not access [ReactInstanceManager] directly. This class is going away in the New Architecture. You should use [ReactHost] instead.")
"Do not access [ReactInstanceManager] directly. This class is going away in the New Architecture. You should use [ReactHost] instead."
)
public fun getReactInstanceManager(): ReactInstanceManager {
val nonNullReactNativeHost =
checkNotNull(reactNativeHost) {
@@ -203,7 +203,8 @@ public open class ReactFragment : Fragment(), PermissionAwareActivity {
public fun build(): ReactFragment = newInstance(componentName, launchOptions, fabricEnabled)
@Deprecated(
"You should not change call ReactFragment.setFabricEnabled. Instead enable the NewArchitecture for the whole application with newArchEnabled=true in your gradle.properties file")
"You should not change call ReactFragment.setFabricEnabled. Instead enable the NewArchitecture for the whole application with newArchEnabled=true in your gradle.properties file"
)
public fun setFabricEnabled(fabricEnabled: Boolean): Builder {
this.fabricEnabled = fabricEnabled
return this
@@ -216,7 +217,8 @@ public open class ReactFragment : Fragment(), PermissionAwareActivity {
protected const val ARG_FABRIC_ENABLED: String = "arg_fabric_enabled"
@Deprecated(
"We will remove this and use a different solution for handling Fragment lifecycle events.")
"We will remove this and use a different solution for handling Fragment lifecycle events."
)
protected const val ARG_DISABLE_HOST_LIFECYCLE_EVENTS: String =
"arg_disable_host_lifecycle_events"
@@ -143,6 +143,8 @@ import java.util.Set;
*/
@ThreadSafe
@LegacyArchitecture
@Deprecated(
since = "This class is part of Legacy Architecture and will be removed in a future release")
public class ReactInstanceManager {
static {
@@ -1568,14 +1570,7 @@ public class ReactInstanceManager {
SystraceMessage.beginSection(TRACE_TAG_REACT, "processPackage")
.arg("className", reactPackage.getClass().getSimpleName())
.flush();
if (reactPackage instanceof ReactPackageLogger) {
((ReactPackageLogger) reactPackage).startProcessPackage();
}
nativeModuleRegistryBuilder.processPackage(reactPackage);
if (reactPackage instanceof ReactPackageLogger) {
((ReactPackageLogger) reactPackage).endProcessPackage();
}
SystraceMessage.endSection(TRACE_TAG_REACT).flush();
}
@@ -40,6 +40,10 @@ import com.facebook.react.packagerconnection.RequestHandler
/** Builder class for [ReactInstanceManager]. */
@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 ReactInstanceManagerBuilder {
private val packages: MutableList<ReactPackage> = mutableListOf()
private var jsBundleAssetUrl: String? = null
@@ -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.
*/
package com.facebook.react
import com.facebook.react.common.annotations.internal.LegacyArchitecture
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel
/** Interface for the bridge to call for TTI start and end markers. */
@Deprecated("This class is deprecated and will be removed in the next major release.")
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
internal interface ReactPackageLogger {
fun startProcessPackage()
fun endProcessPackage()
}
@@ -135,8 +135,10 @@ public abstract class ReactPackageTurboModuleManagerDelegate : TurboModuleManage
for (moduleProvider in moduleProviders) {
val moduleInfo: ReactModuleInfo? = packageModuleInfos[moduleProvider]?.get(moduleName)
if (moduleInfo?.isTurboModule == true &&
(resolvedModule == null || moduleInfo.canOverrideExistingModule)) {
if (
moduleInfo?.isTurboModule == true &&
(resolvedModule == null || moduleInfo.canOverrideExistingModule)
) {
val module = moduleProvider.getModule(moduleName)
if (module != null) {
resolvedModule = module
@@ -182,8 +184,10 @@ public abstract class ReactPackageTurboModuleManagerDelegate : TurboModuleManage
for (moduleProvider in moduleProviders) {
val moduleInfo: ReactModuleInfo? = packageModuleInfos[moduleProvider]?.get(moduleName)
if (moduleInfo?.isTurboModule == false &&
(resolvedModule == null || moduleInfo.canOverrideExistingModule)) {
if (
moduleInfo?.isTurboModule == false &&
(resolvedModule == null || moduleInfo.canOverrideExistingModule)
) {
val module = moduleProvider.getModule(moduleName)
if (module != null) {
resolvedModule = module
@@ -42,7 +42,8 @@ internal class AdditionAnimatedNode(
acc + animatedNode.getValue()
} else {
throw JSApplicationCausedNativeException(
"Illegal node ID set as an input for Animated.Add node")
"Illegal node ID set as an input for Animated.Add node"
)
}
},
)

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