2023-06-22 13:46:57 -07:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
Consolidate JavaScript Flavors (#1433)
Summary:
Fixes https://github.com/facebook/yoga/issues/1417
This dramatically simplifies the matrix of Node vs web, ASM vs WASM, sync vs async compilation, or CommonJS vs ES Modules. We have one variant, using wasm, with ESModule top-level await to do async compilation. Web/node share the same binary, and we base64 encode the WASM into a wrapper JS file for compatibility with Node and bundlers.
This has some downsides, like requiring an environment with top level await, but also has upsides, like a consistent, sync looking API compatible with older Yoga, and mitigating TypeScript issues with package exports and typings resolution.
As part of this work I also removed `ts-node` from the toolchain (at the cost of a couple of config files needing to be vanilla JS).
Pull Request resolved: https://github.com/facebook/yoga/pull/1433
Test Plan:
1. `yarn test`
2. `yarn lint`
3. `yarn tsc`
4. `yarn benchmark`
5. `yarn build` website-next
6. `yarn lint` website-next
7. Locally test website-next
8. Examine package artifact created by GitHub
9. All Automation passes
Reviewed By: yungsters
Differential Revision: D50453324
Pulled By: NickGerleman
fbshipit-source-id: fe1192acc69e57fa69a1ff056dd7b5844d2198d5
2023-10-31 20:41:38 -07:00
|
|
|
import React, {Suspense} from 'react';
|
2023-06-22 13:46:57 -07:00
|
|
|
import clsx from 'clsx';
|
|
|
|
import Link from '@docusaurus/Link';
|
|
|
|
import Layout from '@theme/Layout';
|
Docusaurus: Replant Playground (#1331)
Summary:
Pull Request resolved: https://github.com/facebook/yoga/pull/1331
This lifts and copies code from the Yoga Playground component of the old website, to the new one, using a live workspace version of JS Yoga. This may eventually be used if the new website is fleshed out, but this also gives us real-world validation of the Yoga bindings in a web scenario, compared to the Node test runner. There is still some cleanup here needed, but we are able to bundle, typecheck, and render the playground now.
The code here is mostly the same as before, but I removed some of the cruftier bits (e.g. URL shortener that goes to some private Heroku instance), and needed to do some tweaks for the new Yoga package, and TypeScript.
This is currently using `yoga-layout/sync`, the asmjs bindings. But I had previously checked bundling against the wasm ones.
Reviewed By: cortinico
Differential Revision: D46884439
fbshipit-source-id: f53f0855c131cd2b81975bf05f71c43713600616
2023-07-13 14:08:07 -07:00
|
|
|
import BrowserOnly from '@docusaurus/BrowserOnly';
|
2023-06-22 13:46:57 -07:00
|
|
|
|
|
|
|
import styles from './index.module.css';
|
|
|
|
|
2023-11-03 05:23:56 -07:00
|
|
|
function HeroSection() {
|
2023-06-22 13:46:57 -07:00
|
|
|
return (
|
2023-11-03 05:23:56 -07:00
|
|
|
<header className={clsx('hero', styles.heroBanner)}>
|
|
|
|
<div className={clsx('row', 'container', styles.heroRow)}>
|
|
|
|
<div className="col col--6">
|
|
|
|
<h1 className="hero__title">Yoga Layout</h1>
|
|
|
|
<p className="hero__subtitle">
|
|
|
|
A portable and perfomant layout engine targeting web standards
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<Link className="button button--primary button--lg" to="/docs/intro">
|
|
|
|
Learn more
|
2023-06-22 13:46:57 -07:00
|
|
|
</Link>
|
|
|
|
</div>
|
2023-11-03 05:23:56 -07:00
|
|
|
<div className={clsx(['col col--6', styles.blueprintColumn])}>
|
|
|
|
<div className={clsx([styles.blueprint, styles.blueprintContainer])}>
|
|
|
|
<div className={styles.blueprintHeader}>
|
|
|
|
<div
|
|
|
|
className={clsx([styles.blueprint, styles.blueprintAvatar])}
|
|
|
|
/>
|
|
|
|
<div
|
|
|
|
className={clsx([styles.blueprint, styles.blueprintTitle])}
|
|
|
|
/>
|
|
|
|
<div
|
|
|
|
className={clsx([styles.blueprint, styles.blueprintSubtitle])}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div
|
|
|
|
className={clsx([styles.blueprint, styles.blueprintContent])}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-06-22 13:46:57 -07:00
|
|
|
</div>
|
|
|
|
</header>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-11-03 05:23:56 -07:00
|
|
|
const LazyPlayground = React.lazy(
|
|
|
|
() => import('../components/Playground/Playground'),
|
|
|
|
);
|
Consolidate JavaScript Flavors (#1433)
Summary:
Fixes https://github.com/facebook/yoga/issues/1417
This dramatically simplifies the matrix of Node vs web, ASM vs WASM, sync vs async compilation, or CommonJS vs ES Modules. We have one variant, using wasm, with ESModule top-level await to do async compilation. Web/node share the same binary, and we base64 encode the WASM into a wrapper JS file for compatibility with Node and bundlers.
This has some downsides, like requiring an environment with top level await, but also has upsides, like a consistent, sync looking API compatible with older Yoga, and mitigating TypeScript issues with package exports and typings resolution.
As part of this work I also removed `ts-node` from the toolchain (at the cost of a couple of config files needing to be vanilla JS).
Pull Request resolved: https://github.com/facebook/yoga/pull/1433
Test Plan:
1. `yarn test`
2. `yarn lint`
3. `yarn tsc`
4. `yarn benchmark`
5. `yarn build` website-next
6. `yarn lint` website-next
7. Locally test website-next
8. Examine package artifact created by GitHub
9. All Automation passes
Reviewed By: yungsters
Differential Revision: D50453324
Pulled By: NickGerleman
fbshipit-source-id: fe1192acc69e57fa69a1ff056dd7b5844d2198d5
2023-10-31 20:41:38 -07:00
|
|
|
|
2023-11-03 05:23:56 -07:00
|
|
|
// Docusaurus SSR does not correctly support top-level await
|
|
|
|
// 1. https://github.com/facebook/docusaurus/issues/7238
|
|
|
|
// 2. https://github.com/facebook/docusaurus/issues/9468
|
|
|
|
function BrowserOnlyPlayground() {
|
Consolidate JavaScript Flavors (#1433)
Summary:
Fixes https://github.com/facebook/yoga/issues/1417
This dramatically simplifies the matrix of Node vs web, ASM vs WASM, sync vs async compilation, or CommonJS vs ES Modules. We have one variant, using wasm, with ESModule top-level await to do async compilation. Web/node share the same binary, and we base64 encode the WASM into a wrapper JS file for compatibility with Node and bundlers.
This has some downsides, like requiring an environment with top level await, but also has upsides, like a consistent, sync looking API compatible with older Yoga, and mitigating TypeScript issues with package exports and typings resolution.
As part of this work I also removed `ts-node` from the toolchain (at the cost of a couple of config files needing to be vanilla JS).
Pull Request resolved: https://github.com/facebook/yoga/pull/1433
Test Plan:
1. `yarn test`
2. `yarn lint`
3. `yarn tsc`
4. `yarn benchmark`
5. `yarn build` website-next
6. `yarn lint` website-next
7. Locally test website-next
8. Examine package artifact created by GitHub
9. All Automation passes
Reviewed By: yungsters
Differential Revision: D50453324
Pulled By: NickGerleman
fbshipit-source-id: fe1192acc69e57fa69a1ff056dd7b5844d2198d5
2023-10-31 20:41:38 -07:00
|
|
|
return (
|
2023-11-03 05:23:56 -07:00
|
|
|
<BrowserOnly fallback={null}>
|
Consolidate JavaScript Flavors (#1433)
Summary:
Fixes https://github.com/facebook/yoga/issues/1417
This dramatically simplifies the matrix of Node vs web, ASM vs WASM, sync vs async compilation, or CommonJS vs ES Modules. We have one variant, using wasm, with ESModule top-level await to do async compilation. Web/node share the same binary, and we base64 encode the WASM into a wrapper JS file for compatibility with Node and bundlers.
This has some downsides, like requiring an environment with top level await, but also has upsides, like a consistent, sync looking API compatible with older Yoga, and mitigating TypeScript issues with package exports and typings resolution.
As part of this work I also removed `ts-node` from the toolchain (at the cost of a couple of config files needing to be vanilla JS).
Pull Request resolved: https://github.com/facebook/yoga/pull/1433
Test Plan:
1. `yarn test`
2. `yarn lint`
3. `yarn tsc`
4. `yarn benchmark`
5. `yarn build` website-next
6. `yarn lint` website-next
7. Locally test website-next
8. Examine package artifact created by GitHub
9. All Automation passes
Reviewed By: yungsters
Differential Revision: D50453324
Pulled By: NickGerleman
fbshipit-source-id: fe1192acc69e57fa69a1ff056dd7b5844d2198d5
2023-10-31 20:41:38 -07:00
|
|
|
{() => (
|
2023-11-03 05:23:56 -07:00
|
|
|
<Suspense fallback={null}>
|
|
|
|
<LazyPlayground className={styles.playground} />
|
Consolidate JavaScript Flavors (#1433)
Summary:
Fixes https://github.com/facebook/yoga/issues/1417
This dramatically simplifies the matrix of Node vs web, ASM vs WASM, sync vs async compilation, or CommonJS vs ES Modules. We have one variant, using wasm, with ESModule top-level await to do async compilation. Web/node share the same binary, and we base64 encode the WASM into a wrapper JS file for compatibility with Node and bundlers.
This has some downsides, like requiring an environment with top level await, but also has upsides, like a consistent, sync looking API compatible with older Yoga, and mitigating TypeScript issues with package exports and typings resolution.
As part of this work I also removed `ts-node` from the toolchain (at the cost of a couple of config files needing to be vanilla JS).
Pull Request resolved: https://github.com/facebook/yoga/pull/1433
Test Plan:
1. `yarn test`
2. `yarn lint`
3. `yarn tsc`
4. `yarn benchmark`
5. `yarn build` website-next
6. `yarn lint` website-next
7. Locally test website-next
8. Examine package artifact created by GitHub
9. All Automation passes
Reviewed By: yungsters
Differential Revision: D50453324
Pulled By: NickGerleman
fbshipit-source-id: fe1192acc69e57fa69a1ff056dd7b5844d2198d5
2023-10-31 20:41:38 -07:00
|
|
|
</Suspense>
|
|
|
|
)}
|
|
|
|
</BrowserOnly>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-11-03 05:23:56 -07:00
|
|
|
function PlaygroundSection() {
|
|
|
|
return (
|
|
|
|
<main className={styles.playgroundSection}>
|
|
|
|
<div className="container">
|
|
|
|
<BrowserOnlyPlayground />
|
|
|
|
</div>
|
|
|
|
</main>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-06-22 13:46:57 -07:00
|
|
|
export default function Home(): JSX.Element {
|
|
|
|
return (
|
2023-11-03 05:23:56 -07:00
|
|
|
<Layout title="Yoga Layout | A cross-platform layout engine">
|
|
|
|
<HeroSection />
|
|
|
|
<PlaygroundSection />
|
2023-06-22 13:46:57 -07:00
|
|
|
</Layout>
|
|
|
|
);
|
|
|
|
}
|