-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor!: backend and MessageEndpoint (#500)
Rename client to provider Rename ServerMessage to ServiceMessage Add abstract layer of Backend Add macro utils to handle js_sys::Function Backend should not hold a processor Backend should only call APIs via provider which holding function request Added extension back
- Loading branch information
Showing
36 changed files
with
1,111 additions
and
389 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -3,7 +3,7 @@ resolver = "2" | |
members = ["core", "transport", "node", "rpc", "derive"] | ||
|
||
[workspace.package] | ||
version = "0.4.1" | ||
version = "0.4.2" | ||
edition = "2021" | ||
license = "GPL-3.0" | ||
authors = ["RND <[email protected]>"] | ||
|
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use js_sys::Array; | ||
use js_sys::Function; | ||
use wasm_bindgen::JsValue; | ||
use wasm_bindgen_test::wasm_bindgen_test; | ||
|
||
use crate::utils::js_func; | ||
|
||
#[wasm_bindgen_test] | ||
async fn test_fn_generator() { | ||
let js_code_args = "a, b, c, d"; | ||
let js_code_body = r#" | ||
try { | ||
return new Promise((resolve, reject) => { | ||
const ret = a + b + c + d | ||
if (ret !== "hello world") { | ||
reject(`a: ${a}, b: ${b}, c: ${c}, d: ${d} -> ret: ${ret}`) | ||
} else { | ||
resolve(ret) | ||
} | ||
}) | ||
} catch(e) { | ||
return e | ||
} | ||
"#; | ||
let func = Function::new_with_args(js_code_args, js_code_body); | ||
let native_func = js_func::of4::<String, String, String, String>(&func); | ||
let a = "hello".to_string(); | ||
let b = " ".to_string(); | ||
let c = "world".to_string(); | ||
let d = "".to_string(); | ||
native_func(a, b, c, d).await.unwrap(); | ||
} | ||
|
||
#[wasm_bindgen_test] | ||
async fn test_try_into() { | ||
let a = "hello".to_string(); | ||
let b = " ".to_string(); | ||
let c = "world".to_string(); | ||
let p: Vec<JsValue> = vec![ | ||
a.try_into().unwrap(), | ||
b.try_into().unwrap(), | ||
c.try_into().unwrap(), | ||
]; | ||
let array = Array::from_iter(p.into_iter()); | ||
assert_eq!(array.to_vec().len(), 3, "{:?}", array.to_vec()); | ||
} |
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
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
Oops, something went wrong.