Graphite/frontend
nat-rix f76b850b9c Fix Imaginate by porting its JS roundtrip code to graph-based async execution in Rust (#1250)
* Create asynchronous rust imaginate node

* Make a first imaginate request via rust

* Implement parsing of imaginate API result image

* Stop refresh timer from affecting imaginate progress requests

* Add cargo-about clarification for rustls-webpki

* Delete imaginate.ts and all uses of its functions

* Add imaginate img2img feature

* Fix imaginate random seed button

* Fix imaginate ui inferring non-custom resolutions

* Fix the imaginate progress indicator

* Remove ImaginatePreferences from being compiled into node graph

* Regenerate imaginate only when hitting button

* Add ability to terminate imaginate requests

* Add imaginate server check feature

* Do not compile wasm_bindgen bindings in graphite_editor for tests

* Address some review suggestions

- move wasm futures dependency in editor to the future-executor crate
- guard wasm-bindgen in editor behind a `wasm` feature flag
- dont make seed number input a slider
- remove poll_server_check from process_message function beginning
- guard wasm related code behind `cfg(target_arch = "wasm32")` instead
  of `cfg(test)`
- Call the imaginate idle states "Ready" and "Done" instead of "Nothing
  to do"
- Call the imaginate uploading state "Uploading Image" instead of
  "Uploading Input Image"
- Remove the EvalSyncNode

* Fix imaginate host name being restored between graphite instances

also change the progress status texts a bit.

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
2023-06-09 09:03:15 +02:00
..
assets Add color choices to the options bar of tools (#1199) 2023-05-08 18:00:10 +08:00
dist Migrate build system from Webpack to Parcel (#1102) 2023-04-25 00:43:27 +02:00
public Prevent browser extensions from recoloring the UI 2023-04-04 18:32:27 -07:00
src Fix Imaginate by porting its JS roundtrip code to graph-based async execution in Rust (#1250) 2023-06-09 09:03:15 +02:00
src-tauri Make the dynamic node graph execution asynchronous (#1218) 2023-05-27 11:48:57 +02:00
wasm Fix Imaginate by porting its JS roundtrip code to graph-based async execution in Rust (#1250) 2023-06-09 09:03:15 +02:00
.eslintrc.js Replace TS relative @ import path (#1087) 2023-03-26 01:39:38 +01:00
.gitignore Migrate build system from Webpack to Parcel (#1102) 2023-04-25 00:43:27 +02:00
.parcelrc Migrate build system from Webpack to Parcel (#1102) 2023-04-25 00:43:27 +02:00
README.md Replace the Vue frontend with Svelte 2023-03-10 03:54:39 -08:00
index.html Minor UI design style revamp 2023-04-27 02:05:45 -07:00
package-lock.json Lay groundwork for directly rendering to the canvas without a cpu roundrip (#1291) 2023-06-07 17:13:21 +02:00
package.json Lay groundwork for directly rendering to the canvas without a cpu roundrip (#1291) 2023-06-07 17:13:21 +02:00
tsconfig.json Migrate build system from Webpack to Parcel (#1102) 2023-04-25 00:43:27 +02:00
webpack.config.ts Migrate build system from Webpack to Parcel (#1102) 2023-04-25 00:43:27 +02:00

README.md

Overview of /frontend/

The Graphite frontend is a web app that provides the presentation for the editor. It displays the GUI based on state from the backend and provides users with interactive widgets that send updates to the backend, which is the source of truth for state information. The frontend is built out of reactive components using the Svelte framework. The backend is written in Rust and compiled to WebAssembly (WASM) to be run in the browser alongside the JS code.

For lack of other options, the frontend is currently written as a web app. Maintaining web compatibility will always be a requirement, but the long-term plan is to port this code to a Rust-based native GUI framework, either written by the Rust community or created by our project if necessary. As a medium-term compromise, we may wrap the web-based frontend in a desktop webview windowing solution like Electron (probably not) or Tauri (probably).

Bundled assets: assets/

Icons and images that are used in components and embedded into the application bundle by the build system using loaders.

Public assets: public/

Static content like favicons that are copied directly into the root of the build output by the build system.

Svelte/TypeScript source: src/

Source code for the web app in the form of Svelte components and TypeScript files.

WebAssembly wrapper: wasm/

Wraps the editor backend codebase (/editor) and provides a JS-centric API for the web app to use unburdened by Rust's complex data types that are incompatible with JS data types. Bindings (JS functions that call into the WASM module) are provided by wasm-bindgen in concert with wasm-pack.

ESLint configurations: .eslintrc.js

ESLint is the tool which enforces style rules on the JS, TS, and Svelte files in our frontend codebase. As it is set up in this config file, ESLint will complain about bad practices and often help reformat code automatically when (in VS Code) the file is saved or npm run lint is executed. (If you don't use VS Code, remember to run this command before committing!) This config file for ESLint sets our style preferences and configures our usage of extensions/plugins for Svelte support, Airbnb's popular catalog of sane defaults, and Prettier's role as a code formatter.

npm ecosystem packages: package.json

While we don't use Node.js as a JS-based server, we do have to rely on its wide ecosystem of packages for our build system toolchain. If you're just getting started, make sure to install the latest LTS copy of Node.js and then run cd frontend && npm install to install these packages on your system. Our project's philosophy on third-party packages is to keep our dependency tree as light as possible, so adding anything new to our package.json should have overwhelming justification. Most of the packages are just development tooling (TypeScript, Webpack, ESLint, Prettier, wasm-pack, and Sass) that run in your console during the build process.

npm package installed versions: package-lock.json

Specifies the exact versions of packages installed in the npm dependency tree. While package.json specifies which packages to install and their minimum/maximum acceptable version numbers, package-lock.json represents the exact versions of each dependency and sub-dependency. Running npm install will grab these exact versions to ensure you are using the same packages as everyone else working on Graphite. npm update will modify package-lock.json to specify newer versions of any updated (sub-)dependencies and download those, as long as they don't exceed the maximum version allowed in package.json. To check for newer versions that exceed the max version, run npm outdated to see a list. Unless you know why you are doing it, try to avoid committing updates to package-lock.json by mistake if your code changes don't pertain to package updates. And never manually modify the file.

TypeScript configurations: tsconfig.json

Basic configuration options for the TypeScript build tool to do its job in our repository.

Webpack configurations: webpack.config.js

We use the Webpack bundler/build system. This file is where we configure Webpack to set up plugins (like wasm-pack and license-checker) and loaders (like for Svelte and SVG files). Part of the license-checker plugin setup includes some functions to format web package licenses, as well as Rust package licenses provided by cargo-about, into a text file that's distributed with the application to provide license notices for third-party code.