-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.js
30 lines (27 loc) · 791 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import wrapAsm from "./yoga/javascript/src_js/wrapAsm.js";
import yoga from "./tmp/yoga.mjs";
export * from "./yoga/javascript/src_js/generated/YGEnums.js";
export default async function (wasm) {
const mod = await yoga({
instantiateWasm(info, receive) {
WebAssembly.instantiate(wasm, info).then((instance) => {
if (instance instanceof WebAssembly.Instance) {
receive(instance);
} else {
receive(instance.instance);
}
});
},
});
return wrapAsm(mod);
}
export async function initStreaming(response) {
const mod = await yoga({
instantiateWasm(info, receive) {
WebAssembly.instantiateStreaming(response, info).then(({ instance }) => {
receive(instance);
});
},
});
return wrapAsm(mod);
}