Cleanup entrypoints
This commit is contained in:
4
enums.py
4
enums.py
@@ -222,7 +222,7 @@ for name, values in sorted(ENUMS.items()):
|
|||||||
f.write("}\n")
|
f.write("}\n")
|
||||||
|
|
||||||
# write out javascript file
|
# write out javascript file
|
||||||
with open(root + "/javascript/sources/YGEnums.js", "w") as f:
|
with open(root + "/javascript/src_js/generated/YGEnums.js", "w") as f:
|
||||||
f.write(get_license("js"))
|
f.write(get_license("js"))
|
||||||
f.write("module.exports = {\n")
|
f.write("module.exports = {\n")
|
||||||
items = sorted(ENUMS.items())
|
items = sorted(ENUMS.items())
|
||||||
@@ -243,7 +243,7 @@ with open(root + "/javascript/sources/YGEnums.js", "w") as f:
|
|||||||
f.write("\n")
|
f.write("\n")
|
||||||
f.write("};\n")
|
f.write("};\n")
|
||||||
|
|
||||||
with open(root + "/javascript/sources/YGEnums.d.ts", "w") as f:
|
with open(root + "/javascript/src_js/generated/YGEnums.d.ts", "w") as f:
|
||||||
f.write(get_license("js"))
|
f.write(get_license("js"))
|
||||||
|
|
||||||
for name, values in sorted(ENUMS.items()):
|
for name, values in sorted(ENUMS.items()):
|
||||||
|
@@ -10,7 +10,7 @@ project(yoga)
|
|||||||
file(GLOB SOURCES
|
file(GLOB SOURCES
|
||||||
../yoga/*.cpp
|
../yoga/*.cpp
|
||||||
../yoga/**/*.cpp
|
../yoga/**/*.cpp
|
||||||
sources/*.cc)
|
src_native/*.cc)
|
||||||
|
|
||||||
include_directories(..)
|
include_directories(..)
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ link_libraries(embind)
|
|||||||
|
|
||||||
add_library(yogaObjLib OBJECT ${SOURCES})
|
add_library(yogaObjLib OBJECT ${SOURCES})
|
||||||
|
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dist)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/dist/build)
|
||||||
|
|
||||||
add_executable(asmjs-sync $<TARGET_OBJECTS:yogaObjLib>)
|
add_executable(asmjs-sync $<TARGET_OBJECTS:yogaObjLib>)
|
||||||
target_link_options(asmjs-sync PUBLIC
|
target_link_options(asmjs-sync PUBLIC
|
||||||
|
@@ -9,12 +9,12 @@
|
|||||||
|
|
||||||
module.exports = async () => {
|
module.exports = async () => {
|
||||||
if (process.env['SYNC'] == true && process.env['WASM'] == true) {
|
if (process.env['SYNC'] == true && process.env['WASM'] == true) {
|
||||||
global.Yoga = require("./dist/sync.wasm");
|
global.Yoga = require("./dist/variants/wasm-sync");
|
||||||
} else if (process.env['SYNC'] == true) {
|
} else if (process.env['SYNC'] == true) {
|
||||||
global.Yoga = require("./dist/sync.asmjs");
|
global.Yoga = require("./dist/variants/asmjs-sync");
|
||||||
} else if (process.env['WASM'] == true) {
|
} else if (process.env['WASM'] == true) {
|
||||||
global.Yoga = await require("./dist/index.wasm").loadYoga();
|
global.Yoga = await require("./dist/variants/wasm-async").loadYoga();
|
||||||
} else {
|
} else {
|
||||||
global.Yoga = await require("./dist/index.asmjs").loadYoga();
|
global.Yoga = await require("./dist/variants/asmjs-async").loadYoga();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -7,35 +7,37 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git@github.com:facebook/yoga.git"
|
"url": "git@github.com:facebook/yoga.git"
|
||||||
},
|
},
|
||||||
|
"main": "./dist/index.js",
|
||||||
|
"types": "./dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
".": {
|
".": {
|
||||||
"browser": "./dist/index.wasm.js",
|
"browser": "./dist/variants/wasm-async.js",
|
||||||
"node": "./dist/index.wasm.js",
|
"node": "./dist/variants/wasm-async.js",
|
||||||
"react-native": "./dist/index.asmjs.js",
|
"default": "./dist/variants/asmjs-async.js"
|
||||||
"default": "./dist/index.asmjs.js"
|
|
||||||
},
|
},
|
||||||
"./sync": {
|
"./sync": {
|
||||||
"browser": "./dist/sync.asmks.js",
|
"browser": "./dist/variants/asmjs-sync.js",
|
||||||
"node": "./dist/sync.wasm.js",
|
"node": "./dist/variants/wasm-sync.js",
|
||||||
"react-native": "./dist/sync.asmjs.js",
|
"default": "./dist/variants/asmjs-sync.js"
|
||||||
"default": "./dist/sync.asmjs.js"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"dist/**",
|
"dist/**",
|
||||||
"sources/**"
|
"src_js/**"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"benchmark": "node tests/run-bench $(find tests/Benchmarks -name '*.js')",
|
||||||
"build": "yarn build:native && yarn build:js",
|
"build": "yarn build:native && yarn build:js",
|
||||||
"build:native": "yarn build:native-project && cmake --build build",
|
"build:configure": "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:copy-dts": "cd src_js && find . -name '*.d.ts' | cpio -pdm ../dist",
|
||||||
"build:js": "babel sources --source-maps --out-dir dist && cp -r sources/*.d.ts dist",
|
"build:js": "babel src_js --source-maps --out-dir dist && yarn build:copy-dts",
|
||||||
|
"build:native": "yarn build:configure && cmake --build build",
|
||||||
|
"postinstall": "yarn build",
|
||||||
"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": "WASM=0 SYNC=0 jest",
|
"test:asmjs": "WASM=0 SYNC=0 jest",
|
||||||
"test:asmjs-sync": "WASM=0 SYNC=1 jest",
|
"test:asmjs-sync": "WASM=0 SYNC=1 jest",
|
||||||
"test:wasm": "WASM=1 SYNC=0 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')"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/cli": "^7.20.7",
|
"@babel/cli": "^7.20.7",
|
||||||
|
@@ -1,16 +0,0 @@
|
|||||||
/**
|
|
||||||
* 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
|
|
||||||
*/
|
|
||||||
|
|
||||||
const wrapAsm = require('./wrapAsm');
|
|
||||||
const loadAsm = require('./asmjs-async');
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
loadYoga: () => loadAsm().then(wrapAsm),
|
|
||||||
...require('./YGEnums'),
|
|
||||||
}
|
|
@@ -8,9 +8,8 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const wrapAsm = require('./wrapAsm');
|
const wrapAsm = require('./wrapAsm');
|
||||||
const loadAsm = require('./wasm-async');
|
|
||||||
|
|
||||||
module.exports = {
|
module.exports = (loadAsm) => ({
|
||||||
loadYoga: () => loadAsm().then(wrapAsm),
|
loadYoga: () => loadAsm().then(wrapAsm),
|
||||||
...require('./YGEnums'),
|
...require('./generated/YGEnums'),
|
||||||
}
|
});
|
@@ -8,6 +8,4 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const wrapAsm = require('./wrapAsm');
|
const wrapAsm = require('./wrapAsm');
|
||||||
const loadAsm = require('./wasm-sync');
|
module.exports = (asm) => wrapAsm(asm());
|
||||||
|
|
||||||
module.exports = wrapAsm(loadAsm());
|
|
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
import type {Yoga} from './wrapAsm';
|
import type {Yoga} from './wrapAsm';
|
||||||
|
|
||||||
export * from './YGEnums';
|
export * from './generated/YGEnums';
|
||||||
export * from './wrapAsm';
|
export * from './wrapAsm';
|
||||||
|
|
||||||
export function loadYoga(): Promise<Yoga>;
|
export function loadYoga(): Promise<Yoga>;
|
@@ -7,7 +7,5 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const wrapAsm = require('./wrapAsm');
|
// Fallback for when the export map is not followed
|
||||||
const loadAsm = require('./asmjs-sync');
|
module.exports = require('./variants/asmjs-async');
|
||||||
|
|
||||||
module.exports = wrapAsm(loadAsm());
|
|
16
javascript/src_js/sync.d.ts
vendored
Normal file
16
javascript/src_js/sync.d.ts
vendored
Normal 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
import type {Yoga} from './wrapAsm';
|
||||||
|
|
||||||
|
export * from './generated/YGEnums';
|
||||||
|
export * from './wrapAsm';
|
||||||
|
|
||||||
|
declare const yoga: Yoga;
|
||||||
|
export default yoga;
|
@@ -7,10 +7,5 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type {Yoga} from './wrapAsm';
|
// Fallback for when the export map is not followed
|
||||||
|
module.exports = require('./variants/asmjs-sync');
|
||||||
export * from './YGEnums';
|
|
||||||
export * from './wrapAsm';
|
|
||||||
|
|
||||||
declare const yoga: Yoga;
|
|
||||||
export default yoga;
|
|
11
javascript/src_js/variants/asmjs-async.js
Normal file
11
javascript/src_js/variants/asmjs-async.js
Normal 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
const asm = require('../build/asmjs-async');
|
||||||
|
module.exports = require("../entryAsync")(asm);
|
11
javascript/src_js/variants/asmjs-sync.js
Normal file
11
javascript/src_js/variants/asmjs-sync.js
Normal 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
const asm = require('../build/asmjs-sync');
|
||||||
|
module.exports = require("../entrySync")(asm);
|
11
javascript/src_js/variants/wasm-async.js
Normal file
11
javascript/src_js/variants/wasm-async.js
Normal 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
const asm = require('../build/wasm-async');
|
||||||
|
module.exports = require("../entryAsync")(asm);
|
11
javascript/src_js/variants/wasm-sync.js
Normal file
11
javascript/src_js/variants/wasm-sync.js
Normal 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
const asm = require('../build/wasm-sync');
|
||||||
|
module.exports = require("../entrySync")(asm);
|
@@ -19,9 +19,9 @@
|
|||||||
Justify,
|
Justify,
|
||||||
Display,
|
Display,
|
||||||
ExperimentalFeature,
|
ExperimentalFeature,
|
||||||
} from './YGEnums';
|
} from './generated/YGEnums';
|
||||||
|
|
||||||
import type * as YGEnums from './YGEnums';
|
import type * as YGEnums from './generated/YGEnums';
|
||||||
|
|
||||||
type Layout = {
|
type Layout = {
|
||||||
left: number;
|
left: number;
|
@@ -7,7 +7,7 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const CONSTANTS = require('./YGEnums');
|
const CONSTANTS = require('./generated/YGEnums');
|
||||||
|
|
||||||
module.exports = (lib) => {
|
module.exports = (lib) => {
|
||||||
function patch(prototype, name, fn) {
|
function patch(prototype, name, fn) {
|
@@ -27,7 +27,7 @@ for (let type of ['asmjs', 'wasm']) {
|
|||||||
vm.runInNewContext(
|
vm.runInNewContext(
|
||||||
file,
|
file,
|
||||||
Object.assign(Object.create(global), {
|
Object.assign(Object.create(global), {
|
||||||
Yoga: require(type === 'asmjs' ? '../dist/sync.asmjs' : '../dist/sync.wasm'),
|
Yoga: require(type === 'asmjs' ? '../dist/variants/asmjs-sync' : '../dist/variants/wasm-sync'),
|
||||||
YGBENCHMARK: function(name, fn) {
|
YGBENCHMARK: function(name, fn) {
|
||||||
let testEntry = testResults.get(name);
|
let testEntry = testResults.get(name);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user