Latest repo

This commit is contained in:
Marc
2025-06-02 16:42:16 +00:00
parent 53ddf1a329
commit cde5fae175
27907 changed files with 3875388 additions and 1 deletions

40
node_modules/yoga-layout/README.md generated vendored Normal file
View File

@@ -0,0 +1,40 @@
# yoga-layout
This package provides prebuilt WebAssembly bindings for the Yoga layout engine.
See more at https://yogalayout.dev
## Usage
```ts
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.
```ts
// 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:
```ts
import {loadYoga, Align} from 'yoga-layout/load';
const node = (await loadYoga).Node.create();
node.setAlignContent(Align.Center);
```

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,189 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
export declare enum Align {
Auto = 0,
FlexStart = 1,
Center = 2,
FlexEnd = 3,
Stretch = 4,
Baseline = 5,
SpaceBetween = 6,
SpaceAround = 7,
SpaceEvenly = 8
}
export declare enum BoxSizing {
BorderBox = 0,
ContentBox = 1
}
export declare enum Dimension {
Width = 0,
Height = 1
}
export declare enum Direction {
Inherit = 0,
LTR = 1,
RTL = 2
}
export declare enum Display {
Flex = 0,
None = 1,
Contents = 2
}
export declare enum Edge {
Left = 0,
Top = 1,
Right = 2,
Bottom = 3,
Start = 4,
End = 5,
Horizontal = 6,
Vertical = 7,
All = 8
}
export declare enum Errata {
None = 0,
StretchFlexBasis = 1,
AbsolutePositionWithoutInsetsExcludesPadding = 2,
AbsolutePercentAgainstInnerSize = 4,
All = 2147483647,
Classic = 2147483646
}
export declare enum ExperimentalFeature {
WebFlexBasis = 0
}
export declare enum FlexDirection {
Column = 0,
ColumnReverse = 1,
Row = 2,
RowReverse = 3
}
export declare enum Gutter {
Column = 0,
Row = 1,
All = 2
}
export declare enum Justify {
FlexStart = 0,
Center = 1,
FlexEnd = 2,
SpaceBetween = 3,
SpaceAround = 4,
SpaceEvenly = 5
}
export declare enum LogLevel {
Error = 0,
Warn = 1,
Info = 2,
Debug = 3,
Verbose = 4,
Fatal = 5
}
export declare enum MeasureMode {
Undefined = 0,
Exactly = 1,
AtMost = 2
}
export declare enum NodeType {
Default = 0,
Text = 1
}
export declare enum Overflow {
Visible = 0,
Hidden = 1,
Scroll = 2
}
export declare enum PositionType {
Static = 0,
Relative = 1,
Absolute = 2
}
export declare enum Unit {
Undefined = 0,
Point = 1,
Percent = 2,
Auto = 3
}
export declare enum Wrap {
NoWrap = 0,
Wrap = 1,
WrapReverse = 2
}
declare const constants: {
ALIGN_AUTO: Align;
ALIGN_FLEX_START: Align;
ALIGN_CENTER: Align;
ALIGN_FLEX_END: Align;
ALIGN_STRETCH: Align;
ALIGN_BASELINE: Align;
ALIGN_SPACE_BETWEEN: Align;
ALIGN_SPACE_AROUND: Align;
ALIGN_SPACE_EVENLY: Align;
BOX_SIZING_BORDER_BOX: BoxSizing;
BOX_SIZING_CONTENT_BOX: BoxSizing;
DIMENSION_WIDTH: Dimension;
DIMENSION_HEIGHT: Dimension;
DIRECTION_INHERIT: Direction;
DIRECTION_LTR: Direction;
DIRECTION_RTL: Direction;
DISPLAY_FLEX: Display;
DISPLAY_NONE: Display;
DISPLAY_CONTENTS: Display;
EDGE_LEFT: Edge;
EDGE_TOP: Edge;
EDGE_RIGHT: Edge;
EDGE_BOTTOM: Edge;
EDGE_START: Edge;
EDGE_END: Edge;
EDGE_HORIZONTAL: Edge;
EDGE_VERTICAL: Edge;
EDGE_ALL: Edge;
ERRATA_NONE: Errata;
ERRATA_STRETCH_FLEX_BASIS: Errata;
ERRATA_ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING: Errata;
ERRATA_ABSOLUTE_PERCENT_AGAINST_INNER_SIZE: Errata;
ERRATA_ALL: Errata;
ERRATA_CLASSIC: Errata;
EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS: ExperimentalFeature;
FLEX_DIRECTION_COLUMN: FlexDirection;
FLEX_DIRECTION_COLUMN_REVERSE: FlexDirection;
FLEX_DIRECTION_ROW: FlexDirection;
FLEX_DIRECTION_ROW_REVERSE: FlexDirection;
GUTTER_COLUMN: Gutter;
GUTTER_ROW: Gutter;
GUTTER_ALL: Gutter;
JUSTIFY_FLEX_START: Justify;
JUSTIFY_CENTER: Justify;
JUSTIFY_FLEX_END: Justify;
JUSTIFY_SPACE_BETWEEN: Justify;
JUSTIFY_SPACE_AROUND: Justify;
JUSTIFY_SPACE_EVENLY: Justify;
LOG_LEVEL_ERROR: LogLevel;
LOG_LEVEL_WARN: LogLevel;
LOG_LEVEL_INFO: LogLevel;
LOG_LEVEL_DEBUG: LogLevel;
LOG_LEVEL_VERBOSE: LogLevel;
LOG_LEVEL_FATAL: LogLevel;
MEASURE_MODE_UNDEFINED: MeasureMode;
MEASURE_MODE_EXACTLY: MeasureMode;
MEASURE_MODE_AT_MOST: MeasureMode;
NODE_TYPE_DEFAULT: NodeType;
NODE_TYPE_TEXT: NodeType;
OVERFLOW_VISIBLE: Overflow;
OVERFLOW_HIDDEN: Overflow;
OVERFLOW_SCROLL: Overflow;
POSITION_TYPE_STATIC: PositionType;
POSITION_TYPE_RELATIVE: PositionType;
POSITION_TYPE_ABSOLUTE: PositionType;
UNIT_UNDEFINED: Unit;
UNIT_POINT: Unit;
UNIT_PERCENT: Unit;
UNIT_AUTO: Unit;
WRAP_NO_WRAP: Wrap;
WRAP_WRAP: Wrap;
WRAP_WRAP_REVERSE: Wrap;
};
export default constants;

211
node_modules/yoga-layout/dist/src/generated/YGEnums.js generated vendored Normal file
View File

