Remove most of document-legacy (#1519)

* Remove boolean ops and unused doc-legacy Operations

* Remove Shape legacy layers

* Remove legacy layer Properties panel code

* Remove additional unused doc-legacy Operations

* Removed unused rendering-related legacy-layer code

* Upgrade dep so CI builds

* Remove various additional unused functions and messages

* Remove the LayerData trait

* Remove RenderData struct and usages

* Banish the Operations system

* Further removals
This commit is contained in:
Keavon Chambers 2023-12-19 04:36:19 -08:00
parent c42d030f18
commit 9a7d7de8fa
64 changed files with 330 additions and 5868 deletions

View file

@ -112,7 +112,7 @@ export function createPortfolioState(editor: Editor) {
image.src = blobURL;
await image.decode();
editor.instance.setImageBlobURL(updateImageData.documentId, element.path, element.nodeId, blobURL, image.naturalWidth, image.naturalHeight, element.transform);
// editor.instance.setImageBlobURL(updateImageData.documentId, element.path, element.nodeId, blobURL, image.naturalWidth, image.naturalHeight, element.transform);
});
});
editor.subscriptions.subscribeJsMessage(TriggerRevokeBlobUrl, async (triggerRevokeBlobUrl) => {

View file

@ -10,7 +10,7 @@ export type Editor = Readonly<ReturnType<typeof createEditor>>;
// `wasmImport` starts uninitialized because its initialization needs to occur asynchronously, and thus needs to occur by manually calling and awaiting `initWasm()`
let wasmImport: WebAssembly.Memory | undefined;
export async function updateImage(path: BigUint64Array, nodeId: bigint, mime: string, imageData: Uint8Array, transform: Float64Array, documentId: bigint) {
export async function updateImage(path: BigUint64Array, nodeId: bigint, mime: string, imageData: Uint8Array, _transform: Float64Array, _documentId: bigint) {
const blob = new Blob([imageData], { type: mime });
const blobURL = URL.createObjectURL(blob);
@ -21,10 +21,10 @@ export async function updateImage(path: BigUint64Array, nodeId: bigint, mime: st
await image.decode();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any).editorInstance?.setImageBlobURL(documentId, path, nodeId, blobURL, image.naturalWidth, image.naturalHeight, transform);
// (window as any).editorInstance?.setImageBlobURL(documentId, path, nodeId, blobURL, image.naturalWidth, image.naturalHeight, transform);
}
export async function fetchImage(path: BigUint64Array, nodeId: bigint, mime: string, documentId: bigint, url: string) {
export async function fetchImage(_path: BigUint64Array, _nodeId: bigint, _mime: string, _documentId: bigint, url: string) {
const data = await fetch(url);
const blob = await data.blob();
@ -36,7 +36,7 @@ export async function fetchImage(path: BigUint64Array, nodeId: bigint, mime: str
await image.decode();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(window as any).editorInstance?.setImageBlobURL(documentId, path, nodeId, blobURL, image.naturalWidth, image.naturalHeight, undefined);
// (window as any).editorInstance?.setImageBlobURL(documentId, path, nodeId, blobURL, image.naturalWidth, image.naturalHeight, undefined);
}
const tauri = "__TAURI_METADATA__" in window && import("@tauri-apps/api");

View file

@ -1,12 +1,13 @@
//! This file is where functions are defined to be called directly from JS.
//! It serves as a thin wrapper over the editor backend API that relies
//! on the dispatcher messaging system and more complex Rust data types.
#[allow(clippy::too_many_arguments)]
#[allow(clippy::non_snake_case)]
// This file is where functions are defined to be called directly from JS.
// It serves as a thin wrapper over the editor backend API that relies
// on the dispatcher messaging system and more complex Rust data types.
use crate::helpers::translate_key;
use crate::{Error, EDITOR_HAS_CRASHED, EDITOR_INSTANCES, JS_EDITOR_HANDLES};
use document_legacy::document::LayerId;
use document_legacy::document_metadata::LayerNodeIdentifier;
use document_legacy::LayerId;
use editor::application::generate_uuid;
use editor::application::Editor;
use editor::consts::{FILE_SAVE_SUFFIX, GRAPHITE_DOCUMENT_VERSION};
@ -103,7 +104,6 @@ async fn poll_node_graph_evaluation() {
}
#[wasm_bindgen]
#[allow(clippy::too_many_arguments)]
impl JsEditorHandle {
#[wasm_bindgen(constructor)]
pub fn new(frontend_message_handler_callback: js_sys::Function) -> Self {
@ -575,26 +575,19 @@ impl JsEditorHandle {
self.dispatch(message);
}
/// Sends the blob URL generated by JS to the Image layer
#[wasm_bindgen(js_name = setImageBlobURL)]
pub fn set_image_blob_url(&self, document_id: u64, layer_path: Vec<LayerId>, node_id: Option<NodeId>, blob_url: String, width: f64, height: f64, transform: Option<js_sys::Float64Array>) {
let resolution = (width, height);
let message = PortfolioMessage::SetImageBlobUrl {
document_id,
layer_path: layer_path.clone(),
node_id,
blob_url,
resolution,
};
self.dispatch(message);
if let Some(array) = transform.filter(|array| array.length() == 6) {
let mut transform: [f64; 6] = [0.; 6];
array.copy_to(&mut transform);
let message = document_legacy::Operation::SetLayerTransform { path: layer_path, transform };
self.dispatch(message);
}
}
// /// Sends the blob URL generated by JS to the Image layer
// #[wasm_bindgen(js_name = setImageBlobURL)]
// pub fn set_image_blob_url(&self, document_id: u64, layer_path: Vec<LayerId>, node_id: Option<NodeId>, blob_url: String, width: f64, height: f64, _transform: Option<js_sys::Float64Array>) {
// let resolution = (width, height);
// let message = PortfolioMessage::SetImageBlobUrl {
// document_id,
// layer_path: layer_path.clone(),
// node_id,
// blob_url,
// resolution,
// };
// self.dispatch(message);
// }
/// Notifies the backend that the user connected a node's primary output to one of another node's inputs
#[wasm_bindgen(js_name = connectNodesByLink)]