Migrate remaining node graph data types from Vec to Table (#4067)

* Move Vec<String> to Table<String>

* Remove old VecDVec2

* Move Vec<u8> to Table<u8>

* Move Vec<f64> to Table<f64>

* Move [f64; 4] to Table<f64>

* Move Vec<NodeId> to Table<NodeId>

* Tidy up the TaggedValue variants

* Move Vec<BrushStroke> to Table<BrushStroke>

* Add missing type implementations

* Fix tests

---------
This commit is contained in:
Keavon Chambers
2026-04-28 13:44:25 -07:00
committed by GitHub
parent cf150b5cff
commit b396d17211
25 changed files with 277 additions and 341 deletions

View File

@@ -6,7 +6,7 @@ use canvas_utils::{Canvas, CanvasHandle};
use core_types::WasmNotSend;
#[cfg(target_family = "wasm")]
use core_types::math::bbox::Bbox;
use core_types::table::Table;
use core_types::table::{Table, TableRow};
#[cfg(target_family = "wasm")]
use core_types::transform::Footprint;
use core_types::{Color, Ctx};
@@ -85,14 +85,15 @@ async fn post_request(
#[name("URL")]
url: String,
/// The binary data to include in the body of the POST request.
body: Vec<u8>,
body: Table<u8>,
/// Makes the request run in the background without waiting on a response. This is useful for triggering webhooks without blocking the continued execution of the graph.
discard_result: bool,
#[widget(ParsedWidgetOverride::Custom = "text_area")] headers: String,
) -> String {
let mut header_map = parse_headers(&headers);
header_map.insert("Content-Type", "application/octet-stream".parse().unwrap());
let request = reqwest::Client::new().post(url).body(body).headers(header_map);
let body_bytes: Vec<u8> = body.iter_element_values().copied().collect();
let request = reqwest::Client::new().post(url).body(body_bytes).headers(header_map);
if discard_result {
#[cfg(target_family = "wasm")]
@@ -114,15 +115,15 @@ async fn post_request(
/// Converts a text string to raw binary data. Useful for transmission over HTTP or writing to files.
#[node_macro::node(category("Web Request"), name("String to Bytes"))]
fn string_to_bytes(_: impl Ctx, string: String) -> Vec<u8> {
string.into_bytes()
fn string_to_bytes(_: impl Ctx, string: String) -> Table<u8> {
string.into_bytes().into_iter().map(TableRow::new_from_element).collect()
}
/// Converts extracted raw RGBA pixel data from an input image. Each pixel becomes 4 sequential bytes. Useful for transmission over HTTP or writing to files.
#[node_macro::node(category("Web Request"), name("Image to Bytes"))]
fn image_to_bytes(_: impl Ctx, image: Table<Raster<CPU>>) -> Vec<u8> {
let Some(image) = image.element(0) else { return vec![] };
image.data.iter().flat_map(|color| color.to_rgba8_srgb().into_iter()).collect::<Vec<u8>>()
fn image_to_bytes(_: impl Ctx, image: Table<Raster<CPU>>) -> Table<u8> {
let Some(image) = image.element(0) else { return Table::new() };
image.data.iter().flat_map(|color| color.to_rgba8_srgb()).map(TableRow::new_from_element).collect()
}
/// Loads binary from URLs and local asset paths. Returns a transparent placeholder if the resource fails to load, allowing rendering to continue.
@@ -188,7 +189,6 @@ async fn rasterize<T: WasmNotSend + Clone + 'n>(
where
Table<T>: Render + Clone + graphic_types::IntoGraphicTable,
{
use core_types::table::TableRow;
use glam::{DAffine2, DVec2};
if footprint.transform.matrix2.determinant() == 0. {