Commit Graph

12270 Commits

Author SHA1 Message Date
Alex Hunt f688a2d4be Update /open-debugger to try first target when unspecified (#39255)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39255

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D48873336

fbshipit-source-id: 8d3aac383de1cefa303a89fbfee9a23ce906a979
2023-09-04 06:36:42 -07:00
Ales Pergl 054ab62be0 Fix building Android on Windows (#39190)
Summary:
Currently Android fails to build on Windows, because CMake cannot work with
native Windows paths that are passed to it as build arguments. This change
converts the input paths to the CMake format.

## Changelog:

[Android] [Fixed] - Fix building Android on Windows.

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

Test Plan: Build the React Native Android project on Windows. It should complete successfully.

Reviewed By: NickGerleman

Differential Revision: D48948140

Pulled By: cortinico

fbshipit-source-id: 6d584c2a10e683cdb6df0dd6dcd5875da7e06e2b
2023-09-04 05:28:46 -07:00
Oskar Kwaśniewski 7f26b088b2 Convert ColorUtilTest to Kotlin (#38979)
Summary:
Converts ColorUtilTest to kotlin as requested in https://github.com/facebook/react-native/issues/38825

## Changelog:

[INTERNAL] [CHANGED] - Convert ColorUtilTest to Kotlin

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

Test Plan:
1. Run `./gradlew :packages:react-native:ReactAndroid:test`.
2. All tests should pass.

Reviewed By: fkgozali, cortinico, arushikesarwani94

Differential Revision: D48802302

Pulled By: mdvacca

fbshipit-source-id: 876caf288bd5df1e1fdc4b0b20b41afdfacf364f
2023-09-04 04:29:05 -07:00
Broda Noel 83885f1d69 Update Image.d.ts (#39230)
Summary:
I've seen that this throws a warning:
```
<ImageBackground source={{ uri: undefined }}>
```

But this is properly working, without a warning, thus, I believe the code is allowing it:
```
<ImageBackground source={isLoading ? undefined : { uri: 'https://....' }}>
```

## Changelog:

[GENERAL] [CHANGED] - Fixed `source` in `Image` type

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

Test Plan: Not necessary. It's just a DOC change

Reviewed By: rshest

Differential Revision: D48939824

Pulled By: NickGerleman

fbshipit-source-id: fca2e07b7b4d4b947e365bb9d82fcf4cea484951
2023-09-04 03:05:40 -07:00
Moti Zilberman 4dea63530f Fork ReactCommon/hermes/inspector as inspector-modern (#39253)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39253

X-link: https://github.com/facebook/hermes/pull/1112

Changelog: [Internal]

Forks `ReactCommon/hermes/inspector` → `ReactCommon/hermes/inspector-modern`. More changes to `inspector-modern` will come in subsequent diffs.

The Gradle, CocoaPods and Buck builds of React Native have been updated to use `inspector-modern` everywhere. The code in `ReactCommon/hermes/inspector` is thus **deprecated** and unused in the open source build, and will be deleted in an upcoming diff (likely before the 0.73 cut).

NOTE: The reason we're not immediately deleting `ReactCommon/hermes/inspector` is that there are a handful of references to it in Meta's internal monorepo (*outside of React Native*) that we are in the process of migrating away. Once we've deleted the existing `ReactCommon/hermes/inspector`, we *may* rename `inspector-modern` back to `inspector`.

Reviewed By: blakef

Differential Revision: D48897203

fbshipit-source-id: 13682747d280a3231b7f6bce560f25ad174304e9
2023-09-04 02:48:02 -07:00
Intl Scheduler 152afe9244 translation auto-update for i18n/fb4a.config.json on master
Summary:
Chronos Job Instance ID: 1125907940832858
Sandcastle Job Instance ID: 13510799920053222
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D48941197

fbshipit-source-id: 41d203e41df61c743f2372fe84c3eb9756bb04ba
2023-09-03 19:16:09 -07:00
Yedidya Feldblum 041f459d8c forward-compatible use of u8"..." strings (#39264)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39264

X-link: https://github.com/facebook/hermes/pull/1113

Since C++20, the type of a `u8"..."` string literal is `const char8_t[N]` whereas prior to C++20 the type is `const char[N]`. `char8_t` has the same size, alignment, and signedness as `unsigned char` but is a different type from `unsigned char`, as well as being a different type from `signed char` and from `char`.

In context, the uses of the `u8"..."` expect `const char*` (to which `const char[N]` decays) and not `const char8_t*` (to which `const char8_t[N]` decays). To fit the string to the context since C++20, we must `reinterpret_cast` to `const char*`; this is a type-level no-op prior to C++20.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D48908076

fbshipit-source-id: e68d8fc4ff9dfb9528846901e37e2775c2b98866
2023-09-02 16:23:34 -07:00
Intl Scheduler 7a0d2a06fb translation auto-update for i18n/fb4a.config.json on master
Summary:
Chronos Job Instance ID: 1125907940766435
Sandcastle Job Instance ID: 22517999172097970
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D48929200

fbshipit-source-id: 0a19658d278a4832a5defaba85c3f7c4f589167a
2023-09-02 01:01:49 -07:00
Peter Xu b0a9053e67 Update typings for StyleSheet.create to catch typos in style keys (#39225)
Summary:
Previously, when you tried to create some styles using `StyleSheet.create`, you can create styles with invalid styles:

```ts
const styles = StyleSheet.create({
  container: {
    marginLeft: 1,
    magrinRight: 1, // This is a typo, but would not cause typecheck errors
  },
});
```

The root cause is that Typescript uses a looser [Excess Property Checks](https://www.typescriptlang.org/docs/handbook/2/objects.html#excess-property-checks) if we're using template types rather than using the actual specific types in the function signature.

- https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/62481

## Changelog:

[INTERNAL] [FIXED] - Make StyleSheet.create better check property keys for typos

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

Test Plan: Added a test in __typeTests__, which should get run by CI.

Reviewed By: rshest

Differential Revision: D48859679

Pulled By: NickGerleman

fbshipit-source-id: 43aa69cf85cd69353d053b782dba73ab2027eb64
2023-09-01 21:40:37 -07:00
Jacob Parker 5f40f0800e Implement transform-origin for old arch iOS (#38626)
Summary:
Adds transform-origin for old arch iOS

See also intergalacticspacehighway's work for iOS Fabric and Android:-

- https://github.com/facebook/react-native/pull/38559
- https://github.com/facebook/react-native/pull/38558

## Changelog:

[IOS] [ADDED] - Added support for transform-origin on old arch

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

Test Plan: See RN tester

Reviewed By: NickGerleman

Differential Revision: D48528353

Pulled By: javache

fbshipit-source-id: 09592411e26484d81a999a7e601eff751ca7ae0b
2023-09-01 13:03:50 -07:00
Nishan 9e68599daf feat: android transform origin (#38558)
Summary:
This PR adds transform-origin support for android to make it easier to review. https://github.com/facebook/react-native/pull/37606#pullrequestreview-1513082850 by javache. I'll answer feedback from javache below.

## Changelog:
[Android] [ADDED] - Transform origin
<!-- 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/38558

Test Plan: Run iOS RNTester app in old architecture and test transform-origin example in `TransformExample.js`.

Reviewed By: NickGerleman

Differential Revision: D48528339

Pulled By: javache

fbshipit-source-id: e255a7f364e57396dada60b2c69c724cec406f51
2023-09-01 13:03:50 -07:00
Nishan 177ef21ea2 feat: ios fabric transform origin (#38559)
Summary:
This PR adds transform-origin support for iOS fabric. This PR also incorporates feedback/changes suggested by javache in the original [PR.](https://github.com/facebook/react-native/pull/37606)

## Changelog:
[IOS] [ADDED] - Fabric Transform origin
<!-- 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/38559

Test Plan: Run iOS RNTester app in old architecture and test transform-origin example in `TransformExample.js`.

Reviewed By: NickGerleman

Differential Revision: D48528363

Pulled By: javache

fbshipit-source-id: 347b7c5896ad19ad24278de81b0e055e4cb01016
2023-09-01 13:03:50 -07:00
Pieter De Baets a69bc7f1fd Simplify shadow node fragment placeholders (#39239)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39239

We can avoid static guards and heap allocation memory by forcing a default initialized shared_ptr (which is constexpr), and telling the compiler to not bother with registering a destructor, as these shared_ptr will never hold a value.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D48867013

fbshipit-source-id: c31f535bb19382878c9f21d7145188bd91b63265
2023-09-01 09:53:57 -07:00
Arushi Kesarwani 2b98cda74e Bridgeless -> Runtime in iOS (#39248)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39248

`Bridgeless` -> `Runtime` in .podspec

changelog: [internal] internal

Reviewed By: fkgozali, cipolleschi

Differential Revision: D48789176

fbshipit-source-id: bc656097e0274c7381e66117d91e7300d5c6f6c4
2023-09-01 09:45:48 -07:00
Ethan Gill 92d8428644 Remove superfluous JSI import? (#39247)
Summary:
Seems to be invalid given the other jsi import
Pull Request resolved: https://github.com/facebook/react-native/pull/39247

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D47380384

fbshipit-source-id: 226a3e213176e50b4c882b5ea3f10c57130bd494
2023-09-01 08:01:28 -07:00
Tomasz Sapeta a2dc4d70fa Fix downloading hermes for nightlies (#39243)
Summary:
https://github.com/facebook/react-native/pull/38963 introduced a regression that breaks downloading hermes tarball for nightlies. It fails with the following error when running `pod install`:

```
Fetching podspec for `hermes-engine` from `../../../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`
[!] Failed to load 'hermes-engine' podspec:
[!] Invalid `hermes-engine.podspec` file: undefined local variable or method `react_native_path' for Pod:Module
Did you mean?  react_native_post_install.
```

The root cause is that the `download_nightly_hermes` method was just not implemented.

## Changelog:

[IOS] [FIXED] - Fixed downloading hermes tarball for nightlies

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

Test Plan: After applying these changes, `pod install` in my project no longer fails and downloads the tarball correctly.

Reviewed By: dmytrorykun

Differential Revision: D48897925

Pulled By: cipolleschi

fbshipit-source-id: a504f01b739862bd092f22bca1f240f6df3a6df8
2023-09-01 06:38:45 -07:00
Elżbieta Berger aa2a0c1115 New RNtester e2e tests (#39117)
Summary:
The motivation was to create more e2e tests that test other components in the RNTester app.
The list of components that have been tested is below:

| Component|Test is added|Platform|
| :---        |    :----:   |---: |
|DrawerLayoutAndroid|NO|Android|
|ActivityIndicator|YES|iOS & Android|
|Button|YES|iOS & Android|
|FlatList|YES|iOS & Android|
|Image|NO|iOS & Android|
|JSResponderHandler|YES|iOS & Android|
|InputAccessoryView|NO|iOS|
|KeyboardAvoidingView|YES|iOS & Android|
|Modal|YES|iOS & Android|
|New App Screen|YES|iOS & Android|
|Pressable|YES|iOS & Android|
|RefreshControl|YES|iOS & Android|
|ScrollView|NO|iOS & Android|
|ScrollViewSimpleExample|YES|iOS & Android|
|SafeAreaView|NO|iOS|
|ScrollViewAnimated|NO|iOS & Android|
|ScrollViewIndicatorInsets|NO|iOS|
|SectionList|NO|iOS & Android|
|StatusBar|NO|iOS & Android|
|SwipeableCard|NO|iOS & Android|
|Switch|NO|iOS & Android|
|Text|NO|iOS & Android|
|TextInput|NO|iOS & Android|
|Touchable* and onPress|NO|iOS & Android|
|TextInputs with key prop|NO|Android|
|TransparentHitTestExample|NO|iOS|
|View|NO|iOS & Android|
|New Architecture Examples|NO|iOS & Android|
|Performance Comparison Examples|NO|iOS & Android|

## Changelog:

[General] [Added] - Added next component tests for RNTester

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

Test Plan:
Follow Readme file.

## Test Result:

For iOS platform:<br>
![Screenshot 2023-08-22 at 18 08 28](https://github.com/facebook/react-native/assets/19895261/c9d0ef78-ae31-487f-aa53-4c299fefef6a)

For Android platform:<br>
![Screenshot 2023-08-22 at 18 13 47](https://github.com/facebook/react-native/assets/19895261/db661c95-1cf9-4e1a-b02f-4a6141313719)

Reviewed By: yungsters

Differential Revision: D48828525

Pulled By: cipolleschi

fbshipit-source-id: dfe7cc9871666a6b5c0704a207ca1eeb65f50114
2023-09-01 03:24:30 -07:00
Ethan Gill 70fe5fc870 Delete unused CppComponentRegistry.java (#39246)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39246

Appears to no longer be used

Reviewed By: boxinYang

Differential Revision: D48872901

fbshipit-source-id: 3fd376b30304a1dc643ef77ffa503376dbbab7e7
2023-08-31 20:02:29 -07:00
Xin Chen c99c653398 Add PerformanceStatsHistory to perf monitor overlay (#39202)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39202

This diff adds `PerformanceStatsHistory.kt` which is used to track performance stat in buckets with resolution (in ms) and size. This is to help group perf stats in a time series data structure that we can adapt to any visualization in the future.

Changelog:
[Internal] - Performance monitoring overlay improvements

Reviewed By: rshest

Differential Revision: D48657874

fbshipit-source-id: 3e3fe7c50db6672b1eff117a36f0de72a774fc96
2023-08-31 14:26:26 -07:00
Alex Hunt a5fd0f17e9 Revert to built-in devToolsFrontendUrl in target list (#39242)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39242

Reverts external behaviour of https://github.com/facebook/react-native/pull/39122.

- `/json/list` once again returns the built-in `devtools://devtools/bundled/js_app.html` URL — effectively freezing the current experience in Flipper.
- `/open-debugger` continues to use the *new* frontend via `getDevToolsFrontendUrl`.
    - *Eventually*, we'll want to align this as the returned `devtoolsFrontendUrl` value once Flipper is out of the picture.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D48868767

fbshipit-source-id: 088ecebffa6ce45cb9bed44e3b02df4b7b471068
2023-08-31 09:36:00 -07:00
Moti Zilberman 0cd5648155 Fix up missing index.js in files (#39244)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39244

Changelog: [Internal]

TSIA. Fixup from D48680624.

#publish-packages-to-npm

bypass-github-export-checks

Reviewed By: huntie

Differential Revision: D48869800

fbshipit-source-id: 40733d09f9423232b4b5adb120bf268f8f7e4994
2023-08-31 09:19:52 -07:00
Dmitry Rykun 17df951fe9 Remove unused code from setup_hermes function (#39238)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39238

This does nothing useful. Let's get rid of it.
Changelog: [Internal]

Reviewed By: philIip

Differential Revision: D48833211

fbshipit-source-id: 0b6937f83148bb2ddc66212d2669e72887430364
2023-08-31 08:40:04 -07:00
Moti Zilberman 482207f602 Initial sync of debugger-frontend (#39226)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39226

Changelog: [Internal]

Syncs a custom build of the Chrome DevTools frontend (performed using the script in D48680624) into the `react-native/debugger-frontend` package. **The package is not used anywhere yet.** In a subsequent diff, it will be integrated into `react-native/dev-middleware`.

Review the `BUILD_INFO` file for information about the source revision and build settings that were used to generate this diff.

Reviewed By: huntie

Differential Revision: D48682302

fbshipit-source-id: 50ea532f45d8c751c141d5f4253afe080af31559
2023-08-31 08:34:33 -07:00
Moti Zilberman b27607f853 Add debugger-frontend package and manual build script (#39161)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39161

Changelog: [Internal]

Creates a new stub package named `react-native/debugger-frontend`, which will contain a minimal build of the Chrome DevTools frontend adapted for React Native. Initially, the compiled frontend assets will be checked into the React Native repo, but we intend to replace this with a fully automated build in CI at a later date.

Reviewed By: huntie

Differential Revision: D48680624

fbshipit-source-id: a24c8b019881187963d0be88e773bc0a97a2437d
2023-08-31 08:34:33 -07:00
Pieter De Baets c66d570eb9 Re-enable LayoutableShadowNodeTest inversion tests (#39211)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39211

Some tests were not running because they were disabled when experiment with `enableCalculateTransformedFrames`. Instead, run tests against both variants of the experiment so differences can be better understood.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D48826739

fbshipit-source-id: 5d6fd12e7ab396e4c2f6ee602cdc0aa47b8f45f3
2023-08-31 06:45:39 -07:00
Nick Gerleman ce32d07ed9 C++ Cleanup 7/N: BitUtils (#39223)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39223

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

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

## This diff

This splits up `BitUtils.h`, does some minor renaming, and namespace consistency fixes.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

bypass-github-export-checks

Reviewed By: shwanton

Differential Revision: D48847255

fbshipit-source-id: 4b9722303372f43e936118f8187c0127bceeb1d4
2023-08-31 01:17:39 -07:00
Nick Gerleman 12aca7bfd0 C++ Cleanup 6/N: YGFloatOptional (#39224)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39224

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

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

## This diff

This renames YGFloatOptional to FloatOptional, adds it to a namespace, and moves it to a subdirectory. This needs Fabric updates because Fabric uses Yoga internals for props storage.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Changelog: [Internal]

bypass-github-export-checks

Reviewed By: shwanton

Differential Revision: D48847256

fbshipit-source-id: ab9729a4a02ab90d974183425935f4d274db5732
2023-08-31 01:17:39 -07:00
Nick Gerleman 5225250005 C++ Cleanup 5/N: Reorganize Utils (#39222)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39222

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

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

## This diff

This splits `Utils.h` and `Utils.cpp`, and tweaks naming and namespaces.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

bypass-github-export-checks

Reviewed By: shwanton

Differential Revision: D48847260

fbshipit-source-id: b99df3029cd66257a7ae64de28c13e8751ceb20c
2023-08-31 01:17:39 -07:00
Nick Gerleman 4f755aa6e7 C++ Cleanup 4/N: Reorganize Log and YGNodePrint (#39220)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39220

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

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

## This diff

Moves these files to a `yoga/debug` subdirectory and does some mild renaming, namespace adjustment, and removes Yoga internal log function from list of library exports.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

bypass-github-export-checks

Reviewed By: shwanton

Differential Revision: D48847259

fbshipit-source-id: c1607b1c6457d5a47039c735cdb7c365a301ebc0
2023-08-31 01:17:39 -07:00
Nick Gerleman 5b06ba7201 C++ Cleanup 3/N: Reorganize YGNode (#39219)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39219

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

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

## This diff

This diff adds a top level `node` directory for code related to Yoga nodes and data structures on them (inc moving `YGLayout` to `LayoutResults`).

The public API for config handles is `YGNodeRef`, which is forward declared to be a pointer to a struct named `YGNode`. The existing `YGNode` is split into `yoga::Node`, as the private C++ implementation, inheriting from `YGNode`, a marker type represented as an empty struct. The public API continues to accept `YGNodeRef`, which continues to be `YGNode *`, but it must be cast to its concrete internal representation at the API boundary before doing work on it.

This change ends up needing to touch quite a bit, due to the amount of code that mixed and matched private and public APIs. Don't be scared though, because these changes are very mechanical, and Phabricator's line-count is 3x the actual amount due to mirrors and dirsyncs.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Changelog: [Internal]

bypass-github-export-checks

Reviewed By: shwanton

Differential Revision: D48847258

fbshipit-source-id: fc560893533b55a5c2d52c37d8e9a59f7369f174
2023-08-30 19:57:16 -07:00
Nick Gerleman a966291611 Consistent QualifierAlignment (for real this time I swear) (#39217)
Summary:
(reland of D48761722)

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

React Native uses an inconsistent mix of "west const" and "east const". E.g. `const auto &` in 74 files, but `auto const &` in 60. Sometimes they are mixed from one line to the next:  {F1079102436}

Clang format 14 adds a QualifierAlignment option, but fbsource is still on 12, so we cannot use it in our config until the [world is updated]()https://fb.workplace.com/groups/toolchain.fndn/posts/24006558685624673/?comment_id=24009214565359085&reply_comment_id=24009455088668366. This diff just runs a local version of Clang format locally first to fix QualifierAlignment, then reformats with the fbsource version, to fix any other output differences unrelated to that. This will not continually enforce a style, but will make the world more consistent, and hopefully encourage a consistent style until we can set it.

West const seems more popular in `//xplat` so I just picked left alignment somewhat arbitrarily, but we could also maybe take a poll on this.

Changelog: [Internal]

bypass-github-export-checks

Reviewed By: shwanton

Differential Revision: D48852450

fbshipit-source-id: 1789aa0db43948169f482188cb8b5e8f0f0246b8
2023-08-30 19:56:13 -07:00
Nick Gerleman a659065840 C++ Cleanup 2/N: Reorganize YGConfig (#39218)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39218

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

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

## This diff

This diff adds a top level `config` directory for code related to configuring Yoga and Yoga Nodes.

The public API for config handles is `YGConfigRef`, which is forward declared to be a pointer to a struct named `YGConfig`. The existing `YGConfig` is split into `yoga::Config`, as the private C++ implementation, inheriting from `YGConfig`, a marker type represented as an empty struct. The public API continues to accept `YGConfigRef`, which continues to be `YGConfig *`, but it must be cast to its concrete internal representation at the API boundary before doing work on it.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Changelog: [Internal]

Reviewed By: shwanton

Differential Revision: D48847257

fbshipit-source-id: 7a2157d169ba80a6f79620693ae45bb10dfca5a3
2023-08-30 16:27:32 -07:00
Nick Gerleman 294a50db93 C++ Cleanup 1/N: Reorganize YGStyle (#39221)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39221

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

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

## This diff

This diff adds a `style` directory for code related to storing and manipulating styles. `YGStyle`, which is not a public API, is renamed to `yoga::Style` and moved into this folder, alongside `CompactValue`. We will eventually add `ValuePool` alongside this for the next generation style representation.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Changelog: [Internal]

Reviewed By: shwanton

Differential Revision: D48847261

fbshipit-source-id: 0fc8c6991e19079f3f0d55d368574757e453fe93
2023-08-30 16:27:32 -07:00
Intl Scheduler 5f1404de02 translation auto-update for i18n/fb4a.config.json on master
Summary:
Chronos Job Instance ID: 1125907940671385
Sandcastle Job Instance ID: 27021598795851613
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D48837500

fbshipit-source-id: df1ca65f469348e42b54e3ded79116645dfca68d
2023-08-30 11:27:41 -07:00
Ruslan Shestopalyuk 0c292f3934 Fix bad formatting of generated C++ code (#39212)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39212

## Changelog:
[Internal] -

Some of the generated C++ code was badly formatted - even though it's normally not supposed to be read by humans, sometimes it's still useful/needed, so it helps when it's more readable.

Reviewed By: christophpurrer

Differential Revision: D48827010

fbshipit-source-id: 3481af68ee6158902007c431e72e631d852c8b3c
2023-08-30 10:40:47 -07:00
Blazej Kustra 904d3e8ec9 Add missing type for TextInput.setSelection in Typescript (#39209)
Summary:
The `setSelection` method is available in the `TextInput` implementation [here](https://github.com/blazejkustra/react-native/blob/316c19a91d2548124b04a97427cf7a13e06fca4e/packages/react-native/Libraries/Components/TextInput/TextInput.js#L1256), but the corresponding TypeScript type is currently missing. Notably, this method is included in the Flow types [here](https://github.com/blazejkustra/react-native/blob/316c19a91d2548124b04a97427cf7a13e06fca4e/packages/react-native/Libraries/Components/TextInput/TextInput.flow.js#L944). It would be beneficial to have this method included in TypeScript types for consistency and comprehensive type support.

## Changelog:

[GENERAL] [ADDED] - Add missing type for TextInput.setSelection in Typescript

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

Test Plan: N/A

Reviewed By: christophpurrer

Differential Revision: D48824510

Pulled By: rshest

fbshipit-source-id: b69bd46c95bdbeac407c560f0aa271f393706e0c
2023-08-30 08:45:09 -07:00
Riccardo Cipolleschi 2423342004 Check if cmake is installed on RNTester (#39208)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39208

To properly build RNTester for iOS, we need cmake installed.
This small change check whether Cmake is present in the system. If not, it tries to install it using `brew` if that's available.
Otherwise, it exits with an error message asking to install cmake.

## Changelog:
[Internal] -  Check whether Cmake is present for RNTester

Reviewed By: dmytrorykun

Differential Revision: D48821932

fbshipit-source-id: 94f1000a22a9f9d06efdec70b37698b99af358e5
2023-08-30 06:12:37 -07:00
Ruslan Shestopalyuk 40dca3f0db Only include missing native module once in the TurboModuleRegistry debug reporting (#39207)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39207

## Changelog:
[Internal] -

Fixes a minor annoyance, whereas if a native module implementation is missing, then it may spam the "NotFound" list with many entries.

Reviewed By: javache

Differential Revision: D48819392

fbshipit-source-id: 6962375ada5f1889be61c9879c8fc07dd2286c3d
2023-08-30 04:44:23 -07:00
Intl Scheduler b5ac6189ce translation auto-update for i18n/fb4a.config.json on master
Summary:
Chronos Job Instance ID: 1125907940661998
Sandcastle Job Instance ID: 1036130717
allow-large-files
ignore-conflict-markers
opt-out-review

Differential Revision: D48825599

fbshipit-source-id: 73c1f91681b5cf02c48c2cf08fa73f37751f4408
2023-08-30 04:37:29 -07:00
Zhiyao Zhou 796cdea6fa Revert D48710084: C++ Cleanup 1/N: Reorganize YGStyle
Differential Revision:
D48710084

Original commit changeset: 20961aee30d5

Original Phabricator Diff: D48710084

fbshipit-source-id: 79cda4f13979b8d0cdf87dabbfc13cbd17abe488
2023-08-29 23:27:25 -07:00
Zhiyao Zhou 53df1d3fa8 Revert D48710796: C++ Cleanup 2/N: Reorganize YGConfig
Differential Revision:
D48710796

Original commit changeset: d548553f7ce8

Original Phabricator Diff: D48710796

fbshipit-source-id: c8b2de245f3894f6a87c262ec70d313020aa228e
2023-08-29 23:27:25 -07:00
Zhiyao Zhou 8da095ca56 Revert D48712710: C++ Cleanup 3/N: Reorganize YGNode
Differential Revision:
D48712710

Original commit changeset: d28eae38469a

Original Phabricator Diff: D48712710

fbshipit-source-id: 7a10b071edcf045ce98bbf8f9deca0d0e2e80a14
2023-08-29 23:27:25 -07:00
Zhiyao Zhou ebba73fc28 Revert D48763820: C++ Cleanup 4/N: Reorganize Log and YGNodePrint
Differential Revision:
D48763820

Original commit changeset: 7e3ed7354497

Original Phabricator Diff: D48763820

fbshipit-source-id: 1bea996374f14481160aba8f87940c00e229aa69
2023-08-29 23:27:25 -07:00
Zhiyao Zhou 3030cb0113 Revert D48767465: C++ Cleanup 5/N: Reorganize Utils
Differential Revision:
D48767465

Original commit changeset: da7157953292

Original Phabricator Diff: D48767465

fbshipit-source-id: 0dd948e2c4e6b3aaeb6e197b28b565c0b385d033
2023-08-29 23:27:25 -07:00
Zhiyao Zhou 49b13c6dbf Revert D48767992: C++ Cleanup 6/N: YGFloatOptional
Differential Revision:
D48767992

Original commit changeset: afaff0234359

Original Phabricator Diff: D48767992

fbshipit-source-id: 4666bdbb83aebbf2f7373b3a10a8c1dd0a03f92c
2023-08-29 23:27:25 -07:00
Zhiyao Zhou 1101edd246 Revert D48768374: C++ Cleanup 7/N: BitUtils
Differential Revision:
D48768374

Original commit changeset: 921a22ec88bd

Original Phabricator Diff: D48768374

fbshipit-source-id: 59106ab3d03619940023dac1c2af62fd88566773
2023-08-29 23:27:25 -07:00
Nick Gerleman 5ea2d6162a C++ Cleanup 7/N: BitUtils (#39200)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39200

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

## This diff

This splits up `BitUtils.h`, does some minor renaming, and namespace consistency fixes.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Reviewed By: rshest

Differential Revision: D48768374

fbshipit-source-id: 921a22ec88bd470da1ef9b51f8954afc073d327d
2023-08-29 21:32:56 -07:00
Nick Gerleman 1c2b562b25 C++ Cleanup 6/N: YGFloatOptional (#39196)
Summary:
X-link: https://github.com/facebook/yoga/pull/1356

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

## This diff

This renames YGFloatOptional to FloatOptional, adds it to a namespace, and moves it to a subdirectory. This needs Fabric updates because Fabric uses Yoga internals for props storage.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D48767992

fbshipit-source-id: afaff023435915dbd5e571fd1ee2e695e4f59a5c
2023-08-29 21:32:56 -07:00
Nick Gerleman 079d33dcef C++ Cleanup 5/N: Reorganize Utils (#39199)
Summary:
X-link: https://github.com/facebook/yoga/pull/1357

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

## This diff

This splits `Utils.h` and `Utils.cpp`, and tweaks naming and namespaces.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Reviewed By: rshest

Differential Revision: D48767465

fbshipit-source-id: da71579532924b3a912454163fe281c481770a77
2023-08-29 21:32:56 -07:00
Nick Gerleman 68b5e6a65f C++ Cleanup 4/N: Reorganize Log and YGNodePrint (#39197)
Summary:
X-link: https://github.com/facebook/yoga/pull/1354

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

## This diff

Moves these files to a `yoga/debug` subdirectory and does some mild renaming, namespace adjustment, and removes Yoga internal log function from list of library exports.

## This stack

The organization of the C++ internals of Yoga are in need of attention.
1. Some of the C++ internals are namespaced, but others not.
2. Some of the namespaces include `detail`, but are meant to be used outside of the translation unit (FB Clang Tidy rules warn on any usage of these)
2. Most of the files are in a flat hierarchy, except for event tracing in its own folder
3. Some files and functions begin with YG, others don’t
4. Some functions are uppercase, others are not
5. Almost all of the interesting logic is in Yoga.cpp, and the file is too large to reason about
6. There are multiple grab bag files where folks put random functions they need in (Utils, BitUtils, Yoga-Internal.h)
7. There is no clear indication from file structure or type naming what is private vs not
8. Handles like `YGNodeRef` and `YGConfigRef` can be used to access internals just by importing headers

This stack does some much needed spring cleaning:
1. All non-public headers and C++ implementation details are in separate folders from the root level `yoga`. This will give us room to split up logic and add more files without too large a flat hierarchy
3. All private C++ internals are under the `facebook::yoga` namespace. Details namespaces are only ever used within the same header, as they are intended
4. Utils files are split
5. Most C++ internals drop the YG prefix
6. Most C++ internal function names are all lower camel case
7. We start to split up Yoga.cpp
8. Every header beginning with YG or at the top-level directory is public and C only, with the exception of Yoga-Internal.h which has non-public functions for bindings
9. It is not possible to use private APIs without static casting handles to internal classes

This will give us more leeway to continue splitting monolithic files, and consistent guidelines for style in new files as well.

These changes should not be breaking to any project using only public Yoga headers. This includes every usage of Yoga in fbsource except for RN Fabric which is currently tied to internals. This refactor should make that boundary clearer.

Reviewed By: rshest

Differential Revision: D48763820

fbshipit-source-id: 7e3ed7354497a7e85b2a1f20ab50b0e2baeb4862
2023-08-29 21:32:56 -07:00