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

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,
};
}