feat!: release v2 (#6545)

Co-authored-by: Artur <145776561+arturict@users.noreply.github.com>
Co-authored-by: arturict <arturict@users.noreply.github.com>
Co-authored-by: Thomas <thomas@ajnart.fr>
Co-authored-by: Afonso Jorge Ramos <afonsojorgeramos@gmail.com>
Co-authored-by: Danura30082 <danura30082+github@gmail.com>
Co-authored-by: Kushie <122986913+kushiemoon-dev@users.noreply.github.com>
Co-authored-by: ajnart <thomas@ajnart.fr>
Co-authored-by: ajnart <thomas@ajnart.dev>
Co-authored-by: chenjun <chenjun@foxmail.com>
Co-authored-by: Wikibear <wikibear@users.noreply.github.com>
Co-authored-by: Bergasha <bergasha@gmail.com>
Co-authored-by: leafyelin <43306196+leafyelin@users.noreply.github.com>
Co-authored-by: Lucas Araujo <lucas.lra@gmail.com>
Co-authored-by: GreenMonito <86085570+GreenMonito@users.noreply.github.com>
Co-authored-by: Nerdy-Technician <roffo@nerdy-technician.social>
Co-authored-by: Jun <34545896+jcstrong@users.noreply.github.com>
Co-authored-by: Edmond Abraham <54119952+gitedmond@users.noreply.github.com>
Co-authored-by: thrawnx <tight.bulb9384@fastmail.com>
Co-authored-by: Chris <58918656+nordada@users.noreply.github.com>
Co-authored-by: yi111 <153097222+Yi-111-a@users.noreply.github.com>
Co-authored-by: Yanis <naamaneyanis@gmail.com>
Co-authored-by: Wikibear <me@sej.de>
Co-authored-by: alessiottavo <93441886+alessiottavo@users.noreply.github.com>
This commit is contained in:
3286 files changed
+284386 -139176

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
declare module "*.svg" {
const content: string;
export default content;
}
+70
View File
@@ -0,0 +1,70 @@
// Pure timing helpers. Every visual value in the reel is a function of time.
export const clamp = (v: number, a = 0, b = 1) => Math.min(b, Math.max(a, v));
export const lerp = (a: number, b: number, t: number) => a + (b - a) * t;
export const seg = (t: number, a: number, b: number) => clamp((t - a) / (b - a));
export const map = (t: number, a: number, b: number, c: number, d: number) => lerp(c, d, seg(t, a, b));
export const E = {
linear: (t: number) => t,
inQuad: (t: number) => t * t,
outQuad: (t: number) => 1 - (1 - t) * (1 - t),
inCubic: (t: number) => t * t * t,
outCubic: (t: number) => 1 - (1 - t) ** 3,
inOutCubic: (t: number) => (t < 0.5 ? 4 * t * t * t : 1 - (-2 * t + 2) ** 3 / 2),
outQuart: (t: number) => 1 - (1 - t) ** 4,
inQuart: (t: number) => t ** 4,
inOutQuart: (t: number) => (t < 0.5 ? 8 * t ** 4 : 1 - (-2 * t + 2) ** 4 / 2),
outQuint: (t: number) => 1 - (1 - t) ** 5,
inOutQuint: (t: number) => (t < 0.5 ? 16 * t ** 5 : 1 - (-2 * t + 2) ** 5 / 2),
outExpo: (t: number) => (t >= 1 ? 1 : 1 - 2 ** (-10 * t)),
inExpo: (t: number) => (t <= 0 ? 0 : 2 ** (10 * t - 10)),
inOutExpo: (t: number) =>
t <= 0 ? 0 : t >= 1 ? 1 : t < 0.5 ? 2 ** (20 * t - 10) / 2 : (2 - 2 ** (-20 * t + 10)) / 2,
outBack: (t: number, s = 1.70158) => 1 + (s + 1) * (t - 1) ** 3 + s * (t - 1) ** 2,
inBack: (t: number, s = 1.70158) => (s + 1) * t ** 3 - s * t * t,
outCirc: (t: number) => Math.sqrt(1 - (t - 1) ** 2),
inOutSine: (t: number) => -(Math.cos(Math.PI * t) - 1) / 2,
};
/** Analytic damped spring from 0 to 1. `t` in seconds. */
export function spring(t: number, freq = 3.2, damp = 0.42) {
if (t <= 0) return 0;
const w = 2 * Math.PI * freq;
const wd = w * Math.sqrt(1 - damp * damp);
return 1 - Math.exp(-damp * w * t) * (Math.cos(wd * t) + ((damp * w) / wd) * Math.sin(wd * t));
}
/** Seeded, stateless pseudo random in [0, 1). */
export function rand(seed: number) {
const x = Math.sin(seed * 127.1 + 311.7) * 43758.5453123;
return x - Math.floor(x);
}
/** Smooth 1D value noise, stateless. */
export function noise(x: number, seed = 0) {
const i = Math.floor(x);
const f = x - i;
const u = f * f * (3 - 2 * f);
return lerp(rand(i + seed * 97.3), rand(i + 1 + seed * 97.3), u) * 2 - 1;
}
/** Envelope: 0 → 1 during [a, a+inD], holds, 1 → 0 during [b-outD, b]. */
export function env(t: number, a: number, b: number, inD = 0.5, outD = 0.4, ei = E.outExpo, eo = E.inCubic) {
if (t < a || t > b) return 0;
const i = ei(seg(t, a, a + inD));
const o = 1 - eo(seg(t, b - outD, b));
return Math.min(i, o);
}
/** Beat pulse: sharp attack, exponential decay after each hit time. */
export function pulse(t: number, hits: number[], decay = 6) {
let v = 0;
for (const h of hits) if (t >= h) v = Math.max(v, Math.exp(-(t - h) * decay));
return v;
}
// Tempo of the soundtrack (MOKKA – Synthetic Pleasures); scene lengths are whole bars of it.
export const BPM = 93;
export const BEAT = 60 / BPM;
export const BAR = BEAT * 4;
+147
View File
@@ -0,0 +1,147 @@
// Minimal DOM helpers for frame-driven animation.
type Child = Node | string | null | undefined | false;
export function h<K extends keyof HTMLElementTagNameMap>(
tag: K,
props: { class?: string; style?: Partial<CSSStyleDeclaration> | string; html?: string; [k: string]: unknown } = {},
...children: Child[]
): HTMLElementTagNameMap[K] {
const el = document.createElement(tag);
for (const [key, value] of Object.entries(props)) {
if (value == null) continue;
if (key === "class") el.className = value as string;
else if (key === "style") {
if (typeof value === "string") el.style.cssText = value;
else Object.assign(el.style, value);
} else if (key === "html") el.innerHTML = value as string;
else el.setAttribute(key, String(value));
}
for (const child of children) {
if (child == null || child === false) continue;
el.append(typeof child === "string" ? document.createTextNode(child) : child);
}
return el;
}
export const div = (cls = "", ...children: Child[]) => h("div", { class: cls }, ...children);
export interface Tf {
x?: number;
y?: number;
z?: number;
s?: number;
sx?: number;
sy?: number;
r?: number;
rx?: number;
ry?: number;
skx?: number;
o?: number;
blur?: number;
bright?: number;
px?: boolean;
}
/** Apply a transform snapshot. Translation in px, rotations in degrees. */
export function tf(el: HTMLElement | SVGElement, t: Tf) {
const s = t.s ?? 1;
const sx = (t.sx ?? 1) * s;
const sy = (t.sy ?? 1) * s;
let str = `translate3d(${(t.x ?? 0).toFixed(2)}px,${(t.y ?? 0).toFixed(2)}px,${(t.z ?? 0).toFixed(2)}px)`;
if (t.rx) str += ` rotateX(${t.rx.toFixed(3)}deg)`;
if (t.ry) str += ` rotateY(${t.ry.toFixed(3)}deg)`;
if (t.r) str += ` rotate(${t.r.toFixed(3)}deg)`;
if (t.skx) str += ` skewX(${t.skx.toFixed(3)}deg)`;
if (sx !== 1 || sy !== 1) str += ` scale(${sx.toFixed(4)},${sy.toFixed(4)})`;
el.style.transform = str;
const o = t.o ?? 1;
el.style.opacity = o.toFixed(3);
el.style.visibility = o <= 0.001 ? "hidden" : "visible";
const filters: string[] = [];
if (t.blur && t.blur > 0.05) filters.push(`blur(${t.blur.toFixed(2)}px)`);
if (t.bright != null && t.bright !== 1) filters.push(`brightness(${t.bright.toFixed(3)})`);
el.style.filter = filters.join(" ");
}
export function show(el: HTMLElement, on: boolean) {
el.style.display = on ? "" : "none";
}
/** Tabler icon placeholder, hydrated from node_modules before rendering starts. */
export function icon(name: string, size = 24, stroke = 2, cls = "") {
const el = h("span", { class: `ti ${cls}`, "data-icon": name });
el.style.width = `${size}px`;
el.style.height = `${size}px`;
el.style.setProperty("--sw", String(stroke));
return el;
}
/** Service logo from dashboard-icons. */
export function logo(name: string, size = 40, cls = "") {
const ext = ["linkwarden", "plantit", "tubearchivist", "unmanic", "xteve"].includes(name) ? "png" : "svg";
return h("img", { class: `svc ${cls}`, src: `assets/icons/${name}.${ext}`, width: size, height: size, alt: "" });
}
export async function hydrateIcons(root: ParentNode) {
const nodes = [...root.querySelectorAll<HTMLElement>("[data-icon]")];
const names = [...new Set(nodes.map((n) => n.dataset.icon!))];
const cache = new Map<string, string>();
await Promise.all(
names.map(async (name) => {
const [dir, file] = name.startsWith("filled:") ? ["filled", name.slice(7)] : ["outline", name];
const res = await fetch(`node_modules/@tabler/icons/icons/${dir}/${file}.svg`);
if (!res.ok) throw new Error(`missing icon ${name}`);
cache.set(name, await res.text());
}),
);
for (const n of nodes) n.innerHTML = cache.get(n.dataset.icon!)!;
}
/** Split text into per-character spans (words kept together). */
export function chars(text: string, cls = "ch") {
const wrap = h("span", { class: "chars" });
const out: HTMLElement[] = [];
text.split(/(\s+)/).forEach((word) => {
if (/^\s+$/.test(word)) {
wrap.append(document.createTextNode(word));
return;
}
const w = h("span", { class: "word" });
for (const c of word) {
const s = h("span", { class: cls }, c);
out.push(s);
w.append(s);
}
wrap.append(w);
});
return { el: wrap, chars: out };
}
/** Split text into word spans inside overflow masks. */
export function words(text: string) {
const wrap = h("span", { class: "words" });
const out: HTMLElement[] = [];
text.split(/\s+/).forEach((word, i) => {
if (i) wrap.append(document.createTextNode(" "));
const mask = h("span", { class: "wmask" });
const w = h("span", { class: "w" }, word);
mask.append(w);
out.push(w);
wrap.append(mask);
});
return { el: wrap, words: out };
}
/** Layout offset of `el` inside `root`, ignoring transforms (transformed ancestors count as offsetParents in Chrome). */
export function offsetWithin(el: HTMLElement, root: HTMLElement) {
let x = 0;
let y = 0;
let e: HTMLElement | null = el;
while (e && e !== root) {
x += e.offsetLeft;
y += e.offsetTop;
e = e.offsetParent as HTMLElement | null;
}
return [x, y] as const;
}
+239
View File
@@ -0,0 +1,239 @@
// Reusable motion components. Each exposes update(t) driven by scene-local time.
import { E, clamp, seg, lerp, spring } from "./anim";
import { h, words, chars } from "./dom";
/** Word-by-word masked rise. */
export class Headline {
el: HTMLElement;
ws: HTMLElement[];
constructor(
text: string,
opts: { size: number; cls?: string; accent?: string[]; color?: string; weight?: number; lh?: number } = {
size: 96,
},
) {
const { el, words: ws } = words(text);
this.el = h("div", { class: `display ${opts.cls ?? ""}` }, el);
this.el.style.fontSize = `${opts.size}px`;
if (opts.weight) this.el.style.fontWeight = String(opts.weight);
if (opts.lh) this.el.style.lineHeight = String(opts.lh);
if (opts.color) this.el.style.color = opts.color;
this.ws = ws;
const accent = new Set((opts.accent ?? []).map((w) => w.toLowerCase()));
for (const w of ws)
if (accent.has(w.textContent!.toLowerCase().replace(/[.,!?]/g, ""))) w.style.color = "var(--coral)";
}
update(t: number, tin: number, tout = Infinity, stagger = 0.055, dur = 0.75) {
this.ws.forEach((w, i) => {
const p = E.outExpo(seg(t, tin + i * stagger, tin + i * stagger + dur));
const q = E.inCubic(seg(t, tout + i * stagger * 0.3, tout + i * stagger * 0.3 + 0.3));
const y = (1 - p) * 115 - q * 115;
const rot = (1 - p) * 7 - q * 4;
w.style.transform = `translateY(${y.toFixed(2)}%) rotate(${rot.toFixed(2)}deg)`;
// Rotated words can poke out of their mask while parked; hide them.
w.style.visibility = p <= 0 || q >= 1 ? "hidden" : "visible";
});
return this;
}
}
/** Per-character reveal with blur + scale, for punchier moments. */
export class CharPop {
el: HTMLElement;
cs: HTMLElement[];
constructor(text: string, size: number, cls = "display") {
const { el, chars: cs } = chars(text);
this.el = h("div", { class: cls }, el);
this.el.style.fontSize = `${size}px`;
this.cs = cs;
}
update(t: number, tin: number, tout = Infinity, stagger = 0.03, from: "center" | "left" = "left") {
const n = this.cs.length;
this.cs.forEach((c, i) => {
const order = from === "center" ? Math.abs(i - (n - 1) / 2) : i;
const s0 = tin + order * stagger;
const p = seg(t, s0, s0 + 0.6);
const sp = spring(t - s0, 2.6, 0.5);
const q = E.inExpo(seg(t, tout + order * stagger * 0.4, tout + order * stagger * 0.4 + 0.35));
const y = (1 - sp) * 60 - q * 40;
const sc = lerp(1.6, 1, E.outExpo(p)) * (1 - q * 0.3);
c.style.transform = `translateY(${y.toFixed(2)}px) scale(${sc.toFixed(3)})`;
c.style.opacity = String(clamp(p * 3) * (1 - q));
const b = (1 - E.outCubic(p)) * 14 + q * 10;
c.style.filter = b > 0.1 ? `blur(${b.toFixed(2)}px)` : "";
});
return this;
}
}
/** Chapter marker: index + label with a drawn rule. */
export class Chapter {
el: HTMLElement;
num: HTMLElement;
rule: HTMLElement;
lab: HTMLElement;
constructor(index: string, label: string) {
this.num = h(
"div",
{ class: "mono", style: "font-size:17px;font-weight:700;color:var(--coral);letter-spacing:.1em" },
index,
);
this.rule = h("div", { style: "height:2px;width:64px;background:var(--coral);transform-origin:0 50%" });
this.lab = h("div", { class: "label", style: "color:var(--text);opacity:.9" }, label);
this.el = h("div", { class: "abs row", style: "gap:18px;left:96px;top:78px" }, this.num, this.rule, this.lab);
}
update(t: number, tin: number, tout = Infinity) {
const p = E.outExpo(seg(t, tin, tin + 0.8));
const q = E.inCubic(seg(t, tout, tout + 0.4));
this.rule.style.transform = `scaleX(${(p * (1 - q)).toFixed(3)})`;
this.num.style.opacity = String(p * (1 - q));
this.num.style.transform = `translateX(${((1 - p) * -20).toFixed(1)}px)`;
this.lab.style.clipPath = `inset(0 ${((1 - E.outQuart(seg(t, tin + 0.15, tin + 0.9))) * 100).toFixed(1)}% 0 0)`;
this.lab.style.opacity = String(1 - q);
return this;
}
}
/** Plain text typewriter with caret. */
export class TypeLine {
el: HTMLElement;
txt: HTMLElement;
caret: HTMLElement;
constructor(
public text: string,
cls = "",
caretColor = "var(--coral)",
) {
this.txt = h("span");
this.caret = h("span", { class: "caret" });
this.caret.style.background = caretColor;
this.el = h("span", { class: cls }, this.txt, this.caret);
}
update(t: number, t0: number, cps = 28, caretUntil = Infinity) {
const n = Math.max(0, Math.min(this.text.length, Math.floor((t - t0) * cps)));
this.txt.textContent = this.text.slice(0, n);
const typing = t >= t0 && n < this.text.length;
const blink = typing || Math.floor(t * 2.2) % 2 === 0;
this.caret.style.opacity = t < t0 - 0.4 || t > caretUntil ? "0" : blink ? "1" : "0";
return n >= this.text.length;
}
get duration() {
return this.text.length;
}
}
export type Tok = [string, string?];
/** Syntax-highlighted code typewriter: lines of [text, class] tokens. */
export class CodeType {
el: HTMLElement;
spans: { el: HTMLElement; text: string; start: number }[] = [];
lines: HTMLElement[] = [];
caret: HTMLElement;
total = 0;
lineStart: number[] = [];
constructor(code: Tok[][], cls = "mono") {
this.el = h("div", { class: cls });
this.caret = h("span", { class: "caret" });
let n = 0;
code.forEach((line) => {
const ln = h("div", { style: "white-space:pre;min-height:1.5em" });
this.lineStart.push(n);
line.forEach(([text, c]) => {
const s = h("span", { class: c ? `tok-${c}` : "" });
this.spans.push({ el: s, text, start: n });
n += text.length;
ln.append(s);
});
n += 1; // newline
this.lines.push(ln);
this.el.append(ln);
});
this.total = n;
}
/** Reveal n characters. Returns index of the current line. */
set(n: number, showCaret = true) {
let caretHost: HTMLElement | null = null;
for (const s of this.spans) {
const k = clamp(n - s.start, 0, s.text.length);
s.el.textContent = s.text.slice(0, k);
if (n >= s.start && n <= s.start + s.text.length) caretHost = s.el;
}
let line = 0;
this.lineStart.forEach((st, i) => {
if (n >= st) line = i;
});
if (showCaret && caretHost) caretHost.after(this.caret);
else if (showCaret) this.lines[line]?.append(this.caret);
this.caret.style.display = showCaret ? "" : "none";
return line;
}
}
/** Number that counts up with easing. */
export function countTo(
el: HTMLElement,
t: number,
t0: number,
t1: number,
to: number,
from = 0,
fmt = (v: number) => String(Math.round(v)),
) {
el.textContent = fmt(lerp(from, to, E.outExpo(seg(t, t0, t1))));
}
/** Draw an SVG path progressively. Requires pathLength="1". */
export function drawPath(p: SVGPathElement | SVGGeometryElement, a: number, b = 0) {
p.style.strokeDasharray = "1 1";
const len = clamp(a - b);
p.style.strokeDasharray = `${len} ${2}`;
p.style.strokeDashoffset = String(-b);
}
export const svgNS = "http://www.w3.org/2000/svg";
export function svg<K extends keyof SVGElementTagNameMap>(tag: K, attrs: Record<string, string | number> = {}) {
const el = document.createElementNS(svgNS, tag);
for (const [k, v] of Object.entries(attrs)) el.setAttribute(k, String(v));
return el;
}
/** Evaluate point on cubic bezier. */
export function bez(p0: number[], p1: number[], p2: number[], p3: number[], t: number) {
const u = 1 - t;
return [0, 1].map(
(i) => u * u * u * p0[i]! + 3 * u * u * t * p1[i]! + 3 * u * t * t * p2[i]! + t * t * t * p3[i]!,
) as [number, number];
}
/** Typewriter that keeps its final layout: untyped text is present but transparent, so wrapping never jumps. */
export class TypeBlock {
el: HTMLElement;
shown: HTMLElement;
rest: HTMLElement;
caret: HTMLElement;
constructor(
public text: string,
cls = "",
caretColor = "var(--coral)",
) {
this.shown = h("span");
this.rest = h("span", { style: "color:transparent" });
this.caret = h("span", { class: "caret" });
this.caret.style.background = caretColor;
this.caret.style.marginRight = "-3px";
this.el = h("span", { class: cls }, this.shown, this.caret, this.rest);
}
update(t: number, t0: number, cps = 28, caretUntil = Infinity) {
const n = Math.max(0, Math.min(this.text.length, Math.floor((t - t0) * cps)));
this.shown.textContent = this.text.slice(0, n);
this.rest.textContent = this.text.slice(n);
const typing = t >= t0 && n < this.text.length;
const blink = typing || Math.floor(t * 2.2) % 2 === 0;
this.caret.style.opacity = t < t0 - 0.4 || t > caretUntil ? "0" : blink ? "1" : "0";
return n >= this.text.length;
}
end(t0: number, cps = 28) {
return t0 + this.text.length / cps;
}
}
+85
View File
@@ -0,0 +1,85 @@
import type { LogoState } from "../three/logo";
export interface Fx {
flash: number; // 0..1 white flash
flashColor: string;
shake: number; // px amplitude
ca: number; // chromatic aberration px
fade: number; // 0..1 black
zoom: number; // world zoom punch
grain: number;
vignette: number;
glBlur: number;
}
export interface Ctx {
logo: LogoState;
fx: Fx;
frame: number;
}
export type CueKind =
| "hit" // big impact
| "boom" // sub drop / huge impact
| "whoosh"
| "swish" // short whoosh
| "riser" // build (duration)
| "click"
| "pop"
| "tick" // UI tick
| "type" // typing range (duration)
| "zap" // electric beam
| "chime" // success
| "buzz" // phone buzz
| "glitch"
| "stamp"
| "key" // key press
| "reverse"; // reverse cymbal into a hit (ends at t)
export interface Cue {
t: number;
kind: CueKind;
dur?: number;
gain?: number;
pitch?: number;
pan?: number;
}
export interface Scene {
name: string;
start: number;
end: number;
bg?: HTMLElement;
fg: HTMLElement;
cues: Cue[];
/** Reading holds: scene-local [from, to, speed] ranges played slower than authored. */
warp?: [number, number, number][];
/** Push transition from the previous scene, centred on this scene's first downbeat. */
enter?: { dir: "up" | "left"; dur: number };
update(t: number, ctx: Ctx): void;
}
/** Map between authored scene time and output time for a set of slow-motion holds. */
export function timeWarp(warp: [number, number, number][] = []) {
const w = [...warp].sort((a, b) => a[0] - b[0]);
const toOut = (t: number) => {
let u = t;
for (const [a, b, sp] of w) if (t > a) u += (Math.min(t, b) - a) * (1 / sp - 1);
return u;
};
const toLocal = (u: number) => {
let cur = 0;
let o = 0;
for (const [a, b, sp] of w) {
if (u <= o + (a - cur)) return cur + (u - o);
o += a - cur;
cur = a;
const len = (b - a) / sp;
if (u <= o + len) return a + (u - o) * sp;
o += len;
cur = b;
}
return cur + (u - o);
};
return { toOut, toLocal };
}
+265
View File
@@ -0,0 +1,265 @@
import { LogoGL, defaultLogoState } from "./three/logo";
import { hydrateIcons } from "./lib/dom";
import { BAR, E, lerp, noise, rand } from "./lib/anim";
import { timeWarp, type Ctx, type Cue, type Scene } from "./lib/scene";
import { intro, PX_PER_UNIT } from "./scenes/intro";
import { customWidgets } from "./scenes/custom-widgets";
import { workshop } from "./scenes/workshop";
import { frontDoor } from "./scenes/front-door";
import { ntfy } from "./scenes/ntfy";
import { assistant } from "./scenes/assistant";
import { board } from "./scenes/board";
import { advanced } from "./scenes/advanced";
import { rest } from "./scenes/rest";
import { stats } from "./scenes/stats";
import { outro } from "./scenes/outro";
declare global {
interface Window {
__seek: (t: number) => void;
__ready: Promise<void>;
__duration: number;
__cues: Cue[];
__fps: number;
}
}
const FPS = 60;
// Scene lengths in soundtrack bars. The soundtrack starts on a phrase crash; the assistant lands on the drop, and
// the edits in audio.py put the board and the globe on crashes and the end card on the final hit.
const CRASH_BARS = [0, 8, 22, 30, 34];
const BARS: Record<string, number> = {
intro: 1.5,
"custom-widgets": 3.5,
workshop: 3,
assistant: 4,
"front-door": 5,
ntfy: 5,
board: 4,
advanced: 1.5,
rest: 2.5,
stats: 4,
};
const bg = document.getElementById("bg")!;
const fg = document.getElementById("fg")!;
const world = document.getElementById("world")!;
const flash = document.getElementById("flash")!;
const fade = document.getElementById("fade")!;
const grain = document.getElementById("grain")!;
const vignette = document.getElementById("vignette")!;
const caR = document.getElementById("ca-r")!;
const caB = document.getElementById("ca-b")!;
const blurStd = { up: document.getElementById("vblur-std")!, left: document.getElementById("hblur-std")! };
function makeGrain() {
const c = document.createElement("canvas");
c.width = c.height = 384;
const g = c.getContext("2d")!;
const img = g.createImageData(384, 384);
for (let i = 0; i < img.data.length; i += 4) {
const v = rand(i * 0.37 + 1.3) * 255;
img.data[i] = img.data[i + 1] = img.data[i + 2] = v;
img.data[i + 3] = 255;
}
g.putImageData(img, 0, 0);
return c.toDataURL();
}
async function boot() {
grain.style.backgroundImage = `url(${makeGrain()})`;
const svg = await (await fetch("assets/homarr.svg")).text();
const wordmarkSvg = await (await fetch("assets/homarr-wordmark-rig.svg")).text();
// Kick envelope of the edited soundtrack (written by audio.py); falls back to the bar grid.
const musicEnv: { rate: number; kick: number[] } | null = await fetch("assets/music-env.json")
.then((r) => (r.ok ? r.json() : null))
.catch(() => null);
const glCanvas = document.getElementById("gl") as HTMLCanvasElement;
const gl = new LogoGL(glCanvas, svg, wordmarkSvg);
(window as unknown as { __gl: LogoGL }).__gl = gl;
const scenes: Scene[] = [
intro(),
customWidgets(),
workshop(),
assistant(),
frontDoor(),
ntfy(),
board(),
advanced(),
rest(),
stats(),
outro(),
];
for (const s of scenes) {
if (s.bg) {
s.bg.dataset.scene = s.name;
bg.append(s.bg);
}
s.fg.dataset.scene = s.name;
fg.append(s.fg);
}
await hydrateIcons(document);
await document.fonts.ready;
await Promise.all(
[...document.images].map((img) => (img.complete ? Promise.resolve() : img.decode().catch(() => undefined))),
);
// Scenes play back to back; each one's authored length is stretched by its reading holds, then uniformly
// retimed to its bar count.
const warps = scenes.map((s) => {
const w = timeWarp(s.warp);
const bars = BARS[s.name];
const k = bars ? (bars * BAR) / w.toOut(s.end - s.start) : 1;
return { toOut: (t: number) => w.toOut(t) * k, toLocal: (u: number) => w.toLocal(u / k), k };
});
let acc = 0;
scenes.forEach((s, i) => {
const len = warps[i]!.toOut(s.end - s.start);
s.start = acc;
s.end = acc = acc + len;
});
window.__duration = acc;
window.__cues = scenes
.flatMap((s, i) =>
s.cues.map((c) => {
const w = warps[i]!;
const t = w.toOut(c.t);
return { ...c, t: t + s.start, ...(c.dur ? { dur: w.toOut(c.t + c.dur) - t } : {}) };
}),
)
.sort((a, b) => a.t - b.t);
const w = window as unknown as { __scenes: unknown; __at: (name: string, t: number) => number };
w.__scenes = scenes.map((s, i) => ({ name: s.name, start: s.start, end: s.end, k: warps[i]!.k }));
// Authored scene time → global output time, for stills and debugging.
w.__at = (name, t) => {
const i = scenes.findIndex((s) => s.name === name);
return scenes[i]!.start + warps[i]!.toOut(t);
};
// Push transitions: the outgoing scene keeps playing past its end while the incoming one (at negative local
// time for the first half) slides in behind it, with motion blur along the push.
const whipAt = (T: number) => {
for (let j = 1; j < scenes.length; j++) {
const e = scenes[j]!.enter;
if (e && Math.abs(T - scenes[j]!.start) < e.dur / 2)
return { j, dir: e.dir, u: (T - scenes[j]!.start + e.dur / 2) / e.dur, dur: e.dur };
}
return null;
};
const place = (s: Scene, off: number, dir: "up" | "left") => {
const tr = off === 0 ? "" : dir === "up" ? `translateY(${off.toFixed(1)}px)` : `translateX(${off.toFixed(1)}px)`;
s.fg.style.transform = tr;
if (s.bg) s.bg.style.transform = tr;
};
window.__seek = (T: number) => {
const ctx: Ctx = {
logo: defaultLogoState(),
fx: { flash: 0, flashColor: "#fff", shake: 0, ca: 0, fade: 0, zoom: 1, grain: 0.075, vignette: 1, glBlur: 0 },
frame: Math.round(T * FPS),
};
const whip = whipAt(T);
const live = whip ? [whip.j - 1, whip.j] : [scenes.findIndex((s) => T >= s.start && T < s.end)];
ctx.logo.t = T;
let logo = ctx.logo;
scenes.forEach((s, i) => {
const on = live.includes(i);
s.fg.style.display = on ? "" : "none";
if (s.bg) s.bg.style.display = on ? "" : "none";
if (!on) return;
ctx.logo = defaultLogoState();
ctx.logo.t = T;
let off = 0;
if (whip) {
const span = whip.dir === "up" ? 1080 : 1920;
off = span * ((i === whip.j ? 1 : 0) - E.inOutExpo(whip.u));
}
place(s, off, whip?.dir ?? "up");
s.update(warps[i]!.toLocal(T - s.start), ctx);
if (ctx.logo.visible || ctx.logo.wm.on) {
const dx = whip?.dir === "left" ? off / PX_PER_UNIT : 0;
const dy = whip?.dir === "up" ? -off / PX_PER_UNIT : 0;
ctx.logo.x += dx;
ctx.logo.y += dy;
ctx.logo.wm.x += dx;
ctx.logo.wm.y += dy;
logo = ctx.logo;
}
});
ctx.logo = logo;
// Motion blur from the push velocity; the scenes' own fades would black out the handover.
for (const s of scenes) {
s.fg.style.filter = "";
if (s.bg) s.bg.style.filter = "";
}
if (whip) {
const v = (E.inOutExpo(whip.u + 0.004) - E.inOutExpo(whip.u - 0.004)) / 0.008 / whip.dur;
const b = Math.min(40, v * (whip.dir === "up" ? 1080 : 1920) * 0.0035);
if (b > 0.4) {
blurStd[whip.dir].setAttribute("stdDeviation", whip.dir === "up" ? `0 ${b.toFixed(1)}` : `${b.toFixed(1)} 0`);
for (const i of live) {
const s = scenes[i]!;
s.fg.style.filter = `url(#${whip.dir === "up" ? "vblur" : "hblur"})`;
if (s.bg) s.bg.style.filter = s.fg.style.filter;
}
ctx.fx.glBlur = Math.max(ctx.fx.glBlur, b * 0.5);
}
ctx.fx.fade = 0;
}
// Soundtrack sync: a small push on every kick and a flash on the phrase crashes.
const bar = T / BAR;
let kick: number;
if (musicEnv) {
const f = T * musicEnv.rate;
const i = Math.floor(f);
kick = lerp(musicEnv.kick[i] ?? 0, musicEnv.kick[i + 1] ?? 0, f - i);
} else kick = Math.exp(-(bar * 2 - Math.floor(bar * 2)) * (BAR / 2) * 9);
ctx.fx.zoom *= 1 + 0.004 * kick;
for (const cb of CRASH_BARS) {
const since = T - cb * BAR;
if (since < 0 || since > 1) continue;
const k = Math.exp(-since * 7);
ctx.fx.flash = Math.max(ctx.fx.flash, 0.3 * k);
ctx.fx.ca = Math.max(ctx.fx.ca, 5 * k);
}
// Debug hook: render.mjs eval can patch the logo pose to inspect the rig.
const patch = (window as unknown as { __logoPatch?: Partial<typeof ctx.logo> }).__logoPatch;
if (patch) Object.assign(ctx.logo, patch);
gl.render(ctx.logo);
glCanvas.style.filter = ctx.fx.glBlur > 0.3 ? `blur(${ctx.fx.glBlur.toFixed(1)}px)` : "";
const { fx } = ctx;
const sx = noise(T * 38, 1) * fx.shake;
const sy = noise(T * 41, 2) * fx.shake;
world.style.transform = `translate(${sx.toFixed(2)}px,${sy.toFixed(2)}px) scale(${fx.zoom.toFixed(4)})`;
if (fx.ca > 0.2) {
caR.setAttribute("dx", (-fx.ca).toFixed(2));
caB.setAttribute("dx", fx.ca.toFixed(2));
world.style.filter = "url(#ca)";
} else world.style.filter = "";
flash.style.opacity = fx.flash.toFixed(3);
flash.style.background = fx.flashColor;
fade.style.opacity = fx.fade.toFixed(3);
vignette.style.opacity = fx.vignette.toFixed(3);
grain.style.opacity = fx.grain.toFixed(3);
const f = ctx.frame;
grain.style.backgroundPosition = `${Math.floor(rand(f) * 384)}px ${Math.floor(rand(f + 0.5) * 384)}px`;
};
window.__fps = FPS;
window.__seek(0);
}
window.__ready = boot();
// Interactive preview: ?t=12.5 seeks, ?play plays in real time.
const params = new URLSearchParams(location.search);
window.__ready.then(() => {
if (params.has("t")) window.__seek(Number(params.get("t")));
if (params.has("play")) {
const t0 = performance.now() - Number(params.get("from") ?? 0) * 1000;
const loop = () => {
window.__seek(((performance.now() - t0) / 1000) % window.__duration);
requestAnimationFrame(loop);
};
loop();
}
});
+405
View File
@@ -0,0 +1,405 @@
import { E, seg, lerp, spring, clamp } from "../lib/anim";
import { h, icon, logo } from "../lib/dom";
import { Headline } from "../lib/kit";
import { lobster } from "./assistant";
import type { Scene } from "../lib/scene";
// Hover Downloads, hold Shift for half a second, the advanced view opens.
type Row = [string, number, string, string, string, string, string];
const ROWS: Row[] = [
["Tears of Steel", 22, "8.8 GiB", "26.7 MiB/s", "0 B/s", "4 minutes", "DOWNLOADING"],
["Sintel", 3, "17.0 GiB", "1.1 MiB/s", "48.8 KiB/s", "4 hours", "LEECHING"],
["ubuntu-26.04-desktop-amd64.iso", 61, "5.9 GiB", "48.2 MiB/s", "1.3 MiB/s", "a minute", "DOWNLOADING"],
["Big Buck Bunny", 100, "1.7 GiB", "0 B/s", "2.1 MiB/s", "an hour", "COMPLETED"],
["Agent 327", 45, "3.1 GiB", "39.5 MiB/s", "0 B/s", "a few seconds", "DOWNLOADING"],
["Cosmos Laundromat", 0, "6.8 GiB", "0 B/s", "0 B/s", "∞", "PAUSED"],
["Spring", 100, "2.3 GiB", "0 B/s", "5.5 MiB/s", "an hour", "SEEDING"],
];
const STATE_COLOR: Record<string, string> = {
DOWNLOADING: "#4fb3ff",
LEECHING: "#ffb547",
COMPLETED: "#3ddc97",
SEEDING: "#3ddc97",
PAUSED: "#8f919d",
};
const COLS = "370px 240px 110px 140px 130px 140px 1fr";
const FRAME = { x: 96, y: 300, w: 1728, h: 690 };
const cellX = (c: number) => FRAME.x + 40 + c * 166;
const cellY = (r: number) => FRAME.y + 110 + r * 156;
const WID = { x: cellX(4), y: cellY(0), w: 4 * 166 - 16, h: 140 };
const PANEL = { x: 300, y: 276, w: 1320, h: 720 };
export function advanced(): Scene {
const fg = h("div", { class: "scene" });
const head = new Headline("Advanced views.", { size: 84, accent: ["advanced"] });
const headWrap = h("div", { class: "abs", style: "left:96px;top:84px;white-space:nowrap" }, head.el);
const sub = new Headline("Supported widgets: hover and hold Shift for half a second.", {
size: 32,
weight: 600,
color: "#b9bbc6",
});
const subWrap = h("div", { class: "abs", style: "left:96px;top:196px;white-space:nowrap" }, sub.el);
// ---------- Board ----------
const tile = (key: string, name: string, c: number, r: number) =>
h(
"div",
{
class: "abs card col center",
style: `left:${cellX(c)}px;top:${cellY(r)}px;width:150px;height:140px;gap:8px;border-radius:16px`,
},
logo(key, 46),
h("div", { style: "font-size:15px;font-weight:650;color:#d7d8de;white-space:nowrap" }, name),
);
const bar = (p: number, color: string) =>
h(
"div",
{ style: "height:9px;border-radius:5px;background:rgba(255,255,255,.08);overflow:hidden" },
h("div", { style: `height:100%;width:${p}%;background:${color};border-radius:5px` }),
);
const widget = h(
"div",
{
class: "abs card col",
style: `left:${WID.x}px;top:${WID.y}px;width:${WID.w}px;height:${WID.h}px;padding:18px 22px;gap:14px;border-radius:16px`,
},
h(
"div",
{ class: "row", style: "gap:10px;font-size:19px;font-weight:750" },
logo("qBittorrent", 26),
"Downloads",
h("div", { style: "margin-left:auto;font-size:15px;color:#8f919d;font-weight:600" }, "3 active"),
),
bar(22, "#4fb3ff"),
bar(61, "#3ddc97"),
);
const weather = h(
"div",
{
class: "abs card col",
style: `left:${cellX(8)}px;top:${cellY(0)}px;width:316px;height:296px;padding:20px 22px;gap:6px;border-radius:16px`,
},
h(
"div",
{ class: "row", style: "gap:10px;font-size:17px;font-weight:750;color:#ffb547" },
icon("sun", 22, 2.2),
h("span", { style: "color:#fff" }, "Weather"),
),
h("div", { class: "display", style: "font-size:84px;margin-top:10px" }, "21°"),
h("div", { style: "font-size:17px;color:#a9abb6" }, "Clear sky"),
);
const calendar = h(
"div",
{
class: "abs card col",
style: `left:${cellX(4)}px;top:${cellY(1)}px;width:${WID.w}px;height:140px;padding:18px 22px;gap:12px;border-radius:16px`,
},
h(
"div",
{ class: "row", style: "gap:10px;font-size:17px;font-weight:750" },
h("div", { style: "color:#7c8cff" }, icon("calendar", 22, 2.2)),
"Calendar",
),
h(
"div",
{ style: "display:grid;grid-template-columns:repeat(14,1fr);gap:8px" },
...Array.from({ length: 28 }, (_, i) =>
h("div", {
style: `height:20px;border-radius:5px;background:${[3, 9, 16, 22].includes(i) ? "#fa5352" : i === 12 ? "#7c8cff" : "rgba(255,255,255,.06)"}`,
}),
),
),
);
const APPS: [string, string][] = [
["jellyfin", "Jellyfin"],
["sonarr", "Sonarr"],
["radarr", "Radarr"],
["immich", "Immich"],
["plex", "Plex"],
["prowlarr", "Prowlarr"],
["piHole", "Pi-hole"],
["proxmox", "Proxmox"],
["homeAssistant", "Home Assistant"],
["seerr", "Seerr"],
["bazarr", "Bazarr"],
["beszel", "Beszel"],
["ntfy", "ntfy"],
["navidrome", "Navidrome"],
["lidarr", "Lidarr"],
["uptimeKuma", "Uptime Kuma"],
["nextcloud", "Nextcloud"],
["traefik", "Traefik"],
];
const cell = (i: number): [number, number] => (i < 12 ? [i % 4, Math.floor(i / 4)] : [i - 8, 2]);
const tiles = APPS.map(([k, n], i) => tile(k, n, ...cell(i)));
const frame = h(
"div",
{
class: "abs",
style: `left:${FRAME.x}px;top:${FRAME.y}px;width:${FRAME.w}px;height:${FRAME.h}px;border-radius:22px;background:#0f1014;border:1px solid rgba(255,255,255,.1);overflow:hidden`,
},
h(
"div",
{
class: "row",
style:
"margin:22px 26px 0;height:64px;padding:0 18px;gap:12px;border-radius:14px;background:#17181d;border:1px solid var(--line)",
},
lobster(34),
h("div", { style: "font-size:21px;font-weight:800" }, "Homelab"),
),
);
const boardEl = h(
"div",
{ class: "abs", style: "inset:0;transform-origin:960px 640px" },
frame,
...tiles,
widget,
weather,
calendar,
);
// ---------- Hover + Shift hold ----------
const cursor = h(
"div",
{
class: "abs",
style: "left:0;top:0;width:34px;height:34px;z-index:30;color:#fff;filter:drop-shadow(0 4px 8px rgba(0,0,0,.6))",
},
icon("filled:pointer", 34, 1),
);
const ring = h("div", { class: "abs", style: "inset:-8px;border-radius:50%" });
const key = h("div", { class: "kbd", style: "font-size:24px;padding:.25em .6em;border-radius:.3em" }, "Shift");
const holdTime = h("span", {}, "0.0s");
const keyWrap = h(
"div",
{ class: "abs row", style: "left:0;top:0;gap:14px;z-index:31" },
h(
"div",
{ style: "position:relative;width:44px;height:44px" },
ring,
h("div", { class: "abs", style: "inset:6px;border-radius:50%;background:#15161b" }),
),
key,
h("div", { class: "mono", style: "font-size:18px;color:#b9bbc6;min-width:52px" }, holdTime),
);
const outline = h("div", {
class: "abs",
style: `left:${WID.x - 6}px;top:${WID.y - 6}px;width:${WID.w + 12}px;height:${WID.h + 12}px;border-radius:20px;border:3px solid #fa5352`,
});
// ---------- Advanced panel ----------
const badge = (color: string, n: string) =>
h(
"div",
{
class: "row mono",
style: `gap:6px;padding:4px 10px;border-radius:999px;background:${color}1f;color:${color};font-size:15px;font-weight:800`,
},
h("div", { style: `width:8px;height:8px;border-radius:50%;background:${color}` }),
n,
);
const totalPct = h("div", { class: "display", style: "font-size:52px;width:110px" }, "25%");
const totalBar = h("div", {
style: "height:100%;width:25%;border-radius:5px;background:linear-gradient(90deg,#4fb3ff,#3ddc97)",
});
const summary = h(
"div",
{ class: "row", style: "gap:26px;height:86px;padding:0 6px;border-bottom:1px solid var(--line)" },
totalPct,
h(
"div",
{ class: "col", style: "gap:8px;width:260px" },
h("div", { style: "height:10px;border-radius:5px;background:rgba(255,255,255,.08);overflow:hidden" }, totalBar),
h("div", { class: "mono", style: "font-size:15px;color:#b9bbc6" }, "11.5 GiB / 45.6 GiB"),
),
h(
"div",
{ class: "row mono", style: "gap:8px;font-size:20px;font-weight:700;color:#4fb3ff" },
icon("arrow-down", 20, 2.6),
"115.5 MiB/s",
),
h(
"div",
{ class: "row mono", style: "gap:8px;font-size:20px;font-weight:700;color:#3ddc97" },
icon("arrow-up", 20, 2.6),
"8.9 MiB/s",
),
h(
"div",
{ class: "row", style: "gap:8px" },
badge("#4fb3ff", "3"),
badge("#ffb547", "1"),
badge("#3ddc97", "2"),
badge("#8f919d", "1"),
),
h(
"div",
{ class: "row", style: "margin-left:auto;gap:10px;font-size:17px;font-weight:700;color:#d7d8de" },
logo("qBittorrent", 26),
"1 client",
),
);
const headerRow = h(
"div",
{
class: "label",
style: `display:grid;grid-template-columns:${COLS};align-items:center;height:44px;padding:0 14px;font-size:13px;color:#8f919d;letter-spacing:.14em`,
},
...["Name", "Progress", "Size", "Down", "Up", "ETA", "State"].map((c) => h("div", {}, c)),
);
const fills: { el: HTMLElement; pct: HTMLElement; p: number }[] = [];
const rowEls = ROWS.map(([name, p, size, down, up, eta, state]) => {
const fill = h("div", { style: `height:100%;width:${p}%;border-radius:4px;background:${STATE_COLOR[state]}` });
const pct = h("span", {}, `${p}%`);
fills.push({ el: fill, pct, p });
return h(
"div",
{
style: `display:grid;grid-template-columns:${COLS};align-items:center;height:60px;padding:0 14px;border-top:1px solid var(--line);font-size:18px`,
},
h(
"div",
{ class: "row", style: "gap:10px;font-weight:650;white-space:nowrap;overflow:hidden" },
h("div", { style: "color:#ffd23f;flex:none" }, icon("filled:bolt", 18, 1)),
name,
),
h(
"div",
{ class: "row", style: "gap:12px;padding-right:24px" },
h(
"div",
{ style: "flex:1;height:8px;border-radius:4px;background:rgba(255,255,255,.08);overflow:hidden" },
fill,
),
h("div", { class: "mono", style: "width:44px;font-size:15px;color:#b9bbc6;text-align:right" }, pct),
),
h("div", { class: "mono", style: "font-size:16px;color:#d7d8de" }, size),
h("div", { class: "mono", style: `font-size:16px;color:${down === "0 B/s" ? "#6f717d" : "#4fb3ff"}` }, down),
h("div", { class: "mono", style: `font-size:16px;color:${up === "0 B/s" ? "#6f717d" : "#3ddc97"}` }, up),
h("div", { style: "font-size:16px;color:#b9bbc6;white-space:nowrap" }, eta),
h(
"div",
{ class: "mono", style: `font-size:13px;font-weight:800;letter-spacing:.06em;color:${STATE_COLOR[state]}` },
state,
),
);
});
const controls = h(
"div",
{ class: "row", style: "height:52px;padding:0 10px;border-top:1px solid var(--line);color:#a9abb6;gap:18px" },
icon("filter", 22, 2),
icon("bolt", 22, 2),
h(
"div",
{ class: "row", style: "margin-left:auto;gap:18px" },
icon("player-play", 22, 2),
icon("player-pause", 22, 2),
),
);
const panelBody = h(
"div",
{ class: "col", style: "height:100%" },
summary,
headerRow,
...rowEls,
h("div", { style: "flex:1" }),
controls,
);
const panel = h(
"div",
{
class: "abs card",
style: `left:${PANEL.x}px;top:${PANEL.y}px;width:${PANEL.w}px;height:${PANEL.h}px;padding:18px 26px 8px;border-radius:22px;transform-origin:0 0;background:#16171c;border-color:rgba(255,255,255,.14);box-shadow:0 60px 140px rgba(0,0,0,.75)`,
},
panelBody,
);
fg.append(boardEl, outline, panel, headWrap, subWrap, cursor, keyWrap);
// ---------- Timeline ----------
const HOVER = 0.5;
const HOLD = 0.62;
const HOLD_S = 0.5; // Shift is held for half a second in Homarr; the scene plays at its authored speed
const OPEN = HOLD + HOLD_S;
const END = OPEN + 2.75;
const wc: [number, number] = [WID.x + WID.w * 0.62, WID.y + WID.h * 0.55];
const cues: Scene["cues"] = [
{ t: 0.02, kind: "whoosh", gain: 0.6 },
{ t: HOLD, kind: "key", gain: 1 },
{ t: HOLD + 0.05, kind: "riser", dur: HOLD_S - 0.05, gain: 0.45 },
{ t: OPEN, kind: "hit", gain: 0.8 },
{ t: OPEN + 0.02, kind: "swish", gain: 0.6 },
...ROWS.map((_, i) => ({ t: OPEN + 0.2 + i * 0.04, kind: "tick" as const, gain: 0.22, pitch: i })),
{ t: END - 0.25, kind: "whoosh", gain: 0.7 },
];
return {
name: "advanced",
start: 0,
end: END,
fg,
cues,
update(t, ctx) {
head.update(t, 0.02, Infinity, 0.05, 0.5);
sub.update(t, 0.2, Infinity, 0.02, 0.5);
const open = E.outExpo(seg(t, OPEN, OPEN + 0.4));
const bIn = E.outExpo(seg(t, 0, 0.5));
boardEl.style.transform = `translateY(${((1 - bIn) * 60).toFixed(1)}px) scale(${lerp(1, 0.94, open).toFixed(4)})`;
boardEl.style.filter =
open > 0.01 ? `brightness(${lerp(1, 0.45, open).toFixed(3)}) blur(${(open * 3).toFixed(2)}px)` : "";
// Cursor glides onto Downloads and stays while Shift is held.
const cp = E.inOutCubic(seg(t, 0.1, HOVER));
const cx = lerp(1560, wc[0], cp);
const cy = lerp(1010, wc[1], cp);
cursor.style.transform = `translate(${cx.toFixed(1)}px,${cy.toFixed(1)}px)`;
cursor.style.display = t > 0.08 && t < OPEN + 0.08 ? "" : "none";
const hover = t > HOVER - 0.05;
widget.style.borderColor = hover ? "rgba(255,255,255,.3)" : "";
const hold = seg(t, HOLD, OPEN);
ring.style.background = `conic-gradient(#fa5352 ${(hold * 360).toFixed(1)}deg, rgba(255,255,255,.12) 0)`;
holdTime.textContent = `${(hold * HOLD_S).toFixed(1)}s`;
const kIn = spring(t - HOLD + 0.08, 3.2, 0.5);
keyWrap.style.transform = `translate(${(cx + 40).toFixed(1)}px,${(cy + 34).toFixed(1)}px) scale(${clamp(kIn, 0, 1.3).toFixed(3)})`;
keyWrap.style.display = t > HOLD - 0.08 && t < OPEN + 0.12 ? "" : "none";
key.style.borderBottomWidth = t > HOLD ? "1px" : "3px";
key.style.transform = `translateY(${t > HOLD ? 3 : 0}px)`;
key.style.borderColor = t > HOLD ? "rgba(250,83,82,.8)" : "";
// The outline closes around the widget as the hold completes.
outline.style.display = t > HOLD && t < OPEN + 0.1 ? "" : "none";
outline.style.clipPath = `inset(0 ${((1 - hold) * 100).toFixed(1)}% 0 0 round 20px)`;
const pulse = t > OPEN ? Math.exp(-(t - OPEN) * 8) : 0;
widget.style.boxShadow = `0 0 ${(hold * 30 + pulse * 60).toFixed(0)}px rgba(250,83,82,${(hold * 0.35 + pulse * 0.5).toFixed(2)})`;
// Panel grows out of the widget.
panel.style.display = t >= OPEN ? "" : "none";
const sx = lerp(WID.w / PANEL.w, 1, open);
const sy = lerp(WID.h / PANEL.h, 1, open);
const px = lerp(WID.x - PANEL.x, 0, open);
const py = lerp(WID.y - PANEL.y, 0, open);
panel.style.transform = `translate(${px.toFixed(1)}px,${py.toFixed(1)}px) scale(${sx.toFixed(4)},${sy.toFixed(4)})`;
panelBody.style.visibility = open > 0.55 ? "visible" : "hidden";
rowEls.forEach((r, i) => {
const at = OPEN + 0.18 + i * 0.04;
const p = E.outExpo(seg(t, at, at + 0.3));
r.style.clipPath = `inset(0 ${((1 - p) * 100).toFixed(1)}% 0 0)`;
});
// Live data keeps moving.
fills.forEach((f, i) => {
if (f.p <= 0 || f.p >= 100) return;
const v = Math.min(99, f.p + Math.max(0, t - OPEN) * [4, 0.3, 6, 0, 9][i]!);
f.el.style.width = `${v.toFixed(1)}%`;
f.pct.textContent = `${Math.floor(v)}%`;
});
const tp = 25 + Math.max(0, t - OPEN) * 1.6;
totalBar.style.width = `${tp.toFixed(1)}%`;
totalPct.textContent = `${Math.floor(tp)}%`;
ctx.fx.shake = pulse * 6;
},
};
}
+542
View File
@@ -0,0 +1,542 @@
import { E, seg, lerp, spring, clamp } from "../lib/anim";
import { h, icon, logo, offsetWithin, tf } from "../lib/dom";
import { Chapter, Headline, TypeBlock, svg } from "../lib/kit";
import { LOGO_D, LOGO_VB } from "./intro";
import type { Scene } from "../lib/scene";
const SUGGESTIONS: [string, string][] = [
["heart-rate-monitor", "Check service health"],
["compass", "Explore my Homarr"],
["movie", "Find media to request"],
["palette", "Improve a dashboard"],
["puzzle", "Design a widget"],
];
const PREFILL = "Create and install a Custom Widget for ";
const ASK = "my Radarr upcoming movies";
export function assistant(): Scene {
const bg = h("div", { class: "scene", style: "background:#07070b" });
const fg = h("div", { class: "scene" });
// ---------- Board behind the drawer ----------
const tile = (key: string, name: string) =>
h(
"div",
{ class: "card col center", style: "gap:12px;height:150px;border-radius:16px" },
logo(key, 56),
h("div", { style: "font-size:17px;font-weight:650;color:#d7d8de" }, name),
);
const newWidget = h(
"div",
{
class: "card col",
style:
"grid-column:span 2;height:150px;border-radius:16px;padding:18px 20px;gap:10px;border-color:rgba(250,83,82,.6)",
},
h("div", { class: "row", style: "gap:10px;font-size:18px;font-weight:750" }, logo("radarr", 26), "Radarr upcoming"),
...["Friday · In cinemas", "Next week · Digital release", "In 2 weeks · Physical release"].map((d, i) =>
h(
"div",
{ class: "row", style: "gap:10px;font-size:15px;color:#b9bbc6" },
h("div", {
style: `width:8px;height:8px;border-radius:50%;background:${["#fa5352", "#ffb547", "#4fb3ff"][i]}`,
}),
d,
),
),
);
const board = h(
"div",
{ class: "abs", style: "left:70px;top:60px;width:1780px;height:960px;transform-origin:50% 50%" },
h(
"div",
{
class: "row",
style: "height:70px;padding:0 26px;gap:14px;border-radius:16px;background:#15161b;border:1px solid var(--line)",
},
lobster(40),
h("div", { style: "font-size:24px;font-weight:800" }, "Homelab"),
h(
"div",
{ class: "row", style: "margin-left:auto;gap:10px;color:#8f919d" },
icon("search", 22, 2),
icon("user-circle", 26, 1.8),
),
),
h(
"div",
{ style: "margin-top:24px;display:grid;grid-template-columns:repeat(8,1fr);gap:18px" },
tile("jellyfin", "Jellyfin"),
tile("sonarr", "Sonarr"),
tile("radarr", "Radarr"),
tile("immich", "Immich"),
tile("proxmox", "Proxmox"),
tile("piHole", "Pi-hole"),
tile("homeAssistant", "Home Assistant"),
tile("plex", "Plex"),
tile("prowlarr", "Prowlarr"),
tile("qBittorrent", "qBittorrent"),
newWidget,
tile("beszel", "Beszel"),
tile("ntfy", "ntfy"),
tile("docker", "Docker"),
tile("seerr", "Seerr"),
),
);
bg.append(board);
const toast = h(
"div",
{ class: "abs row", style: "left:0;right:0;top:0;justify-content:center;pointer-events:none" },
h(
"div",
{
class: "row",
style:
"gap:12px;padding:14px 24px;border-radius:14px;background:#10231b;border:1px solid rgba(61,220,151,.55);font-size:22px;font-weight:750;color:#c9f7e1;box-shadow:0 18px 50px rgba(0,0,0,.5)",
},
icon("circle-check", 26, 2.4),
"Assistant installed “Radarr upcoming” on Homelab",
),
);
// ---------- Keycaps ----------
const kShift = h("div", { class: "kbd", style: "font-size:84px;padding:.2em .6em;border-radius:.28em" }, "Shift");
const kA = h("div", { class: "kbd", style: "font-size:84px;min-width:1.6em;border-radius:.28em" }, "A");
const keys = h(
"div",
{ class: "abs row", style: "left:0;right:0;top:360px;justify-content:center;gap:34px" },
kShift,
h("div", { style: "font-size:70px;color:#8f919d" }, "+"),
kA,
);
const keyCap = new Headline("Open Assistant from anywhere.", { size: 46, weight: 650, color: "#d7d8de" });
keyCap.el.style.textAlign = "center";
const keyCapWrap = h(
"div",
{ class: "abs", style: "left:0;right:0;top:600px;white-space:nowrap;text-align:center" },
keyCap.el,
);
// ---------- Drawer ----------
const chipModel = h(
"div",
{
class: "row",
style:
"margin-left:auto;gap:8px;padding:7px 14px;border-radius:999px;background:rgba(250,83,82,.12);border:1px solid rgba(250,83,82,.4);font-size:16px;font-weight:700;color:#ffb3ad",
},
icon("sparkles", 16, 2.2),
"Homarr provider",
);
const sugg = SUGGESTIONS.map(([ic, label]) =>
h(
"div",
{
class: "row",
style:
"gap:14px;height:58px;padding:0 20px;border-radius:14px;border:1px solid var(--line2);background:rgba(255,255,255,.03);font-size:21px;font-weight:600",
},
h("div", { style: "color:#ff8f86" }, icon(ic, 24, 2)),
label,
),
);
const empty = h(
"div",
{ class: "abs col", style: "left:40px;right:40px;top:170px;gap:14px" },
h("div", { style: "color:var(--coral)" }, icon("sparkles", 44, 1.8)),
h("div", { class: "display", style: "font-size:40px;font-weight:800" }, "What can I help with?"),
h(
"div",
{ style: "font-size:20px;line-height:1.45;color:#a9abb6;margin-bottom:14px" },
"Ask about your Homarr setup, inspect live instance data, or approve actions when you want me to make a change.",
),
...sugg,
);
const ask = new TypeBlock(ASK, "", "#fff");
const composerText = h(
"div",
{ style: "flex:1;font-size:21px;line-height:1.35" },
h("span", { style: "color:#d7d8de" }, PREFILL),
ask.el,
);
const placeholder = h(
"div",
{ class: "abs", style: "left:22px;top:30px;font-size:21px;color:#6f717d" },
"Ask Assistant…",
);
const sendBtn = h(
"div",
{ class: "center", style: "width:48px;height:48px;border-radius:13px;background:#fa5352;color:#fff;flex:none" },
icon("arrow-up", 26, 2.6),
);
const composer = h(
"div",
{
class: "abs row",
style:
"left:28px;right:28px;bottom:26px;min-height:92px;padding:14px 16px 14px 22px;gap:14px;border-radius:18px;background:#121318;border:1px solid var(--line2)",
},
placeholder,
composerText,
sendBtn,
);
// Conversation
const bubble = h(
"div",
{
style:
"align-self:flex-end;max-width:560px;padding:16px 22px;border-radius:18px 18px 6px 18px;background:#2b1b1e;border:1px solid rgba(250,83,82,.45);font-size:21px;line-height:1.4",
},
PREFILL + ASK,
);
const step = (text: string, tag: string) => {
const spin = h("div", { class: "abs", style: "left:0;top:0;color:var(--amber)" }, icon("loader-2", 22, 2.4));
const ok = h("div", { class: "abs", style: "left:0;top:0;color:var(--mint)" }, icon("circle-check", 22, 2.4));
const el = h(
"div",
{ class: "row", style: "gap:14px;font-size:20px;color:#d7d8de" },
h("div", { style: "position:relative;width:22px;height:22px;flex:none" }, spin, ok),
text,
h(
"span",
{
class: "mono",
style:
"margin-left:auto;font-size:13px;padding:3px 9px;border-radius:6px;background:rgba(61,220,151,.12);color:var(--mint);letter-spacing:.06em",
},
tag,
),
);
return { el, spin, ok };
};
const s1 = step("Reading your Radarr integration", "READ · AUTO");
const s2 = step("Drafting the Custom Widget", "READ · AUTO");
const approveBtn = h(
"div",
{
class: "row",
style:
"gap:8px;padding:12px 20px;border-radius:11px;background:#fa5352;color:#fff;font-size:18px;font-weight:800",
},
icon("player-play", 18, 2.6),
"Approve and run",
);
const denyBtn = h(
"div",
{
style:
"padding:12px 20px;border-radius:11px;border:1px solid var(--line2);font-size:18px;font-weight:700;color:#d7d8de",
},
"Deny",
);
const approval = h(
"div",
{
class: "col",
style:
"gap:14px;padding:20px 22px;border-radius:16px;background:rgba(255,181,71,.07);border:1px solid rgba(255,181,71,.45)",
},
h(
"div",
{ class: "row label", style: "gap:10px;color:var(--amber);font-size:14px" },
icon("shield-lock", 18, 2.2),
"Approval required",
),
h("div", { style: "font-size:23px;font-weight:750" }, "Create and install Custom Widget “Radarr upcoming”"),
h("div", { class: "row", style: "gap:12px;justify-content:flex-end" }, denyBtn, approveBtn),
);
const installed = h(
"div",
{
class: "row",
style:
"gap:12px;padding:14px 18px;border-radius:14px;background:rgba(61,220,151,.1);border:1px solid rgba(61,220,151,.45);font-size:20px;font-weight:700;color:#c9f7e1",
},
icon("circle-check", 24, 2.4),
"Installed on Homelab",
);
const convo = [bubble, s1.el, s2.el, approval, installed];
const thread = h("div", { class: "abs col", style: "left:28px;right:28px;top:110px;gap:18px" }, ...convo);
const drawer = h(
"div",
{
class: "abs card",
style:
"left:1130px;top:36px;width:750px;height:1008px;overflow:hidden;border-color:rgba(255,255,255,.12);background:linear-gradient(180deg,#1c1d23,#141519)",
},
h(
"div",
{ class: "row", style: "height:78px;padding:0 26px;gap:12px;border-bottom:1px solid var(--line)" },
h("div", { style: "color:var(--coral)" }, icon("sparkles", 26, 2)),
h("div", { style: "font-size:24px;font-weight:800" }, "Assistant"),
chipModel,
),
empty,
thread,
composer,
);
const cursor = h(
"div",
{
class: "abs",
style: "left:0;top:0;width:34px;height:34px;color:#fff;filter:drop-shadow(0 4px 8px rgba(0,0,0,.6))",
},
icon("filled:pointer", 34, 1),
);
const chapter = new Chapter("03", "Assistant");
const headA = new Headline("Or let Assistant build it for you.", { size: 70, lh: 1.05, accent: ["build"] });
const subA = new Headline(
"It works with live Homarr data: boards, apps, integrations, widgets, Docker and supported services.",
{ size: 30, weight: 550, color: "#b9bbc6", lh: 1.3 },
);
const headB = new Headline("Reads can run automatically. Changes wait for your approval.", {
size: 62,
lh: 1.08,
accent: ["approval."],
});
const subB = new Headline("It also answers questions about your setup.", { size: 34, weight: 600, color: "#b9bbc6" });
const leftA = h("div", { class: "abs col", style: "left:96px;top:300px;width:940px;gap:26px" }, headA.el, subA.el);
const leftB = h("div", { class: "abs col", style: "left:96px;top:300px;width:940px;gap:26px" }, headB.el, subB.el);
// ---------- Providers ----------
const provHead = new Headline("Free with the Homarr provider. Or bring your own key.", {
size: 64,
accent: ["Free", "own", "key."],
});
const provHeadWrap = h(
"div",
{ class: "abs", style: "left:0;right:0;top:150px;text-align:center;white-space:nowrap" },
provHead.el,
);
const bullet = (ic: string, text: string, color: string) =>
h(
"div",
{ class: "row", style: "gap:16px;font-size:24px;line-height:1.35;align-items:flex-start;color:#e6e7ec" },
h("div", { style: `color:${color};margin-top:2px;flex:none` }, icon(ic, 26, 2.2)),
text,
);
const provCard = (accent: string, iconName: string, title: string, badge: string, lines: [string, string][]) =>
h(
"div",
{ class: "card col", style: `width:760px;padding:40px 44px;gap:22px;border-color:${accent}66` },
h(
"div",
{ class: "row", style: "gap:18px" },
h(
"div",
{
class: "center",
style: `width:64px;height:64px;border-radius:18px;background:${accent}22;color:${accent}`,
},
icon(iconName, 36, 2),
),
h("div", { style: "font-size:36px;font-weight:850;letter-spacing:-.02em" }, title),
h(
"div",
{
class: "mono",
style: `margin-left:auto;padding:6px 14px;border-radius:999px;background:${accent}22;color:${accent};font-size:16px;font-weight:800;letter-spacing:.1em`,
},
badge,
),
),
...lines.map(([ic, text]) => bullet(ic, text, accent)),
);
const cardFree = provCard("#3ddc97", "gift", "Homarr provider", "FREE", [
["check", "Free, and will never offer paid plans"],
["check", "Only zero-data-retention (ZDR) providers"],
["check", "Daily request allowance, no API key needed"],
]);
const cardByok = provCard("#7c8cff", "key", "Bring your own key", "BYOK", [
["check", "Any OpenAI-compatible Chat Completions API"],
["check", "Keys are encrypted and never returned to the browser"],
]);
const provRow = h(
"div",
{ class: "abs row", style: "left:0;right:0;top:330px;justify-content:center;gap:56px;align-items:stretch" },
cardFree,
cardByok,
);
fg.append(keys, keyCapWrap, toast, drawer, leftA, leftB, chapter.el, provHeadWrap, provRow, cursor);
// ---------- Timeline ----------
const K1 = 0.15;
const K2 = 0.34;
const DR = 0.95;
const PICK = DR + 0.85;
const TYPE = PICK + 0.12;
const ACPS = 60;
const SEND = TYPE + ASK.length / ACPS + 0.1;
const S1 = SEND + 0.15;
const S2 = S1 + 0.3;
const APPR = S2 + 0.35;
const CLICK = APPR + 0.6;
const INST = CLICK + 0.25;
const PROV = INST + 1.15;
const END = PROV + 2.75;
const cues: Scene["cues"] = [
{ t: K1, kind: "key", gain: 1 },
{ t: K2, kind: "key", gain: 1, pitch: 2 },
{ t: K2 + 0.02, kind: "hit", gain: 0.6 },
{ t: DR - 0.12, kind: "whoosh", gain: 0.8 },
...SUGGESTIONS.map((_, i) => ({ t: DR + 0.2 + i * 0.05, kind: "tick" as const, gain: 0.35, pitch: i })),
{ t: PICK, kind: "click", gain: 0.9 },
{ t: TYPE, kind: "type", dur: ASK.length / ACPS, gain: 0.45 },
{ t: SEND, kind: "key", gain: 0.8 },
{ t: S1 + 0.25, kind: "tick", gain: 0.5 },
{ t: S2 + 0.25, kind: "tick", gain: 0.5 },
{ t: APPR, kind: "pop", gain: 0.7 },
{ t: CLICK, kind: "click", gain: 1 },
{ t: INST, kind: "chime", gain: 0.8, pitch: 2 },
{ t: PROV - 0.12, kind: "whoosh", gain: 0.8 },
{ t: PROV + 0.3, kind: "hit", gain: 0.5 },
{ t: PROV + 0.5, kind: "hit", gain: 0.5 },
{ t: END - 0.3, kind: "whoosh", gain: 0.8 },
];
return {
name: "assistant",
start: 0,
end: END,
bg,
fg,
cues,
update(t, ctx) {
ctx.fx.fade = 1 - E.outCubic(seg(t, 0, 0.12));
// Keycaps drop in and press, then give way to the drawer.
const press = (k: HTMLElement, at: number, i: number) => {
const pin = spring(t - at + 0.18, 3.4, 0.5);
const down = t > at && t < at + 0.12;
const out = E.inCubic(seg(t, DR - 0.25 + i * 0.04, DR + 0.05 + i * 0.04));
k.style.transform = `translateY(${((down ? 10 : 0) + (1 - clamp(pin, 0, 1.2)) * -80 - out * 60).toFixed(1)}px) scale(${lerp(1, 0.8, out).toFixed(3)})`;
k.style.opacity = String((t > at - 0.18 ? 1 : 0) * (1 - out));
k.style.borderBottomWidth = down ? "1px" : "3px";
const glow = t > at ? Math.exp(-(t - at) * 3) : 0;
k.style.boxShadow = `0 0 ${(glow * 60).toFixed(0)}px rgba(250,83,82,${(glow * 0.8).toFixed(2)})`;
k.style.borderColor = glow > 0.05 ? `rgba(250,83,82,${(0.3 + glow * 0.7).toFixed(2)})` : "";
};
press(kShift, K1, 0);
press(kA, K2, 1);
(keys.children[1] as HTMLElement).style.opacity = String((t > K1 ? 1 : 0) * (1 - seg(t, DR - 0.25, DR)));
keys.style.display = t < DR + 0.1 ? "" : "none";
keyCap.update(t, K2 + 0.05, DR - 0.3, 0.025, 0.45);
keyCapWrap.style.display = t < DR + 0.1 ? "" : "none";
// Board sits under the drawer; pops to the front when the widget lands.
const bIn = E.outCubic(seg(t, DR - 0.15, DR + 0.35));
// Once the widget lands the drawer leaves for good; the board stays in focus until the cut.
const focusBoard = E.inOutCubic(seg(t, INST + 0.05, INST + 0.35));
const bOut = E.inOutQuart(seg(t, PROV - 0.3, PROV + 0.05));
board.style.opacity = String(bIn * lerp(0.32, 1, focusBoard) * (1 - bOut));
board.style.filter = `blur(${lerp(3.5, 0, focusBoard).toFixed(2)}px)`;
board.style.transform = `perspective(2000px) rotateY(${lerp(8, 0, focusBoard).toFixed(2)}deg) scale(${(lerp(0.92, 0.98, focusBoard) * (1 - bOut * 0.08)).toFixed(4)})`;
const nw = t > INST ? spring(t - INST, 2.8, 0.45) : 0;
newWidget.style.transform = `scale(${clamp(nw, 0, 2).toFixed(3)})`;
newWidget.style.opacity = t > INST ? "1" : "0";
const nwGlow = t > INST ? Math.exp(-(t - INST - 0.2) * 1.8) : 0;
newWidget.style.boxShadow = `0 0 ${(clamp(nwGlow) * 60).toFixed(0)}px rgba(250,83,82,${(clamp(nwGlow) * 0.7).toFixed(2)})`;
// Drawer
const dIn = E.outExpo(seg(t, DR - 0.1, DR + 0.4));
const dOut = E.inOutQuart(seg(t, PROV - 0.35, PROV + 0.05));
drawer.style.transform = `translateX(${((1 - dIn) * 800 + focusBoard * 820 + dOut * 800).toFixed(1)}px)`;
const tIn = spring(t - INST - 0.2, 2.8, 0.5);
const tOut = E.inCubic(seg(t, PROV - 0.45, PROV - 0.2));
tf(toast, { y: 60 + (1 - clamp(tIn, 0, 1.3)) * -120 - tOut * 120, o: t > INST + 0.2 ? 1 : 0 });
toast.style.display = t > INST + 0.15 && t < PROV ? "" : "none";
drawer.style.display = t > DR - 0.15 && t < INST + 0.4 ? "" : "none";
const eOut = E.inCubic(seg(t, SEND - 0.08, SEND + 0.15));
empty.style.opacity = String(1 - eOut);
empty.style.transform = `translateY(${(-eOut * 40).toFixed(1)}px)`;
sugg.forEach((sg, i) => {
const at = DR + 0.2 + i * 0.05;
const si = E.outExpo(seg(t, at, at + 0.3));
const picked = i === 4 && t >= PICK;
sg.style.visibility = t >= at ? "visible" : "hidden";
sg.style.transform = `translateX(${((1 - si) * 60).toFixed(1)}px) scale(${picked && t < PICK + 0.1 ? 0.97 : 1})`;
sg.style.borderColor = picked ? "#fa5352" : i === 4 && t > PICK - 0.2 ? "rgba(255,255,255,.3)" : "var(--line2)";
sg.style.background = picked ? "rgba(250,83,82,.14)" : "rgba(255,255,255,.03)";
});
// Composer
placeholder.style.opacity = t < PICK ? "1" : "0";
composerText.style.opacity = t >= PICK && t < SEND ? "1" : "0";
ask.update(t, TYPE, ACPS, SEND);
const sk = t > SEND ? Math.exp(-(t - SEND) * 6) : 0;
sendBtn.style.transform = `scale(${(t > SEND && t < SEND + 0.1 ? 0.88 : 1 + sk * 0.12).toFixed(3)})`;
// Conversation: messages snap in with a short rise.
const revealAt = [SEND + 0.03, S1, S2, APPR, INST];
convo.forEach((c, i) => {
const r = E.outExpo(seg(t, revealAt[i]!, revealAt[i]! + 0.3));
c.style.visibility = t >= revealAt[i]! ? "visible" : "hidden";
c.style.transform = `translateY(${((1 - r) * 20).toFixed(1)}px)`;
});
[s1, s2].forEach((s, i) => {
const done = t > [S1, S2][i]! + 0.25;
s.spin.style.opacity = done ? "0" : "1";
s.spin.style.transform = `rotate(${((t * 720) % 360).toFixed(1)}deg)`;
s.ok.style.opacity = done ? "1" : "0";
});
const ak = t > CLICK ? Math.exp(-(t - CLICK) * 5) : 0;
approveBtn.style.transform = `scale(${(t > CLICK && t < CLICK + 0.1 ? 0.94 : 1).toFixed(3)})`;
approveBtn.style.boxShadow = `0 0 ${(ak * 40).toFixed(0)}px rgba(250,83,82,${(ak * 0.9).toFixed(2)})`;
approval.style.borderColor = t > CLICK ? "rgba(61,220,151,.5)" : "rgba(255,181,71,.45)";
// Cursor: suggestion pick, then approve.
const drawerX = 1130 + (1 - dIn) * 800;
const sgY = 36 + offsetWithin(sugg[4]!, drawer)[1] + 29;
const [apOx, apOy] = offsetWithin(approveBtn, drawer);
const apY = 36 + apOy + 30;
const apX = drawerX + apOx + approveBtn.offsetWidth - 38;
const c1 = E.inOutCubic(seg(t, DR + 0.35, PICK - 0.04));
const c2 = E.inOutCubic(seg(t, APPR + 0.1, CLICK - 0.06));
let cx = lerp(1000, drawerX + 200, c1);
let cy = lerp(1000, sgY, c1);
if (t > PICK + 0.15) {
cx = lerp(drawerX + 200, apX, c2);
cy = lerp(sgY, apY, c2);
}
const clickDown = (t > PICK && t < PICK + 0.1) || (t > CLICK && t < CLICK + 0.1);
cursor.style.transform = `translate(${cx.toFixed(1)}px,${cy.toFixed(1)}px) scale(${clickDown ? 0.85 : 1})`;
cursor.style.display = t > DR + 0.35 && t < CLICK + 0.3 ? "" : "none";
// Left copy
chapter.update(t, DR + 0.1);
// Copy blocks leave whole (a quick whip), never word by word over the next block.
headA.update(t, DR + 0.1, Infinity, 0.04, 0.5);
subA.update(t, DR + 0.35, Infinity, 0.02, 0.5);
const wA = E.inCubic(seg(t, SEND - 0.1, SEND + 0.12));
tf(leftA, { y: -wA * 90, blur: wA * 14, o: t > DR && wA < 1 ? 1 - wA * 0.6 : 0 });
headB.update(t, SEND + 0.15, Infinity, 0.035, 0.5);
subB.update(t, S2 + 0.1, Infinity, 0.025, 0.5);
const wB = E.inCubic(seg(t, INST - 0.05, INST + 0.2));
tf(leftB, { x: -wB * 300, blur: wB * 16, o: t > SEND && wB < 1 ? 1 - wB * 0.6 : 0 });
// Providers
const pOn = t > PROV - 0.2;
provHeadWrap.style.display = provRow.style.display = pOn ? "" : "none";
provHead.update(t, PROV, Infinity, 0.035, 0.5);
[cardFree, cardByok].forEach((c, i) => {
const ci = spring(t - PROV - 0.05 - i * 0.12, 2.6, 0.55);
c.style.transform = `perspective(1600px) translateY(${((1 - clamp(ci, 0, 1.2)) * 160).toFixed(1)}px) rotateX(${((1 - clamp(ci, 0, 1)) * 25).toFixed(2)}deg)`;
c.style.opacity = t > PROV + 0.05 + i * 0.12 ? "1" : "0";
[...c.children].slice(1).forEach((b, j) => {
const at = PROV + 0.3 + i * 0.12 + j * 0.08;
const bi = E.outExpo(seg(t, at, at + 0.35));
(b as HTMLElement).style.visibility = t >= at ? "visible" : "hidden";
(b as HTMLElement).style.transform = `translateX(${((1 - bi) * 24).toFixed(1)}px)`;
});
});
ctx.fx.shake = (t > K2 ? Math.exp(-(t - K2) * 8) : 0) * 8;
},
};
}
export function lobster(size: number) {
const s = svg("svg", { viewBox: LOGO_VB, width: size, height: (size * 346.2) / 512 });
s.append(svg("path", { d: LOGO_D, fill: "#fa5352" }));
return s as unknown as HTMLElement;
}
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,519 @@
import { E, seg, lerp, spring, clamp } from "../lib/anim";
import { h, tf, icon, logo } from "../lib/dom";
import { Chapter, CodeType, Headline, type Tok } from "../lib/kit";
import type { Scene } from "../lib/scene";
import { SLOT, WORKSHOP_BG, publishedCard } from "./workshop";
// Code shown in the editor: a real homarr-custom-widget-v2 shape.
const K = (s: string): Tok => [s, "k"];
const S = (s: string): Tok => [s, "s"];
const P = (s: string): Tok => [s];
const N = (s: string): Tok => [s, "n"];
const T = (s: string): Tok => [s, "t"];
const code: Tok[][] = [
[P("{")],
[P(" "), K('"$schema"'), P(": "), S('"homarr-custom-widget-v2"'), P(",")],
[P(" "), K('"name"'), P(": "), S('"Sonarr queue"'), P(",")],
[P(" "), K('"sources"'), P(": {")],
[P(" "), K('"default"'), P(": {")],
[P(" "), K('"type"'), P(": "), S('"integration"'), P(",")],
[P(" "), K('"integrationKind"'), P(": "), S('"sonarr"')],
[P(" }")],
[P(" },")],
[P(" "), K('"requests"'), P(": {")],
[P(" "), K('"queue"'), P(": { "), K('"path"'), P(": "), S('"/api/v3/queue"'), P(" },")],
[P(" "), K('"search"'), P(": {")],
[P(" "), K('"kind"'), P(": "), S('"action"'), P(", "), K('"method"'), P(": "), S('"POST"'), P(",")],
[P(" "), K('"path"'), P(": "), S('"/api/v3/command"')],
[P(" }")],
[P(" },")],
[P(" "), K('"options"'), P(": {")],
[
P(" "),
K('"limit"'),
P(": { "),
K('"control"'),
P(": "),
S('"number"'),
P(", "),
K('"default"'),
P(": "),
N("4"),
P(" }"),
],
[P(" },")],
[P(" "), K('"templateLines"'), P(": [")],
[P(" "), S('"'), T("<Stack>"), S('",')],
[P(" "), S('" {data.queue.records.map(item =>"'), P(",")],
[P(" "), S('" '), T("<Progress"), S(" value={item.progress} "), T("/>"), S(')}"'), P(",")],
[
P(" "),
S('" '),
T("<ActionButton"),
S(' requestId=\\"search\\"'),
T(">"),
S("Search"),
T("</ActionButton>"),
S('",'),
],
[P(" "), S('"'), T("</Stack>"), S('"')],
[P(" ]")],
[P("}")],
];
// Line index at which each preview feature becomes available.
const L_SOURCE = 8;
const L_QUEUE = 11;
const L_ACTION = 15;
const L_OPTIONS = 18;
const L_JSX = 25;
const shows = [
{ t: "Severance", e: "S02E10 · 2.4 GB", p: 0.86, c: ["#3b82f6", "#1e3a8a"] },
{ t: "Andor", e: "S02E09 · 3.1 GB", p: 0.61, c: ["#f59e0b", "#7c2d12"] },
{ t: "Slow Horses", e: "S05E02 · 1.8 GB", p: 0.37, c: ["#10b981", "#064e3b"] },
{ t: "The Last of Us", e: "S02E07 · 4.2 GB", p: 0.14, c: ["#ef4444", "#450a0a"] },
];
export function customWidgets(): Scene {
const bg = h("div", { class: "scene" });
const fg = h("div", { class: "scene" });
// Ambient background: dot grid + two drifting colour fields.
const dots = h("div", {
class: "abs",
style:
"inset:-40px;background-image:radial-gradient(rgba(255,255,255,.09) 1.2px,transparent 1.2px);background-size:36px 36px",
});
const blobA = h("div", {
class: "abs",
style:
"width:1300px;height:1300px;border-radius:50%;left:-300px;top:-500px;background:radial-gradient(closest-side,rgba(250,83,82,.22),transparent)",
});
const blobB = h("div", {
class: "abs",
style:
"width:1400px;height:1400px;border-radius:50%;left:900px;top:200px;background:radial-gradient(closest-side,rgba(124,140,255,.16),transparent)",
});
// The Workshop's background, faded in during the publish so the cut to the next scene doesn't show.
const bgWs = h("div", { class: "abs", style: `inset:0;background:${WORKSHOP_BG}` });
bg.append(blobA, blobB, dots, bgWs);
const chapter = new Chapter("01", "Custom Widgets v2");
const kicker = h(
"div",
{ class: "abs mono", style: "left:96px;top:300px;font-size:26px;color:var(--muted)" },
"This is the big one.",
);
const head = new Headline("Build your own widget.", { size: 168, accent: ["own"] });
const headWrap = h(
"div",
{ class: "abs", style: "left:92px;top:360px;transform-origin:0 0;white-space:nowrap" },
head.el,
);
const sub = new Headline("Utilize an integration or connect directly.", {
size: 44,
weight: 600,
color: "var(--muted)",
});
sub.el.style.letterSpacing = "-0.02em";
const subWrap = h("div", { class: "abs", style: "left:98px;top:560px" }, sub.el);
// What the feature is, kept under the small title while the demo runs.
const desc = h(
"div",
{
class: "abs",
style: "left:98px;top:200px;font-size:26px;line-height:36px;font-weight:550;color:#b9bbc6;white-space:nowrap",
},
h("div", {}, "Build widgets from JSX, API requests, actions and typed settings, or describe one to Assistant."),
h("div", {}, "Test it in the workbench, then publish it to the Workshop."),
);
// ---------- Editor ----------
const codeT = new CodeType(code);
codeT.el.style.cssText = "font-size:19px;line-height:28px;font-family:'JetBrains Mono';color:#c9d1d9";
const gutter = h("div", {
class: "mono",
style: "position:absolute;left:0;top:0;width:40px;text-align:right;font-size:15px;line-height:28px;color:#4b4e5a",
});
gutter.innerHTML = code.map((_, i) => `<div>${i + 1}</div>`).join("");
const lineHi = h("div", {
class: "abs",
style: "left:-28px;right:-28px;height:28px;background:rgba(250,83,82,.09);border-left:3px solid var(--coral)",
});
const scroller = h(
"div",
{ class: "abs", style: "left:0;top:0;right:0" },
lineHi,
gutter,
h("div", { style: "margin-left:62px" }, codeT.el),
);
const codeView = h(
"div",
{ class: "abs", style: "left:28px;right:28px;top:76px;bottom:20px;overflow:hidden" },
scroller,
);
const tabs = ["General", "API sources", "Requests", "Options", "JSX"].map((t) =>
h("div", { class: "mono", style: "font-size:14px;color:var(--muted);padding:6px 12px;border-radius:8px" }, t),
);
const valid = h(
"div",
{ class: "row mono", style: "gap:8px;font-size:14px;color:var(--mint);margin-left:auto" },
icon("circle-check", 18, 2),
"Valid",
);
const titleBar = h(
"div",
{
class: "abs row",
style: "left:0;right:0;top:0;height:58px;padding:0 20px;gap:10px;border-bottom:1px solid var(--line)",
},
h("div", { style: "width:12px;height:12px;border-radius:50%;background:#ff5f57" }),
h("div", { style: "width:12px;height:12px;border-radius:50%;background:#febc2e" }),
h("div", { style: "width:12px;height:12px;border-radius:50%;background:#28c840" }),
h("div", { class: "mono", style: "margin-left:14px;font-size:15px;color:#a6a8b3" }, "sonarr-queue.json"),
h("div", { class: "row", style: "gap:2px;margin-left:26px" }, ...tabs),
valid,
);
const editor = h(
"div",
{ class: "abs card", style: "left:96px;top:296px;width:880px;height:690px;overflow:hidden" },
titleBar,
codeView,
);
// ---------- Preview widget ----------
const chipDefs = ["API requests", "Actions", "Typed settings", "JSX"];
const chips = chipDefs.map((c) => h("div", { class: "chip", style: "font-size:19px;padding:9px 16px" }, c));
const chipRow = h("div", { class: "abs row", style: "left:1060px;top:296px;gap:12px" }, ...chips);
const rows = shows.map((s) => {
const bar = h("div", {
style: "height:100%;width:0;background:linear-gradient(90deg,#ff7b70,#fa5352);border-radius:4px",
});
const pct = h(
"div",
{ class: "mono", style: "font-size:15px;color:var(--muted);width:48px;text-align:right" },
"0%",
);
const el = h(
"div",
{ class: "row", style: "gap:18px;height:84px;padding:0 4px;border-top:1px solid var(--line)" },
h("div", {
style: `width:46px;height:64px;border-radius:8px;background:linear-gradient(160deg,${s.c[0]},${s.c[1]});flex:none`,
}),
h(
"div",
{ class: "col", style: "flex:1;gap:6px" },
h(
"div",
{ class: "row", style: "justify-content:space-between" },
h("div", { style: "font-size:21px;font-weight:700" }, s.t),
pct,
),
h("div", { style: "font-size:15px;color:var(--muted)" }, s.e),
h("div", { style: "height:7px;border-radius:4px;background:rgba(255,255,255,.07);margin-top:2px" }, bar),
),
);
const skel = h("div", {
class: "abs",
style:
"inset:10px 0;border-radius:10px;background:linear-gradient(90deg,rgba(255,255,255,.04),rgba(255,255,255,.1),rgba(255,255,255,.04));background-size:200% 100%",
});
const wrap = h("div", { style: "position:relative" }, el, skel);
return { wrap, el, bar, pct, skel, p: s.p };
});
const srcBadge = h(
"div",
{
class: "row mono",
style: "gap:8px;font-size:13px;letter-spacing:.12em;color:var(--muted);text-transform:uppercase",
},
icon("plug-connected", 16, 2),
"Source · saved Sonarr integration",
);
const searchBtn = h(
"div",
{
class: "row",
style:
"gap:10px;padding:12px 22px;border-radius:10px;background:rgba(250,83,82,.16);color:#ff8f86;font-weight:700;font-size:19px;border:1px solid rgba(250,83,82,.35)",
},
icon("search", 20, 2.2),
"Search",
);
const optPop = h(
"div",
{
class: "row",
style:
"gap:12px;padding:10px 14px;border-radius:10px;background:#2a2b33;border:1px solid var(--line2);font-size:17px;color:#d7d8de;margin-left:auto",
},
icon("adjustments-horizontal", 20, 2),
"Items",
h(
"div",
{ class: "mono", style: "padding:3px 12px;border-radius:6px;background:#1a1b21;border:1px solid var(--line2)" },
"4",
),
);
const header = h(
"div",
{ class: "row", style: "gap:14px" },
logo("sonarr", 40),
h("div", { style: "font-size:27px;font-weight:800;letter-spacing:-.02em" }, "Sonarr queue"),
h("div", { class: "row", style: "margin-left:auto;gap:8px;color:var(--muted)" }, icon("refresh", 22, 2)),
);
const rowsBox = h("div", { class: "col", style: "margin-top:18px" }, ...rows.map((r) => r.wrap));
const footer = h("div", { class: "row", style: "margin-top:18px;gap:12px" }, searchBtn, optPop);
const wbTabs = ["Widget", "Data", "Options", "Actions", "Diagnostics"].map((t, i) =>
h(
"div",
{
class: "mono",
style: `font-size:14px;padding:8px 14px;border-radius:8px;${i === 0 ? "background:rgba(250,83,82,.16);color:#ff8f86" : "color:var(--muted)"}`,
},
t,
),
);
const wbBar = h(
"div",
{ class: "row", style: "gap:4px;padding-bottom:16px;margin-bottom:18px;border-bottom:1px solid var(--line)" },
...wbTabs,
);
const wbBarWrap = h("div", { style: "overflow:hidden" }, wbBar);
const preview = h(
"div",
{ class: "abs card", style: "left:1060px;top:364px;width:764px;padding:26px 30px 28px;transform-origin:50% 50%" },
wbBarWrap,
header,
h("div", { style: "margin-top:12px" }, srcBadge),
rowsBox,
footer,
);
const outlineFlash = h("div", {
class: "abs",
style: "inset:-2px;border-radius:19px;border:2px solid var(--coral);box-shadow:0 0 40px rgba(250,83,82,.5)",
});
preview.append(outlineFlash);
// Publish button that sends the widget to the Workshop.
const publish = h(
"div",
{
class: "abs row",
style:
"left:50%;bottom:-78px;transform-origin:50% 50%;gap:10px;padding:14px 26px;border-radius:12px;background:#fa5352;color:#fff;font-weight:800;font-size:22px;white-space:nowrap;box-shadow:0 20px 40px rgba(250,83,82,.35)",
},
icon("upload", 22, 2.4),
"Publish to Workshop",
);
const published = h(
"div",
{
class: "abs row center",
style:
"inset:0;gap:10px;border-radius:12px;background:#2f9e6b;color:#fff;font-weight:800;font-size:22px;white-space:nowrap",
},
icon("check", 22, 2.6),
"Published",
);
publish.style.position = "absolute";
publish.append(published);
preview.append(publish);
// On publish, the preview's card frame (shell) shrinks straight into the widget's catalog slot while the preview
// content fades out and the Workshop card fades in, both stretched to the shell so the two never ghost.
const shell = h("div", { class: "abs card", style: "left:0;top:0;box-sizing:border-box" });
const handoff = publishedCard();
const landRing = h("div", {
class: "abs",
style: `left:${SLOT.x}px;top:${SLOT.y}px;width:${SLOT.w}px;height:${SLOT.h}px;border-radius:16px;border:3px solid #ff8787;box-sizing:border-box`,
});
fg.append(chapter.el, kicker, headWrap, subWrap, desc, editor, chipRow, shell, preview, handoff, landRing);
// Timeline (scene-local seconds)
const TYPE_A = 2.0;
const TYPE_B = 4.9;
const PUBLISH = 6.2;
const CLICK = PUBLISH + 0.4;
const MORPH = CLICK + 0.25; // text is already leaving, the shell starts for the slot
const LANDED = MORPH + 0.6;
const END = LANDED + 0.4; // last frame: the card alone in its slot on the Workshop background
const lineStart = codeT.lineStart;
const charAt = (line: number) => lineStart[line] ?? codeT.total;
const typed = (t: number) => codeT.total * E.inOutSine(seg(t, TYPE_A, TYPE_B));
const lineOf = (n: number) => {
let l = 0;
lineStart.forEach((s, i) => {
if (n >= s) l = i + (n - s) / Math.max(1, (lineStart[i + 1] ?? codeT.total) - s);
});
return l;
};
const tLine = (line: number) => {
// invert typed(): first t where typed >= charAt(line)
const target = charAt(line);
let lo = TYPE_A;
let hi = TYPE_B;
for (let i = 0; i < 30; i++) {
const m = (lo + hi) / 2;
if (typed(m) < target) lo = m;
else hi = m;
}
return hi;
};
const tSource = tLine(L_SOURCE);
const tQueue = tLine(L_QUEUE);
const tAction = tLine(L_ACTION);
const tOptions = tLine(L_OPTIONS);
const tJsx = tLine(L_JSX);
const feature = [tQueue, tAction, tOptions, tJsx];
const cues: Scene["cues"] = [
{ t: TYPE_A, kind: "type", dur: TYPE_B - TYPE_A, gain: 0.55 },
...feature.map((f) => ({ t: f, kind: "pop" as const, gain: 0.7 })),
{ t: PUBLISH - 0.4, kind: "swish", gain: 0.6 },
{ t: CLICK, kind: "click", gain: 0.8 },
{ t: MORPH + 0.1, kind: "swish", gain: 0.5 },
{ t: LANDED, kind: "pop", gain: 0.6, pitch: 4 },
];
return {
name: "custom-widgets",
start: 0,
end: END,
enter: { dir: "up", dur: 0.45 },
bg,
fg,
cues,
update(t, ctx) {
// Background drift
tf(blobA, { x: Math.sin(t * 0.3) * 120, y: Math.cos(t * 0.25) * 80 });
tf(blobB, { x: Math.cos(t * 0.22) * 140, y: Math.sin(t * 0.3) * 90 });
tf(dots, { y: -t * 6, o: 0.8 });
// Intro title. After Publish the description clears out of the card's path at once; the title leaves as the
// card lands, so the scene ends on the card alone.
const leave = E.inCubic(seg(t, CLICK + 0.1, CLICK + 0.4));
const leaveHead = E.inCubic(seg(t, LANDED - 0.1, END - 0.1));
chapter.update(t, 0.25, LANDED - 0.1);
kicker.style.opacity = t > 0.3 && t < 1.75 ? "1" : "0";
head.update(t, 0.4, Infinity, 0.05, 0.6);
sub.update(t, 0.75, 1.7, 0.025, 0.6);
const shrink = E.inOutQuart(seg(t, 1.65, 2.2));
headWrap.style.transform = `translate(${lerp(0, 4, shrink) - leaveHead * 80}px,${lerp(0, -232, shrink)}px) scale(${lerp(1, 0.4, shrink)})`;
headWrap.style.opacity = String(1 - leaveHead);
const dIn = E.outExpo(seg(t, 1.95, 2.5));
tf(desc, { x: -leave * 80, y: (1 - dIn) * 16, o: dIn * (1 - leave) });
desc.style.clipPath = `inset(0 ${((1 - E.outQuart(seg(t, 1.95, 2.7))) * 100).toFixed(1)}% 0 0)`;
// Editor: slides up with a slight 3D tilt, leaves left once the widget is ready to publish.
const edIn = E.outExpo(seg(t, 1.75, 2.4));
const edOut = E.inOutQuart(seg(t, PUBLISH - 0.45, PUBLISH + 0.15));
editor.style.transform = `perspective(1600px) translate(${(-edOut * 1000).toFixed(1)}px,${((1 - edIn) * 160).toFixed(1)}px) rotateY(${((1 - edIn) * 12 + edOut * -25).toFixed(2)}deg)`;
editor.style.opacity = String(Math.min(seg(t, 1.75, 1.9), 1 - edOut));
editor.style.display = t > 1.7 && t < PUBLISH + 0.2 ? "" : "none";
const n = typed(t);
const line = codeT.set(Math.floor(n), t < TYPE_B + 0.5);
const lf = lineOf(n);
const scrollY = Math.max(0, lf - 15) * 28;
scroller.style.transform = `translateY(${(-scrollY).toFixed(1)}px)`;
lineHi.style.transform = `translateY(${(line * 28).toFixed(1)}px)`;
lineHi.style.opacity = t < TYPE_B + 0.5 ? "1" : "0";
const activeTab = n < charAt(3) ? 0 : n < charAt(9) ? 1 : n < charAt(16) ? 2 : n < charAt(19) ? 3 : 4;
tabs.forEach((tb, i) => {
tb.style.background = i === activeTab ? "rgba(250,83,82,.16)" : "transparent";
tb.style.color = i === activeTab ? "#ff8f86" : "var(--muted)";
});
const v = E.outBack(seg(t, TYPE_B + 0.1, TYPE_B + 0.4));
valid.style.opacity = t > TYPE_B + 0.1 ? "1" : "0";
valid.style.transform = `scale(${v.toFixed(3)})`;
// Chips light up as their code is typed.
const chipIn = E.outExpo(seg(t, 1.9, 2.4));
const chipOut = t > PUBLISH - 0.4;
chips.forEach((c, i) => {
const on = t >= feature[i]!;
const k = on ? Math.exp(-(t - feature[i]!) * 3) : 0;
c.style.background = on ? `rgba(250,83,82,${(0.18 + k * 0.5).toFixed(3)})` : "rgba(255,255,255,.04)";
c.style.borderColor = on ? "rgba(250,83,82,.6)" : "var(--line2)";
c.style.color = on ? "#fff" : "var(--muted)";
c.style.transform = `translateY(${((1 - chipIn) * 30).toFixed(1)}px) scale(${(1 + k * 0.08).toFixed(3)})`;
c.style.opacity = chipOut ? "0" : String(chipIn);
});
// Preview card: appears with the source, grows features, then takes centre stage to be published.
const pvIn = E.outExpo(seg(t, tSource - 0.1, tSource + 0.45));
const toPub = E.inOutQuart(seg(t, PUBLISH - 0.4, PUBLISH + 0.05));
const lift = t > CLICK ? E.outCubic(seg(t, CLICK, CLICK + 0.6)) : 0;
const pvH = preview.offsetHeight;
// Preview rect on screen (transform origin is its centre).
const ps = lerp(1, 0.9, toPub) * (1 + lift * 0.02);
const pw = 764 * ps;
const ph = pvH * ps;
const pcx = 1060 + 382 + lerp(0, -482, toPub);
const pcy = 364 + pvH / 2 + lerp((1 - pvIn) * 80, -40, toPub) - lift * 14;
// Shell rect: from the preview to the catalog slot.
const u = seg(t, MORPH, LANDED);
const m = E.inOutCubic(u);
const rw = lerp(pw, SLOT.w, m);
const rh = lerp(ph, SLOT.h, m);
const rx = lerp(pcx - pw / 2, SLOT.x, m);
const ry = lerp(pcy - ph / 2, SLOT.y, m);
preview.style.transform = `translate(${(rx + rw / 2 - 1442).toFixed(2)}px,${(ry + rh / 2 - 364 - pvH / 2).toFixed(2)}px) scale(${(rw / 764).toFixed(4)},${(rh / pvH).toFixed(4)})`;
// Quick crossfade to the card content early in the move; visibility (not display) keeps pvH measurable.
preview.style.opacity = String(Math.min(pvIn * 3, 1) * (1 - E.inOutSine(seg(u, 0.1, 0.3))));
preview.style.visibility = u < 0.3 ? "" : "hidden";
shell.style.display = t >= MORPH && u < 1 ? "" : "none";
Object.assign(shell.style, {
left: `${rx.toFixed(2)}px`,
top: `${ry.toFixed(2)}px`,
width: `${rw.toFixed(2)}px`,
height: `${rh.toFixed(2)}px`,
borderRadius: `${lerp(18 * ps, 14, m).toFixed(2)}px`,
boxShadow: `0 40px 90px -20px rgba(0,0,0,${(0.65 * (1 - m)).toFixed(3)})`,
});
handoff.style.display = u > 0.2 ? "" : "none";
handoff.style.opacity = E.inOutSine(seg(u, 0.2, 0.4)).toFixed(3);
handoff.style.transform =
u < 1
? `translate(${(rx - SLOT.x).toFixed(2)}px,${(ry - SLOT.y).toFixed(2)}px) scale(${(rw / SLOT.w).toFixed(4)},${(rh / SLOT.h).toFixed(4)})`
: "";
const ring = seg(t, LANDED, LANDED + 0.35);
tf(landRing, { s: lerp(1, 1.1, E.outCubic(ring)), o: t < LANDED ? 0 : (1 - ring) * 0.9 });
const flashK = Math.max(
...feature.map((f) => (t >= f ? Math.exp(-(t - f) * 4) : 0)),
t >= tSource ? Math.exp(-(t - tSource) * 4) : 0,
);
outlineFlash.style.opacity = String(flashK * 0.9);
rows.forEach((r, i) => {
const rin = E.outExpo(seg(t, tQueue + i * 0.05, tQueue + 0.35 + i * 0.05));
r.wrap.style.opacity = String(rin);
r.wrap.style.transform = `translateY(${((1 - rin) * 20).toFixed(1)}px)`;
const loaded = seg(t, tQueue + 0.3 + i * 0.06, tQueue + 0.45 + i * 0.06);
r.skel.style.opacity = String(1 - loaded);
r.skel.style.backgroundPosition = `${(-t * 300) % 400}px 0`;
r.el.style.opacity = String(loaded);
const fillP = E.outExpo(seg(t, tJsx + i * 0.08, tJsx + 0.9 + i * 0.08));
const live = r.p + Math.max(0, t - tJsx - 0.9) * 0.01 * (i + 1);
const val = Math.min(0.99, live) * fillP;
r.bar.style.width = `${(val * 100).toFixed(2)}%`;
r.pct.textContent = `${Math.round(val * 100)}%`;
});
const sIn = spring(t - tAction, 3, 0.45);
searchBtn.style.transform = `scale(${clamp(sIn, 0, 2).toFixed(3)})`;
searchBtn.style.opacity = t >= tAction ? "1" : "0";
const oIn = spring(t - tOptions, 3, 0.45);
optPop.style.transform = `scale(${clamp(oIn, 0, 2).toFixed(3)})`;
optPop.style.opacity = t >= tOptions ? "1" : "0";
const wb = E.outExpo(seg(t, TYPE_B + 0.1, TYPE_B + 0.5));
wbBarWrap.style.height = `${(wb * 58).toFixed(1)}px`;
wbBarWrap.style.opacity = String(wb);
const pub = spring(t - PUBLISH, 3, 0.5);
const press = 1 - Math.sin(seg(t, CLICK - 0.09, CLICK + 0.09) * Math.PI) * 0.1;
publish.style.transform = `translateX(-50%) scale(${(clamp(pub, 0, 2) * press).toFixed(3)})`;
publish.style.opacity = t >= PUBLISH ? "1" : "0";
published.style.opacity = t >= CLICK ? "1" : "0";
},
};
}
+645
View File
@@ -0,0 +1,645 @@
import { E, seg, lerp, spring, clamp } from "../lib/anim";
import { h, tf, icon, logo } from "../lib/dom";
import { Chapter, CodeType, Headline, svg, bez, type Tok } from "../lib/kit";
import type { Scene } from "../lib/scene";
import { LOGO_D, LOGO_VB } from "./intro";
const services = [
"sonarr",
"radarr",
"seerr",
"sabNzbd",
"qBittorrent",
"bazarr",
"beszel",
"jellyfin",
"prowlarr",
"immich",
"plex",
"proxmox",
];
const names: Record<string, string> = {
sonarr: "Sonarr",
radarr: "Radarr",
seerr: "Seerr",
sabNzbd: "SABnzbd",
qBittorrent: "qBittorrent",
bazarr: "Bazarr",
beszel: "Beszel",
jellyfin: "Jellyfin",
prowlarr: "Prowlarr",
immich: "Immich",
plex: "Plex",
proxmox: "Proxmox",
};
const credKinds = ["URL", "API key", "Auth header"];
// Sonarr v3 endpoints. Homarr's Sonarr integration only calls the first four (series, calendar, wanted/missing, queue).
const API: [string, string, boolean][] = [
["GET", "/api/v3/series", true],
["GET", "/api/v3/calendar", true],
["GET", "/api/v3/wanted/missing", true],
["GET", "/api/v3/queue", true],
["POST", "/api/v3/command", false],
["GET", "/api/v3/history", false],
["GET", "/api/v3/diskspace", false],
["PUT", "/api/v3/episode/monitor", false],
];
const CALL = 4; // the endpoint the request reaches
const methodColor: Record<string, string> = { GET: "#3ddc97", POST: "#fa5352", PUT: "#ffb547" };
const K = (s: string): Tok => [s, "k"];
const S = (s: string): Tok => [s, "s"];
const P = (s: string): Tok => [s];
const reqCode: Tok[][] = [
[P("{")],
[P(" "), K('"integrationKind"'), P(": "), S('"sonarr"'), P(",")],
[P(" "), K('"method"'), P(": "), S('"POST"'), P(",")],
[P(" "), K('"path"'), P(": "), S('"/api/v3/command"'), P(",")],
[P(" "), K('"body"'), P(": { "), K('"name"'), P(": "), S('"MissingEpisodeSearch"'), P(" }")],
[P("}")],
];
function flatLogo(size: number, color = "#fa5352") {
const s = svg("svg", { viewBox: LOGO_VB, width: size, height: (size * 346.2) / 512 });
s.append(svg("path", { d: LOGO_D, fill: color }));
return s;
}
export function frontDoor(): Scene {
const bg = h("div", { class: "scene" });
const fg = h("div", { class: "scene" });
// ---------- Door: the sentence is split by a real door that swings open ----------
const DX = 960;
const DY = 430;
const DW = 300;
const DH = 500;
const rays = h("div", {
class: "abs",
style: `left:${DX}px;top:${DY}px;width:3000px;height:3000px;margin:-1500px;background:repeating-conic-gradient(from 0deg,rgba(255,140,125,.16) 0deg 2deg,transparent 2deg 8deg);-webkit-mask-image:radial-gradient(closest-side,#000,transparent 70%);mask-image:radial-gradient(closest-side,#000,transparent 70%)`,
});
const spill = h("div", {
class: "abs",
style: `left:0;right:0;top:${DY + DH / 2}px;height:${1080 - DY - DH / 2}px;background:linear-gradient(180deg,rgba(255,200,190,.55),rgba(250,83,82,.12) 70%,transparent);clip-path:polygon(${DX - DW / 2}px 0,${DX + DW / 2}px 0,1560px 100%,360px 100%)`,
});
const doorLight = h("div", {
class: "abs",
style: `left:${DX - DW / 2}px;top:${DY - DH / 2}px;width:${DW}px;height:${DH}px;border-radius:8px;background:radial-gradient(90% 70% at 50% 60%,#fff,#ffd3cc 35%,#fa5352 90%)`,
});
const panel = h(
"div",
{
class: "abs",
style: `left:${DX - DW / 2}px;top:${DY - DH / 2}px;width:${DW}px;height:${DH}px;border-radius:8px;transform-origin:0 50%;background:linear-gradient(90deg,#1b1b22,#121217);border:1.5px solid rgba(255,176,168,.35);box-shadow:inset 0 0 0 14px rgba(255,255,255,.02)`,
},
h("div", {
class: "abs",
style: "left:26px;right:26px;top:30px;height:190px;border-radius:6px;border:1.5px solid rgba(255,255,255,.08)",
}),
h("div", {
class: "abs",
style: "left:26px;right:26px;bottom:30px;height:210px;border-radius:6px;border:1.5px solid rgba(255,255,255,.08)",
}),
h("div", {
class: "abs",
style:
"right:24px;top:246px;width:16px;height:16px;border-radius:50%;background:#ffb0a8;box-shadow:0 0 12px rgba(250,83,82,.8)",
}),
);
const frame = h("div", {
class: "abs",
style: `left:${DX - DW / 2 - 10}px;top:${DY - DH / 2 - 10}px;width:${DW + 20}px;height:${DH + 10}px;border:4px solid #ffb0a8;border-bottom:none;border-radius:12px 12px 0 0;box-shadow:0 0 30px rgba(250,83,82,.7),inset 0 0 20px rgba(250,83,82,.5)`,
});
const sill = h("div", {
class: "abs",
style: `left:260px;right:260px;top:${DY + DH / 2}px;height:2px;background:linear-gradient(90deg,transparent,rgba(255,176,168,.8),transparent)`,
});
const persp = h(
"div",
{ class: "abs", style: `inset:0;perspective:1400px;perspective-origin:${DX}px ${DY}px` },
panel,
);
const headL = new Headline("The front door", { size: 104, accent: ["front", "door"] });
const headR = new Headline("to your homelab.", { size: 104 });
const headLWrap = h(
"div",
{
class: "abs",
style: `right:${1920 - (DX - DW / 2 - 50)}px;top:${DY - 64}px;white-space:nowrap;text-align:right`,
},
headL.el,
);
const headRWrap = h(
"div",
{ class: "abs", style: `left:${DX + DW / 2 + 50}px;top:${DY - 64}px;white-space:nowrap` },
headR.el,
);
const doorScene = h(
"div",
{ class: "abs", style: `inset:0;transform-origin:${DX}px ${DY}px` },
rays,
spill,
sill,
doorLight,
persp,
frame,
headLWrap,
headRWrap,
);
const chapter = new Chapter("04", "Integration requests");
// ---------- Hub ----------
const cx = 960;
const cy = 500;
const hub = h("div", {
class: "abs center",
style: `left:${cx - 110}px;top:${cy - 110}px;width:220px;height:220px;border-radius:44px;background:radial-gradient(circle at 50% 30%,#2a1c1f,#141217);border:2px solid rgba(250,83,82,.6);box-shadow:0 0 80px rgba(250,83,82,.35)`,
});
const hubLock = h(
"div",
{
class: "abs row mono",
style: `left:${cx - 90}px;top:${cy + 130}px;width:180px;justify-content:center;gap:8px;font-size:15px;font-weight:700;color:var(--mint);letter-spacing:.14em`,
},
icon("lock", 18, 2.4),
"ENCRYPTED",
);
const lines = svg("svg", { width: 1920, height: 1080 });
lines.setAttribute("style", "position:absolute;left:0;top:0;overflow:visible");
const RX = 640;
const RY = 330;
const arc: number[] = [0];
for (let k = 1; k <= 720; k++) {
const a0 = ((k - 1) / 720) * Math.PI * 2;
const a1 = (k / 720) * Math.PI * 2;
arc.push(arc[k - 1]! + Math.hypot(RX * (Math.cos(a1) - Math.cos(a0)), RY * (Math.sin(a1) - Math.sin(a0))));
}
const angleAt = (frac: number) => {
const target = frac * arc[720]!;
const k = arc.findIndex((v) => v >= target);
return (Math.max(0, k) / 720) * Math.PI * 2;
};
const nodes = services.map((s, i) => {
const a = angleAt(i / services.length + 0.02) - Math.PI / 2;
const x = cx + Math.cos(a) * RX;
const y = cy + Math.sin(a) * RY;
const path = svg("path", {
d: `M${cx} ${cy} Q ${(cx + x) / 2 + Math.sin(a) * 60} ${(cy + y) / 2 - Math.cos(a) * 60} ${x} ${y}`,
pathLength: 1,
fill: "none",
stroke: "rgba(250,83,82,.45)",
"stroke-width": 2,
});
lines.append(path);
const el = h(
"div",
{ class: "abs col center", style: `left:${x - 70}px;top:${y - 58}px;width:140px;gap:10px` },
h("div", { class: "card center", style: "width:92px;height:92px;border-radius:22px" }, logo(s, 56)),
h("div", { style: "font-size:18px;font-weight:700;white-space:nowrap" }, names[s]!),
);
const cred = h(
"div",
{
class: "abs row mono",
style:
"left:0;top:0;gap:6px;padding:6px 10px;border-radius:8px;background:#2a1a1c;border:1px solid rgba(250,83,82,.6);color:#ffb3ad;font-size:13px;font-weight:700;white-space:nowrap",
},
icon(i % 3 === 0 ? "world" : "key", 15, 2.2),
credKinds[i % 3]!,
);
return { el, path, x, y, a, cred, ctrl: [(cx + x) / 2 + Math.sin(a) * 60, (cy + y) / 2 - Math.cos(a) * 60] };
});
const hubCaption = new Headline("Homarr already has your services' URLs, API keys and auth headers.", {
size: 44,
weight: 700,
lh: 1.15,
});
hubCaption.el.style.letterSpacing = "-0.02em";
const hubCapWrap = h(
"div",
{ class: "abs", style: "left:260px;right:260px;top:888px;text-align:center" },
hubCaption.el,
);
const hubGroup = h(
"div",
{ class: "abs", style: "inset:0;transform-origin:960px 500px" },
lines,
...nodes.map((n) => n.el),
hub,
hubLock,
...nodes.map((n) => n.cred),
);
// ---------- Explanation: an endpoint Homarr has no code for ----------
const headA = new Headline("Homarr only has code for a few Sonarr endpoints.", { size: 60, accent: ["few"] });
const headAWrap = h("div", { class: "abs", style: "left:96px;top:140px;white-space:nowrap" }, headA.el);
const headB = new Headline("One new endpoint reaches the rest.", { size: 60, accent: ["rest."] });
const headBWrap = h("div", { class: "abs", style: "left:96px;top:140px;white-space:nowrap" }, headB.el);
const apiRows = API.map(([m, path, built]) => {
const tagCode = h(
"div",
{
class: "row mono",
style:
"gap:6px;font-size:14px;font-weight:700;letter-spacing:.06em;padding:5px 10px;border-radius:7px;background:rgba(250,83,82,.14);color:#ffb3ad",
},
icon("code", 15, 2.4),
"HOMARR CODE",
);
const tagNone = h(
"div",
{
class: "mono",
style:
"font-size:14px;letter-spacing:.06em;padding:5px 10px;border-radius:7px;border:1px dashed rgba(255,255,255,.2);color:#8f919d",
},
"NO HOMARR CODE",
);
const tagDone = h(
"div",
{
class: "row mono",
style:
"white-space:nowrap;gap:6px;font-size:14px;font-weight:700;letter-spacing:.06em;padding:5px 10px;border-radius:7px;background:#1f7a55;color:#fff",
},
icon("check", 15, 3),
"CALLED THROUGH HOMARR",
);
const tags = h(
"div",
{ class: "row", style: "margin-left:auto;position:relative" },
built ? tagCode : tagNone,
built ? "" : tagDone,
);
tagDone.style.position = "absolute";
tagDone.style.right = "0";
const el = h(
"div",
{
class: "row",
style: "gap:16px;height:58px;padding:0 18px;border-top:1px solid var(--line);border-radius:10px",
},
h("div", { class: "mono", style: `width:62px;font-size:16px;font-weight:800;color:${methodColor[m]}` }, m),
h("div", { class: "mono", style: "font-size:21px;color:#e4e5ea" }, path),
tags,
);
return { el, tagNone, tagDone, built };
});
const apiCard = h(
"div",
{ class: "abs card col", style: "left:96px;top:250px;width:790px;padding:14px 12px 10px" },
h(
"div",
{ class: "row", style: "gap:14px;height:62px;padding:0 18px;font-size:26px;font-weight:800" },
logo("sonarr", 38),
"Sonarr API",
h("div", { class: "mono", style: "margin-left:auto;font-size:15px;color:var(--muted);font-weight:500" }, "v3"),
),
...apiRows.map((r) => r.el),
);
const reqCodeT = new CodeType(reqCode);
reqCodeT.el.style.cssText = "font-size:21px;line-height:33px;font-family:'JetBrains Mono';color:#c9d1d9";
const reqStatus = h(
"div",
{
class: "row mono",
style:
"margin-left:auto;gap:8px;padding:5px 12px;border-radius:8px;background:#1f7a55;color:#fff;font-size:16px;font-weight:800",
},
"201",
h("span", { style: "font-weight:500" }, "Created"),
);
const reqCard = h(
"div",
{
class: "abs card",
style: "left:960px;top:250px;width:864px;padding:18px 26px 22px;border-color:rgba(250,83,82,.45)",
},
h(
"div",
{ class: "row", style: "gap:14px;height:46px;margin-bottom:10px" },
h(
"div",
{
class: "mono",
style: "padding:4px 12px;border-radius:8px;background:#fa5352;color:#fff;font-size:18px;font-weight:800",
},
"POST",
),
h("div", { class: "mono", style: "font-size:24px;font-weight:700" }, "/api/integrations/request"),
reqStatus,
),
reqCodeT.el,
);
const FLOW_Y = 705;
const homarrNode = h(
"div",
{
class: "abs card row",
style: `left:960px;top:${FLOW_Y - 68}px;width:470px;height:136px;padding:0 24px;gap:18px`,
},
flatLogo(70),
h(
"div",
{ class: "col", style: "gap:6px" },
h("div", { style: "font-size:28px;font-weight:850" }, "Homarr"),
h(
"div",
{ style: "font-size:18px;color:#b9bbc6;line-height:1.3" },
"Adds the saved URL and API key.",
h("br"),
"Never returns them.",
),
),
);
const sonarrNode = h(
"div",
{
class: "abs card row",
style: `left:1570px;top:${FLOW_Y - 68}px;width:254px;height:136px;padding:0 24px;gap:16px`,
},
logo("sonarr", 64),
h("div", { style: "font-size:28px;font-weight:850" }, "Sonarr"),
);
const flowWire = h("div", {
class: "abs",
style: `left:1430px;width:140px;top:${FLOW_Y - 1}px;height:3px;background:rgba(250,83,82,.55);transform-origin:0 50%`,
});
const packet = h(
"div",
{
class: "abs row mono",
style:
"left:0;top:0;gap:10px;padding:9px 14px;border-radius:11px;background:#fa5352;color:#fff;font-weight:700;font-size:17px;white-space:nowrap;box-shadow:0 0 30px rgba(250,83,82,.6)",
},
"POST /api/v3/command",
);
// Second leg: the same call, now carrying Homarr's stored key, crosses the wire to Sonarr.
const pkt2 = h(
"div",
{
class: "abs row",
style:
"left:0;top:0;gap:8px;padding:10px 12px;border-radius:999px;background:#fa5352;color:#fff;box-shadow:0 0 30px rgba(250,83,82,.8)",
},
icon("send", 26, 2.4),
h(
"span",
{ class: "center", style: "width:36px;height:36px;border-radius:50%;background:#1f7a55" },
icon("key", 22, 2.6),
),
);
const resp = h(
"div",
{
class: "abs row mono",
style:
"left:0;top:0;gap:10px;padding:9px 14px;border-radius:11px;background:#15261f;border:1.5px solid var(--mint);color:#d8ffe9;font-size:17px;font-weight:700;white-space:nowrap;box-shadow:0 0 30px rgba(61,220,151,.35)",
},
h("span", { style: "color:var(--mint)" }, "201"),
"Created",
);
const statement = new Headline("If the service's API has the endpoint, Homarr can call it.", {
size: 52,
weight: 800,
});
const stWrap = h("div", { class: "abs", style: "left:96px;top:836px;white-space:nowrap" }, statement.el);
const lane = (tag: string, text: string) =>
h(
"div",
{
class: "row",
style:
"gap:12px;padding:9px 16px;border-radius:12px;background:rgba(255,255,255,.04);border:1px solid var(--line2)",
},
h("div", { class: "mono", style: "font-size:14px;letter-spacing:.16em;color:var(--muted)" }, tag),
h("div", { class: "mono", style: "font-size:20px;font-weight:600" }, text),
);
const lanes = [
lane("REST", "POST /api/integrations/request"),
lane("tRPC", "integration.request"),
lane("MCP", "integration_request"),
];
const laneRow = h("div", { class: "abs row", style: "left:96px;top:936px;gap:14px" }, ...lanes);
const expl = h(
"div",
{ class: "abs", style: "inset:0" },
apiCard,
flowWire,
reqCard,
homarrNode,
sonarrNode,
packet,
pkt2,
resp,
stWrap,
laneRow,
headAWrap,
headBWrap,
);
bg.append(doorScene, hubGroup);
fg.append(chapter.el, hubCapWrap, expl);
// Scene-local timeline
const SWING = 0.3;
const PUSH = 1.45;
const HUB = 1.95;
const KEYS = HUB + 0.55;
const EXPL = 4.15;
const ROW = EXPL + 1.05; // command row is singled out
const REQ = EXPL + 1.4;
const TYPE0 = REQ + 0.2;
const TYPE1 = TYPE0 + 0.8;
const PK0 = TYPE1 + 0.15; // packet drops into Homarr
const PK1 = PK0 + 0.3;
const PK2 = PK1 + 0.25; // key attached, leaves for Sonarr
const PK3 = PK2 + 0.32;
const R1 = PK3 + 0.45; // response back at the request card
const STATE = R1 + 0.25;
const END = STATE + 2.2;
const cues: Scene["cues"] = [
{ t: 0.05, kind: "whoosh", gain: 0.6 },
{ t: SWING, kind: "boom", gain: 0.9 },
{ t: SWING + 0.2, kind: "swish", gain: 0.5 },
{ t: PUSH - 0.35, kind: "riser", dur: 0.5, gain: 0.6 },
{ t: PUSH + 0.3, kind: "whoosh", gain: 0.9 },
...nodes.map((_, i) => ({ t: HUB + 0.05 + i * 0.03, kind: "tick" as const, gain: 0.3, pitch: i % 5 })),
...nodes.map((_, i) => ({ t: KEYS + 0.45 + i * 0.04, kind: "zap" as const, dur: 0.06, gain: 0.22 })),
{ t: KEYS + 0.9, kind: "hit", gain: 0.6 },
{ t: EXPL - 0.1, kind: "whoosh", gain: 0.7 },
...API.map((_, i) => ({ t: EXPL + 0.2 + i * 0.04, kind: "tick" as const, gain: 0.25, pitch: i % 6 })),
{ t: ROW, kind: "pop", gain: 0.5 },
{ t: REQ, kind: "swish", gain: 0.5 },
{ t: TYPE0, kind: "type", dur: TYPE1 - TYPE0, gain: 0.45 },
{ t: PK0, kind: "swish", gain: 0.4 },
{ t: PK1 + 0.05, kind: "click", gain: 0.8 },
{ t: PK3, kind: "hit", gain: 0.55 },
{ t: R1, kind: "chime", gain: 0.6, pitch: 3 },
{ t: STATE, kind: "hit", gain: 0.7 },
{ t: END - 0.3, kind: "whoosh", gain: 0.9 },
];
return {
name: "front-door",
start: 0,
end: END,
bg,
fg,
cues,
update(t, ctx) {
// Door: frame is there from the first frame; the panel swings in; the words slide out from behind the jambs.
const swing = E.outBack(seg(t, SWING, SWING + 0.7), 1.1);
const open = clamp(swing, 0, 1.05);
panel.style.transform = `rotateY(${(-open * 108).toFixed(2)}deg)`;
panel.style.filter = `brightness(${lerp(1, 0.55, clamp(open)).toFixed(3)})`;
const glow = clamp(open);
tf(doorLight, { o: 0.25 + glow * 0.75 });
tf(spill, { o: glow * 0.9 });
tf(rays, { r: t * 8, s: 0.5 + glow * 0.7, o: glow * 0.9 });
const wIn = E.outExpo(seg(t, SWING + 0.12, SWING + 0.75));
tf(headLWrap, { x: (1 - wIn) * 260, o: wIn > 0.01 ? 1 : 0 });
tf(headRWrap, { x: -(1 - wIn) * 260, o: wIn > 0.01 ? 1 : 0 });
headLWrap.style.clipPath = `inset(-40px 0 -40px ${((1 - wIn) * 100).toFixed(1)}%)`;
headRWrap.style.clipPath = `inset(-40px ${((1 - wIn) * 100).toFixed(1)}% -40px 0)`;
headL.update(t, SWING + 0.1, Infinity, 0.03, 0.5);
headR.update(t, SWING + 0.14, Infinity, 0.03, 0.5);
// Push through the doorway into the homelab.
const push = E.inExpo(seg(t, PUSH, HUB + 0.1));
doorScene.style.transform = `scale(${(1 + push * 11).toFixed(3)})`;
doorScene.style.opacity = String(1 - seg(t, HUB - 0.05, HUB + 0.15));
doorScene.style.display = t < HUB + 0.2 ? "" : "none";
const hitO = t > SWING ? Math.exp(-(t - SWING) * 6) : 0;
ctx.fx.shake = hitO * 14;
ctx.fx.flash = Math.max(hitO * 0.25, Math.sin(seg(t, HUB - 0.15, HUB + 0.25) * Math.PI) * 0.75);
ctx.fx.flashColor = "#ffd9d3";
ctx.fx.fade = 1 - seg(t, 0, 0.12);
chapter.update(t, HUB + 0.1, END - 0.4);
// Hub
const hubOn = t > HUB - 0.1 && t < EXPL + 0.4;
hubGroup.style.display = hubOn ? "" : "none";
hubCapWrap.style.display = hubOn ? "" : "none";
const hIn = E.outBack(seg(t, HUB - 0.05, HUB + 0.4), 1.4);
const hOut = E.inExpo(seg(t, EXPL - 0.35, EXPL + 0.2));
hubGroup.style.transform = `scale(${(lerp(1.25, 1, E.outExpo(seg(t, HUB - 0.1, HUB + 0.6))) * (1 + hOut * 2.2)).toFixed(3)})`;
hubGroup.style.opacity = String(1 - hOut);
tf(hub, { s: hIn });
const L = ctx.logo;
if (hubOn) {
L.visible = hOut < 0.95;
L.scale = 0.2 * hIn * (1 + hOut * 2.2);
L.y = ((540 - cy) / 168) * (1 + hOut * 2.2);
L.ry = Math.sin(t * 1.6) * 0.5;
L.rx = -0.1;
L.antenna = t * 3;
L.clawL = 0.3 + 0.3 * Math.sin(t * 5);
L.clawR = 0.3 + 0.3 * Math.sin(t * 5 + 1);
ctx.fx.glBlur = hOut * 10;
}
const LOCK = KEYS + 0.9;
const lockIn = spring(t - LOCK, 3, 0.45);
hubLock.style.transform = `scale(${clamp(lockIn, 0, 2).toFixed(3)})`;
hubLock.style.opacity = t > LOCK ? "1" : "0";
const hk = t > LOCK ? Math.exp(-(t - LOCK) * 4) : 0;
hub.style.boxShadow = `0 0 ${(80 + hk * 80).toFixed(0)}px rgba(${hk > 0.05 ? "61,220,151" : "250,83,82"},${(0.35 + hk * 0.4).toFixed(2)})`;
nodes.forEach((n, i) => {
const n0 = HUB + 0.05 + i * 0.03;
const ni = E.outBack(seg(t, n0, n0 + 0.35), 1.6);
const drift = Math.sin(t * 0.8 + i) * 6;
tf(n.el, { s: ni, o: t > n0 ? 1 : 0, y: drift });
const lp = E.outCubic(seg(t, n0, n0 + 0.4));
n.path.style.strokeDasharray = `${lp} 1`;
// Credential travels from service to hub.
const k0 = KEYS + i * 0.04;
const kp = E.inOutCubic(seg(t, k0, k0 + 0.45));
const [px, py] = bez([n.x, n.y + drift], n.ctrl, n.ctrl, [cx, cy], kp);
n.cred.style.transform = `translate(${(px - 50).toFixed(1)}px,${(py - 16).toFixed(1)}px) scale(${lerp(1, 0.5, kp).toFixed(3)})`;
n.cred.style.opacity = String((t > k0 - 0.15 ? 1 : 0) * (1 - seg(t, k0 + 0.38, k0 + 0.45)));
n.path.setAttribute("stroke", t > k0 + 0.45 ? "rgba(61,220,151,.55)" : "rgba(250,83,82,.45)");
});
hubCaption.update(t, HUB + 0.25, EXPL - 0.4, 0.018, 0.55);
// Explanation
const eOn = t > EXPL - 0.1;
expl.style.display = eOn ? "" : "none";
if (!eOn) return;
const whip = E.inExpo(seg(t, END - 0.3, END));
expl.style.transform = `translateX(${(-whip * 1400).toFixed(1)}px)`;
expl.style.filter = whip > 0.02 ? `blur(${(whip * 30).toFixed(1)}px)` : "";
headA.update(t, EXPL, REQ - 0.1, 0.035, 0.55);
headB.update(t, REQ + 0.2, Infinity, 0.035, 0.55);
const aIn = E.outExpo(seg(t, EXPL, EXPL + 0.5));
tf(apiCard, { x: (1 - aIn) * -80, o: t > EXPL ? 1 : 0 });
apiRows.forEach((r, i) => {
const at = EXPL + 0.2 + i * 0.04;
const ri = E.outExpo(seg(t, at, at + 0.35));
tf(r.el, { x: (1 - ri) * 40, o: t > at ? 1 : 0 });
const done = !r.built && i === CALL && t > R1;
const k = done ? Math.exp(-(t - R1) * 4) : 0;
r.tagDone.style.display = done ? "" : "none";
r.tagDone.style.transform = `scale(${done ? clamp(spring(t - R1, 3.2, 0.45), 0, 1.5).toFixed(3) : 0})`;
r.tagNone.style.visibility = done ? "hidden" : "visible";
const focus = i === CALL && t > ROW;
r.el.style.background = done
? `rgba(61,220,151,${(0.1 + k * 0.2).toFixed(3)})`
: focus
? "rgba(250,83,82,.12)"
: "";
r.el.style.boxShadow = focus ? `inset 0 0 0 1.5px ${done ? "rgba(61,220,151,.6)" : "rgba(250,83,82,.6)"}` : "";
// Other unsupported rows recede once the call is singled out.
r.el.style.opacity =
t > ROW && i !== CALL && !r.built ? String(lerp(1, 0.55, seg(t, ROW, ROW + 0.3))) : r.el.style.opacity;
});
const rIn = E.outExpo(seg(t, REQ, REQ + 0.45));
tf(reqCard, { y: (1 - rIn) * 60, o: t > REQ ? 1 : 0 });
reqCodeT.set(Math.floor(reqCodeT.total * seg(t, TYPE0, TYPE1)), t < PK0);
const rs = spring(t - R1, 3.2, 0.45);
reqStatus.style.transform = `scale(${clamp(rs, 0, 1.5).toFixed(3)})`;
reqStatus.style.opacity = t > R1 ? "1" : "0";
const fIn = E.outExpo(seg(t, REQ + 0.2, REQ + 0.6));
tf(homarrNode, { y: (1 - fIn) * 40, o: t > REQ + 0.2 ? 1 : 0 });
tf(sonarrNode, { x: (1 - fIn) * 80, o: t > REQ + 0.25 ? 1 : 0 });
tf(flowWire, { sx: E.outExpo(seg(t, PK2 - 0.1, PK2 + 0.2)) });
// Homarr lights up when it adds the key; Sonarr when the call lands.
const hkk = t > PK1 ? Math.exp(-(t - PK1) * 5) : 0;
homarrNode.style.boxShadow = `0 0 ${(hkk * 60).toFixed(0)}px rgba(61,220,151,${(hkk * 0.7).toFixed(2)})`;
homarrNode.style.borderColor = t > PK1 ? "rgba(61,220,151,.5)" : "";
const sk = t > PK3 ? Math.exp(-(t - PK3) * 5) : 0;
sonarrNode.style.boxShadow = `0 0 ${(sk * 60).toFixed(0)}px rgba(250,83,82,${(sk * 0.8).toFixed(2)})`;
// Packet: request card → into Homarr's logo; a smaller key-carrying packet then crosses the wire to Sonarr.
const LOGO_X = 960 + 24 + 35;
const p1 = E.inOutCubic(seg(t, PK0, PK1));
packet.style.transform = `translate(${lerp(1190, LOGO_X, p1).toFixed(1)}px,${lerp(560, FLOW_Y, p1).toFixed(1)}px) translate(-50%,-50%) scale(${lerp(1, 0.5, seg(p1, 0.75, 1)).toFixed(3)})`;
packet.style.visibility = t > PK0 && t < PK1 ? "visible" : "hidden";
const p2 = E.inOutCubic(seg(t, PK2, PK3));
pkt2.style.transform = `translate(${lerp(1440, 1600, p2).toFixed(1)}px,${FLOW_Y}px) translate(-50%,-50%) scale(${(t < PK2 + 0.08 ? lerp(0.4, 1, seg(t, PK2, PK2 + 0.08)) : 1).toFixed(3)})`;
pkt2.style.visibility = t > PK2 && t < PK3 ? "visible" : "hidden";
// Response: Sonarr → up into the request card.
const rp = E.outCubic(seg(t, PK3 + 0.05, R1));
const rx = lerp(1690, 1730, rp);
const ry = lerp(FLOW_Y, 296, rp);
resp.style.transform = `translate(${rx.toFixed(1)}px,${ry.toFixed(1)}px) translate(-50%,-50%) scale(${lerp(1, 0.6, seg(rp, 0.8, 1)).toFixed(3)})`;
resp.style.opacity = t > PK3 + 0.05 && t < R1 ? "1" : "0";
// Plain statement + where to call it from.
statement.update(t, STATE, Infinity, 0.03, 0.55);
lanes.forEach((l, i) => {
const at = STATE + 0.35 + i * 0.07;
const li = E.outBack(seg(t, at, at + 0.3), 1.8);
l.style.transform = `scale(${clamp(lerp(0.7, 1, li), 0, 1.2).toFixed(3)})`;
l.style.opacity = t > at ? "1" : "0";
});
const hs = t > STATE ? Math.exp(-(t - STATE) * 6) : 0;
ctx.fx.shake = Math.max(ctx.fx.shake, hs * 6);
ctx.fx.ca = hs * 3 + whip * 6;
},
};
}
+158
View File
@@ -0,0 +1,158 @@
import { E, seg, lerp, env, noise, pulse, spring, clamp, BEAT } from "../lib/anim";
import { h, tf } from "../lib/dom";
import { Headline } from "../lib/kit";
import type { Scene } from "../lib/scene";
import logoSvg from "../../assets/homarr.svg";
export const LOGO_D = /d="([^"]+)"/.exec(logoSvg)![1]!;
export const LOGO_VB = "0 82.9 512 346.2";
// 3D logo scale 1 spans 5.15 world units; camera fov 30 at z=12 shows 6.43 units over 1080 px.
export const PX_PER_UNIT = 1080 / (2 * 12 * Math.tan((15 * Math.PI) / 180));
// "NOW IN Homarr v2": the lobster spins in on the opening crash, slides left for the lockup, then waves and winks.
export function intro(): Scene {
const bg = h("div", { class: "scene", style: "background:#070708" });
const fg = h("div", { class: "scene" });
const glow = h("div", {
class: "abs",
style: "inset:0;background:radial-gradient(ellipse 48% 46% at 50% 52%,rgba(250,82,82,.42),rgba(250,82,82,0) 70%)",
});
const rays = h("div", {
class: "abs",
style:
"left:-540px;top:-960px;width:3000px;height:3000px;background:repeating-conic-gradient(from 0deg at 50% 50%,rgba(255,130,130,.08) 0deg 3deg,rgba(255,130,130,0) 3deg 12deg);-webkit-mask-image:radial-gradient(circle at 50% 50%,#000 0%,rgba(0,0,0,.4) 18%,transparent 42%)",
});
bg.append(glow, rays);
const now = h(
"div",
{
class: "abs mono",
style: "left:1004px;top:318px;font-size:28px;font-weight:600;color:#ff8787;white-space:nowrap",
},
"NOW IN",
);
const name = new Headline("Homarr", { size: 172, weight: 830 });
name.el.style.letterSpacing = "-0.045em";
const nameWrap = h("div", { class: "abs", style: "left:996px;top:340px;white-space:nowrap" }, name.el);
const v2 = h(
"div",
{
class: "abs display",
style:
"left:986px;top:470px;font-size:440px;font-weight:900;letter-spacing:-0.07em;line-height:1;color:#fa5352;white-space:nowrap;transform-origin:25% 65%;text-shadow:0 30px 80px rgba(250,82,82,.35)",
},
"v2",
);
const sub = h(
"div",
{
class: "abs mono",
style: "left:1004px;top:912px;font-size:22px;letter-spacing:.3em;color:#cfcfd6;white-space:nowrap",
},
"THE BIGGEST HOMARR UPDATE",
);
const txt = h("div", { class: "abs", style: "inset:0" }, now, nameWrap, v2, sub);
const rings = [0, 1].map((i) =>
h("div", {
class: "abs",
style: `left:1250px;top:640px;width:200px;height:200px;margin:-100px 0 0 -100px;border-radius:50%;border:${[4, 1.5][i]}px solid ${["#ff8787", "#fff"][i]}`,
}),
);
const flash = h("div", {
class: "abs",
style:
"inset:0;background:radial-gradient(circle at 50% 50%,#fff 0%,rgba(255,170,170,.7) 30%,rgba(250,82,82,0) 70%);mix-blend-mode:screen",
});
fg.append(txt, ...rings, flash);
const SLIDE = 0.75; // lobster moves left for the lockup
const SLAM = 2 * BEAT; // "v2" lands on the second kick
const HEY = 3 * BEAT; // wave, pinch and wink
const END = 6 * BEAT;
const LOGO_X = -2.9; // world units: centred at x ≈ 474 px
const tap = (t: number, a: number, d: number) => Math.sin(clamp((t - a) / d) * Math.PI);
return {
name: "intro",
start: 0,
end: END,
bg,
fg,
cues: [
{ t: 0.05, kind: "riser", dur: SLAM - 0.05, gain: 0.7 },
{ t: 0.3, kind: "whoosh", gain: 0.9 },
{ t: 0.05, kind: "swish", gain: 0.5 },
{ t: 0.55, kind: "tick", gain: 0.5 },
{ t: SLAM, kind: "reverse", gain: 0.8 },
{ t: SLAM, kind: "boom", gain: 1 },
{ t: SLAM, kind: "hit", gain: 0.5 },
{ t: SLAM + 0.4, kind: "swish", gain: 0.45 },
{ t: HEY + 0.3, kind: "click", gain: 0.5 },
{ t: HEY + 0.48, kind: "click", gain: 0.5 },
{ t: HEY + 0.58, kind: "pop", gain: 0.5, pitch: 8 },
{ t: END, kind: "whoosh", gain: 0.7 },
],
update(t, ctx) {
const L = ctx.logo;
L.visible = true;
const slide = E.inOutCubic(seg(t, SLIDE, SLIDE + 0.45));
const turn = -Math.PI * 4 * (1 - E.outExpo(seg(t, 0, 1.05)));
L.x = lerp(0, LOGO_X, slide);
L.y = 0.1;
L.scale = lerp(0.05, 0.8, spring(t, 1.25, 0.55)) * lerp(1, 0.78, slide);
L.ry = turn + 0.42 * slide + 0.12 * Math.sin(t * 1.6) * seg(t, 1, 2);
L.rx = -0.06;
L.dust = 0.5 * seg(t, 0, 1.2);
L.sparks = t >= SLAM ? (t - SLAM) / 1.3 : -1;
// Wave hello with the right claw, pinch twice, perk the antennae and wink.
const hey = env(t, HEY, END - 0.1, 0.25, 0.4, E.outBack, E.inCubic);
const wave = Math.sin((t - HEY) * 2 * Math.PI * 2.6);
L.waveR = hey * (-0.02 + wave * 0.11);
L.waveL = hey * 0.06 * Math.sin((t - HEY) * 2 * Math.PI * 1.3 + 1);
L.rz = hey * (-0.06 + wave * 0.015);
L.y += hey * 0.05 * Math.abs(Math.sin((t - HEY) * Math.PI * 2.6));
L.antennaLift = -hey * 0.06;
L.antenna = t * 3 + hey * (t - HEY) * 14;
L.antennaAmp = 0.12 + hey * 0.1;
const pinch = Math.max(tap(t, HEY + 0.25, 0.2), tap(t, HEY + 0.43, 0.2));
const clack = Math.max(tap(t, 0.55, 0.22), tap(t, SLAM, 0.22));
L.clawL = Math.max(clack, pinch * 0.6) + 0.12 * (0.5 + 0.5 * Math.sin(t * 5));
L.clawR = Math.max(clack, pinch * 0.5) + 0.12 * (0.5 + 0.5 * Math.sin(t * 5 + 1));
const wink = HEY + 0.58;
L.blinkL = E.outCubic(seg(t, wink, wink + 0.07)) * (1 - E.inOutCubic(seg(t, wink + 0.22, wink + 0.32)));
glow.style.opacity = String(clamp(0.7 + 0.6 * pulse(t, [0], 4) + 0.5 * pulse(t, [SLAM, 4 * BEAT], 5)));
tf(rays, { r: t * 10, s: lerp(0.6, 1, E.outExpo(seg(t, 0, 1))), o: E.outCubic(seg(t, 0, 0.5)) });
// Lockup on the right.
const np = E.outExpo(seg(t, SLIDE + 0.1, SLIDE + 0.55));
now.style.opacity = String(np);
now.style.letterSpacing = `${lerp(1.3, 0.5, np).toFixed(3)}em`;
name.update(t, SLIDE + 0.12, Infinity, 0, 0.5);
const vp = seg(t, SLAM, SLAM + 0.38);
v2.style.opacity = t < SLAM ? "0" : "1";
v2.style.transform = `scale(${lerp(2.8, 1, E.outExpo(vp)).toFixed(3)}) rotate(${((1 - E.outExpo(vp)) * -8).toFixed(2)}deg)`;
v2.style.filter = vp < 1 ? `blur(${((1 - E.outExpo(vp)) * 18).toFixed(1)}px)` : "";
const sp = E.outExpo(seg(t, SLAM + 0.22, SLAM + 0.65));
tf(sub, { y: (1 - sp) * 14, o: sp });
const sh = t > SLAM ? 16 * Math.exp(-9 * (t - SLAM)) : 0;
tf(txt, { x: noise(t * 35, 3) * sh, y: noise(t * 35, 4) * sh });
// Shockwave from the "v2" on the slam.
rings.forEach((r, i) => {
const a = SLAM + i * 0.06;
const p = seg(t, a, a + 0.9);
tf(r, { s: lerp(0.6, 14 - i * 4, E.outExpo(p)), o: t < a ? 0 : (1 - E.outQuad(p)) * [0.9, 0.7][i]! });
});
flash.style.opacity = String(0.9 * pulse(t, [0], 9) + 0.45 * pulse(t, [SLAM], 16));
ctx.fx.fade = 1 - seg(t, 0, 0.06);
ctx.fx.shake = sh * 0.6;
ctx.fx.ca = t > SLAM ? 7 * Math.exp(-(t - SLAM) * 6) : 0;
},
};
}
+618
View File
@@ -0,0 +1,618 @@
import { E, seg, lerp, spring, clamp } from "../lib/anim";
import { h, icon, logo, offsetWithin, tf } from "../lib/dom";
import { CodeType, Headline, TypeBlock, countTo, type Tok } from "../lib/kit";
import type { Scene } from "../lib/scene";
// The real run from the blog post: one MCP prompt, seven services wired to ntfy.
const PROMPT =
"Install a notification provider and then set it up everywhere it's supported in my installed integrations";
const THOUGHTS = [
"Their integrations: SABnzbd, qBittorrent, Sonarr, Radarr, Prowlarr, Jellyfin x2, Overseerr, Immich, Umami, Beszel.",
"Sonarr/Radarr/Prowlarr/Lidarr: have Notifications with ntfy, Telegram, Discord, Gotify, etc.",
];
const ROWS: [string, string, string, string][] = [
["sonarr", "Sonarr", "Native ntfy connection for grabs, downloads, upgrades and health", "Test fired ✓"],
["radarr", "Radarr", "Native ntfy connection, plus movie added", "Test fired ✓"],
["seerr", "Seerr", "Webhook with a JSON payload for readable titles", "Fires on request, approve, available, fail"],
["sabNzbd", "SABnzbd", "5.1.3 has no ntfy support, so a completion script on the default category", "Dry run ✓"],
["qBittorrent", "qBittorrent", "[AutoRun] completion hook in qBittorrent.conf", "Persisted after restart"],
["bazarr", "Bazarr", "ntfy provider enabled for subtitle events", "Restarted ✓"],
["beszel", "Beszel", "Webhook with status, CPU, memory and disk alerts on all eight systems", "29 alerts created"],
];
// The service API each change goes through, called via Homarr's integration_request tool.
const CALLS: [string, string, string][] = [
["sonarr", "POST", "/api/v3/notification"],
["radarr", "POST", "/api/v3/notification"],
["seerr", "POST", "/api/v1/settings/notifications/webhook"],
["sabNzbd", "GET", "/api?mode=set_config"],
["qBittorrent", "POST", "/api/v2/app/setPreferences"],
["bazarr", "POST", "/api/system/settings"],
["beszel", "POST", "/api/collections/alerts/records"],
];
const OPTIONS: [string, string][] = [
["ntfy", "ntfy"],
["telegram", "Telegram"],
["discord", "Discord"],
["gotify", "Gotify"],
];
const K = (s: string): Tok => [s, "k"];
const S = (s: string): Tok => [s, "s"];
const P = (s: string): Tok => [s];
const COMPOSE: Tok[][] = [
[K("services"), P(":")],
[P(" "), K("ntfy"), P(":")],
[P(" "), K("image"), P(": "), S("binwiederhier/ntfy")],
[P(" "), K("command"), P(": "), S("serve")],
[P(" "), K("ports"), P(": ["), S('"8090:80"'), P("]")],
[P(" "), K("restart"), P(": "), S("unless-stopped")],
];
export function ntfy(): Scene {
const bg = h("div", {
class: "scene",
style: "background:radial-gradient(90% 70% at 30% 40%,#141a33 0%,#0a0b12 60%,#07070b 100%)",
});
const grid = h("div", {
class: "abs",
style:
"inset:-200px;background-image:linear-gradient(rgba(255,255,255,.035) 1px,transparent 1px),linear-gradient(90deg,rgba(255,255,255,.035) 1px,transparent 1px);background-size:80px 80px;-webkit-mask-image:radial-gradient(60% 60% at 50% 50%,#000,transparent);mask-image:radial-gradient(60% 60% at 50% 50%,#000,transparent)",
});
bg.append(grid);
const fg = h("div", { class: "scene" });
// ---------- Title ----------
const title = new Headline("Integration requests in action.", { size: 112, accent: ["action."] });
const titleWrap = h("div", { class: "abs", style: "left:0;top:0;white-space:nowrap;transform-origin:0 0" }, title.el);
const kicker = h(
"div",
{ class: "abs row", style: "left:96px;top:152px;gap:12px;font-size:26px;color:#b9bbc6;white-space:nowrap" },
h("div", { style: "color:var(--coral)" }, icon("plug-connected", 26, 2)),
"A local model, talking to Homarr's MCP server:",
);
// ---------- Chat ----------
const CHAT_W = 820;
const CHAT_TOP = 216;
const CHAT_H = 810;
const BODY_TOP = 70;
const VIEW_H = CHAT_H - BODY_TOP - 128;
const thread = h("div", { class: "col", style: "gap:18px" });
const chatBody = h(
"div",
{ class: "abs", style: `left:28px;right:28px;top:${BODY_TOP}px;height:${VIEW_H}px;overflow:hidden` },
thread,
);
const chat = h(
"div",
{ class: "abs card", style: `left:0;top:${CHAT_TOP}px;width:${CHAT_W}px;height:${CHAT_H}px;overflow:hidden` },
h(
"div",
{
class: "row",
style:
"height:54px;padding:0 22px;gap:9px;border-bottom:1px solid var(--line);background:rgba(255,255,255,.02)",
},
...["#ff5f57", "#febc2e", "#28c840"].map((c) =>
h("div", { style: `width:12px;height:12px;border-radius:50%;background:${c}` }),
),
h("div", { style: "margin-left:16px;font-size:18px;font-weight:700" }, "Agent"),
h(
"div",
{ class: "row mono", style: "margin-left:auto;gap:9px;font-size:14px;color:#a9abb6" },
h("div", {
style: "width:9px;height:9px;border-radius:50%;background:var(--mint);box-shadow:0 0 10px var(--mint)",
}),
"homarr · MCP connected",
),
),
chatBody,
);
const prompt = new TypeBlock(PROMPT, "", "#fff");
const sendBtn = h(
"div",
{ class: "center", style: "width:48px;height:48px;border-radius:13px;background:#fa5352;color:#fff;flex:none" },
icon("arrow-up", 26, 2.6),
);
const composer = h(
"div",
{
class: "abs row",
style:
"left:28px;right:28px;bottom:20px;min-height:92px;padding:12px 14px 12px 22px;gap:16px;border-radius:16px;background:#121318;border:1px solid var(--line2);font-size:21px;line-height:1.35",
},
h("div", { style: "flex:1" }, prompt.el),
sendBtn,
);
chat.append(composer);
const bubble = (text: string) =>
h(
"div",
{
style:
"align-self:flex-end;max-width:640px;padding:16px 22px;border-radius:18px 18px 6px 18px;background:#2b1b1e;border:1px solid rgba(250,83,82,.45);font-size:22px;line-height:1.4;font-weight:560",
},
text,
);
const userMsg = bubble(PROMPT);
const shimmer = h(
"span",
{
style:
"background:linear-gradient(90deg,#8f919d 0%,#fff 50%,#8f919d 100%);background-size:200% 100%;-webkit-background-clip:text;background-clip:text;color:transparent",
},
"Thinking",
);
const thoughtTypes = THOUGHTS.map((tx) => new TypeBlock(tx, "", "#8f919d"));
const thinking = h(
"div",
{ class: "col", style: "gap:8px" },
h(
"div",
{ class: "row", style: "gap:10px;font-size:19px;font-weight:700;color:#a9abb6" },
icon("sparkles", 20, 2),
shimmer,
),
h(
"div",
{
class: "col",
style:
"gap:6px;padding-left:16px;border-left:2px solid rgba(255,255,255,.12);font-size:18px;line-height:1.4;color:#9a9ca8;font-style:italic",
},
...thoughtTypes.map((tt) => h("div", {}, tt.el)),
),
);
const opts = OPTIONS.map(([key, name], i) =>
h(
"div",
{
class: "row",
style:
"gap:12px;height:56px;padding:0 16px;border-radius:13px;border:1.5px solid var(--line2);font-size:22px;font-weight:700",
},
logo(key, 30),
name,
i === 0
? h(
"span",
{
style:
"margin-left:auto;font-size:14px;padding:3px 9px;border-radius:999px;background:rgba(61,220,151,.15);color:var(--mint);font-weight:700",
},
"Recommended",
)
: "",
),
);
const optNtfy = opts[0]!;
const optOther = h(
"div",
{
class: "row",
style:
"grid-column:span 2;gap:12px;height:48px;padding:0 16px;border-radius:13px;border:1px dashed var(--line2);font-size:19px;color:#8f919d",
},
icon("pencil", 20, 2),
"Type your own answer",
);
const question = h(
"div",
{
class: "col",
style:
"gap:10px;padding:18px 20px;border-radius:16px;background:rgba(124,140,255,.07);border:1px solid rgba(124,140,255,.35)",
},
h("div", { class: "label", style: "color:#aab4ff;font-size:13px" }, "Question"),
h(
"div",
{ style: "font-size:24px;font-weight:750;margin-bottom:4px" },
"Which notification provider should I install and wire up?",
),
h("div", { style: "display:grid;grid-template-columns:1fr 1fr;gap:10px" }, ...opts, optOther),
);
const compose = new CodeType(COMPOSE);
compose.el.style.cssText = "font-size:17px;line-height:25px;color:#c9d1d9";
const reply = h(
"div",
{ class: "col", style: "gap:10px" },
h(
"div",
{ style: "font-size:21px;line-height:1.4;color:#e6e7ec" },
"Add ntfy to your compose file and start it. Tell me when it's up.",
),
h(
"div",
{ style: "padding:12px 16px;border-radius:12px;background:#0d0e12;border:1px solid var(--line2)" },
h(
"div",
{
class: "row mono",
style: "gap:8px;font-size:13px;color:var(--muted);margin-bottom:6px;letter-spacing:.08em",
},
icon("brand-docker", 16, 2),
"COMPOSE.YAML",
),
compose.el,
),
);
const userUp = bubble("It's up.");
const callEls = CALLS.map(([key, m, path]) => {
const spin = h("div", { class: "abs", style: "left:0;top:0;color:var(--amber)" }, icon("loader-2", 18, 2.4));
const ok = h("div", { class: "abs", style: "left:0;top:0;color:var(--mint)" }, icon("circle-check", 18, 2.4));
const el = h(
"div",
{ class: "row mono", style: "gap:10px;height:30px;font-size:16px;white-space:nowrap" },
h("div", { style: "position:relative;width:18px;height:18px;flex:none" }, spin, ok),
logo(key, 20),
h("span", { style: "color:#a9abb6;width:104px" }, key.toLowerCase()),
h("span", { style: `font-weight:800;color:${m === "GET" ? "#3ddc97" : "#fa5352"};width:44px` }, m),
h("span", { style: "color:#e6e7ec" }, path),
);
return { el, spin, ok };
});
const wiring = h(
"div",
{
class: "col",
style:
"align-self:stretch;gap:4px;padding:12px 16px;border-radius:12px;background:#15161b;border:1px solid var(--line2)",
},
h(
"div",
{ class: "row mono", style: "gap:10px;font-size:16px;margin-bottom:4px" },
h("span", { style: "color:#a9abb6" }, "execute"),
h("span", { style: "font-weight:700" }, "homarr.integration_request"),
h("span", { style: "margin-left:auto;color:var(--muted)" }, `×${CALLS.length}`),
),
...callEls.map((c) => c.el),
);
const items = [userMsg, thinking, question, reply, userUp, wiring];
thread.append(...items);
const cursor = h(
"div",
{
class: "abs",
style: "left:0;top:0;width:34px;height:34px;color:#fff;filter:drop-shadow(0 4px 8px rgba(0,0,0,.6))",
},
icon("filled:pointer", 34, 1),
);
// ---------- Report table (right of the chat once wiring starts) ----------
const TX = 980;
const TW = 844;
const TY = 268;
const RH = 86;
const tableHead = new Headline("Then it set everything up itself:", { size: 44, weight: 750 });
const tableHeadWrap = h(
"div",
{ class: "abs", style: `left:${TX}px;top:${TY - 76}px;white-space:nowrap` },
tableHead.el,
);
const alerts = h("span", {}, "0");
const rows = ROWS.map(([key, name, how, ver], i) => {
const verEl = h(
"div",
{
class: "row",
style:
"justify-self:end;gap:6px;padding:5px 11px;border-radius:9px;background:rgba(61,220,151,.12);border:1px solid rgba(61,220,151,.4);color:#b8f5d8;font-size:15px;font-weight:700;line-height:1.3;max-width:210px;text-align:right",
},
key === "beszel" ? h("span", {}, alerts, " alerts created") : ver,
);
const el = h(
"div",
{
class: "abs",
style: `left:${TX}px;top:${TY + i * (RH + 6)}px;width:${TW}px;height:${RH}px;display:grid;grid-template-columns:190px 1fr 220px;align-items:center;padding:0 18px;border-radius:13px;background:rgba(255,255,255,.025);border:1px solid var(--line)`,
},
h("div", { class: "row", style: "gap:12px;font-size:21px;font-weight:800" }, logo(key, 36), name),
h("div", { style: "font-size:17px;line-height:1.3;color:#d7d8de;padding-right:16px" }, how),
verEl,
);
return { el, verEl };
});
const table = h("div", { class: "abs", style: "inset:0" }, tableHeadWrap, ...rows.map((r) => r.el));
// ---------- Phone ----------
const notif = (key: string, name: string) =>
h(
"div",
{
class: "row",
style:
"gap:14px;padding:16px;border-radius:22px;background:rgba(40,42,52,.92);border:1px solid rgba(255,255,255,.08);align-items:flex-start",
},
h(
"div",
{ class: "center", style: "width:44px;height:44px;border-radius:12px;background:#1d2d35;flex:none" },
logo("ntfy", 30),
),
h(
"div",
{ class: "col", style: "gap:3px;flex:1" },
h(
"div",
{ class: "row", style: "font-size:15px;color:#a9abb6;gap:6px" },
"ntfy",
h("span", { style: "margin-left:auto" }, "now"),
),
h("div", { class: "row", style: "gap:8px;font-size:19px;font-weight:750" }, logo(key, 20), name),
h("div", { style: "font-size:17px;color:#d7d8de" }, "Test notification"),
),
);
const n1 = notif("sonarr", "Sonarr");
const n2 = notif("radarr", "Radarr");
const phone = h(
"div",
{
class: "abs",
style:
"left:1250px;top:140px;width:400px;height:820px;border-radius:64px;background:#0d0e13;border:10px solid #2a2b33;box-shadow:0 60px 120px rgba(0,0,0,.7),0 0 0 2px #3a3b44;overflow:hidden",
},
h("div", { class: "abs", style: "inset:0;background:radial-gradient(120% 70% at 30% 0%,#3a1c2a,#10121c 60%)" }),
h("div", {
class: "abs",
style: "left:50%;top:18px;width:120px;height:34px;margin-left:-60px;border-radius:20px;background:#000",
}),
h(
"div",
{
class: "abs display",
style:
"left:0;right:0;top:110px;text-align:center;font-size:96px;font-weight:300;letter-spacing:-.03em;color:#f1eef4",
},
"21:04",
),
h("div", { class: "abs col", style: "left:18px;right:18px;top:300px;gap:12px" }, n1, n2),
);
const buzzLines = [0, 1].map(() =>
h("div", {
class: "abs",
style: "width:40px;height:220px;border-left:4px solid rgba(250,83,82,.7);border-radius:50%",
}),
);
const phoneWrap = h("div", { class: "abs", style: "inset:0" }, phone, ...buzzLines);
const cap1 = new Headline("Two test notifications later, the phone buzzed.", { size: 50, weight: 700, lh: 1.15 });
const cap1Wrap = h("div", { class: "abs", style: "left:120px;top:250px;width:980px" }, cap1.el);
const zero = h(
"div",
{
class: "abs display",
style:
"left:112px;top:410px;font-size:260px;font-weight:850;letter-spacing:-.05em;color:var(--mint);line-height:1",
},
"$0",
);
const cost = h(
"div",
{ class: "abs col", style: "left:124px;top:700px;gap:16px" },
h("div", { style: "font-size:40px;font-weight:700" }, "Qwen3.8-27B ran locally through MLX."),
h(
"div",
{ style: "font-size:30px;font-weight:600;color:#cfd0d8" },
"Or $0.008 with DeepSeek v4.1 Flash, free through Homarr Assistant.",
),
h("div", { style: "font-size:28px;color:#8f919d" }, "The only side effect was a funny-smelling GPU."),
);
const costLines = [...cost.children] as HTMLElement[];
fg.append(titleWrap, kicker, table, chat, cursor, cap1Wrap, zero, cost, phoneWrap);
// ---------- Timeline (scene-local) ----------
const P0 = 1.3;
const PCPS = 115;
const SEND = P0 + PROMPT.length / PCPS + 0.1;
const TH0 = SEND + 0.15;
const TCPS = 260;
const thStarts: number[] = [];
let acc = TH0 + 0.15;
for (const tt of thoughtTypes) {
thStarts.push(acc);
acc = tt.end(acc, TCPS) + 0.1;
}
const Q = acc + 0.05;
const CLICK = Q + 0.85;
const REPLY = CLICK + 0.25;
const CODE0 = REPLY + 0.15;
const CODE1 = CODE0 + 0.55;
const UP = CODE1 + 0.35;
const WIRE = UP + 0.35;
const reveal = [SEND, TH0, Q, REPLY, UP, WIRE];
const RS = 0.27;
const callT = (i: number) => WIRE + 0.3 + i * RS;
const LAST = callT(CALLS.length - 1);
const PH = LAST + 1.15;
const OUT = PH + 3.6;
const END = OUT + 0.45;
let scrollTargets: number[] | null = null;
let titleW: number | undefined;
const cues: Scene["cues"] = [
{ t: 0, kind: "whoosh", gain: 0.8 },
{ t: 0.22, kind: "hit", gain: 0.6 },
{ t: 0.85, kind: "swish", gain: 0.5 },
{ t: P0, kind: "type", dur: PROMPT.length / PCPS, gain: 0.45 },
{ t: SEND, kind: "key", gain: 0.9 },
{ t: SEND + 0.06, kind: "swish", gain: 0.4 },
{ t: Q, kind: "pop", gain: 0.7 },
{ t: CLICK, kind: "click", gain: 1 },
{ t: CODE0, kind: "type", dur: CODE1 - CODE0, gain: 0.35 },
{ t: UP, kind: "key", gain: 0.7 },
{ t: WIRE - 0.2, kind: "whoosh", gain: 0.6 },
...CALLS.flatMap((_, i) => [
{ t: callT(i), kind: "zap" as const, dur: 0.12, gain: 0.3, pitch: i },
{ t: callT(i) + 0.2, kind: "tick" as const, gain: 0.6, pitch: i },
]),
{ t: LAST + 0.3, kind: "chime", gain: 0.6, pitch: 3 },
{ t: PH, kind: "whoosh", gain: 0.6 },
{ t: PH + 0.5, kind: "buzz", dur: 0.4, gain: 0.9 },
{ t: PH + 0.9, kind: "buzz", dur: 0.4, gain: 0.9 },
{ t: PH + 1.3, kind: "hit", gain: 0.8 },
{ t: OUT, kind: "whoosh", gain: 0.9 },
];
return {
name: "ntfy",
start: 0,
end: END,
// Typing, thinking and the call table run fast; the phone and the cost lines are for reading.
warp: [
[P0, WIRE + 0.3, 1.5],
[WIRE + 0.3, PH, 1.2],
],
bg,
fg,
cues,
update(t, ctx) {
tf(grid, { y: (t * 12) % 80, o: 0.9 });
// Title: whips in from the right (continuing the previous exit), then docks top-left.
const whipIn = E.outExpo(seg(t, 0, 0.5));
const dockP = E.inOutQuart(seg(t, 0.8, 1.25));
titleW ??= titleWrap.offsetWidth;
const x0 = (1920 - titleW) / 2 + (1 - whipIn) * 900;
titleWrap.style.transform = `translate(${lerp(x0, 96, dockP).toFixed(1)}px,${lerp(460, 66, dockP).toFixed(1)}px) scale(${lerp(1, 0.52, dockP).toFixed(4)})`;
titleWrap.style.filter = whipIn < 0.98 ? `blur(${((1 - whipIn) * 24).toFixed(1)}px)` : "";
title.update(t, 0.03, OUT - 0.1, 0.04, 0.5);
const kIn = E.outExpo(seg(t, 1.05, 1.5));
const kOut = t > PH - 0.1;
kicker.style.clipPath = `inset(-10px ${((1 - kIn) * 100).toFixed(1)}% -10px 0)`;
kicker.style.display = kOut ? "none" : "";
// Chat: slides up from below the frame, centred; moves left when the wiring table arrives.
const cIn = E.outExpo(seg(t, 0.9, 1.4));
const toLeft = E.inOutQuart(seg(t, WIRE - 0.35, WIRE + 0.2));
const cOut = E.inOutQuart(seg(t, PH - 0.3, PH + 0.3));
const chatOn = t < PH + 0.3;
chat.style.display = chatOn ? "" : "none";
const chatX = lerp((1920 - CHAT_W) / 2, 96, toLeft);
chat.style.transform = `translate(${(chatX - cOut * 1000).toFixed(1)}px,${((1 - cIn) * 900).toFixed(1)}px)`;
chat.style.filter = cOut > 0.02 ? `blur(${(cOut * 10).toFixed(1)}px)` : "";
if (chatOn) {
prompt.update(t, P0, PCPS, SEND);
// Sending clears the composer; the message lands in the thread.
(prompt.el.parentElement as HTMLElement).style.visibility = t < SEND ? "visible" : "hidden";
const sk = t > SEND ? Math.exp(-(t - SEND) * 6) : 0;
sendBtn.style.transform = `scale(${(t > SEND && t < SEND + 0.1 ? 0.88 : 1 + sk * 0.12).toFixed(3)})`;
sendBtn.style.boxShadow = `0 0 ${(sk * 40).toFixed(0)}px rgba(250,83,82,${(sk * 0.8).toFixed(2)})`;
thoughtTypes.forEach((tt, i) =>
tt.update(t, thStarts[i]!, TCPS, i === thoughtTypes.length - 1 ? Q : thStarts[i + 1]! - 0.05),
);
shimmer.style.backgroundPosition = `${(200 - ((t * 120) % 200)).toFixed(1)}% 0`;
// Messages pop into the thread (no fade): a quick rise from just below.
items.forEach((it, i) => {
const on = t >= reveal[i]!;
const r = E.outExpo(seg(t, reveal[i]!, reveal[i]! + 0.3));
it.style.visibility = on ? "visible" : "hidden";
it.style.transform = `translateY(${((1 - r) * 18).toFixed(1)}px)`;
});
compose.set(Math.floor(compose.total * seg(t, CODE0, CODE1)), t < UP);
// Scroll so the newest message is always in view.
if (!scrollTargets) {
scrollTargets = items.map((it) => Math.max(0, offsetWithin(it, chatBody)[1] + it.offsetHeight - VIEW_H + 6));
}
let sy = 0;
scrollTargets.forEach((target, i) => {
const prev = i ? scrollTargets![i - 1]! : 0;
sy += (target - prev) * E.inOutCubic(seg(t, reveal[i]! - 0.08, reveal[i]! + 0.3));
});
thread.style.transform = `translateY(${(-sy).toFixed(1)}px)`;
// Question → click ntfy
const picked = t >= CLICK;
const pk = picked ? Math.exp(-(t - CLICK) * 5) : 0;
const hover = seg(t, CLICK - 0.25, CLICK - 0.12);
optNtfy.style.borderColor = picked ? "#fa5352" : hover > 0 ? "rgba(255,255,255,.35)" : "var(--line2)";
optNtfy.style.background = picked
? `rgba(250,83,82,${(0.14 + pk * 0.3).toFixed(3)})`
: `rgba(255,255,255,${(hover * 0.05).toFixed(3)})`;
optNtfy.style.transform = `scale(${(t > CLICK && t < CLICK + 0.12 ? 0.97 : 1).toFixed(3)})`;
opts.slice(1).forEach((o) => (o.style.opacity = picked ? "0.45" : "1"));
optOther.style.opacity = picked ? "0.45" : "1";
// Cursor glides in from the lower right to the ntfy option.
const cp = E.inOutCubic(seg(t, Q + 0.2, CLICK - 0.04));
const [optX, optY] = offsetWithin(optNtfy, chatBody);
const ox = chatX + 28 + optX + 120;
const oy = CHAT_TOP + BODY_TOP + optY - scrollTargets[2]! + 30;
cursor.style.display = t > Q + 0.15 && t < CLICK + 0.45 ? "" : "none";
cursor.style.transform = `translate(${lerp(1400, ox, cp).toFixed(1)}px,${lerp(1060, oy, cp).toFixed(1)}px) scale(${t > CLICK && t < CLICK + 0.12 ? 0.85 : 1})`;
// integration_request calls tick off one by one.
callEls.forEach((c, i) => {
const done = t >= callT(i) + 0.2;
const going = t >= callT(i);
c.el.style.opacity = going ? "1" : "0.28";
c.spin.style.display = going && !done ? "" : "none";
c.spin.style.transform = `rotate(${((t * 720) % 360).toFixed(1)}deg)`;
c.ok.style.display = done ? "" : "none";
c.ok.style.transform = `scale(${done ? clamp(spring(t - callT(i) - 0.2, 4, 0.4), 0, 2).toFixed(3) : 0})`;
});
} else cursor.style.display = "none";
// Table: each row slides out from behind the chat as its call lands.
const tOn = t > WIRE - 0.2 && t < OUT + 0.5;
table.style.display = tOn ? "" : "none";
const recede = E.inOutCubic(seg(t, PH - 0.1, PH + 0.5));
const tOut = E.inCubic(seg(t, OUT, OUT + 0.45));
table.style.transform = `translateX(${(-recede * 880).toFixed(1)}px) scale(${lerp(1, 0.9, recede).toFixed(3)})`;
table.style.opacity = String(lerp(1, 0.16, recede) * (1 - tOut));
table.style.filter = recede > 0.02 ? `blur(${(recede * 6).toFixed(1)}px)` : "";
tableHead.update(t, WIRE - 0.05, Infinity, 0.035, 0.45);
rows.forEach((r, i) => {
const r0 = callT(i);
const ri = E.outExpo(seg(t, r0, r0 + 0.35));
const hit = t > r0 + 0.2 ? Math.exp(-(t - r0 - 0.2) * 4) : 0;
tf(r.el, { x: (1 - ri) * -120, o: t >= r0 ? 1 : 0 });
r.el.style.clipPath = `inset(-4px -4px -4px ${((1 - ri) * 60).toFixed(1)}%)`;
r.el.style.borderColor = hit > 0.05 ? `rgba(61,220,151,${(hit * 0.8).toFixed(2)})` : "rgba(61,220,151,.2)";
r.el.style.background = `rgba(61,220,151,${(hit * 0.12).toFixed(3)})`;
const vi = spring(t - r0 - 0.2, 3.4, 0.45);
r.verEl.style.transform = `scale(${(0.6 + 0.4 * clamp(vi, 0, 2)).toFixed(3)})`;
r.verEl.style.visibility = t >= r0 + 0.2 ? "visible" : "hidden";
});
countTo(alerts, t, callT(6) + 0.2, callT(6) + 0.8, 29);
// Phone + cost
const phOn = t > PH - 0.2;
phoneWrap.style.display = cap1Wrap.style.display = zero.style.display = cost.style.display = phOn ? "" : "none";
const phIn = E.outExpo(seg(t, PH, PH + 0.6));
const buzz = (b: number) => (t > b && t < b + 0.4 ? Math.sin((t - b) * 90) * (1 - (t - b) / 0.4) : 0);
const bz = buzz(PH + 0.5) + buzz(PH + 0.9);
const pOut = E.inCubic(seg(t, OUT, OUT + 0.45));
phone.style.transform = `translate(${(bz * 6).toFixed(1)}px,${((1 - phIn) * 900 + pOut * -80).toFixed(1)}px) rotate(${(lerp(-8, 4, phIn) + bz * 1.2).toFixed(2)}deg) scale(${lerp(1, 1.4, pOut).toFixed(3)})`;
phone.style.opacity = String(1 - pOut);
[n1, n2].forEach((n, i) => {
const nt = PH + 0.5 + i * 0.4;
const ni = spring(t - nt, 2.6, 0.5);
n.style.transform = `translateY(${((1 - clamp(ni, 0, 1.2)) * -40).toFixed(1)}px) scale(${lerp(0.9, 1, clamp(ni, 0, 1)).toFixed(3)})`;
n.style.visibility = t >= nt ? "visible" : "hidden";
});
buzzLines.forEach((b, i) => {
const k = Math.max(
t > PH + 0.5 ? Math.exp(-(t - PH - 0.5) * 5) : 0,
t > PH + 0.9 ? Math.exp(-(t - PH - 0.9) * 5) : 0,
);
const x = i === 0 ? 1212 : 1660;
b.style.transform = `translate(${x}px,440px) scaleX(${i === 0 ? -1 : 1}) scale(${(1 + (1 - k) * 0.3).toFixed(3)})`;
b.style.opacity = String(k);
});
cap1.update(t, PH + 0.15, OUT - 0.15, 0.03, 0.5);
const ZT = PH + 1.3;
const z = spring(t - ZT, 2.4, 0.4);
zero.style.transform = `scale(${clamp(z, 0, 2).toFixed(3)})`;
zero.style.transformOrigin = "0 80%";
zero.style.opacity = String((t >= ZT ? 1 : 0) * (1 - pOut));
zero.style.textShadow = `0 0 ${(40 + (t > ZT ? Math.exp(-(t - ZT) * 3) : 0) * 80).toFixed(0)}px rgba(61,220,151,.45)`;
costLines.forEach((l, i) => {
const c = E.outExpo(seg(t, ZT + 0.2 + i * 0.3, ZT + 0.6 + i * 0.3));
l.style.clipPath = `inset(-10px ${((1 - c) * 100).toFixed(1)}% -10px 0)`;
});
cost.style.opacity = String(1 - pOut);
const hitZ = t > ZT ? Math.exp(-(t - ZT) * 6) : 0;
ctx.fx.shake = hitZ * 10 + Math.abs(bz) * 3 + (1 - whipIn) * 10;
ctx.fx.ca = (1 - whipIn) * 8 + pOut * 6;
ctx.fx.fade = E.inCubic(seg(t, OUT + 0.15, END));
},
};
}
+118
View File
@@ -0,0 +1,118 @@
import { E, seg, lerp, pulse, spring, clamp } from "../lib/anim";
import { h, tf } from "../lib/dom";
import { Headline } from "../lib/kit";
import type { Scene } from "../lib/scene";
const PILLS = ["Open source", "Self-hosted", "v2 out now", "homarr.dev"];
// End card on the track's final hit: the lobster assembles centre stage, then winks.
export function outro(): Scene {
const bg = h("div", { class: "scene", style: "background:#070708" });
const fg = h("div", { class: "scene" });
const CY = 440; // centre of the lockup in px
const glow = h("div", {
class: "abs",
style: `inset:0;background:radial-gradient(ellipse 50% 44% at 50% ${((CY / 1080) * 100).toFixed(1)}%,rgba(250,82,82,.36),rgba(250,82,82,0) 70%)`,
});
const rays = h("div", {
class: "abs",
style: `left:-540px;top:${CY - 1500}px;width:3000px;height:3000px;background:repeating-conic-gradient(from 0deg at 50% 50%,rgba(255,130,130,.08) 0deg 3deg,rgba(255,130,130,0) 3deg 12deg);-webkit-mask-image:radial-gradient(circle at 50% 50%,#000 0%,rgba(0,0,0,.4) 18%,transparent 42%)`,
});
bg.append(glow, rays);
const tag = new Headline("A simple, yet powerful dashboard for your server.", {
size: 40,
weight: 500,
color: "#d5d5dc",
});
const tagWrap = h(
"div",
{ class: "abs", style: "left:0;right:0;top:768px;text-align:center;white-space:nowrap" },
tag.el,
);
const pills = PILLS.map((p, i) =>
h(
"span",
{
class: "chip",
style: `font-size:21px;padding:11px 24px;letter-spacing:.12em;${i === 3 ? "background:#fa5252;border-color:#fa5252;color:#fff" : i === 2 ? "color:#ff8787;border-color:rgba(250,82,82,.55)" : "color:#cfcfd6;border-color:rgba(255,255,255,.22)"}`,
},
p,
),
);
const pillRow = h(
"div",
{ class: "abs row", style: "left:0;right:0;top:856px;justify-content:center;gap:16px" },
...pills,
);
const content = h("div", { class: "abs", style: `inset:0;transform-origin:50% ${CY}px` }, tagWrap, pillRow);
const rings = [0, 1].map((i) =>
h("div", {
class: "abs",
style: `left:960px;top:${CY}px;width:200px;height:200px;margin:-100px 0 0 -100px;border-radius:50%;border:${[4, 1.5][i]}px solid ${["#ff8787", "#fff"][i]}`,
}),
);
const flash = h("div", {
class: "abs",
style: `inset:0;background:radial-gradient(circle at 50% ${((CY / 1080) * 100).toFixed(1)}%,#fff 0%,rgba(255,170,170,.7) 30%,rgba(250,82,82,0) 70%);mix-blend-mode:screen`,
});
fg.append(content, ...rings, flash);
const WINK = 1.75;
const END = 4.0;
const px = (y: number) => (540 - y) / 168;
return {
name: "outro",
start: 0,
end: END,
bg,
fg,
cues: [
{ t: 0.02, kind: "boom", gain: 0.8 },
{ t: 0.9, kind: "tick", gain: 0.45 },
{ t: 1.0, kind: "tick", gain: 0.45 },
{ t: WINK, kind: "pop", gain: 0.5, pitch: 8 },
],
update(t, ctx) {
// Lobster: reassembles from the collapsed globe, settles in the centre and winks.
const L = ctx.logo;
L.visible = true;
L.x = 0;
L.y = px(CY);
L.scale = clamp(spring(t, 2.0, 0.5), 0, 1.3) * 0.5;
L.explode = 1 - E.outExpo(seg(t, 0, 1.1));
L.sparks = t < 1.4 ? seg(t, 0, 1.4) : -1;
L.dust = 0.5;
L.ry = (1 - E.outQuart(seg(t, 0, 1.5))) * Math.PI * 4 + 0.3 + Math.sin(t * 1.1) * 0.12;
L.rx = 0.08 + Math.sin(t * 0.7) * 0.04;
const perk = t > WINK - 0.1 ? Math.exp(-(t - WINK + 0.1) * 2.5) : 0;
L.antennaLift = -perk * 0.06;
L.antenna = t * 3 + perk * 4;
L.antennaAmp = 0.12 + perk * 0.1;
const clack = (at: number) => (t > at ? Math.exp(-(t - at) * 6) : 0);
L.clawL = 0.2 + 0.7 * Math.max(clack(0.9), clack(WINK + 0.05));
L.clawR = 0.2 + 0.7 * Math.max(clack(1.0), clack(WINK + 0.15));
L.blinkL = E.outCubic(seg(t, WINK, WINK + 0.07)) * (1 - E.inOutCubic(seg(t, WINK + 0.24, WINK + 0.34)));
L.wm.on = false;
glow.style.opacity = String(clamp(0.75 + 0.6 * pulse(t, [0], 4)));
tf(rays, { r: t * 9, s: lerp(0.6, 1, E.outExpo(seg(t, 0, 1))), o: E.outCubic(seg(t, 0, 0.6)) });
tag.update(t, 0.55, Infinity, 0.035, 0.5);
pills.forEach((p, i) => {
const a = 0.9 + i * 0.07;
tf(p, { s: clamp(spring(t - a, 2.4, 0.5), 0, 1.2), o: seg(t, a, a + 0.08) });
});
tf(content, { s: 1 + 0.03 * E.outQuad(seg(t, 0, END)) });
rings.forEach((r, i) => {
const a = i * 0.05;
const p = seg(t, a, a + 0.9);
tf(r, { s: lerp(0.6, 12, E.outExpo(p)), o: (1 - E.outQuad(p)) * [0.9, 0.7][i]! });
});
flash.style.opacity = String(0.95 * pulse(t, [0], 8));
ctx.fx.fade = E.inCubic(seg(t, END - 0.7, END));
},
};
}
+589
View File
@@ -0,0 +1,589 @@
import { E, seg, lerp, spring, clamp, BEAT } from "../lib/anim";
import { h, icon, logo, tf } from "../lib/dom";
import { Chapter, CharPop, Headline, TypeLine } from "../lib/kit";
import type { Scene } from "../lib/scene";
const kbd = (k: string) => h("div", { class: "kbd", style: "font-size:17px" }, k);
/** Bento card shell; `vis` holds the per-card micro-animation. */
function card(accent: string, ic: string, title: string, line: string, vis: HTMLElement, keys?: HTMLElement) {
return h(
"div",
{ class: "abs card col", style: `padding:28px 32px;gap:12px;border-color:${accent}40;overflow:hidden` },
h(
"div",
{ class: "row", style: "gap:16px" },
h(
"div",
{
class: "center",
style: `width:50px;height:50px;border-radius:15px;background:${accent}22;color:${accent};flex:none`,
},
icon(ic, 28, 2),
),
h("div", { style: "font-size:30px;font-weight:850;letter-spacing:-.02em;white-space:nowrap" }, title),
keys ? h("div", { class: "row", style: "margin-left:auto;gap:6px" }, keys) : "",
),
h("div", { style: "font-size:21px;line-height:1.4;color:#b9bbc6" }, line),
h("div", { style: "flex:1;position:relative;margin-top:6px" }, vis),
);
}
export function rest(): Scene {
const fg = h("div", { class: "scene" });
// ---------- Title ----------
const big = new CharPop("The rest", 210);
const bigSub = new Headline("(there is a lot)", { size: 64, weight: 700, color: "var(--coral)" });
const title = h("div", { class: "abs col center", style: "inset:0;gap:18px" }, big.el, bigSub.el);
const chapter = new Chapter("06", "The rest (there is a lot)");
// ---------- Page 1 ----------
// Onboarding: six stages complete in sequence.
const STAGES = ["First admin", "Core settings", "Docker discovery", "Apps", "Integrations", "First board"];
const stageEls = STAGES.map((s, i) => {
const num = h(
"div",
{
class: "center mono",
style:
"width:30px;height:30px;border-radius:50%;flex:none;font-size:14px;font-weight:800;border:2px solid rgba(255,255,255,.2);color:#8f919d",
},
String(i + 1),
);
const done = h(
"div",
{ class: "abs center", style: "inset:-2px;border-radius:50%;background:#3ddc97;color:#07130d" },
icon("check", 18, 3),
);
num.style.position = "relative";
num.append(done);
const el = h("div", { class: "row", style: "gap:10px;font-size:17px;font-weight:650;white-space:nowrap" }, num, s);
return { el, done };
});
const visOnb = h(
"div",
{ style: "display:grid;grid-template-columns:1fr 1fr;gap:14px 18px" },
...stageEls.map((s) => s.el),
);
// Board switcher: keyboard focus walks a gallery.
const BOARDS: [string, string[]][] = [
["Homelab", ["#fa5352", "#7c8cff", "#3ddc97"]],
["Media", ["#ffb547", "#fa5352", "#4fb3ff"]],
["Family", ["#3ddc97", "#ffb547", "#7c8cff"]],
["Servers", ["#4fb3ff", "#3ddc97", "#fa5352"]],
];
const thumbs = BOARDS.map(([name, cs]) =>
h(
"div",
{ class: "col", style: "flex:1;gap:8px;padding:8px;border-radius:12px;border:2px solid transparent" },
h(
"div",
{
style:
"height:78px;border-radius:8px;background:#121318;display:grid;grid-template-columns:2fr 1fr;grid-template-rows:1fr 1fr;gap:5px;padding:6px",
},
h("div", { style: `grid-row:span 2;border-radius:5px;background:${cs[0]}55` }),
h("div", { style: `border-radius:5px;background:${cs[1]}55` }),
h("div", { style: `border-radius:5px;background:${cs[2]}55` }),
),
h("div", { style: "font-size:15px;font-weight:700;text-align:center" }, name),
),
);
const visSwitch = h("div", { class: "row", style: "gap:8px;align-items:stretch" }, ...thumbs);
// Command menu: a query and its results.
const query = new TypeLine("se", "", "#4fb3ff");
const RESULTS: [string, string, string][] = [
["settings", "Settings", "Page"],
["apps", "Seerr", "App"],
["world-search", "Search engines", "Page"],
];
const results = RESULTS.map(([ic, name, kind]) =>
h(
"div",
{ class: "row", style: "gap:12px;height:32px;padding:0 12px;border-radius:9px;font-size:17px;font-weight:650" },
h("div", { style: "color:#8fcfff" }, icon(ic, 19, 2)),
name,
h(
"div",
{ class: "mono", style: "margin-left:auto;font-size:12px;color:#8f919d;letter-spacing:.1em" },
kind.toUpperCase(),
),
),
);
const visCmd = h(
"div",
{ class: "col", style: "gap:4px" },
h(
"div",
{
class: "row",
style:
"gap:10px;height:38px;padding:0 14px;border-radius:10px;background:#121318;border:1px solid rgba(79,179,255,.45);font-size:18px;margin-bottom:2px",
},
h("div", { style: "color:#8f919d" }, icon("search", 18, 2.2)),
query.el,
),
...results,
);
// Header studio: three zones; a Docker shortcut drops into the right one.
const hIcon = (ic: string) =>
h(
"div",
{
class: "center",
style:
"width:38px;height:38px;border-radius:10px;background:rgba(255,255,255,.07);border:1px solid var(--line2);flex:none",
},
icon(ic, 20, 2.1),
);
const zone = (label: string, ...chips: HTMLElement[]) =>
h(
"div",
{ class: "col", style: "gap:8px" },
h("div", { class: "label", style: "font-size:11px;color:#ffd79a;letter-spacing:.18em" }, label),
h(
"div",
{
class: "row",
style:
"gap:6px;height:56px;padding:0 9px;border-radius:12px;border:1.5px dashed rgba(255,181,71,.4);background:rgba(255,181,71,.04)",
},
...chips,
),
);
const dockerChip = hIcon("brand-docker");
dockerChip.style.color = "#8fcfff";
const dockerSlot = h(
"div",
{ style: "width:0;height:38px;flex:none;position:relative" },
h("div", { class: "abs", style: "left:0;top:0" }, dockerChip),
);
const visHeader = h(
"div",
{ class: "row", style: "justify-content:space-between;align-items:flex-start" },
zone(
"Left",
h(
"div",
{
class: "row",
style:
"gap:8px;height:38px;padding:0 12px;border-radius:10px;background:rgba(255,255,255,.07);border:1px solid var(--line2);font-size:15px;font-weight:750",
},
icon("layout-dashboard", 17, 2.1),
"Homelab",
),
),
zone("Center", hIcon("layout-grid"), hIcon("search")),
zone("Right", dockerSlot, hIcon("moon"), hIcon("settings")),
);
// Branding: accent and corner style change on a live preview.
const SW = ["#fa5352", "#7c8cff", "#3ddc97", "#ffb547"];
const brandBtn = h(
"div",
{ class: "center", style: "height:40px;padding:0 22px;font-size:16px;font-weight:800;color:#fff" },
"Sign in",
);
const brandName = h(
"div",
{ class: "row", style: "gap:10px;font-size:18px;font-weight:800" },
h("div", { style: "width:26px;height:26px;border-radius:8px" }),
"Your Homelab",
);
const brandPrev = h(
"div",
{ class: "col", style: "width:250px;gap:12px;padding:16px 18px;background:#121318;border:1px solid var(--line2)" },
brandName,
brandBtn,
);
const swatches = SW.map((c) =>
h("div", {
style: `width:34px;height:34px;border-radius:50%;background:${c};border:3px solid transparent;box-sizing:content-box`,
}),
);
const visBrand = h(
"div",
{ class: "row", style: "gap:26px" },
brandPrev,
h(
"div",
{ class: "col", style: "gap:14px" },
h("div", { class: "row", style: "gap:10px" }, ...swatches),
h("div", { class: "mono", style: "font-size:14px;color:#8f919d" }, "global.css"),
),
);
// Widgets: the three new ones, ticking.
const cdEl = h("span", {}, "12d 04h");
const timerEl = h("span", {}, "05:00");
const mini = (ic: string, color: string, name: string, value: HTMLElement | string) =>
h(
"div",
{
class: "col",
style: "flex:1;gap:6px;padding:12px 14px;border-radius:12px;background:#121318;border:1px solid var(--line2)",
},
h(
"div",
{ class: "row", style: `gap:7px;font-size:16px;font-weight:750;color:${color};white-space:nowrap` },
icon(ic, 17, 2.2),
name,
),
h("div", { class: "display", style: "font-size:30px;white-space:nowrap" }, value),
h("div", { class: "mono", style: "font-size:11px;letter-spacing:.14em;color:#8ff0c4" }, "NEW"),
);
const visWidgets = h(
"div",
{ class: "row", style: "gap:10px" },
mini("wind", "#8fcfff", "Air Quality", "AQI 32"),
mini("hourglass", "#ffd79a", "Countdown", cdEl),
mini("stopwatch", "#ffb3ad", "Timer", timerEl),
);
const page1 = [
card("#fa5352", "rocket", "Brand-new onboarding", "A six-stage setup studio.", visOnb),
card(
"#7c8cff",
"layout-grid",
"Board switcher",
"A searchable gallery with keyboard navigation.",
visSwitch,
h("div", { class: "row", style: "gap:6px" }, kbd("Shift"), kbd("C")),
),
card(
"#4fb3ff",
"search",
"Command menu",
"Finds resources, pages, settings, users, groups and commands.",
visCmd,
h("div", { class: "row", style: "gap:6px" }, kbd("Ctrl"), kbd("K")),
),
card(
"#ffb547",
"layout-navbar",
"Customizable header",
"Board links and shortcuts, left, center or right, in any order.",
visHeader,
),
card(
"#3ddc97",
"palette",
"Instance branding",
"Name, logo, favicon, colors, corner styles and login page. Global CSS; board CSS can override it.",
visBrand,
),
card(
"#ff8f86",
"puzzle",
"Widgets",
"Weather and Clock redesigned. Air Quality, Countdown and Timer are new.",
visWidgets,
),
];
const P1W = 540;
const P1H = 348;
page1.forEach((c, i) => {
c.style.left = `${114 + (i % 3) * (P1W + 36)}px`;
c.style.top = `${170 + Math.floor(i / 3) * (P1H + 32)}px`;
c.style.width = `${P1W}px`;
c.style.height = `${P1H}px`;
});
// ---------- Page 2 ----------
const hostEl = (lg: string, name: string) =>
h(
"div",
{
class: "row",
style:
"gap:10px;padding:10px 14px;border-radius:12px;background:#121318;border:1px solid var(--line2);font-size:16px;font-weight:700",
},
logo(lg, 28),
name,
);
const creates = ["Apps", "Integrations", "Containers", "Widgets", "Health checks"].map((s) =>
h("div", { class: "chip", style: "font-size:15px;padding:7px 12px" }, s),
);
const visDocker = h(
"div",
{ class: "col", style: "gap:16px" },
h(
"div",
{ class: "row", style: "gap:12px" },
h(
"div",
{
class: "mono",
style:
"padding:10px 14px;border-radius:10px;background:rgba(79,179,255,.12);border:1px solid rgba(79,179,255,.45);color:#bfe3ff;font-size:17px;font-weight:700",
},
"DOCKER_ENDPOINTS",
),
h("div", { style: "color:#8f919d" }, icon("arrow-right", 22, 2.2)),
hostEl("docker", "Docker"),
hostEl("docker", "Docker"),
hostEl("podman", "Podman"),
),
h(
"div",
{ class: "row", style: "gap:8px;flex-wrap:wrap" },
h(
"div",
{ class: "mono", style: "font-size:14px;color:#8f919d;margin-right:4px;letter-spacing:.08em" },
"LABELS →",
),
...creates,
),
);
const roleChip = (name: string, color: string) =>
h(
"div",
{
class: "chip",
style: `font-size:17px;padding:8px 16px;color:${color};border-color:${color}66;background:${color}14`,
},
name,
);
const same = ["API", "Assistant", "MCP"].map((s) =>
h("div", { class: "chip mono", style: "font-size:16px;padding:7px 14px" }, s),
);
const visPerm = h(
"div",
{ class: "col", style: "gap:16px" },
h(
"div",
{ class: "row", style: "gap:10px" },
roleChip("Viewer", "#8fcfff"),
roleChip("Editor", "#ffd79a"),
roleChip("Admin", "#ffb3ad"),
h(
"div",
{ style: "margin-left:auto;display:flex;gap:8px" },
h("div", { class: "chip mono", style: "font-size:15px;padding:7px 12px" }, "LDAP"),
h("div", { class: "chip mono", style: "font-size:15px;padding:7px 12px" }, "OIDC"),
),
),
h(
"div",
{ class: "row", style: "gap:10px" },
h("div", { class: "mono", style: "font-size:14px;color:#8f919d;letter-spacing:.08em" }, "SAME RULES →"),
...same,
),
);
const PERF = [
"Board startup work runs in parallel",
"Heavy screens load when opened",
"Identical integration requests share work",
];
const perfBars = [0, 1, 2].map(() => h("div", { style: "height:100%;width:0;border-radius:4px;background:#ffb547" }));
const visPerf = h(
"div",
{ class: "row", style: "gap:26px;align-items:flex-start" },
h(
"div",
{ class: "col", style: "gap:12px;flex:1" },
...PERF.map((p) =>
h(
"div",
{ class: "row", style: "gap:10px;font-size:18px;font-weight:650" },
h("div", { style: "color:#ffb547" }, icon("check", 18, 2.8)),
p,
),
),
),
h(
"div",
{ class: "col", style: "gap:10px;width:170px;padding-top:6px" },
...perfBars.map((b) => h("div", { style: "height:10px;border-radius:4px;background:rgba(255,255,255,.07)" }, b)),
),
);
const mysql = h(
"div",
{ class: "chip mono", style: "font-size:16px;padding:8px 14px;color:#8f919d;text-decoration:line-through" },
"MySQL",
);
const visDb = h(
"div",
{ class: "col", style: "gap:16px" },
h(
"div",
{ class: "row", style: "gap:10px" },
h(
"div",
{
class: "chip",
style: "font-size:17px;padding:8px 16px;color:#c3caff;border-color:#7c8cff88;background:#7c8cff18",
},
"SQLite",
h("span", { class: "mono", style: "font-size:12px;letter-spacing:.1em;color:#8f96d8" }, "DEFAULT"),
),
h(
"div",
{
class: "chip",
style: "font-size:17px;padding:8px 16px;color:#c3caff;border-color:#7c8cff88;background:#7c8cff18",
},
"PostgreSQL",
),
),
h(
"div",
{ class: "row", style: "gap:10px" },
mysql,
h("div", { style: "color:#8f919d" }, icon("arrow-right", 20, 2.2)),
h("div", { class: "mono", style: "font-size:15px;color:#b9bbc6" }, "converter"),
h("div", { style: "color:#8f919d" }, icon("arrow-right", 20, 2.2)),
h("div", { class: "chip mono", style: "font-size:16px;padding:8px 14px" }, "SQLite"),
),
);
const page2 = [
card(
"#4fb3ff",
"brand-docker",
"Docker and Podman",
"Several hosts. Assisted setup and container labels create apps, integrations, Containers, widgets and health checks. Homepage-compatible labels work too.",
visDocker,
),
card(
"#fa5352",
"shield-lock",
"Permissions",
"Groups use a Viewer, Editor and Admin matrix. The API, Assistant and MCP follow the same rules.",
visPerm,
),
card("#ffb547", "bolt", "Performance", "Less waiting, less duplicated work.", visPerf),
card(
"#7c8cff",
"database",
"SQLite and PostgreSQL",
"MySQL support is dropped. MySQL users convert to SQLite before upgrading.",
visDb,
),
];
[visDocker, visPerm, visPerf, visDb].forEach((v) => (v.style.zoom = "1.18"));
const P2W = 834;
const P2H = 348;
page2.forEach((c, i) => {
c.style.left = `${108 + (i % 2) * (P2W + 36)}px`;
c.style.top = `${930 + Math.floor(i / 2) * (P2H + 32)}px`;
c.style.width = `${P2W}px`;
c.style.height = `${P2H}px`;
});
// All ten cards sit on one sheet that scrolls slowly under the chapter label.
const sheet = h("div", { class: "abs", style: "inset:0" }, ...page1, ...page2);
const topFade = h("div", {
class: "abs",
style: "left:0;right:0;top:0;height:160px;background:linear-gradient(180deg,#07070b 45%,rgba(7,7,11,0))",
});
fg.append(title, sheet, topFade, chapter.el);
// ---------- Timeline ----------
const P1 = 0.9;
// Every card lands at once; the sheet then scrolls the lower ones into view, where their demos start.
const P2 = P1 + 1.3;
const P3 = P1 + 2.3;
const END = 10 * BEAT;
const SCROLL = [P1 + 1.0, END - 0.1] as const;
const cues: Scene["cues"] = [
{ t: 0.05, kind: "stamp", gain: 0.5 },
{ t: P1, kind: "hit", gain: 0.5 },
{ t: P1 + 0.4, kind: "key", gain: 0.4 },
{ t: P1 + 0.5, kind: "key", gain: 0.4, pitch: 2 },
...STAGES.map((_, i) => ({ t: P1 + 0.45 + i * 0.22, kind: "pop" as const, gain: 0.3, pitch: i * 2 })),
{ t: P1 + 1.2, kind: "click", gain: 0.6 },
{ t: P2 + 0.45, kind: "pop", gain: 0.3, pitch: 4 },
{ t: P3 + 0.3, kind: "swish", gain: 0.4 },
];
return {
name: "rest",
start: 0,
end: END,
enter: { dir: "up", dur: 0.45 },
fg,
cues,
update(t, ctx) {
// Title
title.style.display = t < P1 + 0.1 ? "" : "none";
big.update(t, -0.25, P1 - 0.3, 0.03, "center");
bigSub.update(t, 0.05, P1 - 0.3, 0.04, 0.45);
title.style.transform = `scale(${(1 + seg(t, P1 - 0.35, P1 + 0.05) * 0.25).toFixed(3)})`;
chapter.update(t, P1 - 0.2);
topFade.style.opacity = String(seg(t, P1, P1 + 0.3));
// Cards
const enter = (el: HTMLElement, at: number) => {
const p = spring(t - at, 2.2, 0.6);
el.style.transform = `perspective(1800px) translateY(${((1 - clamp(p, 0, 1.15)) * 140).toFixed(1)}px) rotateX(${((1 - clamp(p)) * 38).toFixed(2)}deg)`;
el.style.opacity = t >= at ? "1" : "0";
el.style.display = t > at - 0.05 ? "" : "none";
};
[...page1, ...page2].forEach((c, i) => enter(c, P1 + i * 0.025));
sheet.style.transform = `translateY(${(-628 * E.inOutSine(seg(t, SCROLL[0], SCROLL[1]))).toFixed(1)}px)`;
// Page 1 micro-animations
stageEls.forEach((s, i) => {
const at = P1 + 0.45 + i * 0.22;
const d = E.outBack(seg(t, at, at + 0.22), 2);
s.done.style.transform = `scale(${clamp(d, 0, 1.3).toFixed(3)})`;
s.done.style.opacity = t >= at ? "1" : "0";
});
const focus = Math.min(3, Math.floor(Math.max(0, t - P1 - 0.5) / 0.5));
thumbs.forEach((th, i) => {
th.style.borderColor = i === focus && t > P1 + 0.35 ? "#7c8cff" : "transparent";
th.style.background = i === focus && t > P1 + 0.35 ? "rgba(124,140,255,.12)" : "";
});
query.update(t, P1 + 0.4, 10, P2);
results.forEach((r, i) => {
const at = P1 + 0.6 + i * 0.08;
const p = E.outExpo(seg(t, at, at + 0.35));
tf(r, { y: (1 - p) * 10, o: p });
const sel = Math.min(2, Math.floor(Math.max(0, t - P1 - 1.1) / 0.5));
r.style.background = t > P1 + 1.0 && i === sel ? "rgba(79,179,255,.14)" : "";
});
{
// Docker shortcut drops into the Right zone; the others make room.
const room = E.inOutCubic(seg(t, P1 + 0.7, P1 + 1.0));
dockerSlot.style.width = `${(room * 38).toFixed(1)}px`;
dockerSlot.style.marginRight = `${(room * 6 - 6).toFixed(1)}px`;
const p = E.outBack(seg(t, P1 + 0.8, P1 + 1.2), 1.6);
tf(dockerChip, { y: lerp(-60, 0, clamp(p, 0, 1.2)), o: t > P1 + 0.8 ? 1 : 0 });
const glow = t > P1 + 1.2 ? Math.exp(-(t - P1 - 1.2) * 4) : 0;
dockerChip.style.boxShadow = `0 0 ${(glow * 24).toFixed(0)}px rgba(79,179,255,${(glow * 0.9).toFixed(2)})`;
}
const sw = Math.floor(Math.max(0, t - P1 - 0.5) / 0.5) % SW.length;
const accent = t > P1 + 0.5 ? SW[sw]! : SW[0]!;
brandBtn.style.background = accent;
(brandName.firstElementChild as HTMLElement).style.background = accent;
const rad = lerp(4, 18, (Math.sin((t - P1) * 2.2) + 1) / 2);
brandPrev.style.borderRadius = `${rad.toFixed(1)}px`;
brandBtn.style.borderRadius = `${(rad * 0.7).toFixed(1)}px`;
swatches.forEach((s, i) => (s.style.borderColor = i === sw && t > P1 + 0.5 ? "#fff" : "transparent"));
{
const secs = Math.max(0, Math.floor((t - P1 - 0.5) * 2));
const rem = Math.max(0, 300 - secs);
timerEl.textContent = `${String(Math.floor(rem / 60)).padStart(2, "0")}:${String(rem % 60).padStart(2, "0")}`;
cdEl.textContent = "12d 04h";
}
// Page 2 micro-animations
creates.forEach((c, i) => {
const at = P2 + 0.45 + i * 0.12;
const p = E.outBack(seg(t, at, at + 0.25), 2);
tf(c, { s: lerp(0.7, 1, clamp(p, 0, 1.3)), o: clamp(p * 1.5) });
c.style.borderColor = t > at ? "rgba(79,179,255,.6)" : "";
c.style.background = t > at ? "rgba(79,179,255,.12)" : "";
});
same.forEach((c, i) => {
const at = P2 + 0.6 + i * 0.14;
const p = E.outBack(seg(t, at, at + 0.25), 2);
tf(c, { s: lerp(0.7, 1, clamp(p, 0, 1.3)), o: clamp(p * 1.5) });
});
perfBars.forEach((b, i) => {
const p = E.outCubic(seg(t, P3 + 0.3, P3 + 1.1 + i * 0.2));
b.style.width = `${(p * 100).toFixed(1)}%`;
});
mysql.style.opacity = String(lerp(1, 0.55, seg(t, P3 + 0.5, P3 + 0.9)));
},
};
}
+319
View File
@@ -0,0 +1,319 @@
import { E, seg, lerp, spring, clamp } from "../lib/anim";
import { h, icon, logo, tf } from "../lib/dom";
import { Headline, countTo } from "../lib/kit";
import type { Scene } from "../lib/scene";
import ALL from "../../assets/integrations-all.json";
const MEDIA: [string, string][] = [
["autobrr", "Autobrr"],
["fileflows", "FileFlows"],
["jackett", "Jackett"],
["jellystat", "Jellystat"],
["komga", "Komga"],
["maintainerr", "Maintainerr"],
["romm", "RomM"],
["stash", "Stash"],
["tubearchivist", "Tube Archivist"],
["unmanic", "Unmanic"],
["xteve", "xTeVe"],
["yourSpotify", "Your Spotify"],
];
const MONITORING: [string, string][] = [
["caddy", "Caddy"],
["changedetection", "Changedetection.io"],
["frigate", "Frigate"],
["gatus", "Gatus"],
["healthchecks", "Healthchecks"],
["netalertx", "NetAlertX"],
["netdata", "Netdata"],
["prometheus", "Prometheus"],
["scrutiny", "Scrutiny"],
["syncthingRelay", "Syncthing Relay"],
];
const COLLECTIONS: [string, string][] = [
["homebox", "Homebox"],
["karakeep", "Karakeep"],
["linkwarden", "Linkwarden"],
["mealie", "Mealie"],
["miniflux", "Miniflux"],
["plantit", "Plant-it"],
["spoolman", "Spoolman"],
["tandoor", "Tandoor"],
["trilium", "Trilium"],
];
// Grid of the 31 new integrations, which lift off into a globe of every integration kind (new ones in red); the
// globe then collapses into the spot where the end card's lobster forms.
const COLS = 7;
const TILE = 104;
const TGAP = 18;
const GRID = { x: 872, y: 262 };
const LOBSTER = { x: 960, y: 440 };
const R = 330;
const CX = 960;
const CY = 560;
const FOCAL = 1400;
export function stats(): Scene {
const fg = h("div", { class: "scene" });
const statHead = new Headline("Statistics and 31 new integrations.", { size: 66, accent: ["31"] });
const statHeadWrap = h("div", { class: "abs", style: "left:96px;top:140px;white-space:nowrap" }, statHead.el);
const METRICS: [string, string, string, number][] = [
["sonarr", "Sonarr", "Series", 214],
["paperless-ngx", "Paperless-ngx", "Documents", 3481],
["navidrome", "Navidrome", "Songs", 12904],
["homebox", "Homebox", "Items", 318],
];
const metricVals: HTMLElement[] = [];
const metricCards = METRICS.map(([k, name, label]) => {
const v = h("div", { class: "display", style: "font-size:52px" }, "0");
metricVals.push(v);
return h(
"div",
{
class: "col",
style: "gap:8px;padding:18px 20px;border-radius:14px;background:#121318;border:1px solid var(--line2)",
},
h("div", { class: "row", style: "gap:10px;font-size:16px;font-weight:700;color:#b9bbc6" }, logo(k, 26), name),
v,
h("div", { class: "mono", style: "font-size:13px;letter-spacing:.14em;color:#8f919d" }, label.toUpperCase()),
);
});
const statsCard = h(
"div",
{ class: "abs card col", style: "left:96px;top:270px;width:640px;padding:24px;gap:18px" },
h(
"div",
{ class: "row", style: "gap:12px;font-size:22px;font-weight:800" },
h("div", { style: "color:#fa5352" }, icon("chart-bar", 24, 2.2)),
"Statistics",
h("div", { class: "chip", style: "margin-left:auto;font-size:14px;padding:6px 12px" }, "Cards"),
),
h("div", { style: "display:grid;grid-template-columns:1fr 1fr;gap:14px" }, ...metricCards),
);
const statCap = h(
"div",
{ class: "abs", style: "left:96px;top:760px;width:640px;font-size:24px;line-height:1.4;color:#b9bbc6" },
"Fields from different services, in one grid.",
);
const NEW = [...MEDIA, ...MONITORING, ...COLLECTIONS];
const tiles = NEW.map(([k], i) => {
const x = GRID.x + (i % COLS) * (TILE + TGAP);
const y = GRID.y + Math.floor(i / COLS) * (TILE + TGAP);
const el = h(
"div",
{
class: "abs center",
style: `left:${x}px;top:${y}px;width:${TILE}px;height:${TILE}px;border-radius:24px;background:linear-gradient(180deg,#1c1d23,#15161b);border:1px solid rgba(255,255,255,.1);box-shadow:0 14px 30px rgba(0,0,0,.35)`,
},
logo(k, 60),
);
return { el, cx: x + TILE / 2, cy: y + TILE / 2 };
});
const counter = h("span", {}, "0");
const counterEl = h(
"div",
{
class: "abs row",
style: `left:${GRID.x}px;top:${GRID.y + 5 * (TILE + TGAP) + 14}px;gap:16px;font-size:26px;font-weight:700;color:#b9bbc6`,
},
h("div", { class: "display", style: "font-size:72px;color:#fff;min-width:86px" }, counter),
"new integrations in v2",
);
// ---------- Globe ----------
const newKeys = new Set(NEW.map(([k]) => k));
// New integrations first so they map to tile indices 0..30.
const kinds = [...NEW.map(([k]) => k), ...Object.keys(ALL).filter((k) => !newKeys.has(k))];
const golden = Math.PI * (3 - Math.sqrt(5));
// Spread the new ones evenly over the sphere instead of clustering them at one pole.
const order = kinds.map((_, i) => (i * 37) % kinds.length);
const chips = kinds.map((k, i) => {
const n = order[i]!;
const y = 1 - ((n + 0.5) / kinds.length) * 2;
const r = Math.sqrt(1 - y * y);
const a = n * golden;
const isNew = newKeys.has(k);
const bgEl = h("div", {
class: "abs",
style: `inset:0;border-radius:50%;background:${isNew ? "radial-gradient(circle at 50% 35%,#3a1d20,#1a1013)" : "#1e1f26"};border:${isNew ? "2px solid rgba(250,83,82,.9)" : "1.5px solid rgba(255,255,255,.22)"};${isNew ? "box-shadow:0 0 22px rgba(250,83,82,.55)" : ""}`,
});
const file = (ALL as Record<string, { file: string }>)[k]?.file;
const img = isNew
? logo(k, 33)
: h("img", { class: "svc", src: `assets/icons/${file}`, width: 33, height: 33, alt: "" });
img.style.position = "relative";
const el = h("div", { class: "abs center", style: "left:0;top:0;width:56px;height:56px" }, bgEl, img);
return { el, bgEl, isNew, p: [Math.cos(a) * r, y, Math.sin(a) * r] as [number, number, number] };
});
const glow = h("div", {
class: "abs",
style: `left:${CX - 520}px;top:${CY - 520}px;width:1040px;height:1040px;border-radius:50%;background:radial-gradient(circle,rgba(250,83,82,.18),rgba(250,83,82,.05) 45%,transparent 68%)`,
});
const shell = h("div", {
class: "abs",
style: `left:${CX - R}px;top:${CY - R}px;width:${2 * R}px;height:${2 * R}px;border-radius:50%;border:1px solid rgba(255,255,255,.08);background:radial-gradient(circle at 40% 35%,rgba(255,255,255,.04),transparent 60%)`,
});
const globeLayer = h("div", { class: "abs", style: "inset:0" }, glow, shell, ...chips.map((c) => c.el));
const globeHead = new Headline("Every integration in Homarr 2.0.", { size: 56, accent: ["every"] });
const globeHeadWrap = h(
"div",
{ class: "abs", style: "left:0;right:0;top:92px;text-align:center;white-space:nowrap" },
globeHead.el,
);
const legendItem = (bg: string, border: string, label: string) =>
h(
"div",
{ class: "row", style: "gap:12px;font-size:22px;font-weight:650;color:#d7d8de" },
h("div", { style: `width:22px;height:22px;border-radius:50%;background:${bg};border:${border}` }),
label,
);
const legend = h(
"div",
{ class: "abs row", style: "left:0;right:0;top:960px;justify-content:center;gap:48px" },
legendItem("#3a1d20", "2px solid #fa5352", "New in 2.0"),
legendItem("#1e1f26", "1.5px solid rgba(255,255,255,.3)", "Already supported"),
);
const core = h("div", {
class: "abs",
style: `left:${LOBSTER.x}px;top:${LOBSTER.y}px;width:10px;height:10px;margin:-5px 0 0 -5px;border-radius:50%;background:#fff;box-shadow:0 0 60px 30px rgba(250,83,82,.8)`,
});
fg.append(
statHeadWrap,
statsCard,
statCap,
...tiles.map((t) => t.el),
counterEl,
globeLayer,
globeHeadWrap,
legend,
core,
);
const GRID_IN = 0.35;
const tileAt = (i: number) => GRID_IN + i * 0.028;
const GL = 3.4; // the grid lifts off into the globe
const CONV = GL + 4.0; // the globe collapses into the end card
const END = CONV + 0.85;
const cues: Scene["cues"] = [
{ t: 0.25, kind: "hit", gain: 0.5 },
...[0, 1, 2, 3, 4].map((r) => ({ t: tileAt(r * COLS), kind: "pop" as const, gain: 0.35, pitch: r * 2 })),
{ t: GL - 0.1, kind: "whoosh", gain: 0.8 },
{ t: GL + 0.75, kind: "hit", gain: 0.6 },
...chips
.filter((c) => !c.isNew)
.map((_, j) => ({ t: GL + 0.45 + j * 0.012, kind: "tick" as const, gain: 0.1, pitch: j % 8 })),
{ t: CONV - 0.9, kind: "riser", dur: 1.0, gain: 0.6 },
{ t: CONV, kind: "swish", gain: 0.6 },
{ t: CONV + 0.1, kind: "reverse", gain: 0.6 },
];
return {
name: "stats",
start: 0,
end: END,
enter: { dir: "left", dur: 0.45 },
fg,
cues,
update(t, ctx) {
const out = E.inCubic(seg(t, GL - 0.25, GL + 0.2));
const wallOn = t < GL + 0.9;
[statHeadWrap, statsCard, statCap, counterEl, ...tiles.map((x) => x.el)].forEach(
(el) => (el.style.display = wallOn ? "" : "none"),
);
statHead.update(t, -0.25, GL - 0.55, 0.03, 0.35);
const stIn = spring(t + 0.25, 2.4, 0.6);
tf(statsCard, { y: (1 - clamp(stIn, 0, 1.15)) * 120 + out * 60, rx: (1 - clamp(stIn)) * 30, o: 1 - out });
METRICS.forEach(([, , , v], i) =>
countTo(metricVals[i]!, t, 0.3 + i * 0.1, 1.3 + i * 0.1, v, 0, (x) => Math.round(x).toLocaleString("en-US")),
);
statCap.style.clipPath = `inset(-10px ${((1 - E.outExpo(seg(t, 0.8, 1.3))) * 100).toFixed(1)}% -10px 0)`;
statCap.style.opacity = String(1 - out);
countTo(counter, t, GRID_IN, tileAt(30) + 0.2, 31);
tf(counterEl, {
y: (1 - E.outExpo(seg(t, GRID_IN, GRID_IN + 0.5))) * 20,
o: seg(t, GRID_IN, GRID_IN + 0.15) * (1 - out),
});
// Tiles pop in and float; each hands over to its globe chip when the grid lifts off.
const liftAt = (i: number) => GL - 0.1 + i * 0.006;
tiles.forEach((tl, i) => {
const at = tileAt(i);
const p = clamp(spring(t - at, 2.6, 0.5), 0, 1.25);
tf(tl.el, {
x: Math.sin(t * 1.3 + i) * 3,
y: Math.cos(t * 1.1 + i * 0.7) * 3,
s: p,
o: t >= at && t < liftAt(i) ? 1 : 0,
});
});
// Globe: rotate, tilt and project every chip.
const gOn = t > GL - 0.15 && t < END;
globeLayer.style.display = globeHeadWrap.style.display = legend.style.display = gOn ? "" : "none";
if (gOn) {
const conv = E.inQuad(seg(t, CONV, END - 0.05));
const spin = (t - GL) * 0.55 + E.inQuad(seg(t, CONV, END)) * 5;
const tilt = -0.32 + Math.sin((t - GL) * 0.6) * 0.06;
const grow = lerp(0.92, 1.06, E.inOutSine(seg(t, GL + 0.5, CONV)));
const rad = R * grow * (1 - conv);
const ccx = lerp(CX, LOBSTER.x, conv);
const ccy = lerp(CY, LOBSTER.y, conv);
const cs = Math.cos(spin);
const sn = Math.sin(spin);
const ct = Math.cos(tilt);
const st = Math.sin(tilt);
chips.forEach((c, i) => {
const [x0, y0, z0] = c.p;
const x1 = x0 * cs + z0 * sn;
const z1 = -x0 * sn + z0 * cs;
const y2 = y0 * ct - z1 * st;
const z2 = y0 * st + z1 * ct;
const persp = FOCAL / (FOCAL - z2 * rad);
const gx = ccx + x1 * rad * persp;
const gy = ccy + y2 * rad * persp;
const depth = (z2 + 1) / 2; // 0 back → 1 front
let x = gx;
let y = gy;
let s = persp * lerp(0.62, 1.05, depth);
let o = lerp(0.28, 1, depth);
let bgO = 1;
if (c.isNew) {
// Fly from the grid tile to the globe spot.
const fp = E.inOutQuart(seg(t, liftAt(i), liftAt(i) + 0.7));
const tl = tiles[i]!;
x = lerp(tl.cx, gx, fp);
y = lerp(tl.cy, gy, fp) - Math.sin(fp * Math.PI) * 60;
s = lerp(60 / 33, s * 1.1, fp);
o = t < liftAt(i) ? 0 : lerp(1, Math.max(o, 0.55), fp);
bgO = fp;
} else {
const at = GL + 0.45 + (i - 31) * 0.012;
const pp = spring(t - at, 3, 0.5);
s *= clamp(pp, 0, 1.3);
o *= t >= at ? 1 : 0;
}
o *= 1 - seg(conv, 0.9, 1);
tf(c.el, { x: x - 28, y: y - 28, s, o });
c.bgEl.style.opacity = bgO.toFixed(3);
c.el.style.zIndex = String(Math.round(depth * 100) + (c.isNew ? 2 : 0));
c.el.style.filter = depth < 0.35 ? `blur(${((0.35 - depth) * 5).toFixed(1)}px)` : "";
});
const shellIn = E.outExpo(seg(t, GL + 0.3, GL + 1.0));
tf(shell, { x: ccx - CX, y: ccy - CY, s: lerp(0.6, 1, shellIn) * grow * (1 - conv), o: shellIn * (1 - conv) });
tf(glow, { x: ccx - CX, y: ccy - CY, s: grow * (1 + conv * 0.3), o: shellIn * (1 - seg(conv, 0.6, 1)) });
globeHead.update(t, GL + 0.55, CONV - 0.35, 0.04, 0.5);
const lg = E.outExpo(seg(t, GL + 1.1, GL + 1.5));
legend.style.clipPath = `inset(-10px ${((1 - lg) * 50).toFixed(1)}% -10px ${((1 - lg) * 50).toFixed(1)}%)`;
legend.style.opacity = String(1 - seg(t, CONV - 0.3, CONV));
ctx.fx.ca = conv * 5;
ctx.fx.zoom = 1 + conv * 0.08;
}
const coreP = seg(t, CONV + 0.25, END);
core.style.display = coreP > 0 ? "" : "none";
core.style.transform = `scale(${(0.2 + coreP ** 3 * 5).toFixed(3)})`;
ctx.fx.flash = seg(t, END - 0.12, END) * 0.9;
},
};
}
+497
View File
@@ -0,0 +1,497 @@
import { E, seg, lerp, clamp, spring, BEAT } from "../lib/anim";
import { h, tf, icon, logo } from "../lib/dom";
import { Chapter, Headline } from "../lib/kit";
import type { Scene } from "../lib/scene";
// Workshop: the catalog opens around the widget published in the previous scene, then a Custom CSS submission gets
// installed and restyles the whole catalog.
type Theme = "base" | "glass";
type Item = {
title: string;
by: string;
hue: number;
kind: "queue" | "poke" | "rows" | "bars" | "css";
uses?: string[];
votes: number;
fresh?: boolean;
};
const ITEMS: Item[] = [
{ title: "Sonarr queue", by: "you", hue: 212, kind: "queue", uses: ["sonarr"], votes: 0, fresh: true },
{ title: "Pokédex", by: "ajnart", hue: 350, kind: "poke", votes: 412 },
{ title: "Pi-hole stats", by: "community", hue: 0, kind: "bars", uses: ["piHole"], votes: 188 },
{ title: "Jellyfin sessions", by: "community", hue: 280, kind: "rows", uses: ["jellyfin"], votes: 256 },
{ title: "Proxmox nodes", by: "community", hue: 28, kind: "bars", uses: ["proxmox"], votes: 143 },
{ title: "Midnight Glass", by: "community", hue: 258, kind: "css", votes: 331 },
{ title: "Immich memories", by: "community", hue: 45, kind: "rows", uses: ["immich"], votes: 97 },
{ title: "Nord", by: "community", hue: 205, kind: "css", votes: 274 },
{ title: "Frigate events", by: "community", hue: 190, kind: "bars", uses: ["frigate"], votes: 165 },
{ title: "Home Assistant scenes", by: "community", hue: 195, kind: "rows", uses: ["homeAssistant"], votes: 210 },
{ title: "Plex now playing", by: "community", hue: 38, kind: "rows", uses: ["plex"], votes: 127 },
{ title: "Release calendar", by: "community", hue: 150, kind: "bars", uses: ["sonarr", "radarr"], votes: 301 },
];
const CSS_ITEM = 5;
const W = 290;
const H = 244;
const GAP = 18;
const PAD = 22;
const HEAD = 86;
const PANEL = { x: 890, y: 100, w: 3 * W + 2 * GAP + 2 * PAD, h: 880 };
const QUEUE = ["#3b82f6", "#f59e0b", "#10b981", "#ef4444"];
function thumb(item: Item, g: boolean) {
const el = h("div", {
class: "abs",
style: `left:10px;top:10px;width:${W - 20}px;height:112px;border-radius:${g ? 18 : 10}px;overflow:hidden;background:linear-gradient(150deg,hsl(${item.hue} 55% 22%),hsl(${item.hue + 30} 50% 10%))`,
});
if (item.kind === "queue")
QUEUE.forEach((c, i) =>
el.append(
h("div", {
class: "abs",
style: `left:16px;top:${12 + i * 24}px;width:14px;height:18px;border-radius:3px;background:${c}`,
}),
h("div", {
class: "abs",
style: `left:42px;top:${19 + i * 24}px;width:200px;height:5px;border-radius:3px;background:rgba(255,255,255,.12)`,
}),
h("div", {
class: "abs",
style: `left:42px;top:${19 + i * 24}px;width:${[172, 122, 74, 28][i]}px;height:5px;border-radius:3px;background:#fa5352`,
}),
),
);
else if (item.kind === "poke")
el.append(
h("div", {
class: "abs",
style:
"left:93px;top:14px;width:84px;height:84px;border-radius:50%;background:linear-gradient(180deg,#fa5352 0 46%,#222 46% 54%,#eee 54%);box-shadow:0 0 0 5px #222 inset",
}),
h("div", {
class: "abs",
style: "left:124px;top:45px;width:22px;height:22px;border-radius:50%;background:#eee;border:5px solid #222",
}),
);
else if (item.kind === "css") {
const nord = item.title === "Nord";
el.append(
h(
"div",
{
class: "abs mono",
style: `left:14px;top:14px;font-size:13px;line-height:22px;color:hsl(${item.hue} 90% 80%)`,
},
".mantine-Card-root {",
),
h(
"div",
{ class: "abs mono", style: "left:30px;top:36px;font-size:13px;line-height:22px;color:#fff;opacity:.75" },
nord ? "background: #3b4252;" : "border-radius: 26px;",
),
h(
"div",
{ class: "abs mono", style: "left:30px;top:58px;font-size:13px;line-height:22px;color:#fff;opacity:.75" },
nord ? "color: #eceff4;" : "backdrop-filter: blur(16px);",
),
h(
"div",
{
class: "abs mono",
style: `left:14px;top:80px;font-size:13px;line-height:22px;color:hsl(${item.hue} 90% 80%)`,
},
"}",
),
);
} else if (item.kind === "bars")
for (let b = 0; b < 9; b++)
el.append(
h("div", {
class: "abs",
style: `left:${18 + b * 27}px;bottom:14px;width:17px;height:${22 + ((b * 37 + item.hue) % 64)}px;border-radius:${g ? 6 : 3}px;background:${b % 3 ? "rgba(255,255,255,.22)" : g ? "#b9a8ff" : "#fa5352"}`,
}),
);
else
for (let r = 0; r < 3; r++)
el.append(
h("div", {
class: "abs",
style: `left:16px;top:${16 + r * 30}px;width:22px;height:22px;border-radius:${g ? 8 : 6}px;background:rgba(255,255,255,.2)`,
}),
h("div", {
class: "abs",
style: `left:48px;top:${22 + r * 30}px;width:${160 - r * 34}px;height:9px;border-radius:5px;background:hsla(${item.hue} 80% 75% / .45)`,
}),
);
return el;
}
/** A Workshop catalog card; `g` renders it with the Midnight Glass Custom CSS. */
function card(item: Item, g: boolean) {
const vote = h("span", { class: "tnum" }, String(item.votes));
const comments = h("span", { class: "tnum" }, "0");
const btn = h(
"div",
{
class: "abs center",
style: `right:12px;bottom:12px;width:104px;height:36px;border-radius:${g ? 18 : 9}px;background:${g ? "#8b7bff" : "#fa5352"};font-size:15px;font-weight:750;overflow:hidden`,
},
"Install",
);
const installed = h(
"div",
{ class: "abs row center", style: "inset:0;gap:5px;background:#2f9e6b;opacity:0" },
icon("check", 16, 3),
"Installed",
);
btn.append(installed);
const badge =
item.kind === "css"
? h(
"span",
{
class: "mono",
style: `padding:5px 10px;border-radius:${g ? 12 : 6}px;background:${g ? "rgba(185,168,255,.2)" : "rgba(124,140,255,.2)"};color:#c3caff;font-size:12px;font-weight:700;letter-spacing:.08em`,
},
"CUSTOM CSS",
)
: h(
"span",
{ class: "row", style: "gap:6px" },
item.uses
? h(
"span",
{ style: `font-size:13px;font-weight:600;margin-right:2px;color:${g ? "#a99fd6" : "var(--muted)"}` },
"Works with",
)
: null,
...(item.uses ?? []).map((u) =>
h(
"span",
{
class: "center",
style: `width:30px;height:30px;border-radius:${g ? 11 : 7}px;background:${g ? "rgba(255,255,255,.12)" : "#2a2b31"}`,
},
logo(u, 20),
),
),
item.uses
? null
: h("span", { class: "mono", style: "font-size:12px;color:var(--muted);letter-spacing:.1em" }, "API"),
);
const el = h(
"div",
{
class: "abs",
style: `width:${W}px;height:${H}px;border-radius:${g ? 26 : 14}px;overflow:hidden;${
g
? "background:rgba(255,255,255,.08);border:1px solid rgba(255,255,255,.22);box-shadow:inset 0 1px 0 rgba(255,255,255,.2),0 20px 40px rgba(10,6,40,.45)"
: "background:#1d1e23;border:1px solid rgba(255,255,255,.08);box-shadow:0 18px 36px rgba(0,0,0,.4)"
}`,
},
thumb(item, g),
h(
"div",
{
class: "abs",
style: `left:16px;top:134px;width:170px;font-size:18px;font-weight:750;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;${g ? "color:#f1edff" : ""}`,
},
item.title,
),
h(
"div",
{ class: "abs", style: `left:16px;top:160px;font-size:14px;color:${g ? "#a99fd6" : "var(--muted)"}` },
`by ${item.by}`,
),
h(
"div",
{ class: "abs row", style: `right:14px;top:137px;gap:10px;font-size:14px;color:${g ? "#d9d2ff" : "#cfcfd6"}` },
h("span", { class: "row", style: "gap:4px" }, icon("arrow-big-up", 16, 2), vote),
h("span", { class: "row", style: "gap:4px" }, icon("message-circle", 15, 2), comments),
),
h("div", { class: "abs row", style: "left:16px;bottom:15px" }, badge),
btn,
);
if (item.fresh) {
el.style.border = `2px solid ${g ? "rgba(185,168,255,.8)" : "rgba(250,83,82,.8)"}`;
el.append(
h(
"div",
{
class: "abs mono",
style: `left:12px;top:12px;padding:4px 9px;border-radius:${g ? 10 : 6}px;background:${g ? "#8b7bff" : "#fa5352"};font-size:12px;font-weight:800;letter-spacing:.1em`,
},
"NEW",
),
);
}
return { el, vote, comments, btn, installed };
}
function panel(theme: Theme) {
const g = theme === "glass";
const cards = ITEMS.map((it, i) => {
const c = card(it, g);
c.el.style.left = `${PAD + (i % 3) * (W + GAP)}px`;
c.el.style.top = `${Math.floor(i / 3) * (H + GAP)}px`;
return c;
});
const grid = h("div", { class: "abs", style: "left:0;top:0;right:0" }, ...cards.map((c) => c.el));
const tab = (label: string, on: boolean) =>
h(
"div",
{
style: `padding:8px 16px;border-radius:${g ? 16 : 8}px;font-size:16px;font-weight:650;${
on
? g
? "background:rgba(185,168,255,.22);color:#e6e0ff"
: "background:rgba(250,83,82,.16);color:#ff8f86"
: `color:${g ? "#a99fd6" : "var(--muted)"}`
}`,
},
label,
);
const el = h(
"div",
{
class: "abs",
style: `left:${PANEL.x}px;top:${PANEL.y}px;width:${PANEL.w}px;height:${PANEL.h}px;border-radius:${g ? 34 : 20}px;overflow:hidden;${
g
? "background:radial-gradient(120% 90% at 20% 0%,#3b2a7a,#12102a 60%,#0a0a18);border:1px solid rgba(255,255,255,.2)"
: "background:#141418;border:1px solid rgba(255,255,255,.08)"
};box-shadow:0 50px 100px -20px rgba(0,0,0,.7)`,
},
h(
"div",
{
class: "abs row",
style: `left:${PAD}px;right:${PAD}px;top:18px;height:48px;gap:12px;font-weight:800;font-size:22px;${g ? "color:#e6e0ff" : ""}`,
},
h(
"div",
{
class: "center",
style: `width:34px;height:34px;border-radius:${g ? 12 : 8}px;background:${g ? "#8b7bff" : "#fa5352"}`,
},
icon("building-store", 20, 2.2),
),
"Workshop",
h(
"div",
{ class: "row", style: "gap:4px;margin-left:18px" },
tab("Widgets", true),
tab("Custom CSS", false),
tab("Installed", false),
),
h(
"div",
{
class: "row",
style: `margin-left:auto;gap:8px;width:190px;height:38px;padding:0 12px;border-radius:${g ? 19 : 9}px;background:${g ? "rgba(255,255,255,.1)" : "#1f2025"};font-size:15px;font-weight:500;color:${g ? "#a99fd6" : "var(--muted)"}`,
},
icon("search", 17, 2),
"Search",
),
),
h("div", { class: "abs", style: `left:0;right:0;top:${HEAD}px;bottom:0;overflow:hidden` }, grid),
);
return { el, grid, cards };
}
/** Screen rect of the published widget's catalog slot (inside the panel's 1px border). */
export const SLOT = { x: PANEL.x + 1 + PAD, y: PANEL.y + 1 + HEAD, w: W, h: H };
export const WORKSHOP_BG =
"radial-gradient(ellipse 55% 50% at 14% 12%,rgba(250,82,82,.16),rgba(250,82,82,0) 62%),#0b0b0f";
/**
* The published widget as a Workshop card, for Custom Widgets to morph into. It ends the scene alone in its slot and
* shadowless, matching the first Workshop frame, where the catalog is still clipped to that card.
*/
export function publishedCard() {
const c = card(ITEMS[0]!, false);
c.el.style.left = `${SLOT.x}px`;
c.el.style.top = `${SLOT.y}px`;
c.el.style.boxShadow = "none";
c.el.style.transformOrigin = "0 0";
return c.el;
}
export function workshop(): Scene {
const bg = h("div", { class: "scene", style: `background:${WORKSHOP_BG}` });
// The Custom CSS restyle spills past the catalog into the background.
const bgGlass = h("div", {
class: "abs",
style:
"inset:0;background:radial-gradient(ellipse 70% 60% at 70% 20%,rgba(139,123,255,.3),rgba(139,123,255,0) 70%),#0d0b1c",
});
bg.append(bgGlass);
const fg = h("div", { class: "scene" });
const A = panel("base");
const B = panel("glass");
const both = [A, B];
const cursor = h(
"div",
{
class: "abs",
style: "left:0;top:0;width:40px;height:40px;color:#fff;filter:drop-shadow(0 4px 8px rgba(0,0,0,.6))",
},
icon("filled:pointer", 40, 1),
);
const chapter = new Chapter("02", "Workshop");
const h1 = new Headline("Share it in the", { size: 96, weight: 830 });
const h2 = new Headline("Workshop.", { size: 96, weight: 830, color: "var(--coral)" });
const head = h(
"div",
{ class: "abs col", style: "left:100px;top:150px;line-height:1.08;white-space:nowrap" },
h1.el,
h2.el,
);
const desc = new Headline("Publish and install community submissions.", { size: 30, weight: 500, color: "#b5b5bf" });
const descWrap = h("div", { class: "abs", style: "left:104px;top:392px;white-space:nowrap" }, desc.el);
const chips = (
[
["puzzle", "Custom Widgets"],
["palette", "Custom CSS"],
["refresh", "Updates"],
["arrow-big-up", "Votes"],
["message-circle", "Comments"],
] as const
).map(([ic, label]) =>
h(
"div",
{
class: "chip",
style: "font-size:19px;padding:9px 17px;color:#dcdce2;border-color:rgba(255,255,255,.2);gap:9px",
},
h("span", { style: "color:#ff8787;display:inline-flex" }, icon(ic, 20, 2)),
label,
),
);
const chipBox = h(
"div",
{ class: "abs row", style: "left:104px;top:458px;width:700px;flex-wrap:wrap;gap:12px" },
...chips,
);
const usesLabel = h(
"div",
{
class: "abs row",
style:
"left:104px;top:600px;width:700px;gap:14px;align-items:flex-start;font-size:26px;line-height:1.35;font-weight:600;color:#dcdce2",
},
h("span", { style: "color:#ff8787;display:inline-flex;margin-top:3px" }, icon("plug-connected", 28, 2)),
h("span", {}, "Custom widgets can leverage your integrations, so you don't have to retype your credentials."),
);
const privacy = h(
"div",
{
class: "abs row",
style: "left:104px;top:740px;gap:12px;font-size:22px;font-weight:550;color:#9a9ca8;white-space:nowrap",
},
h("span", { style: "color:var(--mint);display:inline-flex" }, icon("lock", 22, 2)),
"Deployment URLs and credentials stay on your Homarr instance.",
);
const applied = h(
"div",
{
class: "abs row",
style:
"left:104px;top:824px;gap:12px;padding:12px 20px;border-radius:16px;background:rgba(139,123,255,.16);border:1px solid rgba(185,168,255,.4);font-size:21px;font-weight:650;color:#e6e0ff;white-space:nowrap",
},
icon("palette", 22, 2),
"Custom CSS installed: Midnight Glass",
);
fg.append(A.el, B.el, cursor, chapter.el, head, descWrap, chipBox, usesLabel, privacy, applied);
const LAND = 0.05;
const CLICK = 7 * BEAT;
const WIPE = CLICK + 0.12;
const END = WIPE + 1.5;
// Screen position of the Midnight Glass install button.
const bx = PANEL.x + PAD + (CSS_ITEM % 3) * (W + GAP) + W - 12 - 52;
const by = PANEL.y + HEAD + Math.floor(CSS_ITEM / 3) * (H + GAP) + H - 12 - 18;
// Diagonal wipe edge in screen px: x at a given y.
const edge = (wx: number, y: number) => wx - 0.55 * y;
return {
name: "workshop",
start: 0,
end: END,
bg,
fg,
cues: [
{ t: LAND, kind: "hit", gain: 0.55 },
{ t: 0.25, kind: "swish", gain: 0.5 },
...ITEMS.slice(1).map((_, i) => ({ t: 0.3 + i * 0.05, kind: "tick" as const, gain: 0.25, pitch: i % 6 })),
{ t: 1.9, kind: "swish", gain: 0.35 },
{ t: CLICK, kind: "click", gain: 0.8 },
{ t: WIPE, kind: "swish", gain: 0.7 },
{ t: WIPE + 0.5, kind: "pop", gain: 0.6 },
],
update(t) {
// Left column
chapter.update(t, 0.05, END + 1); // a finite exit keeps it hidden on the first frame, as Custom Widgets left it
h1.update(t, 0.1, Infinity, 0.05, 0.55);
h2.update(t, 0.25, Infinity, 0.05, 0.55);
desc.update(t, 0.55, Infinity, 0.015, 0.5);
chips.forEach((c, i) => {
const a = 1.2 + i * 0.09;
tf(c, { s: clamp(spring(t - a, 2.6, 0.5), 0, 1.3), o: seg(t, a, a + 0.08) });
});
const ul = E.outExpo(seg(t, 1.9, 2.4));
tf(usesLabel, { y: (1 - ul) * 16, o: ul });
const pv = E.outQuart(seg(t, 2.8, 3.4));
tf(privacy, { o: pv });
privacy.style.clipPath = `inset(0 ${((1 - pv) * 100).toFixed(1)}% 0 0)`;
const ap = E.outBack(seg(t, WIPE + 0.45, WIPE + 0.85));
tf(applied, { y: (1 - ap) * 20, s: lerp(0.9, 1, ap), o: seg(t, WIPE + 0.45, WIPE + 0.55) });
// Catalog: grows out of the published card (the first frame is just that card, as Custom Widgets left it), then
// the other cards pop in.
const open = E.outQuart(seg(t, 0.05, 0.75));
const inset = [
SLOT.y - PANEL.y,
PANEL.x + PANEL.w - SLOT.x - W,
PANEL.y + PANEL.h - SLOT.y - H,
SLOT.x - PANEL.x,
];
const press = 1 - 0.1 * Math.sin(seg(t, CLICK - 0.06, CLICK + 0.1) * Math.PI);
const votes = String(Math.round(24 * E.outCubic(seg(t, LAND + 0.3, CLICK))));
const comments = String(Math.round(5 * E.outCubic(seg(t, LAND + 0.8, CLICK))));
for (const P of both) {
if (P === A)
// 1px outside the card so its own anti-aliased edge isn't clipped a second time.
P.el.style.clipPath =
open < 1
? `inset(${inset.map((v) => `${((v - 1) * (1 - open)).toFixed(2)}px`).join(" ")} round ${lerp(15, 20, open).toFixed(2)}px)`
: "";
P.cards.forEach((c, i) => {
if (i > 0) {
const a = 0.3 + i * 0.05;
tf(c.el, { s: lerp(0.85, 1, E.outBack(seg(t, a, a + 0.4))), o: seg(t, a, a + 0.12) });
}
});
P.cards[0]!.vote.textContent = votes;
P.cards[0]!.comments.textContent = comments;
const cc = P.cards[CSS_ITEM]!;
cc.installed.style.opacity = t >= CLICK + 0.04 ? "1" : "0";
cc.btn.style.transform = `scale(${press.toFixed(3)})`;
}
// The glass copy of the catalog and background, revealed by a diagonal wipe after the install.
const wx = lerp(-200, 2700, E.inOutQuart(seg(t, WIPE, WIPE + 0.62)));
const pl = (y: number) => (edge(wx, y) - PANEL.x).toFixed(1);
B.el.style.clipPath = `polygon(0 0,${pl(PANEL.y)}px 0,${pl(PANEL.y + PANEL.h)}px 100%,0 100%)`;
B.el.style.display = t > WIPE ? "" : "none";
bgGlass.style.clipPath = `polygon(0 0,${edge(wx, 0).toFixed(1)}px 0,${edge(wx, 1080).toFixed(1)}px 100%,0 100%)`;
bgGlass.style.display = t > WIPE ? "" : "none";
// The cursor installs Midnight Glass.
const cp = E.inOutCubic(seg(t, CLICK - 0.8, CLICK - 0.04));
const cx = lerp(bx - 380, bx, cp);
const cy = lerp(by + 260, by, cp);
cursor.style.transform = `translate(${cx.toFixed(1)}px,${cy.toFixed(1)}px) scale(${press.toFixed(3)})`;
cursor.style.opacity = String(seg(t, CLICK - 0.9, CLICK - 0.75) * (1 - seg(t, CLICK + 0.5, CLICK + 0.65)));
},
};
}
+253
View File
@@ -0,0 +1,253 @@
@font-face {
font-family: "Inter Tight";
src: url("../node_modules/@fontsource-variable/inter-tight/files/inter-tight-latin-wght-normal.woff2") format("woff2");
font-weight: 100 900;
}
@font-face {
font-family: "Inter";
src: url("../node_modules/@fontsource-variable/inter/files/inter-latin-wght-normal.woff2") format("woff2");
font-weight: 100 900;
}
@font-face {
font-family: "JetBrains Mono";
src: url("../node_modules/@fontsource-variable/jetbrains-mono/files/jetbrains-mono-latin-wght-normal.woff2")
format("woff2");
font-weight: 100 800;
}
:root {
--coral: #fa5352;
--coral2: #ff7b70;
--coral-deep: #c9383d;
--ink: #07070b;
--ink2: #0c0c12;
--navy: #11172f;
--navy2: #0b1024;
--card: #1c1d22;
--card2: #25262c;
--line: rgba(255, 255, 255, 0.085);
--line2: rgba(255, 255, 255, 0.14);
--text: #f4f4f7;
--muted: #8f919d;
--dim: #5d5f6b;
--mint: #3ddc97;
--violet: #7c8cff;
--amber: #ffb547;
--sky: #4fb3ff;
}
* {
box-sizing: border-box;
}
html,
body {
margin: 0;
background: #000;
overflow: hidden;
}
#stage {
position: relative;
width: 1920px;
height: 1080px;
overflow: hidden;
background: var(--ink);
font-family: "Inter", sans-serif;
color: var(--text);
-webkit-font-smoothing: antialiased;
font-feature-settings: "ss01", "cv11";
}
#world {
position: absolute;
inset: 0;
transform-origin: 50% 50%;
}
.layer {
position: absolute;
inset: 0;
}
#bg {
z-index: 0;
}
#gl {
position: absolute;
inset: 0;
width: 1920px;
height: 1080px;
z-index: 1;
pointer-events: none;
}
#fg {
z-index: 2;
}
#fx {
z-index: 20;
pointer-events: none;
}
#flash {
background: #fff;
opacity: 0;
mix-blend-mode: screen;
}
#vignette {
background: radial-gradient(ellipse 75% 70% at 50% 50%, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}
#grain {
opacity: 0.075;
mix-blend-mode: overlay;
}
#fade {
background: #000;
opacity: 0;
}
.scene {
position: absolute;
inset: 0;
overflow: hidden;
}
.scene.clip-none {
overflow: visible;
}
.abs {
position: absolute;
}
.center {
display: flex;
align-items: center;
justify-content: center;
}
.display {
font-family: "Inter Tight", sans-serif;
font-weight: 800;
letter-spacing: -0.045em;
line-height: 0.95;
}
.mono {
font-family: "JetBrains Mono", monospace;
}
.label {
font-family: "JetBrains Mono", monospace;
font-size: 17px;
letter-spacing: 0.24em;
text-transform: uppercase;
color: var(--coral);
font-weight: 600;
}
.muted {
color: var(--muted);
}
.coral {
color: var(--coral);
}
.mint {
color: var(--mint);
}
.ti {
display: inline-flex;
flex: none;
}
.ti svg {
width: 100%;
height: 100%;
stroke-width: var(--sw, 2);
}
img.svc {
display: block;
object-fit: contain;
flex: none;
}
.wmask {
display: inline-block;
overflow: hidden;
vertical-align: top;
padding: 0.04em 0.02em 0.14em;
margin: -0.04em -0.02em -0.14em;
}
.w,
.ch {
display: inline-block;
will-change: transform;
}
.word {
display: inline-block;
white-space: nowrap;
}
.card {
background: linear-gradient(180deg, #212228 0%, #191a1f 100%);
border: 1px solid var(--line);
border-radius: 18px;
box-shadow:
0 40px 90px -20px rgba(0, 0, 0, 0.65),
inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
.glass {
background: rgba(24, 25, 31, 0.72);
border: 1px solid var(--line2);
border-radius: 18px;
backdrop-filter: blur(18px);
}
.chip {
display: inline-flex;
align-items: center;
gap: 10px;
padding: 10px 18px;
border-radius: 999px;
border: 1px solid var(--line2);
background: rgba(255, 255, 255, 0.04);
font-size: 22px;
font-weight: 600;
white-space: nowrap;
}
.kbd {
display: inline-flex;
align-items: center;
justify-content: center;
min-width: 1.9em;
padding: 0.25em 0.55em;
border-radius: 0.35em;
border: 1px solid rgba(255, 255, 255, 0.22);
border-bottom-width: 3px;
background: linear-gradient(180deg, #2c2d35, #1d1e24);
font-family: "JetBrains Mono", monospace;
font-weight: 600;
color: #fff;
}
.row {
display: flex;
align-items: center;
}
.col {
display: flex;
flex-direction: column;
}
.tok-k {
color: #ff7b72;
}
.tok-s {
color: #a5d6ff;
}
.tok-p {
color: #d2a8ff;
}
.tok-n {
color: #79c0ff;
}
.tok-c {
color: #6e7681;
}
.tok-t {
color: #7ee787;
}
.tok-x {
color: #ffa657;
}
.caret {
display: inline-block;
width: 0.55em;
height: 1.15em;
margin-bottom: -0.2em;
background: var(--coral);
}
+82
View File
@@ -0,0 +1,82 @@
export type ModelVariant = "classic" | "chunky" | "rounded" | "metal" | "full";
export type MaterialPreset = "red" | "matte" | "glossy" | "metal" | "chrome" | "plastic" | "glass";
export type RotationAxis = "x" | "y" | "z" | "free";
export type ClawMode = "synchronized" | "alternating" | "offset";
export interface LabConfig {
variant: ModelVariant;
material: MaterialPreset;
depth: number;
bevel: number;
wireframe: boolean;
paused: boolean;
autoRotate: boolean;
rotationSpeed: number;
rotationAxis: RotationAxis;
idleFloat: boolean;
idleBody: boolean;
idleSpeed: number;
idleStrength: number;
claws: boolean;
leftClaw: boolean;
rightClaw: boolean;
clawMode: ClawMode;
clawSpeed: number;
clawStrength: number;
clawFrequency: number;
antennae: boolean;
leftAntenna: boolean;
rightAntenna: boolean;
antennaSpeed: number;
antennaStrength: number;
secondaryMotion: boolean;
eyes: boolean;
bodyPulse: boolean;
axes: boolean;
bounds: boolean;
pivots: boolean;
ground: boolean;
keyLight: number;
fillLight: number;
rimLight: number;
fov: number;
}
export const initialConfig: LabConfig = {
variant: "classic",
material: "red",
depth: 0.48,
bevel: 0.08,
wireframe: false,
paused: false,
autoRotate: true,
rotationSpeed: 0.32,
rotationAxis: "y",
idleFloat: true,
idleBody: false,
idleSpeed: 0.8,
idleStrength: 0.08,
claws: true,
leftClaw: true,
rightClaw: true,
clawMode: "offset",
clawSpeed: 1,
clawStrength: 0.18,
clawFrequency: 0.7,
antennae: true,
leftAntenna: true,
rightAntenna: true,
antennaSpeed: 0.75,
antennaStrength: 0.1,
secondaryMotion: true,
eyes: false,
bodyPulse: false,
axes: false,
bounds: false,
pivots: false,
ground: true,
keyLight: 7,
fillLight: 3,
rimLight: 5,
fov: 34,
};
+359
View File
@@ -0,0 +1,359 @@
// Deterministic Homarr lobster rig, adapted from the feat/3d-logo-lab branch.
// Every pose is derived from the state passed to render(), never from a clock.
import * as THREE from "three";
import { SVGLoader } from "three/examples/jsm/loaders/SVGLoader.js";
import { RoomEnvironment } from "three/examples/jsm/environments/RoomEnvironment.js";
import { initialConfig } from "./lab-types";
import { animateWordmarkRig, buildWordmarkRig, defaultWordmarkMotion, type WordmarkRig } from "./wordmark-rig";
type Side = -1 | 1;
type JointKind = "claw" | "antenna";
interface JointChain {
mesh: THREE.SkinnedMesh;
shoulder: THREE.Bone;
middle: THREE.Bone;
tip: THREE.Bone;
side: Side;
}
const lobsterParts = [
"left-antenna",
"right-antenna",
"body",
"left-eye",
"right-eye",
"right-claw",
"left-claw",
] as const;
function smoothstep(a: number, b: number, v: number) {
const t = THREE.MathUtils.clamp((v - a) / (b - a), 0, 1);
return t * t * (3 - 2 * t);
}
function makeJointedPart(
geometry: THREE.ExtrudeGeometry,
material: THREE.Material,
center: THREE.Vector3,
kind: JointKind,
side: Side,
): JointChain {
const mesh = new THREE.SkinnedMesh(geometry, material);
mesh.frustumCulled = false;
const joints: [number, number][] =
kind === "claw"
? [
[134, 335],
[95, 270],
[65, 180],
]
: [
[227, 226],
[185, 165],
[169, 105],
];
const at = ([x, y]: [number, number]) => new THREE.Vector3((side === -1 ? x : 512 - x) - center.x, y - center.y, 0);
const [a, b, c] = joints.map(at) as [THREE.Vector3, THREE.Vector3, THREE.Vector3];
const shoulder = new THREE.Bone();
shoulder.position.copy(a);
const middle = new THREE.Bone();
middle.position.copy(b).sub(a);
const tip = new THREE.Bone();
tip.position.copy(c).sub(b);
shoulder.add(middle);
middle.add(tip);
mesh.add(shoulder);
const positions = geometry.getAttribute("position");
const skinIndices: number[] = [];
const skinWeights: number[] = [];
const baseY = kind === "claw" ? 370 : 230;
const topY = kind === "claw" ? 113 : 83;
for (let i = 0; i < positions.count; i++) {
const p = THREE.MathUtils.clamp((baseY - (center.y + positions.getY(i))) / (baseY - topY), 0, 1);
const mw = smoothstep(0.08, 0.48, p);
const tw = smoothstep(0.42, 0.9, p);
skinIndices.push(0, 1, 2, 0);
skinWeights.push(1 - mw, mw * (1 - tw), mw * tw, 0);
}
geometry.setAttribute("skinIndex", new THREE.Uint16BufferAttribute(skinIndices, 4));
geometry.setAttribute("skinWeight", new THREE.Float32BufferAttribute(skinWeights, 4));
mesh.bind(new THREE.Skeleton([shoulder, middle, tip]));
return { mesh, shoulder, middle, tip, side };
}
export interface LogoState {
visible: boolean;
x: number; // world units
y: number;
z: number;
scale: number;
rx: number; // radians
ry: number;
rz: number;
clawL: number; // 0 open → 1 closed
clawR: number;
antenna: number; // phase in radians
antennaAmp: number;
antennaLift: number; // radians, positive perks both antennae upright
waveL: number; // radians around the claw's shoulder, positive raises it outward
waveR: number;
blinkL: number; // 0 open → 1 shut
blinkR: number;
explode: number; // 0 → parts fly apart
camZ: number;
sparks: number; // 0..1 burst progress, <0 disabled
dust: number; // opacity of dust field
t: number;
/** Extruded wordmark plaque, posed independently of the lobster (world units, radians). */
wm: { on: boolean; x: number; y: number; scale: number; rx: number; ry: number };
}
export const defaultLogoState = (): LogoState => ({
visible: false,
x: 0,
y: 0,
z: 0,
scale: 1,
rx: 0,
ry: 0,
rz: 0,
clawL: 0,
clawR: 0,
antenna: 0,
antennaAmp: 0.1,
antennaLift: 0,
waveL: 0,
waveR: 0,
blinkL: 0,
blinkR: 0,
explode: 0,
camZ: 12,
sparks: -1,
dust: 0,
t: 0,
wm: { on: false, x: 0, y: 0, scale: 1, rx: 0, ry: 0 },
});
export class LogoGL {
renderer: THREE.WebGLRenderer;
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(30, 16 / 9, 0.05, 200);
root = new THREE.Group();
model = new THREE.Group();
claws: JointChain[] = [];
antennae: JointChain[] = [];
parts: THREE.Mesh[] = [];
eyes: { mesh: THREE.Mesh; side: Side }[] = [];
sparks: THREE.Points;
sparkSeeds: Float32Array;
dust: THREE.Points;
wordmark: WordmarkRig;
wmRoot = new THREE.Group();
constructor(canvas: HTMLCanvasElement, svg: string, wordmarkSvg: string) {
this.renderer = new THREE.WebGLRenderer({ canvas, antialias: true, alpha: true, preserveDrawingBuffer: true });
this.renderer.setPixelRatio(1);
this.renderer.setSize(1920, 1080, false);
this.renderer.outputColorSpace = THREE.SRGBColorSpace;
this.renderer.toneMapping = THREE.ACESFilmicToneMapping;
this.renderer.toneMappingExposure = 0.92;
this.renderer.setClearColor(0x000000, 0);
const pmrem = new THREE.PMREMGenerator(this.renderer);
this.scene.environment = pmrem.fromScene(new RoomEnvironment(), 0.04).texture;
this.scene.environmentIntensity = 0.35;
const key = new THREE.DirectionalLight(0xfff0ea, 2.4);
key.position.set(-5, 7, 6);
const fill = new THREE.DirectionalLight(0x6f8cff, 0.9);
fill.position.set(7, -1, 4);
const rim = new THREE.DirectionalLight(0xffc2ba, 3.4);
rim.position.set(3, 4, -7);
const rim2 = new THREE.DirectionalLight(0xff4a5a, 4);
rim2.position.set(-6, -2, -5);
this.scene.add(key, fill, rim, rim2, new THREE.HemisphereLight(0xffd8d4, 0x0b0b12, 0.25));
this.scene.add(this.root);
this.root.add(this.model);
this.build(svg);
this.wordmark = buildWordmarkRig(wordmarkSvg, initialConfig);
this.wmRoot.add(this.wordmark.model);
this.scene.add(this.wmRoot);
// Spark burst: 600 points on deterministic trajectories.
const n = 600;
this.sparkSeeds = new Float32Array(n * 4);
for (let i = 0; i < n; i++) {
const r = (k: number) => {
const x = Math.sin((i * 4 + k) * 91.345 + 17.1) * 43758.5453;
return x - Math.floor(x);
};
this.sparkSeeds.set([r(0), r(1), r(2), r(3)], i * 4);
}
const sg = new THREE.BufferGeometry();
sg.setAttribute("position", new THREE.BufferAttribute(new Float32Array(n * 3), 3));
this.sparks = new THREE.Points(
sg,
new THREE.PointsMaterial({
color: 0xff7a70,
size: 0.1,
transparent: true,
opacity: 1,
blending: THREE.AdditiveBlending,
depthWrite: false,
}),
);
this.scene.add(this.sparks);
const dn = 1400;
const dg = new THREE.BufferGeometry();
const dp = new Float32Array(dn * 3);
for (let i = 0; i < dn; i++) {
const r = (k: number) => {
const x = Math.sin((i * 3 + k) * 12.9898 + 78.233) * 43758.5453;
return x - Math.floor(x);
};
dp.set([(r(0) - 0.5) * 40, (r(1) - 0.5) * 24, -r(2) * 40 + 4], i * 3);
}
dg.setAttribute("position", new THREE.BufferAttribute(dp, 3));
this.dust = new THREE.Points(
dg,
new THREE.PointsMaterial({ color: 0xffb0a8, size: 0.035, transparent: true, opacity: 0, depthWrite: false }),
);
this.scene.add(this.dust);
}
build(svg: string) {
const parsed = new SVGLoader().parse(svg);
const material = new THREE.MeshPhysicalMaterial({
color: 0xf23b3f,
metalness: 0.1,
roughness: 0.34,
clearcoat: 0.4,
clearcoatRoughness: 0.22,
sheen: 0.15,
sheenColor: new THREE.Color(0xff9a90),
side: THREE.DoubleSide,
});
let idx = 0;
parsed.paths.forEach((path) => {
SVGLoader.createShapes(path).forEach((shape) => {
const geometry = new THREE.ExtrudeGeometry(shape, {
depth: 0.5 * 54,
bevelEnabled: true,
bevelThickness: 0.1 * 20,
bevelSize: 0.1 * 15,
bevelSegments: 5,
curveSegments: 14,
});
geometry.computeVertexNormals();
geometry.computeBoundingBox();
const c = geometry.boundingBox!.getCenter(new THREE.Vector3());
geometry.translate(-c.x, -c.y, -c.z);
const part = lobsterParts[idx];
const side: Side = part?.startsWith("left") ? -1 : 1;
let mesh: THREE.Mesh;
if (part?.endsWith("claw") || part?.endsWith("antenna")) {
const kind = part.endsWith("claw") ? "claw" : "antenna";
const chain = makeJointedPart(geometry, material, c, kind, side);
mesh = chain.mesh;
(kind === "claw" ? this.claws : this.antennae).push(chain);
} else {
mesh = new THREE.Mesh(geometry, material);
if (part?.endsWith("eye")) this.eyes.push({ mesh, side });
}
mesh.position.copy(c);
mesh.name = part ?? `part-${idx}`;
idx++;
this.parts.push(mesh);
this.model.add(mesh);
});
});
const box = new THREE.Box3().setFromObject(this.model);
const center = box.getCenter(new THREE.Vector3());
this.model.children.forEach((child) => {
child.position.sub(center);
child.userData.home = child.position.clone();
});
const size = new THREE.Box3().setFromObject(this.model).getSize(new THREE.Vector3());
const s = 5.15 / Math.max(size.x, size.y);
this.model.scale.set(s, -s, s);
}
render(st: LogoState) {
this.camera.position.set(0, 0, st.camZ);
this.camera.lookAt(0, 0, 0);
this.camera.updateProjectionMatrix();
this.model.visible = st.visible;
this.root.position.set(st.x, st.y, st.z);
this.root.rotation.set(st.rx, st.ry, st.rz);
this.root.scale.setScalar(st.scale);
for (const chain of this.claws) {
const closure = (chain.side === -1 ? st.clawL : st.clawR) * 0.2;
chain.middle.rotation.z = -chain.side * closure * 2.1;
chain.tip.rotation.z = -chain.side * closure;
chain.shoulder.rotation.z = chain.side * (chain.side === -1 ? st.waveL : st.waveR);
}
for (const chain of this.antennae) {
const ph = st.antenna + (chain.side === 1 ? 0.55 : 0);
chain.middle.rotation.z = Math.sin(ph) * st.antennaAmp * 0.7;
chain.tip.rotation.z = Math.sin(ph - 0.85) * st.antennaAmp * 1.25;
chain.middle.rotation.x = Math.sin(ph * 0.72) * st.antennaAmp * 0.2;
chain.tip.rotation.x = Math.sin(ph * 0.72 - 0.65) * st.antennaAmp * 0.45;
chain.shoulder.rotation.z = -chain.side * st.antennaLift;
}
this.model.children.forEach((child, i) => {
const home = child.userData.home as THREE.Vector3;
if (st.explode > 0) {
const dir = home
.clone()
.setZ(i % 2 ? 60 : -60)
.normalize();
child.position.copy(home).add(dir.multiplyScalar(st.explode * (120 + (i % 3) * 40)));
child.rotation.set(
st.explode * (i % 2 ? 0.8 : -0.6),
st.explode * ((i % 3) - 1) * 0.9,
st.explode * 0.4 * (i - 3),
);
} else {
child.position.copy(home);
child.rotation.set(0, 0, 0);
}
});
for (const { mesh, side } of this.eyes) mesh.scale.y = Math.max(0.08, 1 - (side === -1 ? st.blinkL : st.blinkR));
this.wmRoot.visible = st.wm.on;
if (st.wm.on) {
animateWordmarkRig(this.wordmark, st.t, 1 / 60, defaultWordmarkMotion, null);
this.wmRoot.position.set(st.wm.x, st.wm.y, 0);
this.wmRoot.rotation.set(st.wm.rx, st.wm.ry, 0);
this.wmRoot.scale.setScalar(Math.max(1e-3, st.wm.scale));
}
// Sparks: radial burst in the logo's plane with gravity and fade.
const sp = this.sparks.geometry.getAttribute("position") as THREE.BufferAttribute;
const mat = this.sparks.material as THREE.PointsMaterial;
if (st.sparks >= 0 && st.sparks <= 1) {
this.sparks.visible = true;
const p = st.sparks;
for (let i = 0; i < sp.count; i++) {
const a = this.sparkSeeds[i * 4]! * Math.PI * 2;
const sp0 = 2 + this.sparkSeeds[i * 4 + 1]! * 9;
const zz = (this.sparkSeeds[i * 4 + 2]! - 0.5) * 6;
const d = 1 - Math.exp(-p * 3.2);
sp.setXYZ(i, st.x + Math.cos(a) * sp0 * d, st.y + Math.sin(a) * sp0 * d * 0.7 - p * p * 2.5, zz * d);
}
sp.needsUpdate = true;
mat.opacity = Math.max(0, 1 - p) ** 1.5;
} else this.sparks.visible = false;
const dm = this.dust.material as THREE.PointsMaterial;
dm.opacity = st.dust;
this.dust.visible = st.dust > 0.001;
this.dust.position.set(Math.sin(st.t * 0.07) * 1.5, Math.cos(st.t * 0.05), (st.t * 0.6) % 8);
this.renderer.render(this.scene, this.camera);
}
}
+374
View File
@@ -0,0 +1,374 @@
import * as THREE from "three";
import { SVGLoader } from "three/examples/jsm/loaders/SVGLoader.js";
import type { LabConfig } from "./lab-types";
export interface WordmarkRig {
model: THREE.Group;
baseScale: number;
frame: THREE.Group;
spine: THREE.Group;
cursor: THREE.Group;
clickRays: THREE.Group;
panels: THREE.Group[];
letters: THREE.Group[];
kana: THREE.Group[];
arrowHead: THREE.Group;
arrowSegments: THREE.Group[];
arrowTip: THREE.Group;
breathingOrder: THREE.Group[];
hoverParts: THREE.Group[];
hoverMeshes: THREE.Mesh[];
beamParts: THREE.Group[];
beamAnchors: number[];
beamPath: THREE.CatmullRomCurve3;
beamDots: THREE.Mesh[];
}
export interface WordmarkMotion {
cursor: boolean;
arrow: boolean;
panels: boolean;
letters: boolean;
kana: boolean;
beam: boolean;
breathe: boolean;
}
export const defaultWordmarkMotion: WordmarkMotion = {
cursor: true,
arrow: true,
panels: true,
letters: true,
kana: true,
beam: true,
breathe: true,
};
function home(part: THREE.Group) {
return part.userData.home as THREE.Vector3;
}
const beamColor = new THREE.Color(0xffe9c4);
const hoverColor = new THREE.Color(0xffc1c1);
function tintPart(part: THREE.Group, color: THREE.Color, amount: number) {
for (const child of part.children) {
if (!(child instanceof THREE.Mesh)) continue;
const face = Array.isArray(child.material) ? child.material[0] : child.material;
if (!(face instanceof THREE.MeshBasicMaterial)) continue;
face.color.copy(child.userData.baseFaceColor as THREE.Color).lerp(color, amount);
}
}
export function buildWordmarkRig(svg: string, config: LabConfig): WordmarkRig {
const paths = new SVGLoader().parse(svg).paths;
const model = new THREE.Group();
model.name = "IllustratedWordmarkRig";
const reverseArtwork = new THREE.Group();
reverseArtwork.name = "StaticReverseArtwork";
const parts = new Map<string, THREE.Group>();
const plateDepth = config.depth * 60;
paths.forEach((path, pathIndex) => {
const node = path.userData?.node as Element | undefined;
const parent = node?.parentNode as Element | null | undefined;
const partName = parent?.getAttribute("data-rig-part");
if (!partName) throw new Error(`Wordmark contour ${pathIndex} has no rig part`);
let part = parts.get(partName);
if (!part) {
part = new THREE.Group();
part.name = partName;
parts.set(partName, part);
}
let depth = 2.2;
let back = 4 + pathIndex * 0.025;
if (pathIndex === 0) {
depth = plateDepth;
back = -plateDepth;
} else if (pathIndex === 1) {
depth = 2.4;
back = 0.25;
} else if (partName === "arrow-spine") {
depth = 2;
back = 2.8 + pathIndex * 0.025;
} else if (partName === "cursor" || partName === "click-rays") {
depth = 3;
back = 7 + pathIndex * 0.025;
}
const face = new THREE.MeshBasicMaterial({
color: path.color,
side: THREE.DoubleSide,
wireframe: config.wireframe,
toneMapped: false,
});
const edgeColor = pathIndex === 0 ? new THREE.Color(0xf93232) : path.color.clone().multiplyScalar(0.58);
const edge = new THREE.MeshStandardMaterial({
color: edgeColor,
metalness: 0.1,
roughness: 0.58,
side: THREE.DoubleSide,
wireframe: config.wireframe,
});
for (const shape of SVGLoader.createShapes(path)) {
const geometry = new THREE.ExtrudeGeometry(shape, {
depth,
bevelEnabled: pathIndex === 0,
bevelThickness: config.bevel * 8,
bevelSize: config.bevel * 6,
bevelSegments: 2,
curveSegments: 10,
});
geometry.computeBoundingBox();
const center = geometry.boundingBox?.getCenter(new THREE.Vector3()) ?? new THREE.Vector3();
geometry.translate(-center.x, -center.y, -center.z);
const mesh = new THREE.Mesh(geometry, [face, edge]);
mesh.name = `${partName}-${pathIndex}`;
mesh.position.set(center.x, center.y, center.z + back);
mesh.renderOrder = pathIndex;
mesh.castShadow = true;
mesh.receiveShadow = true;
mesh.userData.baseFaceColor = path.color.clone();
part.add(mesh);
if (pathIndex > 0) {
// The reverse is painted too, so the lockup remains readable from
// behind instead of becoming an unmarked white silhouette.
const reverseGeometry = new THREE.ShapeGeometry(shape, 10);
reverseGeometry.translate(-center.x, -center.y, 0);
const reverse = new THREE.Mesh(reverseGeometry, face.clone());
reverse.name = `${partName}-${pathIndex}-reverse`;
reverse.position.set(center.x, center.y, -plateDepth - 0.5 - pathIndex * 0.025);
reverse.renderOrder = pathIndex;
// The rear print belongs to the plaque, not the articulated foreground.
// Moving it with a letter would bury it inside the backing from behind.
reverseArtwork.add(reverse);
}
}
});
for (const part of parts.values()) {
const bounds = new THREE.Box3().setFromObject(part);
const origin = bounds.getCenter(new THREE.Vector3());
if (part.name === "cursor" || part.name === "click-rays") origin.set(1229, 287, origin.z);
for (const child of part.children) child.position.sub(origin);
part.position.copy(origin);
model.add(part);
}
model.add(reverseArtwork);
const bounds = new THREE.Box3().setFromObject(model);
const center = bounds.getCenter(new THREE.Vector3());
const size = bounds.getSize(new THREE.Vector3());
for (const part of parts.values()) {
part.position.sub(center);
part.userData.home = part.position.clone();
}
reverseArtwork.position.sub(center);
const scale = 8.5 / Math.max(size.x, size.y);
model.scale.set(scale, -scale, scale);
const getPart = (name: string) => {
const part = parts.get(name);
if (!part) throw new Error(`Missing wordmark rig part: ${name}`);
return part;
};
const frame = getPart("frame");
const spine = getPart("arrow-spine");
const cursor = getPart("cursor");
const clickRays = getPart("click-rays");
const panels = ["panel-left", "panel-center", "panel-right"].map(getPart);
const letters = ["letter-h", "letter-o", "letter-m", "letter-a", "letter-r-one", "letter-r-two"].map(getPart);
const kana = ["kana-ho", "kana-ma", "kana-dash", "kana-ru"].map(getPart);
const arrowHead = getPart("arrow-head");
const arrowSegments = [
"arrow-segment-one",
"arrow-segment-two",
"arrow-segment-three",
"arrow-segment-four",
"arrow-segment-five",
].map(getPart);
const arrowTip = getPart("arrow-tip");
const chain = [arrowTip, ...arrowSegments.toReversed(), arrowHead];
const beamPoints = chain.map((part) => new THREE.Vector3(home(part).x, home(part).y, home(part).z + 17));
const beamPath = new THREE.CatmullRomCurve3(beamPoints);
let previous = beamPoints[0];
if (!previous) throw new Error("Wordmark chain has no parts");
let beamLength = 0;
const beamDistances = [0];
for (const point of beamPoints.slice(1)) {
beamLength += point.distanceTo(previous);
beamDistances.push(beamLength);
previous = point;
}
if (beamLength === 0) throw new Error("Wordmark chain has no length");
const beamAnchors = beamDistances.map((distance) => distance / beamLength);
const beamDots = [
{ radius: 10, opacity: 0.95 },
{ radius: 22, opacity: 0.22 },
{ radius: 7, opacity: 0.48 },
{ radius: 5, opacity: 0.28 },
].map(({ radius, opacity }) => {
const dot = new THREE.Mesh(
new THREE.SphereGeometry(radius, 12, 8),
new THREE.MeshBasicMaterial({
color: 0xffe7b5,
transparent: true,
opacity,
depthWrite: false,
toneMapped: false,
}),
);
dot.visible = false;
model.add(dot);
return dot;
});
const breathingOrder = [frame, ...panels, cursor, clickRays, ...letters, ...kana, spine, ...chain];
const hoverParts = [...panels, ...letters, ...kana, cursor, clickRays, ...chain];
const hoverMeshes = hoverParts.flatMap((part) =>
part.children.filter((child): child is THREE.Mesh => child instanceof THREE.Mesh),
);
return {
model,
baseScale: scale,
frame,
spine,
cursor,
clickRays,
panels,
letters,
kana,
arrowHead,
arrowSegments,
arrowTip,
breathingOrder,
hoverParts,
hoverMeshes,
beamParts: chain,
beamAnchors,
beamPath,
beamDots,
};
}
export function animateWordmarkRig(
rig: WordmarkRig,
time: number,
delta: number,
motion: WordmarkMotion,
hoveredPart: string | null,
) {
const breathPeriod = rig.breathingOrder.length * 0.23 + 1.3;
const breath = (index: number) => {
if (!motion.breathe) return 0;
const phase = (((time - index * 0.23) % breathPeriod) + breathPeriod) % breathPeriod;
const distance = (phase - 0.24) / 0.3;
return Math.exp(-(distance * distance));
};
rig.breathingOrder.forEach((part, index) => {
part.position.copy(home(part));
part.rotation.set(0, 0, 0);
part.scale.setScalar(1);
if (part === rig.frame) return;
const pulse = breath(index);
part.position.z += pulse * 9;
part.scale.setScalar(1 + pulse * 0.05);
});
const plaqueScale = rig.baseScale * (1 + breath(0) * 0.006);
rig.model.scale.set(plaqueScale, -plaqueScale, plaqueScale);
const blend = 1 - Math.exp(-delta * 14);
const hover = (part: THREE.Group, target: number) => {
const current = (part.userData.hoverLevel as number | undefined) ?? 0;
const next = current + (target - current) * blend;
part.userData.hoverLevel = next;
return next;
};
const activePanel = rig.panels.findIndex((part) => part.name === hoveredPart);
rig.panels.forEach((part, index) => {
let target = 0;
if (motion.panels && activePanel >= 0) target = index === activePanel ? 1 : 0.12;
const level = hover(part, target);
part.position.y -= level * (12 + Math.sin(time * 7 + index) * 2);
part.position.z += level * 46;
part.rotation.y = level * (Math.sin(time * 7 + index) * 0.08);
part.scale.multiplyScalar(1 + level * 0.13);
tintPart(part, hoverColor, level * 0.42);
});
const activeLetter = rig.letters.findIndex((part) => part.name === hoveredPart);
rig.letters.forEach((part, index) => {
let target = 0;
if (motion.letters && activeLetter >= 0) {
if (index === activeLetter) target = 1;
else if (Math.abs(index - activeLetter) === 1) target = 0.18;
}
const level = hover(part, target);
part.position.y -= level * 12;
part.position.z += level * 55;
part.rotation.y = Math.sin(time * 6 + index) * level * 0.05;
part.scale.multiplyScalar(1 + level * 0.14);
tintPart(part, hoverColor, level * 0.38);
});
const activeKana = rig.kana.findIndex((part) => part.name === hoveredPart);
rig.kana.forEach((part, index) => {
let target = 0;
if (motion.kana && activeKana >= 0) {
if (index === activeKana) target = 1;
else if (Math.abs(index - activeKana) === 1) target = 0.18;
}
const level = hover(part, target);
part.position.y -= level * 10;
part.position.z += level * 50;
part.rotation.z = Math.sin(time * 7 + index) * level * 0.035;
part.scale.multiplyScalar(1 + level * 0.16);
tintPart(part, hoverColor, level * 0.42);
});
const cursorHover = hover(rig.cursor, motion.cursor && hoveredPart === rig.cursor.name ? 1 : 0);
const raysHover = hover(rig.clickRays, motion.cursor && hoveredPart === rig.clickRays.name ? 1 : 0);
const click = motion.cursor ? ((1 + Math.cos(time * 3)) / 2) ** 10 : 0;
rig.cursor.position.y += click * 13 - cursorHover * 8;
rig.cursor.position.z += click * 18 + cursorHover * 30;
rig.cursor.scale.multiplyScalar(1 - click * 0.12 + cursorHover * 0.14);
rig.clickRays.position.z += click * 18 + raysHover * 26;
rig.clickRays.scale.multiplyScalar(1 + click * 0.28 + raysHover * 0.24);
rig.arrowSegments.forEach((part, index) => {
if (motion.arrow) {
const wave = Math.sin(time * 1.35 - index * 0.48);
part.position.y += wave * 8;
part.position.z += Math.max(0, wave) * 12;
part.rotation.z = wave * 0.02;
}
});
if (motion.arrow) {
rig.arrowHead.rotation.z = Math.sin(time * 1.35 + 0.4) * 0.018;
rig.arrowTip.rotation.z = Math.sin(time * 1.35 - 2.9) * 0.018;
}
const beamProgress = (time % 5.2) / 4.2;
const beamActive = motion.beam && beamProgress <= 1;
rig.beamDots.forEach((dot, index) => {
const trail = index < 2 ? 0 : (index - 1) * 0.035;
dot.visible = beamActive && beamProgress >= trail;
if (dot.visible) rig.beamPath.getPointAt(beamProgress - trail, dot.position);
});
rig.beamParts.forEach((part, index) => {
const center = rig.beamAnchors[index];
if (center === undefined) return;
const distance = (beamProgress - center) / 0.1;
const light = beamActive ? Math.exp(-(distance * distance)) : 0;
const level = hover(part, motion.arrow && hoveredPart === part.name ? 1 : 0);
part.position.z += light * 9 + level * 24;
part.scale.multiplyScalar(1 + light * 0.055 + level * 0.06);
tintPart(part, beamColor, Math.min(1, light * 0.7 + level * 0.36));
});
}