Skip to content

Commit 4a0c201

Browse files
authored
Rename editor_api.rs -> editor_wrapper.rs (#3926)
1 parent 087b4cd commit 4a0c201

File tree

7 files changed

+13
-8
lines changed

7 files changed

+13
-8
lines changed

frontend/src/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Svelte components that build the Graphite editor GUI from layouts, panels, widge
66

77
## Managers: `managers/`
88

9-
TypeScript files, constructed by the editor frontend, which manage the input/output of browser APIs and link this functionality with the editor backend. These files subscribe to frontend messages to execute JS APIs, and in response to these APIs or user interactions, they may call functions in the backend (defined in `/frontend/wasm/editor_api.rs`).
9+
TypeScript files, constructed by the editor frontend, which manage the input/output of browser APIs and link this functionality with the editor backend. These files subscribe to frontend messages to execute JS APIs, and in response to these APIs or user interactions, they may call functions in the backend (defined in `/frontend/wasm/editor_wrapper.rs`).
1010

1111
Each manager module stores its dependencies (like `subscriptionsRouter` and `editorWrapper`) in module-level variables and exports a `create*()` and `destroy*()` function pair. `Editor.svelte` calls each `create*()` constructor in its `onMount` and calls each `destroy*()` in its `onDestroy`. Managers replace themselves during HMR updates if they are modified live during development.
1212

@@ -30,7 +30,7 @@ Associates messages from the backend with subscribers in the frontend, and route
3030

3131
## Svelte app entry point: `App.svelte`
3232

33-
The entry point for the Svelte application. Initializes the Wasm module, creates the `EditorWrapper` backend instance and the subscriptions router, and renders `Editor.svelte` once both are ready. The `EditorWrapper` is the wasm-bindgen interface to the Rust editor backend (defined in `/frontend/wasm/editor_api.rs`), providing access to callable backend functions. Both the editor and subscriptions router are passed as props to `Editor.svelte` and set as Svelte contexts for use throughout the component tree.
33+
The entry point for the Svelte application. Initializes the Wasm module, creates the `EditorWrapper` backend instance and the subscriptions router, and renders `Editor.svelte` once both are ready. The `EditorWrapper` is the wasm-bindgen interface to the Rust editor backend (defined in `/frontend/wasm/editor_wrapper.rs`), providing access to callable backend functions. Both the editor and subscriptions router are passed as props to `Editor.svelte` and set as Svelte contexts for use throughout the component tree.
3434

3535
## Editor base instance: `Editor.svelte`
3636

frontend/wasm/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Overview of `/frontend/wasm/`
22

3-
## Wasm wrapper API: `src/editor_api.rs`
3+
## Wasm wrapper API: `src/editor_wrapper.rs`
44

55
Provides bindings for JS to call functions defined in this file, and for `FrontendMessage`s to be sent from Rust back to JS in the form of a callback to the subscription router. This Wasm wrapper crate, since it's written in Rust, is able to call into the Editor crate's codebase and send `FrontendMessage`s back to JS.
66

frontend/wasm/src/helpers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#[cfg(not(feature = "native"))]
22
use crate::EDITOR;
3-
use crate::editor_api::EditorWrapper;
3+
use crate::editor_wrapper::EditorWrapper;
44
use crate::{EDITOR_HAS_CRASHED, EDITOR_WRAPPER};
55
#[cfg(not(feature = "native"))]
66
use editor::application::Editor;

frontend/wasm/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#[macro_use]
55
extern crate log;
66

7-
pub mod editor_api;
7+
pub mod editor_wrapper;
88
pub mod helpers;
99
pub mod native_communication;
1010

@@ -25,7 +25,7 @@ thread_local! {
2525
#[cfg(not(feature = "native"))]
2626
pub static EDITOR: Mutex<Option<editor::application::Editor>> = const { Mutex::new(None) };
2727
pub static MESSAGE_BUFFER: std::cell::RefCell<Vec<Message>> = const { std::cell::RefCell::new(Vec::new()) };
28-
pub static EDITOR_WRAPPER: Mutex<Option<editor_api::EditorWrapper>> = const { Mutex::new(None) };
28+
pub static EDITOR_WRAPPER: Mutex<Option<editor_wrapper::EditorWrapper>> = const { Mutex::new(None) };
2929
pub static PANIC_DIALOG_MESSAGE_CALLBACK: std::cell::RefCell<Option<js_sys::Function>> = const { std::cell::RefCell::new(None) };
3030
}
3131

frontend/wasm/src/native_communication.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::editor_api::EditorWrapper;
1+
use crate::editor_wrapper::EditorWrapper;
22
use crate::helpers::wrapper;
33
use editor::messages::prelude::FrontendMessage;
44
use js_sys::{ArrayBuffer, Uint8Array};

website/content/volunteer/guide/codebase-overview/_index.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ The frontend is the GUI for Graphite which users see and interact with. It is bu
3939

4040
## Crate dependency graph
4141

42+
```sh
43+
# Access this quickly in the future:
44+
cargo run explore deps
45+
```
46+
4247
This diagram shows the structure of the crates that comprise the Graphite codebase and how they depend on each other. Every Arrow points from a crate to another which it depends on.
4348

4449
<div class="crate-hierarchy">
@@ -49,7 +54,7 @@ This diagram shows the structure of the crates that comprise the Graphite codeba
4954

5055
## Frontend/backend communication
5156

52-
Frontend-to-backend communication is achieved through a thin Rust translation layer in [`/frontend/wasm/src/editor_api.rs`](https://github.com/GraphiteEditor/Graphite/tree/master/frontend/wasm/src/editor_api.rs) which wraps the editor backend's Rust-based message system API and provides the TypeScript-compatible API of callable functions. These wrapper functions are compiled by [wasm-bindgen](https://github.com/rustwasm/wasm-bindgen) into autogenerated TS functions that serve as an entry point from TS into the Wasm binary.
57+
Frontend-to-backend communication is achieved through a thin Rust translation layer in [`/frontend/wasm/src/editor_wrapper.rs`](https://github.com/GraphiteEditor/Graphite/tree/master/frontend/wasm/src/editor_wrapper.rs) which wraps the editor backend's Rust-based message system API and provides the TypeScript-compatible API of callable functions. These wrapper functions are compiled by [wasm-bindgen](https://github.com/rustwasm/wasm-bindgen) into autogenerated TS functions that serve as an entry point from TS into the Wasm binary.
5358

5459
Backend-to-frontend communication happens by sending a queue of messages to the frontend message dispatcher. After the TS has called any wrapper API function to get into backend code execution, the editor's business logic runs and queues up each [`FrontendMessage`](https://github.com/GraphiteEditor/Graphite/tree/master/editor/src/messages/frontend/frontend_message.rs) which get mapped from Rust to JavaScript data structures in [`/frontend/src/messages.ts`](https://github.com/GraphiteEditor/Graphite/tree/master/frontend/src/messages.ts). Various TS code subscribes to these messages by calling:
5560

0 commit comments

Comments
 (0)