diff --git a/.dockerignore b/.dockerignore index 3ea0852..33a5794 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,2 +1,4 @@ target/ .git/ +web/node_modules/ +web/dist/ diff --git a/Cargo.lock b/Cargo.lock index c87a490..c0e518c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -971,11 +971,13 @@ dependencies = [ "getrandom 0.4.3", "lune-core", "rusqlite", + "rust-embed", "serde", "serde_json", "sha2", "tempfile", "tokio", + "ureq", ] [[package]] @@ -1006,6 +1008,16 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "mime_guess" +version = "2.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e" +dependencies = [ + "mime", + "unicase", +] + [[package]] name = "miniz_oxide" version = "0.9.1" @@ -1302,6 +1314,42 @@ dependencies = [ "sqlite-wasm-rs", ] +[[package]] +name = "rust-embed" +version = "8.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19afa5b4b6a611de00bd1bdae6ae6f39084c9399f0679c3f52d8469cf335cc23" +dependencies = [ + "rust-embed-impl", + "rust-embed-utils", + "walkdir", +] + +[[package]] +name = "rust-embed-impl" +version = "8.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0d8afda6374eac59e066abee06d265247ebbaf3006cf878e2879e8356e34053" +dependencies = [ + "mime_guess", + "proc-macro2", + "quote", + "rust-embed-utils", + "syn 2.0.119", + "walkdir", +] + +[[package]] +name = "rust-embed-utils" +version = "8.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d84e8ba78bd384263e5922f084cbe1b081c3b7e69add59c8fb097b879ba968a" +dependencies = [ + "mime_guess", + "sha2", + "walkdir", +] + [[package]] name = "rustix" version = "1.1.6" @@ -1768,6 +1816,12 @@ version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6f5e870be6c3b371b77fe0ee0bafb859fa4964b4404c27de1d380043c4dda20" +[[package]] +name = "unicase" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "357cc3acc6a036009fd6c973ed009037c732d60d0b4f6c673e9041497482a28f" + [[package]] name = "unicode-ident" version = "1.0.27" diff --git a/Dockerfile b/Dockerfile index 122260c..f2db2d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,15 @@ -# Lune hub: one container, data on /data. +# Lune hub: one container, data on /data. The web canvas is built first and embedded in the binary. +FROM node:22-bookworm-slim AS web +WORKDIR /web +COPY web/package.json web/package-lock.json ./ +RUN npm ci --no-audit --no-fund +COPY web/ ./ +RUN npm run build + FROM rust:1.99-bookworm AS build WORKDIR /src COPY . . +COPY --from=web /web/dist ./web/dist RUN cargo build --release -p lunehub FROM debian:bookworm-slim diff --git a/cli/src/main.rs b/cli/src/main.rs index f65cecb..fd4efec 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -88,8 +88,10 @@ enum Command { #[arg(long)] vaults_dir: Option, }, - /// Make a one-time code to add another of your devices + /// Make a one-time code to add another of your devices (or sign in to the canvas on a phone) Pair, + /// Open the team canvas in your browser, already signed in + Open, /// Vaults on the hub Vault { #[command(subcommand)] @@ -297,6 +299,13 @@ fn run_cli(cli: Cli) -> Result<()> { Command::Join { link, name, vaults_dir } => team::join(&mut config, &link, &name, vaults_dir)?, Command::Login { hub, code, name, vaults_dir } => team::login(&mut config, &hub, &code, &name, vaults_dir)?, Command::Pair => team::pair(&config)?, + Command::Open => { + let url = team::link(&config)?.web_link()?; + let opener = if cfg!(target_os = "macos") { "open" } else { "xdg-open" }; + if std::process::Command::new(opener).arg(&url).status().map(|s| !s.success()).unwrap_or(true) { + println!("Open this link in your browser (it works once, for 2 minutes):\n\n {url}"); + } + } Command::Vault { action: VaultCmd::New { name } } => team::vault_new(&mut config, &name)?, Command::Vault { action: VaultCmd::Upload { name, fresh } } => team::vault_upload(&mut config, &name, fresh)?, Command::Invite { person, vaults } => team::invite(&config, &person, &vaults)?, diff --git a/cli/src/team.rs b/cli/src/team.rs index 5ac7c98..a9d72b7 100644 --- a/cli/src/team.rs +++ b/cli/src/team.rs @@ -48,7 +48,7 @@ pub fn login(config: &mut Config, url: &str, code: &str, label: &str, vaults_dir pub fn pair(config: &Config) -> Result<()> { let h = link(config)?; let code = h.pair()?; - println!("On the new device (code works once, for 10 minutes):\n"); + println!("On the new device (or type the code on the canvas sign-in page; works once, for 10 minutes):\n"); println!(" lunesync login --hub {} --code {code} --name ", h.url); Ok(()) } diff --git a/core/src/hub.rs b/core/src/hub.rs index 1a63369..29ed078 100644 --- a/core/src/hub.rs +++ b/core/src/hub.rs @@ -180,6 +180,12 @@ impl HubLink { } impl HubLink { + /// A one-time link (2 minutes) that opens the canvas signed in as this device's person. + pub fn web_link(&self) -> Result { + let v: Value = self.post("/api/web/link", json!({}))?; + Ok(v["url"].as_str().unwrap_or_default().to_string()) + } + pub fn remove(&self, person: &str, vault: &str, without_saving: bool) -> Result { let v: Value = self.post("/api/remove", json!({"person": person, "vault": vault, "without_saving": without_saving}))?; Ok(v["devices"].as_u64().unwrap_or(0) as usize) diff --git a/docs/SPEC.md b/docs/SPEC.md index 03039df..d948283 100644 --- a/docs/SPEC.md +++ b/docs/SPEC.md @@ -153,47 +153,40 @@ Only the current milestone gets detailed below. The next one is detailed when th --- -## 6. Milestone 4 — Access I can take back +## 6. Milestone 5 — Canvas for access -Milestones 1–3 (sync, safety checks, the hub with invites, pairing and roles) are built; their detail lives in the code and tests now. +Milestones 1–4 (sync, safety checks, the hub, taking access back) are built; their detail lives in the code and tests now. The canvas follows Sen's clickable prototype (team canvas artboard) and the X decisions. ### Goal -Taking access back is as clean as giving it. Removing someone from a vault collects their unshared work for a manager to review, then their copy disappears; their other vaults keep working. Removing someone from the team stops everything. A lost laptop can be removed on its own. All from the CLI. +The hub serves a web canvas where access is managed by touch: drag a vault onto a person to grant, pull a ribbon until it snaps to revoke (with Undo), and every gesture has a button in the details panel. Invites and device labels live here too. ### What Sen does ```bash -lunesync remove Alice --vault DevOps # Alice loses DevOps only (A5) -lunesync remove Alice --vault DevOps --without-saving -lunesync device remove "Old laptop" # one device, e.g. lost; --person for someone else's (owner) -lunesync team remove Bob # owner only; asks to type the name (A8) -lunesync team restore Bob # re-enables the account; prints a one-time sign-in link -lunesync handovers # unshared work that came back, and devices still to report in -lunesync handover show|keep|discard 7 -lunesync handover skip 7 # a device that will never come back: delete without saving -lunesync vault set DevOps --delete-from-devices off # A7, on by default +lunesync open # opens the canvas in the browser, already signed in ``` +Or on a phone / another browser: open the hub's address, type a code from `lunesync pair`. + +On the canvas: drag DevOps onto Alice (she gets Edit; change the role in the panel), pull the dot on a ribbon until it pinches and snaps (Undo for 8 s), **Invite person** (name + vaults → a one-time link to copy), rename or remove a device in a person's panel, switch **Float** / **Dock**, create a vault (owner), turn "delete from their devices" on or off per vault. ### Behavior -- **Removing from a vault (A5, A6)**: the membership ends at once and the hub opens a *departure* for each of that person's devices. A device learns about it the next time it checks in (within ~30 s while running; offline devices on reconnect), then: - 1. stops syncing that vault and saves anything unsaved; - 2. makes the folder read-only; - 3. sends everything not yet shared to the hub's **handover area** for that vault. Notes held by the secret check go along with the secret replaced by `[secret removed when leaving]` (P1: the secret itself is never sent or kept); - 4. after the hub confirms receipt, deletes the folder — only if the app created it (marker in `.git/`, A9), never following links out. A folder the app adopted, or a vault with "delete from devices" off (A7), is left in place, read-only and no longer synced. -- A device that was removed can still do exactly one thing until its departures are done: hand over. It can't read or change the vault. -- **Handovers** are reviewed by a manager: **keep** combines them into the vault (same-lines clashes keep both, labeled with the leaving device), **discard** drops them. If nothing was unshared, the departure just completes. `skip` = "Delete without saving" for a pending departure. -- **Removing a device (A1)**: same flow for every vault on that device; afterwards its key stops working. -- **Remove from team (A8)**: owner only, asks for confirmation. Ends every membership (departures as above), removes every device, disables the account (restorable, keeps its name in history). Restore re-enables it with no vaults and a one-time sign-in link for a new device. -- Everything is in the access log (A10). Messages say plainly what can't be recalled (A11): copies made elsewhere stay where they are. +- **Sign-in (decided, §8)**: no passwords. `lunesync open` makes a one-time sign-in link (2 minutes) from a signed-in device; or type a pairing code on the hub's sign-in page. The session cookie lasts 30 days (HttpOnly, SameSite=Strict, Secure on HTTPS); signing out, or removal from the team, ends it. The canvas acts as the person ("Sen (web)" in the access log), never as a device: it holds no vault content. +- **What you see**: the owner sees every vault and person; others see the vaults they're in. Everyone sees the team's people (to grant). Devices are visible to their owner, the team owner, and managers of a vault the person is in. Gestures only work on vaults you manage. +- **Grant** = drop a vault on a person (Edit). Dropping on an invited person who hasn't joined yet adds it to their invite. No confirmation (X2). +- **Revoke** = pull a ribbon's dot until it snaps. The ribbon disappears and an 8 s Undo toast shows; the hub holds the removal until the window passes, so nothing reaches the person's devices before then. Then the M4 flow runs (handover, delete). +- **Panels (X1, X3, X11)**: overview (vaults, people, recent activity for the owner), vault (members with role and Remove, Give access, the delete-from-devices setting), person (devices: rename, remove; vaults). Back navigation remembers where a panel was opened from. Bottom sheet on phones. +- **Look**: X4–X8 as in the prototype — metaball ribbons with the goo filter, identity colors fading vault→person, focus with veils, Float (shared bobbing clock) and Dock, reduced motion respected. Status colors stay unused until M6. +- **Invite link in a browser** shows how to join (`lunesync join --name …`) instead of an error. +- The hub serves the canvas itself (built into the binary); nothing else to deploy. ### Acceptance — Sen acts this out -1. Alice has DevOps and Notes and edits DevOps while offline. Remove her from DevOps; when she reconnects her edit arrives as a handover, her DevOps folder disappears, Notes keeps syncing. -2. `handover show` lists her changes; `keep` brings them into DevOps on every device; another handover is discarded. -3. Remove Bob from the team: all his vaults leave his devices, his device can't do anything after, the access log shows each step. `team restore Bob` lets him back in with no vaults. -4. Remove a device that's switched off: `handover skip`; when it's switched on later, its copy is deleted without anything being sent. -5. A vault with "delete from devices" off: the person's copy stays, read-only, no longer synced. +1. `lunesync open` → the canvas, signed in. A phone signs in with a code. +2. Drag a vault onto a teammate: the vault arrives on their devices. Change their role in the panel. +3. Pull a ribbon until it snaps, press Undo: nothing changed on their devices. Pull again and wait: the M4 removal runs. +4. Invite a person with a vault; they join from the link; they appear on the canvas with their device. +5. Rename and remove a device from the panel; switch Float/Dock; everything works with buttons alone (keyboard). -### Out of scope for M4 -Undo window and gestures (M5, X2). Permanent account deletion (later admin action). Verifying removal in external tools (non-goal for v1). +### Out of scope for M5 +Freshness glow, Nudge, tidy and handover review, remove from team (M6). Desktop app (M7). ## 7. Open questions None open. @@ -204,3 +197,4 @@ Record here: date, what changed, why, which decision number. Example: - 2026-10-28 — Secret detection (open question, P2): our own short list of ~20 high-confidence rules, not an embedded gitleaks-style set. Fewer false alarms, easy to read. (Sen) - 2026-10-29 — Hub storage (open question): plain bare repos on the hub's volume served by the hub itself (device key + role check, then Git's own HTTP backend); no Gitea underneath. (Sen) +- 2026-10-29 — Web canvas sign-in (new): no passwords; a one-time link from `lunesync open` or a pairing code typed on the hub's sign-in page; 30-day session cookie. (Sen) diff --git a/hub/Cargo.toml b/hub/Cargo.toml index 25a9cbd..10bdcef 100644 --- a/hub/Cargo.toml +++ b/hub/Cargo.toml @@ -11,6 +11,7 @@ chrono = "0.4.45" getrandom = "0.4.3" lune-core = { version = "0.1.0", path = "../core" } rusqlite = { version = "0.41.0", features = ["bundled"] } +rust-embed = { version = "8.13.0", features = ["mime-guess"] } serde = { version = "1.0.229", features = ["derive"] } serde_json = "1.0.154" sha2 = "0.11.1" @@ -18,3 +19,4 @@ tokio = { version = "1.54.1", features = ["full"] } [dev-dependencies] tempfile = "3.27.0" +ureq = "3.5.0" diff --git a/hub/build.rs b/hub/build.rs new file mode 100644 index 0000000..30c91cd --- /dev/null +++ b/hub/build.rs @@ -0,0 +1,13 @@ +// The canvas is built from web/ (npm run build) and embedded. Without a build, embed a page that says so. +fn main() { + let dist = std::path::Path::new("../web/dist"); + if !dist.join("index.html").exists() { + std::fs::create_dir_all(dist).unwrap(); + std::fs::write( + dist.join("index.html"), + "Lune

The canvas isn't built yet: run npm run build in web/, then rebuild the hub.

