Compare commits

...

14 Commits

Author SHA1 Message Date
Nick Gerleman
3a96c7717d Bump to 2.0.1 2023-10-31 21:49:09 -07:00
Nick Gerleman
c01dcd2338 Fix yoga-layout/wasm-sync exporting async binary if browser/node export conditions not met
When node or browser export conditions are not met, we resolve `yoga-layout/wasm-sync` to the async binary because of a typo.
2023-10-31 21:48:56 -07:00
Nick Gerleman
83a58bb9d6 Fixup packages 2023-07-26 22:28:21 -07:00
Nick Gerleman
30b697d3fe ./set-version.py 2.0.0 2023-07-25 09:47:27 -07:00
Nick Gerleman
11721f487d ./set-version.py 2.0.0-beta.2 2023-07-12 18:07:57 -07:00
Nick Gerleman
6570e43a83 Add blurb about configuring TypeScript for ESM resolution (#1330)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1330

This has been tripping folks up a bit. Add a blurb to the package README to call it out.

Reviewed By: cortinico

Differential Revision: D47370333

fbshipit-source-id: f07b2e4d0e23865e3554c7aaf6ec77dff71a7423
2023-07-12 18:04:47 -07:00
Nick Gerleman
6628873c2a Separate Node and Web Binaries (#1325)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1325

Fixes https://github.com/facebook/yoga/issues/1321

Reviewed By: cortinico

Differential Revision: D47368830

fbshipit-source-id: 570a45ad7fd182ef82e6edda4037ae2f6faa0c75
2023-07-12 18:04:17 -07:00
Nicola Corti
edf91b245d Actually hit Maven Central when publishing tags
Summary:
Due to a copypasta error, the tags will keep on publishing to the snapshot repo.
I've updated the config to actually hit Maven Central.

Reviewed By: NickGerleman

Differential Revision: D47150549

fbshipit-source-id: 314b931c1c9203ef53e1433a88bcc00609abd3d0
2023-06-30 13:37:51 -07:00
Nick Gerleman
a4c339264a [local] Workflow syntax fix 2023-06-29 13:18:49 -07:00
Nick Gerleman
9a50bd7d61 [local] Change how we pass npm auth token 2023-06-29 13:04:08 -07:00
Nick Gerleman
1b3ddbbf4a [local] publish YogaKit with --synchronous 2023-06-29 11:54:59 -07:00
Nick Gerleman
24d2782ad3 [local] Fix workflow syntax for npm 2023-06-29 11:38:07 -07:00
Nick Gerleman
f216c84175 [local] Fix workflow syntax 2023-06-29 11:34:23 -07:00
Nick Gerleman
b5d105132e [local] Set version to 2.0.0-beta.1 2023-06-29 11:22:56 -07:00
18 changed files with 211 additions and 62 deletions

View File

@@ -3,7 +3,7 @@ name: Publish Android Release
on:
push:
tags:
- *
- '*'
workflow_dispatch:
jobs:
@@ -20,7 +20,6 @@ jobs:
- name: Publish to Maven Local
run: ./gradlew publishToMavenLocal
env:
ORG_GRADLE_PROJECT_USE_SNAPSHOT: true
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }}
ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }}
@@ -30,11 +29,10 @@ jobs:
name: 'snapshot-artifacts'
path: '~/.m2/repository/'
- name: Publish to the Snapshot Repository
run: ./gradlew publishToSonatype
- name: Publish to the Maven Central
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
env:
ORG_GRADLE_PROJECT_SONATYPE_USERNAME: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_USERNAME }}
ORG_GRADLE_PROJECT_SONATYPE_PASSWORD: ${{ secrets.ORG_GRADLE_PROJECT_SONATYPE_PASSWORD }}
ORG_GRADLE_PROJECT_SIGNING_KEY: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_KEY }}
ORG_GRADLE_PROJECT_SIGNING_PWD: ${{ secrets.ORG_GRADLE_PROJECT_SIGNING_PWD }}
ORG_GRADLE_PROJECT_USE_SNAPSHOT: true