@@ -0,0 +1,211 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// @generated by enums.py
export let Align = /*#__PURE__*/function (Align) {
Align[Align["Auto"] = 0] = "Auto";
Align[Align["FlexStart"] = 1] = "FlexStart";
Align[Align["Center"] = 2] = "Center";
Align[Align["FlexEnd"] = 3] = "FlexEnd";
Align[Align["Stretch"] = 4] = "Stretch";
Align[Align["Baseline"] = 5] = "Baseline";
Align[Align["SpaceBetween"] = 6] = "SpaceBetween";
Align[Align["SpaceAround"] = 7] = "SpaceAround";
Align[Align["SpaceEvenly"] = 8] = "SpaceEvenly";
return Align;
}({});
export let BoxSizing = /*#__PURE__*/function (BoxSizing) {
BoxSizing[BoxSizing["BorderBox"] = 0] = "BorderBox";
BoxSizing[BoxSizing["ContentBox"] = 1] = "ContentBox";
return BoxSizing;
}({});
export let Dimension = /*#__PURE__*/function (Dimension) {
Dimension[Dimension["Width"] = 0] = "Width";
Dimension[Dimension["Height"] = 1] = "Height";
return Dimension;
}({});
export let Direction = /*#__PURE__*/function (Direction) {
Direction[Direction["Inherit"] = 0] = "Inherit";
Direction[Direction["LTR"] = 1] = "LTR";
Direction[Direction["RTL"] = 2] = "RTL";
return Direction;
}({});
export let Display = /*#__PURE__*/function (Display) {
Display[Display["Flex"] = 0] = "Flex";
Display[Display["None"] = 1] = "None";
Display[Display["Contents"] = 2] = "Contents";
return Display;
}({});
export let Edge = /*#__PURE__*/function (Edge) {
Edge[Edge["Left"] = 0] = "Left";
Edge[Edge["Top"] = 1] = "Top";
Edge[Edge["Right"] = 2] = "Right";
Edge[Edge["Bottom"] = 3] = "Bottom";
Edge[Edge["Start"] = 4] = "Start";
Edge[Edge["End"] = 5] = "End";
Edge[Edge["Horizontal"] = 6] = "Horizontal";
Edge[Edge["Vertical"] = 7] = "Vertical";
Edge[Edge["All"] = 8] = "All";
return Edge;
}({});
export let Errata = /*#__PURE__*/function (Errata) {
Errata[Errata["None"] = 0] = "None";
Errata[Errata["StretchFlexBasis"] = 1] = "StretchFlexBasis";
Errata[Errata["AbsolutePositionWithoutInsetsExcludesPadding"] = 2] = "AbsolutePositionWithoutInsetsExcludesPadding";
Errata[Errata["AbsolutePercentAgainstInnerSize"] = 4] = "AbsolutePercentAgainstInnerSize";
Errata[Errata["All"] = 2147483647] = "All";
Errata[Errata["Classic"] = 2147483646] = "Classic";
return Errata;
}({});
export let ExperimentalFeature = /*#__PURE__*/function (ExperimentalFeature) {
ExperimentalFeature[ExperimentalFeature["WebFlexBasis"] = 0] = "WebFlexBasis";
return ExperimentalFeature;
}({});
export let FlexDirection = /*#__PURE__*/function (FlexDirection) {
FlexDirection[FlexDirection["Column"] = 0] = "Column";
FlexDirection[FlexDirection["ColumnReverse"] = 1] = "ColumnReverse";
FlexDirection[FlexDirection["Row"] = 2] = "Row";
FlexDirection[FlexDirection["RowReverse"] = 3] = "RowReverse";
return FlexDirection;
}({});
export let Gutter = /*#__PURE__*/function (Gutter) {
Gutter[Gutter["Column"] = 0] = "Column";
Gutter[Gutter["Row"] = 1] = "Row";
Gutter[Gutter["All"] = 2] = "All";
return Gutter;
}({});
export let Justify = /*#__PURE__*/function (Justify) {
Justify[Justify["FlexStart"] = 0] = "FlexStart";
Justify[Justify["Center"] = 1] = "Center";
Justify[Justify["FlexEnd"] = 2] = "FlexEnd";
Justify[Justify["SpaceBetween"] = 3] = "SpaceBetween";
Justify[Justify["SpaceAround"] = 4] = "SpaceAround";
Justify[Justify["SpaceEvenly"] = 5] = "SpaceEvenly";
return Justify;
}({});
export let LogLevel = /*#__PURE__*/function (LogLevel) {
LogLevel[LogLevel["Error"] = 0] = "Error";
LogLevel[LogLevel["Warn"] = 1] = "Warn";
LogLevel[LogLevel["Info"] = 2] = "Info";
LogLevel[LogLevel["Debug"] = 3] = "Debug";
LogLevel[LogLevel["Verbose"] = 4] = "Verbose";
LogLevel[LogLevel["Fatal"] = 5] = "Fatal";
return LogLevel;
}({});
export let MeasureMode = /*#__PURE__*/function (MeasureMode) {
MeasureMode[MeasureMode["Undefined"] = 0] = "Undefined";
MeasureMode[MeasureMode["Exactly"] = 1] = "Exactly";
MeasureMode[MeasureMode["AtMost"] = 2] = "AtMost";
return MeasureMode;
}({});
export let NodeType = /*#__PURE__*/function (NodeType) {
NodeType[NodeType["Default"] = 0] = "Default";
NodeType[NodeType["Text"] = 1] = "Text";
return NodeType;
}({});
export let Overflow = /*#__PURE__*/function (Overflow) {
Overflow[Overflow["Visible"] = 0] = "Visible";
Overflow[Overflow["Hidden"] = 1] = "Hidden";
Overflow[Overflow["Scroll"] = 2] = "Scroll";
return Overflow;
}({});
export let PositionType = /*#__PURE__*/function (PositionType) {
PositionType[PositionType["Static"] = 0] = "Static";
PositionType[PositionType["Relative"] = 1] = "Relative";
PositionType[PositionType["Absolute"] = 2] = "Absolute";
return PositionType;
}({});
export let Unit = /*#__PURE__*/function (Unit) {
Unit[Unit["Undefined"] = 0] = "Undefined";
Unit[Unit["Point"] = 1] = "Point";
Unit[Unit["Percent"] = 2] = "Percent";
Unit[Unit["Auto"] = 3] = "Auto";
return Unit;
}({});
export let Wrap = /*#__PURE__*/function (Wrap) {
Wrap[Wrap["NoWrap"] = 0] = "NoWrap";
Wrap[Wrap["Wrap"] = 1] = "Wrap";
Wrap[Wrap["WrapReverse"] = 2] = "WrapReverse";
return Wrap;
}({});
const constants = {
ALIGN_AUTO: Align.Auto,
ALIGN_FLEX_START: Align.FlexStart,
ALIGN_CENTER: Align.Center,
ALIGN_FLEX_END: Align.FlexEnd,
ALIGN_STRETCH: Align.Stretch,
ALIGN_BASELINE: Align.Baseline,
ALIGN_SPACE_BETWEEN: Align.SpaceBetween,
ALIGN_SPACE_AROUND: Align.SpaceAround,
ALIGN_SPACE_EVENLY: Align.SpaceEvenly,
BOX_SIZING_BORDER_BOX: BoxSizing.BorderBox,
BOX_SIZING_CONTENT_BOX: BoxSizing.ContentBox,
DIMENSION_WIDTH: Dimension.Width,
DIMENSION_HEIGHT: Dimension.Height,
DIRECTION_INHERIT: Direction.Inherit,
DIRECTION_LTR: Direction.LTR,
DIRECTION_RTL: Direction.RTL,
DISPLAY_FLEX: Display.Flex,
DISPLAY_NONE: Display.None,
DISPLAY_CONTENTS: Display.Contents,
EDGE_LEFT: Edge.Left,
EDGE_TOP: Edge.Top,
EDGE_RIGHT: Edge.Right,
EDGE_BOTTOM: Edge.Bottom,
EDGE_START: Edge.Start,
EDGE_END: Edge.End,
EDGE_HORIZONTAL: Edge.Horizontal,
EDGE_VERTICAL: Edge.Vertical,
EDGE_ALL: Edge.All,
ERRATA_NONE: Errata.None,
ERRATA_STRETCH_FLEX_BASIS: Errata.StretchFlexBasis,
ERRATA_ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING: Errata.AbsolutePositionWithoutInsetsExcludesPadding,
ERRATA_ABSOLUTE_PERCENT_AGAINST_INNER_SIZE: Errata.AbsolutePercentAgainstInnerSize,
ERRATA_ALL: Errata.All,
ERRATA_CLASSIC: Errata.Classic,
EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS: ExperimentalFeature.WebFlexBasis,
FLEX_DIRECTION_COLUMN: FlexDirection.Column,
FLEX_DIRECTION_COLUMN_REVERSE: FlexDirection.ColumnReverse,
FLEX_DIRECTION_ROW: FlexDirection.Row,
FLEX_DIRECTION_ROW_REVERSE: FlexDirection.RowReverse,
GUTTER_COLUMN: Gutter.Column,
GUTTER_ROW: Gutter.Row,
GUTTER_ALL: Gutter.All,
JUSTIFY_FLEX_START: Justify.FlexStart,
JUSTIFY_CENTER: Justify.Center,
JUSTIFY_FLEX_END: Justify.FlexEnd,
JUSTIFY_SPACE_BETWEEN: Justify.SpaceBetween,
JUSTIFY_SPACE_AROUND: Justify.SpaceAround,
JUSTIFY_SPACE_EVENLY: Justify.SpaceEvenly,
LOG_LEVEL_ERROR: LogLevel.Error,
LOG_LEVEL_WARN: LogLevel.Warn,
LOG_LEVEL_INFO: LogLevel.Info,
LOG_LEVEL_DEBUG: LogLevel.Debug,
LOG_LEVEL_VERBOSE: LogLevel.Verbose,
LOG_LEVEL_FATAL: LogLevel.Fatal,
MEASURE_MODE_UNDEFINED: MeasureMode.Undefined,
MEASURE_MODE_EXACTLY: MeasureMode.Exactly,
MEASURE_MODE_AT_MOST: MeasureMode.AtMost,
NODE_TYPE_DEFAULT: NodeType.Default,
NODE_TYPE_TEXT: NodeType.Text,
OVERFLOW_VISIBLE: Overflow.Visible,
OVERFLOW_HIDDEN: Overflow.Hidden,
OVERFLOW_SCROLL: Overflow.Scroll,
POSITION_TYPE_STATIC: PositionType.Static,
POSITION_TYPE_RELATIVE: PositionType.Relative,
POSITION_TYPE_ABSOLUTE: PositionType.Absolute,
UNIT_UNDEFINED: Unit.Undefined,
UNIT_POINT: Unit.Point,
UNIT_PERCENT: Unit.Percent,
UNIT_AUTO: Unit.Auto,
WRAP_NO_WRAP: Wrap.NoWrap,
WRAP_WRAP: Wrap.Wrap,
WRAP_WRAP_REVERSE: Wrap.WrapReverse
};
export default constants;
//# sourceMappingURL=YGEnums.js.map

File diff suppressed because one or more lines are too long

12
node_modules/yoga-layout/dist/src/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,12 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
export type { Config, DirtiedFunction, MeasureFunction, Node, } from './wrapAssembly.ts';
declare const Yoga: import("./wrapAssembly.ts").Yoga;
export default Yoga;
export * from './generated/YGEnums.ts';

16
node_modules/yoga-layout/dist/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
// @ts-ignore untyped from Emscripten
import loadYoga from '../binaries/yoga-wasm-base64-esm.js';
import wrapAssembly from "./wrapAssembly.js";
const Yoga = wrapAssembly(await loadYoga());
export default Yoga;
export * from "./generated/YGEnums.js";
//# sourceMappingURL=index.js.map

1
node_modules/yoga-layout/dist/src/index.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","names":["loadYoga","wrapAssembly","Yoga"],"sources":["../../src/index.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @format\n */\n\n// @ts-ignore untyped from Emscripten\nimport loadYoga from '../binaries/yoga-wasm-base64-esm.js';\nimport wrapAssembly from './wrapAssembly.ts';\n\nexport type {\n Config,\n DirtiedFunction,\n MeasureFunction,\n Node,\n} from './wrapAssembly.ts';\n\nconst Yoga = wrapAssembly(await loadYoga());\nexport default Yoga;\nexport * from './generated/YGEnums.ts';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAOA,QAAQ,MAAM,qCAAqC;AAC1D,OAAOC,YAAY,MAAM,mBAAmB;AAS5C,MAAMC,IAAI,GAAGD,YAAY,CAAC,MAAMD,QAAQ,CAAC,CAAC,CAAC;AAC3C,eAAeE,IAAI;AACnB,cAAc,wBAAwB","ignoreList":[]}

11
node_modules/yoga-layout/dist/src/load.d.ts generated vendored Normal file
View File

@@ -0,0 +1,11 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
export type { Config, DirtiedFunction, MeasureFunction, Node, Yoga, } from './wrapAssembly.ts';
export declare function loadYoga(): Promise<import("./wrapAssembly.ts").Yoga>;
export * from './generated/YGEnums.ts';

17
node_modules/yoga-layout/dist/src/load.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
// @ts-ignore untyped from Emscripten
import loadYogaImpl from '../binaries/yoga-wasm-base64-esm.js';
import wrapAssembly from "./wrapAssembly.js";
export async function loadYoga() {
return wrapAssembly(await loadYogaImpl());
}
export * from "./generated/YGEnums.js";
//# sourceMappingURL=load.js.map

1
node_modules/yoga-layout/dist/src/load.js.map generated vendored Normal file
View File