", + ) + .unwrap(); + } + println!("cargo:rerun-if-changed=../web/dist"); +} diff --git a/hub/src/api.rs b/hub/src/api.rs index 101912a..7e9ff04 100644 --- a/hub/src/api.rs +++ b/hub/src/api.rs @@ -74,9 +74,20 @@ pub fn credentials(headers: &HeaderMap) -> Option<(String, String)> { /// The signed-in device, including one that was removed and may only hand over. pub fn authenticate_any(hub: &Hub, headers: &HeaderMap) -> Result { let unknown = || ApiError(StatusCode::UNAUTHORIZED, "this device isn't signed in to the hub".into()); - let (id, key) = credentials(headers).ok_or_else(unknown)?; - let conn = hub.db.lock().unwrap(); - db::caller(&conn, &id, &key)?.ok_or_else(unknown) + if let Some((id, key)) = credentials(headers) { + let conn = hub.db.lock().unwrap(); + return db::caller(&conn, &id, &key)?.ok_or_else(unknown); + } + // The canvas: a session cookie, plus a header other sites can't send (no cross-site requests). + if let Some(token) = crate::web::session_token(headers) { + if headers.get("x-lune").is_none() { + return Err(denied("requests from the canvas need the X-Lune header")); + } + let conn = hub.db.lock().unwrap(); + return db::web_caller(&conn, &token)? + .ok_or_else(|| ApiError(StatusCode::UNAUTHORIZED, "please sign in again".into())); + } + Err(unknown()) } /// The signed-in device, if it still has normal access. diff --git a/hub/src/db.rs b/hub/src/db.rs index 0ec7820..8f09a99 100644 --- a/hub/src/db.rs +++ b/hub/src/db.rs @@ -62,6 +62,19 @@ CREATE TABLE IF NOT EXISTS departures ( created INTEGER NOT NULL, updated INTEGER NOT NULL ); +CREATE TABLE IF NOT EXISTS web_sessions ( + token_hash TEXT PRIMARY KEY, + account_id INTEGER NOT NULL, + expires INTEGER NOT NULL +); +CREATE TABLE IF NOT EXISTS pending_removals ( + id INTEGER PRIMARY KEY, + account_id INTEGER NOT NULL, + vault_id INTEGER NOT NULL, + without_saving INTEGER NOT NULL, + due INTEGER NOT NULL, + by_who TEXT NOT NULL +); CREATE TABLE IF NOT EXISTS log ( id INTEGER PRIMARY KEY, at INTEGER NOT NULL, @@ -151,6 +164,27 @@ pub fn caller(conn: &Connection, device_id: &str, key: &str) -> Result Result> { + Ok(conn + .query_row( + "SELECT a.id, a.name, a.owner, a.disabled = 0 FROM web_sessions s JOIN accounts a ON a.id = s.account_id + WHERE s.token_hash = ?1 AND s.expires > ?2", + params![hash(token), now()], + |r| { + Ok(Caller { + device_id: String::new(), + device_label: "web".into(), + account_id: r.get(0)?, + person: r.get(1)?, + owner: r.get(2)?, + active: r.get(3)?, + }) + }, + ) + .optional()?) +} + /// Creates a device for `account_id`; returns (device id, key). Only the key's hash is kept. pub fn new_device(conn: &Connection, account_id: i64, label: &str) -> Result<(String, String)> { let id = format!("dev_{}", token(10).to_lowercase()); diff --git a/hub/src/leave.rs b/hub/src/leave.rs index 91e9c5e..78cbbf5 100644 --- a/hub/src/leave.rs +++ b/hub/src/leave.rs @@ -34,6 +34,9 @@ pub struct RemoveReq { vault: String, #[serde(default)] without_saving: bool, + /// The canvas's Undo window: hold the removal this long before anything reaches their devices (X2). + #[serde(default)] + delay_seconds: i64, } /// Removes a person from one vault (A5). Their other vaults are untouched. @@ -51,23 +54,89 @@ pub async fn remove(State(hub): State, headers: HeaderMap, Json(req): Js if db::role(&conn, account_id, vault_id)?.is_none() { return Err(bad(format!("{person} isn't a member of {vault}"))); } - conn.execute("DELETE FROM memberships WHERE account_id = ?1 AND vault_id = ?2", [account_id, vault_id])?; - let n = db::depart(&conn, account_id, vault_id, None, req.without_saving)?; - let how = if req.without_saving { " without saving" } else { "" }; - db::log(&conn, &caller.who(), "access removed", &format!("{person} from {vault}{how} ({})", devices_phrase(n)))?; + if req.delay_seconds > 0 { + conn.execute( + "INSERT INTO pending_removals (account_id, vault_id, without_saving, due, by_who) VALUES (?1, ?2, ?3, ?4, ?5)", + params![account_id, vault_id, req.without_saving, db::now() + req.delay_seconds.min(60), caller.who()], + )?; + return Ok(Json(json!({ "pending": conn.last_insert_rowid() }))); + } + let n = apply_removal(&conn, &caller.who(), account_id, vault_id, req.without_saving)?; Ok(Json(json!({ "devices": n }))) } +/// Ends a membership and opens departures for the person's devices (A6). +pub fn apply_removal(conn: &Connection, who: &str, account_id: i64, vault_id: i64, without_saving: bool) -> Result { + let person: String = conn.query_row("SELECT name FROM accounts WHERE id = ?1", [account_id], |r| r.get(0))?; + let vault: String = conn.query_row("SELECT name FROM vaults WHERE id = ?1", [vault_id], |r| r.get(0))?; + if conn.execute("DELETE FROM memberships WHERE account_id = ?1 AND vault_id = ?2", [account_id, vault_id])? == 0 { + return Ok(0); + } + let n = db::depart(conn, account_id, vault_id, None, without_saving)?; + let how = if without_saving { " without saving" } else { "" }; + db::log(conn, who, "access removed", &format!("{person} from {vault}{how} ({})", devices_phrase(n)))?; + Ok(n) +} + +/// Applies removals whose Undo window has passed. Runs every second. +pub fn apply_due_removals(conn: &Connection) -> Result<()> { + let due: Vec<(i64, i64, i64, bool, String)> = { + let mut stmt = conn.prepare("SELECT id, account_id, vault_id, without_saving, by_who FROM pending_removals WHERE due <= ?1")?; + stmt.query_map([db::now()], |r| Ok((r.get(0)?, r.get(1)?, r.get(2)?, r.get(3)?, r.get(4)?)))?.collect::>()? + }; + for (id, account_id, vault_id, without_saving, who) in due { + conn.execute("DELETE FROM pending_removals WHERE id = ?1", [id])?; + apply_removal(conn, &who, account_id, vault_id, without_saving)?; + } + Ok(()) +} + +#[derive(Deserialize)] +pub struct UndoReq { + pending: i64, +} + +/// Undo within the window: the removal never happened, nothing reached their devices. +pub async fn undo_remove(State(hub): State, headers: HeaderMap, Json(req): Json) -> ApiResult { + let caller = authenticate(&hub, &headers)?; + let conn = hub.db.lock().unwrap(); + let found: Option = conn + .query_row("SELECT vault_id FROM pending_removals WHERE id = ?1", [req.pending], |r| r.get(0)) + .optional()?; + let vault_id = found.ok_or_else(|| bad("too late to undo — the removal already went through"))?; + if !can_manage(&conn, &caller, vault_id)? { + return Err(denied("you need Manage on that vault")); + } + conn.execute("DELETE FROM pending_removals WHERE id = ?1", [req.pending])?; + Ok(Json(json!({}))) +} + #[derive(Deserialize)] pub struct DeviceRemoveReq { + #[serde(default)] label: String, person: Option, + /// The canvas names devices by id. + device_id: Option, } /// Removes one device (A1): it hands over and leaves every vault, then its key stops working. pub async fn remove_device(State(hub): State, headers: HeaderMap, Json(req): Json) -> ApiResult { let caller = authenticate(&hub, &headers)?; let conn = hub.db.lock().unwrap(); + let mut req = req; + if let Some(id) = &req.device_id { + let (label, person): (String, String) = conn + .query_row( + "SELECT d.label, a.name FROM devices d JOIN accounts a ON a.id = d.account_id WHERE d.id = ?1 AND d.removed = 0", + [id], + |r| Ok((r.get(0)?, r.get(1)?)), + ) + .optional()? + .ok_or_else(|| bad("no such device"))?; + req.label = label; + req.person = Some(person); + } let (account_id, person) = match &req.person { Some(p) if !p.eq_ignore_ascii_case(&caller.person) => { if !caller.owner { @@ -133,6 +202,8 @@ pub async fn team_remove(State(hub): State, headers: HeaderMap, Json(req tx.execute("UPDATE devices SET removed = 1 WHERE account_id = ?1", [account_id])?; tx.execute("UPDATE accounts SET disabled = 1 WHERE id = ?1", [account_id])?; tx.execute("DELETE FROM invites WHERE person = ?1 AND used IS NULL", [&person])?; + tx.execute("DELETE FROM web_sessions WHERE account_id = ?1", [account_id])?; + tx.execute("DELETE FROM pending_removals WHERE account_id = ?1", [account_id])?; let devices: Vec = { let mut stmt = tx.prepare("SELECT id FROM devices WHERE account_id = ?1")?; stmt.query_map([account_id], |r| r.get(0))?.collect::>()? diff --git a/hub/src/main.rs b/hub/src/main.rs index caad264..6ab059a 100644 --- a/hub/src/main.rs +++ b/hub/src/main.rs @@ -5,6 +5,7 @@ mod db; mod git; mod hook; mod leave; +mod web; use anyhow::Result; use axum::Router; @@ -63,6 +64,18 @@ async fn serve() -> Result<()> { } let hub = Arc::new(api::Hub { db: Mutex::new(conn), data, url: url.clone() }); + // Removals made on the canvas wait out their Undo window, then go through. + let ticker = hub.clone(); + tokio::spawn(async move { + let mut every = tokio::time::interval(std::time::Duration::from_secs(1)); + loop { + every.tick().await; + let conn = ticker.db.lock().unwrap(); + if let Err(e) = leave::apply_due_removals(&conn) { + eprintln!("hub error: {e:#}"); + } + } + }); let app = Router::new() .route("/api/join", post(api::join)) .route("/api/login", post(api::login)) @@ -84,8 +97,17 @@ async fn serve() -> Result<()> { .route("/api/handovers", get(leave::handovers)) .route("/api/handovers/show", post(leave::handover_show)) .route("/api/handovers/decide", post(leave::handover_decide)) + .route("/api/remove/undo", post(leave::undo_remove)) + .route("/api/web/signin", post(web::signin)) + .route("/api/web/link", post(web::link)) + .route("/api/web/signout", post(web::signout)) + .route("/api/canvas", get(web::canvas)) + .route("/api/invites/grant", post(web::invite_grant)) + .route("/api/devices/rename", post(web::rename_device)) + .route("/signin/{token}", get(web::signin_link)) .route("/git/{repo}/{*rest}", any(git::serve)) .route("/health", get(|| async { "ok" })) + .fallback(web::static_files) .layer(DefaultBodyLimit::disable()) .with_state(hub); let listener = tokio::net::TcpListener::bind(&listen).await?; diff --git a/hub/src/web.rs b/hub/src/web.rs new file mode 100644 index 0000000..605b28b --- /dev/null +++ b/hub/src/web.rs @@ -0,0 +1,284 @@ +//! The web canvas (M5): signing in without passwords, the canvas's state, and serving the app itself. + +use crate::api::{ApiError, ApiResult, Shared, authenticate, bad, can_manage, denied}; +use crate::db; +use axum::Json; +use axum::extract::{Path, State}; +use axum::http::{HeaderMap, HeaderValue, StatusCode, Uri, header}; +use axum::response::{IntoResponse, Response}; +use rusqlite::{Connection, OptionalExtension, params}; +use serde::Deserialize; +use serde_json::{Value, json}; + +const SESSION_DAYS: i64 = 30; + +#[derive(rust_embed::RustEmbed)] +#[folder = "../web/dist"] +struct Assets; + +/// The session cookie's value, if the request carries one. +pub fn session_token(headers: &HeaderMap) -> Option { + let cookies = headers.get(header::COOKIE)?.to_str().ok()?; + cookies.split(';').find_map(|c| c.trim().strip_prefix("lune_session=").map(String::from)) +} + +fn session_cookie(hub: &crate::api::Hub, token: &str, max_age: i64) -> HeaderValue { + let secure = if hub.url.starts_with("https://") { "; Secure" } else { "" }; + HeaderValue::from_str(&format!("lune_session={token}; Path=/; HttpOnly; SameSite=Strict; Max-Age={max_age}{secure}")).unwrap() +} + +/// Starts a 30-day canvas session for `account_id` and returns the cookie to set. +fn start_session(hub: &crate::api::Hub, conn: &Connection, account_id: i64, how: &str) -> Result { + let disabled: bool = conn.query_row("SELECT disabled FROM accounts WHERE id = ?1", [account_id], |r| r.get(0))?; + if disabled { + return Err(denied("this account was removed from the team")); + } + let token = db::token(40); + conn.execute( + "INSERT INTO web_sessions (token_hash, account_id, expires) VALUES (?1, ?2, ?3)", + params![db::hash(&token), account_id, db::now() + SESSION_DAYS * 86400], + )?; + let person: String = conn.query_row("SELECT name FROM accounts WHERE id = ?1", [account_id], |r| r.get(0))?; + db::log(conn, &format!("{person} (web)"), "signed in", how)?; + Ok(session_cookie(hub, &token, SESSION_DAYS * 86400)) +} + +/// Consumes a pairing code (or one-time sign-in token); returns its account. +fn use_code(conn: &Connection, code: &str) -> Result { + let found: Option<(i64, i64, Option)> = conn + .query_row( + "SELECT account_id, expires, used FROM pair_codes WHERE code_hash = ?1", + [db::hash(code)], + |r| Ok((r.get(0)?, r.get(1)?, r.get(2)?)), + ) + .optional()?; + match found { + Some((a, expires, None)) if expires >= db::now() => { + conn.execute("UPDATE pair_codes SET used = ?1 WHERE code_hash = ?2", params![db::now(), db::hash(code)])?; + Ok(a) + } + Some((_, _, Some(_))) => Err(denied("that code was already used — make a new one with `lunesync pair`")), + Some(_) => Err(denied("that code has expired — make a new one with `lunesync pair`")), + None => Err(denied("that code isn't valid")), + } +} + +#[derive(Deserialize)] +pub struct SigninReq { + code: String, +} + +/// Sign in by typing a pairing code from one of your devices. +pub async fn signin(State(hub): State, Json(req): Json) -> Result { + let code: String = req.code.chars().filter(|c| c.is_ascii_alphanumeric()).collect::().to_uppercase(); + let conn = hub.db.lock().unwrap(); + let account_id = use_code(&conn, &code)?; + let cookie = start_session(&hub, &conn, account_id, "with a code")?; + Ok(([(header::SET_COOKIE, cookie)], Json(json!({}))).into_response()) +} + +/// `lunesync open`: a one-time link (2 minutes) that signs the browser in as this device's person. +pub async fn link(State(hub): State, headers: HeaderMap) -> ApiResult { + let caller = authenticate(&hub, &headers)?; + if caller.device_id.is_empty() { + return Err(bad("open the canvas from a device")); + } + let token = db::token(40); + let conn = hub.db.lock().unwrap(); + conn.execute( + "INSERT INTO pair_codes (code_hash, account_id, expires) VALUES (?1, ?2, ?3)", + params![db::hash(&token), caller.account_id, db::now() + 120], + )?; + Ok(Json(json!({ "url": format!("{}/signin/{token}", hub.url) }))) +} + +/// Following the one-time link: set the session and go to the canvas. +pub async fn signin_link(State(hub): State, Path(token): Path) -> Response { + let conn = hub.db.lock().unwrap(); + let result = use_code(&conn, &token).and_then(|a| start_session(&hub, &conn, a, "from a device")); + match result { + Ok(cookie) => (StatusCode::SEE_OTHER, [(header::LOCATION, HeaderValue::from_static("/")), (header::SET_COOKIE, cookie)]).into_response(), + Err(_) => (StatusCode::SEE_OTHER, [(header::LOCATION, HeaderValue::from_static("/signin?expired=1"))]).into_response(), + } +} + +pub async fn signout(State(hub): State, headers: HeaderMap) -> Response { + if let Some(token) = session_token(&headers) { + let conn = hub.db.lock().unwrap(); + let _ = conn.execute("DELETE FROM web_sessions WHERE token_hash = ?1", [db::hash(&token)]); + } + ([(header::SET_COOKIE, session_cookie(&hub, "", 0))], Json(json!({}))).into_response() +} + +/// Everything the canvas shows, limited to what this person may see. +pub async fn canvas(State(hub): State, headers: HeaderMap) -> ApiResult { + let caller = authenticate(&hub, &headers)?; + let conn = hub.db.lock().unwrap(); + + let vault_rows: Vec<(i64, String, bool)> = { + let sql = if caller.owner { + "SELECT id, name, delete_from_devices FROM vaults ORDER BY created, id" + } else { + "SELECT v.id, v.name, v.delete_from_devices FROM vaults v JOIN memberships m ON m.vault_id = v.id + WHERE m.account_id = ?1 ORDER BY v.created, v.id" + }; + let mut stmt = conn.prepare(sql)?; + let map = |r: &rusqlite::Row| Ok((r.get(0)?, r.get(1)?, r.get(2)?)); + if caller.owner { stmt.query_map([], map)?.collect::>()? } else { stmt.query_map([caller.account_id], map)?.collect::>()? } + }; + let mut vaults = vec![]; + let mut managed = vec![]; + for (id, name, delete_files) in &vault_rows { + let manage = can_manage(&conn, &caller, *id)?; + if manage { + managed.push(*id); + } + vaults.push(json!({ "id": format!("v{id}"), "name": name, "can_manage": manage, "delete_from_devices": delete_files })); + } + let visible: Vec = vault_rows.iter().map(|v| v.0).collect(); + + let mut members = vec![]; + { + let mut stmt = conn.prepare("SELECT vault_id, account_id, role FROM memberships")?; + let rows: Vec<(i64, i64, String)> = stmt.query_map([], |r| Ok((r.get(0)?, r.get(1)?, r.get(2)?)))?.collect::>()?; + for (v, a, role) in rows.into_iter().filter(|r| visible.contains(&r.0)) { + members.push(json!({ "vault": format!("v{v}"), "person": format!("a{a}"), "role": role })); + } + } + + let mut people = vec![]; + { + let mut stmt = conn.prepare("SELECT id, name, owner FROM accounts WHERE disabled = 0 ORDER BY created, id")?; + let rows: Vec<(i64, String, bool)> = stmt.query_map([], |r| Ok((r.get(0)?, r.get(1)?, r.get(2)?)))?.collect::>()?; + for (id, name, owner) in rows { + // Devices: your own, the owner sees all, managers see their members' (blueprint J6). + let shares_managed = members.iter().any(|m| { + m["person"] == format!("a{id}") && managed.iter().any(|v| m["vault"] == format!("v{v}")) + }); + let devices: Vec = if id == caller.account_id || caller.owner || shares_managed { + let mut d = conn.prepare("SELECT id, label FROM devices WHERE account_id = ?1 AND removed = 0 ORDER BY created")?; + d.query_map([id], |r| Ok(json!({ "id": r.get::<_, String>(0)?, "label": r.get::<_, String>(1)? })))? + .collect::>()? + } else { + vec![] + }; + people.push(json!({ "id": format!("a{id}"), "name": name, "owner": owner, "invited": false, "devices": devices })); + } + } + + // People invited but not joined yet show up too, with the vaults their invite carries. + { + let mut stmt = conn.prepare( + "SELECT person, grants FROM invites WHERE used IS NULL AND owner = 0 AND account_id IS NULL AND expires > ?1 ORDER BY rowid", + )?; + let rows: Vec<(String, String)> = stmt.query_map([db::now()], |r| Ok((r.get(0)?, r.get(1)?)))?.collect::>()?; + for (person, grants) in rows { + let grants: Vec<(i64, String)> = serde_json::from_str(&grants).unwrap_or_default(); + if !caller.owner && !grants.iter().any(|(v, _)| managed.contains(v)) { + continue; + } + let key = format!("i:{person}"); + for (v, role) in grants.iter().filter(|(v, _)| visible.contains(v)) { + members.push(json!({ "vault": format!("v{v}"), "person": key, "role": role })); + } + people.push(json!({ "id": key, "name": person, "owner": false, "invited": true, "devices": [] })); + } + } + + let pending: Vec = { + let mut stmt = conn.prepare("SELECT id, vault_id, account_id FROM pending_removals")?; + let rows: Vec<(i64, i64, i64)> = stmt.query_map([], |r| Ok((r.get(0)?, r.get(1)?, r.get(2)?)))?.collect::>()?; + rows.into_iter() + .filter(|r| visible.contains(&r.1)) + .map(|(id, v, a)| json!({ "id": id, "vault": format!("v{v}"), "person": format!("a{a}") })) + .collect() + }; + + Ok(Json(json!({ + "me": { "id": format!("a{}", caller.account_id), "person": caller.person, "owner": caller.owner }, + "vaults": vaults, "people": people, "members": members, "pending": pending + }))) +} + +#[derive(Deserialize)] +pub struct InviteGrantReq { + person: String, + vault: String, + role: Option, + #[serde(default)] + remove: bool, +} + +/// Dropping a vault on someone invited but not joined yet: add it to (or take it off) their invite. +pub async fn invite_grant(State(hub): State, headers: HeaderMap, Json(req): Json) -> ApiResult { + let caller = authenticate(&hub, &headers)?; + let conn = hub.db.lock().unwrap(); + let (vault_id, vault) = db::vault_id(&conn, &req.vault)?.ok_or_else(|| bad(format!("no vault named {}", req.vault)))?; + if !can_manage(&conn, &caller, vault_id)? { + return Err(denied(format!("you need Manage on {vault} to give access to it"))); + } + let (token_hash, grants): (String, String) = conn + .query_row( + "SELECT token_hash, grants FROM invites WHERE person = ?1 AND used IS NULL AND account_id IS NULL AND expires > ?2", + params![req.person.trim(), db::now()], + |r| Ok((r.get(0)?, r.get(1)?)), + ) + .optional()? + .ok_or_else(|| bad(format!("no open invite for {}", req.person.trim())))?; + let mut grants: Vec<(i64, String)> = serde_json::from_str(&grants).unwrap_or_default(); + grants.retain(|(v, _)| *v != vault_id); + let role = req.role.unwrap_or_else(|| "edit".into()).to_lowercase(); + if !["read", "edit", "manage"].contains(&role.as_str()) { + return Err(bad("roles are read, edit or manage")); + } + if !req.remove { + grants.push((vault_id, role.clone())); + } + conn.execute("UPDATE invites SET grants = ?1 WHERE token_hash = ?2", params![serde_json::to_string(&grants).unwrap(), token_hash])?; + let what = if req.remove { format!("{vault} taken off") } else { format!("{vault}: {role}") }; + db::log(&conn, &caller.who(), "invite changed", &format!("for {} ({what})", req.person.trim()))?; + Ok(Json(json!({}))) +} + +#[derive(Deserialize)] +pub struct RenameReq { + device_id: String, + label: String, +} + +/// Renames a device: your own, or anyone's for the team owner. +pub async fn rename_device(State(hub): State, headers: HeaderMap, Json(req): Json) -> ApiResult { + let caller = authenticate(&hub, &headers)?; + let label = req.label.trim(); + if label.is_empty() || label.len() > 40 { + return Err(bad("a device label needs 1–40 characters")); + } + let conn = hub.db.lock().unwrap(); + let (account_id, old): (i64, String) = conn + .query_row("SELECT account_id, label FROM devices WHERE id = ?1 AND removed = 0", [&req.device_id], |r| Ok((r.get(0)?, r.get(1)?))) + .optional()? + .ok_or_else(|| bad("no such device"))?; + if account_id != caller.account_id && !caller.owner { + return Err(denied("you can only rename your own devices")); + } + conn.execute("UPDATE devices SET label = ?1 WHERE id = ?2", params![label, req.device_id])?; + db::log(&conn, &caller.who(), "device renamed", &format!("{old} → {label}"))?; + Ok(Json(json!({}))) +} + +/// The canvas app: real files by path, everything else is the app's own page (it routes itself). +pub async fn static_files(uri: Uri) -> Response { + let path = uri.path().trim_start_matches('/'); + let file = Assets::get(path).map(|f| (path.to_string(), f)).or_else(|| Assets::get("index.html").map(|f| ("index.html".into(), f))); + match file { + Some((name, f)) => { + let cache = if name.starts_with("assets/") { "public, max-age=31536000, immutable" } else { "no-cache" }; + ( + [(header::CONTENT_TYPE, f.metadata.mimetype().to_string()), (header::CACHE_CONTROL, cache.to_string())], + f.data.into_owned(), + ) + .into_response() + } + None => (StatusCode::NOT_FOUND, "the canvas wasn't built into this hub").into_response(), + } +} diff --git a/hub/tests/hub.rs b/hub/tests/hub.rs index 54ebfe1..06bef28 100644 --- a/hub/tests/hub.rs +++ b/hub/tests/hub.rs @@ -254,3 +254,60 @@ fn taking_access_back() { assert!(log.iter().any(|a| a == action), "missing {action} in {log:?}"); } } + +// ---- Milestone 5: the canvas's sessions and the Undo window ---- + +#[test] +fn canvas_session_and_undo_window() { + let _turn = SERIAL.lock().unwrap_or_else(|e| e.into_inner()); + let tmp = tempfile::TempDir::new().unwrap(); + let (_hub, url, owner_link) = start_hub(&tmp.path().join("data")); + let (_, sen_w) = hub::join(&owner_link, "Codex").unwrap(); + let codex = as_device(&url, &sen_w); + codex.create_vault("DevOps").unwrap(); + let link = codex.invite("Alice", &[("DevOps".into(), "edit".into())]).unwrap(); + hub::join(&link, "Alice laptop").unwrap(); + as_device(&url, &sen_w); + + let agent: ureq::Agent = ureq::Agent::config_builder().http_status_as_error(false).build().into(); + // Sign in with a pairing code: the browser gets a session cookie. + let res = agent.post(format!("{url}/api/web/signin")).send_json(serde_json::json!({ "code": codex.pair().unwrap() })).unwrap(); + assert_eq!(res.status(), 200); + let cookie = res.headers().get("set-cookie").unwrap().to_str().unwrap().to_string(); + assert!(cookie.contains("HttpOnly") && cookie.contains("SameSite=Strict"), "{cookie}"); + let session = cookie.split(';').next().unwrap().to_string(); + + // Without the canvas header, a cookie alone gets nothing (no cross-site requests). + let res = agent.get(format!("{url}/api/canvas")).header("Cookie", &session).call().unwrap(); + assert_eq!(res.status(), 403); + let canvas = |agent: &ureq::Agent| -> serde_json::Value { + agent.get(format!("{url}/api/canvas")).header("Cookie", &session).header("X-Lune", "1").call().unwrap().body_mut().read_json().unwrap() + }; + let c = canvas(&agent); + assert_eq!(c["me"]["person"], "Sen"); + assert_eq!(c["members"].as_array().unwrap().len(), 2); + + let post = |path: &str, body: serde_json::Value| -> serde_json::Value { + agent.post(format!("{url}{path}")).header("Cookie", &session).header("X-Lune", "1").send_json(body).unwrap().body_mut().read_json().unwrap() + }; + let alice_has_devops = || codex.members("DevOps").unwrap().iter().any(|m| m.person == "Alice"); + + // Pull the ribbon, then Undo inside the window: nothing happened. + let pending = post("/api/remove", serde_json::json!({"person": "Alice", "vault": "DevOps", "delay_seconds": 2}))["pending"].as_i64().unwrap(); + assert!(alice_has_devops(), "still a member during the Undo window"); + post("/api/remove/undo", serde_json::json!({ "pending": pending })); + std::thread::sleep(std::time::Duration::from_millis(3500)); + assert!(alice_has_devops()); + + // Pull again and let the window pass: the removal goes through. + post("/api/remove", serde_json::json!({"person": "Alice", "vault": "DevOps", "delay_seconds": 1})); + std::thread::sleep(std::time::Duration::from_millis(3000)); + assert!(!alice_has_devops()); + let undo = post("/api/remove/undo", serde_json::json!({ "pending": pending })); + assert!(undo["error"].as_str().unwrap().contains("too late")); + + // Signing out ends the session. + post("/api/web/signout", serde_json::json!({})); + let res = agent.get(format!("{url}/api/canvas")).header("Cookie", &session).header("X-Lune", "1").call().unwrap(); + assert_eq!(res.status(), 401); +} diff --git a/web/.gitignore b/web/.gitignore new file mode 100644 index 0000000..b947077 --- /dev/null +++ b/web/.gitignore @@ -0,0 +1,2 @@ +node_modules/ +dist/ diff --git a/web/index.html b/web/index.html new file mode 100644 index 0000000..c8ba912 --- /dev/null +++ b/web/index.html @@ -0,0 +1,14 @@ + + + + + +Lune · Team canvas + + + + +
+ + + diff --git a/web/package-lock.json b/web/package-lock.json new file mode 100644 index 0000000..4c7b848 --- /dev/null +++ b/web/package-lock.json @@ -0,0 +1,1742 @@ +{ + "name": "lune-canvas", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "lune-canvas", + "version": "0.1.0", + "dependencies": { + "react": "18.3.1", + "react-dom": "18.3.1" + }, + "devDependencies": { + "@types/react": "18.3.12", + "@types/react-dom": "18.3.1", + "@vitejs/plugin-react": "4.3.4", + "typescript": "5.6.3", + "vite": "5.4.11" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.29.7.tgz", + "integrity": "sha512-Aup7aUOfpbAUg2ROOJN6Iw5f9DMBlzu0mIkm/malLQFN/YQgO48wCj0Kxa3sEHJvPVFg7siR+qRInwXd2qhQKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-validator-identifier": "^7.29.7", + "js-tokens": "^4.0.0", + "picocolors": "^1.1.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.29.7.tgz", + "integrity": "sha512-locTkQyKvwIEgBzVrn8693ebc97F2U8ZHjbXwDXJ5Fn2TCpNwTlKcaKLkdHop5c/icOFE7qt7Q9JC5hnKNa6Gg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.29.7.tgz", + "integrity": "sha512-RgHBCvtjbOK2gXSNBNIkNoEc9qoVEtau3hj8gEqKQuL3HZAibKarWFEI3Lfm6EYKkLalOh8eSrj9b+ch9H/VBA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.7", + "@babel/helper-compilation-targets": "^7.29.7", + "@babel/helper-module-transforms": "^7.29.7", + "@babel/helpers": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/template": "^7.29.7", + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7", + "@jridgewell/remapping": "^2.3.5", + "convert-source-map": "^2.0.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.3", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/generator": { + "version": "7.29.8", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.29.8.tgz", + "integrity": "sha512-gZbepsdh3WDtgZKWL+vTPh71LSBrm/Y4/QDZBVCcYfmeTEEuoOYwlSy+G1StfJg+/Zy550u/3TATbm7qDbbMtg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.29.8", + "@babel/types": "^7.29.8", + "@jridgewell/gen-mapping": "^0.3.12", + "@jridgewell/trace-mapping": "^0.3.28", + "jsesc": "^3.0.2" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.29.7.tgz", + "integrity": "sha512-wem6WaBj4NaVYVdNhLPPVacES6ZJ+KBBfSkTMD3YZxbP3rm3Di85tJU5ljaUNhaOynt+Aj0xruhYuzQBt8n71g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/compat-data": "^7.29.7", + "@babel/helper-validator-option": "^7.29.7", + "browserslist": "^4.24.0", + "lru-cache": "^5.1.1", + "semver": "^6.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-globals": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-globals/-/helper-globals-7.29.7.tgz", + "integrity": "sha512-3nQVUAtvkKH9zahfWgw96Jc/uFOmjACE1kQz82E2lqWmHBgjzbNlsC22nuQTfahmWeQtTq5nQ/4Nnd2A1wj4zA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.29.7.tgz", + "integrity": "sha512-ejHwrQQYcm9xnTivShn2IDOlIzInN34AXskvq9QicvCtEzq1Vzclu/tKF8Jq1Cg8JG2GL6/EmjgsCT7lXepE3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/traverse": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.29.7.tgz", + "integrity": "sha512-UPUVSyXbOh627KiCIGQSgwWzGeBKLkaJ9PJEdrngIwMSzxLR4jS4+f1f1jb7VzBbg8nFLaYotvVPFCTqdrmTAg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-module-imports": "^7.29.7", + "@babel/helper-validator-identifier": "^7.29.7", + "@babel/traverse": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.29.7.tgz", + "integrity": "sha512-G7sHYigPY17oO5SYWnfD/0MTBwVR781S/JI643e/JhUYgVgWE/61SoW3NH9KWUKyKq5LVh3npif99Wkt6j86Jw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.29.11", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.29.11.tgz", + "integrity": "sha512-snZbO7MEDOof+hvNa97EjEY7qD7h2kwvQr5AJC3ZhQudKW5dnej6k3kP9NQV88hJwaS8vDqRLFo9rivLEhle2g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.29.7.tgz", + "integrity": "sha512-qehxGkRj55h/ff8EMaJ+cYhyaKlHIxqYDn682wQD7RNp9UujOQsHog2uS0r2vzr4pW+sXf90NeeayjcNaX3fFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.29.7.tgz", + "integrity": "sha512-N9ZErrD+yW5geCDtBqnOoxmR8+tNKiGuxKlDpuJxfsqpa2dFcexaziGAE/qoHLiDDreVNMupxGmSoNlyvsA3gw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.29.10", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.29.10.tgz", + "integrity": "sha512-EMCx3AGZ3WfAl6ht7AyQoPm2Lh+BGYEMdc4Q6Hf7uSCDOZFuLq44qNwL+iaim8VlyYhRAo4X43+weadK8ZB4Yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.8" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.29.11", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.11.tgz", + "integrity": "sha512-OZ6+oaK7GMyg3IfCpj8JOmn8n+w2rJbDT0LLfVDTLb1ZFeKDh3AiNELgCMUw175IJHSkLl74hG0M0VLsvx+gag==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.29.11" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-self": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.29.7.tgz", + "integrity": "sha512-TL0hMc9xzy86VD31nUiwzd5otRAcyEPcsegCxolO0PvcXuH1v0kECe/UIznYFihpkvU5wg/jk4v0TTEFfm53fw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-transform-react-jsx-source": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.29.7.tgz", + "integrity": "sha512-06IyK09H3wi4cGbhDBwp5gUGo0IKtnYa8tyTiephirPCK6fbobVGiXMMI5zLQ4aKEYP3wZ3ArU44o+8KMrSG/Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-plugin-utils": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.29.7", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.29.7.tgz", + "integrity": "sha512-puq+Gf35oI24FeN11LkoUQFqv9uwNeWpxXZi/Ji3rRIoKAzKnxRaZ+Gkj0vKS9ZCiTESfng1N9LyOyXvo+m+Gg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/parser": "^7.29.7", + "@babel/types": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.29.10", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.29.10.tgz", + "integrity": "sha512-B3lYAs2nkKskbgQ1nfy8Ma9ao9Q1rntTAQHrzzyDuj+TSO+X3le6PfWwqDvodsb+OumE10eMFfuMCTQSQ5iuIQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.29.7", + "@babel/generator": "^7.29.8", + "@babel/helper-globals": "^7.29.7", + "@babel/parser": "^7.29.9", + "@babel/template": "^7.29.7", + "@babel/types": "^7.29.8", + "debug": "^4.3.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.29.11", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.11.tgz", + "integrity": "sha512-WCsemW40Cpc6gouC1SrY6PBaZ+oLRlEVY9XBvZBI7il/HyUrb2nJ505wE1MHEFyDZNnrWDEuy4jL50WVHfTTSQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.29.11", + "@babel/helper-validator-identifier": "^7.29.7" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", + "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", + "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", + "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", + "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", + "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", + "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", + "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", + "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", + "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", + "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", + "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", + "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", + "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", + "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", + "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", + "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", + "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", + "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", + "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", + "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", + "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", + "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", + "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.13", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz", + "integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/remapping": { + "version": "2.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz", + "integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@napi-rs/lzma-linux-x64-gnu": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/@napi-rs/lzma-linux-x64-gnu/-/lzma-linux-x64-gnu-1.5.1.tgz", + "integrity": "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^22.20 || ^24.12 || >=25" + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.66.0.tgz", + "integrity": "sha512-7y4XeoUHPecjfUDRmap8U0q6bjfLAPn7uOGT8BKyqy8uNDOjsGS8rlBhOx6sZLVwwjN6hapvGl2mW9/IS6UNww==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.66.0.tgz", + "integrity": "sha512-e8WugYZXpgqrlMXLCudYVRAxAcK7AIY36JxRDwFRD38L9q62G1VsEUW6ijXxzjxYjNB8i1zo3B/ycIQ/qjLC/Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.66.0.tgz", + "integrity": "sha512-6vkDCfyDjNLokh+Rt1D2KtNgFFMEPdkWha/mbtP4cSjh9xiN8T/JBS/A7nDYKjmMAXHrvR9J3AzUk2LtFbIBLg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.66.0.tgz", + "integrity": "sha512-/mzZAX0+Q6eXxvkR0HB0RZCCrsbmFD8DpsvCQoMYABDfq/DjqkbfytuJ7GvZ4AhR/Mgis2fXbZrGqfbcK2Z5fA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.66.0.tgz", + "integrity": "sha512-JQJx9E8tUjGqed1RevDmoHaS3V30ODdV8uyvGxlwd4K5se6bkPrMeltSybqAtpJ+ltDRfo7FORQaJG2Hd5nGog==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.66.0.tgz", + "integrity": "sha512-GEaUQQjMaG7X1304qMgqLjzCKv6CdDirzJSS+UqUs3xhJ9X2Kjzu0JDbLoUU42FWxwmZqz+SsgU1SlQv9GNRVA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.66.0.tgz", + "integrity": "sha512-DgmAU9N0NhDQDzHgFUocDio7zRO8jR/nY/obDGvCR8zbJ6J77Fg6X49yPuExJUpYPbC82EOaRhG969pWzUSnHQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.66.0.tgz", + "integrity": "sha512-zG09YZ+sk/HoHq+P9gYB0EseQ3M20RbDuKGWey6fbiMDV1LxfXvhgSW9jDaCcvFPMgfLXpimzXY+UYvA8R2mLQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.66.0.tgz", + "integrity": "sha512-vlArhgyXbcVc1D4WZPoiYuqJIaMiSHBj6etRXua0KlfjlZeuiQyVAPYi0/N49O4mSp3u1iGUBLEjNa8ec81XZg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.66.0.tgz", + "integrity": "sha512-RxJZtk0G87YPotDaRDvRqStV8cbqLSC5TroHvQHHKsqBg0ok64RxKgtXeFsa7FBcy7mb4crBrG3xK8USWIqWNA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-gnu": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-gnu/-/rollup-linux-loong64-gnu-4.66.0.tgz", + "integrity": "sha512-qlGcw959PrLLkZhiBxF3OZ6SQvj+OKY85mCqGNgSRs4LZlDJ6ICqmz6UdxtINdhcXYwNIbZoapQVBAmZlD2hUQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loong64-musl": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loong64-musl/-/rollup-linux-loong64-musl-4.66.0.tgz", + "integrity": "sha512-TvTI/7Cy0WvRA1SXgwzu6bwXBnMpmeT/ln5q7WvSpqmXy1VbmEnY8HVIDQNBiaHJvoWqRr0M4FNo7qiqtyMaFw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-gnu": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-gnu/-/rollup-linux-ppc64-gnu-4.66.0.tgz", + "integrity": "sha512-UZEDkSoDRZ50NyLj70nO6mpIK3dvs2cPTTvQb1bA/PBDmr9fvn5KiESuGfh6srd7Zi6Lt9Sv2sVrFr1QoHLvPQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-ppc64-musl": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-ppc64-musl/-/rollup-linux-ppc64-musl-4.66.0.tgz", + "integrity": "sha512-VRbxTvagLh3HRcysx1CNq+HHcvJbSebNI6fCbk7jwmmWHkXjrSIV3igXBpRHUTFdg0pagWGu50xoSZXnrZHjVQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.66.0.tgz", + "integrity": "sha512-uWdJpvYqh0LE/i+YBL3sMX0a2kUkICENjmrPmyBmMOFc3jMrs6MSQH/pMD+VIpGEoUcr3XkHGLLfymzIqPSRRg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-musl": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.66.0.tgz", + "integrity": "sha512-3FUd88pxgWAjK60OgCrika1AcNG+u8zaCdWjg4TlcZTDkt5TGyci8ZU64l3OJ9ax0MEjw3P80B/3PoSQDCLwJQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.66.0.tgz", + "integrity": "sha512-qT2rMmgyej62g5AdwktK+Bt2lBu497pzWZe12TTQ5JmZjOYPnEwcPEAOSLTBxBV+6gIES75rXm219v/QkT397A==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.66.0.tgz", + "integrity": "sha512-E46rnZgp7J84Qwe8RMlF+rgimnDo/9fuiGbUArGB0ZkMWf97O7yeSCfKls5x/YJOF0RcuSe9RctuKe1hlxICiA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.66.0.tgz", + "integrity": "sha512-Uz1HiZe+qBzqgdPsON+z0wRx3WdATuyzwvGT6cr2VZVrqqko0ZJVfkrQJtwDMuDcAfXYdo7XucaxJ7lTLjEcgg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-openbsd-x64": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openbsd-x64/-/rollup-openbsd-x64-4.66.0.tgz", + "integrity": "sha512-Ph7TX3Ex5qdfcb7Tc6eEPugVkRfJ501eTovO4T5029YObfpZ7dzn3RiwpFvGp50nk2QUhvBMZ0PFGlEj6pOYTg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ] + }, + "node_modules/@rollup/rollup-openharmony-arm64": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-openharmony-arm64/-/rollup-openharmony-arm64-4.66.0.tgz", + "integrity": "sha512-nZYPEya7ZkeNxUEiF7qmNZbyLTyRN3MK5cO22KqsaoneUzXJuzBIQRw+7BEQy9LGj2O5vrCE9V3EpK06FYo1tQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.66.0.tgz", + "integrity": "sha512-u7aTfS3R6C4hRsqXSzaO6qLZYLVuMkHMvcWlux4IM8IJif1VCl2cgPBSo5gSNoFoStQypQP+qwq8W1IyFBf1QQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.66.0.tgz", + "integrity": "sha512-e+i9ueHrH1Bafb0cf0woAIVJbYcoC8vRaD+vz+Xi8w6jz9cYJSV3vyKO6ELGSZ6g4W4MJOm2WPLN4/nQf77h7w==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-gnu": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-gnu/-/rollup-win32-x64-gnu-4.66.0.tgz", + "integrity": "sha512-KfTCbrtr2zXTqH2E1F+uYlFTrYibxHKqPAHobpd8Kfg49cEHmuHebOidCTDRgqG1suaPFX7oejFQeGE71zWKfA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.66.0.tgz", + "integrity": "sha512-xA+neBh1bqkqaS3b48T2UHZnDsTIpb9B0h+TdBzynjF/ymCpYndhfY10RqW0qSKB1HqqQA83mINVhAdwA+mETg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@types/babel__core": { + "version": "7.20.5", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", + "integrity": "sha512-qoQprZvz5wQFJwMDqeseRXWv3rqMvhgpbXFfVyWhbx9X47POIA6i/+dXefEmZKoAgOaTdaIgNSMqMIU61yRyzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.20.7", + "@babel/types": "^7.20.7", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "node_modules/@types/babel__generator": { + "version": "7.27.0", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.27.0.tgz", + "integrity": "sha512-ufFd2Xi92OAVPYsy+P4n7/U7e68fex0+Ee8gSG9KX7eo084CWiQ4sdxktvdl0bOPupXtVJPY19zk6EwWqUQ8lg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__template": { + "version": "7.4.4", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.4.tgz", + "integrity": "sha512-h/NUaSyG5EyxBIp8YRxo4RMe2/qQgvyowRwVMzhYhBCONbW8PUsg4lkFMrhgZhUe5z3L3MiLDuvyJ/CaPa2A8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.28.0.tgz", + "integrity": "sha512-8PvcXf70gTDZBgt9ptxJ8elBeBjcLOAcOtoO/mPJjtji1+CdGbHgm77om1GrsPxsiE+uXIpNSK64UYaIwQXd4Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.28.2" + } + }, + "node_modules/@types/estree": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz", + "integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/prop-types": { + "version": "15.7.15", + "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.15.tgz", + "integrity": "sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/react": { + "version": "18.3.12", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.12.tgz", + "integrity": "sha512-D2wOSq/d6Agt28q7rSI3jhU7G6aiuzljDGZ2hTZHIkrTLUI+AF3WMeKkEZ9nN2fkBAlcktT6vcZjDFiIhMYEQw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/prop-types": "*", + "csstype": "^3.0.2" + } + }, + "node_modules/@types/react-dom": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.1.tgz", + "integrity": "sha512-qW1Mfv8taImTthu4KoXgDfLuk4bydU6Q/TkADnDWWHwi4NX4BR+LWfTp2sVmTqRrsHvyDDTelgelxJ+SsejKKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/react": "*" + } + }, + "node_modules/@vitejs/plugin-react": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/@vitejs/plugin-react/-/plugin-react-4.3.4.tgz", + "integrity": "sha512-SCCPBJtYLdE8PX/7ZQAs1QAZ8Jqwih+0VBLum1EGqmCCQal+MIUqLCzj3ZUy8ufbC0cAM4LRlSTm7IQJwWT4ug==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/core": "^7.26.0", + "@babel/plugin-transform-react-jsx-self": "^7.25.9", + "@babel/plugin-transform-react-jsx-source": "^7.25.9", + "@types/babel__core": "^7.20.5", + "react-refresh": "^0.14.2" + }, + "engines": { + "node": "^14.18.0 || >=16.0.0" + }, + "peerDependencies": { + "vite": "^4.2.0 || ^5.0.0 || ^6.0.0" + } + }, + "node_modules/baseline-browser-mapping": { + "version": "2.11.34", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.34.tgz", + "integrity": "sha512-Aqr8mA1kIvyJ3UY5YAY7ib8LSo1DmDMbMnVqGPtsKW1LxaFQFwn9Eb3yvq2fUKJsRvaXjnAV7R5osqETapzNiA==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "baseline-browser-mapping": "dist/cli.cjs" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/browserslist": { + "version": "4.29.5", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.29.5.tgz", + "integrity": "sha512-khTmKu5NGYTotqcYo8Bew2k4RAE9PuXRSFRXG2lQBrCEQHyeQ/vX6gKMxfokwywBsLiXZMnHsmWMG1pnO8J7uQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "baseline-browser-mapping": "^2.11.33", + "caniuse-lite": "^1.0.30001819", + "electron-to-chromium": "^1.5.464", + "node-releases": "^2.0.60", + "update-browserslist-db": "^1.3.4" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001819", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001819.tgz", + "integrity": "sha512-LFUqIIAwpzsIuevnKnsR9qnStBcgzPShTX61lBwN9uFkkf8o8zLiebEjbW8AYtZiF+1YKDWfdt/pWDtMuG8Xwg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "CC-BY-4.0" + }, + "node_modules/convert-source-map": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", + "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/csstype": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/csstype/-/csstype-3.2.3.tgz", + "integrity": "sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/debug": { + "version": "4.4.3", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", + "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/electron-to-chromium": { + "version": "1.5.467", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.467.tgz", + "integrity": "sha512-Nw9X371rtZmYcBSnEijnCDONILjs93biCZO34juC7MBOmK8E+GFnyD4T/WvyrlJkppul7oxg6TwvtKst9SODTw==", + "dev": true, + "license": "ISC" + }, + "node_modules/esbuild": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", + "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.21.5", + "@esbuild/android-arm": "0.21.5", + "@esbuild/android-arm64": "0.21.5", + "@esbuild/android-x64": "0.21.5", + "@esbuild/darwin-arm64": "0.21.5", + "@esbuild/darwin-x64": "0.21.5", + "@esbuild/freebsd-arm64": "0.21.5", + "@esbuild/freebsd-x64": "0.21.5", + "@esbuild/linux-arm": "0.21.5", + "@esbuild/linux-arm64": "0.21.5", + "@esbuild/linux-ia32": "0.21.5", + "@esbuild/linux-loong64": "0.21.5", + "@esbuild/linux-mips64el": "0.21.5", + "@esbuild/linux-ppc64": "0.21.5", + "@esbuild/linux-riscv64": "0.21.5", + "@esbuild/linux-s390x": "0.21.5", + "@esbuild/linux-x64": "0.21.5", + "@esbuild/netbsd-x64": "0.21.5", + "@esbuild/openbsd-x64": "0.21.5", + "@esbuild/sunos-x64": "0.21.5", + "@esbuild/win32-arm64": "0.21.5", + "@esbuild/win32-ia32": "0.21.5", + "@esbuild/win32-x64": "0.21.5" + } + }, + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "license": "MIT" + }, + "node_modules/jsesc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-3.1.0.tgz", + "integrity": "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==", + "dev": true, + "license": "MIT", + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/json5": { + "version": "2.2.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", + "integrity": "sha512-XmOWe7eyHYH14cLdVPoyg+GOH3rYX++KpzrylJwSW98t3Nk+U8XOl8FWKOgwtzdb8lXGf6zYwDUzeHMWfxasyg==", + "dev": true, + "license": "MIT", + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "license": "MIT", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, + "node_modules/lru-cache": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", + "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", + "dev": true, + "license": "ISC", + "dependencies": { + "yallist": "^3.0.2" + } + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/node-releases": { + "version": "2.0.60", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.60.tgz", + "integrity": "sha512-OmO8+GM1JUZqXET720VrJCwkjUCXmCMQm0Z3UDDRbfNLHS4NEAvY60j5jiFv0tkKw2PNNlqOLhahVmwJIOLDIQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/postcss": { + "version": "8.5.32", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.32.tgz", + "integrity": "sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.20", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/react": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", + "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0", + "scheduler": "^0.23.2" + }, + "peerDependencies": { + "react": "^18.3.1" + } + }, + "node_modules/react-refresh": { + "version": "0.14.2", + "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.2.tgz", + "integrity": "sha512-jCvmsr+1IUSMUyzOkRcvnVbX3ZYC6g9TDrDbFuFmRDq7PD4yaGbLKNQL6k2jnArV8hjYxh7hVhAZB6s9HDGpZA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/rollup": { + "version": "4.66.0", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.66.0.tgz", + "integrity": "sha512-Onq6/qO4ARhxIs+jYiHE0pYehadLyMECAiGEqQ+0/aWND3+2PmifJIIqBLYtuBODqHTlOUEQFtIVPyCy0Lck7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.9" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@napi-rs/lzma-linux-x64-gnu": "1.5.1", + "@rollup/rollup-android-arm-eabi": "4.66.0", + "@rollup/rollup-android-arm64": "4.66.0", + "@rollup/rollup-darwin-arm64": "4.66.0", + "@rollup/rollup-darwin-x64": "4.66.0", + "@rollup/rollup-freebsd-arm64": "4.66.0", + "@rollup/rollup-freebsd-x64": "4.66.0", + "@rollup/rollup-linux-arm-gnueabihf": "4.66.0", + "@rollup/rollup-linux-arm-musleabihf": "4.66.0", + "@rollup/rollup-linux-arm64-gnu": "4.66.0", + "@rollup/rollup-linux-arm64-musl": "4.66.0", + "@rollup/rollup-linux-loong64-gnu": "4.66.0", + "@rollup/rollup-linux-loong64-musl": "4.66.0", + "@rollup/rollup-linux-ppc64-gnu": "4.66.0", + "@rollup/rollup-linux-ppc64-musl": "4.66.0", + "@rollup/rollup-linux-riscv64-gnu": "4.66.0", + "@rollup/rollup-linux-riscv64-musl": "4.66.0", + "@rollup/rollup-linux-s390x-gnu": "4.66.0", + "@rollup/rollup-linux-x64-gnu": "4.66.0", + "@rollup/rollup-linux-x64-musl": "4.66.0", + "@rollup/rollup-openbsd-x64": "4.66.0", + "@rollup/rollup-openharmony-arm64": "4.66.0", + "@rollup/rollup-win32-arm64-msvc": "4.66.0", + "@rollup/rollup-win32-ia32-msvc": "4.66.0", + "@rollup/rollup-win32-x64-gnu": "4.66.0", + "@rollup/rollup-win32-x64-msvc": "4.66.0", + "fsevents": "~2.3.2" + } + }, + "node_modules/scheduler": { + "version": "0.23.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", + "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", + "license": "MIT", + "dependencies": { + "loose-envify": "^1.1.0" + } + }, + "node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/source-map-js": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/typescript": { + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", + "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.3.4.tgz", + "integrity": "sha512-t8wonIOdQyOjtPd2VktlBu6QjTVTks6v8bSi7kd0r2Vll8TK1JYDZtRRdbmCHOAMphkZgrzK+L+vXK4pyZ8t4A==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "escalade": "^3.2.0", + "picocolors": "^1.1.1" + }, + "bin": { + "update-browserslist-db": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/vite": { + "version": "5.4.11", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.4.11.tgz", + "integrity": "sha512-c7jFQRklXua0mTzneGW9QVyxFjUgwcihC4bXEtujIo2ouWCe1Ajt/amn2PCxYnhYfd5k09JX3SB7OYWFKYqj8Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.21.3", + "postcss": "^8.4.43", + "rollup": "^4.20.0" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || >=20.0.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.4.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + } + } + }, + "node_modules/yallist": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.1.1.tgz", + "integrity": "sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g==", + "dev": true, + "license": "ISC" + } + } +} diff --git a/web/package.json b/web/package.json new file mode 100644 index 0000000..a592db6 --- /dev/null +++ b/web/package.json @@ -0,0 +1,22 @@ +{ + "name": "lune-canvas", + "private": true, + "version": "0.1.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc -b && vite build", + "check": "tsc -b" + }, + "dependencies": { + "react": "18.3.1", + "react-dom": "18.3.1" + }, + "devDependencies": { + "@types/react": "18.3.12", + "@types/react-dom": "18.3.1", + "@vitejs/plugin-react": "4.3.4", + "typescript": "5.6.3", + "vite": "5.4.11" + } +} diff --git a/web/src/Canvas.tsx b/web/src/Canvas.tsx new file mode 100644 index 0000000..b77d76a --- /dev/null +++ b/web/src/Canvas.tsx @@ -0,0 +1,791 @@ +// The team canvas (M5): vaults on the left, people on the right, ribbons for who can sync what. +// Grant = drag a vault onto a person; revoke = pull a ribbon's dot until it snaps (Undo for 8 s). Every gesture +// also has a button in the details panel (X3). + +import { useEffect, useMemo, useRef, useState } from 'react'; +import { api, type CanvasData, type LogEntry, type Member, type Person, type Role, type Vault } from './api'; +import { + HANDLE_T, W, boardHeight, circle, easeBack, lerp, personColor, positions, ribbon, roundRect, vaultColor, + type Layout, type Pt, +} from './geometry'; + +const UNDO_SECONDS = 8; +const ROLES: Role[] = ['read', 'edit', 'manage']; +const roleName = (r: Role) => r.charAt(0).toUpperCase() + r.slice(1); +const plural = (n: number, word: string, many = word + 's') => `${n} ${n === 1 ? word : many}`; +const keyOf = (m: { vault: string; person: string }) => `${m.vault}|${m.person}`; + +type Sel = + | { kind: 'overview'; back?: Sel } + | { kind: 'vault'; id: string; back?: Sel } + | { kind: 'person'; id: string; back?: Sel }; +type Drag = + | { kind: 'grant'; v: string; start: Pt; p: Pt; moved: boolean } + | { kind: 'retract'; v: string; p: Pt } + | { kind: 'detach'; key: string; p: Pt } + | { kind: 'snap'; key: string; p: Pt }; +type Toast = { text: string; undo?: () => void }; + +function store(key: string, value?: string): string | null { + try { + if (value !== undefined) localStorage.setItem(key, value); + return localStorage.getItem(key); + } catch { + return null; + } +} + +const reducedMotion = () => window.matchMedia?.('(prefers-reduced-motion: reduce)').matches ?? false; + +export function Canvas({ data, reload, onSignOut }: { data: CanvasData; reload: () => Promise; onSignOut: () => void }) { + const [layout, setLayoutState] = useState(store('lune.layout') === 'dock' ? 'dock' : 'float'); + const [blend, setBlend] = useState<{ from: Layout; to: Layout; t: number } | null>(null); + const [sel, setSel] = useState(null); + const [hover, setHover] = useState<{ kind: 'vault' | 'person'; id: string } | null>(null); + const [drag, setDrag] = useState(null); + const [pinched, setPinched] = useState<{ key: string; p: Pt; t: number } | null>(null); + const [toast, setToast] = useState(null); + const [sheet, setSheet] = useState<'invite' | 'vault' | null>(null); + const [onboarded, setOnboarded] = useState(store('lune.onboarded') === '1'); + const [hidden, setHidden] = useState>(new Set()); + const [extra, setExtra] = useState([]); + const [log, setLog] = useState([]); + const svgRef = useRef(null); + const rafs = useRef>({}); + const toastTimer = useRef(); + const hoverTimer = useRef(); + const lastFocus = useRef<{ kind: 'vault' | 'person'; id: string } | null>(null); + + // Optimistic additions last until fresh data arrives; the hub stays the source of truth. + useEffect(() => setExtra([]), [data]); + useEffect(() => { + const t = window.setInterval(() => reload(), 10000); + return () => window.clearInterval(t); + }, [reload]); + useEffect(() => () => Object.values(rafs.current).forEach(cancelAnimationFrame), []); + // Float: every node bobs on one shared clock (X8). + useEffect(() => { + try { + document.getAnimations?.().forEach((a) => { + if ((a as CSSAnimation).animationName === 'bob' && a.startTime !== 0) a.startTime = 0; + }); + } catch { + /* older browsers: unsynced bobbing is fine */ + } + }); + useEffect(() => { + if (sel?.kind === 'overview' && data.me.owner) api.log(8).then(setLog).catch(() => setLog([])); + }, [sel, data]); + + const vaults = data.vaults; + const people = data.people; + const vault = (id: string) => vaults.find((v) => v.id === id)!; + const person = (id: string) => people.find((p) => p.id === id)!; + const pendingKeys = useMemo(() => new Set(data.pending.map(keyOf)), [data]); + const members = useMemo( + () => + [...data.members, ...extra.filter((e) => !data.members.some((m) => keyOf(m) === keyOf(e)))].filter( + (m) => !hidden.has(keyOf(m)) && !pendingKeys.has(keyOf(m)), + ), + [data, extra, hidden, pendingKeys], + ); + const H = boardHeight(vaults.length, people.length); + const at = useMemo( + () => ({ + float: positions(vaults.map((v) => v.id), people.map((p) => p.id), 'float', H), + dock: positions(vaults.map((v) => v.id), people.map((p) => p.id), 'dock', H), + }), + [vaults, people, H], + ); + const pos = (id: string): Pt => { + if (!blend) return at[layout][id]; + const a = at[blend.from][id], c = at[blend.to][id], t = easeBack(blend.t); + return { x: lerp(a.x, c.x, t), y: lerp(a.y, c.y, t) }; + }; + const ends = (m: { vault: string; person: string }) => { + const a = pos(m.vault), b = pos(m.person); + return { ax: a.x, ay: a.y, bx: b.x, by: b.y }; + }; + + function anim(key: string, ms: number, step: (t: number) => void, done?: () => void) { + const t0 = performance.now(); + cancelAnimationFrame(rafs.current[key]); + const tick = (now: number) => { + const t = Math.min(1, (now - t0) / ms); + step(t); + if (t < 1) rafs.current[key] = requestAnimationFrame(tick); + else done?.(); + }; + rafs.current[key] = requestAnimationFrame(tick); + } + + function say(text: string, undo?: () => void) { + setToast({ text, undo }); + window.clearTimeout(toastTimer.current); + toastTimer.current = window.setTimeout(() => setToast(null), undo ? UNDO_SECONDS * 1000 : 4200); + } + + async function run(action: () => Promise, ok?: string) { + try { + await action(); + if (ok) say(ok); + } catch (e) { + say((e as Error).message); + } finally { + await reload(); + } + } + + // ---- What the gestures and buttons do ---- + + function grant(vId: string, pId: string) { + const v = vault(vId), p = person(pId); + if (members.some((m) => m.vault === vId && m.person === pId)) return say(`${p.name} already has ${v.name}.`); + setExtra((x) => [...x, { vault: vId, person: pId, role: 'edit' }]); + run( + () => (p.invited ? api.inviteGrant(p.name, v.name, 'edit') : api.grant(p.name, v.name, 'edit')), + p.invited ? `${v.name} is added to ${p.name}'s invite.` : `${p.name} can now sync ${v.name}. It arrives on their devices within a minute.`, + ); + } + + async function revoke(key: string) { + const [vId, pId] = key.split('|'); + const v = vault(vId), p = person(pId); + setHidden((h) => new Set(h).add(key)); + const unhide = () => setHidden((h) => { const n = new Set(h); n.delete(key); return n; }); + if (p.invited) { + await run(() => api.inviteGrant(p.name, v.name, null, true), `${v.name} is off ${p.name}'s invite.`); + unhide(); + return; + } + try { + const res = await api.remove(p.name, v.name, UNDO_SECONDS); + const copies = v.delete_from_devices ? 'then deleted from their devices' : 'then their copy stops updating'; + say(`${p.name} removed from ${v.name}. Unshared work comes to you for review, ${copies}.`, async () => { + setToast(null); + await run(() => api.undoRemove(res.pending!), `${p.name} has ${v.name} again. Nothing changed on their devices.`); + unhide(); + }); + window.setTimeout(() => reload().then(unhide), (UNDO_SECONDS + 1.5) * 1000); + } catch (e) { + unhide(); + say((e as Error).message); + } + } + + function cycleRole(m: Member) { + const v = vault(m.vault), p = person(m.person); + const next = ROLES[(ROLES.indexOf(m.role) + 1) % ROLES.length]; + run(() => (p.invited ? api.inviteGrant(p.name, v.name, next) : api.grant(p.name, v.name, next)), `${p.name} now has ${roleName(next)} on ${v.name}.`); + } + + function setLayout(l: Layout) { + if (blend || l === layout) return; + store('lune.layout', l); + if (reducedMotion()) return setLayoutState(l); + const from = layout; + setBlend({ from, to: l, t: 0 }); + anim('layout', 720, (t) => setBlend({ from, to: l, t }), () => { setLayoutState(l); setBlend(null); }); + } + + // ---- Pointer handling ---- + + const toSvg = (e: React.PointerEvent): Pt => { + const svg = svgRef.current; + if (!svg) return { x: 0, y: 0 }; + const pt = svg.createSVGPoint(); + pt.x = e.clientX; + pt.y = e.clientY; + const q = pt.matrixTransform(svg.getScreenCTM()!.inverse()); + return { x: q.x, y: q.y }; + }; + const capture = (e: React.PointerEvent) => { try { svgRef.current?.setPointerCapture(e.pointerId); } catch { /* fine */ } }; + const target = (p: Pt) => { + let best: string | null = null, bd = 1e9; + for (const pr of people) { + const q = pos(pr.id), d = Math.hypot(p.x - q.x, p.y - q.y); + if (d < bd) { bd = d; best = pr.id; } + } + return best && bd < 130 ? { id: best, dist: bd } : null; + }; + + function startGrant(vId: string, e: React.PointerEvent) { + if (sheet || drag || pinched) return; + e.preventDefault(); + const p = toSvg(e); + capture(e); + setDrag({ kind: 'grant', v: vId, start: p, p, moved: false }); + } + function startDetach(key: string, e: React.PointerEvent) { + if (sheet || drag || pinched) return; + e.preventDefault(); + capture(e); + setDrag({ kind: 'detach', key, p: toSvg(e) }); + } + function onMove(e: React.PointerEvent) { + if (!drag || (drag.kind !== 'grant' && drag.kind !== 'detach')) return; + const p = toSvg(e); + if (drag.kind === 'grant') setDrag({ ...drag, p, moved: drag.moved || Math.hypot(p.x - drag.start.x, p.y - drag.start.y) > 6 }); + else setDrag({ ...drag, p }); + } + function onUp() { + const d = drag; + if (!d) return; + if (d.kind === 'grant') { + if (!d.moved) { setDrag(null); setSel({ kind: 'vault', id: d.v }); return; } + const t = target(d.p); + if (t && t.dist < 75) { setDrag(null); grant(d.v, t.id); return; } + const a = pos(d.v), p0 = d.p; + setDrag({ kind: 'retract', v: d.v, p: p0 }); + anim('drag', 260, (t) => { const k = 1 - Math.pow(1 - t, 3); setDrag({ kind: 'retract', v: d.v, p: { x: lerp(p0.x, a.x, k), y: lerp(p0.y, a.y, k) } }); }, () => setDrag(null)); + } else if (d.kind === 'detach') { + const [vId, pId] = d.key.split('|'); + const e = ends({ vault: vId, person: pId }); + const h0 = { x: lerp(e.ax, e.bx, HANDLE_T), y: lerp(e.ay, e.by, HANDLE_T) }; + if (Math.hypot(d.p.x - h0.x, d.p.y - h0.y) > 110) { + const key = d.key, P = d.p; + setDrag(null); + setPinched({ key, p: P, t: 0 }); + anim('pinch', reducedMotion() ? 1 : 300, (t) => setPinched({ key, p: P, t }), () => { setPinched(null); revoke(key); }); + } else { + const q0 = d.p; + setDrag({ kind: 'snap', key: d.key, p: q0 }); + anim('drag', 240, (t) => { const k = 1 - Math.pow(1 - t, 3); setDrag({ kind: 'snap', key: d.key, p: { x: lerp(q0.x, h0.x, k), y: lerp(q0.y, h0.y, k) } }); }, () => setDrag(null)); + } + } + } + + // ---- Drawing ---- + + const bob = !blend && layout === 'float' && !reducedMotion() ? 'bob' : ''; + const grantDrag = drag && drag.kind === 'grant' && drag.moved ? drag : null; + const tgt = grantDrag ? target(grantDrag.p) : null; + const hot = tgt && tgt.dist < 75 ? tgt.id : null; + const focus = !drag && hover ? hover : sel && (sel.kind === 'vault' || sel.kind === 'person') ? { kind: sel.kind, id: sel.id } : null; + if (focus) lastFocus.current = focus; + const relV = (vId: string) => !focus || (focus.kind === 'vault' ? focus.id === vId : members.some((m) => m.vault === vId && m.person === focus.id)); + const relP = (pId: string) => !focus || (focus.kind === 'person' ? focus.id === pId : members.some((m) => m.person === pId && m.vault === focus.id)); + const pct = (x: number, y: number): React.CSSProperties => ({ position: 'absolute', left: `${(x / W) * 100}%`, top: `${(y / H) * 100}%` }); + const leave = () => { window.clearTimeout(hoverTimer.current); hoverTimer.current = window.setTimeout(() => setHover(null), 90); }; + const enter = (kind: 'vault' | 'person', id: string) => { window.clearTimeout(hoverTimer.current); if (!drag) setHover({ kind, id }); }; + + const blobs: { d: string; fill: string; delay: string; op: number }[] = []; + const labels: { text: string; style: React.CSSProperties; inner: React.CSSProperties }[] = []; + const ribbons: { d: string; fill: string; op?: number; dim?: number }[] = []; + const handles: { key: string; x: number; y: number; dim: boolean }[] = []; + const grips: { x: number; y: number; r: number }[] = []; + const grads: { id: string; x1: number; y1: number; x2: number; y2: number; c1: string; c2: string }[] = []; + + vaults.forEach((v, i) => { + const p = pos(v.id), delay = (i * 0.7).toFixed(1), vo = relV(v.id) ? 1 : 0.35; + blobs.push({ d: roundRect(p.x, p.y, 138, 70, 26), fill: vaultColor(v.id).fill, delay, op: focus && relV(v.id) ? 1 : 0 }); + labels.push({ + text: v.name, + style: { ...pct(p.x - 20, p.y), transform: 'translateY(-50%)', opacity: vo, transition: 'opacity .2s' }, + inner: { display: 'inline-block', whiteSpace: 'nowrap', fontWeight: 700, fontSize: 'max(1.4cqw, 10px)', animationDelay: `${delay}s`, maxWidth: '8.2cqw', overflow: 'hidden', textOverflow: 'ellipsis' }, + }); + }); + people.forEach((pr, i) => { + const p = pos(pr.id), delay = (0.35 + i * 0.6).toFixed(1), po = relP(pr.id) ? 1 : 0.35; + if (!pr.invited) blobs.push({ d: circle(p.x, p.y, 38), fill: personColor(pr.id).fill, delay, op: focus && relP(pr.id) ? 1 : 0 }); + labels.push({ text: pr.name.charAt(0).toUpperCase(), style: { ...pct(p.x, p.y), transform: 'translate(-50%,-50%)', opacity: po }, inner: { display: 'inline-block', fontWeight: 700, fontSize: 'max(2cqw, 12px)', animationDelay: `${delay}s` } }); + labels.push({ + text: pr.invited ? `${pr.name} · invited` : pr.name, + style: { ...pct(p.x, p.y + 48), transform: 'translate(-50%,-50%)', opacity: po }, + inner: { display: 'inline-block', whiteSpace: 'nowrap', fontSize: 'max(1.3cqw, 10px)', animationDelay: `${delay}s` }, + }); + }); + + for (const m of members) { + const key = keyOf(m), e = ends(m), gid = `g-${key.replace(/[^a-zA-Z0-9]/g, '-')}`, fill = `url(#${gid})`; + grads.push({ id: gid, x1: e.ax, y1: e.ay, x2: e.bx, y2: e.by, c1: vaultColor(m.vault).fill, c2: personColor(m.person).fill }); + const dim = !!(focus && ((focus.kind === 'vault' && focus.id !== m.vault) || (focus.kind === 'person' && focus.id !== m.person))); + const h0 = { x: lerp(e.ax, e.bx, HANDLE_T), y: lerp(e.ay, e.by, HANDLE_T) }; + if (pinched?.key === key) { + const P = pinched.p, shrink = 1 - pinched.t; + ribbons.push({ d: ribbon(e.ax, e.ay, lerp(e.ax, P.x, 0.45 * shrink), lerp(e.ay, P.y, 0.45 * shrink), 14, 3, 0.6), fill }); + ribbons.push({ d: ribbon(e.bx, e.by, lerp(e.bx, P.x, 0.3 * shrink), lerp(e.by, P.y, 0.3 * shrink), 11, 4, 0.6), fill }); + continue; + } + const active = drag && (drag.kind === 'detach' || drag.kind === 'snap') && drag.key === key ? drag.p : null; + if (active) { + const P = active, dist = Math.hypot(P.x - h0.x, P.y - h0.y), neck = dist < 110 ? 4 + 4 * (1 - dist / 110) : 0; + if (neck > 0.5) { + ribbons.push({ d: ribbon(e.ax, e.ay, P.x, P.y, 16, Math.max(4, neck * 0.8), neck), fill }); + ribbons.push({ d: ribbon(P.x, P.y, e.bx, e.by, neck, Math.max(4, neck * 0.8), 11), fill }); + grips.push({ x: P.x, y: P.y, r: 7 }); + } else { + ribbons.push({ d: ribbon(e.ax, e.ay, lerp(e.ax, P.x, 0.45), lerp(e.ay, P.y, 0.45), 14, 3, 0.6), fill }); + ribbons.push({ d: ribbon(e.bx, e.by, lerp(e.bx, P.x, 0.3), lerp(e.by, P.y, 0.3), 9, 3, 0.6), fill }); + grips.push({ x: P.x, y: P.y, r: 5 }); + } + } else { + ribbons.push({ d: ribbon(e.ax, e.ay, e.bx, e.by, 16, 4.5, 11), fill, dim: focus && !dim ? 1 : 0 }); + const pr = person(m.person); + // You can't pull your own ribbon, nor the team owner's (they always keep access). + if (vault(m.vault).can_manage && !pr.owner && pr.id !== data.me.id) handles.push({ key, x: h0.x, y: h0.y, dim }); + } + } + + let ghost: { d: string; cx: number; cy: number; c2: string } | null = null; + if (drag && ((drag.kind === 'grant' && drag.moved) || drag.kind === 'retract')) { + const a = pos(drag.v); + let E = drag.p; + if (tgt) { const q = pos(tgt.id), k = Math.max(0, Math.min(1, 1 - tgt.dist / 130)) * 0.55; E = { x: lerp(E.x, q.x, k), y: lerp(E.y, q.y, k) }; } + const c2 = tgt ? personColor(tgt.id).fill : vaultColor(drag.v).fill; + grads.push({ id: 'g-ghost', x1: a.x, y1: a.y, x2: E.x, y2: E.y, c1: vaultColor(drag.v).fill, c2 }); + ghost = { d: ribbon(a.x, a.y, E.x, E.y, 16, 4.5, 9), cx: E.x, cy: E.y, c2 }; + } + + let hint = '', hintHot = false; + if (grantDrag) { + hint = hot ? `Release to give ${person(hot).name} access to ${vault(grantDrag.v).name}.` : 'Drop on a person to give access.'; + hintHot = !!hot; + } + if (drag?.kind === 'detach') { + const [vId, pId] = drag.key.split('|'), e = ends({ vault: vId, person: pId }); + const far = Math.hypot(drag.p.x - lerp(e.ax, e.bx, HANDLE_T), drag.p.y - lerp(e.ay, e.by, HANDLE_T)) > 110; + hint = far ? `Release to remove ${person(pId).name} from ${vault(vId).name}.` : 'Pull further to remove access.'; + hintHot = far; + } + + const manages = vaults.some((v) => v.can_manage); + const back = sel?.back; + const backLabel = !back ? '' : back.kind === 'overview' ? 'Vaults & people' : back.kind === 'vault' ? vault(back.id)?.name : person(back.id)?.name; + const open = (s: Sel) => setSel({ ...s, back: sel ?? undefined }); + const boardStyle: React.CSSProperties = { width: `min(100%, calc((100dvh - 160px) * ${W / H}))`, aspectRatio: `${W} / ${H}` }; + + return ( +
+
+
+ +
+ Team canvas + {plural(vaults.length, 'vault')} · {plural(people.filter((p) => !p.invited).length, 'person', 'people')} +
+
+
+ +
+ + +
+ {manages && } +
+
+ +
{ if (e.target === e.currentTarget && !drag) setSel(null); }}> + {vaults.length === 0 ? ( +
+

No vaults yet

+

{data.me.owner ? 'Create one here, or move an existing vault onto the hub with `lunesync vault upload`.' : 'When someone gives you a vault, it shows up here.'}

+ {data.me.owner && } +
+ ) : ( +
+ + + + + + + {grads.map((g) => ( + + + + ))} + + { if (!drag) setSel(null); }} /> + VAULTS + PEOPLE + + {/* Ribbons and node halos melt together (X4); a focused node's set is redrawn bright on top (X7). */} + + {ribbons.map((r, i) => )} + {blobs.map((b, i) => )} + {ghost && <>} + + + {ribbons.filter((r) => r.dim !== undefined).map((r, i) => )} + {blobs.map((b, i) => )} + + {ghost && } + {grips.map((g, i) => )} + + {vaults.map((v, i) => { + const p = pos(v.id), c = vaultColor(v.id), on = sel?.kind === 'vault' && sel.id === v.id, veil = relV(v.id) ? 0 : 0.65; + return ( + + + (v.can_manage ? startGrant(v.id, e) : undefined)} + onClick={() => { if (!v.can_manage) setSel({ kind: 'vault', id: v.id }); }} + onPointerEnter={() => enter('vault', v.id)} onPointerLeave={leave} + style={{ cursor: v.can_manage ? 'grab' : 'pointer' }} + > + + + + + + + ); + })} + + {people.map((pr, i) => { + const p = pos(pr.id), c = personColor(pr.id), on = sel?.kind === 'person' && sel.id === pr.id; + const veil = relP(pr.id) ? 0 : 0.65, n = pr.devices.length; + const angles = n === 1 ? [18] : n === 2 ? [-30, 30] : pr.devices.map((_, j) => -40 + (j * 80) / Math.max(1, n - 1)); + return ( + + + {pr.devices.map((d, j) => { + const a = (angles[j] * Math.PI) / 180, cx = Math.cos(a) * 52, cy = Math.sin(a) * 52; + return ( + + + + + ); + })} + { if (!drag) setSel({ kind: 'person', id: pr.id }); }} onPointerEnter={() => enter('person', pr.id)} onPointerLeave={leave} style={{ cursor: 'pointer' }}> + + + + + + ); + })} + + {handles.map((h) => ( + startDetach(h.key, e)} style={{ cursor: 'grab' }}> + + + + ))} + + + +
+ )} +
+ +
{hint && {hint}}
+ + {!onboarded && manages && vaults.length > 0 && ( +
+ Two moves to know +
1Drag a vault onto a person to give them access.
+
2Pull the dot on a ribbon until it snaps to take access back. You can undo.
+ Click any vault or person for details and buttons. + +
+ )} + + {sel && ( + + )} + + {sheet === 'invite' && v.can_manage)} owner={data.me.owner} close={() => { setSheet(null); reload(); }} />} + {sheet === 'vault' && setSheet(null)} create={(name) => { setSheet(null); run(() => api.createVault(name), `${name} is ready. Drag it onto people to share it.`); }} />} + +
+ {toast && ( +
+ {toast.text} + {toast.undo && } +
+ )} +
+
+ ); +} + +function Avatar({ p }: { p: Person }) { + const c = personColor(p.id); + return {p.name.charAt(0).toUpperCase()}; +} + +function Swatch({ v }: { v: Vault }) { + const c = vaultColor(v.id); + return ( + + + + ); +} + +function CloseButton({ close }: { close: () => void }) { + return ; +} + +function Overview({ data, members, log, open, close, newVault, signOut }: { + data: CanvasData; members: Member[]; log: LogEntry[]; open: (s: Sel) => void; close: () => void; newVault: () => void; signOut: () => void; +}) { + return ( + <> +

Vaults & people

+
+

Vaults

{data.vaults.length}
+ {data.vaults.map((v) => ( + + ))} + {data.me.owner && } +
+
+

People

{data.people.length}
+ {data.people.map((p) => ( + + ))} +
+ {data.me.owner && log.length > 0 && ( +
+

Recent activity

+
    + {log.map((e, i) => ( +
  1. {e.actor} · {e.action}: {e.detail}{new Date(e.at * 1000).toLocaleString()}
  2. + ))} +
+
+ )} +
+ Signed in as {data.me.person} + +
+ + ); +} + +function VaultPanel({ v, data, members, open, close, cycleRole, remove, grant, toggleDelete }: { + v: Vault; data: CanvasData; members: Member[]; open: (s: Sel) => void; close: () => void; + cycleRole: (m: Member) => void; remove: (m: Member) => void; grant: (v: string, p: string) => void; toggleDelete: (v: Vault) => void; +}) { + const inVault = members.filter((m) => m.vault === v.id); + const outside = data.people.filter((p) => !inVault.some((m) => m.person === p.id)); + const mine = inVault.find((m) => m.person === data.me.id); + return ( + <> +
+
Vault · {plural(inVault.length, 'person', 'people')}

{v.name}

+ +
+ {!v.can_manage && mine &&
You have {roleName(mine.role)} access. People with Manage decide who else can sync it.
} +
+

People with access

+ {inVault.map((m) => { + const p = data.people.find((x) => x.id === m.person)!; + // Your own row and the team owner's can't be changed here (no locking yourself out by accident). + const fixed = p.owner || p.id === data.me.id; + return ( +
+ + + {v.can_manage && !fixed ? ( + + ) : ( + {roleName(m.role)} + )} + {v.can_manage && !fixed && ( + + )} +
+ ); + })} +
+ {v.can_manage && outside.length > 0 && ( +
+

Give access

+
{outside.map((p) => )}
+
+ )} + {v.can_manage && ( +
+

When someone is removed

+ +

Removing someone only affects this vault. Copies made elsewhere can't be recalled.

+
+ )} + + ); +} + +function PersonPanel({ p, data, members, open, close, run }: { + p: Person; data: CanvasData; members: Member[]; open: (s: Sel) => void; close: () => void; + run: (action: () => Promise, ok?: string) => Promise; +}) { + const [renaming, setRenaming] = useState<{ id: string; value: string } | null>(null); + const theirs = members.filter((m) => m.person === p.id); + const canEditDevices = p.id === data.me.id || data.me.owner; + const eyebrow = p.invited ? 'Invited' : p.owner ? 'Team owner' : 'Team member'; + return ( + <> +
+
{eyebrow}

{p.name}

+ +
+ {p.invited &&
{p.name} hasn't joined yet. Vaults you give them now arrive once they join with their invite link.
} + {!p.invited && ( +
+

Devices

+ {p.devices.length === 0 &&

{canEditDevices ? 'No devices yet.' : "Only their vault managers see someone's devices."}

} + {p.devices.map((d) => ( +
+ {renaming?.id === d.id ? ( +
{ e.preventDefault(); const label = renaming.value.trim(); setRenaming(null); if (label && label !== d.label) run(() => api.renameDevice(d.id, label), `Renamed to ${label}. New history entries carry this name.`); }}> + + setRenaming({ id: d.id, value: e.target.value })} autoFocus maxLength={40} /> + + +
+ ) : ( +
+ + {d.label} +
+ )} + {canEditDevices && renaming?.id !== d.id && ( +
+ + +
+ )} +
+ ))} +
+ )} +
+

