Skip to content

Commit 3fec335

Browse files
committed
wip-19
1 parent 3935f1d commit 3fec335

File tree

18 files changed

+539
-515
lines changed

18 files changed

+539
-515
lines changed

Cargo.lock

Lines changed: 466 additions & 452 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,16 @@ ctrlc = { version = "3.2", features = ["termination"] }
179179
dirs = "5.0.1"
180180
downcast = "0.11.0"
181181
downcast-rs = "1.2.0"
182-
faster-hex = "0.9.0"
183-
filetime = "0.2.22"
184-
futures = "0.3.29"
182+
faster-hex = "0.10.0"
183+
filetime = "0.2.25"
184+
futures = "0.3.31"
185185
futures-util = { version = "0.3.29", default-features = false, features = ["sink", "std"] }
186186
getrandom = {version = "0.2.10", features=["js"]}
187187
hexplay = "0.3.0"
188-
home = "0.5.5"
188+
home = "0.5.11"
189189
instant = { version ="0.1.12", features = ['wasm-bindgen'] }
190-
itertools = "0.13.0"
191-
js-sys = "0.3.64"
190+
itertools = "0.14.0"
191+
js-sys = "0.3.77"
192192
lazy_static = "1.4.0"
193193
log = "0.4.20"
194194
manual_future = "0.1.1"
@@ -198,10 +198,10 @@ numtoa = "0.2.4"
198198
# nw-sys= { path = "../nw-sys" }
199199
nw-sys = { version = "0.1.6" }
200200
pad = "0.1.6"
201-
parse-variants = "1.0.1"
201+
parse-variants = "1.0.4"
202202
proc-macro-error = { version = "1.0.4", default-features = false }
203203
proc-macro2 = { version = "1.0.50" }
204-
quote = "1.0.23"
204+
quote = "1.0.38"
205205
rand = { version = "0.8.5", features = ["getrandom"] }
206206
regex = "1.10.2"
207207
reqwest = { version = "0.12.4", default-features = false }
@@ -216,30 +216,30 @@ sha2 = "0.10.8"
216216
# syn = {version="2.0",features=["full","fold","extra-traits","parsing","proc-macro"]}
217217
syn = {version="1.0.107",features=["full","fold","extra-traits","parsing","proc-macro"]}
218218
termcolor="1.3.0"
219-
termion = "4.0.2"
219+
termion = "4.0.3"
220220
textwrap = "0.16.0"
221-
thiserror = "1.0.50"
221+
thiserror = "2.0.11"
222222
tokio = { version = "1.33.0", default-features = false, features = ['io-util','time','sync','macros','rt','rt-multi-thread'] }
223223
tokio-tungstenite = { version = "0.23.1", default-features = false, features = ["handshake", "connect"] }
224224
tungstenite = { version = "0.23.0", default-features = false }
225225
triggered = "0.1.2"
226-
wasm-bindgen = "0.2.93"
227-
wasm-bindgen-futures = "0.4.43"
228-
web-sys = "0.3.70"
226+
wasm-bindgen = "0.2.100"
227+
wasm-bindgen-futures = "0.4.50"
228+
web-sys = "0.3.77"
229229
# chrome-sys = {path = "../chrome-sys"}
230230
chrome-sys = { version = "0.2.0" }
231231
chacha20poly1305 = "0.10.1"
232232
zeroize = { version = "1.6.0", default-features = false, features = ["alloc"] }
233233

234234

235235