@@ -0,0 +1 @@
{"version":3,"file":"load.js","names":["loadYogaImpl","wrapAssembly","loadYoga"],"sources":["../../src/load.ts"],"sourcesContent":["/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @format\n */\n\n// @ts-ignore untyped from Emscripten\nimport loadYogaImpl from '../binaries/yoga-wasm-base64-esm.js';\nimport wrapAssembly from './wrapAssembly.ts';\n\nexport type {\n Config,\n DirtiedFunction,\n MeasureFunction,\n Node,\n Yoga,\n} from './wrapAssembly.ts';\n\nexport async function loadYoga() {\n return wrapAssembly(await loadYogaImpl());\n}\nexport * from './generated/YGEnums.ts';\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAOA,YAAY,MAAM,qCAAqC;AAC9D,OAAOC,YAAY,MAAM,mBAAmB;AAU5C,OAAO,eAAeC,QAAQA,CAAA,EAAG;EAC/B,OAAOD,YAAY,CAAC,MAAMD,YAAY,CAAC,CAAC,CAAC;AAC3C;AACA,cAAc,wBAAwB","ignoreList":[]}

155
node_modules/yoga-layout/dist/src/wrapAssembly.d.ts generated vendored Normal file
View File

@@ -0,0 +1,155 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
import { Unit, Direction } from './generated/YGEnums.ts';
import YGEnums from './generated/YGEnums.ts';
import type { Align, BoxSizing, Display, Edge, Errata, ExperimentalFeature, FlexDirection, Gutter, Justify, MeasureMode, Overflow, PositionType, Wrap } from './generated/YGEnums.ts';
type Layout = {
left: number;
right: number;
top: number;
bottom: number;
width: number;
height: number;
};
type Size = {
width: number;
height: number;
};
type Value = {
unit: Unit;
value: number;
};
export type Config = {
free(): void;
isExperimentalFeatureEnabled(feature: ExperimentalFeature): boolean;
setExperimentalFeatureEnabled(feature: ExperimentalFeature, enabled: boolean): void;
setPointScaleFactor(factor: number): void;
getErrata(): Errata;
setErrata(errata: Errata): void;
useWebDefaults(): boolean;
setUseWebDefaults(useWebDefaults: boolean): void;
};
export type DirtiedFunction = (node: Node) => void;
export type MeasureFunction = (width: number, widthMode: MeasureMode, height: number, heightMode: MeasureMode) => Size;
export type Node = {
calculateLayout(width: number | 'auto' | undefined, height: number | 'auto' | undefined, direction?: Direction): void;
copyStyle(node: Node): void;
free(): void;
freeRecursive(): void;
getAlignContent(): Align;
getAlignItems(): Align;
getAlignSelf(): Align;
getAspectRatio(): number;
getBorder(edge: Edge): number;
getChild(index: number): Node;
getChildCount(): number;
getComputedBorder(edge: Edge): number;
getComputedBottom(): number;
getComputedHeight(): number;
getComputedLayout(): Layout;
getComputedLeft(): number;
getComputedMargin(edge: Edge): number;
getComputedPadding(edge: Edge): number;
getComputedRight(): number;
getComputedTop(): number;
getComputedWidth(): number;
getDirection(): Direction;
getDisplay(): Display;
getFlexBasis(): Value;
getFlexDirection(): FlexDirection;
getFlexGrow(): number;
getFlexShrink(): number;
getFlexWrap(): Wrap;
getHeight(): Value;
getJustifyContent(): Justify;
getGap(gutter: Gutter): Value;
getMargin(edge: Edge): Value;
getMaxHeight(): Value;
getMaxWidth(): Value;
getMinHeight(): Value;
getMinWidth(): Value;
getOverflow(): Overflow;
getPadding(edge: Edge): Value;
getParent(): Node | null;
getPosition(edge: Edge): Value;
getPositionType(): PositionType;
getBoxSizing(): BoxSizing;
getWidth(): Value;
insertChild(child: Node, index: number): void;
isDirty(): boolean;
isReferenceBaseline(): boolean;
markDirty(): void;
hasNewLayout(): boolean;
markLayoutSeen(): void;
removeChild(child: Node): void;
reset(): void;
setAlignContent(alignContent: Align): void;
setAlignItems(alignItems: Align): void;
setAlignSelf(alignSelf: Align): void;
setAspectRatio(aspectRatio: number | undefined): void;
setBorder(edge: Edge, borderWidth: number | undefined): void;
setDirection(direction: Direction): void;
setDisplay(display: Display): void;
setFlex(flex: number | undefined): void;
setFlexBasis(flexBasis: number | 'auto' | `${number}%` | undefined): void;
setFlexBasisPercent(flexBasis: number | undefined): void;
setFlexBasisAuto(): void;
setFlexDirection(flexDirection: FlexDirection): void;
setFlexGrow(flexGrow: number | undefined): void;
setFlexShrink(flexShrink: number | undefined): void;
setFlexWrap(flexWrap: Wrap): void;
setHeight(height: number | 'auto' | `${number}%` | undefined): void;
setIsReferenceBaseline(isReferenceBaseline: boolean): void;
setHeightAuto(): void;
setHeightPercent(height: number | undefined): void;
setJustifyContent(justifyContent: Justify): void;
setGap(gutter: Gutter, gapLength: number | `${number}%` | undefined): Value;
setGapPercent(gutter: Gutter, gapLength: number | undefined): Value;
setMargin(edge: Edge, margin: number | 'auto' | `${number}%` | undefined): void;
setMarginAuto(edge: Edge): void;
setMarginPercent(edge: Edge, margin: number | undefined): void;
setMaxHeight(maxHeight: number | `${number}%` | undefined): void;
setMaxHeightPercent(maxHeight: number | undefined): void;
setMaxWidth(maxWidth: number | `${number}%` | undefined): void;
setMaxWidthPercent(maxWidth: number | undefined): void;
setDirtiedFunc(dirtiedFunc: DirtiedFunction | null): void;
setMeasureFunc(measureFunc: MeasureFunction | null): void;
setMinHeight(minHeight: number | `${number}%` | undefined): void;
setMinHeightPercent(minHeight: number | undefined): void;
setMinWidth(minWidth: number | `${number}%` | undefined): void;
setMinWidthPercent(minWidth: number | undefined): void;
setOverflow(overflow: Overflow): void;
setPadding(edge: Edge, padding: number | `${number}%` | undefined): void;
setPaddingPercent(edge: Edge, padding: number | undefined): void;
setPosition(edge: Edge, position: number | `${number}%` | undefined): void;
setPositionPercent(edge: Edge, position: number | undefined): void;
setPositionType(positionType: PositionType): void;
setPositionAuto(edge: Edge): void;
setBoxSizing(boxSizing: BoxSizing): void;
setWidth(width: number | 'auto' | `${number}%` | undefined): void;
setWidthAuto(): void;
setWidthPercent(width: number | undefined): void;
unsetDirtiedFunc(): void;
unsetMeasureFunc(): void;
setAlwaysFormsContainingBlock(alwaysFormsContainingBlock: boolean): void;
};
export type Yoga = {
Config: {
create(): Config;
destroy(config: Config): void;
};
Node: {
create(config?: Config): Node;
createDefault(): Node;
createWithConfig(config: Config): Node;
destroy(node: Node): void;
};
} & typeof YGEnums;
export default function wrapAssembly(lib: any): Yoga;
export {};

125
node_modules/yoga-layout/dist/src/wrapAssembly.js generated vendored Normal file
View File

@@ -0,0 +1,125 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
// @ts-nocheck
import { Unit, Direction } from "./generated/YGEnums.js";
import YGEnums from "./generated/YGEnums.js";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export default function wrapAssembly(lib) {
function patch(prototype, name, fn) {
const original = prototype[name];
prototype[name] = function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return fn.call(this, original, ...args);
};
}
for (const fnName of ['setPosition', 'setMargin', 'setFlexBasis', 'setWidth', 'setHeight', 'setMinWidth', 'setMinHeight', 'setMaxWidth', 'setMaxHeight', 'setPadding', 'setGap']) {
const methods = {
[Unit.Point]: lib.Node.prototype[fnName],
[Unit.Percent]: lib.Node.prototype[`${fnName}Percent`],
[Unit.Auto]: lib.Node.prototype[`${fnName}Auto`]
};
patch(lib.Node.prototype, fnName, function (original) {
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
args[_key2 - 1] = arguments[_key2];
}
// We patch all these functions to add support for the following calls:
// .setWidth(100) / .setWidth("100%") / .setWidth(.getWidth()) / .setWidth("auto")
const value = args.pop();
let unit, asNumber;
if (value === 'auto') {
unit = Unit.Auto;
asNumber = undefined;
} else if (typeof value === 'object') {
unit = value.unit;
asNumber = value.valueOf();
} else {
unit = typeof value === 'string' && value.endsWith('%') ? Unit.Percent : Unit.Point;
asNumber = parseFloat(value);
if (value !== undefined && !Number.isNaN(value) && Number.isNaN(asNumber)) {
throw new Error(`Invalid value ${value} for ${fnName}`);
}
}
if (!methods[unit]) throw new Error(`Failed to execute "${fnName}": Unsupported unit '${value}'`);
if (asNumber !== undefined) {
return methods[unit].call(this, ...args, asNumber);
} else {
return methods[unit].call(this, ...args);
}
});
}
function wrapMeasureFunction(measureFunction) {
return lib.MeasureCallback.implement({
measure: function () {
const {
width,
height
} = measureFunction(...arguments);
return {
width: width ?? NaN,
height: height ?? NaN
};
}
});
}
patch(lib.Node.prototype, 'setMeasureFunc', function (original, measureFunc) {
// This patch is just a convenience patch, since it helps write more
// idiomatic source code (such as .setMeasureFunc(null))
if (measureFunc) {
return original.call(this, wrapMeasureFunction(measureFunc));
} else {
return this.unsetMeasureFunc();
}
});
function wrapDirtiedFunc(dirtiedFunction) {
return lib.DirtiedCallback.implement({
dirtied: dirtiedFunction
});
}
patch(lib.Node.prototype, 'setDirtiedFunc', function (original, dirtiedFunc) {
original.call(this, wrapDirtiedFunc(dirtiedFunc));
});
patch(lib.Config.prototype, 'free', function () {
// Since we handle the memory allocation ourselves (via lib.Config.create),
// we also need to handle the deallocation
lib.Config.destroy(this);
});
patch(lib.Node, 'create', (_, config) => {
// We decide the constructor we want to call depending on the parameters
return config ? lib.Node.createWithConfig(config) : lib.Node.createDefault();
});
patch(lib.Node.prototype, 'free', function () {
// Since we handle the memory allocation ourselves (via lib.Node.create),
// we also need to handle the deallocation
lib.Node.destroy(this);
});
patch(lib.Node.prototype, 'freeRecursive', function () {
for (let t = 0, T = this.getChildCount(); t < T; ++t) {
this.getChild(0).freeRecursive();
}
this.free();
});
patch(lib.Node.prototype, 'calculateLayout', function (original) {
let width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : NaN;
let height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : NaN;
let direction = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Direction.LTR;
// Just a small patch to add support for the function default parameters
return original.call(this, width, height, direction);
});
return {
Config: lib.Config,
Node: lib.Node,
...YGEnums
};
}
//# sourceMappingURL=wrapAssembly.js.map

