Skip to content

Commit

Permalink
Upgrade several Rust dependencies (#1613)
Browse files Browse the repository at this point in the history
`specta` from Hypercube's fork commit to latest upstream commit
`wasm-bindgen` 0.2.87 -> 0.2.91
`spirv-std` from 0.9 to not-yet-merged commit in EmbarkStudios/rust-gpu#1115
`wgpu` 0.17 -> 0.19
`winit` 0.28.6 -> 0.29
`vello` and `vello_svg` from latest upstream commit to not-yet-merged commit in linebender/vello#427
`resvg` 0.36.0 -> 0.39
`glam` 0.24 -> 0.25
`rustybuzz` 0.8.0 -> 0.10.0
`js-sys` and `web-sys` 0.3.55 -> 0.3.67
`usvg` 0.36.0 -> 0.39
`spirv` 0.2.0 -> 0.3

* Update a couple of dependencies

* More test fixing…

* Use upstream Specta instead of fork

* Update comments in Cargo.toml

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
  • Loading branch information
0HyperCube and Keavon authored Feb 17, 2024
1 parent 80bffd3 commit 6f6fb3b
Show file tree
Hide file tree
Showing 20 changed files with 863 additions and 877 deletions.
1,495 changes: 733 additions & 762 deletions Cargo.lock

Large diffs are not rendered by default.

37 changes: 17 additions & 20 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,22 @@ members = [
"libraries/bezier-rs",
"website/other/bezier-rs-demos/wasm",
]

resolver = "2"

exclude = ["node-graph/gpu-compiler"]

[workspace.dependencies]
# We are using this fork because:
# - They specify glam=0.22 whereas we use glam=0.24 so the encoding doesn't work.
# - Their current release doesn't allow doc comments and produces a compile error.
# See: https://github.com/GraphiteEditor/Graphite/pull/1346/files/a2206401b5b4cf669e71df57f6c95c67336802c8#r1280201659
specta = { git = "https://github.com/0HyperCube/specta.git", rev = "c47a22b4c0863d27bc47529f300de3969480c66d", features = [
specta = { git = "https://github.com/oscartbeaumont/specta.git", features = [
"glam",
"typescript",
] }
rustc-hash = "1.1.0"
# wasm-bindgen upgrades may break various things so we pin the version
wasm-bindgen = "=0.2.87"
wasm-bindgen = "=0.2.91"
dyn-any = { path = "libraries/dyn-any", features = ["derive", "glam"] }
graphene-core = { path = "node-graph/gcore" }
graph-craft = { path = "node-graph/graph-craft", features = ["serde"] }
spirv-std = { version = "0.9" }
# Remove the `rev` commit hash field once this merges: https://github.com/EmbarkStudios/rust-gpu/pull/1115 (and consider switching to a release version upon the next release)
spirv-std = { git = "https://github.com/EmbarkStudios/rust-gpu.git", rev = "08e7559012ab6645cf36f6cce84426f9e34b88d9" }
bytemuck = { version = "1.13", features = ["derive"] }
async-trait = { version = "0.1" }
serde = { version = "1.0", features = ["derive", "rc"] }
Expand All @@ -61,33 +57,34 @@ chrono = "^0.4.23"
ron = "0.8"
fastnoise-lite = "1.1.0"
wgpu-types = "0.17"
wgpu = "0.17"
wgpu = "0.19"
wasm-bindgen-futures = { version = "0.4.36" }
winit = "0.28.6"
winit = "0.29"
url = "2.4.0"
tokio = { version = "1.29", features = ["fs", "io-std"] }
vello = { git = "https://github.com/linebender/vello", version = "0.0.1" }
vello_svg = { git = "https://github.com/linebender/vello", version = "0.0.1" }
resvg = { version = "0.36.0" }
# Remove the `rev` commit hash field once this merges: https://github.com/linebender/vello/pull/427
vello = { git = "https://github.com/linebender/vello.git", rev = "f075f58fc50c569daf5ca720fe81b5fee946ce7f", version = "0.0.1" }
vello_svg = { git = "https://github.com/linebender/vello.git", rev = "f075f58fc50c569daf5ca720fe81b5fee946ce7f", version = "0.0.1" }
resvg = { version = "0.39" }
rand = { version = "0.8.5", default-features = false }
rand_chacha = { version = "0.3.1" }
bezier-rs = { path = "libraries/bezier-rs", features = ["dyn-any"] }
kurbo = { git = "https://github.com/linebender/kurbo.git", features = [
"serde",
] }
glam = { version = "0.24", default-features = false, features = ["serde"] }
glam = { version = "0.25", default-features = false, features = ["serde"] }
node-macro = { path = "node-graph/node-macro" }
base64 = { version = "0.21" }
image = { version = "0.24", default-features = false, features = ["png"] }
rustybuzz = { version = "0.8.0" }
rustybuzz = { version = "0.10.0" }
num-derive = { version = "0.4" }
num-traits = { version = "0.2.15", default-features = false, features = [
"i128",
] }
js-sys = { version = "0.3.55" }
web-sys = { version = "0.3.55" }
usvg = "0.36.0"
spirv = "0.2.0"
js-sys = { version = "=0.3.67" }
web-sys = { version = "=0.3.67" }
usvg = "0.39"
spirv = "0.3"
fern = { version = "0.6", features = ["colored"] }

[profile.dev.package.graphite-editor]
Expand Down
27 changes: 11 additions & 16 deletions editor/src/generate_ts_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,26 @@
#[test]
fn generate_ts_types() {
use crate::messages::prelude::FrontendMessage;
use specta::{
ts::{export_datatype, BigIntExportBehavior, ExportConfiguration},
DefOpts, NamedType, Type, TypeDefs,
};
use specta::ts::{export_named_datatype, BigIntExportBehavior, ExportConfig};
use specta::{NamedType, TypeMap};
use std::fs::File;
use std::io::Write;

let config = ExportConfiguration::new().bigint(BigIntExportBehavior::Number);
let config = ExportConfig::new().bigint(BigIntExportBehavior::Number);

let mut type_map = TypeDefs::new();
let mut type_map = TypeMap::default();

let datatype = FrontendMessage::named_data_type(
DefOpts {
parent_inline: false,
type_map: &mut type_map,
},
&FrontendMessage::definition_generics().into_iter().map(Into::into).collect::<Vec<_>>(),
)
.unwrap();
let datatype = FrontendMessage::definition_named_data_type(&mut type_map);

let mut export = String::new();

export += &export_datatype(&config, &datatype).unwrap();
export += &export_named_datatype(&config, &datatype, &type_map).unwrap();

type_map.values().flatten().flat_map(|v| export_datatype(&config, v)).for_each(|e| export += &format!("\n\n{e}"));
type_map
.iter()
.map(|(_, v)| v)
.flat_map(|v| export_named_datatype(&config, v, &type_map))
.for_each(|e| export += &format!("\n\n{e}"));

let mut file = File::create("../types.ts").unwrap();

Expand Down
3 changes: 2 additions & 1 deletion editor/src/messages/layout/utility_types/layout_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -457,8 +457,9 @@ impl WidgetHolder {
}
}

#[derive(Clone)]
#[derive(Clone, specta::Type)]
pub struct WidgetCallback<T> {
#[specta(skip)]
pub callback: Arc<dyn Fn(&T) -> Message + 'static + Send + Sync>,
}

Expand Down
8 changes: 5 additions & 3 deletions editor/src/messages/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ pub enum Message {

/// Provides an impl of `specta::Type` for `MessageDiscriminant`, the struct created by `impl_message`.
/// Specta isn't integrated with `impl_message`, so a remote impl must be provided using this struct.
#[derive(specta::Type)]
#[specta(inline, remote = "MessageDiscriminant")]
pub struct MessageDiscriminantDef(pub u8);
impl specta::Type for MessageDiscriminant {
fn inline(_type_map: &mut specta::TypeMap, _generics: specta::Generics) -> specta::DataType {
specta::DataType::Any
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use graphene_core::{Artboard, Color};
use transform_utils::LayerBounds;

use glam::{DAffine2, DVec2, IVec2};
use usvg::NodeExt;

pub mod transform_utils;

Expand Down Expand Up @@ -761,7 +760,6 @@ impl MessageHandler<GraphOperationMessage, GraphOperationHandlerData<'_>> for Gr
parent,
insert_index,
} => {
use usvg::TreeParsing;
let tree = match usvg::Tree::from_str(&svg, &usvg::Options::default()) {
Ok(t) => t,
Err(e) => {
Expand All @@ -774,7 +772,7 @@ impl MessageHandler<GraphOperationMessage, GraphOperationHandlerData<'_>> for Gr
};
let mut modify_inputs = ModifyInputsContext::new(document_network, document_metadata, node_graph, responses);

import_usvg_node(&mut modify_inputs, &tree.root, transform, id, parent, insert_index);
import_usvg_node(&mut modify_inputs, &usvg::Node::Group(Box::new(tree.root)), transform, id, parent, insert_index);
load_network_structure(document_network, document_metadata, selected_nodes, collapsed);
}
}
Expand Down Expand Up @@ -803,14 +801,14 @@ fn import_usvg_node(modify_inputs: &mut ModifyInputsContext, node: &usvg::Node,
return;
};
modify_inputs.layer_node = Some(layer);
match &*node.borrow() {
usvg::NodeKind::Group(_group) => {
for child in node.children() {
match node {
usvg::Node::Group(group) => {
for child in &group.children {
import_usvg_node(modify_inputs, &child, transform, NodeId(generate_uuid()), LayerNodeIdentifier::new_unchecked(layer), -1);
}
modify_inputs.layer_node = Some(layer);
}
usvg::NodeKind::Path(path) => {
usvg::Node::Path(path) => {
let subpaths = convert_usvg_path(path);
let bounds = subpaths.iter().filter_map(|subpath| subpath.bounding_box()).reduce(Quad::combine_bounds).unwrap_or_default();
let transformed_bounds = subpaths
Expand All @@ -836,10 +834,10 @@ fn import_usvg_node(modify_inputs: &mut ModifyInputsContext, node: &usvg::Node,
);
apply_usvg_stroke(&path.stroke, modify_inputs);
}
usvg::NodeKind::Image(_image) => {
usvg::Node::Image(_image) => {
warn!("Skip image")
}
usvg::NodeKind::Text(text) => {
usvg::Node::Text(text) => {
let font = Font::new(crate::consts::DEFAULT_FONT_FAMILY.to_string(), crate::consts::DEFAULT_FONT_STYLE.to_string());
modify_inputs.insert_text(text.chunks.iter().map(|chunk| chunk.text.clone()).collect(), font, 24., layer);
modify_inputs.fill_set(Fill::Solid(Color::BLACK));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1490,7 +1490,7 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
name: "Render Texture".to_string(),
inputs: vec![
NodeInput::Network(concrete!(ShaderInputFrame<WgpuExecutor>)),
NodeInput::Network(concrete!(Arc<SurfaceHandle<<WgpuExecutor as GpuExecutor>::Surface>>)),
NodeInput::Network(concrete!(Arc<SurfaceHandle<<WgpuExecutor as GpuExecutor>::Surface<'_>>>)),
NodeInput::node(NodeId(0), 0),
],
implementation: DocumentNodeImplementation::Unresolved(ProtoNodeIdentifier::new("gpu_executor::RenderTextureNode<_, _>")),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub fn empty_provider() -> OverlayProvider {
pub struct OverlayContext {
// Serde functionality isn't used but is required by the message system macros
#[serde(skip, default = "overlay_canvas_context")]
#[specta(skip)]
pub render_context: web_sys::CanvasRenderingContext2d,
pub size: DVec2,
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ wasm-bindgen = { workspace = true }
serde-wasm-bindgen = "0.6"
js-sys = { workspace = true }
wasm-bindgen-futures = { workspace = true }
ron = { version = "0.8", optional = true }
ron = { workspace = true, optional = true }
bezier-rs = { workspace = true }
# We don't have wgpu on multiple threads (yet) https://github.com/gfx-rs/wgpu/blob/trunk/CHANGELOG.md#wgpu-types-now-send-sync-on-wasm
wgpu = { version = "0.17", features = ["fragile-send-sync-non-atomic-wasm"] }
wgpu = { workspace = true, features = ["fragile-send-sync-non-atomic-wasm"] }
meval = "0.2.0"

[dependencies.web-sys]
Expand Down
4 changes: 2 additions & 2 deletions libraries/bezier-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ repository = "https://github.com/GraphiteEditor/Graphite/tree/master/libraries/b
documentation = "https://graphite.rs/libraries/bezier-rs/"

[dependencies]
glam = { version = "0.24", features = ["serde"] }
glam = { version = "0.25", features = ["serde"] }

dyn-any = { version = "0.3.0", path = "../dyn-any", optional = true }
serde = { version = "1.0", workspace = true, optional = true }
serde = { workspace = true, optional = true }
log = { workspace = true, optional = true }
2 changes: 1 addition & 1 deletion libraries/dyn-any/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ documentation = "https://docs.rs/dyn-any"
[dependencies]
dyn-any-derive = { path = "derive", version = "0.3.0", optional = true }
log = { version = "0.4", optional = true }
glam = { version = "0.24", optional = true, default-features = false }
glam = { version = "0.25", optional = true, default-features = false }

[features]
derive = ["dyn-any-derive"]
Expand Down
37 changes: 22 additions & 15 deletions node-graph/gcore/src/graphic_element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ impl GraphicGroup {
};

pub fn to_usvg_tree(&self, resolution: UVec2, viewbox: [DVec2; 2]) -> usvg::Tree {
let root_node = usvg::Node::new(usvg::NodeKind::Group(usvg::Group::default()));
let mut root_node = usvg::Group::default();
let tree = usvg::Tree {
size: usvg::Size::from_wh(resolution.x as f32, resolution.y as f32).unwrap(),
view_box: usvg::ViewBox {
Expand All @@ -244,7 +244,7 @@ impl GraphicGroup {
};

for element in self.iter() {
root_node.append(element.to_usvg_node());
root_node.children.push(element.to_usvg_node());
}
tree
}
Expand Down Expand Up @@ -283,35 +283,34 @@ impl GraphicElement {
}
let path = builder.finish().unwrap();
let mut path = usvg::Path::new(path.into());
path.transform = transform;
path.abs_transform = transform;
// TODO: use proper style
path.fill = None;
path.stroke = Some(usvg::Stroke::default());
usvg::Node::new(usvg::NodeKind::Path(path))
usvg::Node::Path(Box::new(path))
}
GraphicElement::ImageFrame(image_frame) => {
if image_frame.image.width * image_frame.image.height == 0 {
return usvg::Node::new(usvg::NodeKind::Group(usvg::Group::default()));
return usvg::Node::Group(Box::new(usvg::Group::default()));
}
let png = image_frame.image.to_png();
usvg::Node::new(usvg::NodeKind::Image(usvg::Image {
usvg::Node::Image(Box::new(usvg::Image {
id: String::new(),
transform: to_transform(image_frame.transform),
abs_transform: to_transform(image_frame.transform),
visibility: usvg::Visibility::Visible,
view_box: usvg::ViewBox {
rect: usvg::NonZeroRect::from_xywh(0., 0., 1., 1.).unwrap(),
aspect: usvg::AspectRatio::default(),
},
rendering_mode: usvg::ImageRendering::OptimizeSpeed,
kind: usvg::ImageKind::PNG(png.into()),
bounding_box: None,
}))
}
GraphicElement::Text(text) => usvg::Node::new(usvg::NodeKind::Text(usvg::Text {
GraphicElement::Text(text) => usvg::Node::Text(Box::new(usvg::Text {
id: String::new(),
transform: usvg::Transform::identity(),
abs_transform: usvg::Transform::identity(),
rendering_mode: usvg::TextRendering::OptimizeSpeed,
positions: Vec::new(),
rotate: Vec::new(),
writing_mode: usvg::WritingMode::LeftToRight,
chunks: vec![usvg::TextChunk {
text: text.clone(),
Expand All @@ -321,17 +320,25 @@ impl GraphicElement {
spans: vec![],
text_flow: usvg::TextFlow::Linear,
}],
dx: Vec::new(),
dy: Vec::new(),
rotate: Vec::new(),
bounding_box: None,
abs_bounding_box: None,
stroke_bounding_box: None,
abs_stroke_bounding_box: None,
flattened: None,
})),
GraphicElement::GraphicGroup(group) => {
let group_element = usvg::Node::new(usvg::NodeKind::Group(usvg::Group::default()));
let mut group_element = usvg::Group::default();

for element in group.iter() {
group_element.append(element.to_usvg_node());
group_element.children.push(element.to_usvg_node());
}
group_element
usvg::Node::Group(Box::new(group_element))
}
// TODO
GraphicElement::Artboard(_board) => usvg::Node::new(usvg::NodeKind::Group(usvg::Group::default())),
GraphicElement::Artboard(_board) => usvg::Node::Group(Box::new(usvg::Group::default())),
}
}
}
Loading

0 comments on commit 6f6fb3b

Please sign in to comment.