Compare commits

...
Author SHA1 Message Date
Christian Falch f217bce77a [ios][prebuilt] fixed using continue in loop
Instead of returning when creating the list of header files from our podspecs, we now call `continue`. This is a bug that causes all subsequent globs in the header file list to be omitted after the first omitted glob.
2025-07-08 16:38:43 +02:00
Christian Falch e2087457f8 [ios][prebuild] add support for USE_FRAMEWORKS
When using prebuilts the USE_FRAMEWORKS setting is not really relevant for the React Native code, since there will not be any source code to build frameworks for - and because we already have a framework for the code in React.XCFramework.

This commit adds a new command to the React Native podspecs like we did with the ReactNativeDependencies framework. The method is called `add_rncore_dependency` and it does nothing when building from source - but when linking with the React.XCFramework it explicitly adds linking with the framework.

In addition there are a few places in the ruby code where we check for the USE_FRAMEWORK value and changes some settings - where needed this commit will add a separate check to ensure we're building from source when making these changes.

Testing:
- Builds without USE_FRAMEWORKS as before with/without prebuilt
- Builds with USE_FRAMEWORKS=dynamic as before with source - and now also with prebuilt code.
- Same goes for the static variant.
2025-07-08 16:35:14 +02:00
Alex Hunt fc5e33b582 Reorganise shared script utils (#52473)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52473

Shared utils that were located in the root of `scripts/` are now colocated closer to their dependencies or moved to `scripts/shared/` — simplifying the root directory layout.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D77873875

fbshipit-source-id: e04dba41a1ef811d32793931033fdfa93afad0cd
2025-07-08 06:10:36 -07:00
Pieter De Baets 6dfe59e1df Fix missing bundle errors not correctly reported on Android (#52441)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52441

When an error is thrown using `handleHostException` from within the (immediate) execution of a `Task`, the `Task` will capture the error. If those errors are never consumed, the error is just silently swallowed. Instead we should make sure that this is raised outside of the context of a `Task` so the error correctly bubbles up and crashes the app (in release).

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D77798248

fbshipit-source-id: 41803aba0cace0e364a235501cf34bb946e7ff51
2025-07-08 05:58:56 -07:00
Moti Zilberman db65cb70de Fix typo in new app screen
Summary:
TSIA

bypass-github-export-checks

Changelog: [Internal]

Reviewed By: vzaidman

Differential Revision: D77928389

fbshipit-source-id: 038d11bed3fbbb96c97b7e2c5727e91973de9078
2025-07-08 05:48:00 -07:00
Mateo Guzmán a0e11904d6 Clean up unnecessary test setup for Android tests (#52471)
Summary:
This came out of https://github.com/facebook/react-native/issues/52457 as I had to fix some tests and realised there is a lot of setup that could be shadow and other things that are not needed at all.

## Changelog:

[INTERNAL] - Clean up unnecessary test setup for Android tests

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

Test Plan:
```sh
yarn test-android
```

Reviewed By: cortinico

Differential Revision: D77926887

Pulled By: javache

fbshipit-source-id: ff493d87633fcb4c4194b50cd374ad2e8acda974
2025-07-08 05:31:11 -07:00
Pieter De Baets 120a417320 Cleanup react-native-codegen DEFS (#52468)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52468

* Re-enable tests
* Simplify logic to avoid bypasses for arc focus

Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D77143018

fbshipit-source-id: 06ec43ce5149a139db78d38630191b01bc520461
2025-07-08 04:53:51 -07:00
Rubén Norte 5a79ece192 Use structuredClone to copy detail field in performance.mark and performance.measure (#52483)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52483

Changelog: [internal]

This is a small refinement for `performance.mark` and `performance.measure` to use `structuredClone` to copy the value of the `detail` field, instead of assigning it by reference.

This still doesn't completely fix the semantics of `performance.mark` and `performance.measure`, as the entries returned by those methods aren't referentially equal to the entries reported by `PerformanceObserver` (and the latter don't have the `detail` field yet).

Reviewed By: huntie

Differential Revision: D77863037

fbshipit-source-id: 54d959612ecd560250e49bb0887bb12112a0142f
2025-07-08 04:40:49 -07:00
Ruslan Lesiutin f000116197 Fix Timestamps conversion for Custom Tracks (#52479)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52479

# Changelog: [Internal]

The previous cast is incorrect.

Reviewed By: javache

Differential Revision: D77894512

fbshipit-source-id: 67e6b9a4ed43020a343a2a9b5d702509c34ae41a
2025-07-08 04:34:14 -07:00
Vitali Zaidman 5cf4d0899f Update debugger-frontend from 51a91a2...844f225 (#52486)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52486

Changelog: [Internal] - Update `react-native/debugger-frontend` from 51a91a2...844f225

Resyncs `react-native/debugger-frontend` from GitHub - see `rn-chrome-devtools-frontend` [changelog](https://github.com/facebook/react-native-devtools-frontend/compare/51a91a2ad62e7f585912ed314a350a72de84d6ed...844f225009e6445d088ed0e431d1fc430325ed95).

### Changelog

| Commit | Author | Date/Time | Subject |
| ------ | ------ | --------- | ------- |
| [844f22500](https://github.com/facebook/react-native-devtools-frontend/commit/844f22500) | Vitali Zaidman (vzaidman@gmail.com) | 2025-07-08T10:16:09+01:00 | [Track when the stack trace symbolication succeeds (#187)](https://github.com/facebook/react-native-devtools-frontend/commit/844f22500) |
| [ffa6bb6af](https://github.com/facebook/react-native-devtools-frontend/commit/ffa6bb6af) | Vitali Zaidman (vzaidman@gmail.com) | 2025-07-07T16:21:55+01:00 | [parse "empty url" and "address at" frames as non-hyperlinked text (#188)](https://github.com/facebook/react-native-devtools-frontend/commit/ffa6bb6af) |

Reviewed By: robhogan

Differential Revision: D77926362

fbshipit-source-id: cbcf8b17cd175400d3d027ce2e8ebefa497f5d79
2025-07-08 04:15:32 -07:00
Marco Wang 68650badd2 Pre-suppress errors for null_void for xplat js (#52480)
Summary:
Changelog: [Internal]

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

Reviewed By: SamChou19815

Differential Revision: D77890434

fbshipit-source-id: cc0571e0ff1c7cec3fff8614f688d46e46970cc4
2025-07-07 20:35:08 -07:00
Luna Wei 5ec8e60581 Refactor VirtualView target structure on Android (#52476)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52476

Changelog: [Internal] - Refactor package structure on Android to prepare for experimental VirtualView so that non-view related objects go under `virtual` and the native view goes under `view`.
This breaks dependency circles for experimental VirtualView in upcoming change.

Reviewed By: yungsters

Differential Revision: D77335426

fbshipit-source-id: 3b978e9cc5ad376c71aebc039cfc74d2515d2cfa
2025-07-07 16:00:13 -07:00
Alex Hunt 918f02dcc3 Consolidate JS API scripts under scripts/js-api/, update docs (#52469)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52469

Organise `scripts/build-types/` and `scripts/diff-api-snapshot/` into a single grouping `scripts/js-api/` parent dir — matching the newly relocated `scripts/cxx-api/`.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D77865488

fbshipit-source-id: 33754d9275e65c3bda686294f18d855221ec7bff
2025-07-07 15:04:37 -07:00
Alex Hunt 5fe782a800 Move cxx-api scripts under scripts/, add README (#52467)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52467

Moves the WIP `cxx-public-api` project under `scripts/cxx-api/`, add minimal README docs.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D77865490

fbshipit-source-id: ce49845386c468ee7422b864c49f2a8c9eed5a70
2025-07-07 15:04:37 -07:00
Christoph Purrer abfb9cbd40 Update outdated ReactNativeCPP.api (#52475)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52475

Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D77887914

fbshipit-source-id: 1431205eff716bac86610750103df729553d22b9
2025-07-07 14:50:58 -07:00
Pieter De Baets 3bf5cb3d0e Deprecate MessageQueueThreadPerfStats (#52470)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52470

These metrics are not actively consumed and are highly noisy.

Changelog: [Android][Removed] Deprecated MessageQueueThreadPerfStats API and replaced with stub.

Reviewed By: cortinico

Differential Revision: D77867087

fbshipit-source-id: 8bf7423ad60cb3bb21a5dbe94771d5a71832633d
2025-07-07 11:29:01 -07:00
Christoph Purrer ead669ade3 Remove unused ReactCommon/TurboModuleUtils functions #deepCopyJSIObject and #deepCopyJSIArray (#52443)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52443

Changelog: [General][Breaking] Remove unused ReactCommon/TurboModuleUtils functions #deepCopyJSIObject and #deepCopyJSIArray

Those are not used anymore

Reviewed By: cortinico

Differential Revision: D77771186

fbshipit-source-id: e1f5e34238567241b4204d58ff85fd9067e321df
2025-07-07 11:04:01 -07:00
Nicola Corti 625f69f284 @DeprecatedInNewArchitecture -> @Deprecated (#52399)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52399

I'm raising the deprecation warnings for those methods that are using legacy arch.
Previously the `DeprecatedInNewArchitecture` was not generating warnings for user in their builds, while now the Kotlin's/Java's `DeprecatedInNewArchitecture` it will.

Changelog:
[Android] [Changed] - Introduce more deprecation warnings for Legacy Arch classes

Reviewed By: mdvacca

Differential Revision: D77736713

fbshipit-source-id: bc21729ed8253d3ec6b6a40577bcd76622c3f8a6
2025-07-07 10:20:43 -07:00
Christoph Purrer 06034554e4 Remove SampleTurboCxxModule example (#52442)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52442

Changelog: [Internal]

The sample is from an outdated approach of enabling C++ Modules in RN which is not recommended anymore.

Prefer C++ Turbo Modules if you need to expose / access C or C++ APIs in RN apps:

https://reactnative.dev/docs/the-new-architecture/pure-cxx-modules

It is not included in any RNTester app at this time

Reviewed By: cortinico

Differential Revision: D77771111

fbshipit-source-id: a4fe1d13fd0224babc46f54b921a036f7b237a48
2025-07-07 09:37:37 -07:00
Samuel Susla 298ec6ca5d Deprecate ShadowNode::ListOfWeak and replace with std::vector<std::weak_ptr<const ShadowNode>> (#52401)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52401

changelog: [internal]

- Mark ShadowNode::ListOfWeak as deprecated with appropriate deprecation message
- Replace all usages of ShadowNode::ListOfWeak with std::vector<std::weak_ptr<const ShadowNode>>
- Updated primitives.h and ReactNativeCPP.api to use the explicit type instead of the alias

This change continues the effort to remove type aliases in favor of explicit standard library types for better code clarity and maintainability.

Reviewed By: christophpurrer

Differential Revision: D77652083

fbshipit-source-id: 79cad019e039c19f661346604ff49a44a4af7a79
2025-07-07 09:29:57 -07:00
Christoph Purrer c1200718a0 Move RuntimeExecutor after copying it into BufferedRuntimeExecutor (#52404)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52404

Changelog: [Internal]

https://github.com/facebook/react-native/blob/main/packages/react-native/ReactCommon/runtimeexecutor/ReactCommon/RuntimeExecutor.h#L23

is a copy-able type (it will be copied when passed into the BufferedRuntimeExecutor constructor).

Hence we can `std::move` it in the `BufferedRuntimeExecutor` constructor

Reviewed By: javache

Differential Revision: D77758211

fbshipit-source-id: 634b1cd0e1ed4d27a013ad8927b2123dc6977ad8
2025-07-07 08:59:56 -07:00
Rubén Norte a3933e6878 Remove legacy tests for Performance API (#52465)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52465

Changelog: [internal]

Now that we have enough coverage for the Performance API in Fantom, Jest tests where most of the API is mocked are redundant and useless, so this removes them (and the mock).

Reviewed By: huntie

Differential Revision: D77860888

fbshipit-source-id: 7dbd1a8a43b056a3b34e4e37d578be9ccb521824
2025-07-07 06:42:23 -07:00
Rubén Norte 9f8179afa7 Add tests for durationThreshold option for PerformanceObserver (#52464)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52464

Changelog: [internal]

This adds tests for the `durationThreshold` option for `PerformanceObserver.prototype.observe`.

Reviewed By: huntie

Differential Revision: D77860882

fbshipit-source-id: 1e56391166523d2c4f837f758bc367b58fe8e82e
2025-07-07 06:42:23 -07:00
Rubén Norte e6bff3f1fe Add tests for performance.eventCounts (#52463)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52463

Changelog: [internal]

This adds Fantom tests for `performance.eventCounts`.

Reviewed By: huntie

Differential Revision: D77860881

fbshipit-source-id: 26b9ef56b9c610cbad7011bc0adde27251fda909
2025-07-07 06:42:23 -07:00
Rubén Norte feeef97554 Expand tests for the performance API (#52462)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52462

Changelog: [internal]

This adds a few more tests for `performance.getEntries`, `performance.getEntriesByName` and `performance.getEntriesByType`.

Reviewed By: huntie

Differential Revision: D77801746

fbshipit-source-id: 42f80c4e2b787c455b149ee38d071511181532b0
2025-07-07 06:42:23 -07:00
Rubén Norte 9005d93e32 Optimize performance.mark and performance.measure (#52429)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52429

Changelog: [internal]

This implements a significant optimization for `performance.mark` and `performance.measure`. After these changes, they take 1/3 of the time they took before.

We've seen these methods show up too often in traces (in the Hermes sampling profiler) so this should significantly reduce their overhead.

I found out that most of the time spent in `performance.mark` and `performance.measure` was creating the `PerformanceMark` and `PerformanceMeasure` instances returned by those methods. I applied the same playbook I did for `ReactNativeElement` (avoiding private fields and `super()` calls, which yielded these wins.

* Before

| (index) | Task name                                                 | Latency average (ns) | Latency median (ns) | Throughput average (ops/s) | Throughput median (ops/s) | Samples |
| ------- | --------------------------------------------------------- | -------------------- | ------------------- | -------------------------- | ------------------------- | ------- |
| 0       | 'mark (default)'                                          | '5579.80 ± 0.32%'    | '5479.00'           | '181368 ± 0.02%'           | '182515'                  | 179218  |
| 1       | 'mark (with custom startTime)'                            | '5759.72 ± 0.99%'    | '5648.00'           | '176162 ± 0.02%'           | '177054'                  | 173620  |
| 2       | 'measure (with start and end timestamps)'                 | '6506.38 ± 0.34%'    | '6390.00'           | '155503 ± 0.02%'           | '156495'                  | 153696  |
| 3       | 'measure (with mark names)'                               | '6770.94 ± 0.72%'    | '6620.00'           | '149833 ± 0.03%'           | '151057'                  | 147691  |
| 4       | 'clearMarks'                                              | '785.89 ± 0.07%'     | '771.00'            | '1291356 ± 0.01%'          | '1297017'                 | 1272442 |
| 5       | 'clearMeasures'                                           | '777.98 ± 0.06%'     | '761.00'            | '1303362 ± 0.01%'          | '1314060'                 | 1285383 |
| 6       | 'mark + clearMarks'                                       | '5995.34 ± 1.37%'    | '5779.00'           | '171874 ± 0.03%'           | '173040'                  | 166797  |
| 7       | 'measure + clearMeasures (with start and end timestamps)' | '7040.28 ± 0.57%'    | '6830.00'           | '145289 ± 0.03%'           | '146413'                  | 142040  |
| 8       | 'measure + clearMeasures (with mark names)'               | '7184.43 ± 0.40%'    | '6990.00'           | '141809 ± 0.03%'           | '143062'                  | 139190  |

* After

| (index) | Task name                                                 | Latency average (ns) | Latency median (ns) | Throughput average (ops/s) | Throughput median (ops/s) | Samples |
| ------- | --------------------------------------------------------- | -------------------- | ------------------- | -------------------------- | ------------------------- | ------- |
| 0       | 'mark (default)'                                          | '1678.19 ± 0.73%'    | '1633.00'           | '607139 ± 0.01%'           | '612370'                  | 595882  |
| 1       | 'mark (with custom startTime)'                            | '1920.23 ± 1.30%'    | '1843.00'           | '538217 ± 0.01%'           | '542594'                  | 520772  |
| 2       | 'measure (with start and end timestamps)'                 | '2651.72 ± 0.94%'    | '2554.00'           | '388312 ± 0.02%'           | '391543'                  | 377114  |
| 3       | 'measure (with mark names)'                               | '2815.84 ± 0.75%'    | '2744.00'           | '362303 ± 0.02%'           | '364431'                  | 355134  |
| 4       | 'clearMarks'                                              | '743.82 ± 0.06%'     | '731.00'            | '1363190 ± 0.01%'          | '1367989'                 | 1344417 |
| 5       | 'clearMeasures'                                           | '776.69 ± 0.07%'     | '761.00'            | '1306563 ± 0.01%'          | '1314060'                 | 1287512 |
| 6       | 'mark + clearMarks'                                       | '2043.97 ± 1.26%'    | '1973.00'           | '504750 ± 0.01%'           | '506842'                  | 489801  |
| 7       | 'measure + clearMeasures (with start and end timestamps)' | '3048.39 ± 0.87%'    | '2965.00'           | '335285 ± 0.02%'           | '337268'                  | 328042  |
| 8       | 'measure + clearMeasures (with mark names)'               | '3132.75 ± 0.80%'    | '3065.00'           | '324365 ± 0.02%'           | '326264'                  | 319209  |

Reviewed By: huntie

Differential Revision: D77790874

fbshipit-source-id: baf7aca07d281fef4373956d125c63f006fab592
2025-07-07 06:42:23 -07:00
Rubén Norte 74c03b67e3 Fix bugs in performance.mark and performance.measure (#52430)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52430

Changelog: [internal]

(This is marked as internal because this API hasn't been marked as stable yet).

This fixes multiple bugs and missing features in `performance.mark` and `performance.measure`. See re-enabled tests to see the specific behaviors.

Validated that performance isn't regressed by this change using the existing benchmark for `Performance` (`Performance-benchmark-itest`):

* Before

| (index) | Task name                                                 | Latency average (ns) | Latency median (ns) | Throughput average (ops/s) | Throughput median (ops/s) | Samples |
| ------- | --------------------------------------------------------- | -------------------- | ------------------- | -------------------------- | ------------------------- | ------- |
| 0       | 'mark (default)'                                          | '5557.96 ± 0.34%'    | '5459.00'           | '182114 ± 0.02%'           | '183184'                  | 179922  |
| 1       | 'mark (with custom startTime)'                            | '5664.54 ± 1.71%'    | '5518.00'           | '180296 ± 0.02%'           | '181225'                  | 176537  |
| 2       | 'measure (with start and end timestamps)'                 | '6653.62 ± 0.94%'    | '6530.00'           | '152296 ± 0.02%'           | '153139'                  | 150295  |
| 3       | 'measure (with mark names)'                               | '6903.37 ± 0.42%'    | '6790.00'           | '146429 ± 0.02%'           | '147275'                  | 144857  |
| 4       | 'clearMarks'                                              | '782.98 ± 0.04%'     | '771.00'            | '1287735 ± 0.01%'          | '1297017'                 | 1277173 |
| 5       | 'clearMeasures'                                           | '792.24 ± 0.03%'     | '781.00'            | '1270847 ± 0.01%'          | '1280410'                 | 1262238 |
| 6       | 'mark + clearMarks'                                       | '5883.69 ± 0.52%'    | '5759.00'           | '172863 ± 0.02%'           | '173641'                  | 169962  |
| 7       | 'measure + clearMeasures (with start and end timestamps)' | '7222.22 ± 0.68%'    | '7021.00'           | '141204 ± 0.02%'           | '142430'                  | 138462  |
| 8       | 'measure + clearMeasures (with mark names)'               | '7234.53 ± 0.34%'    | '7121.00'           | '139600 ± 0.02%'           | '140430'                  | 138227  |

* After

| (index) | Task name                                                 | Latency average (ns) | Latency median (ns) | Throughput average (ops/s) | Throughput median (ops/s) | Samples |
| ------- | --------------------------------------------------------- | -------------------- | ------------------- | -------------------------- | ------------------------- | ------- |
| 0       | 'mark (default)'                                          | '5579.80 ± 0.32%'    | '5479.00'           | '181368 ± 0.02%'           | '182515'                  | 179218  |
| 1       | 'mark (with custom startTime)'                            | '5759.72 ± 0.99%'    | '5648.00'           | '176162 ± 0.02%'           | '177054'                  | 173620  |
| 2       | 'measure (with start and end timestamps)'                 | '6506.38 ± 0.34%'    | '6390.00'           | '155503 ± 0.02%'           | '156495'                  | 153696  |
| 3       | 'measure (with mark names)'                               | '6770.94 ± 0.72%'    | '6620.00'           | '149833 ± 0.03%'           | '151057'                  | 147691  |
| 4       | 'clearMarks'                                              | '785.89 ± 0.07%'     | '771.00'            | '1291356 ± 0.01%'          | '1297017'                 | 1272442 |
| 5       | 'clearMeasures'                                           | '777.98 ± 0.06%'     | '761.00'            | '1303362 ± 0.01%'          | '1314060'                 | 1285383 |
| 6       | 'mark + clearMarks'                                       | '5995.34 ± 1.37%'    | '5779.00'           | '171874 ± 0.03%'           | '173040'                  | 166797  |
| 7       | 'measure + clearMeasures (with start and end timestamps)' | '7040.28 ± 0.57%'    | '6830.00'           | '145289 ± 0.03%'           | '146413'                  | 142040  |
| 8       | 'measure + clearMeasures (with mark names)'               | '7184.43 ± 0.40%'    | '6990.00'           | '141809 ± 0.03%'           | '143062'                  | 139190  |

Reviewed By: huntie

Differential Revision: D77795990

fbshipit-source-id: 97895065ca63f87f1f66710cf7bce97e1255a142
2025-07-07 06:42:23 -07:00
Rubén Norte 34201d8387 Fix Flow types for performance.measure (#52431)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52431

Changelog: [internal]

`performance.measure` supports passing mark names as `start` and `end` options, so this fixes the Flow type before fixing the actual implementation.

It also makes it so you can't specify both `end` and `duration`, enforced by the type system.

Reviewed By: huntie

Differential Revision: D77795991

fbshipit-source-id: e89f509c7efc2fa49d17d79bc19bc1d14e007871
2025-07-07 06:42:23 -07:00
Rubén Norte 2edda6d967 Add basic Fantom tests for performance.mark and performance.measure (#52432)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52432

Changelog: [internal]

This creates a battery of tests for `performance.mark` and `performance.measure`. For this, it was necessary to add a new method in the native module to mock the current time.

Many of the tests are currently failing, as the API doesn't support all the options or behaviors defined in the spec. They're skipped here and will be re-enabled and fixed in a following diff.

Reviewed By: huntie

Differential Revision: D77795989

fbshipit-source-id: 3ebf18c8ac336df1fb43003a55a4678b52e8982d
2025-07-07 06:42:23 -07:00
268 changed files with 3054 additions and 2214 deletions
@@ -17,7 +17,7 @@ runs:
env:
SCRATCH_DIR: ${{ runner.temp }}/diff-js-api-breaking-changes
run: |
node ./scripts/diff-api-snapshot \
node ./scripts/js-api/diff-api-snapshot \
${{ github.workspace }}/packages/react-native/ReactNativeApi.d.ts \
$SCRATCH_DIR/ReactNativeApi-after.d.ts \
> $SCRATCH_DIR/output.json
+1 -1
View File
@@ -32,7 +32,7 @@ if (process.env.FBSOURCE_ENV === '1') {
require('@fb-tools/babel-register');
} else {
// Register Babel to allow local packages to be loaded from source
require('../scripts/babel-register').registerForMonorepo();
require('../scripts/shared/babelRegister').registerForMonorepo();
}
const transformer = require('@react-native/metro-babel-transformer');
+4 -1
View File
@@ -8,14 +8,16 @@
"android": "yarn --cwd packages/rn-tester android",
"build-android": "./gradlew :packages:react-native:ReactAndroid:build",
"build": "node ./scripts/build/build.js",
"build-types": "node ./scripts/build-types",
"build-types": "node ./scripts/js-api/build-types",
"clang-format": "clang-format -i --glob=*/**/*.{h,cpp,m,mm}",
"clean": "node ./scripts/build/clean.js",
"cxx-api-build": "node ./scripts/cxx-api/public-api.js",
"flow-check": "flow check",
"flow": "flow",
"format-check": "prettier --list-different \"./**/*.{js,md,yml,ts,tsx}\"",
"format": "npm run prettier && npm run clang-format",
"featureflags": "yarn --cwd packages/react-native featureflags",
"js-api-diff": "node ./scripts/js-api/diff-api-snapshot",
"lint-ci": "./.github/workflow-scripts/analyze_code.sh && yarn shellcheck",
"lint-markdown": "markdownlint-cli2 2>&1",
"lint": "eslint --max-warnings 0 .",
@@ -82,6 +84,7 @@
"glob": "^7.1.1",
"hermes-eslint": "0.29.1",
"hermes-transform": "0.29.1",
"ini": "^5.0.0",
"inquirer": "^7.1.0",
"jest": "^29.7.0",
"jest-config": "^29.7.0",
+1 -1
View File
@@ -13,7 +13,7 @@ export type * from './index.flow';
*/
if (!process.env.BUILD_EXCLUDE_BABEL_REGISTER) {
require('../../../scripts/babel-register').registerForMonorepo();
require('../../../scripts/shared/babelRegister').registerForMonorepo();
}
module.exports = require('./index.flow');
+1 -1
View File
@@ -13,7 +13,7 @@ export type * from './index.flow';
*/
if (process.env.BUILD_EXCLUDE_BABEL_REGISTER == null) {
require('../../../scripts/babel-register').registerForMonorepo();
require('../../../scripts/shared/babelRegister').registerForMonorepo();
}
module.exports = require('./index.flow');
@@ -13,7 +13,7 @@ export type * from './version.flow';
*/
if (process.env.BUILD_EXCLUDE_BABEL_REGISTER == null) {
require('../../../../scripts/babel-register').registerForMonorepo();
require('../../../../scripts/shared/babelRegister').registerForMonorepo();
}
module.exports = require('./version.flow');
+2 -2
View File
@@ -1,5 +1,5 @@
@generated SignedSource<<8c4db6a5e1ba269169ac93cc53f95538>>
Git revision: 51a91a2ad62e7f585912ed314a350a72de84d6ed
@generated SignedSource<<1ce3fb7dd23581737fedaf58528fe575>>
Git revision: 844f225009e6445d088ed0e431d1fc430325ed95
Built with --nohooks: false
Is local checkout: false
Remote URL: https://github.com/facebook/react-native-devtools-frontend
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -13,7 +13,7 @@ export type * from './index.flow';
*/
if (!Boolean(process.env.BUILD_EXCLUDE_BABEL_REGISTER)) {
require('../../../../scripts/babel-register').registerForMonorepo();
require('../../../../scripts/shared/babelRegister').registerForMonorepo();
}
module.exports = require('./index.flow');
+1 -1
View File
@@ -13,7 +13,7 @@ export type * from './index.flow';
*/
if (!process.env.BUILD_EXCLUDE_BABEL_REGISTER) {
require('../../../../scripts/babel-register').registerForMonorepo();
require('../../../../scripts/shared/babelRegister').registerForMonorepo();
}
export * from './index.flow';
+1 -1
View File
@@ -13,7 +13,7 @@ export type * from './index.flow';
*/
if (!process.env.BUILD_EXCLUDE_BABEL_REGISTER) {
require('../../../scripts/babel-register').registerForMonorepo();
require('../../../scripts/shared/babelRegister').registerForMonorepo();
}
export * from './index.flow';
@@ -148,6 +148,7 @@ abstract class GeneratePackageListTask : DefaultTask() {
{{ packageImports }}
@SuppressWarnings("deprecation")
public class PackageList {
private Application application;
private ReactNativeHost reactNativeHost;
@@ -233,6 +233,7 @@ class GeneratePackageListTaskTest {
@SuppressWarnings("deprecation")
public class PackageList {
private Application application;
private ReactNativeHost reactNativeHost;
@@ -311,7 +312,8 @@ class GeneratePackageListTaskTest {
import com.facebook.react.aPackage;
// @react-native/another-package
import com.facebook.react.anotherPackage;
@SuppressWarnings("deprecation")
public class PackageList {
private Application application;
private ReactNativeHost reactNativeHost;
+1 -1
View File
@@ -13,7 +13,7 @@ export type * from './index.flow';
*/
if (!process.env.BUILD_EXCLUDE_BABEL_REGISTER) {
require('../../../scripts/babel-register').registerForMonorepo();
require('../../../scripts/shared/babelRegister').registerForMonorepo();
}
module.exports = require('./index.flow');
+1 -1
View File
@@ -65,7 +65,7 @@ const Links: Array<{
},
{
title: 'Community',
description: 'Expore & get help',
description: 'Explore & get help',
url: 'https://reactnative.dev/community/overview',
},
{
@@ -65,15 +65,15 @@ const TestTemplate = ({
propValue: string,
}) => `
TEST(${componentName}_${testName}, etc) {
auto propParser = RawPropsParser();
RawPropsParser propParser{};
propParser.prepare<${componentName}>();
auto const &sourceProps = ${componentName}();
auto const &rawProps = RawProps(folly::dynamic::object("${propName}", ${propValue}));
${componentName} sourceProps{};
RawProps rawProps(folly::dynamic::object("${propName}", ${propValue}));
ContextContainer contextContainer{};
PropsParserContext parserContext{-1, contextContainer};
rawProps.parse(propParser, parserContext);
rawProps.parse(propParser);
${componentName}(parserContext, sourceProps, rawProps);
}
`;
@@ -12,7 +12,9 @@ import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.uimanager.ViewManager
@Suppress("DEPRECATION")
public class OSSLibraryExamplePackage : ReactPackage {
@Deprecated("Migrate to [BaseReactPackage] and implement [getModule] instead.")
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> =
listOf(NativeSampleModule(reactContext))
@@ -84,4 +84,5 @@ Pod::Spec.new do |s|
depend_on_js_engine(s)
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -55,4 +55,5 @@ Pod::Spec.new do |s|
end
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -53,4 +53,5 @@ Pod::Spec.new do |s|
add_dependency(s, "React-NativeModulesApple")
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -50,4 +50,5 @@ Pod::Spec.new do |s|
add_dependency(s, "React-featureflags")
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -52,4 +52,5 @@ Pod::Spec.new do |s|
add_dependency(s, "React-NativeModulesApple", :additional_framework_paths => ["build/generated/ios"])
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -49,4 +49,5 @@ Pod::Spec.new do |s|
add_dependency(s, "React-NativeModulesApple", :additional_framework_paths => ["build/generated/ios"])
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -19,6 +19,8 @@ function processAspectRatio(aspectRatio?: number | string): ?number {
if (typeof aspectRatio !== 'string') {
if (__DEV__) {
invariant(
/* $FlowFixMe[constant-condition] Error discovered during Constant
* Condition roll out. See https://fburl.com/workplace/1v97vimq. */
!aspectRatio,
'aspectRatio must either be a number, a ratio string or `auto`. You passed: %s',
aspectRatio,
@@ -49,4 +49,5 @@ Pod::Spec.new do |s|
add_dependency(s, "React-NativeModulesApple")
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
+1 -4
View File
@@ -83,10 +83,6 @@ Pod::Spec.new do |s|
ss.exclude_files = exclude_files
ss.private_header_files = "React/Cxx*/*.h"
# Include prebuilt if we're not building from source
if !ReactNativeCoreUtils.build_rncore_from_source()
ss.dependency "React-Core-prebuilt", version
end
end
s.subspec "DevSupport" do |ss|
@@ -137,4 +133,5 @@ Pod::Spec.new do |s|
depend_on_js_engine(s)
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -63,4 +63,5 @@ Pod::Spec.new do |s|
add_dependency(s, "React-NativeModulesApple")
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -61,6 +61,7 @@ Pod::Spec.new do |s|
depend_on_js_engine(s)
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
s.subspec "components" do |ss|
ss.source_files = podspec_sources("FBReactNativeSpec/react/renderer/components/FBReactNativeSpec/**/*.{m,mm,cpp,h}", "FBReactNativeSpec/react/renderer/components/FBReactNativeSpec/**/*.{h}")
@@ -97,6 +97,7 @@ Pod::Spec.new do |s|
depend_on_js_engine(s)
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
s.test_spec 'Tests' do |test_spec|
test_spec.source_files = podspec_sources("Tests/**/*.{mm}", "")
@@ -68,4 +68,5 @@ Pod::Spec.new do |s|
depend_on_js_engine(s)
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -353,7 +353,7 @@ public abstract class com/facebook/react/ReactNativeHost {
}
public abstract interface class com/facebook/react/ReactPackage {
public abstract fun createNativeModules (Lcom/facebook/react/bridge/ReactApplicationContext;)Ljava/util/List;
public fun createNativeModules (Lcom/facebook/react/bridge/ReactApplicationContext;)Ljava/util/List;
public abstract fun createViewManagers (Lcom/facebook/react/bridge/ReactApplicationContext;)Ljava/util/List;
public fun getModule (Ljava/lang/String;Lcom/facebook/react/bridge/ReactApplicationContext;)Lcom/facebook/react/bridge/NativeModule;
}
@@ -1561,28 +1561,26 @@ public abstract interface class com/facebook/react/bridge/queue/MessageQueueThre
public abstract fun assertIsOnThread ()V
public abstract fun assertIsOnThread (Ljava/lang/String;)V
public abstract fun callOnQueue (Ljava/util/concurrent/Callable;)Ljava/util/concurrent/Future;
public abstract fun getPerfStats ()Lcom/facebook/react/bridge/queue/MessageQueueThreadPerfStats;
public fun getPerfStats ()Lcom/facebook/react/bridge/queue/MessageQueueThreadPerfStats;
public abstract fun isIdle ()Z
public abstract fun isOnThread ()Z
public abstract fun quitSynchronous ()V
public abstract fun resetPerfStats ()V
public fun resetPerfStats ()V
public abstract fun runOnQueue (Ljava/lang/Runnable;)Z
}
public final class com/facebook/react/bridge/queue/MessageQueueThreadImpl : com/facebook/react/bridge/queue/MessageQueueThread {
public static final field Companion Lcom/facebook/react/bridge/queue/MessageQueueThreadImpl$Companion;
public synthetic fun <init> (Ljava/lang/String;Landroid/os/Looper;Lcom/facebook/react/bridge/queue/QueueThreadExceptionHandler;Lcom/facebook/react/bridge/queue/MessageQueueThreadPerfStats;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public synthetic fun <init> (Ljava/lang/String;Landroid/os/Looper;Lcom/facebook/react/bridge/queue/QueueThreadExceptionHandler;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
public fun assertIsOnThread ()V
public fun assertIsOnThread (Ljava/lang/String;)V
public fun callOnQueue (Ljava/util/concurrent/Callable;)Ljava/util/concurrent/Future;
public static final fun create (Lcom/facebook/react/bridge/queue/MessageQueueThreadSpec;Lcom/facebook/react/bridge/queue/QueueThreadExceptionHandler;)Lcom/facebook/react/bridge/queue/MessageQueueThreadImpl;
public final fun getLooper ()Landroid/os/Looper;
public final fun getName ()Ljava/lang/String;
public fun getPerfStats ()Lcom/facebook/react/bridge/queue/MessageQueueThreadPerfStats;
public fun isIdle ()Z
public fun isOnThread ()Z
public fun quitSynchronous ()V
public fun resetPerfStats ()V
public fun runOnQueue (Ljava/lang/Runnable;)Z
}
@@ -22,6 +22,7 @@ import javax.inject.Provider
/** Abstract class that supports lazy loading of NativeModules by default. */
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.")
@@ -112,6 +112,7 @@ public abstract class HeadlessJsTaskService : Service(), HeadlessJsTaskEventList
* simply have a different mechanism for storing a `ReactNativeHost`, e.g. as a static field
* somewhere.
*/
@Suppress("DEPRECATION")
protected val reactNativeHost: ReactNativeHost
get() = (application as ReactApplication).reactNativeHost
@@ -92,6 +92,8 @@ public abstract class LazyReactPackage : ReactPackage {
* @param reactContext react application context that can be used to create modules
* @return A [List]<[NativeModule]> to register
*/
@Suppress("DEPRECATION")
@Deprecated("Migrate to [BaseReactPackage] and implement [getModule] instead.")
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> =
buildList {
for (holder in getNativeModules(reactContext)) {
@@ -18,20 +18,22 @@ import android.view.KeyEvent;
import android.view.Window;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Assertions;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.Callback;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.common.annotations.DeprecatedInNewArchitecture;
import com.facebook.react.interfaces.fabric.ReactSurface;
import com.facebook.react.internal.featureflags.ReactNativeNewArchitectureFeatureFlags;
import com.facebook.react.modules.core.PermissionListener;
import com.facebook.react.views.view.WindowUtilKt;
import com.facebook.systrace.Systrace;
import java.util.Objects;
/**
* Delegate class for {@link ReactActivity}. You can subclass this to provide custom implementations
* for e.g. {@link #getReactNativeHost()}, if your Application class doesn't implement {@link
* ReactApplication}.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
public class ReactActivityDelegate {
private final @Nullable Activity mActivity;
@@ -86,8 +88,11 @@ public class ReactActivityDelegate {
* ReactApplication#getReactNativeHost()}. Override this method if your application class does not
* implement {@code ReactApplication} or you simply have a different mechanism for storing a
* {@code ReactNativeHost}, e.g. as a static field somewhere.
*
* @deprecated "Do not access {@link ReactNativeHost} directly. This class is going away in the
* New Architecture. You should access {@link ReactHost} instead."
*/
@DeprecatedInNewArchitecture(message = "Use getReactHost()")
@Deprecated
protected ReactNativeHost getReactNativeHost() {
return ((ReactApplication) getPlainActivity().getApplication()).getReactNativeHost();
}
@@ -107,16 +112,21 @@ public class ReactActivityDelegate {
return mReactDelegate;
}
@DeprecatedInNewArchitecture(message = "Use getReactHost()")
/**
* @deprecated @deprecated "Do not access {@link ReactInstanceManager} directly. This class is
* going away in the New Architecture. You should access {@link ReactHost} instead."
* @noinspection deprecation
*/
public ReactInstanceManager getReactInstanceManager() {
return mReactDelegate.getReactInstanceManager();
return Objects.requireNonNull(mReactDelegate).getReactInstanceManager();
}
@Nullable
public String getMainComponentName() {
return mMainComponentName;
}
public void onCreate(Bundle savedInstanceState) {
public void onCreate(@Nullable Bundle savedInstanceState) {
Systrace.traceSection(
Systrace.TRACE_TAG_REACT,
"ReactActivityDelegate.onCreate::init",
@@ -147,6 +157,7 @@ public class ReactActivityDelegate {
launchOptions,
isFabricEnabled()) {
@Override
@Nullable
protected ReactRootView createRootView() {
ReactRootView rootView = ReactActivityDelegate.this.createRootView();
if (rootView == null) {
@@ -162,31 +173,29 @@ public class ReactActivityDelegate {
});
}
protected void loadApp(String appKey) {
mReactDelegate.loadApp(appKey);
protected void loadApp(@Nullable String appKey) {
Objects.requireNonNull(mReactDelegate).loadApp(Objects.requireNonNull(appKey));
getPlainActivity().setContentView(mReactDelegate.getReactRootView());
}
public void setReactSurface(ReactSurface reactSurface) {
mReactDelegate.setReactSurface(reactSurface);
Objects.requireNonNull(mReactDelegate).setReactSurface(reactSurface);
}
public void setReactRootView(ReactRootView reactRootView) {
mReactDelegate.setReactRootView(reactRootView);
Objects.requireNonNull(mReactDelegate).setReactRootView(reactRootView);
}
public void onUserLeaveHint() {
if (mReactDelegate != null) {
mReactDelegate.onUserLeaveHint();
}
Objects.requireNonNull(mReactDelegate).onUserLeaveHint();
}
public void onPause() {
mReactDelegate.onHostPause();
Objects.requireNonNull(mReactDelegate).onHostPause();
}
public void onResume() {
mReactDelegate.onHostResume();
Objects.requireNonNull(mReactDelegate).onHostResume();
if (mPermissionsCallback != null) {
mPermissionsCallback.invoke();
@@ -195,43 +204,43 @@ public class ReactActivityDelegate {
}
public void onDestroy() {
mReactDelegate.onHostDestroy();
Objects.requireNonNull(mReactDelegate).onHostDestroy();
}
public void onActivityResult(int requestCode, int resultCode, Intent data) {
mReactDelegate.onActivityResult(requestCode, resultCode, data, true);
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
Objects.requireNonNull(mReactDelegate).onActivityResult(requestCode, resultCode, data, true);
}
public boolean onKeyDown(int keyCode, KeyEvent event) {
return mReactDelegate.onKeyDown(keyCode, event);
return Objects.requireNonNull(mReactDelegate).onKeyDown(keyCode, event);
}
public boolean onKeyUp(int keyCode, KeyEvent event) {
return mReactDelegate.shouldShowDevMenuOrReload(keyCode, event);
return Objects.requireNonNull(mReactDelegate).shouldShowDevMenuOrReload(keyCode, event);
}
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
return mReactDelegate.onKeyLongPress(keyCode);
return Objects.requireNonNull(mReactDelegate).onKeyLongPress(keyCode);
}
public boolean onBackPressed() {
return mReactDelegate.onBackPressed();
return Objects.requireNonNull(mReactDelegate).onBackPressed();
}
public boolean onNewIntent(Intent intent) {
return mReactDelegate.onNewIntent(intent);
public boolean onNewIntent(@Nullable Intent intent) {
return Objects.requireNonNull(mReactDelegate).onNewIntent(Objects.requireNonNull(intent));
}
public void onWindowFocusChanged(boolean hasFocus) {
mReactDelegate.onWindowFocusChanged(hasFocus);
Objects.requireNonNull(mReactDelegate).onWindowFocusChanged(hasFocus);
}
public void onConfigurationChanged(Configuration newConfig) {
mReactDelegate.onConfigurationChanged(newConfig);
Objects.requireNonNull(mReactDelegate).onConfigurationChanged(newConfig);
}
public void requestPermissions(
String[] permissions, int requestCode, PermissionListener listener) {
String[] permissions, int requestCode, @Nullable PermissionListener listener) {
mPermissionListener = listener;
getPlainActivity().requestPermissions(permissions, requestCode);
}
@@ -267,7 +276,7 @@ public class ReactActivityDelegate {
* context will no longer be valid.
*/
public @Nullable ReactContext getCurrentReactContext() {
return mReactDelegate.getCurrentReactContext();
return Objects.requireNonNull(mReactDelegate).getCurrentReactContext();
}
/**
@@ -10,6 +10,10 @@ package com.facebook.react
/** Interface that represents an instance of a React Native application */
public interface ReactApplication {
/** Get the default [ReactNativeHost] for this app. */
@Suppress("DEPRECATION")
@Deprecated(
"You should not use ReactNativeHost directly in the New Architecture. Use ReactHost instead.",
ReplaceWith("reactHost"))
public val reactNativeHost: ReactNativeHost
/**
@@ -14,7 +14,6 @@ import android.os.Bundle
import android.view.KeyEvent
import com.facebook.react.bridge.ReactContext
import com.facebook.react.bridge.UiThreadUtil.runOnUiThread
import com.facebook.react.common.annotations.DeprecatedInNewArchitecture
import com.facebook.react.devsupport.DoubleTapReloadRecognizer
import com.facebook.react.devsupport.ReleaseDevSupportManager
import com.facebook.react.devsupport.interfaces.DevSupportManager
@@ -26,12 +25,17 @@ import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler
* A delegate for handling React Application support. This delegate is unaware whether it is used in
* an [Activity] or a [android.app.Fragment].
*/
@Suppress("DEPRECATION")
public open class ReactDelegate {
private val activity: Activity
private var internalReactRootView: ReactRootView? = null
private val mainComponentName: String?
private var launchOptions: Bundle?
private var doubleTapReloadRecognizer: DoubleTapReloadRecognizer?
@Deprecated(
"You should not use ReactNativeHost directly in the New Architecture. Use ReactHost instead.",
ReplaceWith("reactHost"))
private var reactNativeHost: ReactNativeHost? = null
public var reactHost: ReactHost? = null
private set
@@ -380,7 +384,8 @@ public open class ReactDelegate {
return false
}
@DeprecatedInNewArchitecture(message = "Use reactHost")
@Deprecated(
"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) {
@@ -58,6 +58,10 @@ public open class ReactFragment : Fragment(), PermissionAwareActivity {
* method if your application class does not implement `ReactApplication` or you simply have a
* different mechanism for storing a `ReactNativeHost`, e.g. as a static field somewhere.
*/
@Suppress("DEPRECATION")
@Deprecated(
"You should not use ReactNativeHost directly in the New Architecture. Use ReactHost instead.",
ReplaceWith("reactHost"))
protected open val reactNativeHost: ReactNativeHost?
get() = (activity?.application as ReactApplication?)?.reactNativeHost
@@ -10,6 +10,7 @@ package com.facebook.react;
import android.app.Application;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Assertions;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.JSExceptionHandler;
import com.facebook.react.bridge.JavaScriptExecutorFactory;
import com.facebook.react.bridge.ReactMarker;
@@ -18,7 +19,6 @@ import com.facebook.react.bridge.UIManagerProvider;
import com.facebook.react.common.LifecycleState;
import com.facebook.react.common.SurfaceDelegate;
import com.facebook.react.common.SurfaceDelegateFactory;
import com.facebook.react.common.annotations.DeprecatedInNewArchitecture;
import com.facebook.react.common.annotations.internal.LegacyArchitecture;
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel;
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger;
@@ -32,12 +32,12 @@ import java.util.List;
/**
* Simple class that holds an instance of {@link ReactInstanceManager}. This can be used in your
* {@link Application class} (see {@link ReactApplication}), or as a static field.
*
* @deprecated This class will be replaced by com.facebook.react.ReactHost in the New Architecture.
*/
@DeprecatedInNewArchitecture(
message =
"This class will be replaced by com.facebook.react.ReactHost in the new architecture of"
+ " React Native.")
@Deprecated
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Nullsafe(Nullsafe.Mode.LOCAL)
public abstract class ReactNativeHost {
static {
@@ -10,7 +10,6 @@ package com.facebook.react
import com.facebook.react.bridge.NativeModule
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.UIManager
import com.facebook.react.common.annotations.DeprecatedInNewArchitecture
import com.facebook.react.common.annotations.StableReactNativeAPI
import com.facebook.react.uimanager.ViewManager
@@ -34,8 +33,9 @@ public interface ReactPackage {
* @return list of native modules to register with the newly created catalyst instance This method
* is deprecated in the new Architecture of React Native.
*/
@DeprecatedInNewArchitecture(message = "Migrate to BaseReactPackage and implement getModule")
public fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule>
@Deprecated(message = "Migrate to [BaseReactPackage] and implement [getModule] instead.")
public fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> =
emptyList()
/** @return a list of view managers that should be registered with [UIManager] */
public fun createViewManagers(
@@ -28,6 +28,7 @@ internal object ReactPackageHelper {
FLog.d(
ReactConstants.TAG,
"${reactPackage.javaClass.simpleName} is not a LazyReactPackage, falling back to old version.")
@Suppress("DEPRECATION")
val nativeModules = reactPackage.createNativeModules(reactApplicationContext)
return Iterable {
object : Iterator<ModuleHolder> {
@@ -83,6 +83,7 @@ public abstract class ReactPackageTurboModuleManagerDelegate : TurboModuleManage
if (shouldSupportLegacyPackages()) {
// TODO(T145105887): Output warnings that ReactPackage was used
@Suppress("DEPRECATION")
val nativeModules = reactPackage.createNativeModules(reactApplicationContext)
val moduleMap: MutableMap<String, NativeModule> = mutableMapOf()
@@ -94,6 +95,7 @@ public abstract class ReactPackageTurboModuleManagerDelegate : TurboModuleManage
val moduleName = reactModule?.name ?: module.name
@Suppress("DEPRECATION")
val moduleInfo: ReactModuleInfo =
if (reactModule != null)
ReactModuleInfo(
@@ -16,7 +16,6 @@ import com.facebook.infer.annotation.Nullsafe;
import com.facebook.infer.annotation.ThreadConfined;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.annotations.DeprecatedInNewArchitecture;
import com.facebook.react.common.annotations.StableReactNativeAPI;
import com.facebook.react.common.build.ReactBuildConfig;
import java.util.Map;
@@ -72,7 +71,6 @@ public abstract class BaseJavaModule implements NativeModule {
/**
* @return a map of constants this module exports to JS. Supports JSON types.
*/
@DeprecatedInNewArchitecture()
public @Nullable Map<String, Object> getConstants() {
return null;
}
@@ -14,11 +14,11 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.facebook.common.logging.FLog;
import com.facebook.infer.annotation.Assertions;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.infer.annotation.ThreadConfined;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.bridge.queue.ReactQueueConfiguration;
import com.facebook.react.common.ReactConstants;
import com.facebook.react.common.annotations.DeprecatedInNewArchitecture;
import com.facebook.react.common.annotations.FrameworkAPI;
import com.facebook.react.common.annotations.UnstableReactNativeAPI;
import com.facebook.react.common.annotations.VisibleForTesting;
@@ -27,16 +27,21 @@ import com.facebook.react.common.annotations.internal.LegacyArchitectureLogLevel
import com.facebook.react.common.annotations.internal.LegacyArchitectureLogger;
import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder;
import java.util.Collection;
import java.util.Objects;
/**
* This is the bridge-specific concrete subclass of ReactContext. ReactContext has many methods that
* delegate to the react instance. This subclass implements those methods, by delegating to the
* CatalystInstance. If you need to create a ReactContext within an "bridge context", please create
* BridgeReactContext.
*
* @deprecated This class is deprecated in the New Architecture and will be replaced by {@link
* com.facebook.react.runtime.BridgelessReactContext}
*/
@DeprecatedInNewArchitecture
@VisibleForTesting
@LegacyArchitecture(logLevel = LegacyArchitectureLogLevel.ERROR)
@Deprecated
@Nullsafe(Nullsafe.Mode.LOCAL)
public class BridgeReactContext extends ReactApplicationContext {
static {
LegacyArchitectureLogger.assertLegacyArchitecture(
@@ -119,6 +124,7 @@ public class BridgeReactContext extends ReactApplicationContext {
if (mCatalystInstance == null) {
raiseCatalystInstanceMissingException();
}
Assertions.assertNotNull(mCatalystInstance);
return mCatalystInstance.hasNativeModule(nativeModuleInterface);
}
@@ -127,6 +133,7 @@ public class BridgeReactContext extends ReactApplicationContext {
if (mCatalystInstance == null) {
raiseCatalystInstanceMissingException();
}
Assertions.assertNotNull(mCatalystInstance);
return mCatalystInstance.getNativeModules();
}
@@ -139,6 +146,7 @@ public class BridgeReactContext extends ReactApplicationContext {
if (mCatalystInstance == null) {
raiseCatalystInstanceMissingException();
}
Assertions.assertNotNull(mCatalystInstance);
return mCatalystInstance.getNativeModule(nativeModuleInterface);
}
@@ -147,6 +155,7 @@ public class BridgeReactContext extends ReactApplicationContext {
if (mCatalystInstance == null) {
raiseCatalystInstanceMissingException();
}
Assertions.assertNotNull(mCatalystInstance);
return mCatalystInstance.getNativeModule(moduleName);
}
@@ -210,8 +219,7 @@ public class BridgeReactContext extends ReactApplicationContext {
@Override
public void handleException(Exception e) {
boolean catalystInstanceVariableExists = mCatalystInstance != null;
boolean isCatalystInstanceAlive =
catalystInstanceVariableExists && !mCatalystInstance.isDestroyed();
boolean isCatalystInstanceAlive = mCatalystInstance != null && !mCatalystInstance.isDestroyed();
boolean hasExceptionHandler = getJSExceptionHandler() != null;
if (isCatalystInstanceAlive && hasExceptionHandler) {
@@ -268,18 +276,19 @@ public class BridgeReactContext extends ReactApplicationContext {
return null;
}
@DeprecatedInNewArchitecture(
message =
"This method will be deprecated later as part of Stable APIs with bridge removal and not"
+ " encouraged usage.")
/**
* Get the UIManager for Fabric from the CatalystInstance.
*
* @return The UIManager when CatalystInstance is active.
* @deprecated Do not use this method. Instead use {@link
* com.facebook.react.uimanager.UIManagerHelper} method {@code getUIManager} to get the
* UIManager instance from the current ReactContext.
*/
@Override
@Deprecated
public @Nullable UIManager getFabricUIManager() {
return mCatalystInstance.getFabricUIManager();
//noinspection deprecation
return Objects.requireNonNull(mCatalystInstance).getFabricUIManager();
}
/**
@@ -32,6 +32,8 @@ protected constructor(
// do nothing
}
@Deprecated(
"The method canOverrideExistingModule is not used in the New Architecture and will be removed in a future release.")
override fun canOverrideExistingModule(): Boolean = false
override fun invalidate() {
@@ -53,6 +53,7 @@ public class ModuleHolder {
public constructor(nativeModule: NativeModule) {
name = nativeModule.name
@Suppress("DEPRECATION")
reactModuleInfo =
ReactModuleInfo(
nativeModule.name,
@@ -9,7 +9,6 @@ package com.facebook.react.bridge;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.proguard.annotations.DoNotStrip;
import com.facebook.react.common.annotations.DeprecatedInNewArchitecture;
import com.facebook.react.common.annotations.StableReactNativeAPI;
import javax.annotation.Nonnull;
@@ -50,8 +49,11 @@ public interface NativeModule {
* of a different package (such as the core one). Trying to override without returning true from
* this method is considered an error and will throw an exception during initialization. By
* default all modules return false.
*
* @deprecated The method canOverrideExistingModule is not used in the New Architecture and will
* be removed in a future release.
*/
@DeprecatedInNewArchitecture()
@Deprecated
default boolean canOverrideExistingModule() {
return false;
}
@@ -108,14 +108,8 @@ public abstract class ReactContext extends ContextWrapper {
mInteropModuleRegistry = new InteropModuleRegistry();
}
public void resetPerfStats() {
if (mNativeModulesMessageQueueThread != null) {
mNativeModulesMessageQueueThread.resetPerfStats();
}
if (mJSMessageQueueThread != null) {
mJSMessageQueueThread.resetPerfStats();
}
}
@Deprecated(since = "MessageQueueThread perf stats are no longer collected")
public void resetPerfStats() {}
public void setJSExceptionHandler(@Nullable JSExceptionHandler jSExceptionHandler) {
mJSExceptionHandler = jSExceptionHandler;
@@ -55,13 +55,16 @@ public interface MessageQueueThread {
* Returns the perf counters taken when the framework was started. This method is intended to be
* used for instrumentation purposes.
*/
public fun getPerfStats(): MessageQueueThreadPerfStats?
@Deprecated("MessageQueueThread perf stats are no longer collected")
@Suppress("DEPRECATION")
public fun getPerfStats(): MessageQueueThreadPerfStats? = null
/**
* Resets the perf counters. This is useful if the RN threads are being re-used. This method is
* intended to be used for instrumentation purposes.
*/
public fun resetPerfStats()
@Deprecated("MessageQueueThread perf stats are no longer collected")
public fun resetPerfStats(): Unit = Unit
/**
* Resets the perf counters. This is useful if the RN threads are being re-used. This method is
@@ -9,8 +9,6 @@ package com.facebook.react.bridge.queue
import android.os.Looper
import android.os.Process
import android.os.SystemClock
import android.util.Pair
import com.facebook.common.logging.FLog
import com.facebook.proguard.annotations.DoNotStripAny
import com.facebook.react.bridge.AssertionException
@@ -29,7 +27,6 @@ private constructor(
public val name: String,
public val looper: Looper,
exceptionHandler: QueueThreadExceptionHandler,
private val stats: MessageQueueThreadPerfStats? = null
) : MessageQueueThread {
private val handler = MessageQueueThreadHandler(looper, exceptionHandler)
private val assertionErrorMessage = "Expected to be called from the '$name' thread!"
@@ -105,27 +102,9 @@ private constructor(
}
}
override fun getPerfStats(): MessageQueueThreadPerfStats? = stats
override fun resetPerfStats() {
assignToPerfStats(stats, -1, -1)
runOnQueue {
val wallTime = SystemClock.uptimeMillis()
val cpuTime = SystemClock.currentThreadTimeMillis()
assignToPerfStats(stats, wallTime, cpuTime)
}
}
public override fun isIdle(): Boolean = looper.queue.isIdle
public companion object {
private fun assignToPerfStats(stats: MessageQueueThreadPerfStats?, wall: Long, cpu: Long) {
stats?.let { s ->
s.wallTime = wall
s.cpuTime = cpu
}
}
@JvmStatic
@Throws(RuntimeException::class)
public fun create(
@@ -160,27 +139,23 @@ private constructor(
stackSize: Long,
exceptionHandler: QueueThreadExceptionHandler
): MessageQueueThreadImpl {
val dataFuture = SimpleSettableFuture<Pair<Looper?, MessageQueueThreadPerfStats>>()
val looperFuture = SimpleSettableFuture<Looper?>()
val bgThread =
Thread(
null,
{
Process.setThreadPriority(Process.THREAD_PRIORITY_DISPLAY)
Looper.prepare()
val stats = MessageQueueThreadPerfStats()
val wallTime = SystemClock.uptimeMillis()
val cpuTime = SystemClock.currentThreadTimeMillis()
assignToPerfStats(stats, wallTime, cpuTime)
dataFuture.set(Pair(Looper.myLooper(), stats))
looperFuture.set(Looper.myLooper())
Looper.loop()
},
"mqt_$name",
stackSize)
bgThread.start()
val pair = dataFuture.getOrThrow()
val looper = pair?.first ?: throw RuntimeException("Looper not found for thread")
return MessageQueueThreadImpl(name, looper, exceptionHandler, pair.second)
val looper =
looperFuture.getOrThrow() ?: throw RuntimeException("Looper not found for thread")
return MessageQueueThreadImpl(name, looper, exceptionHandler)
}
}
}
@@ -8,6 +8,7 @@
package com.facebook.react.bridge.queue
/** This class holds perf counters' values at the beginning of an RN startup. */
@Deprecated("MessageQueueThread perf stats are no longer collected")
public class MessageQueueThreadPerfStats {
@JvmField public var wallTime: Long = 0
@JvmField public var cpuTime: Long = 0
@@ -26,6 +26,7 @@ private constructor(
public const val DEFAULT_STACK_SIZE_BYTES: Long = 0
@JvmStatic
@Deprecated("Use newBackgroundThreadSpec")
public fun newUIBackgroundTreadSpec(name: String): MessageQueueThreadSpec =
MessageQueueThreadSpec(ThreadType.NEW_BACKGROUND, name)
@@ -1,16 +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.common.annotations
/**
* Annotates a method or class that will be deprecated once the NewArchitecture is fully released in
* OSS.
*/
@Retention(AnnotationRetention.SOURCE)
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
internal annotation class DeprecatedInNewArchitecture(val message: String = "")
@@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react.defaults
import android.content.Context
@@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react.defaults
import android.app.Application
@@ -53,7 +53,7 @@ public class BlobProvider : ContentProvider() {
var blobModule: BlobModule? = null
val context = context?.applicationContext
if (context is ReactApplication) {
val host = (context as ReactApplication).reactNativeHost
@Suppress("DEPRECATION") val host = (context as ReactApplication).reactNativeHost
val reactContext =
host.reactInstanceManager.currentReactContext
?: throw RuntimeException("No ReactContext associated with BlobProvider")
@@ -829,13 +829,6 @@ public class ReactHostImpl(
null
},
executor)
.continueWith({ task: Task<Void> ->
// TODO: validate whether errors during startup go through here?
if (task.isFaulted()) {
handleHostException(checkNotNull(task.getError()))
}
null
})
private fun getOrCreateReactContext(): BridgelessReactContext {
val method = "getOrCreateReactContext()"
@@ -952,9 +945,14 @@ public class ReactHostImpl(
},
bgExecutor)
val lifecycleUpdateTask = { task: Task<CreationResult> ->
val lifecycleUpdateTask = task@{ task: Task<CreationResult> ->
if (task.isFaulted()) {
// handleHostException may throw, so move it outside of the task scheduler
uiExecutor.execute { handleHostException(checkNotNull(task.getError())) }
return@task
}
val result = checkNotNull(task.getResult())
val reactInstance = result.instance
val reactContext = result.context
val isReloading = result.isReloading
val isManagerResumed = reactLifecycleStateManager.lifecycleState == LifecycleState.RESUMED
@@ -991,10 +989,9 @@ public class ReactHostImpl(
for (listener in reactInstanceEventListeners) {
listener.onReactContextInitialized(reactContext)
}
reactInstance
}
creationTask.onSuccess(lifecycleUpdateTask, uiExecutor)
creationTask.continueWith(lifecycleUpdateTask, uiExecutor)
creationTask.onSuccess({ task -> checkNotNull(task.getResult()).instance })
}
}
@@ -10,7 +10,6 @@ package com.facebook.react.uimanager
import android.view.View
import com.facebook.common.logging.FLog
import com.facebook.react.bridge.ReadableArray
import com.facebook.react.common.annotations.DeprecatedInNewArchitecture
import com.facebook.react.uimanager.ViewManagersPropertyCache.PropSetter
import java.util.HashMap
@@ -70,8 +69,8 @@ public object ViewManagerPropertyUpdater {
}
}
@DeprecatedInNewArchitecture
@JvmStatic
@Deprecated("Use ViewManager#updateProperties to update a view's properties")
public fun <T : ReactShadowNode<T>> updateProps(node: T, props: ReactStylesDiffMap) {
val setter = findNodeSetter(node.javaClass)
val iterator = props.backingMap.entryIterator
@@ -8,12 +8,10 @@
package com.facebook.react.uimanager.common
import androidx.annotation.IntDef
import com.facebook.react.common.annotations.DeprecatedInNewArchitecture
@Retention(AnnotationRetention.SOURCE)
@Suppress("DEPRECATION")
@IntDef(UIManagerType.DEFAULT, UIManagerType.LEGACY, UIManagerType.FABRIC)
@DeprecatedInNewArchitecture
public annotation class UIManagerType {
public companion object {
@Deprecated(
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.views.virtualview
package com.facebook.react.views.virtual
internal enum class VirtualViewMode(val value: Int) {
Visible(0),
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.views.virtualview
package com.facebook.react.views.virtual
import android.graphics.Rect
import androidx.annotation.VisibleForTesting
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.views.virtualview
package com.facebook.react.views.virtual
/**
* Represents the the render state of children in the most recent commit.
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.views.virtualview
package com.facebook.react.views.virtual.view
import android.content.Context
import android.graphics.Rect
@@ -24,6 +24,8 @@ import com.facebook.react.views.scroll.ReactScrollView
import com.facebook.react.views.scroll.ReactScrollViewHelper
import com.facebook.react.views.scroll.ScrollEventType
import com.facebook.react.views.view.ReactViewGroup
import com.facebook.react.views.virtual.VirtualViewMode
import com.facebook.react.views.virtual.VirtualViewRenderState
import com.facebook.systrace.Systrace
internal class ReactVirtualView(context: Context) :
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.views.virtualview
package com.facebook.react.views.virtual.view
import android.graphics.Rect
import androidx.annotation.VisibleForTesting
@@ -19,6 +19,9 @@ import com.facebook.react.uimanager.annotations.ReactProp
import com.facebook.react.uimanager.events.EventDispatcher
import com.facebook.react.viewmanagers.VirtualViewManagerDelegate
import com.facebook.react.viewmanagers.VirtualViewManagerInterface
import com.facebook.react.views.virtual.VirtualViewMode
import com.facebook.react.views.virtual.VirtualViewModeChangeEvent
import com.facebook.react.views.virtual.VirtualViewRenderState
@ReactModule(name = ReactVirtualViewManager.REACT_CLASS)
internal class ReactVirtualViewManager :
@@ -18,11 +18,9 @@ import android.view.WindowManager
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.BridgeReactContext
import com.facebook.react.bridge.CatalystInstance
import com.facebook.react.bridge.JavaOnlyArray
import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.ReactTestHelper
import com.facebook.react.bridge.WritableArray
import com.facebook.react.bridge.WritableMap
import com.facebook.react.common.SystemClock
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsForTests
import com.facebook.react.uimanager.DisplayMetricsHolder
@@ -30,14 +28,12 @@ import com.facebook.react.uimanager.UIManagerModule
import com.facebook.react.uimanager.events.EventDispatcher
import com.facebook.react.uimanager.events.RCTEventEmitter
import com.facebook.react.uimanager.events.TouchEvent
import com.facebook.testutils.shadows.ShadowArguments
import java.util.Date
import org.assertj.core.api.Assertions.*
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.MockedStatic
import org.mockito.Mockito.mockStatic
import org.mockito.kotlin.KArgumentCaptor
import org.mockito.kotlin.any
import org.mockito.kotlin.argumentCaptor
@@ -52,16 +48,15 @@ import org.mockito.kotlin.whenever
import org.robolectric.Robolectric
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
@Config(shadows = [ShadowArguments::class])
@RunWith(RobolectricTestRunner::class)
class RootViewTest {
private lateinit var reactContext: BridgeReactContext
private lateinit var catalystInstanceMock: CatalystInstance
private lateinit var arguments: MockedStatic<Arguments>
private lateinit var systemClock: MockedStatic<SystemClock>
private lateinit var downEventCaptor: KArgumentCaptor<TouchEvent>
private lateinit var downActionTouchesArgCaptor: KArgumentCaptor<WritableArray>
@@ -72,14 +67,6 @@ class RootViewTest {
fun setUp() {
ReactNativeFeatureFlagsForTests.setUp()
arguments = mockStatic(Arguments::class.java)
arguments.`when`<WritableArray> { Arguments.createArray() }.thenAnswer { JavaOnlyArray() }
arguments.`when`<WritableMap> { Arguments.createMap() }.thenAnswer { JavaOnlyMap() }
val ts = SystemClock.uptimeMillis()
systemClock = mockStatic(SystemClock::class.java)
systemClock.`when`<Long> { SystemClock.uptimeMillis() }.thenReturn(ts)
catalystInstanceMock = ReactTestHelper.createMockCatalystInstance()
reactContext = spy(BridgeReactContext(RuntimeEnvironment.getApplication()))
reactContext.initializeWithInstance(catalystInstanceMock)
@@ -96,12 +83,6 @@ class RootViewTest {
upActionTouchesArgCaptor = argumentCaptor()
}
@After
fun tearDown() {
systemClock.close()
arguments.close()
}
@Test
fun testTouchEmitter() {
val instanceManager: ReactInstanceManager = mock()
@@ -10,23 +10,20 @@
package com.facebook.react.animated
import android.annotation.SuppressLint
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.Callback
import com.facebook.react.bridge.CatalystInstance
import com.facebook.react.bridge.JavaOnlyArray
import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.bridge.WritableArray
import com.facebook.react.bridge.WritableMap
import com.facebook.react.uimanager.UIManagerModule
import com.facebook.react.uimanager.events.Event
import com.facebook.react.uimanager.events.EventDispatcher
import com.facebook.react.uimanager.events.RCTEventEmitter
import com.facebook.testutils.shadows.ShadowArguments
import kotlin.collections.Map
import kotlin.math.abs
import org.assertj.core.api.Assertions.assertThat
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@@ -34,8 +31,6 @@ import org.mockito.ArgumentCaptor
import org.mockito.ArgumentMatchers.any
import org.mockito.ArgumentMatchers.anyInt
import org.mockito.ArgumentMatchers.eq
import org.mockito.MockedStatic
import org.mockito.Mockito.mockStatic
import org.mockito.kotlin.atMost
import org.mockito.kotlin.mock
import org.mockito.kotlin.reset
@@ -44,8 +39,10 @@ import org.mockito.kotlin.verify
import org.mockito.kotlin.verifyNoMoreInteractions
import org.mockito.kotlin.whenever
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
/** Tests the animated nodes graph traversal algorithm from {@link NativeAnimatedNodesManager}. */
@Config(shadows = [ShadowArguments::class])
@RunWith(RobolectricTestRunner::class)
class NativeAnimatedNodeTraversalTest {
@@ -55,7 +52,6 @@ class NativeAnimatedNodeTraversalTest {
private lateinit var uiManagerMock: UIManagerModule
private lateinit var eventDispatcherMock: EventDispatcher
private lateinit var nativeAnimatedNodesManager: NativeAnimatedNodesManager
private lateinit var arguments: MockedStatic<Arguments>
private fun nextFrameTime(): Long {
frameTimeNanos += FRAME_LEN_NANOS
@@ -64,10 +60,6 @@ class NativeAnimatedNodeTraversalTest {
@Before
fun setUp() {
arguments = mockStatic(Arguments::class.java)
arguments.`when`<WritableArray> { Arguments.createArray() }.thenAnswer { JavaOnlyArray() }
arguments.`when`<WritableMap> { Arguments.createMap() }.thenAnswer { JavaOnlyMap() }
frameTimeNanos = INITIAL_FRAME_TIME_NANOS
reactApplicationContextMock = mock<ReactApplicationContext>()
@@ -113,11 +105,6 @@ class NativeAnimatedNodeTraversalTest {
nativeAnimatedNodesManager = NativeAnimatedNodesManager(reactApplicationContextMock)
}
@After
fun tearDown() {
arguments.close()
}
/**
* Generates a simple animated nodes graph and attaches the props node to a given {@param viewTag}
* Parameter {@param opacity} is used as a initial value for the "opacity" attribute.
@@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react.fabric
import com.facebook.react.bridge.BridgeReactContext
@@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react.fabric
import com.facebook.react.ReactRootView
@@ -11,12 +11,10 @@ import android.util.DisplayMetrics
import android.view.MotionEvent
import android.view.MotionEvent.PointerCoords
import android.view.MotionEvent.PointerProperties
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.JavaOnlyArray
import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.ReactTestHelper
import com.facebook.react.bridge.ReadableMap
import com.facebook.react.bridge.WritableArray
import com.facebook.react.bridge.WritableMap
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsForTests
import com.facebook.react.modules.core.ReactChoreographer
@@ -26,6 +24,7 @@ import com.facebook.react.uimanager.events.FabricEventDispatcher
import com.facebook.react.uimanager.events.TouchEvent
import com.facebook.react.uimanager.events.TouchEventCoalescingKeyHelper
import com.facebook.react.uimanager.events.TouchEventType
import com.facebook.testutils.shadows.ShadowArguments
import com.facebook.testutils.shadows.ShadowSoLoader
import org.assertj.core.api.Assertions.assertThat
import org.junit.After
@@ -34,8 +33,6 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.ArgumentMatchers.*
import org.mockito.MockedStatic
import org.mockito.Mockito.mockStatic
import org.mockito.kotlin.mock
import org.mockito.kotlin.times
import org.mockito.kotlin.verify
@@ -43,7 +40,7 @@ import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(shadows = [ShadowSoLoader::class])
@Config(shadows = [ShadowSoLoader::class, ShadowArguments::class])
class TouchEventDispatchTest {
private val touchEventCoalescingKeyHelper = TouchEventCoalescingKeyHelper()
@@ -460,16 +457,12 @@ class TouchEventDispatchTest {
private lateinit var eventDispatcher: EventDispatcher
private lateinit var eventEmitter: FabricEventEmitter
private lateinit var arguments: MockedStatic<Arguments>
private var reactChoreographerOriginal: ReactChoreographer? = null
@Before
fun setUp() {
ReactNativeFeatureFlagsForTests.setUp()
arguments = mockStatic(Arguments::class.java)
arguments.`when`<WritableArray> { Arguments.createArray() }.thenAnswer { JavaOnlyArray() }
arguments.`when`<WritableMap> { Arguments.createMap() }.thenAnswer { JavaOnlyMap() }
val metrics = DisplayMetrics()
metrics.xdpi = 1f
metrics.ydpi = 1f
@@ -488,7 +481,6 @@ class TouchEventDispatchTest {
@After
fun tearDown() {
arguments.close()
ReactChoreographer.overrideInstanceForTest(reactChoreographerOriginal)
}
@@ -9,49 +9,39 @@ package com.facebook.react.modules.appstate
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.Callback
import com.facebook.react.bridge.JavaOnlyArray
import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.WritableArray
import com.facebook.react.bridge.WritableMap
import com.facebook.testutils.shadows.ShadowArguments
import org.assertj.core.api.Assertions.assertThat
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.MockedStatic
import org.mockito.Mockito.mockStatic
import org.mockito.kotlin.any
import org.mockito.kotlin.mock
import org.mockito.kotlin.never
import org.mockito.kotlin.times
import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
@Config(shadows = [ShadowArguments::class])
@RunWith(RobolectricTestRunner::class)
class AppStateModuleTest {
private lateinit var appStateModule: AppStateModule
private lateinit var reactContext: ReactApplicationContext
private lateinit var arguments: MockedStatic<Arguments>
@Before
fun setUp() {
reactContext = mock()
appStateModule = AppStateModule(reactContext)
arguments = mockStatic(Arguments::class.java)
arguments.`when`<WritableArray>(Arguments::createArray).thenAnswer { JavaOnlyArray() }
arguments.`when`<WritableMap>(Arguments::createMap).thenAnswer { JavaOnlyMap() }
// we check whether we have an active react instance before emitting an event,
// therefore for the tests we need this returning `true`.
whenever(reactContext.hasActiveReactInstance()).thenReturn(true)
}
@After
fun tearDown() {
arguments.close()
}
@Test
fun testGetCurrentAppState() {
val successCallbackMock: Callback = mock()
@@ -8,11 +8,9 @@
package com.facebook.react.modules.blob
import android.net.Uri
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.JavaOnlyArray
import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.ReactTestHelper
import com.facebook.react.bridge.WritableMap
import java.nio.ByteBuffer
import java.util.UUID
import kotlin.random.Random
@@ -21,8 +19,6 @@ import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.MockedStatic
import org.mockito.Mockito.mockStatic
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
@@ -32,13 +28,9 @@ class BlobModuleTest {
private lateinit var bytes: ByteArray
private lateinit var blobId: String
private lateinit var blobModule: BlobModule
private lateinit var arguments: MockedStatic<Arguments>
@Before
fun prepareModules() {
arguments = mockStatic(Arguments::class.java)
arguments.`when`<WritableMap> { Arguments.createMap() }.thenAnswer { JavaOnlyMap() }
bytes = ByteArray(120)
Random.Default.nextBytes(bytes)
@@ -49,7 +41,6 @@ class BlobModuleTest {
@After
fun cleanUp() {
blobModule.remove(blobId)
arguments.close()
}
@Test
@@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react.modules.clipboard
import android.annotation.SuppressLint
@@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react.modules.deviceinfo
import com.facebook.react.bridge.BridgeReactContext
@@ -10,13 +10,12 @@
package com.facebook.react.modules.network
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.JavaOnlyArray
import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.WritableArray
import com.facebook.react.bridge.WritableMap
import com.facebook.react.common.network.OkHttpCallUtil
import com.facebook.testutils.shadows.ShadowArguments
import java.io.InputStream
import java.nio.charset.StandardCharsets
import okhttp3.Call
@@ -46,15 +45,16 @@ import org.mockito.kotlin.verify
import org.mockito.kotlin.whenever
import org.mockito.kotlin.withSettings
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
/** Tests [NetworkingModule] */
@Config(shadows = [ShadowArguments::class])
@RunWith(RobolectricTestRunner::class)
class NetworkingModuleTest {
private lateinit var networkingModule: NetworkingModule
private lateinit var httpClient: OkHttpClient
private lateinit var context: ReactApplicationContext
private lateinit var arguments: MockedStatic<Arguments>
private lateinit var okHttpCallUtil: MockedStatic<OkHttpCallUtil>
private lateinit var requestBodyUtil: MockedStatic<RequestBodyUtil>
private lateinit var requestArgumentCaptor: KArgumentCaptor<Request>
@@ -74,10 +74,6 @@ class NetworkingModuleTest {
networkingModule = NetworkingModule(context, "", httpClient, null)
arguments = mockStatic(Arguments::class.java)
arguments.`when`<WritableArray> { Arguments.createArray() }.thenAnswer { JavaOnlyArray() }
arguments.`when`<WritableMap> { Arguments.createMap() }.thenAnswer { JavaOnlyMap() }
okHttpCallUtil = mockStatic(OkHttpCallUtil::class.java)
requestArgumentCaptor = argumentCaptor()
}
@@ -92,7 +88,6 @@ class NetworkingModuleTest {
@After
fun tearDown() {
arguments.close()
okHttpCallUtil.close()
}
@@ -8,40 +8,31 @@
package com.facebook.react.modules.network
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.JavaOnlyArray
import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.WritableArray
import com.facebook.react.bridge.WritableMap
import com.facebook.testutils.shadows.ShadowArguments
import java.net.SocketTimeoutException
import org.assertj.core.api.Assertions.assertThat
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.MockedStatic
import org.mockito.Mockito.mockStatic
import org.mockito.kotlin.any
import org.mockito.kotlin.mock
import org.mockito.kotlin.never
import org.mockito.kotlin.verify
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
@Config(shadows = [ShadowArguments::class])
@RunWith(RobolectricTestRunner::class)
class ResponseUtilTest {
private lateinit var reactContext: ReactApplicationContext
private lateinit var arguments: MockedStatic<Arguments>
@Before
fun setUp() {
reactContext = mock()
arguments = mockStatic(Arguments::class.java)
arguments.`when`<WritableArray>(Arguments::createArray).thenAnswer { JavaOnlyArray() }
arguments.`when`<WritableMap>(Arguments::createMap).thenAnswer { JavaOnlyMap() }
}
@After
fun tearDown() {
arguments.close()
}
@Test
@@ -14,12 +14,10 @@ package com.facebook.react.modules.timing
import android.content.Context
import android.os.Looper
import android.view.Choreographer.FrameCallback
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.BridgeReactContext
import com.facebook.react.bridge.CatalystInstance
import com.facebook.react.bridge.JavaOnlyArray
import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.WritableArray
import com.facebook.react.common.SystemClock
import com.facebook.react.devsupport.interfaces.DevSupportManager
import com.facebook.react.jstasks.HeadlessJsTaskConfig
@@ -29,6 +27,7 @@ import com.facebook.react.modules.core.JSTimers
import com.facebook.react.modules.core.ReactChoreographer
import com.facebook.react.modules.core.ReactChoreographer.CallbackType
import com.facebook.react.modules.core.TimingModule
import com.facebook.testutils.shadows.ShadowArguments
import org.assertj.core.api.Assertions.assertThat
import org.junit.After
import org.junit.Before
@@ -49,6 +48,7 @@ import org.mockito.kotlin.whenever
import org.mockito.stubbing.Answer
import org.robolectric.RobolectricTestRunner
import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config
object MockCompat {
// Same as Mockito's 'eq()', but works for non-nullable types
@@ -63,6 +63,7 @@ object MockCompat {
@Suppress("UNCHECKED_CAST") fun <T> uninitialized(): T = null as T
}
@Config(shadows = [ShadowArguments::class])
@RunWith(RobolectricTestRunner::class)
class TimingModuleTest {
companion object {
@@ -75,7 +76,6 @@ class TimingModuleTest {
private lateinit var postFrameCallbackHandler: PostFrameCallbackHandler
private lateinit var idlePostFrameCallbackHandler: PostFrameCallbackHandler
private lateinit var jsTimersMock: JSTimers
private lateinit var arguments: MockedStatic<Arguments>
private lateinit var systemClock: MockedStatic<SystemClock>
private lateinit var reactChoreographerMock: ReactChoreographer
@@ -84,9 +84,6 @@ class TimingModuleTest {
@Before
fun prepareModules() {
arguments = mockStatic(Arguments::class.java)
arguments.`when`<WritableArray> { Arguments.createArray() }.thenAnswer { JavaOnlyArray() }
systemClock = mockStatic(SystemClock::class.java)
systemClock
.`when`<Long> { SystemClock.uptimeMillis() }
@@ -147,7 +144,6 @@ class TimingModuleTest {
@After
fun tearDown() {
systemClock.close()
arguments.close()
ReactChoreographer.overrideInstanceForTest(reactChoreographerOriginal)
}
@@ -5,37 +5,35 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react.uimanager
import android.view.View.OnFocusChangeListener
import com.facebook.react.R
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.BridgeReactContext
import com.facebook.react.bridge.JavaOnlyArray
import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.WritableArray
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsForTests
import com.facebook.react.views.view.ReactViewGroup
import com.facebook.react.views.view.ReactViewManager
import com.facebook.testutils.shadows.ShadowArguments
import java.util.Locale
import org.assertj.core.api.Assertions
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.MockedStatic
import org.mockito.Mockito
import org.mockito.kotlin.mock
import org.mockito.kotlin.times
import org.mockito.kotlin.verify
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
@Config(shadows = [ShadowArguments::class])
@RunWith(RobolectricTestRunner::class)
class BaseViewManagerTest {
private lateinit var viewManager: BaseViewManager<ReactViewGroup, *>
private lateinit var view: ReactViewGroup
private lateinit var arguments: MockedStatic<Arguments>
private lateinit var themedReactContext: ThemedReactContext
@Before
@@ -45,13 +43,6 @@ class BaseViewManagerTest {
val context = BridgeReactContext(RuntimeEnvironment.getApplication())
themedReactContext = ThemedReactContext(context, context, null, -1)
view = ReactViewGroup(themedReactContext)
arguments = Mockito.mockStatic(Arguments::class.java)
arguments.`when`<WritableArray> { Arguments.createMap() }.thenAnswer { JavaOnlyArray() }
}
@After
fun tearDown() {
arguments.close()
}
@Test
@@ -7,32 +7,19 @@
package com.facebook.react.uimanager
import com.facebook.react.common.SystemClock
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsForTests
import org.assertj.core.api.Assertions.assertThat
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.MockedStatic
import org.mockito.Mockito.mockStatic
import org.robolectric.RobolectricTestRunner
@RunWith(RobolectricTestRunner::class)
class OnLayoutEventTest {
private lateinit var systemClock: MockedStatic<SystemClock>
@Before
fun setup() {
ReactNativeFeatureFlagsForTests.setUp()
val ts = SystemClock.uptimeMillis()
systemClock = mockStatic(SystemClock::class.java)
systemClock.`when`<Long> { SystemClock.uptimeMillis() }.thenReturn(ts)
}
@After
fun tearDown() {
systemClock.close()
}
@Test
@@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react.uimanager
import android.view.View
@@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react.uimanager
import com.facebook.react.bridge.BridgeReactContext
@@ -5,6 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
@file:Suppress("DEPRECATION")
package com.facebook.react.uimanager
import android.view.View
@@ -19,11 +19,8 @@ import com.facebook.drawee.drawable.ScalingUtils
import com.facebook.react.bridge.Arguments
import com.facebook.react.bridge.BridgeReactContext
import com.facebook.react.bridge.CatalystInstance
import com.facebook.react.bridge.JavaOnlyArray
import com.facebook.react.bridge.JavaOnlyMap
import com.facebook.react.bridge.ReactTestHelper.createMockCatalystInstance
import com.facebook.react.bridge.WritableArray
import com.facebook.react.bridge.WritableMap
import com.facebook.react.common.ReactConstants
import com.facebook.react.internal.featureflags.ReactNativeFeatureFlagsForTests
import com.facebook.react.uimanager.DisplayMetricsHolder
@@ -32,6 +29,7 @@ import com.facebook.react.uimanager.ThemedReactContext
import com.facebook.react.util.RNLog
import com.facebook.react.views.imagehelper.ImageSource
import com.facebook.soloader.SoLoader
import com.facebook.testutils.shadows.ShadowArguments
import org.assertj.core.api.Assertions.assertThat
import org.junit.After
import org.junit.Before
@@ -47,26 +45,24 @@ import org.mockito.kotlin.reset
import org.mockito.kotlin.verify
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
/**
* Verify that [com.facebook.drawee.drawable.ScalingUtils] properties are being applied correctly by
* [ReactImageManager].
*/
@Config(shadows = [ShadowArguments::class])
@RunWith(RobolectricTestRunner::class)
class ReactImagePropertyTest {
private lateinit var context: BridgeReactContext
private lateinit var catalystInstanceMock: CatalystInstance
private lateinit var themeContext: ThemedReactContext
private lateinit var arguments: MockedStatic<Arguments>
private lateinit var rnLog: MockedStatic<RNLog>
private lateinit var flogMock: MockedStatic<FLog>
@Before
fun setup() {
arguments = mockStatic(Arguments::class.java)
arguments.`when`<WritableArray> { Arguments.createArray() }.thenAnswer { JavaOnlyArray() }
arguments.`when`<WritableMap> { Arguments.createMap() }.thenAnswer { JavaOnlyMap() }
rnLog = mockStatic(RNLog::class.java)
rnLog.`when`<Boolean> { RNLog.w(any(), anyString()) }.thenAnswer {}
@@ -87,7 +83,6 @@ class ReactImagePropertyTest {
@After
fun teardown() {
DisplayMetricsHolder.setWindowDisplayMetrics(null)
arguments.close()
rnLog.close()
flogMock.close()
}
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.react.views.virtualview
package com.facebook.react.views.virtual.view
import android.app.Activity
import android.content.Context
@@ -19,6 +19,8 @@ import com.facebook.react.uimanager.DisplayMetricsHolder
import com.facebook.react.uimanager.events.Event
import com.facebook.react.uimanager.events.EventDispatcher
import com.facebook.react.views.scroll.ReactScrollView
import com.facebook.react.views.virtual.VirtualViewMode
import com.facebook.react.views.virtual.VirtualViewModeChangeEvent
import org.assertj.core.api.Assertions.assertThat
import org.junit.Before
import org.junit.Test
@@ -18,18 +18,15 @@ import org.robolectric.annotation.Implements
import org.robolectric.shadow.api.Shadow
@Implements(Arguments::class)
class ShadowArguments {
object ShadowArguments {
@JvmStatic @Implementation fun createArray(): WritableArray = JavaOnlyArray()
companion object {
@JvmStatic @Implementation fun createArray(): WritableArray = JavaOnlyArray()
@JvmStatic @Implementation fun createMap(): WritableMap = JavaOnlyMap()
@JvmStatic @Implementation fun createMap(): WritableMap = JavaOnlyMap()
@JvmStatic
@Implementation
fun fromJavaArgs(args: Array<Any?>): WritableNativeArray =
WritableNativeArray().apply {
(Shadow.extract(this) as ShadowNativeArray).backingArray = JavaOnlyArray.of(*args)
}
}
@JvmStatic
@Implementation
fun fromJavaArgs(args: Array<Any?>): WritableNativeArray =
WritableNativeArray().apply {
(Shadow.extract(this) as ShadowNativeArray).backingArray = JavaOnlyArray.of(*args)
}
}
@@ -9,8 +9,6 @@ package com.facebook.testutils.shadows
import com.facebook.react.bridge.JavaOnlyArray
import com.facebook.react.bridge.NativeArray
import com.facebook.react.bridge.ReadableNativeArray
import com.facebook.react.bridge.WritableNativeArray
import org.robolectric.annotation.Implements
import org.robolectric.shadow.api.Shadow
@@ -19,20 +17,6 @@ import org.robolectric.shadow.api.Shadow
open class ShadowNativeArray {
var backingArray: JavaOnlyArray = JavaOnlyArray()
@Deprecated(
"Use ShadowReadableNativeArray",
ReplaceWith(
"ShadowReadableNativeArray", "com.facebook.testutils.shadows.ShadowReadableNativeArray"))
@Implements(ReadableNativeArray::class)
class Readable : ShadowNativeArray()
@Deprecated(
"Use ShadowWritableNativeArray",
ReplaceWith(
"ShadowWritableNativeArray", "com.facebook.testutils.shadows.ShadowWritableNativeArray"))
@Implements(WritableNativeArray::class)
class Writable : ShadowNativeArray()
companion object {
fun getContents(array: NativeArray): List<Any?> =
(Shadow.extract(array) as ShadowNativeArray).backingArray.toArrayList()
@@ -32,7 +32,7 @@ Pod::Spec.new do |s|
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
"DEFINES_MODULE" => "YES" }
if ENV['USE_FRAMEWORKS']
if ENV['USE_FRAMEWORKS'] && ReactNativeCoreUtils.build_rncore_from_source()
s.header_mappings_dir = './'
s.module_name = 'React_Fabric'
end
@@ -56,6 +56,7 @@ Pod::Spec.new do |s|
depend_on_js_engine(s)
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
s.subspec "animations" do |ss|
ss.source_files = podspec_sources("react/renderer/animations/**/*.{m,mm,cpp,h}", "react/renderer/animations/**/*.{h}")
@@ -79,6 +79,7 @@ Pod::Spec.new do |s|
depend_on_js_engine(s)
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
s.subspec "components" do |ss|
@@ -78,4 +78,5 @@ Pod::Spec.new do |s|
depend_on_js_engine(s)
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -39,5 +39,5 @@ Pod::Spec.new do |s|
add_dependency(s, "React-debug")
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -32,11 +32,12 @@ Pod::Spec.new do |s|
"DEFINES_MODULE" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
"GCC_WARN_PEDANTIC" => "YES" }
if ENV['USE_FRAMEWORKS']
if ENV['USE_FRAMEWORKS'] && ReactNativeCoreUtils.build_rncore_from_source()
s.header_mappings_dir = './'
end
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
# TODO (T48588859): Restructure this target to align with dir structure: "react/nativemodule/..."
# Note: Update this only when ready to minimize breaking changes.
@@ -52,4 +52,5 @@ Pod::Spec.new do |s|
end
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -48,4 +48,5 @@ Pod::Spec.new do |s|
add_dependency(s, "React-runtimeexecutor", :additional_framework_paths => ["platform/ios"])
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -33,7 +33,7 @@ Pod::Spec.new do |s|
"USE_HEADERMAP" => "YES",
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard()
}
if ENV['USE_FRAMEWORKS']
if ENV['USE_FRAMEWORKS'] && ReactNativeCoreUtils.build_rncore_from_source()
s.header_mappings_dir = '../'
s.module_name = 'React_jserrorhandler'
end
@@ -49,5 +49,6 @@ Pod::Spec.new do |s|
end
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -46,4 +46,5 @@ Pod::Spec.new do |s|
s.exclude_files = files_to_exclude
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -41,4 +41,5 @@ Pod::Spec.new do |s|
end
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -60,4 +60,5 @@ Pod::Spec.new do |s|
end
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -41,10 +41,11 @@ Pod::Spec.new do |s|
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
"DEFINES_MODULE" => "YES"}
if ENV['USE_FRAMEWORKS']
if ENV['USE_FRAMEWORKS'] && ReactNativeCoreUtils.build_rncore_from_source()
s.module_name = module_name
s.header_mappings_dir = "../.."
end
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end
@@ -41,7 +41,7 @@ Pod::Spec.new do |s|
"CLANG_CXX_LANGUAGE_STANDARD" => rct_cxx_language_standard(),
"DEFINES_MODULE" => "YES"}
if ENV['USE_FRAMEWORKS']
if ENV['USE_FRAMEWORKS'] && ReactNativeCoreUtils.build_rncore_from_source()
s.module_name = module_name
s.header_mappings_dir = "../.."
end
@@ -52,4 +52,5 @@ Pod::Spec.new do |s|
s.dependency "React-timing"
add_rn_third_party_dependencies(s)
add_rncore_dependency(s)
end

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