-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wasm): use
instantiateStreaming
when available (#1330)
close #1143
- Loading branch information
Showing
6 changed files
with
54 additions
and
19 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 |
---|---|---|
@@ -1,6 +1,11 @@ | ||
import { untilUpdated } from '../../testUtils' | ||
|
||
test('should work', async () => { | ||
await page.click('.run') | ||
await untilUpdated(() => page.textContent('.result'), 'Wasm result: 42') | ||
test('should work when inlined', async () => { | ||
await page.click('.inline-wasm .run') | ||
await untilUpdated(() => page.textContent('.inline-wasm .result'), '42') | ||
}) | ||
|
||
test('should work when output', async () => { | ||
await page.click('.output-wasm .run') | ||
await untilUpdated(() => page.textContent('.output-wasm .result'), '24') | ||
}) |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,36 @@ | ||
<button class="run">Click to run wasm</button> | ||
<div class="result"></div> | ||
<h1>Web Assembly</h1> | ||
|
||
<div class="inline-wasm"> | ||
<h3>When wasm is inline, result should be 42</h3> | ||
<button class="run">Click to run</button> | ||
<span class="result"></span> | ||
</div> | ||
|
||
<div class="output-wasm"> | ||
<h3>When wasm is output, result should be 24</h3> | ||
<button class="run">Click to run</button> | ||
<span class="result"></span> | ||
</div> | ||
|
||
<script type="module"> | ||
import init from './simple.wasm' | ||
;(async () => { | ||
import light from './light.wasm' | ||
import heavy from './heavy.wasm' | ||
|
||
async function testWasm(init, resultElement) { | ||
const { exported_func } = await init({ | ||
imports: { | ||
imported_func: (res) => { | ||
document.querySelector('.result').textContent = `Wasm result: ${res}` | ||
} | ||
imported_func: (res) => resultElement.textContent = res | ||
} | ||
}) | ||
document.querySelector('.run').addEventListener('click', exported_func) | ||
})() | ||
exported_func() | ||
} | ||
|
||
document.querySelector('.inline-wasm .run') | ||
.addEventListener('click', async () => | ||
testWasm(light, document.querySelector('.inline-wasm .result'))) | ||
|
||
document.querySelector('.output-wasm .run') | ||
.addEventListener('click', async () => | ||
testWasm(heavy, document.querySelector('.output-wasm .result'))) | ||
|
||
</script> |
File renamed without changes.
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