Commit Graph

2198 Commits

Author SHA1 Message Date
Nick Gerleman
4fc1657f2c Basic CocoaPods Validation (#1303)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1303

This gets `pod lib lint` and building the sample app with xcbuild passing (using https://github.com/facebook/yoga/pull/1105 as a template).

Reviewed By: cipolleschi

Differential Revision: D46470738

fbshipit-source-id: f66f6c6efc1b7cf1443fbca0815a24801c16a626
2023-06-06 14:56:44 -07:00
Nick Gerleman
5e74e20a4d Remove In-tree C# Bindings (#1302)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1302

These C# bindings were contributed as part of ff8f17ac99. They have occasionally been refreshed, but has never really had validation it built continuously, or dedicated maintenance.

There has been a surge of work with https://github.com/facebook/yoga/pull/1207 to try to modernize the build for these, but checking with jkoritzinsky I'm not sure either of us have the time to commit to supporting these at the same level as other bindings.

Some well-known projects like Unity had already abandoned this set of bindings for their own. 016297e35c (diff-c85198aaac9095a5446ed00b0fba8025072d235b2b69dea8aad85abc64a83e1e)

So, as part of the work for an official OSS release, and really trying to define what is deprecated, and what we will try to support, I am removing the in-tree C# bindings from Yoga.

In the past, gaps in Yoga bindings we haven't supported have led to new bindings with dedicated maintainers e.g. [FlexLayout](https://github.com/layoutBox/FlexLayout), [yoga-rs](https://github.com/bschwind/yoga-rs), [yoga-wasm-web](https://github.com/shuding/yoga-wasm-web). My hope is that by removing the C# bindings that we are not supporting, we free up the opportunity for a new version to become the defacto.

Reviewed By: javache

Differential Revision: D46425886

fbshipit-source-id: df964c4d55adf93c4d1e82c104e74ca5ad181612
2023-06-05 10:48:10 -07:00
Nicola Corti
1ab0c7b493 Add a Github Action to publish SNAPSHOTS after every commit.
Summary: I'm adding this action which will setup publishing of `-SNAPSHOT` version after every commit to main.

Reviewed By: mdvacca

Differential Revision: D46330012

fbshipit-source-id: 8d9f32a357f157a8f2e05c88074befd8dd871c94
2023-05-31 15:22:21 -07:00
Nicola Corti
9a0ba05d13 Setup publishing of snapshots using io.github.gradle-nexus.publish-plugin
Summary:
This sets up publishing of -SNAPSHOT verison of Yoga using the
Gradle plugin `io.github.gradle-nexus.publish-plugin`

This plugin will take care of setting up the credentials for Sonatype and hitting the Maven repository.
I've cleaned up the setup and centralized it inside a script plugin in the `build-logic` folder so we can easily add more module and just use `id("publish")` to publish them as well.

Reviewed By: mdvacca

Differential Revision: D46330013

fbshipit-source-id: 7221b296b9955a257fc290a2d1ac1d9fedfb787d
2023-05-31 15:22:21 -07:00
Nicola Corti
186f4d318d Update project to use Gradle's plugins{} block
Summary:
This project was still using the legacy Gradle's "apply:" syntax
to apply Gradle Plugins. I'm changing it here to use instead the
`plugins{}` block as it make easier to apply other plugins for publishing later.

Reviewed By: mdvacca

Differential Revision: D46330014

fbshipit-source-id: 5483a717a62d5ab76749026c5203dc96a35d73e7
2023-05-31 14:48:05 -07:00
Nick Gerleman
f2b4e42ca2 Change how we set cmake policy (#1288)
Summary:
X-link: https://github.com/facebook/react-native/pull/37349

Pull Request resolved: https://github.com/facebook/yoga/pull/1288

Fixes https://github.com/facebook/yoga/issues/1283

New versions of CMake add "policies" which control how the build system acts wrt breaking changes. By default, CMake will emulate the behavior of the version specified in `cmake_minimum_required`.

Setting a policy to true (to opt into new behavior where `cmake_minimum_required` is lower than the current version) seems actually just error out on the old versions.

Googling around, apparently the way I should be doing this is to specify `<policy_max>` as part of `cmake_minimum_required `. https://gitlab.kitware.com/cmake/cmake/-/issues/20392

This should I think use new policies introduced up to 3.26 (what we test on right now), while letting 3.13 be the minimum.

Reviewed By: cortinico

Differential Revision: D45724864

fbshipit-source-id: 120cc2015a043605e7c07ef0459667643a4284b7
2023-05-15 15:21:56 -07:00
Nick Gerleman
3fb698c08b Remove pinned CMake version from Gradle build (#1292)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1292

AGP 8.0 will now bring in a new enough CMake version to avoid internal warnings without extra configuration.

Reviewed By: cortinico

Differential Revision: D45766980

fbshipit-source-id: 7834f723c87ec76c450a94958cd36b4930a8961a
2023-05-15 14:03:00 -07:00
Patryk Ozga
6f31ea8e03 remove extra semis from arfx/atlas/modules and deps attempt 2 (#1299)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1299

X-link: https://github.com/facebook/igl/pull/22

deletes semicolons and adds whitespace sometimes

moved the runtime ipc chages int a seperate diff

Reviewed By: KSRandom

Differential Revision: D45835378

fbshipit-source-id: 2890e93620af4cadd33b9c8c9149157d9078fa32
2023-05-15 13:15:29 -07:00
Junfeng Li
974473aa99 Revert D45722118: remove extra semis from arfx/atlas/modules and deps
Differential Revision:
D45722118

Original commit changeset: a749ca9e979d

Original Phabricator Diff: D45722118

fbshipit-source-id: 9316f2946966e001f0884af17bf733a1a48e75cc
2023-05-12 15:57:47 -07:00
Patryk Ozga
13e2b5ee73 remove extra semis from arfx/atlas/modules and deps (#1289)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1289

X-link: https://github.com/facebook/react-native/pull/37360

X-link: https://github.com/facebook/litho/pull/947

X-link: https://github.com/facebook/igl/pull/21

Reviewed By: nlutsenko, NickGerleman

Differential Revision: D45722118

fbshipit-source-id: a749ca9e979d4447e65d075493c251169f81c289
2023-05-12 12:44:37 -07:00
Nick Gerleman
6db81656ac Make jni_YGNodeDeallocateJNI call YGNodeDeallocate
Summary:
X-link: https://github.com/facebook/react-native/pull/37388

Fixes https://github.com/facebook/yoga/issues/1271

Updating this glue was missed in D45556206 when moving from one revision to the other...

Reviewed By: yungsters

Differential Revision: D45780647

fbshipit-source-id: 4ca64bc9971d3e4697990e73b618a3dc91df259b
2023-05-11 13:30:49 -07:00
Nick Gerleman
e53d1ee28a Enable -Wextra in C++ builds (#1294)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1294

X-link: https://github.com/facebook/react-native/pull/37383

Add -Wextra to the build, and fixup some more instances of -Wunused-parameter that it sufaces which were not automatically fixable.

Reviewed By: javache

Differential Revision: D45772846

fbshipit-source-id: 29bf71006f63161521fe5869c3a7d8bf7aae9c81
2023-05-11 09:43:36 -07:00
Nick Gerleman
a97dbecb49 Apply fixes from clag-tidy misc-unused-parameters (#1293)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1293

X-link: https://github.com/facebook/react-native/pull/37384

Gets the project mostly clean of `-Wunused-parameter`, part of `-Wextra`.

Reviewed By: yungsters

Differential Revision: D45772554

fbshipit-source-id: db4c4d2bd222debef178c4c16f7b60fb6c8db2a2
2023-05-11 09:43:36 -07:00
Nick Gerleman
9e1b14cd9e Add hasErrata(), addErrata(), removeErrata()
Summary:
X-link: https://github.com/facebook/react-native/pull/37375

Adds internal helpers to YGConfig to make bit manipulation more readable. We also expose `hasErrata()` to YGNode beacuse checking that will be a common pattern. We intentionally don't add mutating functions to the node, since current model is to inval a node on commiting whole config.

This is not exposed via the C ABI.

Reviewed By: yungsters

Differential Revision: D45765971

fbshipit-source-id: eadaee4b9cf5204ac4984ecc52cc08650d144a30
2023-05-11 05:30:57 -07:00
Nick Gerleman
3b088c3383 Fix use-after-free if JNI Yoga nodes are garbage collected using multiple threads (#1279)
Summary:
X-link: https://github.com/facebook/react-native/pull/37243

X-link: https://github.com/facebook/litho/pull/944

Pull Request resolved: https://github.com/facebook/yoga/pull/1279

Java bindings for Yoga rely solely on garbage collection for memory management. Each Java `YogaNode` has references to its children and parent Java Nodes. This means, for a node to be garbage collected, it cannot be reachable from any user accessible node. Each node then has single ownership of a `YGNodeRef`. When the `YogaNode` is garbage collected, a finalizer is run to call `YGNodeFree` and free the underlying native Yoga Node.

This may cause a use-after-free if finalizers are run from multiple threads. This is because `YGNodeFree` does more than just freeing, but instead also interacts with its parent and children nodes to detach itself, and remove any dangling pointers. If multiple threads run finalizers at once, one may traverse and try to mutate a node which another is freeing.

Because we know the entire connected tree is dead, there is no need to remove dangling pointers, so I want to expose a way to just free a Yoga Node, without it mutating the tree as a side effect.

This adds a currently private `YGNodeDeallocate` that frees without traversal. Ideally from naming this is what `YGNodeFree` would do, but we think changing the behavior of that might be too disruptive to OSS. At the same time there may be other memory safety related API changes we would like to eventually make, so this isn't made public beyond the JNI bindings to prevent needing to transition more APIs.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D45556206

fbshipit-source-id: 62a1394c6f6bdc2b437b388098ea362a0fbcd0f7
2023-05-10 22:52:48 -07:00
Nick Gerleman
149849d22b Move generated Jest tests to TypeScript (#1287)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1287

Outputs tests as TypeScript, along with using/testing the new form of enums imported directly from the package.

We need to change how we are telling Jest which variant to run, so that tests can import enums from "yoga-layout" and have it resolve to the entrypoint which has a binary which has already been built.

Reviewed By: yungsters

Differential Revision: D45723545

fbshipit-source-id: 887d929344a78cadec159a07c643b74b76b87c6c
2023-05-10 22:46:39 -07:00
Nick Gerleman
e769dd97d8 Add data-disabled to test fixtures (#1286)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1286

This can be marked in fixtures to skip a test without commenting it out. We add one more usage of this.

The same functionality existed (unused) before for `experiments`, which I changed to `data-experiments`.

Formatting of JS tests changed to be closer to what Prettier would output, and to remove usage of `Yoga.UNDEFINED` which doesn't existi and just resolves to `undefined` (this is converted to NaN by the wrapper layer).

Reviewed By: yungsters

Differential Revision: D45723003

fbshipit-source-id: 337af319ab1c1c12047d6579da8c7e63b4f1537a
2023-05-10 22:46:39 -07:00
Nick Gerleman
e409bfb43a Use babel-node instead of ts-node when running benchmark script
Summary:
`ts-node` does transformation using tsc. Do transformation with Babel instead so that the generation is consistent with Jest and the packed output.

We still need `ts-node` around since various systems rely on it being present to enable `.ts` config files.

This also enables transformation of any JS files.

Reviewed By: yungsters

Differential Revision: D45722106

fbshipit-source-id: 51b7a4f6a1532bea1133d59e626297d3b40f1762
2023-05-10 17:12:10 -07:00
generatedunixname89002005325679
82096a1465 Daily arc lint --take PRETTIERJAVASCRIPT
Reviewed By: adamjernst

Differential Revision: D45725703

fbshipit-source-id: efab6e4a84888178066be723ebb7915830792791
2023-05-10 07:04:59 -07:00
Nick Gerleman
af89315fd4 Fixup TypeScript with export maps (#1284)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1284

This makes TypeScript resolution play nicely with export maps, and converts the entrypoints to TypeScript.

We remove the non-export-map fallbacks as well, so the export maps are always followed.

Tests are moved to load yoga from its external export, testing the entrypoints.

This moves the only untyped bit to the binary wrapper, which another diff will move.

Reviewed By: yungsters

Differential Revision: D45713689

fbshipit-source-id: 228e6f2c9d53520230707a81e76c3c35fcd46de5
2023-05-09 22:21:01 -07:00
Nick Gerleman
104646d8ca Namespaced and TypeScript Enums (#1285)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1285

Enums are currently exposed to the JS package as constants (e.g. `import {ERRATA_NONE} from 'yoga-layout'`).

This exports enums in the form of `import {Errata} from 'yoga-layout'` then `Errata.None`.

It would be more ergonomic for these to be string union based enums instead, but right now it is a pretty thin wrapper around the native API, we need ordinal values to do things with bit masks, and folks have wanted to serialize them before.

Reviewed By: yungsters

Differential Revision: D45570417

fbshipit-source-id: dbfd330e939051d0c16460a4d2a996f88f98875c
2023-05-09 22:21:01 -07:00
Nick Gerleman
aa812d0e48 In-place JS environment
Summary:
This change restructures the package to try to remove the JS build step from the inner loop. Instead, we have a single `src` directory that we babel transform when using, then apply the same transform inline during prepublish.

At the end, we will be publishing a source directory with Babel transformed TS, JS, and TS declarations.

We do a little spring cleaning when doing this. Fixing up some of the folder/file conventions, and removing the non-export-map fallbacks.

We cannot remove the need for a native build.

Reviewed By: yungsters

Differential Revision: D45682153

fbshipit-source-id: ea2dd75c2dd6e3529b1ef6cf6ac6a64a270049a4
2023-05-09 15:35:42 -07:00
Nick Gerleman
0a6a581936 Match xplat/yoga/javascript prettier conventions
Summary:
Match Prettier config to match other Meta OSS projects

Didn't update the test generator to use this form yet.

Reviewed By: yungsters

Differential Revision: D45570415

fbshipit-source-id: d5fd791b047debf41c28aecac75fb8dde16da3e3
2023-05-09 15:35:42 -07:00
Nick Gerleman
0cb4a49d38 Convert manually authored tests to TypeScript
Summary: Converts the manually authored tests against the JavaScript bindings to TypeScript. This should make authoring UTs a bit more pleasent, but more importantly lets us run typechecking on sample usage of all of the various APIs.

Reviewed By: yungsters

Differential Revision: D45570416

fbshipit-source-id: 44586b4d31fbeae406b388ed336a8305c788b5dd
2023-05-09 15:35:42 -07:00
Nicola Corti
172bd0a88e Let the Yoga sample app compile
Summary:
The sample app is really old and has a lot of legacy code. Here I'm refreshing it a bit.
Will do another pass later (perhaps rewrite it in Kotlin?).

Reviewed By: mdvacca

Differential Revision: D45694414

fbshipit-source-id: 36a84609b0dcf5b4a5237da900f665e4eb7895a5
2023-05-09 10:43:02 -07:00
Nicola Corti
420f0016c6 Hook Yoga's Gradle build into Gradle Enterprise
Summary: This adds the setup necessary to hook Yoga into a Gradle Enterprise instance

Reviewed By: mdvacca

Differential Revision: D45694413

fbshipit-source-id: 766ea7e05f99ae347853dbe3817521379b4e44ba
2023-05-09 09:48:55 -07:00
Nick Gerleman
a1fbbc6070 Fix YGNodeSetConfig causing excessive dirtying
Summary:
X-link: https://github.com/facebook/react-native/pull/37316

In Fabric, a ShadowNode may re-initialize YGConfig several times throughout the lifetime of a perpetually cloned Yoga Node.

RN sets `pointScaleFactor` lazily, when laying out the rootview. So right now it initializes a config to `pointScaleFactor` of 1.0, sets it, sets a new `pointScaleFactor` on the config, then repeats. This cycles the config between two `pointScaleFactor` values and will excessively dirty the node now that `YGNodeSetConfig` dirties on config change (D45505089)

This change makes it so that we retain previously used `pointScaleFactor` when cloning the Yoga nodes.

Changelog: [Internal]

Reviewed By: rozele

Differential Revision: D45669878

fbshipit-source-id: bfd2e185d9264a1cda64e59132960060385e16f1
2023-05-08 16:30:06 -07:00
Nick Gerleman
b8126cdc6c Dirty nodes when dynamically setting config (#37207)
Summary:
X-link: https://github.com/facebook/react-native/pull/37207

Pull Request resolved: https://github.com/facebook/yoga/pull/1274

Yoga exposes public APIs for dirtying Nodes, but will itself perform dirty marking when changing bits which invalidate layout. E.g. changing the style of a Node will invalidate it along with every parent Node.

Because config setting is newly public to the C ABI, this makes a similar change so that replacing a Node's config will dirty the tree above the node if there is a layout impacting config change (I don't think children need to be invalidated since child output shouldn't change given the same owner dimensions).

One quirk of this is that configs may be changed independently of the node. So someone could attach a config to a Node, then change the live config after the fact. The config does not currently have a back pointer to the Node, so we do not invalidate in that case of live config edits. The future work to rectify this would be to make configs immutable once created.

There are also currently some experimental features here which should maybe be compared, but these should be moved to YGErrata anyway.

Reviewed By: javache

Differential Revision: D45505089

fbshipit-source-id: 72b2b84ba758679af081d92e7403750c9cc53cb5
2023-05-07 00:34:02 -07:00
Nicola Corti
54d78926ce AGP to 8.0.1 (#1280)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1280

I'm refreshing some of the dependencies of the project,
here doing AGP to 8.0.1.
I'm also removing the older publishing plugin as we're most likely going to use
Gradle's default publishing + another plugin to manage the nexus interactions (the same we use on React Native).

I'm also doing some changes on the JDK side:
- Bumps the JDK version to 17 as that's required by AGP
- Bumps the source/target version to JDK 8. JDK 7 is long deprecated and we're getting a lot of warnings for it on console. Users should be on JDK 11 already by now, but 8 is also good enough.

Reviewed By: passy

Differential Revision: D45564575

fbshipit-source-id: ffe1cc15892659923177a2cad609d5d30f8249ac
2023-05-05 04:07:40 -07:00
Nicola Corti
3a69a040c4 local.properties to gitignore
Summary:
When trying to open Yoga on Android studio, the local.properties file gets created and added
to the untracked files. This file should not be committed so I'm .gitignoring it.

Reviewed By: mdvacca

Differential Revision: D45564577

fbshipit-source-id: 62c8c8798b539cd6db6e341ee321e27239c25b87
2023-05-04 11:30:01 -07:00
Nicola Corti
1712b38282 Gradle to 8.1
Summary:
I'm refreshing some of the dependencies of the project,
starting with Gradle to 8.1

Reviewed By: mdvacca

Differential Revision: D45564578

fbshipit-source-id: 9570d0026a1c5c4e15921a411b80471f5c5e8ebd
2023-05-04 11:30:01 -07:00
Nick Gerleman
44ea3c1555 Add types to scripts and config files (#1277)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1277

Now that we have some TypeScript infra set up, move scripts (mainly the benchmarking one) and config files to TypeScript.

Starts to move away a bit from the magic globals used in the JS environment.

Reviewed By: yungsters

Differential Revision: D45511176

fbshipit-source-id: 09bb1117a1b331758ed9d210e82d5b250577df81
2023-05-04 08:11:04 -07:00
Nick Gerleman
19aed1d63e Lint and typecheck TypeScript (#1276)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1276

This change starts to enlighten linting and other repo configuration to TypeScript. This was previously special-cased out of linting, and meant we were not linting everything. It is also a precondition to do real typechecking and linting our definitions with type information.

1. Add TypeScript dependencies
1. Configure ESLint, Babel, tsc for TypeScript
1. Run tsc as part of linting (OSS only for now)

This is continued in another change with adding types to scripts and config files, but more importantly converting hand-written tests and test generation to TypeScript, so we get real-world usage to typecheck against for testing.

Reviewed By: yungsters

Differential Revision: D45508576

fbshipit-source-id: 6d2e48b9d25bb6b1788440ea3515ea5f5c64d346
2023-05-04 08:11:04 -07:00
Nick Gerleman
70153cc16c Try to fix MSVC Buck Build (#37242)
Summary:
X-link: https://github.com/facebook/react-native/pull/37242

Pull Request resolved: https://github.com/facebook/yoga/pull/1278

Reviewed By: yungsters

Differential Revision: D45552325

fbshipit-source-id: 5687e8ec27a7a70df66e2f89e800210e3ce21ba3
2023-05-04 00:41:12 -07:00
Nick Gerleman
f3633a256b TypeScript fixes (#1275)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1275

A pending change revamps a lot of how ESLint, Prettier, and Jest are configured in the repo, along with moving the world to TypeScript (and adding tsc usage).

That still needs some work to split up, but this change adds types used in our unit tests that I found were missing.

Reviewed By: yungsters

Differential Revision: D45506781

fbshipit-source-id: c4c5cb3aeff95f16bd54121e2ca0e042b6429ba0
2023-05-03 16:11:20 -07:00
Nick Gerleman
d8dec0f85a Don't export private headers from Buck target (#1269)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1269

X-link: https://github.com/facebook/react-native/pull/37127

This prevents targets which include Yoga from using its private APIs.

Instances of this have been mostly cleaned up in the past diffs, with the major exception of RN Fabric. To stage this without blocking on that, I added a `yoga-private-api` target for now to keep using these headers while making it unlikely new usages will show up.

Reviewed By: javache

Differential Revision: D45339425

fbshipit-source-id: eb7ef151ad2467d7c3370cd7c10d47e8db9496a0
2023-05-02 18:08:58 -07:00
Nick Gerleman
080d16cabf Cleanup YGValue.h header (#37179)
Summary:
X-link: https://github.com/facebook/react-native/pull/37179

Pull Request resolved: https://github.com/facebook/yoga/pull/1273

1. Simplify nan handling a bit
2. Remove string literal operators which seem dead enough to remove. These are public, so anyone could be using them, but it seems like almost nobody is.
    1. FB has no usages of `using namespace facebook::yoga::literals` (exposing the literal operators) outside of Yoga tests.
    1. There is only [a single usage](6dfba905ea/SDLTest/UIKit.hpp (L19)) on GitHub.

Reviewed By: yungsters

Differential Revision: D45419970

fbshipit-source-id: 8121303e5ae66596132a848a711802081728f4fb
2023-05-02 17:08:24 -07:00
Nick Gerleman
3156cb207f Fix YG_DEPRECATED in MSVC C Build (#37178)
Summary:
X-link: https://github.com/facebook/react-native/pull/37178

Pull Request resolved: https://github.com/facebook/yoga/pull/1272

Forgot to export this one to the Yoga repo to test the MSVC bits...

Reviewed By: yungsters

Differential Revision: D45432859

fbshipit-source-id: 8d5f2daacb00daab67de111410329f8db80475e0
2023-04-30 11:06:02 -07:00
Nick Gerleman
f32d37a3d5 Deprecate YGConfigSetUseLegacyStretchBehaviour (#37117)
Summary:
X-link: https://github.com/facebook/react-native/pull/37117

Pull Request resolved: https://github.com/facebook/yoga/pull/1265

This deprecates `YGConfigSetUseLegacyStretchBehaviour` and `YGConfigGetUseLegacyStretchBehaviour`and points users to errata APIs instead. Using the C API will fire deprecation warnings, which should create errors in builds with `-Werror`, though they can be ignored if truly needed (like we do with the language bindings which need to expose their own deprecated interface).

Reviewed By: rshest

Differential Revision: D45337198

fbshipit-source-id: 7f069623e38834171f5702382bbf47c37a556a22
2023-04-30 08:20:05 -07:00
Nick Gerleman
893b3e3957 Add JavaScript bindings for Errata API (#1260)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1260

Wire C ABI to embind to expose to JS

Reviewed By: yungsters

Differential Revision: D45297215

fbshipit-source-id: ef832ad423703496a550b864ebee70525a858b50
2023-04-27 13:53:45 -07:00
Nick Gerleman
215f0a9d6d Add C# bindings for Errata API (#1259)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1259

Wires C ABI to C# bindings using `System.Runtime.InteropServices`. Note that we don't have a working C# build right now, but there is [effort to address that](https://github.com/facebook/yoga/pull/1207) which may get some more effort before the Yoga release, so this keeps the bindings up to date.

Reviewed By: yungsters

Differential Revision: D45297676

fbshipit-source-id: 408f84d74ebbc7698407e951e831627117cbc2ed
2023-04-27 13:53:45 -07:00
Nick Gerleman
c1a5219b03 Move YogaKit to YGErrataClassic (#1261)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1261

YogaKit integrates Yoga with UIKit as a higher level framework. It does not expose config setting to users.

We set YGErrataClassic for now to prioritize compatibility instead of conformance (YogaKit is relatively used in fbsource as well).

I'm also tempted to remove the usage of ExperimentalWebFlexBasis since last I heard rozelle thought it was generally broken, but I am a bit afraid to if it has been enabled so long, and is used in many cases in Meta.

Reviewed By: yungsters

Differential Revision: D45298803

fbshipit-source-id: 92f72148fafbdaffba4589c18c8b46591ca7c364
2023-04-27 13:53:45 -07:00
Nick Gerleman
26a7f72124 Deprecate Java YogaConfig.setUseLegacyStretchBehaviour() (#37095)
Summary:
X-link: https://github.com/facebook/react-native/pull/37095

Pull Request resolved: https://github.com/facebook/yoga/pull/1262

X-link: https://github.com/facebook/litho/pull/942

Now that our own usages are removed, mark this as deprecated to encourage users to move to the errata API. The same will be done to variants of this function on other platforms before releasing, and the functions will be removed after releasing.

Reviewed By: yungsters

Differential Revision: D45300343

fbshipit-source-id: 1ecb2b25021f43a0c97ae6e7976317d28551abea
2023-04-27 12:32:28 -07:00
Nick Gerleman
4692e97ba0 Add Java bindings for Errata API (#37096)
Summary:
X-link: https://github.com/facebook/react-native/pull/37096

Pull Request resolved: https://github.com/facebook/yoga/pull/1263

JNI glue to expose `YogaConfig.setErrata()` and `YogaConfig.getErrata()`.

Reviewed By: yungsters

Differential Revision: D45296538

fbshipit-source-id: 8d743d278b7df43f7843a79d8f4542bfb03fc08d
2023-04-27 06:48:04 -07:00
Nick Gerleman
fc6485b8cd Add YGErrata integration within C ABI (#37075)
Summary:
X-link: https://github.com/facebook/react-native/pull/37075

Pull Request resolved: https://github.com/facebook/yoga/pull/1255

This diff wires up YGErrata to a public API, along with existing functions to set UseLegacyStretchBehaviour.

The `UseLegacyStretchBehaviour` functions will be removed after the world internally is transitioned to `YGConfigSetErrata`. This is intentionally breaking, since most users previously enabling `UseLegacyStretchBehaviour` will want to pick a new appropriate errata setting. Internally, users of the API will be moved to`YGErrataAll`.

The overall change looks like:
1. Clean up YGConfig to use accessors/setters
2. Change up YGconfig internal storage
    1. Fabric has a config per ShadowNode, so it makes sense to do some size optimization before adding more (free-form bools to bitfield, `std::array<bool,>` to `std::bitset` since not specialized)
3. Wire accessor/setter of UseLegacyStretchBehaviour to errata while both APIs exist
4. Add errata APIs to C ABI

After this we will need to expose the ABI to more language projections, and (more involved), add usages of the API to internal consumption of Yoga before adding more errata and removing `UseLegacyStretchBehaviour`.

Note that this API representation is similar, but distinct to `YGExperimentalFeature`. I think that API may also have made sense as an enum bitset, like we explicitly want for the new API, but it's not really worth changing the existing API to make that happen.

Reviewed By: rshest

Differential Revision: D45254097

fbshipit-source-id: 5c725ce5a77b25c1356f753d11c468587dbd8ded
2023-04-27 06:48:04 -07:00
Nick Gerleman
36406ce17c Remove config variant copy ctor from YGNode (#37091)
Summary:
X-link: https://github.com/facebook/react-native/pull/37091

Pull Request resolved: https://github.com/facebook/yoga/pull/1258

This private constructor was added specifically for Fabric when config setting was deprecated, but that is undeprecated now. Fbsource fabric was moved off of it, and the RN desktop for was in the last diff in the stack, so we can remove it now.

Reviewed By: yungsters

Differential Revision: D45292729

fbshipit-source-id: 87b2a1adaafaf817befe44dbc3ac178af59a6e68
2023-04-27 06:48:04 -07:00
Nick Gerleman
c878ceeabd Define Flag operators for YGPrintOptions (#37115)
Summary:
X-link: https://github.com/facebook/react-native/pull/37115

Pull Request resolved: https://github.com/facebook/yoga/pull/1267

This is an existing bitset enum in the API. Use the facility added in the last diff to add flag operators to it, to avoid the need for casting, and to make it clearer in the generated YGEnums.h that it is a bitset.

Reviewed By: rshest

Differential Revision: D45341504

fbshipit-source-id: 0b80588f3e2e167d4c1c722c6d6608408dd617ba
2023-04-27 03:15:14 -07:00
Nick Gerleman
01c0c4ed3b Add YGErrata Enum (#1256)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1256

X-link: https://github.com/facebook/react-native/pull/37076

This adds a `YGErrata` bitset enum matching the API and guarantees described in https://github.com/facebook/yoga/issues/1247.

It is hooked up in later diffs. There are a couple of `YGExperimentalFeature` values that belong here, but keeping the current options means that the default `YGErrataNone` corresponds to existing default behavior, letting us stage the series of changes as:
1. Implement errata API
2. Update internal Yoga users we want to de-risk to `YGErrataClassic` or `YGErrataAll` (if setting `UseLegacyStretchBehaviour`)
3. Add new errata, changing Yoga defaults to be conformant, while letting internal apps opt into compatibility modes pending experimentation.

I also added a macro to let C++ users of Yoga perform bitwise operations on the enum without casting (already available for C users).

Reviewed By: rshest

Differential Revision: D45254098

fbshipit-source-id: d4b61271a8018f548f2d9d8c953db4b121a502d1
2023-04-27 03:15:14 -07:00
Nick Gerleman
fc68765314 Remove private headers exposed by podspecs (#940)
Summary:
X-link: https://github.com/facebook/litho/pull/940

Pull Request resolved: https://github.com/facebook/yoga/pull/1252

X-link: https://github.com/facebook/react-native/pull/36993

Fabric relies on the private C++ internals of Yoga. This creates a conundrum in the open source build due to how header creation in Cocoapods works.

1. The default mechanism of specifying public headers needs to include the private headers for them to be made usable by fabric (by default)
2. Cocoapods will roll up all of the public headers when importing a module

https://github.com/facebook/react-native/pull/33381 fixed the Fabric Cocoapods build which ran into this. React Native relies on FlipperKit which relies on YogaKit, which in turn finally imports the Yoga podspec. Because YogaKit may use Swift, we can only expose the public Yoga C ABI.

The first solution in that PR was to allow RN to access Yoga private headers, but this was changed to instead make all Yoga headers public, and to add ifdefs to all of them to no-op when included outside of a C++ environment.

Talking to Kudo, we should be able to change back to the earlier approach in the PR, to instead expose the private headers to only RN. This lets us avoid exposing headers that we ideally wouldn't be, and lets us avoid the messy ifdefs in every Yoga header.

Changelog: [Internal]

Reviewed By: rshest

Differential Revision: D45139075

fbshipit-source-id: 99152986a578f7aac8324dffe0e18c42a38cc6a5
2023-04-26 17:27:29 -07:00
Nick Gerleman
292bbc43d6 Disable broken YogaKit test
Summary: This test fails locally and testx shows it always failing in continuous, disable it for now.

Reviewed By: yungsters

Differential Revision: D45298519

fbshipit-source-id: dc1d654bc4ecf5b32b733a6b5ae40255f35acafc
2023-04-26 07:01:36 -07:00