diff --git a/Cargo.lock b/Cargo.lock
index a1494f3..af3d242 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1659,11 +1659,13 @@ dependencies = [
"futures",
"gpui",
"gpui_platform",
+ "gpui_web",
"image",
"iso_currency",
"isocountry",
"isolang",
"jiff",
+ "js-sys",
"log",
"objc",
"pulldown-cmark",
@@ -1679,6 +1681,8 @@ dependencies = [
"smallvec",
"unicode-segmentation",
"vte",
+ "wasm-bindgen",
+ "web-sys",
"web-time",
"wry",
]
diff --git a/Cargo.toml b/Cargo.toml
index 01c9cfe..c801b67 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -60,6 +60,12 @@ rustix = { version = "1", default-features = false, features = ["std", "fs"] }
[dev-dependencies]
env_logger = "0.11"
+[target.'cfg(target_family = "wasm")'.dev-dependencies]
+gpui_web = { git = "https://github.com/zed-industries/zed", rev = "1a28cff4b409169bac058bca40dfbfeb7621d19b" }
+js-sys = "0.3"
+wasm-bindgen = "0.2"
+web-sys = { version = "0.3", features = ["Location", "UrlSearchParams", "Window"] }
+
[target.'cfg(target_os = "macos")'.dev-dependencies]
core-foundation = "0.10"
core-graphics = "0.24"
@@ -71,6 +77,13 @@ unexpected_cfgs = { level = "warn", check-cfg = ['cfg(feature, values("cargo-cli
[lints.clippy]
all = { level = "warn", priority = -1 }
+# The web gallery: small over fast, one unit so LTO sees everything.
+[profile.web]
+inherits = "release"
+opt-level = "z"
+lto = true
+codegen-units = 1
+
[[example]]
name = "gallery"
path = "examples/gallery/main.rs"
diff --git a/examples/gallery/index.html b/examples/gallery/index.html
new file mode 100644
index 0000000..5442c2e
--- /dev/null
+++ b/examples/gallery/index.html
@@ -0,0 +1,32 @@
+
+
+
+
+
+ Ely Gallery
+
+
+
+
+
+
diff --git a/examples/gallery/main.rs b/examples/gallery/main.rs
index 8c3514b..f9995eb 100644
--- a/examples/gallery/main.rs
+++ b/examples/gallery/main.rs
@@ -1,4 +1,7 @@
+#![cfg_attr(target_family = "wasm", no_main)]
+
/// A file under the gallery's assets, by name.
+#[cfg(not(target_family = "wasm"))]
macro_rules! asset {
($name:literal) => {
concat!(
@@ -9,28 +12,48 @@ macro_rules! asset {
};
}
+/// On the web, the address the site serves it at: the build names the folder.
+#[cfg(target_family = "wasm")]
+macro_rules! asset {
+ ($name:literal) => {
+ concat!(env!("ELY_GALLERY_ASSETS"), $name)
+ };
+}
+
+#[cfg(not(target_family = "wasm"))]
mod capture;
mod pages;
mod probe;
+#[cfg(not(target_family = "wasm"))]
mod script;
mod shell;
+// Native capture alone plays the scripts.
+#[cfg_attr(target_family = "wasm", allow(dead_code))]
+mod step;
+#[cfg(not(target_family = "wasm"))]
mod swipe;
mod ui;
+#[cfg(target_family = "wasm")]
+mod web;
+#[cfg(not(target_family = "wasm"))]
use std::path::PathBuf;
+#[cfg(not(target_family = "wasm"))]
use anyhow::{Context as _, Result, bail};
+#[cfg(not(target_family = "wasm"))]
use ely_gpui_component::Assets;
+use ely_gpui_component::theme::{Mode, Theme};
use gpui::{
- App, AppContext, Bounds, KeyBinding, Menu, MenuItem, TitlebarOptions, WindowBounds,
- WindowHandle, WindowOptions, actions, point, px, size,
+ App, AppContext, Bounds, KeyBinding, Menu, MenuItem, SharedString, TitlebarOptions,
+ WindowBounds, WindowHandle, WindowOptions, actions, point, px, size,
};
actions!(gallery, [Quit, About, LightMode, DarkMode, NewWindow]);
-/// The gallery's menu bar and Dock menu: NativeMenu and JumpList at work. Set before the window opens, whose first frame may draw them.
-fn menus(cx: &mut App) {
- cx.set_menus(vec![
+/// The gallery's menu bar: NativeMenu at work, and what MenuBar draws.
+pub fn app_menus() -> Vec