View File

@@ -3,7 +3,7 @@ name: Publish CocoaPods Release
on:
push:
tags:
- *
- '*'
workflow_dispatch:
jobs:
@@ -23,6 +23,7 @@ jobs:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
- name: Publish YogaKit
run: pod trunk push YogaKit.podspec
# Must run with --synchronous since YogaKit may depend on the just published version of Yoga
run: pod trunk push YogaKit.podspec --synchronous
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}

View File

@@ -3,7 +3,7 @@ name: Publish NPM Release
on:
push:
tags:
- *
- '*'
workflow_dispatch:
jobs:
@@ -17,8 +17,9 @@ jobs:
- name: Setup
uses: ./.github/actions/setup-js
- name: Store auth token in config file
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
- name: yarn publish
run: yarn publish
working-directory: javascript
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

View File

@@ -6,7 +6,7 @@
Pod::Spec.new do |spec|
spec.name = 'Yoga'
spec.version = '2.0.0'
spec.version = '2.0.1'
spec.license = { :type => 'MIT', :file => "LICENSE" }
spec.homepage = 'https://yogalayout.com/'
spec.documentation_url = 'https://yogalayout.com/docs'

View File

@@ -5,7 +5,7 @@
podspec = Pod::Spec.new do |spec|
spec.name = 'YogaKit'
spec.version = '2.0.0'
spec.version = '2.0.1'
spec.license = { :type => 'MIT', :file => "LICENSE" }
spec.homepage = 'https://yogalayout.com/'
spec.documentation_url = 'https://yogalayout.com/docs'

View File

@@ -11,4 +11,4 @@ android.useAndroidX=true
org.gradle.jvmargs=-Xmx1536M
VERSION_NAME=2.0.0
VERSION_NAME=2.0.1

View File

