diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml
new file mode 100644
index 0000000..cc3da93
--- /dev/null
+++ b/.idea/jsLibraryMappings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Cargo.toml b/Cargo.toml
index 0be8b4e..62e8054 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,6 +4,12 @@ version = "0.1.0"
authors = ["Sambo Chea "]
edition = "2018"
+[dependencies.web-sys]
+version = "0.3"
+features = [
+ "console",
+]
+
[lib]
crate-type = ["cdylib", "rlib"]
diff --git a/run b/run
index c87e928..13ac453 100755
--- a/run
+++ b/run
@@ -1,5 +1,18 @@
#!/bin/bash
+echo "build wasm pack..."
+wasm-pack build
+
+if [ $? -eq 0 ]
+then
+ echo -e "\e[32mBuild successfully!"
+else
+ echo -e "\e[31mBuild failed for wasm-pack into script!" >&2
+ exit 1
+fi
+
+echo -e "\e[39m"
+
echo "install deps...."
cd www && npm install
diff --git a/src/lib.rs b/src/lib.rs
index 0464975..9d380c6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,13 +1,20 @@
-mod utils;
-
use wasm_bindgen::prelude::*;
+extern crate web_sys;
+
+mod utils;
+
// When the `wee_alloc` feature is enabled, use `wee_alloc` as the global
// allocator.
#[cfg(feature = "wee_alloc")]
#[global_allocator]
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
+#[wasm_bindgen(start)]
+pub fn run() {
+ log("[WASM] internal logging...");
+}
+
#[wasm_bindgen]
extern {
fn alert(s: &str);
@@ -17,3 +24,8 @@ extern {
pub fn greet() {
alert("Hey, CUBETIQ Solution!");
}
+
+#[wasm_bindgen]
+pub fn log(s: &str) {
+ web_sys::console::log_1(&s.into());
+}
diff --git a/www/index.ts b/www/index.ts
index f60e8b3..6e0e00d 100644
--- a/www/index.ts
+++ b/www/index.ts
@@ -2,3 +2,4 @@
import * as wasm from "./../pkg/wasmweb_sample"
wasm.greet()
+wasm.log("[WEB] external logging...")