Compare commits

...
Author SHA1 Message Date
Dennis Kobert e1e9ed9660 Merge branch 'master' into fix-colinear-handles-extension 2026-11-06 22:26:29 +01:00
Ramayen c88d9d366f Add a test suite for Pen tool offsets (#4823)
Add Pen tool tests for joining paths across groups, artboards, and boolean layers
2026-11-06 19:39:56 +00:00
e45a397abf Create the matching Read node when dropping a Map node onto a wire (#4925)
* Create the matching Read node when dropping a Map node onto a wire

Co-authored-by: Ankit-cs <[email protected]>
Co-authored-by: shubhtrek <[email protected]>
2026-11-06 17:26:02 +01:00
James LindsayandDennis Kobert b40c57d200 Bump the Rust dependencies (#4605)
* Bump rust dependencies

* Update more dependencies

---------

Co-authored-by: Dennis Kobert <[email protected]>
2026-11-05 23:49:21 +00:00
Keavon Chambers 1d3ebc5454 Add an acknowledgments section to the project readme and website donation page 2026-11-05 15:36:41 -08:00
Shubh Pingale 314e9f7866 Merge branch 'upstream/master' into fix-colinear-handles-extension 2026-10-21 20:08:30 +05:30
Shubh Pingale 69d3b465d6 Verify colinearity with is_almost_colinear and add get_handle_at helper 2026-10-14 20:39:02 +05:30
Shubh Pingale 49412afedf Extract get_anchor_near and get_segment_between helpers; add single-segment colinear handle test
Address review nits from 0HyperCube:

- Extract repeated point-lookup into a reusable get_anchor_near helper

- Extract repeated segment-lookup into a reusable get_segment_between helper

- Add test verifying single-segment anchors preserve colinear handles
2026-10-14 20:36:43 +05:30
Shubh Pingale 9efed51d8b Assert new segment handle remains at the anchor 2026-10-14 20:36:43 +05:30
Shubh Pingale 9f444bc964 Add test for extending from points connected to multiple segments 2026-10-14 20:36:43 +05:30
Shubh Pingale e8356e6efa Fix #4618: Prevent colinear handles when extending from points connected to multiple segments 2026-10-14 20:36:43 +05:30
48 changed files with 2667 additions and 2449 deletions

No files matched your search

+1 -1
View File
@@ -12,7 +12,7 @@
},
// NOTICE: keep these tool versions in sync with `.github/workflows/build.yml`, `.nix/dev.nix` and `.nix/pkgs/graphite.nix` (wasm-bindgen-cli), `tools/cargo-run/src/requirements.rs` (wasm-bindgen-cli, cargo-about), `tools/cargo-run/src/requirements/wasm_opt.rs` (Binaryen), and the `wasm-bindgen` crate in `Cargo.toml`
"containerEnv": {
"WASM_BINDGEN_CLI_VERSION": "0.2.127",
"WASM_BINDGEN_CLI_VERSION": "0.2.129",
"CARGO_ABOUT_VERSION": "0.9.2",
"BINARYEN_VERSION": "130",
"CARGO_BINSTALL_VERSION": "1.23.0"
+3 -3
View File
@@ -62,7 +62,7 @@ jobs:
SCCACHE_GHA_RW_MODE: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') && 'READ_WRITE' || 'READ_ONLY' }}
# NOTICE: keep these tool versions in sync with the other jobs in this file, `check.yml` (sccache), `.devcontainer/devcontainer.json`, `.nix/dev.nix` and `.nix/pkgs/graphite.nix` (wasm-bindgen-cli), `tools/cargo-run/src/requirements.rs` (wasm-bindgen-cli, cargo-about), `tools/cargo-run/src/requirements/wasm_opt.rs` (Binaryen), and the `wasm-bindgen` crate in `Cargo.toml`
SCCACHE_VERSION: "v0.19.0"
WASM_BINDGEN_CLI_VERSION: "0.2.127"
WASM_BINDGEN_CLI_VERSION: "0.2.129"
BINARYEN_VERSION: "130"
CARGO_ABOUT_VERSION: "0.9.2"
steps:
@@ -348,7 +348,7 @@ jobs:
env:
# NOTICE: keep these tool versions in sync with the other jobs in this file, `.devcontainer/devcontainer.json`, `.nix/dev.nix` and `.nix/pkgs/graphite.nix` (wasm-bindgen-cli), `tools/cargo-run/src/requirements.rs` (wasm-bindgen-cli, cargo-about), `tools/cargo-run/src/requirements/wasm_opt.rs` (Binaryen), and the `wasm-bindgen` crate in `Cargo.toml`
WASM_BINDGEN_CLI_VERSION: "0.2.127"
WASM_BINDGEN_CLI_VERSION: "0.2.129"
BINARYEN_VERSION: "130"
CARGO_ABOUT_VERSION: "0.9.2"
CARGO_BINSTALL_VERSION: "1.23.0"
@@ -617,7 +617,7 @@ jobs:
env:
# NOTICE: keep these tool versions in sync with the other jobs in this file, `.devcontainer/devcontainer.json`, `.nix/dev.nix` and `.nix/pkgs/graphite.nix` (wasm-bindgen-cli), `tools/cargo-run/src/requirements.rs` (wasm-bindgen-cli, cargo-about), `tools/cargo-run/src/requirements/wasm_opt.rs` (Binaryen), and the `wasm-bindgen` crate in `Cargo.toml`
WASM_BINDGEN_CLI_VERSION: "0.2.127"
WASM_BINDGEN_CLI_VERSION: "0.2.129"
BINARYEN_VERSION: "130"
CARGO_ABOUT_VERSION: "0.9.2"
CARGO_BINSTALL_VERSION: "1.23.0"
+1 -1
View File
@@ -22,7 +22,7 @@ let
pkgs.lld
pkgs.nodejs
pkgs.binaryen
pkgs.wasm-bindgen-cli_0_2_127
pkgs.wasm-bindgen-cli_0_2_129
deps.cargoAbout
pkgs.rustc
+1 -1
View File
@@ -83,7 +83,7 @@ deps.crane.lib.buildPackage (
pkgs.lld
pkgs.nodejs
pkgs.binaryen
pkgs.wasm-bindgen-cli_0_2_127
pkgs.wasm-bindgen-cli_0_2_129
deps.cargoAbout
pkgs.removeReferencesTo
pkgs.importNpmLock.npmConfigHook
Generated
+1974 -2364
View File
File diff suppressed because it is too large. Load diff
+26 -26
View File
@@ -147,10 +147,10 @@ web-time = "1.1"
env_logger = "0.11"
log = "0.4"
bitflags = { version = "2.4", features = ["serde"] }
ctor = "0.2"
ctor = "1.0"
convert_case = "0.12"
titlecase = "3.6"
fancy-regex = "0.18.0"
fancy-regex = "0.20.0"
unicode-segmentation = "1.13.2"
indoc = "2.0.5"
derivative = "2.2"
@@ -176,10 +176,10 @@ wgpu = { version = "30.0", default-features = false, features = [
"strict_asserts",
] }
once_cell = "1.13" # Remove and replace with `core::cell::LazyCell` (<https://doc.rust-lang.org/core/cell/struct.LazyCell.html>)
wasm-bindgen = "=0.2.127" # NOTICE: keep in sync with the `wasm-bindgen-cli` version pinned in `.github/workflows/build.yml`, `.devcontainer/devcontainer.json`, `.nix/dev.nix`, `.nix/pkgs/graphite.nix`, and `tools/cargo-run/src/requirements.rs`. We pin this version because wasm-bindgen upgrades may break various things.
wasm-bindgen = "=0.2.129" # NOTICE: keep in sync with the `wasm-bindgen-cli` version pinned in `.github/workflows/build.yml`, `.devcontainer/devcontainer.json`, `.nix/dev.nix`, `.nix/pkgs/graphite.nix`, and `tools/cargo-run/src/requirements.rs`. We pin this version because wasm-bindgen upgrades may break various things.
wasm-bindgen-futures = "0.4"
js-sys = "=0.3.104"
web-sys = { version = "=0.3.104", features = [
js-sys = "=0.3.106"
web-sys = { version = "=0.3.106", features = [
"Document",
"DomRect",
"Element",
@@ -210,25 +210,25 @@ tokio = { version = "1.29", features = ["fs", "macros", "io-std", "rt", "rt-mult
# Linebender ecosystem (BEGIN)
kurbo = { version = "0.13", features = ["serde"] }
vello_gpu = { version = "0.3", default-features = false, features = ["wgpu", "full_image_support"] }
usvg = "0.47"
usvg = "0.49"
simplecss = "0.2"
parley = { version = "0.9", default-features = false, features = ["std"] }
skrifa = "0.42"
parley = { version = "0.12", default-features = false, features = ["std"] }
skrifa = "0.44"
polycool = "0.4"
color = "0.3"
# Linebender ecosystem (END)
rand = { version = "0.9", default-features = false, features = ["std_rng"] }
rand_chacha = "0.9"
glam = { version = "0.33", default-features = false, features = [
rand = { version = "0.10", default-features = false, features = ["std_rng"] }
rand_chacha = "0.10"
glam = { version = "0.34", default-features = false, features = [
"std",
"scalar-math",
"bytemuck",
"debug-glam-assert",
"all-types",
] }
base64 = "0.22"
base64 = "0.23"
blake3 = "1.5"
mmap-io = { version = "0.9", features = ["hugepages"] }
mmap-io = { version = "1.0", features = ["hugepages"] }
image = { version = "0.25", default-features = false, features = [
"png",
"jpeg",
@@ -245,10 +245,10 @@ image = { version = "0.25", default-features = false, features = [
pretty_assertions = "1.4"
fern = { version = "0.7", features = ["colored"] }
num_enum = { version = "0.7", default-features = false }
num-derive = "0.4"
num-derive = "0.5"
num-traits = "0.2"
tsify = { version = "0.5", default-features = false, features = ["js"] }
syn = { version = "2.0", default-features = false, features = [
syn = { version = "3.0", default-features = false, features = [
"full",
"derive",
"parsing",
@@ -262,14 +262,14 @@ syn = { version = "2.0", default-features = false, features = [
lyon_geom = "1.0"
delaunator = "1.0"
robust = "1.2"
petgraph = { version = "0.7", default-features = false, features = ["graphmap"] }
petgraph = { version = "0.8", default-features = false, features = ["graphmap"] }
half = { version = "2.4", default-features = false, features = ["bytemuck"] }
tinyvec = { version = "1", features = ["std"] }
criterion = { version = "0.7", features = ["html_reports"] }
gungraun = { version = "0.18" }
ndarray = "0.16"
ollev = "0.1.1"
dirs = "6.0"
criterion = { version = "0.8", features = ["html_reports"] }
gungraun = { version = "0.20" }
ndarray = "0.17"
ollev = "0.1.2"
dirs = "7.0"
cef = "156"
cef-dll-sys = "156"
include_dir = "0.7"
@@ -277,14 +277,14 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tracing = "0.1"
rfd = "0.17"
open = "5.3"
spin = "0.10"
spin = "0.12"
clap = "4.5"
qrcodegen = "1.8"
lzma-rust2 = { version = "0.16", default-features = false, features = ["std", "encoder", "optimization", "xz"] }
scraper = "0.25"
linesweeper = "0.4"
lzma-rust2 = { version = "0.25", default-features = false, features = ["std", "encoder", "optimization", "xz"] }
scraper = "0.29"
linesweeper = "0.5"
smallvec = "1.13.2"
zip = { version = "8", default-features = false }
zip = { version = "9", default-features = false }
[workspace.lints]
+10 -2
View File
@@ -1,5 +1,3 @@
<a href="https://graphite.art/">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/user-attachments/assets/9366c148-4405-484f-909a-9a3526eb9209">
@@ -83,3 +81,13 @@ Are you a graphics programmer or Rust developer? Graphite aims to be one of the
## License
Graphite's source code is dual-licensed under your choice of either the [MIT license](LICENSE-MIT) or the [Apache License 2.0](LICENSE-APACHE), at your option, unless otherwise noted within the repository. By submitting code for inclusion in the project, you agree to license your contributions under both licenses, and that you have the authority to do so.
## Acknowledgments
We're grateful to these programs and organizations for the grants and services that help make Graphite possible.
[<img width="600" alt="European Commission, NGI Zero, and NLnet Foundation" src="https://github.com/user-attachments/assets/d5b3c623-710a-4809-916b-263e80c28184" />](https://nlnet.nl/commonsfund/)
[<img width="600" alt="Google Summer of Code" src="https://github.com/user-attachments/assets/37284dfe-fccd-4abd-904c-1165ff36da53" />](https://summerofcode.withgoogle.com/)
[<img width="300" alt="CI Powered by Blacksmith" src="https://github.com/user-attachments/assets/72bd48c2-ab21-4aed-b0a5-d440a8662128" />](https://www.blacksmith.sh/)
+1 -1
View File
@@ -1,4 +1,4 @@
use rand::Rng;
use rand::RngExt;
use rfd::AsyncFileDialog;
use std::fs;
use std::io::Read;
+1 -1
View File
@@ -34,7 +34,7 @@ serde_json = { workspace = true }
rand = { workspace = true, features = ["thread_rng"] }
cef = { workspace = true }
bytemuck = { workspace = true, optional = true }
ipc-channel = "0.22"
ipc-channel = "0.23"
# Linux-specific dependencies
[target.'cfg(target_os = "linux")'.dependencies]
+1 -1
View File
@@ -36,7 +36,7 @@ impl Archive for Zip {
if !entry.is_file() {
continue;
}
let name = entry.name().to_string();
let name = entry.name().map_err(zip_err)?.to_string();
validate_path(&name)?;
let size = checked_entry_size(&mut total_size, entry.size())?;
+2 -2
View File
@@ -91,7 +91,7 @@ impl MmappedBytes {
/// later degrading to the `&[]` fallback in [`AsRef::as_ref`], which cannot return an error.
pub fn new(file: mmap_io::mmap::MemoryMappedFile) -> Result<Self> {
let len = file.len();
file.as_slice(0, len)
file.as_slice_bytes(0, len)
.map_err(|error| ContainerError::Backend(format!("mmap slice of {:?} failed: {error}", file.path())))?;
Ok(Self(file))
}
@@ -105,7 +105,7 @@ impl MmappedBytes {
impl AsRef<[u8]> for MmappedBytes {
fn as_ref(&self) -> &[u8] {
let len = self.0.len();
match self.0.as_slice(0, len) {
match self.0.as_slice_bytes(0, len) {
Ok(slice) => slice,
Err(error) => {
log::error!("Failed to obtain mmap slice: {error}");
+1 -1
View File
@@ -244,7 +244,7 @@ fn registration(core: &TokenStream2, register: TokenStream2, migration: TokenStr
quote! {
use #core::ctor::ctor;
#[cfg_attr(not(target_family = "wasm"), ctor)]
#[cfg_attr(not(target_family = "wasm"), ctor(unsafe, crate_path = #core::ctor))]
fn register() {
#core::#register(#migration);
}
+1 -1
View File
@@ -13,7 +13,7 @@ publish.workspace = true
[dependencies]
core-types = { workspace = true }
document-graph-storage = { workspace = true }
matchbox_socket = "0.14.0"
matchbox_socket = "0.15.0"
futures = { workspace = true }
log = { workspace = true }
serde = { workspace = true }
+2 -2
View File
@@ -14,7 +14,7 @@ const FRAME_FINAL: u8 = 1;
const FRAME_MORE: u8 = 0;
/// Split a packet into `[flag][bytes]` chunks, the last carrying [`FRAME_FINAL`] so no length prefix is needed.
fn frames(bytes: &[u8]) -> Vec<Box<[u8]>> {
fn frames(bytes: &[u8]) -> Vec<Packet> {
// Chunking an empty packet would yield no frame at all.
let chunks: Vec<&[u8]> = if bytes.is_empty() { vec![&[]] } else { bytes.chunks(CHUNK_BYTES).collect() };
@@ -258,7 +258,7 @@ mod tests {
assert_eq!(incoming.wait().now_or_never(), None, "nothing arrived yet");
lock(&inbox).packets.push_back((peer(1), Box::new([FRAME_FINAL, 7])));
lock(&inbox).packets.push_back((peer(1), Packet::from_static(&[FRAME_FINAL, 7])));
assert_eq!(incoming.wait().now_or_never(), Some(true), "an arrival resolves the wait");
assert_eq!(incoming.wait().now_or_never(), Some(true), "and keeps it resolved until the inbox is drained");
@@ -99,7 +99,7 @@ impl MessageHandler<FutureMessage, ()> for FutureMessageHandler {
}));
}
FutureMessage::Drain => {
while let Ok(Some(message)) = self.results_receiver.try_next() {
while let Ok(message) = self.results_receiver.try_recv() {
responses.push_back(message);
}
}
@@ -650,6 +650,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphMessageContext<'a>> for NodeG
insert_node_input_index,
} => {
network_interface.insert_node_between(&node_id, &input_connector, insert_node_input_index, selection_network_path);
network_interface.connect_read_node_to_map(&node_id, selection_network_path);
}
NodeGraphMessage::InsertDotOnWire { node_id, input_connector, x, y } => {
network_interface.insert_dot_on_wire(node_id, &input_connector, IVec2::new(x, y), selection_network_path);
@@ -4,6 +4,7 @@ use super::{
};
use crate::consts::{GRID_SIZE, WIRE_DRAG_NODE_EXPAND_DELAY_MILLISECONDS};
use crate::messages::input_mapper::utility_types::pointer::EditorPointerState;
use crate::messages::portfolio::document::node_graph::document_node_definitions::resolve_proto_node_type;
use crate::messages::portfolio::document::node_graph::utility_types::{ContextMenuData, Direction};
use crate::messages::portfolio::document::utility_types::wires::GraphWireStyle;
use crate::test_utils::test_prelude::*;
@@ -3547,3 +3548,106 @@ async fn cannot_preview_node_without_outputs() {
network_interface.toggle_preview(custom_node, &[]);
assert_eq!(network_interface.previewing(&[]), Previewing::No);
}
fn map_definition() -> DefinitionIdentifier {
DefinitionIdentifier::ProtoNode(graphene_std::graphic::map::IDENTIFIER)
}
async fn layer_with_chain_and_unwired_map(editor: &mut EditorTestUtils) -> (NodeId, NodeId, NodeId) {
let (layer, near, ..) = layer_with_chain(editor).await;
editor
.active_document_mut()
.network_interface
.create_wire(&OutputConnector::primary_output(layer), &InputConnector::Export(0), &[]);
editor.handle_message(NodeGraphMessage::RunDocumentGraph).await;
let map = editor.create_node_by_name_at(map_definition(), 0, 30).await;
(layer, near, map)
}
async fn drop_map_onto_chain(editor: &mut EditorTestUtils, layer: NodeId, map: NodeId) {
editor
.handle_message(NodeGraphMessage::InsertNodeBetween {
node_id: map,
input_connector: InputConnector::layer_secondary_input(layer),
insert_node_input_index: 0,
})
.await;
}
#[tokio::test]
async fn dropping_a_map_node_onto_a_wire_feeds_it_the_matching_read_node() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
let (layer, near, map) = layer_with_chain_and_unwired_map(&mut editor).await;
drop_map_onto_chain(&mut editor, layer, map).await;
let network_interface = &editor.active_document().network_interface;
let Some(NodeInput::Node { node_id: read_node, .. }) = network_interface.input_from_connector(&InputConnector::node_at_index(map, 1), &[]).cloned() else {
panic!("The Map node's mapped input should be fed by a new node");
};
assert_eq!(
network_interface.reference(&read_node, &[]),
Some(DefinitionIdentifier::ProtoNode(graphene_std::context::read_vector::IDENTIFIER))
);
let map_position = network_interface.position(&map, &[]).unwrap();
let near_position = network_interface.position(&near, &[]).unwrap();
let near_bottom = near_position.y + network_interface.node_height(&near, &[]) as i32;
let read_node_position = network_interface.position(&read_node, &[]).unwrap();
assert_eq!(read_node_position.x, map_position.x - crate::consts::NODE_CHAIN_WIDTH);
assert!(
read_node_position.y > near_bottom,
"The Read node should sit below the Map node's content source rather than overlap it"
);
assert_invariants(&editor, "after dropping a Map node onto a wire");
}
#[test]
fn map_content_types_resolve_to_the_read_node_of_their_element() {
use super::layout::read_node_for_content;
use super::resolved_types::TypeSource;
use graph_craft::{item, list};
use graphene_std::context::{read_graphic, read_number, read_vector};
use graphene_std::list::Bundle;
use graphene_std::text_nodes::read_string;
use graphene_std::{Graphic, Vector};
assert_eq!(read_node_for_content(&TypeSource::Compiled(list!(Vector))), Some(read_vector::IDENTIFIER));
assert_eq!(read_node_for_content(&TypeSource::Compiled(item!(Graphic))), Some(read_graphic::IDENTIFIER));
assert_eq!(read_node_for_content(&TypeSource::Compiled(list!(f64))), Some(read_number::IDENTIFIER));
assert_eq!(read_node_for_content(&TypeSource::TaggedValue(list!(String))), Some(read_string::IDENTIFIER));
assert_eq!(read_node_for_content(&TypeSource::Compiled(item!(Bundle<Vector>))), Some(read_vector::IDENTIFIER));
assert_eq!(
read_node_for_content(&TypeSource::Compiled(list!(i64))),
None,
"Read Number yields f64, which a Map over integers can't take"
);
assert_eq!(read_node_for_content(&TypeSource::Compiled(list!(bool))), None);
assert_eq!(read_node_for_content(&TypeSource::Unknown), None);
}
#[tokio::test]
async fn dropping_a_map_node_onto_a_wire_keeps_its_wired_mapped_input() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
let (layer, _, map) = layer_with_chain_and_unwired_map(&mut editor).await;
let mapped_source = NodeId::new();
let read_vector = resolve_proto_node_type(graphene_std::context::read_vector::IDENTIFIER).unwrap().default_node_template();
let network_interface = &mut editor.active_document_mut().network_interface;
network_interface.insert_node(mapped_source, read_vector, &[]);
network_interface.create_wire(&OutputConnector::primary_output(mapped_source), &InputConnector::node_at_index(map, 1), &[]);
let node_count = editor.active_document().network_interface.document_network().nodes.len();
drop_map_onto_chain(&mut editor, layer, map).await;
let network_interface = &editor.active_document().network_interface;
assert_eq!(
network_interface.input_from_connector(&InputConnector::node_at_index(map, 1), &[]),
Some(&NodeInput::node(mapped_source, 0))
);
assert_eq!(network_interface.document_network().nodes.len(), node_count);
}
@@ -1,4 +1,9 @@
use super::resolved_types::TypeSource;
use super::*;
use graph_craft::{ProtoNodeIdentifier, concrete};
use graphene_std::raster_types::{CPU, Raster};
use graphene_std::vector::style::Gradient;
use graphene_std::{Color, Graphic};
impl NodeNetworkInterface {
/// The top left corner of a node in node graph grid coordinates.
@@ -1155,6 +1160,41 @@ impl NodeNetworkInterface {
self.create_wire(&upstream_output, &InputConnector::node_at_index(*node_id, insert_node_input_index), network_path);
}
/// Feeds an unconnected Map node's mapped input with the Read node matching the element type of its content.
pub fn connect_read_node_to_map(&mut self, node_id: &NodeId, network_path: &[NodeId]) {
if self.reference(node_id, network_path) != Some(DefinitionIdentifier::ProtoNode(graphene_std::graphic::map::IDENTIFIER)) {
return;
}
let mapped_input = InputConnector::node_at_index(*node_id, 1);
if !matches!(self.input_from_connector(&mapped_input, network_path), Some(NodeInput::Value { .. })) {
return;
}
let Some(content_source) = self.upstream_output_connector(&InputConnector::primary_input(*node_id), network_path) else {
return;
};
let Some(mut read_node_template) = read_node_for_content(&self.output_type(&content_source, network_path))
.and_then(resolve_proto_node_type)
.map(|definition| definition.default_node_template())
else {
return;
};
let Some(map_position) = self.position(node_id, network_path) else {
return;
};
let below_content_source = content_source
.node_id()
.and_then(|source| Some(self.position(&source, network_path)?.y + self.node_height(&source, network_path) as i32 + 1));
let read_node_position = IVec2::new(map_position.x - NODE_CHAIN_WIDTH, below_content_source.unwrap_or(map_position.y + 2));
read_node_template.node_type_metadata = NodeTypePersistentMetadata::node(read_node_position);
let read_node_id = NodeId::new();
self.insert_node(read_node_id, read_node_template, network_path);
self.create_wire(&OutputConnector::primary_output(read_node_id), &mapped_input, network_path);
}
/// Inserts the freshly-created `node_id` onto the wire feeding `input_connector`: the previous upstream becomes the
/// new node's primary (index 0) input, and the new node feeds `input_connector`.
///
@@ -1575,3 +1615,30 @@ impl NodeNetworkInterface {
self.layer_chain(layer, network_path) == intended_chain
}
}
/// The Read node yielding each element of a Map node's content, unbundling a whole-list `Item<Bundle<T>>` wire to its `T`.
pub(super) fn read_node_for_content(content_type: &TypeSource) -> Option<ProtoNodeIdentifier> {
use graphene_std::context::{read_color, read_gradient, read_graphic, read_number, read_raster, read_vector};
use graphene_std::text_nodes::read_string;
let bundle_element = content_type.compiled_nested_type().and_then(Type::bundle_element_name);
let element_type = content_type.compiled_element_type()?;
[
(concrete!(Vector), read_vector::IDENTIFIER),
(concrete!(Graphic), read_graphic::IDENTIFIER),
(concrete!(Raster<CPU>), read_raster::IDENTIFIER),
(concrete!(Color), read_color::IDENTIFIER),
(concrete!(Gradient), read_gradient::IDENTIFIER),
(concrete!(f64), read_number::IDENTIFIER),
(concrete!(String), read_string::IDENTIFIER),
]
.into_iter()
.find_map(|(candidate, read_node)| {
let matches = match (bundle_element, &candidate) {
(Some(bundle_element), Type::Concrete(descriptor)) => descriptor.name == bundle_element,
_ => candidate == *element_type,
};
matches.then_some(read_node)
})
}
@@ -1478,7 +1478,9 @@ impl PenToolData {
/// Perform extension of an existing path
fn extend_existing_path(&mut self, document: &DocumentMessageHandler, layer: LayerNodeIdentifier, point: PointId, position: DVec2) {
let vector: Option<VectorGeometry> = document.network_interface.compute_modified_vector(layer);
let (handle_start, in_segment) = if let Some(vector) = &vector {
let (handle_start, in_segment) = if let Some(vector) = &vector
&& vector.connected_count(point) <= 1
{
vector
.segment_iter()
.find_map(|(segment_id, bezier, start, end)| {
@@ -2496,13 +2498,30 @@ impl Fsm for PenToolFsmState {
#[cfg(test)]
mod test_pen_tool {
use super::is_almost_colinear;
use crate::messages::input_mapper::utility_types::pointer::EditorPointerState;
use crate::messages::portfolio::document::graph_operation::utility_types::TransformIn;
use crate::messages::portfolio::document::utility_types::misc::GroupFolderType;
use crate::messages::tool::common_functionality::snap_session::WAKE_DWELL_ON_APPROACH;
use crate::test_utils::EditorTestUtils;
use crate::test_utils::test_prelude::*;
use glam::DAffine2;
use graphene_std::vector::misc::{HandleId, ManipulatorPointId};
use graphene_std::vector::{SegmentId, VectorGeometry};
use glam::{DAffine2, DVec2};
use graphene_std::vector::misc::{BooleanOperation, HandleId, ManipulatorPointId};
use graphene_std::vector::{PointId, SegmentId, VectorGeometry};
fn assert_expected_anchors(editor: &EditorTestUtils, expected_anchors: &[DVec2]) {
let (layer, vector) = drawn_path(editor).expect("Expected a drawn path");
let layer_to_viewport = editor.active_document().metadata().transform_to_viewport(layer);
let mut viewport_points: Vec<DVec2> = vector.anchor_positions().into_iter().map(|pos| layer_to_viewport.transform_point2(pos)).collect();
for (expected_index, &expected_position) in expected_anchors.iter().enumerate() {
let Some(viewport_index) = viewport_points.iter().position(|viewport| viewport.distance_squared(expected_position) < 1e-10) else {
panic!("The expected anchor index {expected_index} and position {expected_position} was not found in the actual anchors {viewport_points:?}");
};
viewport_points.remove(viewport_index);
}
assert!(viewport_points.is_empty(), "Viewport point(s) were not matched: {viewport_points:?}");
}
/// The single Pen-drawn path layer and its vector, or `None` once the layer has been undone away.
fn drawn_path(editor: &EditorTestUtils) -> Option<(LayerNodeIdentifier, VectorGeometry)> {
@@ -2565,6 +2584,267 @@ mod test_pen_tool {
const C: DVec2 = DVec2::new(200., 200.);
const D: DVec2 = DVec2::new(100., 200.);
async fn create_a_rectangle() -> EditorTestUtils {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
editor.select_primary_color(Color::RED).await;
// Draw a rectangle not at the origin (so will end up with a non-identity transform)
editor.draw_rect(A.x, A.y, C.x, C.y).await;
editor
}
/// Using the path tool to merge layers (by setting the endpoint to an anchor of another layer) should produce only expected anchor positions.
#[tokio::test]
async fn merging_layers_simple() {
let mut editor = create_a_rectangle().await;
// Start the pen somewhere random
let pen_start = DVec2::new(999., 999.);
click_pen(&mut editor, pen_start).await;
// Connect to the top right of the rectangle
click_pen(&mut editor, B).await;
// Validate that these anchors are the only ones that exist
let expected_anchors = [A, B, C, D, pen_start];
assert_expected_anchors(&editor, &expected_anchors);
}
#[tokio::test]
async fn merging_two_pen_paths() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
// Create First Pen path
click_pen(&mut editor, A).await;
click_pen(&mut editor, C).await;
// Abort the first pen process
editor.handle_message(ToolMessage::Pen(PenToolMessage::Abort)).await;
// Create a second pen stroke
click_pen(&mut editor, B).await;
click_pen(&mut editor, C).await;
// Validate that these anchors are the only ones that exist
let expected_anchors = [A, B, C];
assert_expected_anchors(&editor, &expected_anchors);
}
#[tokio::test]
async fn merging_layers_in_group_with_offset() {
let mut editor = create_a_rectangle().await;
// Group rectangle
editor
.handle_message(DocumentMessage::GroupSelectedLayers {
group_folder_type: GroupFolderType::Layer,
})
.await;
let group = editor.active_document().metadata().all_layers().next().unwrap();
let offset = DVec2::new(50., 60.);
editor
.handle_message(GraphOperationMessage::TransformSet {
layer: group,
transform: DAffine2::from_translation(offset),
transform_in: TransformIn::Local,
skip_rerender: false,
})
.await;
// Start the pen somewhere random
let pen_start = DVec2::new(999., 999.);
click_pen(&mut editor, pen_start).await;
// Connect to the top right of the rectangle (offset by the group transform)
click_pen(&mut editor, B + offset).await;
let expected_anchors = [A + offset, B + offset, C + offset, D + offset, pen_start];
assert_expected_anchors(&editor, &expected_anchors);
}
#[tokio::test]
async fn merging_layers_in_different_groups_with_offsets() {
let mut editor = create_a_rectangle().await;
// Group rectangle into Group 1
editor
.handle_message(DocumentMessage::GroupSelectedLayers {
group_folder_type: GroupFolderType::Layer,
})
.await;
let group1 = editor.active_document().metadata().all_layers().next().unwrap();
let offset1 = DVec2::new(50., 60.);
editor
.handle_message(GraphOperationMessage::TransformSet {
layer: group1,
transform: DAffine2::from_translation(offset1),
transform_in: TransformIn::Local,
skip_rerender: false,
})
.await;
// Nest Group 1 inside Group 2 with a different offset
editor
.handle_message(DocumentMessage::GroupSelectedLayers {
group_folder_type: GroupFolderType::Layer,
})
.await;
let group2 = editor.active_document().metadata().all_layers().next().unwrap();
let offset2 = DVec2::new(30., -20.);
editor
.handle_message(GraphOperationMessage::TransformSet {
layer: group2,
transform: DAffine2::from_translation(offset2),
transform_in: TransformIn::Local,
skip_rerender: false,
})
.await;
let total_offset = offset1 + offset2;
// Start the pen somewhere random
let pen_start = DVec2::new(999., 999.);
click_pen(&mut editor, pen_start).await;
// Connect to the top right of the rectangle (offset by the nested group transforms)
click_pen(&mut editor, B + total_offset).await;
let expected_anchors = [A + total_offset, B + total_offset, C + total_offset, D + total_offset, pen_start];
assert_expected_anchors(&editor, &expected_anchors);
}
#[tokio::test]
async fn merging_layers_in_artboard_with_offset() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
let offset = DVec2::new(60., 70.);
editor.drag_tool(ToolType::Artboard, 0., 0., 500., 500., ModifierKeys::empty()).await;
let artboard = editor.active_document().metadata().all_layers().next().unwrap();
editor
.handle_message(GraphOperationMessage::TransformSet {
layer: artboard,
transform: DAffine2::from_translation(offset),
transform_in: TransformIn::Local,
skip_rerender: false,
})
.await;
editor.select_primary_color(Color::RED).await;
editor.draw_rect(A.x + offset.x, A.y + offset.y, C.x + offset.x, C.y + offset.y).await;
let pen_start = DVec2::new(999., 999.);
click_pen(&mut editor, pen_start).await;
click_pen(&mut editor, B + offset).await;
let expected_anchors = [A + offset, B + offset, C + offset, D + offset, pen_start];
assert_expected_anchors(&editor, &expected_anchors);
}
#[tokio::test]
async fn merging_layers_in_artboards_with_different_offsets() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
// Create first artboard with offset
editor.drag_tool(ToolType::Artboard, 0., 0., 400., 400., ModifierKeys::empty()).await;
let artboard1 = editor.active_document().metadata().all_layers().next().unwrap();
let offset1 = DVec2::new(50., 60.);
editor
.handle_message(GraphOperationMessage::TransformSet {
layer: artboard1,
transform: DAffine2::from_translation(offset1),
transform_in: TransformIn::Local,
skip_rerender: false,
})
.await;
// Draw rectangle in first artboard
editor.select_primary_color(Color::RED).await;
editor.draw_rect(A.x + offset1.x, A.y + offset1.y, C.x + offset1.x, C.y + offset1.y).await;
// Create second artboard with different offset
let offset2 = DVec2::new(-30., 40.);
let artboard2_origin = DVec2::new(600., 600.);
editor
.drag_tool(
ToolType::Artboard,
artboard2_origin.x,
artboard2_origin.y,
artboard2_origin.x + 400.,
artboard2_origin.y + 400.,
ModifierKeys::empty(),
)
.await;
let artboard2 = editor.active_document().metadata().all_layers().next().unwrap();
editor
.handle_message(GraphOperationMessage::TransformSet {
layer: artboard2,
transform: DAffine2::from_translation(offset2),
transform_in: TransformIn::Local,
skip_rerender: false,
})
.await;
// Start pen in second artboard
let pen_start = artboard2_origin + offset2 + DVec2::new(50., 50.);
click_pen(&mut editor, pen_start).await;
// Connect to anchor B of the rectangle in the first artboard
click_pen(&mut editor, B + offset1).await;
let expected_anchors = [A + offset1, B + offset1, C + offset1, D + offset1, pen_start];
assert_expected_anchors(&editor, &expected_anchors);
}
async fn test_boolean_operation(operation: BooleanOperation) {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
editor.select_primary_color(Color::RED).await;
editor.draw_rect(A.x, A.y, C.x, C.y).await;
editor.draw_rect(150., 150., 250., 250.).await;
// Select both rectangles and create boolean operation layer
let layers: Vec<_> = editor.active_document().metadata().all_layers().collect();
editor
.handle_message(NodeGraphMessage::SelectedNodesSet {
nodes: layers.iter().map(|l| l.to_node()).collect(),
})
.await;
editor
.handle_message(DocumentMessage::GroupSelectedLayers {
group_folder_type: GroupFolderType::BooleanOperation(operation),
})
.await;
let bool_layer = editor.active_document().metadata().all_layers().next().unwrap();
let bool_vector = editor.active_document().network_interface.compute_modified_vector(bool_layer).expect("Boolean layer vector");
let bool_to_viewport = editor.active_document().metadata().transform_to_viewport(bool_layer);
let mut expected_anchors: Vec<DVec2> = bool_vector.anchor_positions().into_iter().map(|pos| bool_to_viewport.transform_point2(pos)).collect();
// Connect pen to one of the anchors of the boolean operation
let connect_anchor = expected_anchors[0];
let pen_start = DVec2::new(999., 999.);
click_pen(&mut editor, pen_start).await;
click_pen(&mut editor, connect_anchor).await;
expected_anchors.push(pen_start);
assert_expected_anchors(&editor, &expected_anchors);
}
#[tokio::test]
async fn merging_layers_with_different_boolean_outputs() {
for operation in [BooleanOperation::Union, BooleanOperation::SubtractFront, BooleanOperation::Intersect, BooleanOperation::Difference] {
test_boolean_operation(operation).await;
}
}
#[tokio::test]
async fn enter_or_esc_after_a_single_click_leaves_no_layer() {
for key in [Key::Enter, Key::Escape] {
@@ -3145,6 +3425,37 @@ mod test_pen_tool {
assert!(leaving.distance(handle) < 1e-6, "the joining segment's handle is at {leaving}");
}
/// Finds the point ID whose viewport position is within tolerance of `target`.
fn get_anchor_near(vector: &VectorGeometry, layer_to_viewport: DAffine2, target: DVec2) -> PointId {
vector
.anchors()
.find(|&(_id, pos)| layer_to_viewport.transform_point2(pos).distance(target) < 1e-6)
.map(|(id, _pos)| id)
.unwrap_or_else(|| panic!("No anchor found near {target}"))
}
/// Finds the segment that connects two given point IDs (in either direction).
fn get_segment_between(vector: &VectorGeometry, point_a: PointId, point_b: PointId) -> SegmentId {
vector
.segment_ids()
.into_iter()
.find(|&segment| {
let start = vector.segment_start_from_id(segment);
let end = vector.segment_end_from_id(segment);
(start == Some(point_a) && end == Some(point_b)) || (start == Some(point_b) && end == Some(point_a))
})
.unwrap_or_else(|| panic!("No segment found between the given anchors"))
}
/// Finds the handle position on `segment` that corresponds to `point`.
fn get_handle_at(vector: &VectorGeometry, segment: SegmentId, point: PointId) -> Option<DVec2> {
if vector.segment_start_from_id(segment) == Some(point) {
vector.position_of(ManipulatorPointId::PrimaryHandle(segment))
} else {
vector.position_of(ManipulatorPointId::EndHandle(segment))
}
}
#[tokio::test]
async fn an_anchor_moved_with_space_lands_on_a_corner_and_carries_its_handles_along() {
let mut editor = EditorTestUtils::create();
@@ -3432,4 +3743,83 @@ mod test_pen_tool {
let stroke = position(graphene_std::vector_nodes::stroke::IDENTIFIER).expect("The path should have a Stroke node");
assert!(transform > fill && transform > stroke, "the Transform should be upstream of the Fill and Stroke in {chain:?}");
}
#[tokio::test]
async fn extending_from_anchor_with_multiple_segments_does_not_create_colinear_handle() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
// 1. Draw a path through A, B, and C with curved handles dragged out at B
click_pen(&mut editor, A).await;
let handle = B + DVec2::new(50., 0.);
editor.drag_path(&[B, handle], ModifierKeys::empty()).await;
click_pen(&mut editor, C).await;
editor.press(Key::Enter, ModifierKeys::empty()).await;
assert_path_shape(&editor, 3, 2);
// 2. Extend from anchor B to D by clicking on B and then D (without dragging)
click_pen(&mut editor, B).await;
click_pen(&mut editor, D).await;
editor.press(Key::Enter, ModifierKeys::empty()).await;
assert_path_shape(&editor, 4, 3);
// 3. Verify the new branch leaving B does not create a mirrored/colinear handle
let (layer, vector) = drawn_path(&editor).expect("Expected a drawn path");
let layer_to_viewport = editor.active_document().metadata().transform_to_viewport(layer);
let b_id = get_anchor_near(&vector, layer_to_viewport, B);
let d_id = get_anchor_near(&vector, layer_to_viewport, D);
let bd_segment = get_segment_between(&vector, b_id, d_id);
if let Some(handle_pos) = get_handle_at(&vector, bd_segment, b_id) {
let handle_pos = layer_to_viewport.transform_point2(handle_pos);
assert!(handle_pos.distance(B) < 1e-4, "Handle at B for the new segment should remain at the anchor");
}
}
#[tokio::test]
async fn extending_from_anchor_with_single_segment_uses_colinear_handle() {
let mut editor = EditorTestUtils::create();
editor.new_document().await;
// 1. Draw a single segment A→B with a curved handle dragged out at B
click_pen(&mut editor, A).await;
let handle = B + DVec2::new(50., 0.);
editor.drag_path(&[B, handle], ModifierKeys::empty()).await;
editor.press(Key::Enter, ModifierKeys::empty()).await;
assert_path_shape(&editor, 2, 1);
// 2. Extend from B to C by clicking B then C (only one segment is attached to B)
click_pen(&mut editor, B).await;
click_pen(&mut editor, C).await;
editor.press(Key::Enter, ModifierKeys::empty()).await;
assert_path_shape(&editor, 3, 2);
// 3. Verify the new segment leaving B carries a mirrored/colinear handle
let (layer, vector) = drawn_path(&editor).expect("Expected a drawn path");
let layer_to_viewport = editor.active_document().metadata().transform_to_viewport(layer);
let b_id = get_anchor_near(&vector, layer_to_viewport, B);
let c_id = get_anchor_near(&vector, layer_to_viewport, C);
let bc_segment = get_segment_between(&vector, b_id, c_id);
let a_id = get_anchor_near(&vector, layer_to_viewport, A);
let ab_segment = get_segment_between(&vector, a_id, b_id);
let existing_handle_at_b = get_handle_at(&vector, ab_segment, b_id).expect("Segment AB should have a handle at B");
let existing_handle_pos = layer_to_viewport.transform_point2(existing_handle_at_b);
let new_handle_at_b = get_handle_at(&vector, bc_segment, b_id).expect("The new segment should have a handle at B");
let new_handle_pos = layer_to_viewport.transform_point2(new_handle_at_b);
// When only one segment is connected, the handle should not collapse to the
// anchor, and must be colinear with the existing handle at B.
assert!(
new_handle_pos.distance(B) > 1e-4,
"Handle at B should not collapse to the anchor when only one segment is connected (got {new_handle_pos})"
);
assert!(
is_almost_colinear(B, existing_handle_pos, new_handle_pos),
"New handle should be colinear with the existing handle at B (existing: {existing_handle_pos}, new: {new_handle_pos})"
);
}
}
+1 -1
View File
@@ -30,7 +30,7 @@ glam = ["dep:glam"]
dyn-any-derive = { path = "derive", optional = true }
# Optional dependencies
glam = { version = "0.33", optional = true, default-features = false, features = ["all-types"] }
glam = { version = "0.34", optional = true, default-features = false, features = ["all-types"] }
reqwest = { version = "0.13", optional = true, default-features = false }
[package.metadata.docs.rs]
+1
View File
@@ -18,6 +18,7 @@ workspace = true
thiserror = "2.0"
num-complex = "0.4"
unicode-ident = "1.0"
# This is intentionally not upgraded since the cache API was removed for soundness https://codeberg.org/zesterer/chumsky/pulls/980
chumsky = { version = "0.10", default-features = false, features = ["std", "unstable"] }
[dev-dependencies]
@@ -149,7 +149,7 @@ struct MmappedBytes(MemoryMappedFile);
impl AsRef<[u8]> for MmappedBytes {
fn as_ref(&self) -> &[u8] {
let len = self.0.len();
match self.0.as_slice(0, len) {
match self.0.as_slice_bytes(0, len) {
Ok(slice) => slice,
Err(error) => {
log::error!("Failed to obtain mmap slice: {error}");
+1 -1
View File
@@ -43,7 +43,7 @@ winit = { workspace = true }
clap = { workspace = true, features = ["cargo", "derive"] }
image = { workspace = true }
serde_json = { workspace = true }
getrandom = "0.3"
getrandom = "0.4"
wgpu-executor = { workspace = true, optional = true }
[package.metadata.cargo-shear]
@@ -1,4 +1,4 @@
use rand::{Rng, SeedableRng};
use rand::{RngExt, SeedableRng};
/// Gives each of `count` items a factor from 0 to 1, either spread evenly in item order or drawn at random from the `seed`.
/// The even spread restarts after every `repeat_every` items, unless it is 0 to span all the items once.
+1 -1
View File
@@ -42,7 +42,7 @@ mod u64_string {
mod uuid_generation {
use rand_chacha::ChaCha20Rng;
use rand_chacha::rand_core::{RngCore, SeedableRng};
use rand_chacha::rand_core::{Rng, SeedableRng};
use std::cell::Cell;
use std::sync::Mutex;
@@ -3016,7 +3016,7 @@ fn draw_glyph_run_to_bezpaths(glyph_run: &parley::GlyphRun<'_, ()>, x_offset: f3
let run = glyph_run.run();
let font = run.font();
let font_size_pts = run.font_size();
let normalized_coords: Vec<NormalizedCoord> = run.normalized_coords().iter().map(|c| NormalizedCoord::from_bits(*c)).collect();
let normalized_coords: Vec<NormalizedCoord> = run.normalized_coords().iter().map(|c| NormalizedCoord::from_bits(c.to_bits())).collect();
let Ok(font_ref) = SkrifaFontRef::from_index(font.data.as_ref(), font.index) else { return };
let outlines = font_ref.outline_glyphs();
@@ -33,7 +33,7 @@ impl WeldExt for Vector {
// TODO: We lose information on the winding order by using an undirected graph. Switch to a directed graph and fix the algorithm to handle that.
// Graph containing only short edges, referencing the data graph
let mut short_edges = UnGraphMap::new();
let mut short_edges = UnGraphMap::<_, _, rustc_hash::FxBuildHasher>::new();
for segment_id in working.segment_ids.iter().copied() {
let length = indices.segment_chord_length(segment_id);
+2 -2
View File
@@ -24,8 +24,8 @@ quote = { workspace = true }
convert_case = { workspace = true }
indoc = { workspace = true }
proc-macro-crate = "3.1.0"
proc-macro-error2 = "2"
proc-macro-crate = "3.1"
proc-macro-error3 = "3.1"
[dev-dependencies]
core-types = { workspace = true }
+2 -2
View File
@@ -1057,7 +1057,7 @@ pub(crate) fn generate_node_code(crate_ident: &CrateIdent, parsed: &ParsedNodeFn
#register_node_impl
#[cfg_attr(not(target_family = "wasm"), ctor)]
#[cfg_attr(not(target_family = "wasm"), ctor(unsafe, crate_path = gcore::ctor))]
fn register_metadata() {
let metadata = NodeMetadata {
display_name: #display_name,
@@ -1429,7 +1429,7 @@ fn generate_register_node_impl(
}
}
Ok(quote! {
#[cfg_attr(not(target_family = "wasm"), ctor)]
#[cfg_attr(not(target_family = "wasm"), ctor(unsafe, crate_path = gcore::ctor))]
fn register_node() {
let mut registry = NODE_REGISTRY.lock().unwrap();
registry.insert(
+1 -1
View File
@@ -245,7 +245,7 @@ pub fn derive_destructure_impl(item: TokenStream2) -> syn::Result<TokenStream2>
use super::*;
use #gcore::ctor::ctor;
#[cfg_attr(not(target_family = "wasm"), ctor)]
#[cfg_attr(not(target_family = "wasm"), ctor(unsafe, crate_path = core_types::ctor))]
fn register_memoize_and_monitor() {
#graphene_core::memo::register_memoize_and_monitor::<#struct_ident>();
#graphene_core::memo::register_memoize_and_monitor::<#mapped_ident>();
+1 -1
View File
@@ -1,5 +1,5 @@
use proc_macro::TokenStream;
use proc_macro_error2::proc_macro_error;
use proc_macro_error3::proc_macro_error;
mod codegen;
mod crate_ident;
-1
View File
@@ -1172,7 +1172,6 @@ impl ParsedNodeFn {
ident: ident.clone(),
colon_token: Some(Default::default()),
bounds,
eq_token: None,
default: None,
}));
self.input.ty = parse_quote!(#ident);
+1 -1
View File
@@ -1,5 +1,5 @@
use crate::parsing::{Implementation, NodeOutputTier, NodeParsedField, ParsedFieldType, ParsedNodeFn, RegularParsedField, output_payload, output_tier};
use proc_macro_error2::{abort_if_dirty, emit_error};
use proc_macro_error3::{abort_if_dirty, emit_error};
use quote::quote;
use syn::spanned::Spanned;
use syn::{GenericParam, Type};
+1 -1
View File
@@ -15,7 +15,7 @@ use math_parser::object::Object;
use math_parser::parser::{MessagePart, ParseError};
use math_parser::reducer::{Reducer, classify_reducer};
use math_parser::value::{Value, Vector2, Vector3};
use rand::{Rng, SeedableRng};
use rand::{RngExt, SeedableRng};
use std::sync::{Arc, Mutex, PoisonError};
use vector_types::Gradient;
+1 -1
View File
@@ -15,7 +15,7 @@ use core_types::misc::{format_f64, parse_f64};
use core_types::{CloneVarArgs, Context, Ctx, ExtractAll, ExtractVarArgs, OwnedContextImpl};
use dyn_any::DynAny;
use glam::DVec2;
use rand::{Rng, SeedableRng};
use rand::{RngExt, SeedableRng};
use unicode_segmentation::UnicodeSegmentation;
// Re-export for convenience
+1 -1
View File
@@ -137,7 +137,7 @@ impl PathBuilder {
let font = run.font();
let font_size = run.font_size();
let normalized_coords = run.normalized_coords().iter().map(|coord| NormalizedCoord::from_bits(*coord)).collect::<Vec<_>>();
let normalized_coords = run.normalized_coords().iter().map(|coord| NormalizedCoord::from_bits(coord.to_bits())).collect::<Vec<_>>();
// TODO: This can be cached for better performance
let font_collection_ref = font.data.as_ref();
+1 -1
View File
@@ -44,7 +44,7 @@ pub fn for_each_styled_glyph_run(layout: &Layout<()>, text: &str, typesetting: T
if is_last_para_line && let Some(correction) = last_line_correction {
let metrics = line.metrics();
let content_advance = metrics.advance - metrics.trailing_whitespace;
let content_advance = metrics.advance - metrics.hanging_advance;
let free_space = alignment_width - content_advance;
match correction {
+1 -1
View File
@@ -21,7 +21,7 @@ use graphic_types::raster_types::{CPU, GPU, Raster};
use graphic_types::{Appearance, Cover, CoverPlacement, Coverage, Graphic, IntoGraphicList, stamp_coverage};
use kurbo::simplify::{SimplifyOptions, simplify_bezpath};
use kurbo::{Affine, BezPath, DEFAULT_ACCURACY, Line, ParamCurve, ParamCurveArclen, PathEl, PathSeg, Shape};
use rand::{Rng, SeedableRng};
use rand::{RngExt, SeedableRng};
use std::collections::hash_map::DefaultHasher;
use std::collections::{HashMap, HashSet};
use vector_types::GradientForm;
+1 -1
View File
@@ -51,7 +51,7 @@ pub fn editor_commands_impl(attr: TokenStream, module: ItemMod) -> syn::Result<T
if let Some(receiver) = signature.receiver() {
return Err(Error::new(receiver.span(), "command functions take no `self`; they are pure `args… -> Message` translations"));
}
if !signature.generics.params.is_empty() || signature.asyncness.is_some() || signature.unsafety.is_some() {
if !signature.generics.params.is_empty() || signature.asyncness.is_some() || matches!(signature.safety, syn::Safety::Unsafe(_)) {
return Err(Error::new(signature.span(), "command functions must be plain non-generic, non-async, safe functions"));
}
+1 -1
View File
@@ -20,7 +20,7 @@ pub fn message_handler_data_attr_impl(attr: TokenStream, input_item: TokenStream
// Extract the message type from the trait path
let trait_path = match &impl_block.trait_ {
Some((_, path, _)) => path,
Some((path, _)) => path,
None => return Err(syn::Error::new(Span::call_site(), "Expected trait implementation")),
};
+1 -1
View File
@@ -16,6 +16,6 @@ workspace = true
[dependencies]
cargo-run = { path = "../.." }
ureq = { version = "3", default-features = false, features = ["rustls"] }
sha2 = { version = "0.10" }
sha2 = { version = "0.11" }
flate2 = { version = "1", default-features = false, features = ["rust_backend"] }
tar = { version = "0.4", default-features = false }
+2 -2
View File
@@ -55,8 +55,8 @@ fn requirements(task: &Task) -> Vec<Requirement> {
args: &["--version"],
name: "Wasm Bindgen",
// NOTICE: keep in sync with the `wasm-bindgen` crate in `Cargo.toml` and the `wasm-bindgen-cli` version pinned in `.github/workflows/build.yml`, `.devcontainer/devcontainer.json`, `.nix/dev.nix`, and `.nix/pkgs/graphite.nix`
version: Some("=0.2.127"),
install: "cargo install -f [email protected]7".into(),
version: Some("=0.2.129"),
install: "cargo install -f [email protected]9".into(),
skip: Some(&|task| matches!(task.target, Target::Cli)),
..Default::default()
},
+1 -1
View File
@@ -16,6 +16,6 @@ workspace = true
[dependencies]
serde = { workspace = true }
toml = "0.8"
toml = "1.1"
anyhow = { workspace = true }
glob = "0.3"
+1 -1
View File
@@ -28,7 +28,7 @@ clap = { workspace = true, features = ["derive"] }
# Other dependencies
image = { version = "0.25", default-features = false, features = ["png"] }
interprocess = "2.4.2"
getrandom = "0.3"
getrandom = "0.4"
[target.'cfg(windows)'.dependencies]
windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Security", "Win32_System_Threading"] }
+5 -8
View File
@@ -1,7 +1,7 @@
//! Starting, reaching, and stopping the session host, which owns the browser so separate invocations can act on the same editor one after another.
use control_protocol::{ClientMessage, Command, CommandResult, HostMessage, PROTOCOL_VERSION};
use interprocess::local_socket::{RecvHalf, SendHalf, Stream, prelude::*};
use interprocess::local_socket::{Stream, prelude::*};
use serde::{Deserialize, Serialize};
use std::io::BufReader;
use std::path::PathBuf;
@@ -36,8 +36,7 @@ enum OpenFailure {
}
pub struct Connection {
receiver: BufReader<RecvHalf>,
sender: SendHalf,
stream: BufReader<Stream>,
next_id: u64,
}
@@ -45,10 +44,8 @@ impl Connection {
fn open(record: &SessionRecord) -> Result<Self, OpenFailure> {
let name = socket::name(&record.session_id).map_err(|_| OpenFailure::Unreachable)?;
let stream = Stream::connect(name).map_err(|_| OpenFailure::Unreachable)?;
let (receiver, sender) = stream.split();
let mut connection = Self {
receiver: BufReader::new(receiver),
sender,
stream: BufReader::new(stream),
next_id: 1,
};
@@ -94,11 +91,11 @@ impl Connection {
}
fn send(&mut self, message: &ClientMessage) -> Result<(), String> {
socket::write_message(&mut self.sender, message)
socket::write_message(&mut self.stream.get_ref(), message)
}
fn receive(&mut self) -> Result<Option<HostMessage>, String> {
socket::read_message(&mut self.receiver)
socket::read_message(&mut self.stream)
}
}
+2 -2
View File
@@ -69,8 +69,8 @@ pub fn run(options: SessionOptions) -> Result<(), String> {
}
fn serve(stream: Stream, state: &HostState) {
let (receiver, mut sender) = stream.split();
let mut receiver = BufReader::new(receiver);
let mut receiver = BufReader::new(&stream);
let mut sender = &stream;
let refusal = match socket::read_message(&mut receiver) {
Ok(Some(ClientMessage::Attach { version, .. })) if version != PROTOCOL_VERSION => Some(format!(
+16
View File
@@ -212,3 +212,19 @@ js = ["/js/page/donate.js"]
</div>
</div>
</section>
<section class="acknowledgments">
<div class="block">
## Acknowledgments
We're grateful to these programs and organizations for the grants and services that help make Graphite possible.
<div class="acknowledgment-logos">
<a href="https://nlnet.nl/commonsfund/"><img src="https://static.graphite.art/content/donate/logo-ngi-zero-commons-fund.svg" width="571" height="80" alt="European Commission, NGI Zero, and NLnet Foundation" /></a>
<a href="https://summerofcode.withgoogle.com/"><img src="https://static.graphite.art/content/donate/logo-google-summer-of-code.svg" width="476" height="80" alt="Google Summer of Code" /></a>
<a href="https://www.blacksmith.sh/"><img src="https://static.graphite.art/content/donate/logo-blacksmith.png" width="234" height="80" alt="CI powered by Blacksmith" /></a>
</div>
</div>
</section>
+25
View File
@@ -458,3 +458,28 @@
.donation-picker:has([value="github"]:checked) :is(.action, .method-note)[data-method="github"] {
display: block;
}
// ===============
// ACKNOWLEDGMENTS
// ===============
.acknowledgments {
.acknowledgment-logos {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: calc(40 * var(--variable-px)) calc(60 * var(--variable-px));
margin-top: calc(40 * var(--variable-px));
a {
min-width: 0;
max-width: 100%;
}
}
img {
display: block;
max-width: 100%;
height: auto;
}
}