Vaults

+ {theirs.length === 0 &&

None yet. Drag a vault onto {p.name} to share it.

} + {theirs.map((m) => { + const v = data.vaults.find((x) => x.id === m.vault)!; + return ( + + ); + })} +
+ + ); +} + +function InviteDialog({ vaults, owner, close }: { vaults: Vault[]; owner: boolean; close: () => void }) { + const [name, setName] = useState(''); + const [picked, setPicked] = useState>(new Set()); + const [link, setLink] = useState(''); + const [error, setError] = useState(''); + const [copied, setCopied] = useState(false); + const create = async (e: React.FormEvent) => { + e.preventDefault(); + try { + const grants = vaults.filter((v) => picked.has(v.id)).map((v) => ({ vault: v.name, role: 'edit' as Role })); + setLink((await api.invite(name.trim(), grants)).link); + setError(''); + } catch (err) { + setError((err as Error).message); + } + }; + const command = `lunesync join ${link} --name ""`; + return ( +
{ if (e.target === e.currentTarget) close(); }}> +
+

Invite a person

+ {!link ? ( +
+ + setName(e.target.value)} placeholder="Sari" autoFocus /> + {vaults.length > 0 && ( +
+ Vaults they get (Edit){owner ? ' — optional' : ''} + {vaults.map((v) => ( + + ))} +
+ )} +

You'll get a one-time link to send them. They join with the sync app and appear here; give them more vaults by dragging.

+ {error &&

{error}

} +
+ + +
+
+ ) : ( + <> +

Send this to {name.trim()} over a channel you trust. It works once, for 7 days. They run:

+
{command}
+
+ + +
+ + )} +
+
+ ); +} + +function NewVaultDialog({ close, create }: { close: () => void; create: (name: string) => void }) { + const [name, setName] = useState(''); + return ( +
{ if (e.target === e.currentTarget) close(); }}> +
{ e.preventDefault(); if (name.trim()) create(name.trim()); }}> +

