Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(desktop): animated installer splash generated in-repo
Elian Dorana23c6acee8ee
diff --git a/apps/desktop/electron-forge/setup-icon/generate/README.md b/apps/desktop/electron-forge/setup-icon/generate/README.mdnew file mode 100644index 0000000000..507584023c--- /dev/null+++ b/apps/desktop/electron-forge/setup-icon/generate/README.md@@ -0,0 +1,32 @@+# Installer splash generation++`setup-banner.gif` and `setup-banner-dev.gif` (one directory up) are the splash screens shown by the+Squirrel.Windows installer while it extracts the app (`loadingGif` in `electron-forge/forge.config.ts`).+Squirrel only accepts GIF, shows it at native pixel size in a borderless window, and provides no+progress bar — the animation is the user's only feedback that the install is running.++Both files are generated from `splash.html` in this directory. Do not edit the GIFs by hand;+change the HTML/timeline and regenerate:++```bash+pnpm --filter desktop generate-setup-banners+```++Run it on **Windows** so the wordmark renders in Segoe UI (the font is rasterized into the GIF).++## How it works++- `splash.html` is a deterministic frame source: `window.renderFrame(i)` computes every element's+ opacity/transform for frame `i` (no CSS animations), so output is reproducible. `?variant=nightly`+ switches to the purple palette and shows the NIGHTLY badge.+- `generate.mts` steps through the timeline in headless Chromium (via the repo's `@playwright/test`),+ screenshots each frame, and encodes an animated GIF with `gifenc` — no external binaries needed.++## Output contract++- 640 × 480, opaque white background (GIF transparency is 1-bit and would leave ragged edges over+ the desktop), 36 frames at 100 ms (3.6 s loop), infinite loop, ≤ 128 colors per frame.+- The leaf geometry and the nine stable fill colors are taken verbatim from the app icon+ (`icon-color.svg`); the nightly variant remaps each leaf to a purple ramp.+- The dot pulse cycle (1.2 s) divides the loop length evenly so the pulse is continuous across the+ GIF loop point — keep that invariant if you change the timing.diff --git a/apps/desktop/electron-forge/setup-icon/generate/generate.mts b/apps/desktop/electron-forge/setup-icon/generate/generate.mtsnew file mode 100644index 0000000000..8a5150b87d--- /dev/null+++ b/apps/desktop/electron-forge/setup-icon/generate/generate.mts@@ -0,0 +1,78 @@+/**+ * Regenerates the Squirrel.Windows installer splash GIFs (setup-banner.gif and+ * setup-banner-dev.gif) from splash.html.+ *+ * Run with: pnpm --filter desktop generate-setup-banners+ *+ * Renders each frame deterministically via window.renderFrame(i) in headless+ * Chromium, then encodes an animated GIF with gifenc. Run on Windows so the+ * wordmark renders in Segoe UI, which is what the installer audience sees.+ */+import { chromium, type Page } from "@playwright/test";+import { writeFileSync } from "fs";+import gifenc from "gifenc";+import path from "path";+import { PNG } from "pngjs";+import { fileURLToPath, pathToFileURL } from "url";++// gifenc's CJS build exposes no named ESM exports, hence the default import.+const { GIFEncoder, quantize, applyPalette } = gifenc;++const SETUP_ICON_DIR = path.dirname(path.dirname(fileURLToPath(import.meta.url)));+const SPLASH_PAGE = pathToFileURL(path.join(SETUP_ICON_DIR, "generate", "splash.html"));++const WIDTH = 640;+const HEIGHT = 480;+const MAX_COLORS = 128;++const VARIANTS = [+ { variant: "stable", fileName: "setup-banner.gif" },+ { variant: "nightly", fileName: "setup-banner-dev.gif" }+];++async function renderVariant(page: Page, variant: string): Promise<Buffer> {+ await page.goto(`${SPLASH_PAGE}?variant=${variant}`);+ const timeline = await page.evaluate(() => window.SPLASH_TIMELINE);++ const gif = GIFEncoder();+ for (let frame = 0; frame < timeline.totalFrames; frame++) {+ await page.evaluate((f) => window.renderFrame(f), frame);+ const screenshot = PNG.sync.read(await page.screenshot({ clip: { x: 0, y: 0, width: WIDTH, height: HEIGHT } }));+ const rgba = new Uint8Array(screenshot.data.buffer, screenshot.data.byteOffset, screenshot.data.length);++ const palette = quantize(rgba, MAX_COLORS);+ const index = applyPalette(rgba, palette);+ gif.writeFrame(index, WIDTH, HEIGHT, {+ palette,+ delay: 1000 / timeline.fps,+ repeat: 0 // loop forever+ });+ }+ gif.finish();++ return Buffer.from(gif.bytes());+}++const browser = await chromium.launch();+try {+ const page = await browser.newPage({+ viewport: { width: WIDTH, height: HEIGHT },+ deviceScaleFactor: 1+ });++ for (const { variant, fileName } of VARIANTS) {+ const gif = await renderVariant(page, variant);+ const outputPath = path.join(SETUP_ICON_DIR, fileName);+ writeFileSync(outputPath, gif);+ console.log(`[${variant}] ${outputPath} (${(gif.length / 1024).toFixed(1)} KiB)`);+ }+} finally {+ await browser.close();+}++declare global {+ interface Window {+ SPLASH_TIMELINE: { fps: number; totalFrames: number };+ renderFrame: (frame: number) => void;+ }+}diff --git a/apps/desktop/electron-forge/setup-icon/generate/gifenc.d.ts b/apps/desktop/electron-forge/setup-icon/generate/gifenc.d.tsnew file mode 100644index 0000000000..97b276f17c--- /dev/null+++ b/apps/desktop/electron-forge/setup-icon/generate/gifenc.d.ts@@ -0,0 +1,25 @@+// gifenc ships no type definitions; minimal surface used by generate.mts.+declare module "gifenc" {+ export interface WriteFrameOptions {+ palette?: number[][];+ delay?: number;+ repeat?: number;+ transparent?: boolean;+ transparentIndex?: number;+ dispose?: number;+ first?: boolean;+ }++ export interface GIFEncoderInstance {+ writeFrame(index: Uint8Array, width: number, height: number, options?: WriteFrameOptions): void;+ finish(): void;+ bytes(): Uint8Array;+ }++ const gifenc: {+ GIFEncoder(): GIFEncoderInstance;+ quantize(rgba: Uint8Array | Uint8ClampedArray, maxColors: number): number[][];+ applyPalette(rgba: Uint8Array | Uint8ClampedArray, palette: number[][]): Uint8Array;+ };+ export default gifenc;+}diff --git a/apps/desktop/electron-forge/setup-icon/generate/splash.html b/apps/desktop/electron-forge/setup-icon/generate/splash.htmlnew file mode 100644index 0000000000..7cfeec0d32--- /dev/null+++ b/apps/desktop/electron-forge/setup-icon/generate/splash.html@@ -0,0 +1,174 @@+<!DOCTYPE html>+<html>+<head>+<meta charset="utf-8">+<title>Trilium installer splash — frame source</title>+<style>+ html, body {+ margin: 0;+ padding: 0;+ overflow: hidden;+ background: #ffffff;+ }+ .stage {+ width: 640px;+ height: 480px;+ background: #ffffff;+ display: flex;+ flex-direction: column;+ align-items: center;+ justify-content: center;+ font-family: "Segoe UI", "Segoe UI Variable Text", system-ui, sans-serif;+ user-select: none;+ }+ svg.mark {+ width: 190px;+ height: 190px;+ display: block;+ }+ .leaf { transform-origin: 128px 128px; }+ .wordmark {+ margin-top: 26px;+ font-size: 30px;+ font-weight: 600;+ letter-spacing: 0.01em;+ color: #232920;+ display: flex;+ align-items: baseline;+ gap: 12px;+ }+ .word-notes { font-weight: 350; color: #6b7264; }+ .nightly-badge {+ display: none;+ font-size: 12.5px;+ font-weight: 700;+ letter-spacing: 0.16em;+ color: #ffffff;+ background: #8146b8;+ border-radius: 3px;+ padding: 3px 8px 4px;+ transform: translateY(-4px);+ }+ .variant-nightly .nightly-badge { display: block; }+ .status {+ margin-top: 14px;+ font-size: 16px;+ color: #8a9082;+ display: flex;+ align-items: center;+ gap: 10px;+ }+ .dots { display: flex; gap: 7px; }+ .dot { width: 8px; height: 8px; border-radius: 50%; }+ .variant-stable .dot.d1 { background: #4fa52b; }+ .variant-stable .dot.d2 { background: #e47b19; }+ .variant-stable .dot.d3 { background: #e33f3b; }+ .variant-nightly .dot.d1 { background: #6e2ea8; }+ .variant-nightly .dot.d2 { background: #8146b8; }+ .variant-nightly .dot.d3 { background: #9668c2; }++ /* Leaf fills — stable values are the exact nine fills from icon-color.svg. */+ .variant-stable .g1 { fill: #95c980; } .variant-stable .g2 { fill: #72b755; } .variant-stable .g3 { fill: #4fa52b; }+ .variant-stable .r1 { fill: #ee8c89; } .variant-stable .r2 { fill: #e96562; } .variant-stable .r3 { fill: #e33f3b; }+ .variant-stable .o1 { fill: #efb075; } .variant-stable .o2 { fill: #e99547; } .variant-stable .o3 { fill: #e47b19; }+ .variant-nightly .g1 { fill: #b18ad6; } .variant-nightly .g2 { fill: #9159c4; } .variant-nightly .g3 { fill: #6e2ea8; }+ .variant-nightly .r1 { fill: #cdb2e4; } .variant-nightly .r2 { fill: #b08fd6; } .variant-nightly .r3 { fill: #9668c2; }+ .variant-nightly .o1 { fill: #c09fe0; } .variant-nightly .o2 { fill: #a276cf; } .variant-nightly .o3 { fill: #8146b8; }+</style>+</head>+<body>+<div class="stage" id="stage">+ <svg class="mark" viewBox="0 0 256 256" aria-label="Trilium mark" role="img">+ <g class="leaf leaf-green">+ <path class="g1" d="m202.9 112.7c-22.5 16.1-54.5 12.8-74.9 6.3l14.8-11.8 14.1-11.3 49.1-39.3-51.2 35.9-14.3 10-14.9 10.5c0.7-21.2 7-49.9 28.6-65.4 1.8-1.3 3.9-2.6 6.1-3.8 2.7-1.5 5.7-2.9 8.8-4.1 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.9 65.9-2.4 2.8-4.9 5.4-7.4 7.8-3.4 3.5-6.8 6.4-10.1 8.8z"/>+ <path class="g2" d="m213.1 104c-22.2 12.6-51.4 9.3-70.3 3.2l14.1-11.3 49.1-39.3-51.2 35.9-14.3 10c0.5-18.1 4.9-42.1 19.7-58.6 2.7-1.5 5.7-2.9 8.8-4.1 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.9 65.9-2.3 2.8-4.8 5.4-7.2 7.8z"/>+ <path class="g3" d="m220.5 96.2c-21.1 8.6-46.6 5.3-63.7-0.2l49.2-39.4-51.2 35.9c0.3-15.8 3.5-36.6 14.3-52.8 27.1-11.1 68.5-15.3 85.2-9.5 0.1 16.2-15.9 45.4-33.8 66z"/>+ </g>+ <g class="leaf leaf-orange">+ <path class="o1" d="m86.3 59.1c21.7 10.9 32.4 36.6 35.8 54.9l-15.2-6.6-14.5-6.3-50.6-22 48.8 24.9 13.6 6.9 14.3 7.3c-16.6 7.9-41.3 14.5-62.1 4.1-1.8-0.9-3.6-1.9-5.4-3.2-2.3-1.5-4.5-3.2-6.8-5.1-19.9-16.4-40.3-46.4-42.7-61.5 12.4-6.5 41.5-5.8 64.8-0.3 3.2 0.8 6.2 1.6 9.1 2.5 4 1.3 7.6 2.8 10.9 4.4z"/>+ <path class="o2" d="m75.4 54.8c18.9 12 28.4 35.6 31.6 52.6l-14.5-6.3-50.6-22 48.7 24.9 13.6 6.9c-14.1 6.8-34.5 13-53.3 8.2-2.3-1.5-4.5-3.2-6.8-5.1-19.8-16.4-40.2-46.4-42.6-61.5 12.4-6.5 41.5-5.8 64.8-0.3 3.1 0.8 6.2 1.6 9.1 2.6z"/>+ <path class="o3" d="m66.3 52.2c15.3 12.8 23.3 33.6 26.1 48.9l-50.6-22 48.8 24.9c-12.2 6-29.6 11.8-46.5 10-19.8-16.4-40.2-46.4-42.6-61.5 12.4-6.5 41.5-5.8 64.8-0.3z"/>+ </g>+ <g class="leaf leaf-red">+ <path class="r1" d="m106.7 179c-5.8-21 5.2-43.8 15.5-57.2l4.8 14.2 4.5 13.4 15.9 47-12.8-47.6-3.6-13.2-3.7-13.9c15.5 6.2 35.1 18.6 40.7 38.8 0.5 1.7 0.9 3.6 1.2 5.5 0.4 2.4 0.6 5 0.7 7.7 0.9 23.1-7.1 54.9-15.9 65.7-12-4.3-29.3-24-39.7-42.8-1.4-2.6-2.7-5.1-3.8-7.6-1.6-3.5-2.9-6.8-3.8-10z"/>+ <path class="r2" d="m110.4 188.9c-3.4-19.8 6.9-40.5 16.6-52.9l4.5 13.4 15.9 47-12.8-47.6-3.6-13.2c13.3 5.2 29.9 15 38.1 30.4 0.4 2.4 0.6 5 0.7 7.7 0.9 23.1-7.1 54.9-15.9 65.7-12-4.3-29.3-24-39.7-42.8-1.4-2.6-2.7-5.2-3.8-7.7z"/>+ <path class="r3" d="m114.2 196.5c-0.7-18 8.6-35.9 17.3-47.1l15.9 47-12.8-47.6c11.6 4.4 26.1 12.4 35.2 24.8 0.9 23.1-7.1 54.9-15.9 65.7-12-4.3-29.3-24-39.7-42.8z"/>+ </g>+ </svg>+ <div class="wordmark">Trilium <span class="word-notes">Notes</span><span class="nightly-badge">NIGHTLY</span></div>+ <div class="status">+ <span>Installing</span>+ <span class="dots"><span class="dot d1"></span><span class="dot d2"></span><span class="dot d3"></span></span>+ </div>+</div>+<script>+ const stage = document.getElementById("stage");+ const params = new URLSearchParams(location.search);+ stage.classList.add(params.get("variant") === "nightly" ? "variant-nightly" : "variant-stable");++ // Timeline (seconds). The loop is TOTAL_FRAMES / FPS long; DOT_CYCLE must divide+ // it evenly so the pulse is continuous across the GIF loop point.+ const FPS = 10;+ const TOTAL_FRAMES = 36;+ const LEAF_STARTS = { green: 0, orange: 0.25, red: 0.5 };+ const LEAF_DURATION = 0.4;+ const TEXT_START = 0.7;+ const TEXT_DURATION = 0.35;+ const DOT_CYCLE = 1.2;+ const DOT_DELAYS = [0, 0.2, 0.4];++ function clamp01(x) {+ return Math.min(1, Math.max(0, x));+ }++ function easeOutCubic(p) {+ return 1 - Math.pow(1 - p, 3);+ }++ // Overshoots slightly above 1 near the end, giving the leaves a small pop.+ function easeOutBack(p) {+ const c1 = 1.70158;+ const c3 = c1 + 1;+ return 1 + c3 * Math.pow(p - 1, 3) + c1 * Math.pow(p - 1, 2);+ }++ function setLeaf(selector, t, start) {+ const p = clamp01((t - start) / LEAF_DURATION);+ const leaf = stage.querySelector(selector);+ leaf.style.opacity = String(easeOutCubic(p));+ const scale = 0.62 + 0.38 * easeOutBack(p);+ const rotation = -8 * (1 - easeOutCubic(p));+ leaf.style.transform = `scale(${scale}) rotate(${rotation}deg)`;+ }++ function renderFrame(frame) {+ const t = frame / FPS;++ setLeaf(".leaf-green", t, LEAF_STARTS.green);+ setLeaf(".leaf-orange", t, LEAF_STARTS.orange);+ setLeaf(".leaf-red", t, LEAF_STARTS.red);++ const textProgress = easeOutCubic(clamp01((t - TEXT_START) / TEXT_DURATION));+ for (const selector of [".wordmark", ".status"]) {+ const el = stage.querySelector(selector);+ el.style.opacity = String(textProgress);+ el.style.transform = `translateY(${8 * (1 - textProgress)}px)`;+ }++ for (const [i, delay] of DOT_DELAYS.entries()) {+ const phase = (((t - delay) % DOT_CYCLE) + DOT_CYCLE) % DOT_CYCLE / DOT_CYCLE;+ const pulse = 0.5 - 0.5 * Math.cos(2 * Math.PI * phase);+ const dot = stage.querySelector(`.dot.d${i + 1}`);+ dot.style.opacity = String(0.25 + 0.75 * pulse);+ dot.style.transform = `scale(${0.8 + 0.2 * pulse})`;+ }+ }++ window.SPLASH_TIMELINE = { fps: FPS, totalFrames: TOTAL_FRAMES };+ window.renderFrame = renderFrame;++ // When opened directly in a browser, show the settled state.+ renderFrame(TOTAL_FRAMES - 1);+</script>+</body>+</html>diff --git a/apps/desktop/electron-forge/setup-icon/setup-banner-dev.gif b/apps/desktop/electron-forge/setup-icon/setup-banner-dev.gifindex 1dd5984245..eec34c49fc 100644Binary files a/apps/desktop/electron-forge/setup-icon/setup-banner-dev.gif and b/apps/desktop/electron-forge/setup-icon/setup-banner-dev.gif differdiff --git a/apps/desktop/electron-forge/setup-icon/setup-banner.gif b/apps/desktop/electron-forge/setup-icon/setup-banner.gifindex dc442eeb50..41c90f27d2 100644Binary files a/apps/desktop/electron-forge/setup-icon/setup-banner.gif and b/apps/desktop/electron-forge/setup-icon/setup-banner.gif differdiff --git a/apps/desktop/package.json b/apps/desktop/package.jsonindex 3b9832dd9c..306825d567 100644--- a/apps/desktop/package.json+++ b/apps/desktop/package.json@@ -21,6 +21,7 @@"electron-forge:package": "pnpm build && electron-forge package dist","electron-forge:start": "pnpm build && electron-forge start dist","e2e": "pnpm build && cross-env TRILIUM_INTEGRATION_TEST=memory-no-store TRILIUM_PORT=8082 TRILIUM_DATA_DIR=data-e2e TRILIUM_ELECTRON_DATA_DIR=data-e2e-electron-8082 ELECTRON_IS_DEV=0 playwright test",+ "generate-setup-banners": "tsx electron-forge/setup-icon/generate/generate.mts","test": "vitest --config vitest.config.mts"},"dependencies": {@@ -45,8 +46,11 @@"@triliumnext/core": "workspace:*","@triliumnext/server": "workspace:*","@types/electron-squirrel-startup": "1.0.2",+ "@types/pngjs": "6.0.5","electron": "42.6.0",+ "gifenc": "1.0.3","node-mocks-http": "1.17.2",+ "pngjs": "7.0.0","prebuild-install": "7.1.3"}}\ No newline at end of filediff --git a/apps/desktop/tsconfig.forge.json b/apps/desktop/tsconfig.forge.jsonindex 310a0ee6fd..e4dafd7cd0 100644--- a/apps/desktop/tsconfig.forge.json+++ b/apps/desktop/tsconfig.forge.json@@ -13,6 +13,7 @@},"include": ["**/*.ts",+ "electron-forge/**/*.mts","../server/src/*.d.ts","package.json"],diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex d30a6d1af0..e468ac2c42 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -500,12 +500,21 @@ importers:'@types/electron-squirrel-startup':specifier: 1.0.2version: 1.0.2+ '@types/pngjs':+ specifier: 6.0.5+ version: 6.0.5electron:specifier: 42.6.0version: 42.6.0+ gifenc:+ specifier: 1.0.3+ version: 1.0.3node-mocks-http:specifier: 1.17.2version: 1.17.2(@types/[email protected])(@types/[email protected])+ pngjs:+ specifier: 7.0.0+ version: 7.0.0prebuild-install:specifier: 7.1.3version: 7.1.3@@ -5726,6 +5735,9 @@ packages:'@types/[email protected]':resolution: {integrity: sha512-fRa09kZTgu8o71KFcDjUFuc7F+dEbZYZmkI0mg5YBTRs0yMKjYHsq/c0urDKeDb+D5qVgXOdFcuu+DZPKOITwA==}+ '@types/[email protected]':+ resolution: {integrity: sha512-0k5eKfrA83JOZPppLtS2C7OUtyNAl2wKNxfyYl9Q5g9lPkgBl/9hNyAu6HuEH2J4XmIv2znEpkDd0SaZVxW6iQ==}+'@types/[email protected]':resolution: {integrity: sha512-GZHUBZR9hckSUhrxmp1nG6NwdpM9fCunJwyThLW1X3AyHgd9IlHb6VANpQQqDr2o/qQp6McZ3y/IA2rVzKzSbw==}@@ -9060,6 +9072,9 @@ packages:resolution: {integrity: sha512-b1O07XYq8eRuVzBNgJLstU6FYc1tS6wnMtF1I1D9lE8LxZSOGZ7LhxN54yPP6mGw5f2CkXY2BQUL9Fx41qvcIg==}engines: {node: '>= 14'}+ resolution: {integrity: sha512-xdr6AdrfGBcfzncONUOlXMBuc5wJDtOueE3c5rdG0oNgtINLD+f2iFZltrBRZYzACRbKr+mSVU/x98zv2u3jmw==}+resolution: {integrity: sha512-2760b1vpJHNmLzZ/ubTtNnEx5WApN/PYWJvXvgS+tL1egTTthayFYIQQNi136FLEDcN/IyEY2EcGpIITD6eYUw==}@@ -18416,7 +18431,7 @@ snapshots:'@types/[email protected]':dependencies:'@types/connect': 3.4.38- '@types/node': 24.13.1+ '@types/node': 24.13.2'@types/[email protected]':dependencies:@@ -18608,7 +18623,7 @@ snapshots:'@types/[email protected]':dependencies:- '@types/node': 24.13.1+ '@types/node': 24.13.2'@types/qs': 6.15.1'@types/range-parser': 1.2.7'@types/send': 1.2.1@@ -18718,6 +18733,10 @@ snapshots:dependencies:undici-types: 7.18.2+ '@types/[email protected]':+ dependencies:+ '@types/node': 24.13.2+'@types/[email protected]': {}'@types/[email protected]': {}@@ -23616,6 +23635,8 @@ snapshots:transitivePeerDependencies:- supports-color+ [email protected]: {}+dependencies:image-q: 4.0.0