diff options
| author | Mitchell Hashimoto <mitchell.hashimoto@gmail.com> | 2022-08-17 13:57:21 -0700 |
|---|---|---|
| committer | Mitchell Hashimoto <mitchell.hashimoto@gmail.com> | 2022-08-17 13:57:21 -0700 |
| commit | 2457454b07f0b24e6bbb149cb1498fb4671b465f (patch) | |
| tree | b50160310741bae25483de0512af2871d1036a84 /example | |
| parent | ead6e5a4359f3c8122299565c5f163b7b35d079b (diff) | |
test wasm of the term package
Diffstat (limited to 'example')
| -rw-r--r-- | example/index.html | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/example/index.html b/example/index.html new file mode 100644 index 000000000..f93da37d7 --- /dev/null +++ b/example/index.html @@ -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> |
