Remove all use of document indices (#406)

* removed all use of document indicies

* -add u64 support for wasm bridge

* fixed rust formating

* Cleaned up FrontendDocumentState in js-messages

* Tiny tweaks from code review

* - moved more of closeDocumentWithConfirmation to rust
- updated serde_wasm_bindgen to add feature flag

* changed to upsteam version of serde_wasm_bindgen

* cargo fmt

* -fix event propigation on delete
- Js message change class extention to typedef

* changed another typedef

* cargo fmt

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
mfish33
2021-12-24 19:07:19 -05:00
committed by Keavon Chambers
co-authored by Keavon Chambers
parent 1594b9c61d
commit 04c1b2ed03
13 changed files with 213 additions and 184 deletions
+3 -34
View File
@@ -2,10 +2,7 @@ use crate::consts::VIEWPORT_ROTATE_SNAP_INTERVAL;
use glam::{DAffine2, DVec2};
use graphene::layers::{style::ViewMode, BlendMode, Layer, LayerData as DocumentLayerData, LayerDataType};
use graphene::LayerId;
use serde::{
ser::{SerializeSeq, SerializeStruct},
Deserialize, Serialize,
};
use serde::{ser::SerializeStruct, Deserialize, Serialize};
use std::collections::HashMap;
use std::fmt;
@@ -84,39 +81,11 @@ pub fn layer_panel_entry(layer_data: &LayerData, transform: DAffine2, layer: &La
opacity: layer.opacity,
layer_type: (&layer.data).into(),
layer_data: *layer_data,
path: path.into(),
path,
thumbnail,
}
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct Path(Vec<LayerId>);
impl From<Vec<LayerId>> for Path {
fn from(iter: Vec<LayerId>) -> Self {
Self(iter)
}
}
impl Serialize for Path {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
let mut seq = serializer.serialize_seq(Some(self.0.len()))?;
for e in self.0.iter() {
#[cfg(target_arch = "wasm32")]
{
// LayerIds are sent as (u32, u32) because json does not support u64s
let id = ((e >> 32) as u32, (e << 32 >> 32) as u32);
seq.serialize_element(&id)?;
}
#[cfg(not(target_arch = "wasm32"))]
seq.serialize_element(e)?;
}
seq.end()
}
}
#[derive(Debug, Clone, Deserialize, PartialEq)]
pub struct RawBuffer(Vec<u8>);
@@ -152,7 +121,7 @@ pub struct LayerPanelEntry {
pub opacity: f64,
pub layer_type: LayerType,
pub layer_data: LayerData,
pub path: crate::document::layer_panel::Path,
pub path: Vec<LayerId>,
pub thumbnail: String,
}