Some WASM changes, not ready yet.

This commit is contained in:
Oleksandr Kozachuk
2023-01-03 11:15:40 +01:00
parent 69f65a5be0
commit 1b96ca3239
3 changed files with 19 additions and 2 deletions
+4
View File
@@ -14,3 +14,7 @@ crate-type = ["cdylib"]
[dependencies]
hel = { version = "0.1.0", path = "../hel" }
wasm-bindgen = "0.2.83"
[dependencies.web-sys]
version = "0.3.4"
features = [ 'Document' ]
+14 -1
View File
@@ -1,6 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<script type="module" src="./pkg/helwasm.js"></script>
<script src="https://unpkg.com/react@18/umd/react.development.js" crossorigin></script>
<script src="https://unpkg.com/react-dom@18/umd/react-dom.development.js" crossorigin></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
@@ -75,6 +76,18 @@
</head>
<body>
<div id="root"></div>
<script type="text/javascript">
function read_line(prompt) {
console.log("called read_line: " + prompt);
return "line";
}
function read_password(prompt) {
console.log("called read_password: " + prompt);
return "password";
}
</script>
<script type="text/babel">
function Terminal() {
const [input, setInput] = React.useState("");
@@ -101,7 +114,7 @@
case "help":
return "Available commands: help, date, ls";
case "date":
return new Date().toString();
return hel.ok_add(1, 2).toString();
case "ls":
return "file1.txt file2.txt file3.txt";
default:
+1 -1
View File
@@ -3,6 +3,6 @@ extern crate hel;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn add(a: i32, b: i32) -> i32 {
pub fn ok_add(a: i32, b: i32) -> i32 {
a + b + 1
}