diff --git a/Cargo.lock b/Cargo.lock index 265eba78985a..a49164567f70 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3288,6 +3288,7 @@ dependencies = [ "ruffle_video_software", "ruffle_web_common", "serde", + "serde-wasm-bindgen", "thiserror", "url", "wasm-bindgen", @@ -3430,6 +3431,17 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-wasm-bindgen" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfc62771e7b829b517cb213419236475f434fb480eddd76112ae182d274434a" +dependencies = [ + "js-sys", + "serde", + "wasm-bindgen", +] + [[package]] name = "serde-xml-rs" version = "0.6.0" @@ -4013,8 +4025,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" dependencies = [ "cfg-if 1.0.0", - "serde", - "serde_json", "wasm-bindgen-macro", ] diff --git a/web/Cargo.toml b/web/Cargo.toml index fad93a3cae22..6c25408881f0 100644 --- a/web/Cargo.toml +++ b/web/Cargo.toml @@ -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" diff --git a/web/src/lib.rs b/web/src/lib.rs index 6db0a16bbdef..61db47d45a31 100644 --- a/web/src/lib.rs +++ b/web/src/lib.rs @@ -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. @@ -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) } @@ -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); } });