Commit Graph

2215 Commits

Author SHA1 Message Date
Nick Gerleman
506027925d Add publish workflows for npmjs and CocoaPods (#1316)
Summary:
This adds workflows which run on tag, or manually, to publish packages to npmjs and cocoapods. These secrets should be set, but this is untested. We can fix manually and re-run though.

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

Test Plan: no parse errors when adding to GitHub

Reviewed By: cortinico

Differential Revision: D47069617

Pulled By: NickGerleman

fbshipit-source-id: efe0664be7cd287c598515c9572daff1655cfc14
2023-06-28 13:54:03 -07:00
Nick Gerleman
0294373929 Add yarn pack validation (#1315)
Summary:
Adds a step to validate the prepublish steps, and upload the resulting tarball.

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

Test Plan: A tarball is uploaded as part of validation and looks decent.

Reviewed By: cortinico

Differential Revision: D47068368

Pulled By: NickGerleman

fbshipit-source-id: 62c8946a1bb542310634c8a7384a0e4890b35bdf
2023-06-28 02:21:05 -07:00
Nick Gerleman
23e58ebaf5 Docusaurus: Replace config basics (#1314)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1314

Replace some of the basic parts of the config with values for Yoga

Reviewed By: yungsters

Differential Revision: D46884432

fbshipit-source-id: ff729d93b4378925c9b526b50dd06f95f5e27b51
2023-06-23 17:56:41 -07:00
Nick Gerleman
3e3c4f09f9 Docusaurus: Use yarn workspaces (#1313)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1313

Use yarn workspaces to consolidate the lockfile, and to let the website use our local Yoga package. This was not possible with the old version of Gatsby we were previously using.

This does not yet sync the versions of different packages, or move config files to the root of the repo. That will happen later after removing the original website package.

Reviewed By: yungsters

Differential Revision: D46884433

fbshipit-source-id: dfa43bdaaad66bb4365922287a39d6a34fa9f464
2023-06-23 17:56:41 -07:00
Nick Gerleman
cd7390e093 Include CMmake configuration stdio
Summary: Include error messages or other output for CMake generating the build for ninja

Reviewed By: yungsters

Differential Revision: D46884396

fbshipit-source-id: a31ae4dbdecd8833e62d8e3b8bf8dcaae9ba67e2
2023-06-23 14:08:12 -07:00
Nick Gerleman
d63f078fd4 Docusarus: Init Project (#1312)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1312

This starts us transitioning the Yoga website off of an ancient version of Gatsby by initializing a new Docusaurus project. This commit adds a new stock project, to be filled in later, then fixes license lint errors.

Note that this seems to have init'd using npm, but in the next diff I convert this to yarn workspaces anyway.

Reviewed By: yungsters

Differential Revision: D46884434

fbshipit-source-id: 7a0a4dddc144ad2d22cd18a02e8dcb9ff2184489
2023-06-22 13:46:57 -07:00
Nick Gerleman
75322f2bcb Add more ignore patterns (#1311)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1311

Adds some more output files to be ignored by prettier, eslint, tsconfig

Reviewed By: rozele

Differential Revision: D46884397

fbshipit-source-id: 69329f924cb3e949152a07d93514dc8cf8b3253a
2023-06-21 17:18:26 -07:00
Nick Gerleman
b8a0240aaf Build WebAssembly with SINGLE_FILE=1 (#1310)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1310

Emscripten normally compiles a binary into a `.js` file and a `.wasm` file. The `.js` file contains a shim to load the WebAssembly file for the target platform, along with passing some environment information to the underlying assembly.

Under Node this would use APIs like `fs.readFile` and its WebAssembly APIs to load the binary. In a browser, APIs like `instantiateStreaming` are used to start downloading and compiling the binary at the same time.

This format creates many, many, headaches, and manual bundler configuration. E.g. we must tell Webpack to treat WASM files as auxilary files instead of WebAssembly, cannot use Emscripten's loader directly, and would need to add more variants of the binary, since (or Node polyfills in the browser) `-s ENVIRONMENT='web,node'` emits code that looks like `if (isNode) {require('fs')}`.

This change makes us instead pack the WebAssembly as base64 inline with the JS loader. This adds a size penalty, and means we cannot start async compilation until the entire file is present, but should work out of the box when using different bundlers and configurations, and the size is small enough where it likely makes sense to inline into the bundle anyway.

There is a [proposal for integration of WebAssembly and ES Modules](https://github.com/WebAssembly/esm-integration/tree/main/proposals/esm-integration) that Node has experimental support for, and bundlers are veering towards supporting. It is the eventual solution we should target, but does not seem mature enough yet. E.g. WebPack [does not support](https://github.com/webpack/webpack/issues/11893) WebAssembly import objects, and will instead try to import each of the named imports as modules.

Reviewed By: rozele

Differential Revision: D46884398

fbshipit-source-id: a1c93c122c255b913f426bfb6bdb38fd9f9dfd41
2023-06-21 17:18:26 -07:00
Nick Gerleman
8c8235cfcf Use ES Module Export in wrapAssembly.js
Summary: This is needed to make Webpack happy when bundling Yoga. Webpack assumes this is an ESModule after following it from the package.json export map. We are already importing this via default import.

Reviewed By: GijsWeterings

Differential Revision: D46811190

fbshipit-source-id: 7a074e5d2aa9c0cb4b59e506a0d910762a62dd58
2023-06-20 14:53:03 -07:00
Andrew Wang
f3e9b6bfb0 Fix the issue that local reference overflows in Yoga 1 (#1308)
Summary:
X-link: https://github.com/facebook/react-native/pull/37929

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

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

Long story in short, we're trying to fix an issue with Yoga that could potentially lead to an overflow in the JNI local reference table.

Reviewed By: NickGerleman, astreet

Differential Revision: D46653732

fbshipit-source-id: 0bc34bd5a819037c046c62b651e414b249cbdcb8
2023-06-16 06:15:07 -07:00
Eric Rozell
ca4cf852aa Update watir to 7.2.0
Summary: I was not able to run `ruby gentest.rb` from Yoga. Updating watir seems to fix the issue.

Reviewed By: shwanton, NickGerleman

Differential Revision: D46687292

fbshipit-source-id: 9922996144aa23fc7fa2f0dcb372367121689598
2023-06-13 12:40:09 -07:00
Nick Gerleman
2d19f45c86 Sync up package descriptions (#1307)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1307

This syncs up some of the descriptions, author names, etc between the different Yoga packages we are going to soon publish.

Reviewed By: cortinico

Differential Revision: D46664187

fbshipit-source-id: b15974efee31f349650e5d23f9fcaebaef6d6dd3
2023-06-13 11:33:58 -07:00
Nick Gerleman
2d408acbab Mark YogaKit Podspec as Deprecated (#1306)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1306

We are deprecating YogaKit as part of Yoga 2.0, with that version planned as the last release. Mark the podspec as deprecated.

We are also deprecating the Android ViewGroup in a similar way but from the googling I did there is not an equivalent way to do that for Maven artifacts.

Reviewed By: cortinico

Differential Revision: D46663201

fbshipit-source-id: 14e89df8f20470996b5c4b25f098d27cd3f49c7f
2023-06-13 11:33:58 -07:00
Nick Gerleman
3792d72462 Quick and dirty versioning script (#1305)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1305

Made a quick script to set versions in manifests that currently exist. This should probably be stamped in more places, like the binary as well, but we don't do that right now. This does not update lockfiles for CocoaPods or JS, so those will need to be updated via an install after running this script.

A note on language: This repo already has too many toolchains, but I chose Python for this since it corresponds with the enum script, and we  can run it with no dependencies on macOS/Linux distros.

Reviewed By: cortinico

Differential Revision: D46662378

fbshipit-source-id: 74ab99eef137511f8ed2fd7d81335a0fa633caf5
2023-06-12 15:53:16 -07:00
Nicola Corti
36e491754f Setup publishing for Yoga stables
Summary:
This sets up publishing for stable of Yoga whenever a git tag gets published.
I also re-enabled Javadoc publishing as this is a requirement to hit Maven Central.

Reviewed By: NickGerleman

Differential Revision: D46522898

fbshipit-source-id: dc4b9139aed7aff27dce966bcee7b9b0cc4c6fe9
2023-06-08 02:23:48 -07:00
Nicola Corti
a2832f4d55 Use the correct secrets for snapshot publishing
Summary:
I accidentally mixed the secret name for publishing to sonatype.
The correct values are `SONATYPE_USERNAME` and `SONATYPE_PASSWORD`.

After this snapshot publishing should be green.

Reviewed By: NickGerleman

Differential Revision: D46522897

fbshipit-source-id: 3ebb5bf5be32a7bbac1fefc9ed46c49be15bd56c
2023-06-08 01:51:30 -07:00
Pieter Vanderwerff
8a07ffe6c8 Update prettier to v2.8.8
Summary:
X-link: https://github.com/facebook/react-native/pull/37738

Upgrade Prettier to the latest stable version, 2.8.8.

Reviewed By: SamChou19815

Differential Revision: D46403769

fbshipit-source-id: 551d64db0b701a8d3f275900dd8f6324c115a3e6
2023-06-06 20:06:25 -07:00
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