Skip to content

Commit

Permalink
web_sys: fix deprecation error
Browse files Browse the repository at this point in the history
  • Loading branch information
astraw committed Oct 22, 2024
1 parent 3ca5a40 commit f3b2b11
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 30 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ chrono = { version = "0.4.35", default-features = false }
eyre = "0.6.12"
image = { version = "0.25", default-features = false }
rerun = { version = "0.19", default-features = false, features = ["sdk"] }
web-sys = { version = "0.3.72" }

[replace]
# "tokio-threadpool:0.1.6" = {git="https://bare-git.strawlab.org/tokio.git", rev="472e64c1ea67f3976191cb1b291061faf2082735"}
Expand Down
2 changes: 1 addition & 1 deletion ads-webasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ rust-cam-bui-types = { path = "../rust-cam-bui-types" }
bui-backend-session-types = { path = "../bui-backend-session/types" }

[dependencies.web-sys]
version = "0.3"
workspace = true
features = [
"CanvasRenderingContext2d",
"Document",
Expand Down
2 changes: 1 addition & 1 deletion braid-april-cal/braid-april-cal-webapp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ yew = { version = "0.21.0", features = ["csr"] }
yew-tincture = "0.2.2"
js-sys = "0.3"
wasm-bindgen = "0.2.92"
web-sys = { version = "0.3", features = [
web-sys = { workspace = true, features = [
"CssStyleDeclaration",
"HtmlAnchorElement",
"Url",
Expand Down
8 changes: 3 additions & 5 deletions braid-april-cal/braid-april-cal-webapp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,9 @@ fn download_file(orig_buf: &[u8], filename: &str) {
let array = js_sys::Array::new();
array.push(&b.buffer());

let blob = web_sys::Blob::new_with_u8_array_sequence_and_options(
&array,
web_sys::BlobPropertyBag::new().type_(mime_type),
)
.unwrap();
let options = web_sys::BlobPropertyBag::new();
options.set_type(mime_type);
let blob = web_sys::Blob::new_with_u8_array_sequence_and_options(&array, &options).unwrap();
let data_url = web_sys::Url::create_object_url_with_blob(&blob).unwrap();
let document = web_sys::window().unwrap().document().unwrap();
let anchor = document
Expand Down
2 changes: 1 addition & 1 deletion braid/braid-run/braid_frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ rust-cam-bui-types = { path = "../../../rust-cam-bui-types" }
ads-webasm = { path = "../../../ads-webasm" }

[dependencies.web-sys]
version = "0.3"
workspace = true
features = [
"Event",
"EventSource",
Expand Down
10 changes: 5 additions & 5 deletions braid/braid-run/braid_frontend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -471,16 +471,16 @@ fn view_model_server_link(opt_addr: &Option<std::net::SocketAddr>) -> Html {

async fn post_callback(msg: &BraidHttpApiCallback) -> Result<(), FetchError> {
use web_sys::{Request, RequestInit, Response};
let mut opts = RequestInit::new();
opts.method("POST");
opts.cache(web_sys::RequestCache::NoStore);
let opts = RequestInit::new();
opts.set_method("POST");
opts.set_cache(web_sys::RequestCache::NoStore);
let buf = serde_json::to_string(&msg).unwrap_throw();
opts.body(Some(&JsValue::from_str(&buf)));
opts.set_body(&JsValue::from_str(&buf));
let headers = web_sys::Headers::new().unwrap_throw();
headers
.append("Content-Type", "application/json")
.unwrap_throw();
opts.headers(&headers);
opts.set_headers(&headers);

let url = "callback";
let request = Request::new_with_str_and_init(url, &opts)?;
Expand Down
2 changes: 1 addition & 1 deletion braidz-viewer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ braidz-parser = { path = "../braidz-parser" }
wasm-bindgen-futures = { version = "0.4.37" }

[dependencies.web-sys]
version = "0.3.64"
workspace = true
features = [
"Blob",
"DateTimeValue",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ yew-agent = "0.2.0"
yew-tincture = "0.2.2"
js-sys = "0.3"
wasm-bindgen = "0.2.92"
web-sys = { version = "0.3", features = [
web-sys = { workspace = true, features = [
"CssStyleDeclaration",
"HtmlAnchorElement",
] }
Expand Down
9 changes: 4 additions & 5 deletions freemovr-calibration/freemovr-calibration-webapp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,10 @@ fn download_file(orig_buf: &[u8], filename: &str) {
let array = js_sys::Array::new();
array.push(&b.buffer());

let blob = web_sys::Blob::new_with_u8_array_sequence_and_options(
&array,
web_sys::BlobPropertyBag::new().type_(mime_type),
)
.unwrap_throw();
let options = web_sys::BlobPropertyBag::new();
options.set_type(mime_type);
let blob =
web_sys::Blob::new_with_u8_array_sequence_and_options(&array, &options).unwrap_throw();
let data_url = web_sys::Url::create_object_url_with_blob(&blob).unwrap_throw();
let document = web_sys::window().unwrap_throw().document().unwrap_throw();
let anchor = document
Expand Down
2 changes: 1 addition & 1 deletion strand-cam/yew_frontend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ enum-iter = { path = "../../enum-iter" }
ads-webasm = { path = "../../ads-webasm" }

[dependencies.web-sys]
version = "0.3"
workspace = true
features = [
"DomRect",
"DomTokenList",
Expand Down
8 changes: 4 additions & 4 deletions strand-cam/yew_frontend/src/components/video_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub struct VideoField {
last_frame_render: f64,
mouse_xy: Option<MouseCoords>,
green_stroke: StrokeStyle,
green: JsValue,
green: &'static str,
rendered_frame_number: Option<u64>,
timeout: Option<Timeout>,
zoom_mode: ZoomMode,
Expand Down Expand Up @@ -95,7 +95,7 @@ impl Component for VideoField {
mouse_xy: None,
show_div: true,
green_stroke: StrokeStyle::from_rgb(0x7F, 0xFF, 0x7F),
green: JsValue::from("7fff7f"),
green: "7fff7f",
rendered_frame_number: None,
timeout: None,
zoom_mode: ZoomMode::FitWidth,
Expand Down Expand Up @@ -420,11 +420,11 @@ impl VideoField {
ctx.draw_image_with_html_image_element(&self.image, 0.0, 0.0)
.unwrap_throw();

ctx.set_stroke_style(&self.green);
ctx.set_stroke_style_str(self.green);
ctx.set_line_width(1.0);

for drawable_shape in in_msg.draw_shapes.iter() {
ctx.set_stroke_style(&drawable_shape.stroke_style.clone().into());
ctx.set_stroke_style_str(&drawable_shape.stroke_style);
ctx.set_line_width(drawable_shape.line_width as f64);
use http_video_streaming_types::Shape;
match &drawable_shape.shape {
Expand Down
10 changes: 5 additions & 5 deletions strand-cam/yew_frontend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1348,16 +1348,16 @@ fn to_rate(rate_enum: &RecordingFrameRate) -> Option<f32> {

async fn post_message(msg: &CallbackType) -> Result<(), FetchError> {
use web_sys::{Request, RequestInit, Response};
let mut opts = RequestInit::new();
opts.method("POST");
opts.cache(web_sys::RequestCache::NoStore);
let opts = RequestInit::new();
opts.set_method("POST");
opts.set_cache(web_sys::RequestCache::NoStore);
let buf = serde_json::to_string(&msg).unwrap_throw();
opts.body(Some(&JsValue::from_str(&buf)));
opts.set_body(&JsValue::from_str(&buf));
let headers = web_sys::Headers::new().unwrap_throw();
headers
.append("Content-Type", "application/json")
.unwrap_throw();
opts.headers(&headers);
opts.set_headers(&headers);

let url = "callback";
let request = Request::new_with_str_and_init(url, &opts)?;
Expand Down

0 comments on commit f3b2b11

Please sign in to comment.