New vault

+ + setName(e.target.value)} placeholder="DevOps" autoFocus /> +

It starts empty and arrives on your devices within a minute. To move an existing vault here, use lunesync vault upload.

+
+ + +
+
+
+ ); +} diff --git a/web/src/api.ts b/web/src/api.ts new file mode 100644 index 0000000..8d98e44 --- /dev/null +++ b/web/src/api.ts @@ -0,0 +1,81 @@ +// Talking to the hub. The session cookie signs requests; X-Lune marks them as coming from the canvas. + +export type Role = 'read' | 'edit' | 'manage'; + +export interface Vault { + id: string; + name: string; + can_manage: boolean; + delete_from_devices: boolean; +} + +export interface Device { + id: string; + label: string; +} + +export interface Person { + id: string; + name: string; + owner: boolean; + /** Invited but not joined yet. */ + invited: boolean; + devices: Device[]; +} + +export interface Member { + vault: string; + person: string; + role: Role; +} + +export interface CanvasData { + me: { id: string; person: string; owner: boolean }; + vaults: Vault[]; + people: Person[]; + members: Member[]; + /** Removals waiting out their Undo window. */ + pending: { id: number; vault: string; person: string }[]; +} + +export interface LogEntry { + at: number; + actor: string; + action: string; + detail: string; +} + +export class SignedOut extends Error {} + +async function call(method: string, path: string, body?: unknown): Promise { + const res = await fetch(path, { + method, + credentials: 'same-origin', + headers: { 'X-Lune': '1', ...(body ? { 'Content-Type': 'application/json' } : {}) }, + body: body ? JSON.stringify(body) : undefined, + }); + const data = await res.json().catch(() => ({})); + if (res.status === 401) throw new SignedOut(data.error ?? 'please sign in'); + if (!res.ok) throw new Error(data.error ?? 'something went wrong on the hub'); + return data as T; +} + +export const api = { + canvas: () => call('GET', '/api/canvas'), + log: (count = 8) => call('GET', `/api/log?count=${count}`), + signin: (code: string) => call('POST', '/api/web/signin', { code }), + signout: () => call('POST', '/api/web/signout'), + grant: (person: string, vault: string, role: Role) => call('POST', '/api/grants', { person, vault, role }), + inviteGrant: (person: string, vault: string, role: Role | null, remove = false) => + call('POST', '/api/invites/grant', { person, vault, role, remove }), + remove: (person: string, vault: string, delaySeconds: number) => + call<{ pending?: number }>('POST', '/api/remove', { person, vault, delay_seconds: delaySeconds }), + undoRemove: (pending: number) => call('POST', '/api/remove/undo', { pending }), + invite: (person: string, grants: { vault: string; role: Role }[]) => + call<{ link: string }>('POST', '/api/invites', { person, grants }), + createVault: (name: string) => call('POST', '/api/vaults', { name }), + vaultSetting: (vault: string, deleteFromDevices: boolean) => + call('POST', '/api/vaults/settings', { vault, delete_from_devices: deleteFromDevices }), + renameDevice: (deviceId: string, label: string) => call('POST', '/api/devices/rename', { device_id: deviceId, label }), + removeDevice: (deviceId: string) => call('POST', '/api/device/remove', { device_id: deviceId }), +}; diff --git a/web/src/geometry.ts b/web/src/geometry.ts new file mode 100644 index 0000000..158e6cc --- /dev/null +++ b/web/src/geometry.ts @@ -0,0 +1,81 @@ +// Shapes and places on the canvas. Coordinates are in the board's viewBox: 1000 wide, height grows with the team. + +export type Pt = { x: number; y: number }; +export type Layout = 'float' | 'dock'; + +export const W = 1000; +/** How far along a ribbon (vault → person) its grab dot sits. */ +export const HANDLE_T = 0.8; + +export function boardHeight(nVaults: number, nPeople: number): number { + return Math.max(620, 140 + Math.max(nVaults, nPeople) * 120); +} + +/** Where each vault (left) and person (right) sits. Float is a loose scatter, Dock a tidy column. */ +export function positions(vaults: string[], people: string[], layout: Layout, h: number): Record { + const out: Record = {}; + const jitter = [35, -40, 45, -25, 20, -35]; + const column = (ids: string[], x: number) => { + const top = 120, bottom = h - 90, n = ids.length; + ids.forEach((id, i) => { + const y = n === 1 ? h / 2 : top + (i * (bottom - top)) / (n - 1); + out[id] = { x: layout === 'float' ? x + jitter[i % jitter.length] : x, y }; + }); + }; + column(vaults, 200); + column(people, 770); + return out; +} + +export const lerp = (a: number, b: number, t: number) => a + (b - a) * t; +export function easeBack(t: number) { + const c = 1.3; + return 1 + (c + 1) * Math.pow(t - 1, 3) + c * Math.pow(t - 1, 2); +} + +/** A ribbon from (x1,y1) to (x2,y2): w1/w2 half-widths at the ends, wm at the waist. */ +export function ribbon(x1: number, y1: number, x2: number, y2: number, w1: number, wm: number, w2: number): string { + const dx = x2 - x1, dy = y2 - y1, L = Math.max(1, Math.hypot(dx, dy)); + const ux = dx / L, uy = dy / L, nx = -uy, ny = ux, k = L * 0.35; + const f = (x: number, y: number) => `${x.toFixed(1)} ${y.toFixed(1)}`; + return ( + `M${f(x1 + nx * w1, y1 + ny * w1)} C${f(x1 + ux * k + nx * wm, y1 + uy * k + ny * wm)} ${f(x2 - ux * k + nx * wm, y2 - uy * k + ny * wm)} ${f(x2 + nx * w2, y2 + ny * w2)}` + + ` L${f(x2 - nx * w2, y2 - ny * w2)} C${f(x2 - ux * k - nx * wm, y2 - uy * k - ny * wm)} ${f(x1 + ux * k - nx * wm, y1 + uy * k - ny * wm)} ${f(x1 - nx * w1, y1 - ny * w1)} Z` + ); +} + +export function roundRect(cx: number, cy: number, w: number, h: number, r: number): string { + const x = cx - w / 2, y = cy - h / 2; + return `M${x + r} ${y} h${w - 2 * r} a${r} ${r} 0 0 1 ${r} ${r} v${h - 2 * r} a${r} ${r} 0 0 1 ${-r} ${r} h${-(w - 2 * r)} a${r} ${r} 0 0 1 ${-r} ${-r} v${-(h - 2 * r)} a${r} ${r} 0 0 1 ${r} ${-r} Z`; +} + +export function circle(cx: number, cy: number, r: number): string { + return `M${cx - r} ${cy} a${r} ${r} 0 1 0 ${2 * r} 0 a${r} ${r} 0 1 0 ${-2 * r} 0 Z`; +} + +/** Identity colors (X5): no green, amber, grey or red — those mean status. */ +const VAULT_COLORS = [ + { fill: '#9B85F0', tint: '#ECE6FD', stroke: '#6A4BD0' }, + { fill: '#6FB4EA', tint: '#E2F0FB', stroke: '#2B78B0' }, + { fill: '#EE97B4', tint: '#FCE8EF', stroke: '#B9476E' }, + { fill: '#8FA0F5', tint: '#E8ECFD', stroke: '#3F51B5' }, + { fill: '#C58AE8', tint: '#F5EAFC', stroke: '#8A3FB0' }, + { fill: '#7CC3E0', tint: '#E3F4FA', stroke: '#2A7FA0' }, +]; +const PERSON_COLORS = [ + { fill: '#B3A2F6', tint: '#F2EEFE', ring: '#6A4BD0' }, + { fill: '#F0A6CA', tint: '#FDEEF5', ring: '#B0457A' }, + { fill: '#86CCD8', tint: '#E7F6F8', ring: '#2A8296' }, + { fill: '#D4A2E4', tint: '#F8EEFB', ring: '#8E4AA8' }, + { fill: '#9DB4F2', tint: '#ECF1FD', ring: '#3D5BB8' }, + { fill: '#E9A6E0', tint: '#FBEDF8', ring: '#A2448F' }, +]; + +function pick(list: T[], id: string): T { + let h = 0; + for (const c of id) h = (h * 31 + c.charCodeAt(0)) >>> 0; + return list[h % list.length]; +} + +export const vaultColor = (id: string) => pick(VAULT_COLORS, id); +export const personColor = (id: string) => pick(PERSON_COLORS, id); diff --git a/web/src/main.tsx b/web/src/main.tsx new file mode 100644 index 0000000..b3ca787 --- /dev/null +++ b/web/src/main.tsx @@ -0,0 +1,81 @@ +import { StrictMode, useEffect, useState } from 'react'; +import { createRoot } from 'react-dom/client'; +import { api, SignedOut, type CanvasData } from './api'; +import { Canvas } from './Canvas'; +import './styles.css'; + +/** Sign in with a code from one of your devices (no passwords, §8). */ +function SignIn({ onDone }: { onDone: () => void }) { + const expired = new URLSearchParams(location.search).has('expired'); + const [code, setCode] = useState(''); + const [error, setError] = useState(expired ? 'That sign-in link was used or expired. Run `lunesync open` again, or use a code.' : ''); + const submit = async (e: React.FormEvent) => { + e.preventDefault(); + try { + await api.signin(code); + history.replaceState(null, '', '/'); + onDone(); + } catch (err) { + setError((err as Error).message); + } + }; + return ( +
+
+ Lune +