File diff suppressed because one or more lines are too long

53
node_modules/yoga-layout/package.json generated vendored Normal file
View File

@@ -0,0 +1,53 @@
{
"name": "yoga-layout",
"version": "3.2.1",
"description": "An embeddable and performant flexbox layout engine with bindings for multiple languages",
"license": "MIT",
"author": "Meta Open Source",
"homepage": "https://yogalayout.dev/",
"repository": {
"type": "git",
"url": "git@github.com:facebook/yoga.git"
},
"type": "module",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",
"exports": {
".": "./dist/src/index.js",
"./load": "./dist/src/load.js"
},
"files": [
"dist/binaries/**",
"dist/src/**",
"src/**"
],
"scripts": {
"benchmark": "just benchmark --config just.config.cjs",
"build": "just build --config just.config.cjs",
"clang-format": "just clang-format --config just.config.cjs",
"clang-format:fix": "just clang-format --fix --config just.config.cjs",
"clean": "just clean --config just.config.cjs",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"prepack": "just prepack --config just.config.cjs",
"test": "just test --config just.config.cjs",
"tsc": "tsc --noEmit"
},
"devDependencies": {
"@babel/cli": "^7.23.0",
"@babel/core": "^7.23.0",
"@babel/preset-env": "^7.23.0",
"@babel/preset-typescript": "^7.23.0",
"@types/jest": "^29.5.1",
"@types/node": "^16.18.25",
"@types/which": "^3.0.0",
"@yogalayout/cmake-bin": "3.28.0-1",
"babel-register-esm": "^1.2.5",
"clang-format": "^1.8.0",
"glob": "^10.4.2",
"jest": "^29.3.1",
"just-scripts": "^2.1.0",
"ninja-binaries": "^1.11.1",
"which": "^3.0.0"
}
}

54
node_modules/yoga-layout/src/Config.cpp generated vendored Normal file
View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <yoga/Yoga.h>
#include "./Config.h"
/* static */ Config* Config::create(void) {
return new Config();
}
/* static */ void Config::destroy(Config* node) {
delete node;
}
Config::Config(void) : m_config(YGConfigNew()) {}
Config::~Config(void) {
YGConfigFree(m_config);
}
void Config::setExperimentalFeatureEnabled(int feature, bool enabled) {
YGConfigSetExperimentalFeatureEnabled(
m_config, static_cast<YGExperimentalFeature>(feature), enabled);
}
void Config::setPointScaleFactor(float pixelsInPoint) {
YGConfigSetPointScaleFactor(m_config, pixelsInPoint);
}
void Config::setErrata(int errata) {
YGConfigSetErrata(m_config, static_cast<YGErrata>(errata));
}
void Config::setUseWebDefaults(bool useWebDefaults) {
YGConfigSetUseWebDefaults(m_config, useWebDefaults);
}
bool Config::isExperimentalFeatureEnabled(int feature) const {
return YGConfigIsExperimentalFeatureEnabled(
m_config, static_cast<YGExperimentalFeature>(feature));
}
int Config::getErrata() const {
return static_cast<int>(YGConfigGetErrata(m_config));
}
bool Config::useWebDefaults() const {
return YGConfigGetUseWebDefaults(m_config);
}

44
node_modules/yoga-layout/src/Config.h generated vendored Normal file
View File

@@ -0,0 +1,44 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <yoga/Yoga.h>
class Config {
friend class Node;
public:
static Config* create(void);
static void destroy(Config* config);
private:
Config(void);
public:
~Config(void);
public: // Prevent accidental copy
Config(Config const&) = delete;
Config const& operator=(Config const&) = delete;
public: // Setters
void setExperimentalFeatureEnabled(int feature, bool enabled);
void setPointScaleFactor(float pixelsInPoint);
void setErrata(int errata);
void setUseWebDefaults(bool useWebDefaults);
public: // Getters
bool isExperimentalFeatureEnabled(int feature) const;
int getErrata() const;
bool useWebDefaults() const;
private:
YGConfigRef m_config;
};

19
node_modules/yoga-layout/src/Layout.h generated vendored Normal file
View File

@@ -0,0 +1,19 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
struct Layout {
double left;
double right;
double top;
double bottom;
double width;
double height;
};

507
node_modules/yoga-layout/src/Node.cpp generated vendored Normal file
View File