@@ -37,13 +37,13 @@ add_link_options(
"SHELL:-s ALLOW_MEMORY_GROWTH=1"
"SHELL:-s ASSERTIONS=0"
"SHELL:-s DYNAMIC_EXECUTION=0"
"SHELL:-s ENVIRONMENT='web,node'"
"SHELL:-s EXPORT_NAME='loadYoga'"
"SHELL:-s FETCH_SUPPORT_INDEXEDDB=0"
"SHELL:-s FILESYSTEM=0"
"SHELL:-s MALLOC='emmalloc'"
"SHELL:-s MODULARIZE=1"
"SHELL:-s TEXTDECODER=0")
"SHELL:-s TEXTDECODER=0"
"SHELL:-s SINGLE_FILE=1")
link_libraries(embind)
@@ -51,24 +51,62 @@ add_library(yogaObjLib OBJECT ${SOURCES})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/binaries)
add_executable(asmjs-sync-node $<TARGET_OBJECTS:yogaObjLib>)
target_link_options(asmjs-sync-node PUBLIC
"SHELL:-s ENVIRONMENT='node'"
"SHELL:-s WASM=0"
"SHELL:-s WASM_ASYNC_COMPILATION=0")
add_executable(asmjs-async-node $<TARGET_OBJECTS:yogaObjLib>)
target_link_options(asmjs-async-node PUBLIC
"SHELL:-s ENVIRONMENT='node'"
"SHELL:-s WASM=0"
"SHELL:-s WASM_ASYNC_COMPILATION=1")
add_executable(asmjs-sync-web $<TARGET_OBJECTS:yogaObjLib>)
target_link_options(asmjs-sync-web PUBLIC
"SHELL:-s ENVIRONMENT='web'"
"SHELL:-s WASM=0"
"SHELL:-s WASM_ASYNC_COMPILATION=0")
add_executable(asmjs-async-web $<TARGET_OBJECTS:yogaObjLib>)
target_link_options(asmjs-async-web PUBLIC
"SHELL:-s ENVIRONMENT='web'"
"SHELL:-s WASM=0"
"SHELL:-s WASM_ASYNC_COMPILATION=1")
add_executable(asmjs-sync $<TARGET_OBJECTS:yogaObjLib>)
target_link_options(asmjs-sync PUBLIC
"SHELL:-s ENVIRONMENT='web,node'"
"SHELL:-s WASM=0"
"SHELL:-s WASM_ASYNC_COMPILATION=0")
add_executable(asmjs-async $<TARGET_OBJECTS:yogaObjLib>)
target_link_options(asmjs-async PUBLIC
"SHELL:-s ENVIRONMENT='web,node'"
"SHELL:-s WASM=0"
"SHELL:-s WASM_ASYNC_COMPILATION=1")
add_executable(wasm-sync $<TARGET_OBJECTS:yogaObjLib>)
target_link_options(wasm-sync PUBLIC
add_executable(wasm-sync-node $<TARGET_OBJECTS:yogaObjLib>)
target_link_options(wasm-sync-node PUBLIC
"SHELL:-s ENVIRONMENT='node'"
"SHELL:-s WASM=1"
"SHELL:-s SINGLE_FILE=1"
"SHELL:-s WASM_ASYNC_COMPILATION=0")
add_executable(wasm-async $<TARGET_OBJECTS:yogaObjLib>)
target_link_options(wasm-async PUBLIC
add_executable(wasm-async-node $<TARGET_OBJECTS:yogaObjLib>)
target_link_options(wasm-async-node PUBLIC
"SHELL:-s ENVIRONMENT='node'"
"SHELL:-s WASM=1"
"SHELL:-s WASM_ASYNC_COMPILATION=1")
add_executable(wasm-sync-web $<TARGET_OBJECTS:yogaObjLib>)
target_link_options(wasm-sync-web PUBLIC
"SHELL:-s ENVIRONMENT='web'"
"SHELL:-s WASM=1"
"SHELL:-s WASM_ASYNC_COMPILATION=0")
add_executable(wasm-async-web $<TARGET_OBJECTS:yogaObjLib>)
target_link_options(wasm-async-web PUBLIC
"SHELL:-s ENVIRONMENT='web'"
"SHELL:-s WASM=1"
"SHELL:-s SINGLE_FILE=1"
"SHELL:-s WASM_ASYNC_COMPILATION=1")

View File

@@ -41,12 +41,15 @@ node.free();
For better performance and smaller packages, WebAssembly is preferred to asm.js where available. `yoga-layout` tries to provide the right default using [export maps](https://webpack.js.org/guides/package-exports/#conditional-syntax) so that platforms which can take advantage of WebAssembly use it by default.
A specific entrypoint may be specified on platforms which do not understand export conditions.
Different entrypoints are exposed to choose a flavor explicitly.
```ts
import {loadYoga} from 'yoga-layout/wasm-async';
```
## Using TypeScript
This package provides out-of-the-box TypeScript typings so long as `tsc` is configured to support ESM resolution. It is recommended to set `moduleResolution: 'bundler'` or `moduleResolution: node16` in your `tsconfig.json` according to your environment.
## Contributing

View File

@@ -45,37 +45,35 @@ function defineFlavor(flavor: string, env: NodeJS.ProcessEnv) {
);
}
defineFlavor('asmjs-async', {WASM: '0', SYNC: '0'});
defineFlavor('asmjs-sync', {WASM: '0', SYNC: '1'});
defineFlavor('wasm-async', {WASM: '1', SYNC: '0'});
defineFlavor('wasm-sync', {WASM: '1', SYNC: '1'});
defineFlavor('asmjs-async-node', {WASM: '0', SYNC: '0'});
defineFlavor('asmjs-sync-node', {WASM: '0', SYNC: '1'});
defineFlavor('asmjs-async-web', {WASM: '0', SYNC: '0'});
defineFlavor('asmjs-sync-web', {WASM: '0', SYNC: '1'});
defineFlavor('wasm-async-node', {WASM: '1', SYNC: '0'});
defineFlavor('wasm-sync-node', {WASM: '1', SYNC: '1'});
defineFlavor('wasm-async-web', {WASM: '1', SYNC: '0'});
defineFlavor('wasm-sync-web', {WASM: '1', SYNC: '1'});
task('cmake-build:all', cmakeBuildTask());
task(
'cmake-build:async',
cmakeBuildTask({targets: ['asmjs-async', 'wasm-async']}),
);
task(
'cmake-build:sync',
cmakeBuildTask({targets: ['asmjs-sync', 'wasm-sync']}),
);
task('build', series(emcmakeGenerateTask(), 'cmake-build:all'));
task('build', series(emcmakeGenerateTask(), cmakeBuildTask()));
task(
'test',
series(
emcmakeGenerateTask(),
series('cmake-build:asmjs-async', 'jest:asmjs-async'),
series('cmake-build:asmjs-sync', 'jest:asmjs-sync'),
series('cmake-build:wasm-async', 'jest:wasm-async'),
series('cmake-build:wasm-sync', 'jest:wasm-sync'),
series('cmake-build:asmjs-async-node', 'jest:asmjs-async-node'),
series('cmake-build:asmjs-sync-node', 'jest:asmjs-sync-node'),
series('cmake-build:wasm-async-node', 'jest:wasm-async-node'),
series('cmake-build:wasm-sync-node', 'jest:wasm-sync-node'),
),
);
task(
'benchmark',
series(emcmakeGenerateTask(), 'cmake-build:sync', runBenchTask()),
series(
emcmakeGenerateTask(),
cmakeBuildTask({targets: ['asmjs-sync-node', 'wasm-sync-node']}),
runBenchTask(),
),
);
task(

View File

@@ -1,6 +1,6 @@
{
"name": "yoga-layout",
"version": "2.0.0",
"version": "2.0.1",
"description": "An embeddable and performant flexbox layout engine with bindings for multiple languages",
"license": "MIT",
"author": "Meta Open Source",
@@ -11,19 +11,35 @@
},
"exports": {
".": {
"browser": "./src/entrypoint/wasm-async.ts",
"node": "./src/entrypoint/wasm-async.ts",
"default": "./src/entrypoint/asmjs-async.ts"
"browser": "./src/entrypoint/wasm-async-web.ts",
"node": "./src/entrypoint/wasm-async-node.ts",
"default": "./src/entrypoint/asmjs-async-web.ts"
},
"./sync": {
"browser": "./src/entrypoint/asmjs-sync.ts",
"node": "./src/entrypoint/wasm-sync.ts",
"default": "./src/entrypoint/asmjs-sync.ts"
"browser": "./src/entrypoint/asmjs-sync-web.ts",
"node": "./src/entrypoint/wasm-sync-node.ts",
"default": "./src/entrypoint/asmjs-sync-web.ts"
},
"./asmjs-async": "./src/entrypoint/asmjs-async.ts",
"./asmjs-sync": "./src/entrypoint/asmjs-sync.ts",
"./wasm-async": "./src/entrypoint/wasm-async.ts",
"./wasm-sync": "./src/entrypoint/wasm-sync.ts"
"./asmjs-async": {
"browser": "./src/entrypoint/asmjs-async-web.ts",
"node": "./src/entrypoint/asmjs-async-node.ts",
"default": "./src/entrypoint/asmjs-async-web.ts"
},
"./asmjs-sync": {
"browser": "./src/entrypoint/asmjs-sync-web.ts",
"node": "./src/entrypoint/asmjs-sync-node.ts",
"default": "./src/entrypoint/asmjs-sync-web.ts"
},
"./wasm-async": {
"browser": "./src/entrypoint/wasm-async-web.ts",
"node": "./src/entrypoint/wasm-async-node.ts",
"default": "./src/entrypoint/wasm-async-web.ts"
},
"./wasm-sync": {
"browser": "./src/entrypoint/wasm-sync-web.ts",
"node": "./src/entrypoint/wasm-sync-node.ts",
"default": "./src/entrypoint/wasm-sync-web.ts"
}
},
"files": [
"binaries/**",
@@ -36,11 +52,7 @@
"lint": "just lint",
"lint:fix": "just lint --fix",
"prepack": "just prepack",
"test": "just test",
"test:asmjs-async": "just test:asmjs-async",
"test:asmjs-sync": "just test:asmjs-sync",
"test:wasm-async": "just test:wasm-async",
"test:wasm-sync": "just test:wasm-sync"
"test": "just test"
},
"devDependencies": {
"@babel/cli": "^7.20.7",

View File

@@ -0,0 +1,26 @@
/**
* 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 wrapAssembly from '../wrapAssembly';
import type {Yoga} from '../wrapAssembly';
export * from '../generated/YGEnums';
export type {
Config,
DirtiedFunction,
MeasureFunction,
Node,
Yoga,
} from '../wrapAssembly';
const loadAssembly = require('../../binaries/asmjs-async-node');
export async function loadYoga(): Promise<Yoga> {
return wrapAssembly(await loadAssembly());
}

View File

@@ -19,7 +19,7 @@ export type {
Yoga,
} from '../wrapAssembly';
const loadAssembly = require('../../binaries/wasm-async');
const loadAssembly = require('../../binaries/asmjs-async-web');
export async function loadYoga(): Promise<Yoga> {
return wrapAssembly(await loadAssembly());

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
*/
import wrapAssembly from '../wrapAssembly';
export * from '../generated/YGEnums';
export type {
Config,
DirtiedFunction,
MeasureFunction,
Node,
Yoga,
} from '../wrapAssembly';
const loadAssembly = require('../../binaries/asmjs-sync-node');
const Yoga = wrapAssembly(loadAssembly());
export default Yoga;

View File

@@ -18,6 +18,6 @@ export type {
Yoga,
} from '../wrapAssembly';
const loadAssembly = require('../../binaries/wasm-sync');
const loadAssembly = require('../../binaries/asmjs-sync-web');
const Yoga = wrapAssembly(loadAssembly());
export default Yoga;

View File

@@ -0,0 +1,26 @@
/**
* 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 wrapAssembly from '../wrapAssembly';
import type {Yoga} from '../wrapAssembly';
export * from '../generated/YGEnums';
export type {
Config,
DirtiedFunction,
MeasureFunction,
Node,
Yoga,
} from '../wrapAssembly';
const loadAssembly = require('../../binaries/wasm-async-node');
export async function loadYoga(): Promise<Yoga> {
return wrapAssembly(await loadAssembly());
}

View File

@@ -19,7 +19,7 @@ export type {
Yoga,
} from '../wrapAssembly';
const loadAssembly = require('../../binaries/asmjs-async');
const loadAssembly = require('../../binaries/wasm-async-web');
export async function loadYoga(): Promise<Yoga> {
return wrapAssembly(await loadAssembly());

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
*/
import wrapAssembly from '../wrapAssembly';
export * from '../generated/YGEnums';
export type {
Config,
DirtiedFunction,
MeasureFunction,
Node,
Yoga,
} from '../wrapAssembly';
const loadAssembly = require('../../binaries/wasm-sync-node');
const Yoga = wrapAssembly(loadAssembly());
export default Yoga;

View File

@@ -18,6 +18,6 @@ export type {
Yoga,
} from '../wrapAssembly';
const loadAssembly = require('../../binaries/asmjs-sync');
const loadAssembly = require('../../binaries/wasm-sync-web');
const Yoga = wrapAssembly(loadAssembly());
export default Yoga;