236-
egui = "0.28.1"
236+
egui = "0.31.0"
237237
# epaint = "=0.28.1"
238238
# egui_plot = "=0.28.1"
239239
# egui_extras = { version = "=0.28.1", features = ["svg","image"] }
240240
# eframe = "0.28.1"
241-
eframe = { version = "0.28.1", default-features = false, features = [
242-
# # "accesskit", # Make egui comptaible with screen readers. NOTE: adds a lot of dependencies.
241+
eframe = { version = "0.31.0", default-features = false, features = [
242+
# # "accesskit", # Make egui compatible with screen readers. NOTE: adds a lot of dependencies.
243243
# # "default_fonts", # Embed the default egui fonts.
244244
"glow", # Use the glow rendering backend. Alternative: "wgpu".
245245
# # "persistence", # Enable restoring app state when restarting the app.

core/macros/src/enums.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ pub fn macro_handler(item: TokenStream) -> TokenStream {
106106

107107
let mut descr: Vec<String> = Vec::new();
108108
let mut docs: Vec<String> = Vec::new();
109+
let wrappers = regex::Regex::new(r#"(^\"|\"$)"#).unwrap();
110+
let collapse_spaces_regex = regex::Regex::new(r"\s+").unwrap();
111+
109112
for e in enums.iter() {
110113
let have_key = e.args.has("default");
111114
if !have_key {
@@ -125,8 +128,6 @@ pub fn macro_handler(item: TokenStream) -> TokenStream {
125128
.map(|doc| doc.to_token_stream().to_string())
126129
.collect::<Vec<String>>()
127130
.join(" ");
128-
let collapse_spaces_regex = regex::Regex::new(r"\s+").unwrap();
129-
let wrappers = regex::Regex::new(r#"(^\"|\"$)"#).unwrap();
130131
let doc = wrappers
131132
.replace_all(&doc, "")
132133
.replace("\\\"", "\"")

core/src/enums.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ pub use u32_try_from;
115115
/// assert_eq!(v1, v2);
116116
/// ```
117117
///
118-
119118
#[macro_export]
120119
macro_rules! u16_try_from {
121120
($(#[$meta:meta])* $vis:vis enum $name:ident {
@@ -173,7 +172,6 @@ pub use u16_try_from;
173172
/// assert_eq!(v1, v2);
174173
/// ```
175174
///
176-
177175
#[macro_export]
178176
macro_rules! u8_try_from {
179177
($(#[$meta:meta])* $vis:vis enum $name:ident {

core/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn buffer_as_slice_mut<'data, T: 'data>(
2222
data: &'data mut [u8],
2323
byte_offset: usize,
2424
elements: usize,
25-
) -> &mut [T] {
25+
) -> &'data mut [T] {
2626
unsafe {
2727
std::slice::from_raw_parts_mut::<T>(
2828
std::mem::transmute::<*mut u8, *mut T>(data.as_mut_ptr().add(byte_offset)),

d3/src/graph.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ static mut DOM_INIT: bool = false;
1616

1717
const ONE_DAY_MSEC: u64 = DAYS;
1818
const ONE_DAY_SEC: u64 = DAYS / 1000;
19-
const LOWREW_CELL_SIZE: u64 = ONE_DAY_SEC / 4096;
19+
const LOWREZ_CELL_SIZE: u64 = ONE_DAY_SEC / 4096;
2020

2121
#[derive(Clone)]
2222
pub struct GraphDuration;
@@ -588,7 +588,7 @@ impl Graph {
588588
context.begin_path();
589589
context.move_to(0.0, height as f64);
590590
context.line_to(width as f64, height as f64);
591-
context.set_stroke_style(&JsValue::from(&options.x_axis_color));
591+
context.set_stroke_style_str(&options.x_axis_color);
592592
context.stroke();
593593

594594
context.begin_path();
@@ -604,14 +604,14 @@ impl Graph {
604604
context.move_to(x, height as f64);
605605
context.line_to(x, height as f64 + tick_size);
606606
}
607-
context.set_stroke_style(&JsValue::from(&options.x_axis_color));
607+
context.set_stroke_style_str(&options.x_axis_color);
608608
context.stroke();
609609

610610
// used for debugging
611611

612612
context.set_text_align("center");
613613
context.set_text_baseline("top");
614-
context.set_fill_style(&JsValue::from(&options.x_axis_color));
614+
context.set_fill_style_str(&options.x_axis_color);
615615
context.set_font(&options.x_axis_font);
616616
// context.fill_text(
617617
// &format!("{tick_width}/{width}/{count}/{count2}"),
@@ -663,20 +663,20 @@ impl Graph {
663663
context.move_to(0.0, y);
664664
context.line_to(-tick_size, y);
665665
}
666-
context.set_stroke_style(&JsValue::from(&options.y_axis_color));
666+
context.set_stroke_style_str(&options.y_axis_color);
667667
context.stroke();
668668
let height = self.height();
669669
context.begin_path();
670670
context.move_to(-tick_size, 0.0);
671671
context.line_to(0.0, 0.0);
672672
context.line_to(0.0, height as f64);
673673
context.line_to(-tick_size, height as f64);
674-
context.set_stroke_style(&JsValue::from(&options.y_axis_color));
674+
context.set_stroke_style_str(&options.y_axis_color);
675675
context.stroke();
676676

677677
context.set_text_align("right");
678678
context.set_text_baseline("middle");
679-
context.set_fill_style(&JsValue::from(&options.y_axis_color));
679+
context.set_fill_style_str(&options.y_axis_color);
680680
context.set_font(&options.y_axis_font);
681681
for tick in ticks {
682682
let y = self
@@ -704,7 +704,7 @@ impl Graph {
704704
context.save();
705705
context.set_text_baseline("top");
706706
context.set_font(&title_font);
707-
context.set_fill_style(&JsValue::from(&title_color));
707+
context.set_fill_style_str(&title_color);
708708
let metrics = if let Some(title) = self.title.as_ref() {
709709
context.measure_text(&format!("{} {}", title, self.value()))?
710710
} else {
@@ -743,7 +743,7 @@ impl Graph {
743743
context.set_text_align("right");
744744
context.set_text_baseline("top");
745745
context.set_font(&y_caption_font);
746-
context.set_fill_style(&JsValue::from(&y_caption_color));
746+
context.set_fill_style_str(&y_caption_color);
747747
context.fill_text(&self.y_caption, -10.0, 10.0)?;
748748
context.restore();
749749

@@ -760,7 +760,7 @@ impl Graph {
760760
context.set_text_align("left");
761761
context.set_text_baseline("top");
762762
context.set_font(&title_font);
763-
context.set_fill_style(&JsValue::from(&title_color));
763+
context.set_fill_style_str(&title_color);
764764

765765
{
766766
let (y, height, width) = {
@@ -877,7 +877,7 @@ impl Graph {
877877
self.data_hirez.push(&item.into());
878878

879879
let lowrez_cell = self.lowrez_cell.fetch_add(1, Ordering::SeqCst);
880-
if lowrez_cell % LOWREW_CELL_SIZE == 0 {
880+
if lowrez_cell % LOWREZ_CELL_SIZE == 0 {
881881
let lowrez_cell_value = self.lowrez_cell_value.load(Ordering::SeqCst);
882882
let lowrez_value = JsValue::from(lowrez_cell_value);
883883
let item = js_sys::Object::new();
@@ -931,7 +931,7 @@ impl Graph {
931931

932932
let data = if secs > ONE_DAY_SEC as u32 {
933933
let len = self.data_lowrez.length();
934-
let cells = secs / LOWREW_CELL_SIZE as u32;
934+
let cells = secs / LOWREZ_CELL_SIZE as u32;
935935
if let Some(start) = len.checked_sub(cells) {
936936
self.data_lowrez.slice(start, len)
937937
} else {
@@ -953,8 +953,8 @@ impl Graph {
953953
let context = &self.context;
954954
context.begin_path();
955955
self.area.call1(&JsValue::NULL, &data)?;
956-
context.set_fill_style(&JsValue::from(&area_fill_color));
957-
context.set_stroke_style(&JsValue::from(&area_stroke_color));
956+
context.set_fill_style_str(&area_fill_color);
957+
context.set_stroke_style_str(&area_stroke_color);
958958
context.fill();
959959
context.stroke();
960960

egui/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ wasm-bindgen-futures.workspace = true
6868
workspace = true
6969
features = [
7070
'VisibilityState',
71+
'HtmlCanvasElement',
7172
]
7273

7374
[lints.clippy]

egui/src/fonts.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use egui::{FontData, FontDefinitions, FontFamily};
1+
use {
2+
egui::{FontData, FontDefinitions, FontFamily},
3+
std::sync::Arc,
4+
};
25

36
pub trait RegisterStaticFont {
47
fn add_static(&mut self, family: FontFamily, name: &str, bytes: &'static [u8]);
@@ -7,7 +10,7 @@ pub trait RegisterStaticFont {
710
impl RegisterStaticFont for FontDefinitions {
811
fn add_static(&mut self, family: FontFamily, name: &str, bytes: &'static [u8]) {
912
self.font_data
10-
.insert(name.to_owned(), FontData::from_static(bytes));
13+
.insert(name.to_owned(), Arc::new(FontData::from_static(bytes)));
1114

1215
self.families
1316
.entry(family)

egui/src/frame/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ cfg_if! {
110110
where T : App
111111
{
112112
use workflow_dom::utils::document;
113+
use web_sys::HtmlCanvasElement;
114+
use wasm_bindgen::JsCast;
113115

114116
// Redirect `log` message to `console.log` and friends:
115117
eframe::WebLogger::init(log::LevelFilter::Debug).ok();
@@ -118,9 +120,14 @@ cfg_if! {
118120
element.remove();
119121
}
120122

123+
let Some(canvas) = document().get_element_by_id(options.canvas_id.as_str()) else {
124+
return Err(Error::custom("canvas_id is required (workflow-egui/frame.rs)"));
125+
};
126+
121127
eframe::WebRunner::new()
122128
.start(
123-
options.canvas_id.as_str(),
129+
canvas.dyn_into::<HtmlCanvasElement>()
130+
.map_err(|_| Error::custom("Element is not a canvas"))?,
124131
options.web_options,
125132
Box::new(move |cc| {
126133
let runtime = Runtime::new(&cc.egui_ctx, events);

egui/src/imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ pub use egui::{Rect, Vec2};
3131
pub use owning_ref::{OwningRef, OwningRefMut};
3232
pub use std::collections::VecDeque;
3333
pub use std::marker::PhantomData;
34-
pub use web_sys::VisibilityState;
34+
pub use web_sys::{HtmlCanvasElement, VisibilityState};

0 commit comments

Comments
 (0)