@@ -0,0 +1,507 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <algorithm>
#include <yoga/Yoga.h>
#include "./Config.h"
#include "./Layout.h"
#include "./Node.h"
#include "./Size.h"
static YGSize globalMeasureFunc(
YGNodeConstRef nodeRef,
float width,
YGMeasureMode widthMode,
float height,
YGMeasureMode heightMode) {
Node const& node = *reinterpret_cast<Node const*>(YGNodeGetContext(nodeRef));
Size size = node.callMeasureFunc(width, widthMode, height, heightMode);
YGSize ygSize = {
static_cast<float>(size.width), static_cast<float>(size.height)};
return ygSize;
}
static void globalDirtiedFunc(YGNodeConstRef nodeRef) {
Node const& node = *reinterpret_cast<Node const*>(YGNodeGetContext(nodeRef));
node.callDirtiedFunc();
}
/* static */ Node* Node::createDefault(void) {
return new Node(nullptr);
}
/* static */ Node* Node::createWithConfig(Config* config) {
return new Node(config);
}
/* static */ void Node::destroy(Node* node) {
delete node;
}
/* static */ Node* Node::fromYGNode(YGNodeRef nodeRef) {
return reinterpret_cast<Node*>(YGNodeGetContext(nodeRef));
}
Node::Node(Config* config)
: m_node(
config != nullptr ? YGNodeNewWithConfig(config->m_config)
: YGNodeNew()),
m_measureFunc(nullptr),
m_dirtiedFunc(nullptr) {
YGNodeSetContext(m_node, reinterpret_cast<void*>(this));
}
Node::~Node(void) {
YGNodeFree(m_node);
}
void Node::reset(void) {
m_measureFunc.reset(nullptr);
m_dirtiedFunc.reset(nullptr);
YGNodeReset(m_node);
}
void Node::copyStyle(Node const& other) {
YGNodeCopyStyle(m_node, other.m_node);
}
void Node::setBoxSizing(int boxSizing) {
YGNodeStyleSetBoxSizing(m_node, static_cast<YGBoxSizing>(boxSizing));
}
void Node::setPositionType(int positionType) {
YGNodeStyleSetPositionType(m_node, static_cast<YGPositionType>(positionType));
}
void Node::setPosition(int edge, double position) {
YGNodeStyleSetPosition(m_node, static_cast<YGEdge>(edge), position);
}
void Node::setPositionPercent(int edge, double position) {
YGNodeStyleSetPositionPercent(m_node, static_cast<YGEdge>(edge), position);
}
void Node::setPositionAuto(int edge) {
YGNodeStyleSetPositionAuto(m_node, static_cast<YGEdge>(edge));
}
void Node::setAlignContent(int alignContent) {
YGNodeStyleSetAlignContent(m_node, static_cast<YGAlign>(alignContent));
}
void Node::setAlignItems(int alignItems) {
YGNodeStyleSetAlignItems(m_node, static_cast<YGAlign>(alignItems));
}
void Node::setAlignSelf(int alignSelf) {
YGNodeStyleSetAlignSelf(m_node, static_cast<YGAlign>(alignSelf));
}
void Node::setFlexDirection(int flexDirection) {
YGNodeStyleSetFlexDirection(
m_node, static_cast<YGFlexDirection>(flexDirection));
}
void Node::setDirection(int direction) {
YGNodeStyleSetDirection(m_node, static_cast<YGDirection>(direction));
}
void Node::setFlexWrap(int flexWrap) {
YGNodeStyleSetFlexWrap(m_node, static_cast<YGWrap>(flexWrap));
}
void Node::setJustifyContent(int justifyContent) {
YGNodeStyleSetJustifyContent(m_node, static_cast<YGJustify>(justifyContent));
}
void Node::setMargin(int edge, double margin) {
YGNodeStyleSetMargin(m_node, static_cast<YGEdge>(edge), margin);
}
void Node::setMarginPercent(int edge, double margin) {
YGNodeStyleSetMarginPercent(m_node, static_cast<YGEdge>(edge), margin);
}
void Node::setMarginAuto(int edge) {
YGNodeStyleSetMarginAuto(m_node, static_cast<YGEdge>(edge));
}
void Node::setOverflow(int overflow) {
YGNodeStyleSetOverflow(m_node, static_cast<YGOverflow>(overflow));
}
void Node::setDisplay(int display) {
YGNodeStyleSetDisplay(m_node, static_cast<YGDisplay>(display));
}
void Node::setFlex(double flex) {
YGNodeStyleSetFlex(m_node, flex);
}
void Node::setFlexBasis(double flexBasis) {
YGNodeStyleSetFlexBasis(m_node, flexBasis);
}
void Node::setFlexBasisPercent(double flexBasis) {
YGNodeStyleSetFlexBasisPercent(m_node, flexBasis);
}
void Node::setFlexBasisAuto() {
YGNodeStyleSetFlexBasisAuto(m_node);
}
void Node::setFlexGrow(double flexGrow) {
YGNodeStyleSetFlexGrow(m_node, flexGrow);
}
void Node::setFlexShrink(double flexShrink) {
YGNodeStyleSetFlexShrink(m_node, flexShrink);
}
void Node::setWidth(double width) {
YGNodeStyleSetWidth(m_node, width);
}
void Node::setWidthPercent(double width) {
YGNodeStyleSetWidthPercent(m_node, width);
}
void Node::setWidthAuto() {
YGNodeStyleSetWidthAuto(m_node);
}
void Node::setHeight(double height) {
YGNodeStyleSetHeight(m_node, height);
}
void Node::setHeightPercent(double height) {
YGNodeStyleSetHeightPercent(m_node, height);
}
void Node::setHeightAuto() {
YGNodeStyleSetHeightAuto(m_node);
}
void Node::setMinWidth(double minWidth) {
YGNodeStyleSetMinWidth(m_node, minWidth);
}
void Node::setMinWidthPercent(double minWidth) {
YGNodeStyleSetMinWidthPercent(m_node, minWidth);
}
void Node::setMinHeight(double minHeight) {
YGNodeStyleSetMinHeight(m_node, minHeight);
}
void Node::setMinHeightPercent(double minHeight) {
YGNodeStyleSetMinHeightPercent(m_node, minHeight);
}
void Node::setMaxWidth(double maxWidth) {
YGNodeStyleSetMaxWidth(m_node, maxWidth);
}
void Node::setMaxWidthPercent(double maxWidth) {
YGNodeStyleSetMaxWidthPercent(m_node, maxWidth);
}
void Node::setMaxHeight(double maxHeight) {
YGNodeStyleSetMaxHeight(m_node, maxHeight);
}
void Node::setMaxHeightPercent(double maxHeight) {
YGNodeStyleSetMaxHeightPercent(m_node, maxHeight);
}
void Node::setAspectRatio(double aspectRatio) {
YGNodeStyleSetAspectRatio(m_node, aspectRatio);
}
void Node::setBorder(int edge, double border) {
YGNodeStyleSetBorder(m_node, static_cast<YGEdge>(edge), border);
}
void Node::setPadding(int edge, double padding) {
YGNodeStyleSetPadding(m_node, static_cast<YGEdge>(edge), padding);
}
void Node::setPaddingPercent(int edge, double padding) {
YGNodeStyleSetPaddingPercent(m_node, static_cast<YGEdge>(edge), padding);
}
void Node::setIsReferenceBaseline(bool isReferenceBaseline) {
YGNodeSetIsReferenceBaseline(m_node, isReferenceBaseline);
}
void Node::setGap(int gutter, double gapLength) {
YGNodeStyleSetGap(m_node, static_cast<YGGutter>(gutter), gapLength);
}
void Node::setGapPercent(int gutter, double gapLength) {
YGNodeStyleSetGapPercent(m_node, static_cast<YGGutter>(gutter), gapLength);
}
int Node::getBoxSizing(void) const {
return YGNodeStyleGetBoxSizing(m_node);
}
int Node::getPositionType(void) const {
return YGNodeStyleGetPositionType(m_node);
}
Value Node::getPosition(int edge) const {
return Value::fromYGValue(
YGNodeStyleGetPosition(m_node, static_cast<YGEdge>(edge)));
}
int Node::getAlignContent(void) const {
return YGNodeStyleGetAlignContent(m_node);
}
int Node::getAlignItems(void) const {
return YGNodeStyleGetAlignItems(m_node);
}
int Node::getAlignSelf(void) const {
return YGNodeStyleGetAlignSelf(m_node);
}
int Node::getFlexDirection(void) const {
return YGNodeStyleGetFlexDirection(m_node);
}
int Node::getDirection(void) const {
return YGNodeStyleGetDirection(m_node);
}
int Node::getFlexWrap(void) const {
return YGNodeStyleGetFlexWrap(m_node);
}
int Node::getJustifyContent(void) const {
return YGNodeStyleGetJustifyContent(m_node);
}
Value Node::getMargin(int edge) const {
return Value::fromYGValue(
YGNodeStyleGetMargin(m_node, static_cast<YGEdge>(edge)));
}
int Node::getOverflow(void) const {
return YGNodeStyleGetOverflow(m_node);
}
int Node::getDisplay(void) const {
return YGNodeStyleGetDisplay(m_node);
}
Value Node::getFlexBasis(void) const {
return Value::fromYGValue(YGNodeStyleGetFlexBasis(m_node));
}
double Node::getFlexGrow(void) const {
return YGNodeStyleGetFlexGrow(m_node);
}
double Node::getFlexShrink(void) const {
return YGNodeStyleGetFlexShrink(m_node);
}
Value Node::getWidth(void) const {
return Value::fromYGValue(YGNodeStyleGetWidth(m_node));
}
Value Node::getHeight(void) const {
return Value::fromYGValue(YGNodeStyleGetHeight(m_node));
}
Value Node::getMinWidth(void) const {
return Value::fromYGValue(YGNodeStyleGetMinWidth(m_node));
}
Value Node::getMinHeight(void) const {
return Value::fromYGValue(YGNodeStyleGetMinHeight(m_node));
}
Value Node::getMaxWidth(void) const {
return Value::fromYGValue(YGNodeStyleGetMaxWidth(m_node));
}
Value Node::getMaxHeight(void) const {
return Value::fromYGValue(YGNodeStyleGetMaxHeight(m_node));
}
double Node::getAspectRatio(void) const {
return YGNodeStyleGetAspectRatio(m_node);
}
double Node::getBorder(int edge) const {
return YGNodeStyleGetBorder(m_node, static_cast<YGEdge>(edge));
}
Value Node::getPadding(int edge) const {
return Value::fromYGValue(
YGNodeStyleGetPadding(m_node, static_cast<YGEdge>(edge)));
}
float Node::getGap(int gutter) {
return YGNodeStyleGetGap(m_node, static_cast<YGGutter>(gutter));
}
bool Node::isReferenceBaseline() {
return YGNodeIsReferenceBaseline(m_node);
}
void Node::insertChild(Node* child, unsigned index) {
YGNodeInsertChild(m_node, child->m_node, index);
}
void Node::removeChild(Node* child) {
YGNodeRemoveChild(m_node, child->m_node);
}
unsigned Node::getChildCount(void) const {
return YGNodeGetChildCount(m_node);
}
Node* Node::getParent(void) {
auto nodePtr = YGNodeGetParent(m_node);
if (nodePtr == nullptr)
return nullptr;
return Node::fromYGNode(nodePtr);
}
Node* Node::getChild(unsigned index) {
auto nodePtr = YGNodeGetChild(m_node, index);
if (nodePtr == nullptr)
return nullptr;
return Node::fromYGNode(nodePtr);
}
void Node::setMeasureFunc(MeasureCallback* measureFunc) {
m_measureFunc.reset(measureFunc);
YGNodeSetMeasureFunc(m_node, &globalMeasureFunc);
}
void Node::unsetMeasureFunc(void) {
m_measureFunc.reset(nullptr);
YGNodeSetMeasureFunc(m_node, nullptr);
}
Size Node::callMeasureFunc(
double width,
int widthMode,
double height,
int heightMode) const {
return m_measureFunc->measure(width, widthMode, height, heightMode);
}
void Node::setDirtiedFunc(DirtiedCallback* dirtiedFunc) {
m_dirtiedFunc.reset(dirtiedFunc);
YGNodeSetDirtiedFunc(m_node, &globalDirtiedFunc);
}
void Node::unsetDirtiedFunc(void) {
m_dirtiedFunc.reset(nullptr);
YGNodeSetDirtiedFunc(m_node, nullptr);
}
void Node::callDirtiedFunc(void) const {
m_dirtiedFunc->dirtied();
}
void Node::markDirty(void) {
YGNodeMarkDirty(m_node);
}
bool Node::isDirty(void) const {
return YGNodeIsDirty(m_node);
}
void Node::markLayoutSeen() {
YGNodeSetHasNewLayout(m_node, false);
}
bool Node::hasNewLayout(void) const {
return YGNodeGetHasNewLayout(m_node);
}
void Node::calculateLayout(double width, double height, int direction) {
YGNodeCalculateLayout(
m_node, width, height, static_cast<YGDirection>(direction));
}
double Node::getComputedLeft(void) const {
return YGNodeLayoutGetLeft(m_node);
}
double Node::getComputedRight(void) const {
return YGNodeLayoutGetRight(m_node);
}
double Node::getComputedTop(void) const {
return YGNodeLayoutGetTop(m_node);
}
double Node::getComputedBottom(void) const {
return YGNodeLayoutGetBottom(m_node);
}
double Node::getComputedWidth(void) const {
return YGNodeLayoutGetWidth(m_node);
}
double Node::getComputedHeight(void) const {
return YGNodeLayoutGetHeight(m_node);
}
Layout Node::getComputedLayout(void) const {
Layout layout;
layout.left = YGNodeLayoutGetLeft(m_node);
layout.right = YGNodeLayoutGetRight(m_node);
layout.top = YGNodeLayoutGetTop(m_node);
layout.bottom = YGNodeLayoutGetBottom(m_node);
layout.width = YGNodeLayoutGetWidth(m_node);
layout.height = YGNodeLayoutGetHeight(m_node);
return layout;
}
double Node::getComputedMargin(int edge) const {
return YGNodeLayoutGetMargin(m_node, static_cast<YGEdge>(edge));
}
double Node::getComputedBorder(int edge) const {
return YGNodeLayoutGetBorder(m_node, static_cast<YGEdge>(edge));
}
double Node::getComputedPadding(int edge) const {
return YGNodeLayoutGetPadding(m_node, static_cast<YGEdge>(edge));
}
void Node::setAlwaysFormsContainingBlock(bool alwaysFormsContainingBlock) {
return YGNodeSetAlwaysFormsContainingBlock(
m_node, alwaysFormsContainingBlock);
}

239
node_modules/yoga-layout/src/Node.h generated vendored Normal file
View File

