Commit Graph

38536 Commits

Author SHA1 Message Date
Sunbreak d7fd83ed5d Remove JSCJavaScriptExecutor/Factory (#41406)
Summary:
- `JSCJavaScriptExecutor` & `JSCJavaScriptExecutorFactory` have been deprecated according to https://github.com/facebook/react-native/issues/38594
- `JSCJavaScriptExecutor`'s native implementation is missing
- `JSCJavaScriptExecutor` should be bundle into library that contains `JSCJavaScriptExecutorHolder`, e.g. [`V8Executor`](https://github.com/Sunbreak/react-native/blob/0.69-v8/ReactAndroid/src/main/java/io/csie/kudo/reactnative/v8/executor/V8Executor.java) and [`V8ExecutorHolder`](https://github.com/Sunbreak/react-native/blob/0.69-v8/ReactAndroid/src/main/java/com/facebook/v8/executor/OnLoad.cpp)

```mermaid
classDiagram
    class JSCJavaScriptExecutor["JSCJavaScriptExecutor.java"] {
        -initHybrid()$
    }
    class JSCExecutor["JSCExecutor.java"] {
        -initHybrid()$
    }
    JSCExecutor <|.. JSCExecutorHolder: Composition
    class JSCExecutorHolder["JSCExecutorHolder.cpp"] {
        +initHybrid()$
    }
    class HermesExecutor["HermesExecutor.java"] {
        -initHybrid()$
    }
    HermesExecutor <|.. HermesExecutorHolder: Composition
    class HermesExecutorHolder["HermesExecutor.cpp"] {
        +initHybrid()$
    }
    class ProxyJavaScriptExecutor["ProxyJavaScriptExecutor.java"] {
        -initHybrid()$
    }
    ProxyJavaScriptExecutor <|.. ProxyJavaScriptExecutorHolder: Composition
    class ProxyJavaScriptExecutorHolder["ProxyJavaScriptExecutorHolder.cpp"] {
        +initHybrid()$
    }
```

Remove JSCJavaScriptExecutor/Factory

## Changelog:

[ANDROID] [REMOVED] - Remove JSCJavaScriptExecutor/Factory

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

Test Plan: None

Reviewed By: christophpurrer

Differential Revision: D51198037

Pulled By: javache

fbshipit-source-id: 73f335f76adfe644bef1ee37e8ec474625d37e0d
2023-11-13 03:18:28 -08:00
Nick Gerleman 99ebcfd3a9 "yogalayout.com" to "yogalayout.dev" (#41420)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41420

X-link: https://github.com/facebook/yoga/pull/1465

https://yogalayout.com now redirects to https://yogalayout.dev

This replaces references to "yogalayout.com" with "yogalayout.dev", the same website, with a new domain. This includes:
1. Code comments
2. Yoga website config (publish action CNAME, Docusaurus config)
3. Documentation URLs in Yoga packages

Changelog:
[General][Fixed] - "yogalayout.com" to "yogalayout.dev"

Reviewed By: christophpurrer

Differential Revision: D51229587

fbshipit-source-id: b1c336a52aab5e02565071b61430d5435381dc0a
2023-11-13 02:48:29 -08:00
David Vacca 1891d9e647 Introduce again com/facebook/react/turbomodule/core/interfaces/TurboModule.kt (#41412)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41412

The PR https://github.com/facebook/react-native/pull/39682
 moved all TurboModule classes into the folder com/facebook/react/internal/turbomodule/core/interfaces/TurboModule. The reasoning is TurboModule classes are internal implementation of RN and they shouldn't be part of the public API.

Later we realized that com.facebook.react.internal.turbomodule.core.interfaces.TurboModule interface is actually being used by OSS developers too implement the TurboReactPackage.getReactModuleInfoProvider() method:
https://reactnative.dev/docs/next/the-new-architecture/pillars-turbomodules#updating-the-calculatorpackagejava

In this diff I'm re-introducing the com.facebook.react.turbomodule.core.interfaces.TurboModule interface jus for backward compatibility.

Since the plan is to delete the TurboReactPackage.getReactModuleInfoProvider method in the next few months, the plan is:

- Iterate on the experiments to remove TurboReactPackage.getReactModuleInfoProvider method

- Once TurboReactPackage.getReactModuleInfoProvider method is ready to be deleted, there's no need to expose TurboModule interface anymore, so we will delete 'com.facebook.react.turbomodule.core.interfaces.TurboModule' and 'TurboReactPackage.getReactModuleInfoProvider' method
- com.facebook.react.internal.turbomodule.core.interfaces.TurboModule will still remain in the codebase, but this will be an internal API

changelog: [Android][Changed] Fix backward compatibility breakage

Reviewed By: fkgozali

Differential Revision: D51168413

fbshipit-source-id: 921475f4beee7c6f04912558204a1911cd74b5ca
2023-11-10 22:26:54 -08:00
Arushi Kesarwani f53bd5621c Revert D50926872: Refactor DefaultReactNativeHost to use the new way of Fabric initialization
Differential Revision:
D50926872

Original commit changeset: be2bcea7b2ce

Original Phabricator Diff: D50926872

fbshipit-source-id: 677def6c91edc505dfd312ff944fd90c6abeb645
2023-11-10 21:08:33 -08:00
Nick Gerleman a9c23fbc1e Simplify YGConfigSetPointScaleFactor (#41327)
Summary:
X-link: https://github.com/facebook/yoga/pull/1451

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

The special meaning of `0.0` is now explained in the function header, and we aren't doing any sort of insensitive compare here, so the code after should be equivalent and a bit simpler.

Reviewed By: yungsters

Differential Revision: D51014264

fbshipit-source-id: 60f4a2df039f74089d5c7fabd4b7d8ac6234ba72
2023-11-10 16:31:46 -08:00
Nick Gerleman 5910032b2d Modularize and document public API (#41317)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41317

X-link: https://github.com/facebook/yoga/pull/1449

This aims to clean up the public Yoga C API, by:
1. Documenting public YGNode, YGValue, YGConfig APIs
2. Splitting APIs for specific objects into different header files (because Yoga.h was big enough without documentation)
3. Reordering headers and definitions for consistent grouping

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D50963424

fbshipit-source-id: 45124b7370256fc63aefd6d5b7641466e9a79d3b
2023-11-10 16:31:46 -08:00
Phillip Pan 0479bebbe5 Remove vestigial reference to UIActionSheetDelegate (#41402)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41402

Changelog: [Internal]

UIActionSheet was deprecated in iOS 8.3.

The RCTActionSheetManager class listed the UIActionSheetDelegate as an adopted protocol but none of the protocol methods were implemented.

Reviewed By: sammy-SC

Differential Revision: D50732844

fbshipit-source-id: e954f1e9a03e80561b3b066557e56c7f3d3589d4
2023-11-10 12:56:58 -08:00
ehsemloh 9b33e752c7 fixed (iOS) Relayout not Working for Nested Inline (#41352)
Summary:
React Native, the text inline is made versatile by design. Being managed in an alien layout logic (i.e., text paragraph), inline views work seamlessly as if in normal **flex** layout. The capacities such as animation and relayout, however, requires extra efforts on native layer.

This PR fixed one critical issue for inline, i.e., `setState()` is not working when inline contains nested views.

Closes https://github.com/facebook/react-native/issues/41348

Demo (Fixed)

https://github.com/facebook/react-native/assets/149237137/2b42d657-4024-476b-bf0c-be25ef4f8c0c

## Problem in technical:

This issue is caused by a bug in `RCTShadowView::sizeThatFitsMinimumSize()` which accidentally unlink children (of yoga nodes) with their parent (owner). More specifically, on the critical path, it
1. first **shallow** clones the current node
```
  YGNodeRef clonedYogaNode = YGNodeClone(self.yogaNode);
```
2. then calls `YGNodeCalculateLayout()` using the cloned node
3. deallocate the cloned node `YGNodeFree()`

One unseen implication of `YGNodeFree()` is to unlink all its children (because of the **shallow** clone)

```
  for (size_t i = 0; i < childCount; i++) {
    auto child = node->getChild(i);
    child->setOwner(nullptr);
  }
```

Next, let's examine,

**How nullptr of owner can cause the broken `setState()` of nested inline views**

The orphan children has two consequences:
**a**. the changes on child node (`setState()`) cannot be propagated to the parent (`YGNodeMarkDirty` -> `node->markDirtyAndPropagate();`);
**b**. `YGNodeCalculateLayout()` (`yoga::calculateLayoutImpl`) will create new children instances when orphan is detected (see below)

```
  node->cloneChildrenIfNeeded(); // line 1599 # CalculateLayout.cpp
```

Both compounded are contributing the failed `setState()`. Respectively,
**a** causes early return of `YGNodeCalculateLayout()` because parent is recognized as not *dirty*;
**b** clones a new *dirty* node which replaces the child which is supposed to be *cleaned* within `YGNodeCalculateLayout()`. And this is the *dirty* node detected by the assertion mentioned in the issue description https://github.com/facebook/react-native/issues/41348.

## The fix:

The fix introduced in this PR is to relink the children with their parent in `RCTShadowView::sizeThatFitsMinimumSize()`

## Changelog:

[IOS] [FIXED] - `setState` is not working for nested inline views in text

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

Test Plan:
Test directly in rn-tester
TBD

Reviewed By: yungsters

Differential Revision: D51071338

Pulled By: NickGerleman

fbshipit-source-id: 1f3d8a3e1e03cb11577f903e43f2c2cce9e07b6e
2023-11-10 10:58:45 -08:00
Pieter De Baets 94da17e642 Stub nativeFabricUIManager for jest tests (#41408)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41408

When FabricRenderer is used during jests it will currently error out since `nativeFabricUIManager` is nog a configured global.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D51198314

fbshipit-source-id: 4db1450f6b36699311692c2cd467184f6abea518
2023-11-10 08:41:57 -08:00
Sunbreak c267a0679d Fix type in BlobCollector.h/cpp (#41404)
Summary:
When working on JSI module, `BlobCollector`'s `nativeInstall` is a good example. But the first type should be `jni::alias_ref<jclass>` according to https://github.com/facebookincubator/fbjni/blob/main/docs/quickref.md#basic-method-usage-java-to-c-and-c-to-java

Fix type in BlobCollector.h/cpp

## Changelog:

[ANDROID] [FIXED] - Fix type in BlobCollector.h/cpp

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

Test Plan: None

Reviewed By: cipolleschi

Differential Revision: D51198049

Pulled By: javache

fbshipit-source-id: 86f471cbe3cd683a7be605ce127b3b3c3769c037
2023-11-10 05:26:58 -08:00
Oskar Kwaśniewski 88e3913603 feat(iOS) remove deprecated [UIScreen mainScreen] references (#41388)
Summary:
The goal for this PR is to further remove references for `[UIScreen mainScreen]` and migrate them to use trait collections. This helps out of tree platforms like visionOS (where the `UIScreen` is not available).

bypass-github-export-checks

## Changelog:

[INTERNAL] [CHANGED] - use currentTraitCollection for FBSnapshotTestController.m
[IOS] [CHANGED] - use key window width to assign the correct width for RCTDevLoadingView

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

Test Plan:
– Check if tests passes
- Check if `RCTDevLoadingView` shows up correctly.

Screenshot:
![CleanShot 2023-11-09 at 13 48 48@2x](https://github.com/facebook/react-native/assets/52801365/4c91399e-f70a-4e78-8288-bc7b8377c980)

Reviewed By: javache

Differential Revision: D51156230

Pulled By: cipolleschi

fbshipit-source-id: bbe711e0281046a082fd1680b55e2d117915ad00
2023-11-10 05:03:26 -08:00
Gabriel Donadel 1a61afddf7 Expose unstable_InspectorProxy and unstable_Device from dev-middleware (#41370)
Summary:
Recently, both `metro-inspector-proxy`(https://github.com/facebook/react-native/pull/39045) and `react-native-community/cli-plugin-metro`(https://github.com/facebook/react-native/pull/38795) were moved to this repo and in the process of moving these packages, the `exports` field inside package.json was added, only exporting the `index.js` file.

The problem is that Expo CLI (and possibly other community packages) rely on functions and classes that are not exported in the `index.js` file, e.g. Importing the InspectorProxy class from `react-native/dev-middleware/dist/inspector-proxy/InspectorProxy`. Normally this wouldn't be a problem and we would just import from `dist/` but due to the `exports` field, attempting to import from any other file not specified on this field will result in a `ERR_PACKAGE_PATH_NOT_EXPORTED` error.

As a short-term fix, we should create `unstable_`-prefixed exports of individual features Expo currently depends on.

## Changelog:

[INTERNAL] [CHANGED] - Expose unstable_InspectorProxy and unstable_Device from `react-native/dev-middleware`

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

Test Plan: N / A

Reviewed By: robhogan

Differential Revision: D51163134

Pulled By: blakef

fbshipit-source-id: e67adaedc4fc64131e4c9dd8383c9877b8202283
2023-11-10 04:45:51 -08:00
Arushi Kesarwani eb3ee4d132 Refactor DefaultReactNativeHost to use the new way of Fabric initialization (#41374)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41374

Refactoring `DefaultReactNativeHost` to use the new way of Fabric initialization through `FabricUIManagerProviderImpl`

Changelog:
[Internal] internal

Reviewed By: philIip, luluwu2032

Differential Revision: D50926872

fbshipit-source-id: be2bcea7b2ce7cb1b3f903dc92fcd2c91be267da
2023-11-10 02:30:18 -08:00
Arushi Kesarwani 153a2641b4 Refactor ReactNativeHost to add UIManagerProvider (#41383)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41383

Refactor `ReactNativeHost` to add the APIs for `UIManagerProvider`.

Reviewed By: christophpurrer, philIip

Differential Revision: D51120159

fbshipit-source-id: 3d9b384e3fb2f5420c5ea28f43c4147a1425d137
2023-11-10 02:30:18 -08:00
Arushi Kesarwani ea622de4e1 Refactor react initialization to use FabricUIManagerProvider instead of JSIModule (#41313)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41313

Refactor ReactNativeHost, ReactInstanceManager & Builder of `react-native-github` to use the new way of fabric initialization using the newly added class `FabricUIManagerProviderImpl.java` instead of JSIModule and thereby also refactoring the call site in FbReactInstanceHolder.java

Changelog:
[Internal] internal

Reviewed By: philIip

Differential Revision: D50783751

fbshipit-source-id: 0a9d3412bc995834cafa8fbaec2ff17e321d9906
2023-11-10 02:30:18 -08:00
Christoph Purrer c2ac0cc72a react-native-codegen: Cxx TMs > Fixed Undefined Behavior exception when running ASAN builds (#41401)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41401

Changelog: [Internal]

When build Cxx Turbo Modules with Clang's ASAN build mode the apps are crashing at runtime due to, e.g.:
```
runtime error: downcast of address 0x00010dafd618 which does not point to an object of type 'facebook::react::NativePerformance'
0x00010dafd618: note: object is of type 'facebook::react::NativePerformanceCxxSpec<facebook::react::NativePerformance>'
 00 00 00 00  f0 08 49 06 01 00 00 00  4e 61 74 69 76 65 50 65  72 66 6f 72 6d 61 6e 63  65 43 78 78
              ^~~~~~~~~~~~~~~~~~~~~~~
              vptr for 'facebook::react::NativePerformanceCxxSpec<facebook::react::NativePerformance>'
UndefinedBehaviorSanitizer: undefined-behavior FBReactNativeSpecJSI.h:6122:17
```

Where the corresponding generated code looks like

```
NativePerformanceCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
    : TurboModule(std::string{NativePerformanceCxxSpec::kModuleName}, jsInvoker),
      delegate_(static_cast<T*>(this), jsInvoker) {}
```

This change fixes that problem

AddressSanitizer: stack-use-after-scope shared_ptr.h:634 in std::__1::shared_ptr<facebook::react::InstanceHandle const>::shared_ptr[abi:v160006](std::__1::shared_ptr<facebook::react::InstanceHandle const> const&)
Shadow bytes around the buggy address:
  0x00016cea4a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00016cea4b00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00016cea4b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00016cea4c00: 00 00 00 00 00 00 00 00 f1 f1 f1 f1 f8 f8 f8 f8
  0x00016cea4c80: f8 f8 f2 f2 f2 f2 f8 f8 f2 f2 00 00 f2 f2 f8 f8
=>0x00016cea4d00: f2 f2 f8 f8 f2 f2 00 00 f2 f2[f8]f8 f2 f2 00 00
  0x00016cea4d80: f2 f2 f8 f8 f2 f2 f8 f8 f2 f2 f8 f8 f8 f2 f2 f2
  0x00016cea4e00: f2 f2 f8 f8 f2 f2 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
  0x00016cea4e80: f8 f8 f8 f8 f8 f8 f8 f8 f8 f2 f2 f2 f2 f2 f2 f2
  0x00016cea4f00: f2 f2 f8 f8 f3 f3 f3 f3 00 00 00 00 00 00 00 00
  0x00016cea4f80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==41992==ABORTING

```

Reviewed By: rshest

Differential Revision: D51183328

fbshipit-source-id: 5aff5b5eecb9d78f9b7438fbdda2c01625c9a4d9
2023-11-09 22:14:57 -08:00
Sam Zhou d7af27dd7d Deploy 0.221.0 to xplat (#41400)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41400

Changelog: [Internal]

Reviewed By: pieterv

Differential Revision: D51181099

fbshipit-source-id: 9489dc78e305eb44602baf0a719aaee0ba898a76
2023-11-09 16:57:15 -08:00
Tommy Nguyen c58e19e89a Correctly declare runtime dependencies (#41398)
Summary:
In pnpm setups, codegen will fail during build because it cannot find its dependencies. Some of the dependencies it relies on at runtime are currently declared under `devDependencies`. This change moves them to `dependencies`.

## Changelog:

[GENERAL] [FIXED] - Fix `react-native/codegen` not being able to resolve dependencies in pnpm setups

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

Test Plan: We are currently trying to [enable pnpm mode](https://github.com/microsoft/rnx-kit/pull/2811) in rnx-kit and hit this issue. We've patched this package locally and it works.

Reviewed By: christophpurrer

Differential Revision: D51169116

Pulled By: NickGerleman

fbshipit-source-id: 28906a0de412c660d2fc42f62deaf77240d27a58
2023-11-09 15:07:52 -08:00
Christoph Purrer 9320174df4 Cxx TurboModules > Add example to return a JS function from Cxx to JS (#41385)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41385

Changelog: Internal

Adding a Cxx TM example which adds a listener and returns a subscription to remove that listener from the TM.

You should be able to use this with React Hooks - https://legacy.reactjs.org/docs/hooks-reference.html

E.g.

```
useEffect(() => {
  const subscription =  NativeCxxModuleExample.setValueCallbackWithSubscription(
          callbackValue => // use it
        );
  return subscription;
});
```

Reviewed By: shwanton

Differential Revision: D50473063

fbshipit-source-id: 4e9b92aeccff1771eb4ffad6bdaa20ba7f18435f
2023-11-09 11:38:54 -08:00
Ruslan Lesiutin 01b4d7853d refactor: move React DevTools hook injections to DevAppContainer (#41360)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41360

Changelog: [Internal]

This is Flipper-only, React DevTools inject these internals in `connectToDevTools` call

Mostly for 2 reasons:
- For React DevTools' hook being accessed only in one place (AppContainer-dev)
- This logic is not related to Inspector itself

Reviewed By: GijsWeterings

Differential Revision: D50559547

fbshipit-source-id: 2127f3a20b71261858fdfc004a372d1d95ced164
2023-11-09 11:09:10 -08:00
Ruslan Lesiutin a1f2330ebb cleanup[Inspector]: remove unused code (#41292)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41292

Changelog: [Internal]

Seems to be unused

Reviewed By: javache

Differential Revision: D50559548

fbshipit-source-id: 4bf7c27cb75e567c43adfa5aa4c120c67ef4dd5e
2023-11-09 11:09:10 -08:00
Ruslan Lesiutin dbd42d406c refactor: use reactDevToolsAgent in state (#41291)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41291

Changelog: [Internal]

We have the same logic in 3 different places, encapsulating access to React DevTools hook in one place, all other components that require agent will get it as a prop.

Reviewed By: GijsWeterings

Differential Revision: D50559550

fbshipit-source-id: f3667a82ca48a36032c60c730df8f661098401ee
2023-11-09 11:09:10 -08:00
Ruslan Lesiutin d659a560ce refactor: move devtools types to a separate file (#41307)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41307

Changelog: [Internal]

To be able to use it in other possible places.

Reviewed By: javache

Differential Revision: D50952773

fbshipit-source-id: f21f4553e7f51ab0683a6adb834dc5c90c33c927
2023-11-09 11:09:10 -08:00
Ruslan Lesiutin 9cc46f58ad refactor[AppContainer]: migrate to functional component (#41285)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41285

Changelog: [Internal]

I have an ongoing work on improving debugging overlays, lots of changes in these files are planned.

- Split `AppContainer` into 2 implementations: DEV and PROD
- Rewrite to functional components

Reviewed By: javache

Differential Revision: D50559549

fbshipit-source-id: 3790f149d504bd45be78c6f3103e05677f3a107d
2023-11-09 11:09:10 -08:00
Riccardo Cipolleschi 19945ad83b Add Github Action to add a commit with #run-e2e-tests (#41311)
Summary:
https://github.com/facebook/react-native/issues/41308 introduce the possibility to run e2e tests if a commit contains #run-e2e-tests in the commit message.
This PR builds on top of that, and let users to run e2e tests by adding a comment with with #run-e2e-tests

## Changelog:
[Internal] - Allow to run e2e tests from comments

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

Test Plan: Not sure it can be tested until the PR is merged... ¯\_(ツ)_/¯

Reviewed By: dmytrorykun

Differential Revision: D51111543

Pulled By: cipolleschi

fbshipit-source-id: e6c55950552f03830fa35c89d385ab9b17f8facb
2023-11-09 05:53:47 -08:00
Oskar Kwaśniewski 7bcfd02a60 feat(iOS) make build-hermes-xcode.sh more extensible for out of tree platforms (#41387)
Summary:
This PR aims to make scripts building hermes locally more extensible for out-of-tree platforms. It will make it easier for forks like visionOS to add additional `elif` statements.

As a side benefit this PR fixes Hermes builds for MacOS 😄 (I've checked that it now builds correctly)

## Changelog:

[IOS] [ADDED] - make build-hermes-xcode.sh more extensible for out-of-tree platforms

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

Test Plan: Run the local Hermes build by running `USE_HERMES=1 bundle exec pod install` and check if it runs smoothly. Also, a CI check should be sufficient.

Reviewed By: dmytrorykun

Differential Revision: D51156307

Pulled By: cipolleschi

fbshipit-source-id: 1c65b84b16fc8bd0552037c6ef558543cbe03889
2023-11-09 05:53:30 -08:00
George Zahariev c95b2d9728 Enable Flow casting_syntax=both in fbsource
Summary:
Enable Flow `casting_syntax=both` in fbsource, before the announcement so that when people see it they can check it out without rebasing.

bypass-github-export-checks
bypass-lint

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D51097870

fbshipit-source-id: dfcb04000df26140c971422389b6fce0b1ba51e7
2023-11-09 01:02:55 -08:00
Pieter De Baets 050a5a3797 Fix CellRenderer onCellFocusCapture not being stable (#41381)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41381

Noticed that when scrolling VirtualizedList's CellRenderer was re-rendering due to `onCellFocusCapture` not having a stable identify. Change the interface to CellRenderer to pass in the `cellKey` in the callback to save on creating new callbacks.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D51112928

fbshipit-source-id: 3fcb974d9b5585403895746fbc45f2cf5a9fa6b1
2023-11-08 15:16:54 -08:00
Intl Scheduler ae9302cca8 translation auto-update for i18n/fb4a.config.json on master
Summary:
Chronos Job Instance ID: 1125907943211396
Sandcastle Job Instance ID: 4503600731222116
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D51133781

fbshipit-source-id: 1acc03a3fbb8692161ff0f41764542bf32039485
2023-11-08 14:44:03 -08:00
hieu9102002 05d92bf2a5 Remove redundant LongLivedObject import in RCTTurboModule.mm (#41368)
Summary:
Similarly to https://github.com/facebook/react-native/issues/36391 , we found that this import was periodically causing issues for our builds. We applied this patch and found that it is solving the issue, thus raising the PR here.

It may potentially be related to https://github.com/facebook/react-native/issues/35664 and https://github.com/facebook/react-native/issues/41281

## Changelog:

[IOS] [FIXED] - Unbreak Cocoapods build

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

Test Plan: Automated test builds should be able to spot out potential issues.

Reviewed By: javache

Differential Revision: D51117316

Pulled By: cipolleschi

fbshipit-source-id: 5c8ee35ab38539ae1f5556202bb274566adf09b3
2023-11-08 12:36:53 -08:00
Moti Zilberman 1bcd28636f Handle source file / source map fetch errors correctly, add tests (#41342)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41342

While rewriting `Debugger.getScriptSource` messages to fetch code and source map over HTTP, we weren't checking the status code of the fetch calls. This diff fixes that and adds corresponding tests (as well as for the filesystem error case).

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D51013054

fbshipit-source-id: 58e7bb9fcd6a3cf92329b43fb8a139093c80d305
2023-11-08 07:19:40 -08:00
Moti Zilberman 4eb3e300a4 Add tests for reload message injection (#41340)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41340

Tests for D17100911 and D14503522.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D51013053

fbshipit-source-id: 65aba42e21fad891e458647c8421cd316518ec3c
2023-11-08 07:19:40 -08:00
Moti Zilberman 246657214d Add tests for Debugger.getScriptSource rewriting (#41338)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41338

Tests for D21401320 and D39629274.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D51013052

fbshipit-source-id: af25935d1d7fff90112720888b3728ce195ac5d1
2023-11-08 07:19:40 -08:00
Moti Zilberman 3afadef6d6 Add tests for source map fetching and URL rewriting hacks (#41339)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41339

Tests for D42973408, D14800976, and D15116579.

Changelog: [Internal]

Reviewed By: blakef

Differential Revision: D51013055

fbshipit-source-id: cff8a9d1dd22b642117594da16e6b74cf679aa34
2023-11-08 07:19:40 -08:00
Moti Zilberman c6eccda2c7 Add tests for HTTPS-specific behaviour (#41341)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41341

* Extends `dev-middleware`'s test utilities to enable testing against an HTTPS server with a self-signed cert.
* Runs the CDP transport integration tests (D51002261) using both HTTP and HTTPS.
* Adds a test to explicitly cover the `ws=...` / `wss=...` variation in `devtoolsFrontendUrl` first introduced in D49158227.

Changelog: [Internal]

Reviewed By: blakef

Differential Revision: D51006835

fbshipit-source-id: df3db8cd865898248cd0d8f307f75949a7f313fd
2023-11-08 07:19:40 -08:00
Moti Zilberman c85b2da1e7 Add minimal test for "Improved Chrome Reloads" synthetic page (#41335)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41335

`inspector-proxy` has special behaviour to allow a debugger connection to persist across app reloads.

In the React Native runtime, a reload is modelled as the creation of an entirely new "page" with its own ID. To insulate the debugger from this detail, the proxy advertises a separate, synthetic page on each device, with ID `-1`, that always maps to the latest React Native page reported by that device.

Here we test the message forwarding part of this functionality. The proxy also injects CDP messages (in both directions) as part of simulating a reload, but that will be tested in a separate diff.

Changelog: [Internal]

Reviewed By: blakef

Differential Revision: D51002262

fbshipit-source-id: 296135177321a511ebbe7d9696e4e7a61275aa32
2023-11-08 07:19:40 -08:00
Moti Zilberman 38a878194b Add CDP transport tests (#41343)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41343

Changelog: [Internal]

Adds basic tests for two-way communication between a debugger (frontend) and a target (backend) using CDP over `inspector-proxy`.

Reviewed By: blakef

Differential Revision: D51002261

fbshipit-source-id: 44e571f89437c26e76ef6e6192b2bf6244665cf0
2023-11-08 07:19:40 -08:00
Moti Zilberman 1602d42cec Clean up polling interval on device disconnection (#41331)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41331

`inspector-proxy`'s `Device` class currently leaks a `setInterval` handle. This is mostly harmless in current usage. In the test suite added up the stack, it shows up as a leak that prevents Jest from exiting cleanly, so let's clean it up properly.

Changelog: [Internal]

Reviewed By: blakef

Differential Revision: D51002263

fbshipit-source-id: ca36797ce1196aa049ceb3a8e96ee53d34893fdc
2023-11-08 07:19:40 -08:00
Moti Zilberman 0ea72807a6 Add tests for inspector-proxy's HTTP API (#41314)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41314

Changelog: [Internal]

Adds the beginning of a test suite for `inspector-proxy`. For maintainability, we only test functionality exposed from the `dev-middleware` boundary rather than instantiating `InspectorProxy` directly.

In this diff, the test coverage is far from complete, but this is a first stab at covering some basics. `InspectorProxyHttpApi-test` exercises the HTTP GET endpoints (`/json/list` and `/json/version`) as well as some device registration logic through the `/inspector/device` WebSocket. Some reusable helpers for server setup and device mocking are included in separate files.

As an overall strategy, I'm planning to add multiple test files that share helpers between them, not build out one massive test file with all the helpers inline. There will likely be some verbose tests when we start covering debugger-to-device communication, and I want to keep them as readable as possible.

Reviewed By: blakef

Differential Revision: D50980467

fbshipit-source-id: 962dae5a380451d6dac57eac23c4436550a39cf8
2023-11-08 07:19:40 -08:00
Riccardo Cipolleschi 47f773e458 Migrate the remaining Podspec (#41359)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41359

This change migrates the remaining podspecs to the new functions, so we do not depend on hardcoded values anymore and we can scale the solution to other platforms.

## Context
Last week I helped macOS to work with static framework.
When multiple platforms are specified, frameworks are build in two variants, the iOS and macOS one.

This break all the HEADER_SEARCH_PATHS as now we have to properly specify the base folder from which the search path is generated.
See also [this PR](https://github.com/microsoft/react-native-macos/pull/1967) where I manually make MacOS work with `use_framewroks!`

## Changelog:
[Internal] - Add helper function to create header_search_path

Reviewed By: shwanton

Differential Revision: D51068403

fbshipit-source-id: 4c0455543363ccf4272d5e8590a7c663d9c33e8b
2023-11-08 03:31:18 -08:00
Riccardo Cipolleschi fa6f170658 Expose function to create Header Search Paths and migrate Ruby Code (#41358)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41358

This change expose a missing function to create Header Search Paths when a podspec can't depend on another one explicitly.
This also migrate the ruby code to this new function.

## Context
Last week I helped macOS to work with static framework.
When multiple platforms are specified, frameworks are build in two variants, the iOS and macOS one.

This break all the HEADER_SEARCH_PATHS as now we have to properly specify the base folder from which the search path is generated.
See also [this PR](https://github.com/microsoft/react-native-macos/pull/1967) where I manually make MacOS work with `use_framewroks!`

## Changelog:
[Internal] - Add helper function to create header_search_path

Reviewed By: shwanton

Differential Revision: D51068390

fbshipit-source-id: ba9e09cd2f0671a9f3f00cc72496a0d5682eeb90
2023-11-08 03:31:18 -08:00
Riccardo Cipolleschi 406e6361f9 Migrate React-RCTBlob to add_dependency (#41357)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41357

This change migrate React-RCTBlob to the new add_dependency to improve its compatibility with macOS and to remove some maintenance burden.

## Context
Last week I helped macOS to work with static framework.
When multiple platforms are specified, frameworks are build in two variants, the iOS and macOS one.

This break all the HEADER_SEARCH_PATHS as now we have to properly specify the base folder from which the search path is generated.
See also [this PR](https://github.com/microsoft/react-native-macos/pull/1967) where I manually make MacOS work with `use_framewroks!`

## Changelog:
[Internal] - Add helper function to create header_search_path

Reviewed By: shwanton

Differential Revision: D51030365

fbshipit-source-id: c4b9037d6d0223052d659c04a1f494508944ed2a
2023-11-08 03:31:18 -08:00
Riccardo Cipolleschi 21902d70ba Cleanup React-Core (#41356)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41356

React-Core does not depends on any bit of ReactCommon, React-RCTFabric or React-NativeModuleApple, so I'm cleaning that up.

## Context
Last week I helped macOS to work with static framework.
When multiple platforms are specified, frameworks are build in two variants, the iOS and macOS one.

This break all the HEADER_SEARCH_PATHS as now we have to properly specify the base folder from which the search path is generated.
See also [this PR](https://github.com/microsoft/react-native-macos/pull/1967) where I manually make MacOS work with `use_framewroks!`

## Changelog:
[Internal] - Add helper function to create header_search_path

Reviewed By: shwanton

Differential Revision: D51030115

fbshipit-source-id: f87dbfe99e90d52cf8c07057be22cd024e38db42
2023-11-08 03:31:18 -08:00
Riccardo Cipolleschi e1092b4e3c Add add_dependency function to ract_native_pods and Migrate React-RCTAppDelegate (#41355)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41355

This change expose a new API to react_native_pod to add dependencies that automatically configure their search paths when using frameworksa and with multiple Apple platforms.
It also migrates React-RCTAppDelegate to this new mechanism to test that it works.

## Context
Last week I helped macOS to work with static framework.
When multiple platforms are specified, frameworks are build in two variants, the iOS and macOS one.

This break all the HEADER_SEARCH_PATHS as now we have to properly specify the base folder from which the search path is generated.
See also [this PR](https://github.com/microsoft/react-native-macos/pull/1967) where I manually make MacOS work with `use_framewroks!`

## Changelog:
[Internal] - Add helper function to create header_search_path

Reviewed By: shwanton

Differential Revision: D51029484

fbshipit-source-id: 77dfe85419d495f7327a2f484d33f9ed8701e00d
2023-11-08 03:31:18 -08:00
Riccardo Cipolleschi befc6d4004 Add helper function to add dependencies (#41354)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41354

In order to make the infra scalable and avoid a maintenance nightmare for macOS and future platform, we are introducing this function that automate adding a dependency to a podspec and it generates the required search paths.

## Context
Last week I helped macOS to work with static framework.
When multiple platforms are specified, frameworks are build in two variants, the iOS and macOS one.

This break all the HEADER_SEARCH_PATHS as now we have to properly specify the base folder from which the search path is generated.
See also [this PR](https://github.com/microsoft/react-native-macos/pull/1967) where I manually make MacOS work with `use_framewroks!`

## Changelog:
[Internal] - Add helper function to create header_search_path

Reviewed By: shwanton

Differential Revision: D51027343

fbshipit-source-id: 33ac4c07112eacb08067220397e38db0a19240fb
2023-11-08 03:31:18 -08:00
Riccardo Cipolleschi a66fdd43eb Add helper function to create header_search_path (#41353)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41353

Last week I helped macOS to work with static framework.
When multiple platforms are specified, frameworks are build in two variants, the iOS and macOS one.

This break all the HEADER_SEARCH_PATHS as now we have to properly specify the base folder from which the search path is generated.
See also [this PR](https://github.com/microsoft/react-native-macos/pull/1967) where I manually make MacOS work with `use_framewroks!`

In order to make the infra scalable and avoid a maintenance nightmare for macOS and future platform, we are introducing this function that should factor out the platforms from the generation of header search paths.

## Changelog:
[Internal] - Add helper function to create header_search_path

Reviewed By: shwanton

Differential Revision: D51026356

fbshipit-source-id: 7cf03601d94d7680f3fdfcaf52b2fd6bcd48c5b4
2023-11-08 03:31:18 -08:00
Riccardo Cipolleschi bb4e940b6d Configure E2E tests to run on a commit that contains #run-e2e-tests (#41308)
Summary:
This change allow our CI to run E2E tests using a specific tag in the commit message

## Changelog:
[Internal] - Allow to run e2e test using a specific tag in the last commit message

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

Test Plan:
CircleCI is green
Tested interacting with the PR/branch

Reviewed By: NickGerleman

Differential Revision: D50975588

Pulled By: cipolleschi

fbshipit-source-id: 6318800d7e86e1cab394af2b320e280304189dd2
2023-11-08 02:03:52 -08:00
Moti Zilberman 5abaf388cd Use hermes-parser for Flow codegen specs (#39036)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39036

Changelog: [General][Changed] Use `hermes-parser` instead of `flow-parser` to parse Flow Codegen specs.

`hermes-parser` is a WASM build of the Hermes parser (plus supporting code), maintained by the Flow and Hermes teams. It is the recommended way of parsing Flow code in Node and its benefits (compared to `flow-parser`) include better performance and improved type safety.

Here we update `react-native/codegen` to use `hermes-parser` instead of `flow-parser`. Both parsers produce ASTs that conform to the ESTree spec so this is mostly a drop-in replacement.

In future work we should be able to use the improved AST types available in `hermes-estree` to improve type safety within `react-native/codegen` itself.

Reviewed By: huntie

Differential Revision: D48384078

fbshipit-source-id: 310ad150ec62671ba395b0e2f6415ccae97ac04d
2023-11-08 01:33:42 -08:00
Moti Zilberman a74765eb0a Throw Flow syntax errors instead of continuing to process the AST (#39035)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39035

Changelog: [General][Fixed] Flow syntax errors in Codegen specs are no longer ignored.

Instead of throwing errors like most parsers, the `flow-parser` package returns errors as part of the AST (along with a best-effort parse). It turns out that `react-native/codegen` ignores such errors and only detects a subset of them after the fact. Here we change the behaviour to immediately throwing a descriptive error message (containing the file name and a code frame).

**This change is theoretically breaking** for any published packages that already contain broken Flow code (that somehow doesn't happen to affect the Codegen output today). Hopefully, anyone using Flow-flavoured RN Codegen is also typechecking with Flow and/or building with Metro (which would both flag the same errors), so the impact should be fairly contained.

Reviewed By: huntie

Differential Revision: D48385786

fbshipit-source-id: c7e1f5fb64a61fb0eb9e9f8f7501b43264c9626c
2023-11-08 01:33:42 -08:00
Nick Gerleman 5a7ae618a2 Remove Yoga-internal.h (#41346)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41346

X-link: https://github.com/facebook/yoga/pull/1452

This removes the last remnant from `Yoga-interna.h`, `YGNodeDellocate()`. The API is renamed to `YGNodeFinalize` to give it the explicit purpose of freeing the node from a garbage collector, and made public with that documented contract.

With that, every top-level header is now a public API, and Yoga's JNI bindings do not need to rely on private headers anymore.

Changelog: [Internal]

Reviewed By: joevilches

Differential Revision: D51014340

fbshipit-source-id: 553f04b62c78b76f9102cd6197146650955aeec5
2023-11-07 21:27:59 -08:00