react-nitro-yoga
v0.0.1-alpha.15
Published
This package owns Yoga's native build, generated FFI bindings, and Hermes runtime initialization. The `yoga` Git submodule is pinned to `9d159f2d3d8dbc777e1f82c20b94e369c113d608`.
Readme
React Nitro Yoga
This package owns Yoga's native build, generated FFI bindings, and Hermes runtime
initialization. The yoga Git submodule is pinned to
9d159f2d3d8dbc777e1f82c20b94e369c113d608.
ffi.config.ts selects the C functions to expose. It uses yoga/yoga as the CMake
source directory and yogacore as the native target. The shared builder in
react-nitro-ffigen handles generation, type checking, native compilation, and
the exported Static Hermes unit.
From the repository root:
git submodule update --init --recursive
bun installThe build needs Bun, Clang, CMake, and Ninja. The root postinstall runs the
workspace build scripts in dependency order: Hermes's compiler is built
before this package builds native Yoga and generates its bindings. Native
builds are incremental and target the macOS host.
To rebuild only Yoga after editing its FFI configuration, run
bun run --cwd packages/react-nitro-yoga build from the repository root.
Outputs belong to this package:
Generated/native.ts,native.d.ts,api.d.ts, andffigen_yoga_adapters.hGenerated/yoga.c, the exported Static Hermes unit.build/yoga/libyogacore.a, the native library for the host target
The generated sources are checked in so Xcode does not need Bun or CMake during
an app build. Regenerate them with this package's build command; do not edit
them by hand.
The generated native declarations import shared Hermes types from
react-nitro-ffigen/hermes.
Import public types from this package:
import type { YGNodeRef } from "react-nitro-yoga";
const node: YGNodeRef = globalThis.yoga.YGNodeNew();
globalThis.yoga.YGNodeFreeRecursive(node);Declare react-nitro-yoga as a dependency of the consuming package. The type
import also declares globalThis.yoga; native initialization must run before
application JavaScript uses it.
Package.swift exposes two products:
Yogacompiles the submodule's native C++ sources and exposes<yoga/Yoga.h>andimport yoga. The renderer depends on this product.ReactNitroYogacompiles the generated C unit and the C++ runtime initializer. It depends onYogaandHermes.ReactNitroRuntimecallsmargelo::nitro::yoga::installHermesBindingsfor each new Hermes runtime, before application JavaScript runs.
The renderer has no dependency on the Hermes bridge. Its Nitro bindings still
use JSI through NitroModules.
