Commit Graph
34076 Commits
Author SHA1 Message Date
sebmarkbage 896f3c0790 Gracefully handle suspending in DOM configs (#26768)
Summary:
E.g. if we suspend (throw a promise) in pushStartInstance today we might
have already pushed some chunks (or even child segments potentially). We
should revert back to where we were.

This doesn't usually happen because when we suspend in a component it
doesn't write anything itself, it'll always defer to som host instance
to do the writing.

There was a todo about this already but I'm not 100% sure it's always
safe when suspending. It should be safe when suspending just regularly
because it's just a noop. We might not even want "throwing a promise" in
this mechanism to be supported longer term but for now that's how a
suspend in internals.

DiffTrain build for commit https://github.com/facebook/react/commit/c10010a6a00911fe99452bc561dd47c3e15f4eb8.

Changelog: [Internal]

<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: christophpurrer

Differential Revision: D45547661

Pulled By: tyao1

fbshipit-source-id: 69654c95f06bc0f056fc8231e41aa395931af228
2023-05-05 16:36:15 -07:00
acdlite 2db8c8f225 Add useFormStatus to Flight fixture (#26773)
Summary:
DiffTrain build for commit https://github.com/facebook/react/commit/f533cee8cb4fb54c170230741eea7902cb41ee06.

Changelog: [Internal]
<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: christophpurrer

Differential Revision: D45540265

Pulled By: tyao1

fbshipit-source-id: 3dd365f0569953075c61f7fdca2eb099f1bf98d7
2023-05-05 16:36:15 -07:00
sebmarkbage 98f2c1ed6e Reuse request so that a ReabableStream body does not become disturbed (#26771)
Summary:
DiffTrain build for commit https://github.com/facebook/react/commit/2c1117a8d008e34eb77eaaf7b8ef315a38644735.

Changelog: [Internal]:
<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: kassens

Differential Revision: D45539259

Pulled By: tyao1

fbshipit-source-id: a07d78cc68aae4a5002ef20003aedc33e65f3f51
2023-05-05 16:36:15 -07:00
sebmarkbage 9af7245892 Check for nullish values on ReactCustomFormAction (#26770)
Summary:
Usually we don't have to do this since we only set these in the loop but
the ReactCustomFormAction props are optional so they might be undefined.

Also moved it to a general type since it's a semi-public API.

DiffTrain build for commit https://github.com/facebook/react/commit/fa7a447b9ce5a4f0be592fc2946380b0fa3b29c0.

Changelog: [Internal]:
<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: sammy-SC

Differential Revision: D45537647

Pulled By: tyao1

fbshipit-source-id: 15aa00347467e424e3fa7d509139b2f87cdcdb69
2023-05-05 16:36:15 -07:00
acdlite ba39d87113 useOptimisticState -> useOptimistic (#26772)
Summary:
Drop the "state". Just "useOptimistic". It's cleaner.

This is still an experimental API. May not be the final name.

DiffTrain build for commit https://github.com/facebook/react/commit/b7972822b5887d05ae772ef757a453265b4b7aec.

Changelog: [Internal]:
<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: sammy-SC

Differential Revision: D45537245

Pulled By: tyao1

fbshipit-source-id: e31f77c4a55e8931c9671d13fc43d6ff32e25dbb
2023-05-05 16:36:15 -07:00
acdlite 57c9cd19b6 Add "canary" to list of allowed npm dist tags (#26767)
Summary:
Forgot this allowlist existed. It's an extra safeguard, in case we mess
up the configuration somehow.

DiffTrain build for commit https://github.com/facebook/react/commit/388686f291afb2362fdc813c49f75b4132bc1314.

Changelog: [Internal]:
<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: sammy-SC

Differential Revision: D45532426

Pulled By: tyao1

fbshipit-source-id: e81a2efe340bfa1f8397c5b1301956a0e94e5357
2023-05-05 16:36:15 -07:00
hoxyq (Meta Employee) 6892a15a71 fix[dynamic-scripts-injection]: unregister content scripts before registration (#26765)
Summary:
## Summary
Fixes #26756.

DevTools is failing to inject `__REACT_DEVTOOLS_GLOBAL_HOOK__` hook in
incognito mode. This is not happening straight-forward, but if extension
is toggled on and off, the next time I try to open it I am receiving an
error that content script was already registered.

<img width="676" alt="Screenshot 2023-05-02 at 14 36 53"
src="https://user-images.githubusercontent.com/28902667/235877692-51c5d284-79d9-4b00-b62e-d25d5bb5e056.png">

- Unregistering content scripts before attempting to register them
again. We need to inject `__REACT_DEVTOOLS_GLOBAL_HOOK__` on each page,
so this should be expected behaviour.
- Fixed error logging

## How did you test this change?
Local build of extension for Chrome, trying the same steps, which
resulted in an error.
No regression in performance, tested on react.dev, still the same.

DiffTrain build for commit https://github.com/facebook/react/commit/8a25302c668d6f9a24f6680fb4947e9b388bb7d9.

Changelog: [Internal]:
<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: sammy-SC

Differential Revision: D45532160

Pulled By: tyao1

fbshipit-source-id: d021721a4aee3e052512006f61cfdf72df56dbda
2023-05-05 16:36:15 -07:00
acdlite bebd8d0470 Rename "next" prerelease channel to "canary" (#26761)
Summary:
The "next" prerelease channel represents what will be published the next
time we do a stable release. We publish a new "next" release every day
using a timed CI workflow.

When we introduced this prerelease channel a few years ago, another name
we considered was "canary". But I proposed "next" instead to create a
greater distinction between this channel and the "experimental" channel
(which is published at the same cadence, but includes extra experimental
features), because some other projects use "canary" to refer to releases
that are more unstable than how we would use it.

The main downside of "next" is someone might mistakenly assume the name
refers to Next.js. We were aware of this risk at the time but didn't
think it would be an issue in practice.

However, colloquially, we've ended up referring to this as the "canary"
channel anyway to avoid precisely that confusion.

So after further discussion, we've agreed to rename to "canary".

This affects the label used in the version string (e.g.
`18.3.0-next-a1c2d3e4` becomes `18.3.0-canary-a1c2d3e4`) as well as the
npm dist tags used to publish the releases. For now, I've chosen to
publish the canaries using both `canary` and `next` dist tags, so that
downstream consumers who might depend on `next` have time to adjust. We
can remove that later after the change has been communicated.

DiffTrain build for commit https://github.com/facebook/react/commit/2c2476834a7c739ca239750b73f74aa1df144a93.

Changelog: [Internal]:
<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: sammy-SC

Differential Revision: D45531681

Pulled By: tyao1

fbshipit-source-id: 27ebe14eabad5c92fe6e5aa4944ff798b808ec33
2023-05-05 16:36:15 -07:00
acdlite fab2bd9b4c Remove deprecated workflow key from Circle config (#26762)
Summary:
This key was only valid during the 2.0 beta period so we can remove it.

DiffTrain build for commit https://github.com/facebook/react/commit/fa4314841e7fdeef6e6bc5a7722fe74dc8e9fd89.

Changelog: [Internal]:
<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: sammy-SC

Differential Revision: D45531656

Pulled By: tyao1

fbshipit-source-id: e2e3c9e5463c39e301361e18364d22dcec428c8a
2023-05-05 16:36:15 -07:00
Phillip Pan 438f6cf591 delete RCTJSScriptLoaderModule (#37284)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37284

Changelog: [iOS][Removed]

in the past, we had this protocol so we could decorate the `RCTDevSplitBundleLoader`, which was removed by motiz88. now that doesn't exist anymore, we should delete this protocol. i did a quick grep on github and this protocol was only used by `RCTDevSplitBundleLoader`, so i don't think this will be a major breaking change

Reviewed By: christophpurrer

Differential Revision: D45591882

fbshipit-source-id: 23656d0c04fa4e1c4cfc65b1052d4c3614ba8708
2023-05-05 15:14:24 -07:00
Phillip Pan 842a239cf5 keep loadScript: private to RCTInstance (#37260)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37260

Changelog: [Internal]

we don't need to expose this!

Reviewed By: RSNara

Differential Revision: D45582533

fbshipit-source-id: 77395d7bcedf4da5d92bd9519aeec2a440677d3c
2023-05-05 15:14:24 -07:00
Luna Wei d24f568c6f Update nightly versioning of react-native (#37028)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37028

Changelog: [Internal] - Update nightly versions of react-native

Reviewed By: hoxyq

Differential Revision: D45192008

fbshipit-source-id: d3626c676906f996bc38f8cb156261b7ae202c2a
2023-05-05 14:48:29 -07:00
Phillip Pan 9b69263a1c fold RCTInstanceDelegate into RCTHostDelegate (#37245)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37245

in general, userland has no reason to know about RCTInstance. this is the first step in starting to decouple consumers from the implementation details of bridgeless mode.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D45542678

fbshipit-source-id: e3b3c2ea9a913b2a2329f305aebbb6b0235d2a0e
2023-05-05 13:14:48 -07:00
David Vacca 83d6e8d450 Introduce ReactInstanceDelegateHostTest (#37281)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37281

This is an small unit test to setup how we are going to be testing stable APIs in RN Android + kotlin.

The test itself doesn't do much and it will refactor as I iterate on ReactInstanceDelegate interface

changelog: [internal] internal

Reviewed By: luluwu2032

Differential Revision: D45551424

fbshipit-source-id: 2cf7b8eb1795e9d3f2eba611b9ee3ce28edf9ee0
2023-05-05 12:58:54 -07:00
David Vacca 1b848c5ad0 Introduce ReactInstanceDelegate.Builder (#37280)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37280

In this diff I'm introducing the ReactInstanceDelegate.Builder class that will be used to initialize ReactHost in Android

This class is still under development, it is missing:
- Tests
- Documentantion for class and methods
- Default objects for optional fields on ReactInstanceDelegate.Builder

The goal of this diff is to introduce the class, test UnstableReactNativeAPI annotation and create a diff stack that shows the process to create a stable API in Android.

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D45509432

fbshipit-source-id: 7ae12f6b146491953a78edf02acf0e1ee8f8fce5
2023-05-05 11:55:24 -07:00
Christoph Purrer 8cfc1c3e75 Add missing <algorithm> import in (#37262)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37262

Fix compile errors on Windows as
```
stderr:react-native-github\packages\react-native\ReactCommon\react\renderer\componentregistry\componentNameByReactViewName.cpp(18,12): error: no member named 'mismatch' in namespace 'std'
  if (std::mismatch(rctPrefix.begin(), rctPrefix.end(), viewName.begin())
      ~~~~~^
```

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D45597108

fbshipit-source-id: e9e1439fe35727e6c4b956e7ec03236758910b60
2023-05-05 10:30:12 -07:00
Nicola Corti 7dcaf00835 Polish DevServerHelper (#37266)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37266

This class is full of warnings and other issues which I'm doing a pass on it since I touched it:
- Missing `NonNull` annotations
- Try with resources missing
- Unused inner Interfaces that can be removed

Technically a breaking change for users as we do have some public interfaces that have been removed, though not sure why people would depend on those.

Changelog:
[Android] [Removed] - Polish DevServerHelper (remove unused Interfaces)

Reviewed By: motiz88

Differential Revision: D45600284

fbshipit-source-id: 6274ae29ff3384d7409764fd6474da68d777958a
2023-05-05 09:58:07 -07:00
Nicola Corti da358d0ec7 DevServerHelper should not depend on internal ctor parameter (#37265)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37265

DevServerHelper was having a constructor parameter as `DevInternalSettings` which is effectively internal. This should not be the case as that class is Internal as was bleeding out of the public API.

I've updated the primary constructor to take instead:

```
  public DevServerHelper(
          DeveloperSettings settings,
          String packageName,
          InspectorPackagerConnection.BundleStatusProvider bundleStatusProvider,
          PackagerConnectionSettings packagerConnectionSettings) {
```

This is breaking change for users that were depending on the Internal class.

Changelog:
[Android] [Removed] - DevServerHelper should not depend on internal ctor parameter

Reviewed By: mdvacca

Differential Revision: D45600283

fbshipit-source-id: e73139dbdf5f2505201b2d2c8b5a9143b7e207ba
2023-05-05 09:58:07 -07:00
Marshall Roch 8aa228164d upgrade to flow v0.205.1
Summary: Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D45597056

fbshipit-source-id: 0dedb3f3fd6876886c5ab4a2c1731ce404fc7d57
2023-05-05 07:27:45 -07:00
Nicola Corti 758b74094b Store test artifacts for Android (#37269)
Summary:
We should store XML datas from the test we execute so when they fail it's easier to immediately see which test caused the failure.

## Changelog:

[INTERNAL] - Store test artifacts for Android

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

Test Plan: Wait for CI results

Reviewed By: cipolleschi

Differential Revision: D45603973

Pulled By: cortinico

fbshipit-source-id: e818b353816e10b3e4ed16bdb66dd4c8918a9c51
2023-05-05 07:01:00 -07:00
Nicola Corti a3b57f6cb0 Disable all the measure* tests on Windows as they're flaky (#37264)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37264

Instead of disabling one test at a time, I've suppressed all the measure* related tests on Windows
with the hope to make the Windows CI less flaky.

Changelog:
[Internal] [Changed] - Disable all the measure* tests on Windows as they're flaky

Reviewed By: cipolleschi

Differential Revision: D45601448

fbshipit-source-id: 010905e1dbebd9c9da9d6710ea6ca0b99c4a2d5f
2023-05-05 03:37:01 -07:00
Douglas Lowder 615d9aefc4 Read Maven group from GROUP property (#37204)
Summary:
The [React Native TV repo](https://github.com/react-native-tvos/react-native-tvos) shares most of the same Android code as the core repo. Beginning in 0.71, it needs to also publish Android Maven artifacts for the `react-android` and `hermes-android` libraries.

In order to avoid conflicts, it needs to publish the artifacts to a different group name. However, `react-native-gradle-plugin` uses a hardcoded group name (`com.facebook.react`).

Solution: read the group name from the existing `GROUP` property in `ReactAndroid/gradle.properties`.

## Changelog:

[Android] [Fixed] - read GROUP name in gradle-plugin dependency code

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

Test Plan:
- Android unit tests have been added for the new code and new method in `DependencyUtils.kt`.
- Existing tests should pass
- The new code defaults to the correct group (`com.facebook.react`) so no functional change is expected in the core repo.

Reviewed By: luluwu2032

Differential Revision: D45576700

Pulled By: cortinico

fbshipit-source-id: 6297ab515b4bdbb17024989c7d3035b0a2ded0ae
2023-05-05 03:12:33 -07:00
sammy-SC (Meta Employee) ef69c5434a Use content hash for react-native builds (#26734)
Summary:
DiffTrain build for commit https://github.com/facebook/react/commit/5dd90c562354758942c833b0a46923176e92208e.

Changelog: [Internal]:
<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: josephsavona

Differential Revision: D45479086

Pulled By: tyao1

fbshipit-source-id: 4b535994413e9a881e8facf5dcc7a13145530fef
2023-05-04 17:26:37 -07:00
Luna Wei 12bea9c80b Fixes to our types
Summary:
Changelog: [Internal] - Noticed when I was cutting 0.72 types there was some types not exported and also some duplicate.

I'm not sure why our lint didn't catch this, I can look into that next

bypass-github-export-checks

Reviewed By: NickGerleman

Differential Revision: D45294027

fbshipit-source-id: addf5a5d7af10e3087edaaf660ff99e46932bc3e
2023-05-04 17:13:16 -07:00
David Vacca 9ca68efeb4 Migrating ReactInstanceDelegate to kotlin (#37259)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37259

I'm migrating the ReactInstanceDelegate interface to kotlin to start developping new api in kotlin

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: cortinico, philIip

Differential Revision: D45507000

fbshipit-source-id: 893a04951c3d92a55f82c47617f4e7633737067b
2023-05-04 16:36:39 -07:00
Genki Kondo d3fbcbb04d Add JSI<->C++ bridging conversion for folly::dynamic (#37237)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37237

Enables bridging conversions to/from jsi::Value and folly::dynamic.

Changelog:
[Internal] - Add JSI<->C++ bridging conversion for folly::dynamic

Reviewed By: javache

Differential Revision: D45544843

fbshipit-source-id: 89e773705a11eb3c5818cd081ef8c63436dc3340
2023-05-04 14:56:14 -07:00
sebmarkbage a89b572768 Allow an action provide a custom set of props to use for progressive enhancement (#26749)
Summary:
Stacked on top of #26735.

This allows a framework to add a `$$FORM_ACTION` property to a function.
This lets the framework return a set of props to use in place of the
function but only during SSR. Effectively, this lets you implement
progressive enhancement of form actions using some other way instead of
relying on the replay feature.

This will be used by RSC on Server References automatically by
convention in a follow up, but this mechanism can also be used by other
frameworks/libraries.

DiffTrain build for commit https://github.com/facebook/react/commit/559e83aebb2026035d47aa0ebf842f78d4cd6757.

Changelog: [Internal]

<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: sammy-SC

Differential Revision: D45454355

Pulled By: tyao1

fbshipit-source-id: 4b4b65c77ecbc113a79e51e4aff97b2e3b88c31a
2023-05-04 14:22:04 -07:00
sebmarkbage de78fbfade Allow forms to skip hydration of hidden inputs (#26735)
Summary:
This allows us to emit extra ephemeral data that will only be used on
server rendered forms.

First I refactored the shouldSkip functions to now just do that work
inside the canHydrate methods. This makes the Config bindings a little
less surface area but it also helps us optimize a bit since we now can
look at the code together and find shared paths.

canHydrate returns the instance if it matches, that used to just be
there to refine the type but it can also be used to just return a
different instance later that we find. If we don't find one, we'll bail
out and error regardless so no need to skip past anything.

DiffTrain build for commit https://github.com/facebook/react/commit/67f4fb02130b1fe1856289e3b66bb0b8cca57ff7.

Changelog: [Internal]

<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: sammy-SC

Differential Revision: D45453502

Pulled By: tyao1

fbshipit-source-id: 1ac34bcc2d59fdbfbc25e51f6bd5354777a33f96
2023-05-04 14:22:04 -07:00
gnoff f7a5096054 Encode external fizz runtime into chunks eagerly (#26752)
Summary:
in https://github.com/facebook/react/pull/26738 we added nonce to the
ResponseState. Initially it was used in a variety of places but the
version that got merged only included it with the external fizz runtime.
This PR updates the config for the external fizz runtime so that the
nonce is encoded into the script chunks at request creation time.

The rationale is that for live-requests, streaming is more likely than
not so doing the encoding work at the start is better than during flush.
For cases such as SSG where the runtime is not required the extra
encoding is tolerable (not a live request). Bots are an interesting case
because if you want fastest TTFB you will end up requiring the runtime
but if you are withholding until the stream is done you have already
sacrificed fastest TTFB and the marginal slowdown of the extraneous
encoding is hopefully neglibible

I'm writing this so later if we learn that this tradeoff isn't worth it
we at least understand why I made the change in the first place.

DiffTrain build for commit https://github.com/facebook/react/commit/8ea96ef84d8f08ed1846dec9e8ed20d2225db0d3.

Changelog: [Internal]

<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: sammy-SC

Differential Revision: D45449587

Pulled By: tyao1

fbshipit-source-id: 76a5f34e42db5e9ad5a78b4b8f0d4e3dad2e7fcd
2023-05-04 14:22:04 -07:00
acdlite 9bec659698 Implement experimental_useOptimisticState (#26740)
Summary:
This adds an experimental hook tentatively called useOptimisticState.
(The actual name needs some bikeshedding.)

The headline feature is that you can use it to implement optimistic
updates. If you set some optimistic state during a transition/action,
the state will be automatically reverted once the transition completes.

Another feature is that the optimistic updates will be continually
rebased on top of the latest state.

It's easiest to explain with examples; we'll publish documentation as
the API gets closer to stabilizing. See tests for now.

Technically the use cases for this hook are broader than just optimistic
updates; you could use it implement any sort of "pending" state, such as
the ones exposed by useTransition and useFormStatus. But we expect
people will most often reach for this hook to implement the optimistic
update pattern; simpler cases are covered by those other hooks.

DiffTrain build for commit https://github.com/facebook/react/commit/491aec5d6113ce5bae7c10966bc38a4a8fc091a8.

Changelog: [Internal]

<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: sammy-SC

Differential Revision: D45448404

Pulled By: tyao1

fbshipit-source-id: 09b1e8c77fb6fb5d9f0859a2392234371c011b4f
2023-05-04 14:22:04 -07:00
gnoff b46a7e700c Add nonce support to bootstrap scripts and external runtime (#26738)
Summary:
Adds support for nonce on `bootstrapScripts`, `bootstrapModules` and the external fizz runtime

DiffTrain build for commit https://github.com/facebook/react/commit/9545e4810c2dc8922f575b6d8f726503a7345d0c.

Changelog: [Internal]

<< DO NOT EDIT BELOW THIS LINE >>

Reviewed By: sammy-SC

Differential Revision: D45446494

Pulled By: tyao1

fbshipit-source-id: 31a32a1b99bdc86069b06e0870009a9846a12085
2023-05-04 14:22:04 -07:00
Ramanpreet Nara 80ecbdf2b2 ObjCTurboModule: Migrate over to id<RCTBridgeModule>
Summary:
## Definitions
- **id<RCTBridgeModule>**: A native module object.
- **id<RCTTurboModule>**: A turbo module object.

## Changes
This diff refactors the ObjCTurboModule, so that it can create perform method dispatch for legacy native module objects.
This change shouldn't impact any existing behaviour of the TurboModule system, because all turbo modules are also native modules.

## Rationale
In Bridgeless mode, the TurboModule system will now have to manage legacy native modules.

Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D44646371

fbshipit-source-id: 946dcb82bdfced60f5c29fda8e3b4a92cda8acb0
2023-05-04 11:26:51 -07:00
Ramanpreet Nara 97c0fc0774 TurboModuleManager: Migrate over to id<RCTBridgeModule> (#37238)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37238

## Definitions
- **id<RCTBridgeModule>**: A native module object.
- **id<RCTTurboModule>**: A turbo module object.

## Changes
This diff refactors the TurboModuleManager, so that it can create legacy native module objects.
This change shouldn't impact any existing behaviour of the TurboModule system, because all turbo modules are also native modules.

## Rationale
In Bridgeless mode, the TurboModule system will now have to create legacy native modules.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D44645955

fbshipit-source-id: fcf36d07af4a1d196a821ed948eaa036f0a83890
2023-05-04 11:26:51 -07:00
Nicola Corti 1a9e444b61 Reduce visibility of DevInternalSettings class (#37256)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37256

This class is public but annotated with VisibleForTesting which is not correct (as there are no tests for it).
Apparently this class is used only within this package so it's safe to reduce its visibility to package internal.

On top of this, we had methods which were not annotated with Override, which I've fixed + I've sorted the methods to have first all the public/Override ones and the then others after.

Changelog:
[Android] [Removed] - Reduce visibility of DevInternalSettings class

Reviewed By: mdvacca

Differential Revision: D45566473

fbshipit-source-id: 2c0e809094bb965f2d6263e7b2eae17a1f095165
2023-05-04 11:18:23 -07:00
David Vacca 2b415d0ab4 Delete getViewManagers method from ReactHost (#37209)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37209

Deleting getViewManagers method from ReactHost since it is not used

changelog: [internal] internal

Reviewed By: philIip

Differential Revision: D45494325

fbshipit-source-id: e5b091b69060e18eec00a5aa2eddc48c18b8ab66
2023-05-04 11:17:13 -07:00
Siddarth Kumar d46f92cdad move getEventArgument function into parsers-commons.js (#37133)
Summary:
[Codegen 116] This PR attempts to extract the logic of `getEventArgument` function from the following locations :
- `parsers/flow/components/events.js`
- `parsers/typescript/components/events.js`
since they are the same and move the function to `parsers/parsers-commons.js` as requested on https://github.com/facebook/react-native/issues/34872

## Changelog:

[Internal] [Changed] - Move `getEventArgument` to parser-commons and update usages.

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

Test Plan: Run `yarn jest react-native-codegen` and ensure CI is green

Reviewed By: christophpurrer

Differential Revision: D45569128

Pulled By: cipolleschi

fbshipit-source-id: 63a7619e5b4fca0157c62a359ac51831f4f15945
2023-05-04 11:16:37 -07:00
Nicola Corti 74987b6fca Kotlin to 1.8.0 and JDK Toolchain to 11 (#37220)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37220

I'm bumping Kotlin to 1.8.0 to align to the version used internally.

On top of this, I had to configure the JDK toolchain to 11 as Kotlin 1.8
was changing the default version of the stdlib it ships with by default.

This also shields us against problems once we'll bump to AGP 8 which requires
JDK 17 but still allows to produce libraries that are JDK 11 compatible.

Changelog:
[Android] [Changed] - Kotlin to 1.8.0 and JDK Toolchain to 11

Reviewed By: cipolleschi

Differential Revision: D45524689

fbshipit-source-id: 2558b5b6727b5d6e0e1e3cc58f0c6a85ddcefc4d
2023-05-04 11:12:00 -07:00
Nicola Corti 9e893a9a69 Add Adaptive Icons for RN-Tester (#37255)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37255

I've just realized that RN-Tester still ships with a legacy Android icon. Those have been superseeded in API 26 by adaptive icon. On API 33 Android also added support for monochrome icons which we haven't followed up with.

This brings the icon setup of RN Tester similar to one from the template + makes it easier to recognize.

Changelog:
[Internal] [Changed] - Add Adaptive Icons for RN-Tester

Reviewed By: yungsters, NickGerleman, mdvacca

Differential Revision: D45567471

fbshipit-source-id: 51bfe9bb9f99376353ab76e7d54c34b66382b007
2023-05-04 09:33:23 -07:00
Nicola Corti 88e3130218 Fix unreadable dev menu header on dark theme apps (#37253)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37253

Currently the Dev Menu has unreadable header/subtitle on apps with Dark theme. Here I'm fixing it:
* First I'm adding support for Dark Theme to RN Tester (we were forcign ligth theme).
* Then I'm removing any color reference and defaulting to the theme provided colors.

Changelog:
[Android] [Fixed] - Fix unreadable dev menu header on dark theme apps

Reviewed By: mdvacca

Differential Revision: D45566321

fbshipit-source-id: 947693aefdea846fec927a2cfa4d8236e02e0bfd
2023-05-04 09:33:23 -07:00
Nicola Corti 6a31799725 Polishing of the DevSupportManagerBase class (#37254)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37254

I've done a pass on this class as I was working on the debugging experiencefor New Architecture and I've fixed a couple of potential issues.
- A potential NPE accessing a `Nullable` field.
- Java 8 functional references which we were not using
- Similarly lambdas we were not using
- Using resource string with placeholders on Android

Changelog:
[Internal] [Changed] - Polishing of the DevSupportManagerBase class

Reviewed By: mdvacca, cipolleschi

Differential Revision: D45566320

fbshipit-source-id: 4a9e63a7285bc3c2f224b176627e4d191d45f64b
2023-05-04 09:33:23 -07:00
David Vacca d69a51a8e9 Introduce kotlin annotation to OptIn into the new Architecture API (#37171)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37171

In this diff I'm introducing a new kotlin annotation to OptIn into the new Architecture API. I named it "NewReactNativeArchitectureExperimentalAPI" but I'm open to name suggestions, maybe make it a bit more generic like:
ReactNativeExperimental?

Ideally it should be named similar to how we are going to publicitize the New Architecture in OSS.

The plan is to use this annotation to mark classes of experimental API, forcing external developers to explicitly optIn into new APIs:

```
UnstableReactNativeAPI
class ReactHost // A class requiring opt-in

// Client code
// this code will compile
OptIn(UnstableReactNativeAPI::class)
fun getReactHost(): ReactHost {
    // ...
    return ReactHost()
}

// This code wont compile
fun getReactHost(): ReactHost {
    // ...
    return ReactHost()
}

```

For more details about OptIn read:
https://kotlinlang.org/docs/opt-in-requirements.html#create-opt-in-requirement-annotations

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D45417255

fbshipit-source-id: f94f85844342a577e5a526b82b7b345470f66ead
2023-05-04 08:58:49 -07:00
Nicola Corti 4c91e8acbb Re-land: Convert RootViewTest to Kotlin (#37250)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37250

This is a re-land of a previous commit which ended up in us losing the history
of the Java file. This new PR should not be doing so.

This is a reference PR on how to convert a JVM Unit test from Java to Kotlin.
A couple of things to keep in mind when converting:
1. Do not use hungarian notation (`mActivity` -> `activity`)
2. JUnit rules need to be annotated with `get:Rule` rather than just `Rule`.
3. Use `import org.powermock.api.mockito.PowerMockito.`when` as whenever`to avoid having to escape all the `when` function invocation in the code as it's a keyword.
4. Do static imports of all the Mockito/PowerMock functions.

Getting rid of PowerMock and using Fakes is a plus, but that's not always possible. Having the test running and be green is already a good result.

Changelog:
[Internal] [Changed] - Convert RootViewTest to Kotlin

Reviewed By: cipolleschi

Differential Revision: D45565375

fbshipit-source-id: 6c01d037e04dc1ec0003263177d86079a6f19a04
2023-05-04 07:56:09 -07:00
Nicola Corti fe5455b87c Back out "Convert RootViewTest to Kotlin" (#37249)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37249

Original commit changeset: e0cf65012665

Original Phabricator Diff: D45526517

I'm reverting this change as the history got lost in this Kotlin conversion. I'm going to re-push it using `hg mv`.

Changelog:
[Internal] [Changed] - Back out "[RN][Android] Convert RootViewTest to Kotlin"

Reviewed By: cipolleschi

Differential Revision: D45564898

fbshipit-source-id: b144f688cfa612f0d22d65cadfd766f73996371c
2023-05-04 07:56:09 -07:00
Max Metral 34d5212f5c Fix Flipper by moving FB_SONARKIT_ENABLED to RCTAppDelegate (#37240)
Summary:
An out-of-the-box react-native init project no longer enables Flipper properly as of 0.72.0-rc1.

## Changelog:

[IOS] [FIXED] Fix Flipper by moving podfile modification of preprocessor def `FB_SONARKIT_ENABLED` from React-Core to React-RCTAppDelegate where it is now used.

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

Test Plan: Generated an app and verified Flipper cannot see the app. Made the modification and generated another app and verified Flipper now sees it and can enable plugins. Verified that runtime (non-test) use of FB_SONARKIT_ENABLED is limited to Libraries/AppDelegate in this project.

Reviewed By: dmytrorykun

Differential Revision: D45563282

Pulled By: cipolleschi

fbshipit-source-id: d760c5ae123cc7c967b19c6c626801d6db28d052
2023-05-04 07:54:01 -07:00
generatedunixname89002005325672 c8a0f19f1a Daily arc lint --take KTFMT
Reviewed By: hick209

Differential Revision: D45561077

fbshipit-source-id: 43c945ca21bccc18ceceb0b8e1ea61564dba0f71
2023-05-04 06:54:53 -07:00
Zihan Chen (MSFT) 4fd8f405be Recognize dictionary type in codegen (#37206)
Summary:
Previously we allow `{[key:string]:Something}` in codegen, `Something` is type-checked but thrown away, generating a `GenericObjectTypeAnnotation`.
In this change, `Something` is added to `GenericObjectTypeAnnotation` as an optional field.
For downstream code such as C++ codegen, this change is **backward compatible**. It allows C++ codegen to produce a more precious type optionally.

## Changelog:

[General] [Added] - Recognize dictionary type in codegen

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

Test Plan:
```
yarn jest react-native-codegen
yarn jest react-native-codegen-typescript-test
```

Reviewed By: cipolleschi

Differential Revision: D45563340

Pulled By: dmytrorykun

fbshipit-source-id: 9a9ce36df6ded6d42d35c3dcb6fb0eaca16c4458
2023-05-04 05:04:12 -07:00
Riccardo Cipolleschi 8c8f7a510f Add example in RNTester to use events with arrays (#37143)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37143

This change add an example on how to use events with arrays in the New Architecture in RNTester.

## Changelog:
[Internal] - Add Examples on RNTester on how to send events with arrays from Native to JS

Reviewed By: cortinico

Differential Revision: D45357873

fbshipit-source-id: 812521aad070181759c0a1c76b5e8c628166229c
2023-05-04 04:11:49 -07:00
Riccardo Cipolleschi b422375782 Add support for Arrays in generator (#37145)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37145

This diff adds the generation of Array types in events.

It supports the generation of Array of:
- Boolean
- Int32
- Float
- Double
- String
- Objects
- Array

**Note:** This is a first iteration. We could improve the generation further by leveraging the `Bridging` module within React Native.
I'll take a stab at it in a next diff.

## Changelog:
[General][Added] - Generate events with arrays

Reviewed By: cortinico

Differential Revision: D45321685

fbshipit-source-id: 34b05f5501b06714d1fabf1a51cb057af7027f00
2023-05-04 04:11:49 -07:00
Riccardo Cipolleschi 6168701887 Support Array parsing in events (#37142)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37142

This diff introduce support to parse arrays in events.

We support parsing Arrays of:
- Boolean
- Double
- Float
- Int32
- String Enums
- String
- Objects
- Arrays

## Changelog:
[General][Added] - Add generic support for Arrays in Events parsing

Reviewed By: dmytrorykun, RSNara

Differential Revision: D45268779

fbshipit-source-id: 0c6eae65eb2b41ebf7b47a4cc3e0f0e5fa20d871
2023-05-04 04:11:49 -07:00
Riccardo Cipolleschi 6f75f14883 Revert ENABLE_HERMES_PROFILER flag in cocoapods (#37228)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/37228

As discussed offline, the current approach for the Hermes profiler is not the right one.

I'm partially reverting [the commit](https://github.com/facebook/react-native/commit/dce9d8d5de381fe53760ddda0d6cbbdfb5be00e4) which introduced it.

The commit did also a bit of refactoring to improve the quality of the cocoapods scripts we would like to keep.

## Changelog:
[iOS][Removed] - Remove support of Hermes profiler as that's not the right approach.

Reviewed By: cortinico

Differential Revision: D45527507

fbshipit-source-id: acea5f8b610d8b67ee7a6a91993bb8e4592d093f
2023-05-04 03:01:50 -07:00