Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37553
## Context
I added some getters in EventTarget/EventEmitter to access the React instance handle for a given shadow node/shadow node family in https://github.com/facebook/react-native/commit/43864a1d6025bfc4483dded115d51f7613018199 (D44022477), so I could implement DOM traversal methods easily.
I wanted to reuse that method to implement `MutationObserver` and `IntersectionObserver`, but unfortunately `EventEmitter`/`EventTarget` only allow access to the instance handle as long as the shadow node is mounted. That makes sense for events, but not for this use case, as with `MutationObserver` we intentionally want to have access to unmounted nodes when creating the list of `addedNodes` and `removedNodes` for the `MutationRecord` (depending on when exactly we generate this list, either `addedNodes` or `removedNodes` wouldn't be mounted).
## Changes
This reverts my original change and adds a new field in `ShadowNodeFamily` to provide access to the `InstanceHandle` at any point (even if the node isn't mounted).
This provides the same guarantees as the original method, keeping weak references to the handles to avoid memory leaks.
Changelog: [internal]
Reviewed By: sammy-SC
Differential Revision: D46149084
fbshipit-source-id: f76abae50134a5d55a98cab42eebeb62084024f9
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37772
Changelog: [internal]
`ShadowNodeFragment` is used in multiple places as a general definition for the fragment, but it lacks information that's going to be constructed in the fragment itself in the future (like `eventEmitter` in D46149084).
This migrates some of the usages of this fragment to the `ShadowNodeFamily` directly (as they already have access to it).
Reviewed By: javache, sammy-SC
Differential Revision: D46190382
fbshipit-source-id: 3a879861106594d66a2580410d4d83523c288314
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37771
While working on debugging tools, I noticed that we ask in every template app to
- Add a "com.facebook.react.devsupport.DevSettingsActivity" activity
- Add the <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
This is error prone and can be cleanup as we now distribute React Native that is variant aware (debug/release).
So I'm creating a manifest inside `src/debug` that contains those directive so we don't need to ask users
to add them (I'm removing them from the template).
Changelog:
[Internal] [Changed] - Create a Debug manifest inside React Native Android
Reviewed By: cipolleschi
Differential Revision: D46556884
fbshipit-source-id: 10034a6b245bf419dfa663bc998c4d1ad5d24a90
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37727
We currently throw an exception when trying to access `node.offsetParent` in direct children of the root node in Fabric. This fixes that with an additional check.
Changelog: [internal]
Reviewed By: twobassdrum
Differential Revision: D46485786
fbshipit-source-id: f64156ef774ae600c4042c0718b099cfb92cf7f1
Summary:
## Changelog:
[Internal] [Changed] - Convert ProgressiveStringDecoderTest to Kotlin
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
Pull Request resolved: https://github.com/facebook/react-native/pull/37728
Reviewed By: cipolleschi
Differential Revision: D46552406
Pulled By: cortinico
fbshipit-source-id: 9fd75991cff98fcf71223c5bc386a7ee0b435d8d
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37716
We call `surfaceHandler.stop` both from `SurfaceHandlerBinding` as well as `Binding`. Since we don't check asserts in production, the second one should generally be a no-op, but may be causing a crash due to incorrectly de-referencing a unique_ptr.
Changelog: [Internal]
Reviewed By: mdvacca
Differential Revision: D46441620
fbshipit-source-id: e93b9722fd717947ebf772f545f692c2e31f816e
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37767
`test_android` is currently broken on main due to a wrong import for the `encodeUtf8` function from OkIO
Changelog:
[Internal] [Changed] - Fix broken test_android on main due to wrong import
Reviewed By: cipolleschi
Differential Revision: D46555207
fbshipit-source-id: 4fd5dd2f8ddda0602873169c833420a7154b830b
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37761
Changelog: [Android] [Fixed] - W3CPointerEvents: fix a case where cancel can cause NPE
When we need to dispatch a pointercancel event, we clear the previous state (last coordinates, last hit path) for the active pointer ID (this is needed in order to fire the proper events when the action causing the cancel is over).
Previously, we stored the previous state in the form of references to the corresponding state in the current `PointerEventState`. However, this PointerEventState is also used later when actually dispatching the events. Since the dispatch can happen asynchronously, alterations to the event state might be visible during the dispatch. In particular, we saw some cases where an NPE can occur due to removing entries from our local state (which got reflected in the event state).
This change fixes the issue by making copies of the data from the PointerEventState instead of just storing references to it.
Reviewed By: rozele
Differential Revision: D46522585
fbshipit-source-id: 78d6dd60cf8f5419870fb9f6703443c957d4d048
Summary:
This PR converts JSStackTraceTest.java to Kotlin as requested in https://github.com/facebook/react-native/issues/37708.
## Changelog:
[INTERNAL] [CHANGED] - Convert JSStackTraceTest to Kotlin
Pull Request resolved: https://github.com/facebook/react-native/pull/37751
Test Plan:
Run ./gradlew :packages:react-native:ReactAndroid:test.
All tests should pass.
Reviewed By: mdvacca
Differential Revision: D46525516
Pulled By: cortinico
fbshipit-source-id: 880479fc4a38fcacb4a09820e9dbc469393a6cdb
Summary:
Migrates the **ClipboardModuleTest** Java class to Kotlin. It also changes the import for **ClipboardManager** from `android.text.ClipboardManager` to `android.content.ClipboardManager`. Since the import from `android.text` is deprecated and in the [ClipboardManager.java](https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/clipboard/ClipboardModule.java) the import refers to `android.content`, so it's safe to update the import in test file as well.
It's a sub-task of the umbrella issue [here](https://github.com/facebook/react-native/issues/37708)
## Changelog:
[INTERNAL] [CHANGED] ClipboardModuleTest class migrated from Java to Kotlin
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
Pull Request resolved: https://github.com/facebook/react-native/pull/37726
Test Plan:
🟢 Test passes when running the following:
```sh
./gradlew :packages:react-native:ReactAndroid:test
```
Reviewed By: cortinico
Differential Revision: D46486129
Pulled By: mdvacca
fbshipit-source-id: 10ca6efdeea1236162dc40871cc0159cbe492335
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37745
`codegen-typescript-test` is using Jest 24 still, which has transitive dependencies on node-notifier < 8.0.1. This is causing us to fail our oss requirements (T139285789), but the original task for it got reaped (T81929770)
Changelog: [Internal]
Reviewed By: makovkastar
Differential Revision: D46506536
fbshipit-source-id: 83037459775f3c8edb000f34f6e6f77ea7059ff0
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37636
Moves `flow-typed/` directory from `packages/react-native/flow-typed/` to the repo root.
- This is a more suitable location for `flow-typed` definitions for 3P dependencies to be used across React Native packages.
- **Breaking**: We no longer publish these 3P libdefs as part of the `react-native` package (assuming that external use of React Native with Flow is extremely rare, and that these projects can manage their own package libdefs).
Changelog:
[General][Breaking] Remove included `flow-typed/` directory from the `react-native` package
- **Upgrade instructions**: Projects using Flow should install or replicate third party `flow-typed` definitions for React Native dependencies — see https://github.com/facebook/react-native/tree/main/flow-typed and [#37636](https://github.com/facebook/react-native/pull/37636).
Reviewed By: hoxyq
Differential Revision: D46313482
fbshipit-source-id: 3d97d5408e44dd43132664c4933f3ff1075f90a1
Summary:
Converts InterpolatorTypeTest from Java to Kotlin, as per issue https://github.com/facebook/react-native/issues/37708
## Changelog:
[Internal] [Changed] - Convert InterpolatorTypeTest to Kotlin
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
Pull Request resolved: https://github.com/facebook/react-native/pull/37724
Test Plan:
Tests pass: `./gradlew :packages:react-native:ReactAndroid:test`
Formatted with [KtFmt](https://facebook.github.io/ktfmt/)
Reviewed By: cortinico, yungsters
Differential Revision: D46486141
Pulled By: mdvacca
fbshipit-source-id: bcdfa6497b9170640b4b9f3f20f6afad8fb56bee
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37695
In this diff I'm reducing visibility of RCTDeviceEventEmitter interface in ReactContext.
This is an internal interface that has no usages externally (neither at Meta or github source)
changelog: [internal] internal
Reviewed By: cortinico, luluwu2032
Differential Revision: D46241623
fbshipit-source-id: 297256b7394768c54b24125ad91f7b3fabbd42d0
Summary:
Converts InstanceHandleHelper from Java to Kotlin, as per issue https://github.com/facebook/react-native/issues/37708
## Changelog:
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Convert InstanceHandleHelper to Kotlin
Pull Request resolved: https://github.com/facebook/react-native/pull/37740
Test Plan:
Tests pass: `./gradlew :packages:react-native:ReactAndroid:test`
Formatted with [KtFmt](https://facebook.github.io/ktfmt/)
Reviewed By: rshest
Differential Revision: D46515395
Pulled By: cortinico
fbshipit-source-id: 5091d1932c2ad623f063972661ec82ceb4c74089
Summary: SetSpanOperation.java doesn't have the required licence header, causing a compliance failure for OSS repo checkup. This diff adds the header.
Reviewed By: cortinico
Differential Revision: D46505914
fbshipit-source-id: 278021ff08b30b4f051a0f0a6a7dec580e012225
Summary:
Part of https://github.com/facebook/react-native/issues/37708
Convert FakeEventDispatcher to Kotlin
## Changelog:
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal][Changed]: Convert FakeEventDispatcher to Kotlin
Pull Request resolved: https://github.com/facebook/react-native/pull/37739
Test Plan:
```
./gradlew :packages:react-native:ReactAndroid:test
```
Reviewed By: rshest
Differential Revision: D46514164
Pulled By: cortinico
fbshipit-source-id: 355f568ad9b36073aa9f1981472a2c7567e7ab2d
Summary:
Converts StackTraceHelperTest from Java to Kotlin, as per issue https://github.com/facebook/react-native/issues/37708
## Changelog:
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[Internal] [Changed] - Convert StackTraceHelperTest to Kotlin
Pull Request resolved: https://github.com/facebook/react-native/pull/37741
Test Plan:
Tests pass: `./gradlew :packages:react-native:ReactAndroid:test`
Formatted with [KtFmt](https://facebook.github.io/ktfmt/)
Reviewed By: cortinico
Differential Revision: D46498064
Pulled By: mdvacca
fbshipit-source-id: d0d62097edfa8fe3649e2c72acb4ae8b3d20a89a
Summary:
[Migrate](https://github.com/facebook/react-native/issues/37708) BlobModuleTest class to Kotlin
## Changelog:
<!-- Help reviewers and the release process by writing your own changelog entry.
Pick one each for the category and type tags:
[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->
[INTERNAL] [CHANGED] `BlobModuleTest` class migrated from Java to Kotlin
Pull Request resolved: https://github.com/facebook/react-native/pull/37719
Test Plan:
Tests should pass
```sh
./gradlew :packages:react-native:ReactAndroid:test
```
Reviewed By: yungsters
Differential Revision: D46485981
Pulled By: cortinico
fbshipit-source-id: 69858fedfd84b59d6c1c2aca99f6fa9c0a8832fa
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37744
This diff introduces the new generic class BoltsFutureTask<> that will be used by ReactHost to expose async task in its API.
The goal of BoltsFutureTask is to avoid leadking the bolts.Task dependency into the ReactHost API.
Public methods of this class follow the spec defined in the Future interface, see: https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/Future.html. I didn't add javadocs to avoid duplicated documentation with Future and also
becuase this is private class.
Task Cancellation follows the patters defined in bolts documentation: https://github.com/BoltsFramework/Bolts-Android#cancelling-tasks
changelog: [internal] internal
Reviewed By: NickGerleman
Differential Revision: D46170466
fbshipit-source-id: eed92584bcd3ff0145e7cbb5d735139fbb6b0f33
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37638
Changelog: [Android] [Fixed] - W3CPointerEvents: properly update hit path during native gestures
Per [the W3C spec](https://www.w3.org/TR/pointerevents/#the-pointercancel-event), we need to fire pointerout and pointerleave after firing a pointercancel. However, in cases where the pointer doesn't physically leave the target after a cancel (e.g. scrolling by clicking and dragging), we would never re-fire a pointerenter event once the native gesture was completed. This change fixes the bug by clearing out the last hit path (and other relevant state) for the pointer when we start handling a native gesture. Then we'll re-fire a pointerenter as expected upon the next motion event (due to the logic in handleHitStateDivergence).
Note: this bug only affected hovering pointers (e.g. mouse) because for non-hovering pointers the native gesture won't end unless the pointer is physically removed (i.e. finger is lifted).
Reviewed By: javache
Differential Revision: D46226021
fbshipit-source-id: de796217bac27b169ccf9ed5e0df85f7b63d8c5e
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37626
`inspector_->connect` can return `null` when the connection fails. Check for `null` and raise an exception (preventing a later crash when the `null` connection is used).
Changelog: [Internal]
Reviewed By: voideanvalue
Differential Revision: D46126080
fbshipit-source-id: 42e08687b4d425dd87642cf6b61f675e77c738ee
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37687
We end up creating a stub RuntimeExecutor wherever we configure this, and might as well pass in the runtime directly, to match the other binding installer signatures.
Changelog: [iOS][Deprecated] Use -[RCTTurboModuleManager installJSBindings:] instead of -[RCTTurboModuleManager installJSBindingWithRuntimeExecutor:]
Reviewed By: philIip
Differential Revision: D46390501
fbshipit-source-id: df7644ccbd04462dbbe752c60e5d5961ab50dff5
Summary:
We haven't really used this macro, so it's safe to remove as of now.
Changelog:
[Internal] [Changed] - Remove CircularDepsValidator.cmake as is not needed
Reviewed By: javache
Differential Revision: D46443083
fbshipit-source-id: 2a48749d7af31c393828668006d53c7a6755ac5d
Summary:
[Codegen 132] This PR introduces `emitMixedProp` to parser-primitives and abstracts the logic out of typescript and parser events as requested on https://github.com/facebook/react-native/issues/34872
## Changelog:
[Internal] [Changed] - Add emitMixedProp to parser-primitives and update usages.
Pull Request resolved: https://github.com/facebook/react-native/pull/37608
Test Plan:
Run yarn jest react-native-codegen and ensure CI is green
## Screenshot of tests passing locally:
<img width="1182" alt="Screenshot 2023-05-28 at 12 46 49 PM" src="https://github.com/facebook/react-native/assets/64726664/dbea4daf-d954-4c7f-b121-c6aad1fb318e">
Reviewed By: dmytrorykun
Differential Revision: D46275638
Pulled By: cipolleschi
fbshipit-source-id: 803d82055c7925e49aca1f408b5c7a50c687349a
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37667
Changelog:
[Android][Fixed] - Fixing line truncation issue in Text containing /n when numberOfLines = {1}
When the text has multiple lines (with new line characters \n to hard-break the lines), and the first line is short enough to fit, Text component with `numberOfLines = {1}` doesn't display "..." at the end and rather disrespects the /n character.
With `numberOfLines = {1}`, On iOS it translates to
`line 1`, on Android & Web it translates to `line 1 line 2...`
**Expected Behavior :**
`line 1...`
Reviewed By: javache, NickGerleman
Differential Revision: D46175963
fbshipit-source-id: 3377c38ab65e6801bddb1f262432f8d156a2641f