Skip to content

Commit

Permalink
web: Switch to serde-wasm-bindgen over serde-serialize feature (#…
Browse files Browse the repository at this point in the history
…8080)

The `serde-serialize` feature is deprecated
(rustwasm/wasm-bindgen#3031).

This solves a cyclic dependency error with aHash
  • Loading branch information
Aaron1011 committed Sep 24, 2022
1 parent e448f5e commit 1922156
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
14 changes: 12 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ ruffle_render_webgl = { path = "../render/webgl", optional = true }
ruffle_render_wgpu = { path = "../render/wgpu", optional = true }
ruffle_video_software = { path = "../video/software" }
url = "2.3.1"
wasm-bindgen = { version = "=0.2.82", features = ["serde-serialize"] }
wasm-bindgen = { version = "=0.2.82" }
wasm-bindgen-futures = "0.4.32"
chrono = { version = "0.4", features = ["wasmbind"] }
getrandom = { version = "0.2", features = ["js"] }
serde = { version = "1.0.144", features = ["derive"] }
thiserror = "1.0"
base64 = "0.13.0"
serde-wasm-bindgen = "0.4.3"

[dependencies.ruffle_core]
path = "../core"
Expand Down
8 changes: 4 additions & 4 deletions web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,8 @@ pub struct Ruffle(Index);
impl Ruffle {
#[allow(clippy::new_ret_no_self)]
#[wasm_bindgen(constructor)]
pub fn new(parent: HtmlElement, js_player: JavascriptPlayer, config: &JsValue) -> Promise {
let config: Config = config.into_serde().unwrap_or_default();
pub fn new(parent: HtmlElement, js_player: JavascriptPlayer, config: JsValue) -> Promise {
let config: Config = serde_wasm_bindgen::from_value(config).unwrap_or_default();
wasm_bindgen_futures::future_to_promise(async move {
if RUFFLE_GLOBAL_PANIC.is_completed() {
// If an actual panic happened, then we can't trust the state it left us in.
Expand Down Expand Up @@ -289,7 +289,7 @@ impl Ruffle {
pub fn prepare_context_menu(&mut self) -> JsValue {
self.with_core_mut(|core| {
let info = core.prepare_context_menu();
JsValue::from_serde(&info).unwrap_or(JsValue::UNDEFINED)
serde_wasm_bindgen::to_value(&info).unwrap_or(JsValue::UNDEFINED)
})
.unwrap_or(JsValue::UNDEFINED)
}
Expand Down Expand Up @@ -1032,7 +1032,7 @@ impl Ruffle {
is_action_script_3: swf_header.is_action_script_3(),
};

if let Ok(value) = JsValue::from_serde(&metadata) {
if let Ok(value) = serde_wasm_bindgen::to_value(&metadata) {
instance.js_player.set_metadata(value);
}
});
Expand Down

0 comments on commit 1922156

Please sign in to comment.