@@ -0,0 +1,239 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <memory>
#include <emscripten/bind.h>
#include <yoga/Yoga.h>
#include "./Config.h"
#include "./Layout.h"
#include "./Size.h"
#include "./Value.h"
class MeasureCallback {
public:
virtual ~MeasureCallback() {}
virtual Size
measure(float width, int widthMode, float height, int heightMode) = 0;
};
class MeasureCallbackWrapper : public emscripten::wrapper<MeasureCallback> {
public:
EMSCRIPTEN_WRAPPER(MeasureCallbackWrapper);
Size measure(float width, int widthMode, float height, int heightMode) {
return call<Size>("measure", width, widthMode, height, heightMode);
}
};
class DirtiedCallback {
public:
virtual ~DirtiedCallback() {}
virtual void dirtied() = 0;
};
class DirtiedCallbackWrapper : public emscripten::wrapper<DirtiedCallback> {
public:
EMSCRIPTEN_WRAPPER(DirtiedCallbackWrapper);
void dirtied() {
return call<void>("dirtied");
}
};
class Node {
public:
static Node* createDefault(void);
static Node* createWithConfig(Config* config);
static void destroy(Node* node);
public:
static Node* fromYGNode(YGNodeRef nodeRef);
private:
Node(Config* config);
public:
~Node(void);
public: // Prevent accidental copy
Node(Node const&) = delete;
Node const& operator=(Node const&) = delete;
public:
void reset(void);
public: // Style setters
void copyStyle(Node const& other);
void setPositionType(int positionType);
void setPosition(int edge, double position);
void setPositionPercent(int edge, double position);
void setPositionAuto(int edge);
void setAlignContent(int alignContent);
void setAlignItems(int alignItems);
void setAlignSelf(int alignSelf);
void setFlexDirection(int flexDirection);
void setFlexWrap(int flexWrap);
void setJustifyContent(int justifyContent);
void setDirection(int direction);
void setMargin(int edge, double margin);
void setMarginPercent(int edge, double margin);
void setMarginAuto(int edge);
void setOverflow(int overflow);
void setDisplay(int display);
void setFlex(double flex);
void setFlexBasis(double flexBasis);
void setFlexBasisPercent(double flexBasis);
void setFlexBasisAuto();
void setFlexGrow(double flexGrow);
void setFlexShrink(double flexShrink);
void setWidth(double width);
void setWidthPercent(double width);
void setWidthAuto();
void setHeight(double height);
void setHeightPercent(double height);
void setHeightAuto();
void setMinWidth(double minWidth);
void setMinWidthPercent(double minWidth);
void setMinHeight(double minHeight);
void setMinHeightPercent(double minHeight);
void setMaxWidth(double maxWidth);
void setMaxWidthPercent(double maxWidth);
void setMaxHeight(double maxHeight);
void setMaxHeightPercent(double maxHeight);
void setAspectRatio(double aspectRatio);
void setBorder(int edge, double border);
void setPadding(int edge, double padding);
void setPaddingPercent(int edge, double padding);
void setGap(int gutter, double gapLength);
void setGapPercent(int gutter, double gapLength);
void setBoxSizing(int boxSizing);
public: // Style getters
int getPositionType(void) const;
Value getPosition(int edge) const;
int getAlignContent(void) const;
int getAlignItems(void) const;
int getAlignSelf(void) const;
int getFlexDirection(void) const;
int getFlexWrap(void) const;
int getJustifyContent(void) const;
int getDirection(void) const;
Value getMargin(int edge) const;
int getOverflow(void) const;
int getDisplay(void) const;
Value getFlexBasis(void) const;
double getFlexGrow(void) const;
double getFlexShrink(void) const;
Value getWidth(void) const;
Value getHeight(void) const;
Value getMinWidth(void) const;
Value getMinHeight(void) const;
Value getMaxWidth(void) const;
Value getMaxHeight(void) const;
double getAspectRatio(void) const;
double getBorder(int edge) const;
Value getPadding(int edge) const;
float getGap(int gutter);
int getBoxSizing(void) const;
public: // Tree hierarchy mutators
void insertChild(Node* child, unsigned index);
void removeChild(Node* child);
public: // Tree hierarchy inspectors
unsigned getChildCount(void) const;
// The following functions cannot be const because they could discard const
// qualifiers (ex: constNode->getChild(0)->getParent() wouldn't be const)
Node* getParent(void);
Node* getChild(unsigned index);
public: // Measure func mutators
void setMeasureFunc(MeasureCallback* measureFunc);
void unsetMeasureFunc(void);
public: // Measure func inspectors
Size callMeasureFunc(
double width,
int widthMode,
double height,
int heightMode) const;
public: // Dirtied func mutators
void setDirtiedFunc(DirtiedCallback* dirtiedFunc);
void unsetDirtiedFunc(void);
public: // Dirtied func inspectors
void callDirtiedFunc(void) const;
public: // Dirtiness accessors
void markDirty(void);
bool isDirty(void) const;
void markLayoutSeen();
bool hasNewLayout(void) const;
public: // Layout mutators
void calculateLayout(double width, double height, int direction);
public: // Layout inspectors
double getComputedLeft(void) const;
double getComputedRight(void) const;
double getComputedTop(void) const;
double getComputedBottom(void) const;
double getComputedWidth(void) const;
double getComputedHeight(void) const;
Layout getComputedLayout(void) const;
double getComputedMargin(int edge) const;
double getComputedBorder(int edge) const;
double getComputedPadding(int edge) const;
public:
void setIsReferenceBaseline(bool isReferenceBaseline);
bool isReferenceBaseline();
YGNodeRef m_node;
std::unique_ptr<MeasureCallback> m_measureFunc;
std::unique_ptr<DirtiedCallback> m_dirtiedFunc;
public:
void setAlwaysFormsContainingBlock(bool alwaysFormContainingBlock);
};

17
node_modules/yoga-layout/src/Size.h generated vendored Normal file
View File

@@ -0,0 +1,17 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
struct Size {
double width;
double height;
Size(void) : width(0.0), height(0.0) {}
Size(double width, double height) : width(width), height(height) {}
};

23
node_modules/yoga-layout/src/Value.h generated vendored Normal file
View File

@@ -0,0 +1,23 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#pragma once
#include <yoga/Yoga.h>
struct Value {
static Value fromYGValue(YGValue const& ygValue) {
return Value(static_cast<int>(ygValue.unit), ygValue.value);
}
int unit;
double value;
Value(void) : unit(YGUnitUndefined), value(0.0) {}
Value(int unit, double value) : unit(unit), value(value) {}
};

207
node_modules/yoga-layout/src/embind.cpp generated vendored Normal file
View File

@@ -0,0 +1,207 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "./Config.h"
#include "./Layout.h"
#include "./Node.h"
#include "./Size.h"
#include "./Value.h"
#include <emscripten/bind.h>
#include <yoga/Yoga.h>
using namespace emscripten;
EMSCRIPTEN_BINDINGS(YOGA_LAYOUT) {
class_<MeasureCallback>("MeasureCallback")
.function("measure", &MeasureCallback::measure, pure_virtual())
.allow_subclass<MeasureCallbackWrapper>("MeasureCallbackWrapper");
class_<DirtiedCallback>("DirtiedCallback")
.function("dirtied", &DirtiedCallback::dirtied, pure_virtual())
.allow_subclass<DirtiedCallbackWrapper>("DirtiedCallbackWrapper");
class_<Config>("Config")
.constructor<>(&Config::create, allow_raw_pointers())
.class_function<>("create", &Config::create, allow_raw_pointers())
.class_function<>("destroy", &Config::destroy, allow_raw_pointers())
.function(
"setExperimentalFeatureEnabled",
&Config::setExperimentalFeatureEnabled)
.function("setPointScaleFactor", &Config::setPointScaleFactor)
.function("setErrata", &Config::setErrata)
.function("setUseWebDefaults", &Config::setUseWebDefaults)
.function(
"isExperimentalFeatureEnabled", &Config::isExperimentalFeatureEnabled)
.function("getErrata", &Config::getErrata)
.function("useWebDefaults", &Config::useWebDefaults);
value_object<Layout>("Layout")
.field("left", &Layout::left)
.field("right", &Layout::right)
.field("top", &Layout::top)
.field("bottom", &Layout::bottom)
.field("width", &Layout::width)
.field("height", &Layout::height);
value_object<Size>("Size")
.field("width", &Size::width)
.field("height", &Size::height);
value_object<Value>("Value")
.field("value", &Value::value)
.field("unit", &Value::unit);
class_<Node>("Node")
.constructor<>(&Node::createDefault, allow_raw_pointers())
.class_function<>(
"createDefault", &Node::createDefault, allow_raw_pointers())
.class_function<>(
"createWithConfig", &Node::createWithConfig, allow_raw_pointers())
.class_function<>("destroy", &Node::destroy, allow_raw_pointers())
.function("reset", &Node::reset)
.function("copyStyle", &Node::copyStyle)
.function("setPositionType", &Node::setPositionType)
.function("setPosition", &Node::setPosition)
.function("setPositionPercent", &Node::setPositionPercent)
.function("setPositionAuto", &Node::setPositionAuto)
.function("setAlignContent", &Node::setAlignContent)
.function("setAlignItems", &Node::setAlignItems)
.function("setAlignSelf", &Node::setAlignSelf)
.function("setFlexDirection", &Node::setFlexDirection)
.function("setFlexWrap", &Node::setFlexWrap)
.function("setJustifyContent", &Node::setJustifyContent)
.function("setMargin", &Node::setMargin)
.function("setMarginPercent", &Node::setMarginPercent)
.function("setMarginAuto", &Node::setMarginAuto)
.function("setOverflow", &Node::setOverflow)
.function("setDisplay", &Node::setDisplay)
.function("setFlex", &Node::setFlex)
.function("setFlexBasis", &Node::setFlexBasis)
.function("setFlexBasisPercent", &Node::setFlexBasisPercent)
.function("setFlexBasisAuto", &Node::setFlexBasisAuto)
.function("setFlexGrow", &Node::setFlexGrow)
.function("setFlexShrink", &Node::setFlexShrink)
.function("setWidth", &Node::setWidth)
.function("setWidthPercent", &Node::setWidthPercent)
.function("setWidthAuto", &Node::setWidthAuto)
.function("setHeight", &Node::setHeight)
.function("setHeightPercent", &Node::setHeightPercent)
.function("setHeightAuto", &Node::setHeightAuto)
.function("setMinWidth", &Node::setMinWidth)
.function("setMinWidthPercent", &Node::setMinWidthPercent)
.function("setMinHeight", &Node::setMinHeight)
.function("setMinHeightPercent", &Node::setMinHeightPercent)
.function("setMaxWidth", &Node::setMaxWidth)
.function("setMaxWidthPercent", &Node::setMaxWidthPercent)
.function("setMaxHeight", &Node::setMaxHeight)
.function("setMaxHeightPercent", &Node::setMaxHeightPercent)
.function("setBoxSizing", &Node::setBoxSizing)
.function("setAspectRatio", &Node::setAspectRatio)
.function("setBorder", &Node::setBorder)
.function("setPadding", &Node::setPadding)
.function("setPaddingPercent", &Node::setPaddingPercent)
.function("setGap", &Node::setGap)
.function("setGapPercent", &Node::setGapPercent)
.function("setDirection", &Node::setDirection)
.function("getPositionType", &Node::getPositionType)
.function("getPosition", &Node::getPosition)
.function("getAlignContent", &Node::getAlignContent)
.function("getAlignItems", &Node::getAlignItems)
.function("getAlignSelf", &Node::getAlignSelf)
.function("getFlexDirection", &Node::getFlexDirection)
.function("getFlexWrap", &Node::getFlexWrap)
.function("getJustifyContent", &Node::getJustifyContent)
.function("getMargin", &Node::getMargin)
.function("getFlexBasis", &Node::getFlexBasis)
.function("getFlexGrow", &Node::getFlexGrow)
.function("getFlexShrink", &Node::getFlexShrink)
.function("getWidth", &Node::getWidth)
.function("getHeight", &Node::getHeight)
.function("getMinWidth", &Node::getMinWidth)
.function("getMinHeight", &Node::getMinHeight)
.function("getMaxWidth", &Node::getMaxWidth)
.function("getMaxHeight", &Node::getMaxHeight)
.function("getBoxSizing", &Node::getBoxSizing)
.function("getAspectRatio", &Node::getAspectRatio)
.function("getBorder", &Node::getBorder)
.function("getOverflow", &Node::getOverflow)
.function("getDisplay", &Node::getDisplay)
.function("getPadding", &Node::getPadding)
.function("getGap", &Node::getGap)
.function("insertChild", &Node::insertChild, allow_raw_pointers())
.function("removeChild", &Node::removeChild, allow_raw_pointers())
.function("getChildCount", &Node::getChildCount)
.function("getParent", &Node::getParent, allow_raw_pointers())
.function("getChild", &Node::getChild, allow_raw_pointers())
.function(
"setAlwaysFormsContainingBlock", &Node::setAlwaysFormsContainingBlock)
.function("isReferenceBaseline", &Node::isReferenceBaseline)
.function("setIsReferenceBaseline", &Node::setIsReferenceBaseline)
.function("setMeasureFunc", &Node::setMeasureFunc, allow_raw_pointers())
.function("unsetMeasureFunc", &Node::unsetMeasureFunc)
.function("setDirtiedFunc", &Node::setDirtiedFunc, allow_raw_pointers())
.function("unsetDirtiedFunc", &Node::unsetDirtiedFunc)
.function("markDirty", &Node::markDirty)
.function("isDirty", &Node::isDirty)
.function("markLayoutSeen", &Node::markLayoutSeen)
.function("hasNewLayout", &Node::hasNewLayout)
.function("calculateLayout", &Node::calculateLayout)
.function("getComputedLeft", &Node::getComputedLeft)
.function("getComputedRight", &Node::getComputedRight)
.function("getComputedTop", &Node::getComputedTop)
.function("getComputedBottom", &Node::getComputedBottom)
.function("getComputedWidth", &Node::getComputedWidth)
.function("getComputedHeight", &Node::getComputedHeight)
.function("getComputedLayout", &Node::getComputedLayout)
.function("getComputedMargin", &Node::getComputedMargin)
.function("getComputedBorder", &Node::getComputedBorder)
.function("getComputedPadding", &Node::getComputedPadding)
.function("getDirection", &Node::getDirection);
}

