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")
|
||||
|
||||
# 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("module.exports = {\n")
|
||||
items = sorted(ENUMS.items())
|
||||
@@ -243,7 +243,7 @@ with open(root + "/javascript/sources/YGEnums.js", "w") as f:
|
||||
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"))
|
||||
|
||||
for name, values in sorted(ENUMS.items()):
|
||||
|
@@ -10,7 +10,7 @@ project(yoga)
|
||||
file(GLOB SOURCES
|
||||
../yoga/*.cpp
|
||||
../yoga/**/*.cpp
|
||||
sources/*.cc)
|
||||
src_native/*.cc)
|
||||
|
||||
include_directories(..)
|
||||
|
||||
@@ -49,7 +49,7 @@ link_libraries(embind)
|
||||
|
||||
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>)
|
||||
target_link_options(asmjs-sync PUBLIC
|
||||
|
@@ -9,12 +9,12 @@
|
||||
|
||||
module.exports = async () => {
|
||||
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) {
|
||||
global.Yoga = require("./dist/sync.asmjs");
|
||||
global.Yoga = require("./dist/variants/asmjs-sync");
|
||||
} else if (process.env['WASM'] == true) {
|
||||
global.Yoga = await require("./dist/index.wasm").loadYoga();
|
||||
global.Yoga = await require("./dist/variants/wasm-async").loadYoga();
|
||||
} else {
|
||||
global.Yoga = await require("./dist/index.asmjs").loadYoga();
|
||||
global.Yoga = await require("./dist/variants/asmjs-async").loadYoga();
|
||||
}
|
||||
}
|
||||
|
@@ -7,35 +7,37 @@
|
||||
"type": "git",
|
||||
"url": "git@github.com:facebook/yoga.git"
|
||||
},
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"browser": "./dist/index.wasm.js",
|
||||
"node": "./dist/index.wasm.js",
|
||||
"react-native": "./dist/index.asmjs.js",
|
||||
"default": "./dist/index.asmjs.js"
|
||||
"browser": "./dist/variants/wasm-async.js",
|
||||
"node": "./dist/variants/wasm-async.js",
|
||||
"default": "./dist/variants/asmjs-async.js"
|
||||
},
|
||||
"./sync": {
|
||||
"browser": "./dist/sync.asmks.js",
|
||||
"node": "./dist/sync.wasm.js",
|
||||
"react-native": "./dist/sync.asmjs.js",
|
||||
"default": "./dist/sync.asmjs.js"
|
||||
"browser": "./dist/variants/asmjs-sync.js",
|
||||
"node": "./dist/variants/wasm-sync.js",
|
||||
"default": "./dist/variants/asmjs-sync.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist/**",
|
||||
"sources/**"
|
||||
"src_js/**"
|
||||
],
|
||||
"scripts": {
|
||||
"benchmark": "node tests/run-bench $(find tests/Benchmarks -name '*.js')",
|
||||
"build": "yarn build:native && yarn build:js",
|
||||
"build:native": "yarn build:native-project && cmake --build 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:configure": "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 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:asmjs": "WASM=0 SYNC=0 jest",
|
||||
"test:asmjs-sync": "WASM=0 SYNC=1 jest",
|
||||
"test:wasm": "WASM=1 SYNC=0 jest",
|
||||
"test:wasm-sync": "WASM=1 SYNC=1 jest",
|
||||
"benchmark": "node tests/run-bench $(find tests/Benchmarks -name '*.js')"
|
||||
"test:wasm-sync": "WASM=1 SYNC=1 jest"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@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 loadAsm = require('./wasm-async');
|
||||
|
||||
module.exports = {
|
||||
module.exports = (loadAsm) => ({
|
||||
loadYoga: () => loadAsm().then(wrapAsm),
|
||||
...require('./YGEnums'),
|
||||
}
|
||||
...require('./generated/YGEnums'),
|
||||
});
|
@@ -7,7 +7,5 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
const wrapAsm = require('./wrapAsm');
|
||||
const loadAsm = require('./wasm-sync');
|
||||
|
||||
module.exports = wrapAsm(loadAsm());
|
||||
const wrapAsm = require('./wrapAsm');
|
||||
module.exports = (asm) => wrapAsm(asm());
|
@@ -9,7 +9,7 @@
|
||||
|
||||
import type {Yoga} from './wrapAsm';
|
||||
|
||||
export * from './YGEnums';
|
||||
export * from './generated/YGEnums';
|
||||
export * from './wrapAsm';
|
||||
|
||||
export function loadYoga(): Promise<Yoga>;
|
@@ -7,7 +7,5 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
const wrapAsm = require('./wrapAsm');
|
||||
const loadAsm = require('./asmjs-sync');
|
||||
|
||||
module.exports = wrapAsm(loadAsm());
|
||||
// Fallback for when the export map is not followed
|
||||
module.exports = require('./variants/asmjs-async');
|
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
|
||||
*/
|
||||
|
||||
import type {Yoga} from './wrapAsm';
|
||||
|
||||
export * from './YGEnums';
|
||||
export * from './wrapAsm';
|
||||
|
||||
declare const yoga: Yoga;
|
||||
export default yoga;
|
||||
// Fallback for when the export map is not followed
|
||||
module.exports = require('./variants/asmjs-sync');
|
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);
|
@@ -7,7 +7,7 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import type {
|
||||
import type {
|
||||
Edge,
|
||||
Wrap,
|
||||
Align,
|
||||
@@ -19,9 +19,9 @@
|
||||
Justify,
|
||||
Display,
|
||||
ExperimentalFeature,
|
||||
} from './YGEnums';
|
||||
} from './generated/YGEnums';
|
||||
|
||||
import type * as YGEnums from './YGEnums';
|
||||
import type * as YGEnums from './generated/YGEnums';
|
||||
|
||||
type Layout = {
|
||||
left: number;
|
@@ -7,7 +7,7 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
const CONSTANTS = require('./YGEnums');
|
||||
const CONSTANTS = require('./generated/YGEnums');
|
||||
|
||||
module.exports = (lib) => {
|
||||
function patch(prototype, name, fn) {
|
@@ -27,7 +27,7 @@ for (let type of ['asmjs', 'wasm']) {
|
||||
vm.runInNewContext(
|
||||
file,
|
||||
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) {
|
||||
let testEntry = testResults.get(name);
|
||||
|
||||
|
Reference in New Issue
Block a user