benchmark in Actions, opaque/safe enum types, more explicit test scripts
This commit is contained in:
4
.github/workflows/validate-js.yml
vendored
4
.github/workflows/validate-js.yml
vendored
@@ -25,3 +25,7 @@ jobs:
|
|||||||
- name: yarn test
|
- name: yarn test
|
||||||
run: yarn test
|
run: yarn test
|
||||||
working-directory: javascript
|
working-directory: javascript
|
||||||
|
|
||||||
|
- name: yarn benchmark
|
||||||
|
run: yarn benchmark
|
||||||
|
working-directory: javascript
|
||||||
|
34
enums.py
34
enums.py
@@ -230,17 +230,14 @@ with open(root + "/javascript/sources/YGEnums.js", "w") as f:
|
|||||||
f.write(" %s_COUNT: %s,\n" % (to_java_upper(name), len(values)))
|
f.write(" %s_COUNT: %s,\n" % (to_java_upper(name), len(values)))
|
||||||
base = 0
|
base = 0
|
||||||
for value in values:
|
for value in values:
|
||||||
if isinstance(value, tuple):
|
value_arg = value[0] if isinstance(value, tuple) else value
|
||||||
|
ordinal_arg = value[1] if isinstance(value, tuple) else base
|
||||||
|
|
||||||
f.write(
|
f.write(
|
||||||
" %s_%s: %d,\n"
|
" %s_%s: %d,\n"
|
||||||
% (to_java_upper(name), to_java_upper(value[0]), value[1])
|
% (to_java_upper(name), to_java_upper(value_arg), ordinal_arg)
|
||||||
)
|
)
|
||||||
base = value[1] + 1
|
base = ordinal_arg + 1
|
||||||
else:
|
|
||||||
f.write(
|
|
||||||
" %s_%s: %d,\n" % (to_java_upper(name), to_java_upper(value), base)
|
|
||||||
)
|
|
||||||
base += 1
|
|
||||||
|
|
||||||
if name != items[-1][0]:
|
if name != items[-1][0]:
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
@@ -252,18 +249,21 @@ with open(root + "/javascript/sources/YGEnums.d.ts", "w") as f:
|
|||||||
for name, values in sorted(ENUMS.items()):
|
for name, values in sorted(ENUMS.items()):
|
||||||
base = 0
|
base = 0
|
||||||
for value in values:
|
for value in values:
|
||||||
if isinstance(value, tuple):
|
value_arg = value[0] if isinstance(value, tuple) else value
|
||||||
|
ordinal_arg = value[1] if isinstance(value, tuple) else base
|
||||||
|
|
||||||
f.write(
|
f.write(
|
||||||
"export const %s_%s: %d;\n"
|
(
|
||||||
% (to_java_upper(name), to_java_upper(value[0]), value[1])
|
"type {name}_{value} = {ordinal} & ['{name}']\n"
|
||||||
|
+ "export const {name}_{value}: {name}_{value};\n\n"
|
||||||
|
).format(
|
||||||
|
name=to_java_upper(name),
|
||||||
|
value=to_java_upper(value_arg),
|
||||||
|
ordinal=ordinal_arg,
|
||||||
)
|
)
|
||||||
base = value[1] + 1
|
|
||||||
else:
|
|
||||||
f.write(
|
|
||||||
"export const %s_%s: %d;\n"
|
|
||||||
% (to_java_upper(name), to_java_upper(value), base)
|
|
||||||
)
|
)
|
||||||
base += 1
|
|
||||||
|
base = ordinal_arg + 1
|
||||||
|
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
|
|
||||||
|
@@ -8,11 +8,11 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = async () => {
|
module.exports = async () => {
|
||||||
if (process.env['SYNC'] && process.env['WASM']) {
|
if (process.env['SYNC'] == true && process.env['WASM'] == true) {
|
||||||
global.Yoga = require("./dist/sync.wasm");
|
global.Yoga = require("./dist/sync.wasm");
|
||||||
} else if (process.env['SYNC']) {
|
} else if (process.env['SYNC'] == true) {
|
||||||
global.Yoga = require("./dist/sync.asmjs");
|
global.Yoga = require("./dist/sync.asmjs");
|
||||||
} else if (process.env['WASM']) {
|
} else if (process.env['WASM'] == true) {
|
||||||
global.Yoga = await require("./dist/index.wasm").loadYoga();
|
global.Yoga = await require("./dist/index.wasm").loadYoga();
|
||||||
} else {
|
} else {
|
||||||
global.Yoga = await require("./dist/index.asmjs").loadYoga();
|
global.Yoga = await require("./dist/index.asmjs").loadYoga();
|
||||||
|
@@ -31,9 +31,9 @@
|
|||||||
"build:native-project": "which ninja && emcmake cmake -S . -B build -G Ninja || emcmake cmake -S . -B build",
|
"build:native-project": "which ninja && emcmake cmake -S . -B build -G Ninja || emcmake cmake -S . -B build",
|
||||||
"build:js": "babel sources --source-maps --out-dir dist && cp -r sources/*.d.ts dist",
|
"build:js": "babel sources --source-maps --out-dir dist && cp -r sources/*.d.ts dist",
|
||||||
"test": "yarn test:asmjs && yarn test:asmjs-sync && yarn test:wasm && yarn test:wasm-sync",
|
"test": "yarn test:asmjs && yarn test:asmjs-sync && yarn test:wasm && yarn test:wasm-sync",
|
||||||
"test:asmjs": "jest",
|
"test:asmjs": "WASM=0 SYNC=0 jest",
|
||||||
"test:asmjs-sync": "SYNC=1 jest",
|
"test:asmjs-sync": "WASM=0 SYNC=1 jest",
|
||||||
"test:wasm": "WASM=1 jest",
|
"test:wasm": "WASM=1 SYNC=0 jest",
|
||||||
"test:wasm-sync": "WASM=1 SYNC=1 jest",
|
"test:wasm-sync": "WASM=1 SYNC=1 jest",
|
||||||
"benchmark": "node tests/run-bench $(find tests/Benchmarks -name '*.js')"
|
"benchmark": "node tests/run-bench $(find tests/Benchmarks -name '*.js')"
|
||||||
},
|
},
|
||||||
|
260
javascript/sources/YGEnums.d.ts
vendored
260
javascript/sources/YGEnums.d.ts
vendored
@@ -7,87 +7,217 @@
|
|||||||
|
|
||||||
// @generated by enums.py
|
// @generated by enums.py
|
||||||
|
|
||||||
export const ALIGN_AUTO: 0;
|
type ALIGN_AUTO = 0 & ['ALIGN']
|
||||||
export const ALIGN_FLEX_START: 1;
|
export const ALIGN_AUTO: ALIGN_AUTO;
|
||||||
export const ALIGN_CENTER: 2;
|
|
||||||
export const ALIGN_FLEX_END: 3;
|
|
||||||
export const ALIGN_STRETCH: 4;
|
|
||||||
export const ALIGN_BASELINE: 5;
|
|
||||||
export const ALIGN_SPACE_BETWEEN: 6;
|
|
||||||
export const ALIGN_SPACE_AROUND: 7;
|
|
||||||
|
|
||||||
export const DIMENSION_WIDTH: 0;
|
type ALIGN_FLEX_START = 1 & ['ALIGN']
|
||||||
export const DIMENSION_HEIGHT: 1;
|
export const ALIGN_FLEX_START: ALIGN_FLEX_START;
|
||||||
|
|
||||||
export const DIRECTION_INHERIT: 0;
|
type ALIGN_CENTER = 2 & ['ALIGN']
|
||||||
export const DIRECTION_LTR: 1;
|
export const ALIGN_CENTER: ALIGN_CENTER;
|
||||||
export const DIRECTION_RTL: 2;
|
|
||||||
|
|
||||||
export const DISPLAY_FLEX: 0;
|
type ALIGN_FLEX_END = 3 & ['ALIGN']
|
||||||
export const DISPLAY_NONE: 1;
|
export const ALIGN_FLEX_END: ALIGN_FLEX_END;
|
||||||
|
|
||||||
export const EDGE_LEFT: 0;
|
type ALIGN_STRETCH = 4 & ['ALIGN']
|
||||||
export const EDGE_TOP: 1;
|
export const ALIGN_STRETCH: ALIGN_STRETCH;
|
||||||
export const EDGE_RIGHT: 2;
|
|
||||||
export const EDGE_BOTTOM: 3;
|
|
||||||
export const EDGE_START: 4;
|
|
||||||
export const EDGE_END: 5;
|
|
||||||
export const EDGE_HORIZONTAL: 6;
|
|
||||||
export const EDGE_VERTICAL: 7;
|
|
||||||
export const EDGE_ALL: 8;
|
|
||||||
|
|
||||||
export const EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS: 0;
|
type ALIGN_BASELINE = 5 & ['ALIGN']
|
||||||
|
export const ALIGN_BASELINE: ALIGN_BASELINE;
|
||||||
|
|
||||||
export const FLEX_DIRECTION_COLUMN: 0;
|
type ALIGN_SPACE_BETWEEN = 6 & ['ALIGN']
|
||||||
export const FLEX_DIRECTION_COLUMN_REVERSE: 1;
|
export const ALIGN_SPACE_BETWEEN: ALIGN_SPACE_BETWEEN;
|
||||||
export const FLEX_DIRECTION_ROW: 2;
|
|
||||||
export const FLEX_DIRECTION_ROW_REVERSE: 3;
|
|
||||||
|
|
||||||
export const GUTTER_COLUMN: 0;
|
type ALIGN_SPACE_AROUND = 7 & ['ALIGN']
|
||||||
export const GUTTER_ROW: 1;
|
export const ALIGN_SPACE_AROUND: ALIGN_SPACE_AROUND;
|
||||||
export const GUTTER_ALL: 2;
|
|
||||||
|
|
||||||
export const JUSTIFY_FLEX_START: 0;
|
|
||||||
export const JUSTIFY_CENTER: 1;
|
|
||||||
export const JUSTIFY_FLEX_END: 2;
|
|
||||||
export const JUSTIFY_SPACE_BETWEEN: 3;
|
|
||||||
export const JUSTIFY_SPACE_AROUND: 4;
|
|
||||||
export const JUSTIFY_SPACE_EVENLY: 5;
|
|
||||||
|
|
||||||
export const LOG_LEVEL_ERROR: 0;
|
type DIMENSION_WIDTH = 0 & ['DIMENSION']
|
||||||
export const LOG_LEVEL_WARN: 1;
|
export const DIMENSION_WIDTH: DIMENSION_WIDTH;
|
||||||
export const LOG_LEVEL_INFO: 2;
|
|
||||||
export const LOG_LEVEL_DEBUG: 3;
|
|
||||||
export const LOG_LEVEL_VERBOSE: 4;
|
|
||||||
export const LOG_LEVEL_FATAL: 5;
|
|
||||||
|
|
||||||
export const MEASURE_MODE_UNDEFINED: 0;
|
type DIMENSION_HEIGHT = 1 & ['DIMENSION']
|
||||||
export const MEASURE_MODE_EXACTLY: 1;
|
export const DIMENSION_HEIGHT: DIMENSION_HEIGHT;
|
||||||
export const MEASURE_MODE_AT_MOST: 2;
|
|
||||||
|
|
||||||
export const NODE_TYPE_DEFAULT: 0;
|
|
||||||
export const NODE_TYPE_TEXT: 1;
|
|
||||||
|
|
||||||
export const OVERFLOW_VISIBLE: 0;
|
type DIRECTION_INHERIT = 0 & ['DIRECTION']
|
||||||
export const OVERFLOW_HIDDEN: 1;
|
export const DIRECTION_INHERIT: DIRECTION_INHERIT;
|
||||||
export const OVERFLOW_SCROLL: 2;
|
|
||||||
|
|
||||||
export const POSITION_TYPE_STATIC: 0;
|
type DIRECTION_LTR = 1 & ['DIRECTION']
|
||||||
export const POSITION_TYPE_RELATIVE: 1;
|
export const DIRECTION_LTR: DIRECTION_LTR;
|
||||||
export const POSITION_TYPE_ABSOLUTE: 2;
|
|
||||||
|
|
||||||
export const PRINT_OPTIONS_LAYOUT: 1;
|
type DIRECTION_RTL = 2 & ['DIRECTION']
|
||||||
export const PRINT_OPTIONS_STYLE: 2;
|
export const DIRECTION_RTL: DIRECTION_RTL;
|
||||||
export const PRINT_OPTIONS_CHILDREN: 4;
|
|
||||||
|
|
||||||
export const UNIT_UNDEFINED: 0;
|
|
||||||
export const UNIT_POINT: 1;
|
|
||||||
export const UNIT_PERCENT: 2;
|
|
||||||
export const UNIT_AUTO: 3;
|
|
||||||
|
|
||||||
export const WRAP_NO_WRAP: 0;
|
type DISPLAY_FLEX = 0 & ['DISPLAY']
|
||||||
export const WRAP_WRAP: 1;
|
export const DISPLAY_FLEX: DISPLAY_FLEX;
|
||||||
export const WRAP_WRAP_REVERSE: 2;
|
|
||||||
|
type DISPLAY_NONE = 1 & ['DISPLAY']
|
||||||
|
export const DISPLAY_NONE: DISPLAY_NONE;
|
||||||
|
|
||||||
|
|
||||||
|
type EDGE_LEFT = 0 & ['EDGE']
|
||||||
|
export const EDGE_LEFT: EDGE_LEFT;
|
||||||
|
|
||||||
|
type EDGE_TOP = 1 & ['EDGE']
|
||||||
|
export const EDGE_TOP: EDGE_TOP;
|
||||||
|
|
||||||
|
type EDGE_RIGHT = 2 & ['EDGE']
|
||||||
|
export const EDGE_RIGHT: EDGE_RIGHT;
|
||||||
|
|
||||||
|
type EDGE_BOTTOM = 3 & ['EDGE']
|
||||||
|
export const EDGE_BOTTOM: EDGE_BOTTOM;
|
||||||
|
|
||||||
|
type EDGE_START = 4 & ['EDGE']
|
||||||
|
export const EDGE_START: EDGE_START;
|
||||||
|
|
||||||
|
type EDGE_END = 5 & ['EDGE']
|
||||||
|
export const EDGE_END: EDGE_END;
|
||||||
|
|
||||||
|
type EDGE_HORIZONTAL = 6 & ['EDGE']
|
||||||
|
export const EDGE_HORIZONTAL: EDGE_HORIZONTAL;
|
||||||
|
|
||||||
|
type EDGE_VERTICAL = 7 & ['EDGE']
|
||||||
|
export const EDGE_VERTICAL: EDGE_VERTICAL;
|
||||||
|
|
||||||
|
type EDGE_ALL = 8 & ['EDGE']
|
||||||
|
export const EDGE_ALL: EDGE_ALL;
|
||||||
|
|
||||||
|
|
||||||
|
type EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS = 0 & ['EXPERIMENTAL_FEATURE']
|
||||||
|
export const EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS: EXPERIMENTAL_FEATURE_WEB_FLEX_BASIS;
|
||||||
|
|
||||||
|
|
||||||
|
type FLEX_DIRECTION_COLUMN = 0 & ['FLEX_DIRECTION']
|
||||||
|
export const FLEX_DIRECTION_COLUMN: FLEX_DIRECTION_COLUMN;
|
||||||
|
|
||||||
|
type FLEX_DIRECTION_COLUMN_REVERSE = 1 & ['FLEX_DIRECTION']
|
||||||
|
export const FLEX_DIRECTION_COLUMN_REVERSE: FLEX_DIRECTION_COLUMN_REVERSE;
|
||||||
|
|
||||||
|
type FLEX_DIRECTION_ROW = 2 & ['FLEX_DIRECTION']
|
||||||
|
export const FLEX_DIRECTION_ROW: FLEX_DIRECTION_ROW;
|
||||||
|
|
||||||
|
type FLEX_DIRECTION_ROW_REVERSE = 3 & ['FLEX_DIRECTION']
|
||||||
|
export const FLEX_DIRECTION_ROW_REVERSE: FLEX_DIRECTION_ROW_REVERSE;
|
||||||
|
|
||||||
|
|
||||||
|
type GUTTER_COLUMN = 0 & ['GUTTER']
|
||||||
|
export const GUTTER_COLUMN: GUTTER_COLUMN;
|
||||||
|
|
||||||
|
type GUTTER_ROW = 1 & ['GUTTER']
|
||||||
|
export const GUTTER_ROW: GUTTER_ROW;
|
||||||
|
|
||||||
|
type GUTTER_ALL = 2 & ['GUTTER']
|
||||||
|
export const GUTTER_ALL: GUTTER_ALL;
|
||||||
|
|
||||||
|
|
||||||
|
type JUSTIFY_FLEX_START = 0 & ['JUSTIFY']
|
||||||
|
export const JUSTIFY_FLEX_START: JUSTIFY_FLEX_START;
|
||||||
|
|
||||||
|
type JUSTIFY_CENTER = 1 & ['JUSTIFY']
|
||||||
|
export const JUSTIFY_CENTER: JUSTIFY_CENTER;
|
||||||
|
|
||||||
|
type JUSTIFY_FLEX_END = 2 & ['JUSTIFY']
|
||||||
|
export const JUSTIFY_FLEX_END: JUSTIFY_FLEX_END;
|
||||||
|
|
||||||
|
type JUSTIFY_SPACE_BETWEEN = 3 & ['JUSTIFY']
|
||||||
|
export const JUSTIFY_SPACE_BETWEEN: JUSTIFY_SPACE_BETWEEN;
|
||||||
|
|
||||||
|
type JUSTIFY_SPACE_AROUND = 4 & ['JUSTIFY']
|
||||||
|
export const JUSTIFY_SPACE_AROUND: JUSTIFY_SPACE_AROUND;
|
||||||
|
|
||||||
|
type JUSTIFY_SPACE_EVENLY = 5 & ['JUSTIFY']
|
||||||
|
export const JUSTIFY_SPACE_EVENLY: JUSTIFY_SPACE_EVENLY;
|
||||||
|
|
||||||
|
|
||||||
|
type LOG_LEVEL_ERROR = 0 & ['LOG_LEVEL']
|
||||||
|
export const LOG_LEVEL_ERROR: LOG_LEVEL_ERROR;
|
||||||
|
|
||||||
|
type LOG_LEVEL_WARN = 1 & ['LOG_LEVEL']
|
||||||
|
export const LOG_LEVEL_WARN: LOG_LEVEL_WARN;
|
||||||
|
|
||||||
|
type LOG_LEVEL_INFO = 2 & ['LOG_LEVEL']
|
||||||
|
export const LOG_LEVEL_INFO: LOG_LEVEL_INFO;
|
||||||
|
|
||||||
|
type LOG_LEVEL_DEBUG = 3 & ['LOG_LEVEL']
|
||||||
|
export const LOG_LEVEL_DEBUG: LOG_LEVEL_DEBUG;
|
||||||
|
|
||||||
|
type LOG_LEVEL_VERBOSE = 4 & ['LOG_LEVEL']
|
||||||
|
export const LOG_LEVEL_VERBOSE: LOG_LEVEL_VERBOSE;
|
||||||
|
|
||||||
|
type LOG_LEVEL_FATAL = 5 & ['LOG_LEVEL']
|
||||||
|
export const LOG_LEVEL_FATAL: LOG_LEVEL_FATAL;
|
||||||
|
|
||||||
|
|
||||||
|
type MEASURE_MODE_UNDEFINED = 0 & ['MEASURE_MODE']
|
||||||
|
export const MEASURE_MODE_UNDEFINED: MEASURE_MODE_UNDEFINED;
|
||||||
|
|
||||||
|
type MEASURE_MODE_EXACTLY = 1 & ['MEASURE_MODE']
|
||||||
|
export const MEASURE_MODE_EXACTLY: MEASURE_MODE_EXACTLY;
|
||||||
|
|
||||||
|
type MEASURE_MODE_AT_MOST = 2 & ['MEASURE_MODE']
|
||||||
|
export const MEASURE_MODE_AT_MOST: MEASURE_MODE_AT_MOST;
|
||||||
|
|
||||||
|
|
||||||
|
type NODE_TYPE_DEFAULT = 0 & ['NODE_TYPE']
|
||||||
|
export const NODE_TYPE_DEFAULT: NODE_TYPE_DEFAULT;
|
||||||
|
|
||||||
|
type NODE_TYPE_TEXT = 1 & ['NODE_TYPE']
|
||||||
|
export const NODE_TYPE_TEXT: NODE_TYPE_TEXT;
|
||||||
|
|
||||||
|
|
||||||
|
type OVERFLOW_VISIBLE = 0 & ['OVERFLOW']
|
||||||
|
export const OVERFLOW_VISIBLE: OVERFLOW_VISIBLE;
|
||||||
|
|
||||||
|
type OVERFLOW_HIDDEN = 1 & ['OVERFLOW']
|
||||||
|
export const OVERFLOW_HIDDEN: OVERFLOW_HIDDEN;
|
||||||
|
|
||||||
|
type OVERFLOW_SCROLL = 2 & ['OVERFLOW']
|
||||||
|
export const OVERFLOW_SCROLL: OVERFLOW_SCROLL;
|
||||||
|
|
||||||
|
|
||||||
|
type POSITION_TYPE_STATIC = 0 & ['POSITION_TYPE']
|
||||||
|
export const POSITION_TYPE_STATIC: POSITION_TYPE_STATIC;
|
||||||
|
|
||||||
|
type POSITION_TYPE_RELATIVE = 1 & ['POSITION_TYPE']
|
||||||
|
export const POSITION_TYPE_RELATIVE: POSITION_TYPE_RELATIVE;
|
||||||
|
|
||||||
|
type POSITION_TYPE_ABSOLUTE = 2 & ['POSITION_TYPE']
|
||||||
|
export const POSITION_TYPE_ABSOLUTE: POSITION_TYPE_ABSOLUTE;
|
||||||
|
|
||||||
|
|
||||||
|
type PRINT_OPTIONS_LAYOUT = 1 & ['PRINT_OPTIONS']
|
||||||
|
export const PRINT_OPTIONS_LAYOUT: PRINT_OPTIONS_LAYOUT;
|
||||||
|
|
||||||
|
type PRINT_OPTIONS_STYLE = 2 & ['PRINT_OPTIONS']
|
||||||
|
export const PRINT_OPTIONS_STYLE: PRINT_OPTIONS_STYLE;
|
||||||
|
|
||||||
|
type PRINT_OPTIONS_CHILDREN = 4 & ['PRINT_OPTIONS']
|
||||||
|
export const PRINT_OPTIONS_CHILDREN: PRINT_OPTIONS_CHILDREN;
|
||||||
|
|
||||||
|
|
||||||
|
type UNIT_UNDEFINED = 0 & ['UNIT']
|
||||||
|
export const UNIT_UNDEFINED: UNIT_UNDEFINED;
|
||||||
|
|
||||||
|
type UNIT_POINT = 1 & ['UNIT']
|
||||||
|
export const UNIT_POINT: UNIT_POINT;
|
||||||
|
|
||||||
|
type UNIT_PERCENT = 2 & ['UNIT']
|
||||||
|
export const UNIT_PERCENT: UNIT_PERCENT;
|
||||||
|
|
||||||
|
type UNIT_AUTO = 3 & ['UNIT']
|
||||||
|
export const UNIT_AUTO: UNIT_AUTO;
|
||||||
|
|
||||||
|
|
||||||
|
type WRAP_NO_WRAP = 0 & ['WRAP']
|
||||||
|
export const WRAP_NO_WRAP: WRAP_NO_WRAP;
|
||||||
|
|
||||||
|
type WRAP_WRAP = 1 & ['WRAP']
|
||||||
|
export const WRAP_WRAP: WRAP_WRAP;
|
||||||
|
|
||||||
|
type WRAP_WRAP_REVERSE = 2 & ['WRAP']
|
||||||
|
export const WRAP_WRAP_REVERSE: WRAP_WRAP_REVERSE;
|
||||||
|
|
||||||
|
|
||||||
export type Align =
|
export type Align =
|
||||||
| typeof ALIGN_AUTO
|
| typeof ALIGN_AUTO
|
||||||
|
Reference in New Issue
Block a user