Files
yoga/javascript
Bela Bohlender bbdd1afe59 Entry point without TLA for js package (#1638)
Summary:
Follow up on https://github.com/facebook/yoga/issues/1637

TLDR: tooling for TLA is not there yet; An additional entry point without top-level-await is appropriate

- adds ./load entry to js package
- uses .js file extensions to prevent requiring [allowImportingTsExtensions](https://www.typescriptlang.org/tsconfig#allowImportingTsExtensions)

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

Reviewed By: joevilches

Differential Revision: D55614636

Pulled By: NickGerleman

fbshipit-source-id: 126a94aa68d22d32b938282cfa1a5059bb9df337
2024-04-08 12:04:08 -07:00
..
2024-03-12 16:35:42 -07:00

yoga-layout

This package provides prebuilt WebAssembly bindings for the Yoga layout engine.

See more at https://yogalayout.dev

Usage

import {Yoga, Align} from 'yoga-layout';

const node = Yoga.Node.create();
node.setAlignContent(Align.Center);

Objects created by Yoga.<>.create() are not automatically garbage collected and should be freed once they are no longer in use.

// Free a config
config.free();

// Free a tree of Nodes
node.freeRecursive();

// Free a single Node
node.free();

Requirements

yoga-layout requires a toolchain that supports ES Modules and top-level await.

If top-level-await is not supported, use the yoga-layout/load entry point instead. This requires to load yoga manually:

import {loadYoga, Align} from 'yoga-layout/load';

const node = (await loadYoga).Node.create();
node.setAlignContent(Align.Center);