-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Shu Ding <[email protected]>
- Loading branch information
Showing
7 changed files
with
31 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,7 +76,6 @@ | |
"@types/node": "^16", | ||
"@types/opentype.js": "^1.3.3", | ||
"@types/react": "^17.0.38", | ||
"@types/yoga-layout": "^1.9.4", | ||
"@typescript-eslint/eslint-plugin": "^5.40.0", | ||
"@typescript-eslint/parser": "^5.40.0", | ||
"@vitest/ui": "^0.7.6", | ||
|
@@ -104,7 +103,7 @@ | |
"emoji-regex": "^10.2.1", | ||
"linebreak": "^1.1.0", | ||
"postcss-value-parser": "^4.2.0", | ||
"yoga-wasm-web": "^0.3.1" | ||
"yoga-wasm-web": "^0.3.3" | ||
}, | ||
"packageManager": "[email protected]", | ||
"engines": { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
let Yoga: typeof import('yoga-layout') | ||
import type { Yoga } from 'yoga-wasm-web' | ||
|
||
export function init(yoga: typeof Yoga) { | ||
Yoga = yoga | ||
let yogaInstance: Yoga | ||
|
||
export function init(yoga: Yoga) { | ||
yogaInstance = yoga | ||
} | ||
|
||
let initializationPromise = null | ||
|
||
export default async function getYoga(): Promise<typeof Yoga> { | ||
if (Yoga) return Yoga | ||
export default async function getYoga(): Promise<Yoga> { | ||
if (yogaInstance) return yogaInstance | ||
|
||
if (initializationPromise) { | ||
await initializationPromise | ||
return Yoga | ||
return yogaInstance | ||
} | ||
|
||
initializationPromise = import('@yoga') | ||
.then((mod) => mod.getYogaModule()) | ||
.then((yogaInstance) => (Yoga = yogaInstance)) | ||
.then((yoga) => (yogaInstance = yoga)) | ||
|
||
await initializationPromise | ||
initializationPromise = null | ||
|
||
return Yoga | ||
return yogaInstance | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,4 @@ | ||
export async function getYogaModule() { | ||
const initYoga = await import('yoga-wasm-web/asm') | ||
if (initYoga.default) { | ||
return initYoga.default() | ||
} | ||
const { default: initYoga } = await import('yoga-wasm-web/asm') | ||
return initYoga() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89b1618
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
satori-playground – ./
satori-playground.vercel.sh
satori-playground.vercel.app
og-playground.vercel.app
og-playground.vercel.sh
satori-playground-git-main.vercel.sh