210
node_modules/yoga-layout/src/generated/YGEnums.ts generated vendored Normal file
View File

@@ -0,0 +1,210 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
// @generated by enums.py
export enum Align {
Auto = 0,
FlexStart = 1,
Center = 2,
FlexEnd = 3,
Stretch = 4,
Baseline = 5,
SpaceBetween = 6,
SpaceAround = 7,
SpaceEvenly = 8,
}
export enum BoxSizing {
BorderBox = 0,
ContentBox = 1,
}
export enum Dimension {
Width = 0,
Height = 1,
}
export enum Direction {
Inherit = 0,
LTR = 1,
RTL = 2,
}
export enum Display {
Flex = 0,
None = 1,
Contents = 2,
}
export enum Edge {
Left = 0,
Top = 1,
Right = 2,
Bottom = 3,
Start = 4,
End = 5,
Horizontal = 6,
Vertical = 7,
All = 8,
}
export enum Errata {
None = 0,
StretchFlexBasis = 1,
AbsolutePositionWithoutInsetsExcludesPadding = 2,
AbsolutePercentAgainstInnerSize = 4,
All = 2147483647,
Classic = 2147483646,
}
export enum ExperimentalFeature {
WebFlexBasis = 0,
}
export enum FlexDirection {
Column = 0,
ColumnReverse = 1,
Row = 2,
RowReverse = 3,
}
export enum Gutter {
Column = 0,
Row = 1,
All = 2,
}
export enum Justify {
FlexStart = 0,
Center = 1,
FlexEnd = 2,
SpaceBetween = 3,
SpaceAround = 4,
SpaceEvenly = 5,
}
export enum LogLevel {
Error = 0,
Warn = 1,
Info = 2,
Debug = 3,
Verbose = 4,
Fatal = 5,
}
export enum MeasureMode {
Undefined = 0,
Exactly = 1,
AtMost = 2,
}
export enum NodeType {
Default = 0,
Text = 1,
}
export enum Overflow {
Visible = 0,
Hidden = 1,
Scroll = 2,
}
export enum PositionType {
Static = 0,
Relative = 1,
Absolute = 2,
}
export enum Unit {
Undefined = 0,
Point = 1,
Percent = 2,
Auto = 3,
}
export enum Wrap {
NoWrap = 0,
Wrap = 1,
WrapReverse = 2,
}
const constants = {
ALIGN_AUTO: Align.Auto,
ALIGN_FLEX_START: Align.FlexStart,
ALIGN_CENTER: Align.Center,
ALIGN_FLEX_END: Align.FlexEnd,
ALIGN_STRETCH: Align.Stretch,
ALIGN_BASELINE: Align.Baseline,
ALIGN_SPACE_BETWEEN: Align.SpaceBetween,
ALIGN_SPACE_AROUND: Align.SpaceAround,
ALIGN_SPACE_EVENLY: Align.SpaceEvenly,
BOX_SIZING_BORDER_BOX: BoxSizing.BorderBox,
BOX_SIZING_CONTENT_BOX: BoxSizing.ContentBox,
DIMENSION_WIDTH: Dimension.Width,
DIMENSION_HEIGHT: Dimension.Height,
DIRECTION_INHERIT: Direction.Inherit,
DIRECTION_LTR: Direction.LTR,
DIRECTION_RTL: Direction.RTL,
DISPLAY_FLEX: Display.Flex,
DISPLAY_NONE: Display.None,
DISPLAY_CONTENTS: Display.Contents,
EDGE_LEFT: Edge.Left,
EDGE_TOP: Edge.Top,
EDGE_RIGHT: Edge.Right,
EDGE_BOTTOM: Edge.Bottom,
EDGE_START: Edge.Start,
EDGE_END: Edge.End,
EDGE_HORIZONTAL: Edge.Horizontal,
EDGE_VERTICAL: Edge.Vertical,
EDGE_ALL: Edge.All,
ERRATA_NONE: Errata.None,
ERRATA_STRETCH_FLEX_BASIS: Errata.StretchFlexBasis,
ERRATA_ABSOLUTE_POSITION_WITHOUT_INSETS_EXCLUDES_PADDING: Errata.AbsolutePositionWithoutInsetsExcludesPadding,
ERRATA_ABSOLUTE_PERCENT_AGAINST_INNER_SIZE: Errata.AbsolutePercentAgainstInnerSize,
ERRATA_ALL: Errata.All,
ERRATA_CLASSIC: Errata.Classic,
EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS: ExperimentalFeature.WebFlexBasis,
FLEX_DIRECTION_COLUMN: FlexDirection.Column,
FLEX_DIRECTION_COLUMN_REVERSE: FlexDirection.ColumnReverse,
FLEX_DIRECTION_ROW: FlexDirection.Row,
FLEX_DIRECTION_ROW_REVERSE: FlexDirection.RowReverse,
GUTTER_COLUMN: Gutter.Column,
GUTTER_ROW: Gutter.Row,
GUTTER_ALL: Gutter.All,
JUSTIFY_FLEX_START: Justify.FlexStart,
JUSTIFY_CENTER: Justify.Center,
JUSTIFY_FLEX_END: Justify.FlexEnd,
JUSTIFY_SPACE_BETWEEN: Justify.SpaceBetween,
JUSTIFY_SPACE_AROUND: Justify.SpaceAround,
JUSTIFY_SPACE_EVENLY: Justify.SpaceEvenly,
LOG_LEVEL_ERROR: LogLevel.Error,
LOG_LEVEL_WARN: LogLevel.Warn,
LOG_LEVEL_INFO: LogLevel.Info,
LOG_LEVEL_DEBUG: LogLevel.Debug,
LOG_LEVEL_VERBOSE: LogLevel.Verbose,
LOG_LEVEL_FATAL: LogLevel.Fatal,
MEASURE_MODE_UNDEFINED: MeasureMode.Undefined,
MEASURE_MODE_EXACTLY: MeasureMode.Exactly,
MEASURE_MODE_AT_MOST: MeasureMode.AtMost,
NODE_TYPE_DEFAULT: NodeType.Default,
NODE_TYPE_TEXT: NodeType.Text,
OVERFLOW_VISIBLE: Overflow.Visible,
OVERFLOW_HIDDEN: Overflow.Hidden,
OVERFLOW_SCROLL: Overflow.Scroll,
POSITION_TYPE_STATIC: PositionType.Static,
POSITION_TYPE_RELATIVE: PositionType.Relative,
POSITION_TYPE_ABSOLUTE: PositionType.Absolute,
UNIT_UNDEFINED: Unit.Undefined,
UNIT_POINT: Unit.Point,
UNIT_PERCENT: Unit.Percent,
UNIT_AUTO: Unit.Auto,
WRAP_NO_WRAP: Wrap.NoWrap,
WRAP_WRAP: Wrap.Wrap,
WRAP_WRAP_REVERSE: Wrap.WrapReverse,
}
export default constants

23
node_modules/yoga-layout/src/index.ts generated vendored Normal file
View File

@@ -0,0 +1,23 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
// @ts-ignore untyped from Emscripten
import loadYoga from '../binaries/yoga-wasm-base64-esm.js';
import wrapAssembly from './wrapAssembly.ts';
export type {
Config,
DirtiedFunction,
MeasureFunction,
Node,
} from './wrapAssembly.ts';
const Yoga = wrapAssembly(await loadYoga());
export default Yoga;
export * from './generated/YGEnums.ts';

25
node_modules/yoga-layout/src/load.ts generated vendored Normal file
View File