Sign in to the team canvas

+ + setCode(e.target.value)} placeholder="K7QD-4MXA" autoComplete="one-time-code" autoFocus /> + {error &&

{error}

} + +

Get a code with lunesync pair, or run lunesync open on a device to skip this page.

+
+
+ ); +} + +/** What an invite link shows in a browser: how to join with the app. */ +function Join() { + const link = location.href; + return ( +
+
+ Lune · invite +

You're invited to a team

+

Install the sync app, then join from the device you'll use (this link works once):

+
lunesync join {link} --name "My laptop"
+

Pick any name for the device; your team sees it next to your changes. Shared vaults arrive in ~/Vaults.

+
+
+ ); +} + +function App() { + const [data, setData] = useState(null); + const [state, setState] = useState<'loading' | 'signin' | 'ready' | 'error'>('loading'); + const [error, setError] = useState(''); + + const load = async () => { + try { + setData(await api.canvas()); + setState('ready'); + } catch (e) { + if (e instanceof SignedOut) setState('signin'); + else { + setError((e as Error).message); + setState('error'); + } + } + }; + useEffect(() => { + if (!location.pathname.startsWith('/join/')) load(); + }, []); + + if (location.pathname.startsWith('/join/')) return ; + if (state === 'signin') return ; + if (state === 'error') return

{error}

; + if (!data) return
; + return { await api.signout().catch(() => {}); setState('signin'); }} />; +} + +createRoot(document.getElementById('root')!).render(); diff --git a/web/src/styles.css b/web/src/styles.css new file mode 100644 index 0000000..db600ff --- /dev/null +++ b/web/src/styles.css @@ -0,0 +1,129 @@ +/* The team canvas, after Sen's prototype: ink on lavender paper, display type for names, a calm purple accent. + Status colors (green/amber/grey/red) are reserved for M6 and not used here (X6). */ +:root { + --paper: #F5F3FB; + --dots: #DCD5EE; + --surface: #FFFFFF; + --ink: #221E33; + --muted: #6A6480; + --line: #E2DDF0; + --line-strong: #D7D0EC; + --accent: #6A4BD0; + --accent-hover: #5A3CC0; + --accent-soft: #F1EDFB; + --accent-tint: #E8E1FB; + --focus: #9B84EA; + --danger-ink: #A52A2F; + --font-display: 'Bricolage Grotesque', 'Avenir Next', system-ui, sans-serif; + --font-body: 'Atkinson Hyperlegible', system-ui, -apple-system, sans-serif; +} + +* { box-sizing: border-box; } +html, body { margin: 0; height: 100%; } +body { background: var(--paper); color: var(--ink); font-family: var(--font-body); font-size: 15px; } +code, pre { font-family: ui-monospace, Menlo, monospace; font-size: 0.9em; } +.disp { font-family: var(--font-display); } +.muted { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0; } +.eyebrow { font-size: 12px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); font-weight: 700; } +.error { color: var(--danger-ink); margin: 0; font-size: 14px; } + +.btn { font: inherit; font-size: 14px; min-height: 40px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; } +.btn:hover { background: var(--accent-soft); } +.btn:disabled { opacity: 0.55; cursor: default; } +.btn-primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; } +.btn-primary:hover { background: var(--accent-hover); } +.btn-danger { color: var(--danger-ink); border-color: #EBC5C7; } +.btn-danger:hover { background: #FBEDED; } +.btn-small { min-height: 32px; padding: 4px 10px; font-size: 13px; border-radius: 10px; } +.btn-ghost { border-color: transparent; background: transparent; } +button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; } +.field { font: inherit; font-size: 15px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); width: 100%; } +.field.code { font-family: var(--font-display); font-size: 24px; letter-spacing: 3px; text-transform: uppercase; } + +/* Sign-in and join pages */ +.page { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; } +.card { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 28px; width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 16px 40px rgba(34, 30, 51, 0.08); } +.card h1 { margin: 0; font-size: 26px; line-height: 1.15; } +.card p { margin: 0; line-height: 1.5; } +.card label { font-weight: 700; font-size: 14px; } +.cmd { background: #1E1B2E; color: #EDE9F8; border-radius: 12px; padding: 12px 14px; margin: 0; overflow-x: auto; white-space: pre-wrap; word-break: break-all; } + +/* Canvas */ +.root { height: 100vh; height: 100dvh; overflow: hidden; position: relative; background-color: var(--paper); background-image: radial-gradient(var(--dots) 1.2px, transparent 1.4px); background-size: 24px 24px; } +.bob { animation: bob 4.6s ease-in-out infinite; } +@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } } +.fade { transition: opacity 0.2s ease; } +.stage { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 88px 24px 84px; transition: padding 0.3s ease; } +.board { position: relative; container-type: inline-size; } +.open .stage { padding-right: 428px; } +.topbar { position: absolute; top: 0; left: 0; right: 0; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 16px; pointer-events: none; z-index: 12; } +.topbar > * { pointer-events: auto; } +.float-card { background: rgba(255, 255, 255, 0.94); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 6px 20px rgba(34, 30, 51, 0.08); } +.seg { display: flex; padding: 4px; gap: 4px; background: var(--accent-soft); border-radius: 14px; } +.seg .btn { border-color: transparent; background: transparent; color: var(--muted); } +.seg .btn[aria-pressed='true'] { background: #FFFFFF; color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(34, 30, 51, 0.12); } +.bottombar { position: absolute; left: 16px; right: 16px; bottom: 16px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 8px; pointer-events: none; z-index: 11; transition: right 0.3s ease; } +.open .bottombar { right: 428px; } +.chipbar { background: rgba(255, 255, 255, 0.94); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 13px; color: var(--muted); } +.chipbar.hot { color: #4B2FB0; font-weight: 700; } +.empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; } +.empty > div { pointer-events: auto; text-align: center; max-width: 360px; display: flex; flex-direction: column; gap: 10px; align-items: center; } + +.panel { position: absolute; top: 84px; right: 16px; bottom: 16px; width: 396px; max-width: calc(100% - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 20px; display: flex; flex-direction: column; gap: 20px; box-shadow: 0 16px 40px rgba(34, 30, 51, 0.14); z-index: 15; animation: slidein 0.25s ease-out; } +.panel h2 { margin: 0; font-size: 24px; } +.panel h3 { margin: 0 0 6px; font-size: 12px; letter-spacing: 1.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; } +.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; } +.panel-head > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; } +.backbtn { font: inherit; font-size: 13px; font-weight: 700; background: none; border: 0; color: var(--accent); cursor: pointer; padding: 6px 8px; margin: -8px 0 -6px -8px; border-radius: 8px; align-self: flex-start; } +.backbtn:hover { background: var(--accent-soft); } +.ov-sec { background: #F8F6FC; border: 1px solid #ECE8F5; border-radius: 18px; padding: 12px; display: flex; flex-direction: column; gap: 2px; } +.ov-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 6px 8px; } +.ov-count { font-size: 12px; color: var(--muted); background: #FFFFFF; border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; } +.row { font: inherit; display: flex; align-items: center; gap: 12px; width: 100%; background: transparent; border: 0; border-radius: 12px; padding: 8px 6px; cursor: pointer; text-align: left; color: var(--ink); } +.row:hover { background: #FFFFFF; } +.row .sub { font-size: 13px; color: var(--muted); } +.chev { color: #A39DB8; font-size: 20px; line-height: 1; flex: none; } +.member { display: flex; align-items: center; gap: 10px; padding: 6px 0; } +.namebtn { font: inherit; font-weight: 700; flex: 1; text-align: left; background: none; border: 0; padding: 4px 0; cursor: pointer; color: var(--ink); min-width: 0; overflow: hidden; text-overflow: ellipsis; } +.namebtn:hover { color: var(--accent); text-decoration: underline; } +.avatar { width: 34px; height: 34px; border-radius: 50%; border: 3px solid; display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; } +.swatch { width: 34px; height: 34px; border-radius: 11px; border: 2px solid; display: flex; align-items: center; justify-content: center; flex: none; } +.device { border: 1px solid var(--line); border-radius: 16px; padding: 12px; display: flex; flex-direction: column; gap: 8px; } +.device-head { display: flex; align-items: center; gap: 10px; } +.chips { display: flex; gap: 8px; flex-wrap: wrap; } +.note { background: var(--accent-soft); border: 1px solid var(--line-strong); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; line-height: 1.45; } +.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; line-height: 1.45; } +.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; } +.log { list-style: none; margin: 0; padding: 0 6px; display: flex; flex-direction: column; } +.log li { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 10px; padding: 7px 0; font-size: 14px; line-height: 1.4; } +.log li i { width: 8px; height: 8px; border-radius: 50%; background: #BBA8F2; margin-top: 6px; display: block; } + +.coach { position: absolute; left: 16px; bottom: 68px; z-index: 13; width: 320px; max-width: calc(100% - 32px); background: #FFFFFF; border: 1px solid var(--line); border-radius: 20px; padding: 16px; box-shadow: 0 12px 32px rgba(34, 30, 51, 0.14); display: flex; flex-direction: column; gap: 10px; } +.tip { display: flex; gap: 10px; font-size: 14px; line-height: 1.45; } +.tipn { width: 22px; height: 22px; border-radius: 50%; background: var(--accent-tint); color: #4B2FB0; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; flex: none; } + +.scrim { position: fixed; inset: 0; background: rgba(34, 30, 51, 0.38); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20; } +.dialog { background: #FFFFFF; border-radius: 24px; padding: 24px; width: 100%; max-width: 460px; display: flex; flex-direction: column; gap: 14px; max-height: calc(100dvh - 32px); overflow-y: auto; } +.dialog h2 { margin: 0; font-size: 22px; } +.dialog label.lbl { font-size: 14px; font-weight: 700; } +.actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; } + +.toast-wrap { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30; width: max-content; max-width: calc(100% - 32px); } +.toast { background: var(--ink); color: #FFFFFF; padding: 10px 10px 10px 18px; border-radius: 14px; font-size: 14px; line-height: 1.4; box-shadow: 0 8px 24px rgba(34, 30, 51, 0.25); display: flex; align-items: center; gap: 12px; } +.undo { font: inherit; font-size: 14px; font-weight: 700; background: none; border: 0; color: #C9B8FF; cursor: pointer; padding: 6px 8px; border-radius: 8px; } +.undo:hover { background: rgba(255, 255, 255, 0.1); } + +@keyframes slidein { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } } +@keyframes slideup { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } } +@media (max-width: 720px) { + .stage { padding: 136px 8px 64px; } + .open .stage { padding-right: 8px; padding-bottom: 58vh; } + .panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-width: none; height: 56vh; animation-name: slideup; } + .open .bottombar { display: none; } + .coach { bottom: 16px; } +} +@media (prefers-reduced-motion: reduce) { + .bob { animation: none; } + .panel { animation: none; } + .stage, .bottombar, .fade { transition: none; } +} diff --git a/web/tsconfig.json b/web/tsconfig.json new file mode 100644 index 0000000..e1b38e1 --- /dev/null +++ b/web/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "target": "ES2020", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "moduleResolution": "bundler", + "jsx": "react-jsx", + "strict": true, + "noEmit": true, + "skipLibCheck": true, + "isolatedModules": true, + "noUnusedLocals": true, + "noUnusedParameters": true + }, + "include": ["src"] +} diff --git a/web/tsconfig.tsbuildinfo b/web/tsconfig.tsbuildinfo new file mode 100644 index 0000000..cbbc852 --- /dev/null +++ b/web/tsconfig.tsbuildinfo @@ -0,0 +1 @@ +{"root":["./src/canvas.tsx","./src/api.ts","./src/geometry.ts","./src/main.tsx"],"version":"5.6.3"} \ No newline at end of file diff --git a/web/vite.config.ts b/web/vite.config.ts new file mode 100644 index 0000000..cc5199c --- /dev/null +++ b/web/vite.config.ts @@ -0,0 +1,8 @@ +import { defineConfig } from 'vite'; +import react from '@vitejs/plugin-react'; + +// `npm run dev` talks to a hub on :8080; `npm run build` output is embedded in the hub binary. +export default defineConfig({ + plugins: [react()], + server: { proxy: { '/api': 'http://127.0.0.1:8080', '/signin/': 'http://127.0.0.1:8080' } }, +});