mirror of
https://github.com/ghostty-org/ghostty.git
synced 2026-04-20 14:25:19 +00:00
test wasm of the term package
This commit is contained in:
34
example/index.html
Normal file
34
example/index.html
Normal file
@@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>WASM Example</title>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
const importObject = {
|
||||
module: {},
|
||||
env: {
|
||||
// memory: new WebAssembly.Memory({ initial: 256 }),
|
||||
}
|
||||
};
|
||||
|
||||
fetch('ghostty-term.wasm').then(response =>
|
||||
response.arrayBuffer()
|
||||
).then(bytes =>
|
||||
WebAssembly.instantiate(bytes, importObject)
|
||||
).then(results => {
|
||||
const {
|
||||
terminal_new,
|
||||
terminal_free,
|
||||
terminal_print,
|
||||
} = results.instance.exports;
|
||||
|
||||
const term = terminal_new(80, 80);
|
||||
console.log(term);
|
||||
terminal_free(term);
|
||||
terminal_print('a');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user