@@ -0,0 +1,25 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
// @ts-ignore untyped from Emscripten
import loadYogaImpl from '../binaries/yoga-wasm-base64-esm.js';
import wrapAssembly from './wrapAssembly.ts';
export type {
Config,
DirtiedFunction,
MeasureFunction,
Node,
Yoga,
} from './wrapAssembly.ts';
export async function loadYoga() {
return wrapAssembly(await loadYogaImpl());
}
export * from './generated/YGEnums.ts';

336
node_modules/yoga-layout/src/wrapAssembly.ts generated vendored Normal file
View File

@@ -0,0 +1,336 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
// @ts-nocheck
import {Unit, Direction} from './generated/YGEnums.ts';
import YGEnums from './generated/YGEnums.ts';
import type {
Align,
BoxSizing,
Display,
Edge,
Errata,
ExperimentalFeature,
FlexDirection,
Gutter,
Justify,
MeasureMode,
Overflow,
PositionType,
Wrap,
} from './generated/YGEnums.ts';
type Layout = {
left: number;
right: number;
top: number;
bottom: number;
width: number;
height: number;
};
type Size = {
width: number;
height: number;
};
type Value = {
unit: Unit;
value: number;
};
export type Config = {
free(): void;
isExperimentalFeatureEnabled(feature: ExperimentalFeature): boolean;
setExperimentalFeatureEnabled(
feature: ExperimentalFeature,
enabled: boolean,
): void;
setPointScaleFactor(factor: number): void;
getErrata(): Errata;
setErrata(errata: Errata): void;
useWebDefaults(): boolean;
setUseWebDefaults(useWebDefaults: boolean): void;
};
export type DirtiedFunction = (node: Node) => void;
export type MeasureFunction = (
width: number,
widthMode: MeasureMode,
height: number,
heightMode: MeasureMode,
) => Size;
export type Node = {
calculateLayout(
width: number | 'auto' | undefined,
height: number | 'auto' | undefined,
direction?: Direction,
): void;
copyStyle(node: Node): void;
free(): void;
freeRecursive(): void;
getAlignContent(): Align;
getAlignItems(): Align;
getAlignSelf(): Align;
getAspectRatio(): number;
getBorder(edge: Edge): number;
getChild(index: number): Node;
getChildCount(): number;
getComputedBorder(edge: Edge): number;
getComputedBottom(): number;
getComputedHeight(): number;
getComputedLayout(): Layout;
getComputedLeft(): number;
getComputedMargin(edge: Edge): number;
getComputedPadding(edge: Edge): number;
getComputedRight(): number;
getComputedTop(): number;
getComputedWidth(): number;
getDirection(): Direction;
getDisplay(): Display;
getFlexBasis(): Value;
getFlexDirection(): FlexDirection;
getFlexGrow(): number;
getFlexShrink(): number;
getFlexWrap(): Wrap;
getHeight(): Value;
getJustifyContent(): Justify;
getGap(gutter: Gutter): Value;
getMargin(edge: Edge): Value;
getMaxHeight(): Value;
getMaxWidth(): Value;
getMinHeight(): Value;
getMinWidth(): Value;
getOverflow(): Overflow;
getPadding(edge: Edge): Value;
getParent(): Node | null;
getPosition(edge: Edge): Value;
getPositionType(): PositionType;
getBoxSizing(): BoxSizing;
getWidth(): Value;
insertChild(child: Node, index: number): void;
isDirty(): boolean;
isReferenceBaseline(): boolean;
markDirty(): void;
hasNewLayout(): boolean;
markLayoutSeen(): void;
removeChild(child: Node): void;
reset(): void;
setAlignContent(alignContent: Align): void;
setAlignItems(alignItems: Align): void;
setAlignSelf(alignSelf: Align): void;
setAspectRatio(aspectRatio: number | undefined): void;
setBorder(edge: Edge, borderWidth: number | undefined): void;
setDirection(direction: Direction): void;
setDisplay(display: Display): void;
setFlex(flex: number | undefined): void;
setFlexBasis(flexBasis: number | 'auto' | `${number}%` | undefined): void;
setFlexBasisPercent(flexBasis: number | undefined): void;
setFlexBasisAuto(): void;
setFlexDirection(flexDirection: FlexDirection): void;
setFlexGrow(flexGrow: number | undefined): void;
setFlexShrink(flexShrink: number | undefined): void;
setFlexWrap(flexWrap: Wrap): void;
setHeight(height: number | 'auto' | `${number}%` | undefined): void;
setIsReferenceBaseline(isReferenceBaseline: boolean): void;
setHeightAuto(): void;
setHeightPercent(height: number | undefined): void;
setJustifyContent(justifyContent: Justify): void;
setGap(gutter: Gutter, gapLength: number | `${number}%` | undefined): Value;
setGapPercent(gutter: Gutter, gapLength: number | undefined): Value;
setMargin(
edge: Edge,
margin: number | 'auto' | `${number}%` | undefined,
): void;
setMarginAuto(edge: Edge): void;
setMarginPercent(edge: Edge, margin: number | undefined): void;
setMaxHeight(maxHeight: number | `${number}%` | undefined): void;
setMaxHeightPercent(maxHeight: number | undefined): void;
setMaxWidth(maxWidth: number | `${number}%` | undefined): void;
setMaxWidthPercent(maxWidth: number | undefined): void;
setDirtiedFunc(dirtiedFunc: DirtiedFunction | null): void;
setMeasureFunc(measureFunc: MeasureFunction | null): void;
setMinHeight(minHeight: number | `${number}%` | undefined): void;
setMinHeightPercent(minHeight: number | undefined): void;
setMinWidth(minWidth: number | `${number}%` | undefined): void;
setMinWidthPercent(minWidth: number | undefined): void;
setOverflow(overflow: Overflow): void;
setPadding(edge: Edge, padding: number | `${number}%` | undefined): void;
setPaddingPercent(edge: Edge, padding: number | undefined): void;
setPosition(edge: Edge, position: number | `${number}%` | undefined): void;
setPositionPercent(edge: Edge, position: number | undefined): void;
setPositionType(positionType: PositionType): void;
setPositionAuto(edge: Edge): void;
setBoxSizing(boxSizing: BoxSizing): void;
setWidth(width: number | 'auto' | `${number}%` | undefined): void;
setWidthAuto(): void;
setWidthPercent(width: number | undefined): void;
unsetDirtiedFunc(): void;
unsetMeasureFunc(): void;
setAlwaysFormsContainingBlock(alwaysFormsContainingBlock: boolean): void;
};
export type Yoga = {
Config: {
create(): Config;
destroy(config: Config): void;
};
Node: {
create(config?: Config): Node;
createDefault(): Node;
createWithConfig(config: Config): Node;
destroy(node: Node): void;
};
} & typeof YGEnums;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export default function wrapAssembly(lib: any): Yoga {
function patch(prototype, name, fn) {
const original = prototype[name];
prototype[name] = function (...args) {
return fn.call(this, original, ...args);
};
}
for (const fnName of [
'setPosition',
'setMargin',
'setFlexBasis',
'setWidth',
'setHeight',
'setMinWidth',
'setMinHeight',
'setMaxWidth',
'setMaxHeight',
'setPadding',
'setGap',
]) {
const methods = {
[Unit.Point]: lib.Node.prototype[fnName],
[Unit.Percent]: lib.Node.prototype[`${fnName}Percent`],
[Unit.Auto]: lib.Node.prototype[`${fnName}Auto`],
};
patch(lib.Node.prototype, fnName, function (original, ...args) {
// We patch all these functions to add support for the following calls:
// .setWidth(100) / .setWidth("100%") / .setWidth(.getWidth()) / .setWidth("auto")
const value = args.pop();
let unit, asNumber;
if (value === 'auto') {
unit = Unit.Auto;
asNumber = undefined;
} else if (typeof value === 'object') {
unit = value.unit;
asNumber = value.valueOf();
} else {
unit =
typeof value === 'string' && value.endsWith('%')
? Unit.Percent
: Unit.Point;
asNumber = parseFloat(value);
if (
value !== undefined &&
!Number.isNaN(value) &&
Number.isNaN(asNumber)
) {
throw new Error(`Invalid value ${value} for ${fnName}`);
}
}
if (!methods[unit])
throw new Error(
`Failed to execute "${fnName}": Unsupported unit '${value}'`,
);
if (asNumber !== undefined) {
return methods[unit].call(this, ...args, asNumber);
} else {
return methods[unit].call(this, ...args);
}
});
}
function wrapMeasureFunction(measureFunction) {
return lib.MeasureCallback.implement({
measure: (...args) => {
const {width, height} = measureFunction(...args);
return {
width: width ?? NaN,
height: height ?? NaN,
};
},
});
}
patch(lib.Node.prototype, 'setMeasureFunc', function (original, measureFunc) {
// This patch is just a convenience patch, since it helps write more
// idiomatic source code (such as .setMeasureFunc(null))
if (measureFunc) {
return original.call(this, wrapMeasureFunction(measureFunc));
} else {
return this.unsetMeasureFunc();
}
});
function wrapDirtiedFunc(dirtiedFunction) {
return lib.DirtiedCallback.implement({dirtied: dirtiedFunction});
}
patch(lib.Node.prototype, 'setDirtiedFunc', function (original, dirtiedFunc) {
original.call(this, wrapDirtiedFunc(dirtiedFunc));
});
patch(lib.Config.prototype, 'free', function () {
// Since we handle the memory allocation ourselves (via lib.Config.create),
// we also need to handle the deallocation
lib.Config.destroy(this);
});
patch(lib.Node, 'create', (_, config) => {
// We decide the constructor we want to call depending on the parameters
return config
? lib.Node.createWithConfig(config)
: lib.Node.createDefault();
});
patch(lib.Node.prototype, 'free', function () {
// Since we handle the memory allocation ourselves (via lib.Node.create),
// we also need to handle the deallocation
lib.Node.destroy(this);
});
patch(lib.Node.prototype, 'freeRecursive', function () {
for (let t = 0, T = this.getChildCount(); t < T; ++t) {
this.getChild(0).freeRecursive();
}
this.free();
});
patch(
lib.Node.prototype,
'calculateLayout',
function (original, width = NaN, height = NaN, direction = Direction.LTR) {
// Just a small patch to add support for the function default parameters
return original.call(this, width, height, direction);
},
);
return {
Config: lib.Config,
Node: lib.Node,
...YGEnums,
};
}