From 86912c193945ae3bc0f4ee034466cc8995fac839 Mon Sep 17 00:00:00 2001 From: Steven Vandevelde Date: Mon, 30 Mar 2026 23:22:24 +0200 Subject: [PATCH] chore: improve facet loading --- src/common/foundation.js | 14 ++++++++++++++ src/facets/connect/atproto/index.html | 5 ----- src/facets/connect/atproto/index.inline.js | 7 ++++++- src/facets/connect/common.css | 8 -------- src/facets/connect/https/index.html | 5 ----- src/facets/connect/https/index.inline.js | 7 ++++++- src/facets/connect/icecast/index.html | 5 ----- src/facets/connect/icecast/index.inline.js | 7 ++++++- src/facets/connect/index.html | 5 ----- src/facets/connect/index.inline.js | 6 ++++++ src/facets/connect/local/index.html | 5 ----- src/facets/connect/local/index.inline.js | 7 ++++++- src/facets/connect/opensubsonic/index.html | 5 ----- src/facets/connect/opensubsonic/index.inline.js | 7 ++++++- src/facets/connect/s3/index.html | 5 ----- src/facets/connect/s3/index.inline.js | 7 ++++++- src/facets/data/export-import/index.html | 8 -------- src/facets/data/export-import/index.inline.js | 12 +++++++----- src/facets/data/process-tracks/index.html | 9 --------- src/facets/data/process-tracks/index.inline.js | 7 ++++++- src/facets/data/v3-import/index.html | 8 -------- src/facets/data/v3-import/index.inline.js | 7 ++++++- .../examples/generate-playlist/index.inline.js | 6 ++++++ src/facets/examples/now-playing/index.inline.js | 6 ++++++ src/facets/misc/scrobble/last.fm/index.html | 15 --------------- src/facets/misc/scrobble/last.fm/index.inline.js | 6 ++++++ src/facets/misc/split-view/index.inline.js | 6 ++++++ src/facets/playback/auto-queue/index.html | 8 -------- src/facets/playback/auto-queue/index.inline.js | 11 +++++++---- src/l/index.vto | 10 +++++----- src/styles/loader.css | 9 +++++++++ .../blur/artwork-controller/facet/index.inline.js | 6 ++++++ src/themes/winamp/browser/facet/index.html | 9 --------- src/themes/winamp/browser/facet/index.inline.js | 10 ++++++---- src/themes/winamp/facet/index.html | 9 --------- src/themes/winamp/facet/index.inline.js | 10 ++++++---- 36 files changed, 138 insertions(+), 139 deletions(-) diff --git a/src/common/foundation.js b/src/common/foundation.js index 61c96e70..67ecf8f8 100644 --- a/src/common/foundation.js +++ b/src/common/foundation.js @@ -176,7 +176,21 @@ export const config = { */ setup: ({ title }) => { document.title = title; + }, + + /** + * Hide the loader and fade in the facet content by adding the `has-loaded` + * class to `#container` after two animation frames (so the initial opacity:0 + * is painted first and the CSS transition actually runs). + */ + ready: () => { config.hideLoader(); + + requestAnimationFrame(() => { + requestAnimationFrame(() => { + document.querySelector("#container")?.classList.add("has-loaded"); + }); + }); }, }; diff --git a/src/facets/connect/atproto/index.html b/src/facets/connect/atproto/index.html index 89ae5f55..73a40a7a 100644 --- a/src/facets/connect/atproto/index.html +++ b/src/facets/connect/atproto/index.html @@ -8,8 +8,3 @@
- - diff --git a/src/facets/connect/atproto/index.inline.js b/src/facets/connect/atproto/index.inline.js index 2bb5e228..a186e820 100644 --- a/src/facets/connect/atproto/index.inline.js +++ b/src/facets/connect/atproto/index.inline.js @@ -204,7 +204,6 @@ if (atprotoPasskeyEl) { ); }); } - //////////////////////////////////////////// // ACTIONS //////////////////////////////////////////// @@ -257,3 +256,9 @@ async function handlePasskeyRemove() { $passkeyError.value = null; await atprotoPasskeyEl.removePasskey(); } + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/facets/connect/common.css b/src/facets/connect/common.css index 3cd7bf21..54a52250 100644 --- a/src/facets/connect/common.css +++ b/src/facets/connect/common.css @@ -3,15 +3,7 @@ main { align-items: center; justify-content: center; min-height: 100dvh; - opacity: 0; padding: var(--wa-space-m); - pointer-events: none; - transition: opacity 750ms; - - &.has-loaded { - opacity: 1; - pointer-events: auto; - } } wa-card { diff --git a/src/facets/connect/https/index.html b/src/facets/connect/https/index.html index 39022ca4..560cd9e1 100644 --- a/src/facets/connect/https/index.html +++ b/src/facets/connect/https/index.html @@ -8,8 +8,3 @@
- - diff --git a/src/facets/connect/https/index.inline.js b/src/facets/connect/https/index.inline.js index 92aa5a92..8515619e 100644 --- a/src/facets/connect/https/index.inline.js +++ b/src/facets/connect/https/index.inline.js @@ -82,7 +82,6 @@ effect(() => { }), ); }); - //////////////////////////////////////////// // ACTIONS //////////////////////////////////////////// @@ -123,3 +122,9 @@ async function addUrl() { }, ]); } + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/facets/connect/icecast/index.html b/src/facets/connect/icecast/index.html index 940821e6..6d78971d 100644 --- a/src/facets/connect/icecast/index.html +++ b/src/facets/connect/icecast/index.html @@ -8,8 +8,3 @@
- - diff --git a/src/facets/connect/icecast/index.inline.js b/src/facets/connect/icecast/index.inline.js index 5be5fa77..b92b688b 100644 --- a/src/facets/connect/icecast/index.inline.js +++ b/src/facets/connect/icecast/index.inline.js @@ -83,7 +83,6 @@ effect(() => { }), ); }); - //////////////////////////////////////////// // ACTIONS //////////////////////////////////////////// @@ -125,3 +124,9 @@ async function addStream() { }, ]); } + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/facets/connect/index.html b/src/facets/connect/index.html index dc302fda..2a11fd69 100644 --- a/src/facets/connect/index.html +++ b/src/facets/connect/index.html @@ -25,8 +25,3 @@
- - diff --git a/src/facets/connect/index.inline.js b/src/facets/connect/index.inline.js index f7653629..3efaa4fa 100644 --- a/src/facets/connect/index.inline.js +++ b/src/facets/connect/index.inline.js @@ -78,3 +78,9 @@ litRender( `, main, ); + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/facets/connect/local/index.html b/src/facets/connect/local/index.html index 90120042..81ffbc2e 100644 --- a/src/facets/connect/local/index.html +++ b/src/facets/connect/local/index.html @@ -8,8 +8,3 @@
- - diff --git a/src/facets/connect/local/index.inline.js b/src/facets/connect/local/index.inline.js index d376d0f2..831a7acc 100644 --- a/src/facets/connect/local/index.inline.js +++ b/src/facets/connect/local/index.inline.js @@ -176,7 +176,6 @@ effect(() => { })), ); }); - //////////////////////////////////////////// // ACTIONS //////////////////////////////////////////// @@ -375,3 +374,9 @@ async function readDirectoryEntry(dir) { readBatch(); }); } + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/facets/connect/opensubsonic/index.html b/src/facets/connect/opensubsonic/index.html index bf332533..d7a6f669 100644 --- a/src/facets/connect/opensubsonic/index.html +++ b/src/facets/connect/opensubsonic/index.html @@ -8,8 +8,3 @@
- - diff --git a/src/facets/connect/opensubsonic/index.inline.js b/src/facets/connect/opensubsonic/index.inline.js index 9cbfc8cc..daa51a9c 100644 --- a/src/facets/connect/opensubsonic/index.inline.js +++ b/src/facets/connect/opensubsonic/index.inline.js @@ -120,7 +120,6 @@ effect(() => { })), ); }); - //////////////////////////////////////////// // ACTIONS //////////////////////////////////////////// @@ -170,3 +169,9 @@ async function addServer() { }, ]); } + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/facets/connect/s3/index.html b/src/facets/connect/s3/index.html index 38aeb7d4..936da497 100644 --- a/src/facets/connect/s3/index.html +++ b/src/facets/connect/s3/index.html @@ -8,8 +8,3 @@
- - diff --git a/src/facets/connect/s3/index.inline.js b/src/facets/connect/s3/index.inline.js index 95a6a255..d395533d 100644 --- a/src/facets/connect/s3/index.inline.js +++ b/src/facets/connect/s3/index.inline.js @@ -161,7 +161,6 @@ effect(() => { })), ); }); - //////////////////////////////////////////// // ACTIONS //////////////////////////////////////////// @@ -232,3 +231,9 @@ async function addBucket(mode) { await outputOrchestrator.select(OUTPUT_S3_ID); } } + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/facets/data/export-import/index.html b/src/facets/data/export-import/index.html index 5303585b..630e387c 100644 --- a/src/facets/data/export-import/index.html +++ b/src/facets/data/export-import/index.html @@ -50,15 +50,7 @@ } main { - opacity: 0; padding: var(--space-md); - pointer-events: none; - transition: opacity 750ms; - - &.has-loaded { - opacity: 1; - pointer-events: auto; - } } p { diff --git a/src/facets/data/export-import/index.inline.js b/src/facets/data/export-import/index.inline.js index 7133ae49..f0dc2cf0 100644 --- a/src/facets/data/export-import/index.inline.js +++ b/src/facets/data/export-import/index.inline.js @@ -5,11 +5,8 @@ import { effect } from "~/common/signal.js"; // Set doc title foundation.setup({ title: "Export & Import | Diffuse" }); -// Doc loader -const main = /** @type {HTMLElement} */ (document.querySelector("main")); -main.classList.add("has-loaded"); - // Setup +const main = /** @type {HTMLElement} */ (document.querySelector("main")); const output = await foundation.orchestrator.output(); // Elements @@ -140,7 +137,6 @@ importPlaylistItemsBtn.onclick = async () => { showStatus(`Import failed: ${/** @type {Error} */ (err).message}`, "error"); } }; - // Import facets importFacetsBtn.onclick = async () => { /** @type {any[]} */ @@ -155,3 +151,9 @@ importFacetsBtn.onclick = async () => { showStatus(`Import failed: ${/** @type {Error} */ (err).message}`, "error"); } }; + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/facets/data/process-tracks/index.html b/src/facets/data/process-tracks/index.html index 94a91c60..96e39b08 100644 --- a/src/facets/data/process-tracks/index.html +++ b/src/facets/data/process-tracks/index.html @@ -24,15 +24,6 @@ @import "./themes/winamp/98-vars.css"; @import "./themes/winamp/98-extra.css"; - main { - opacity: 0; - pointer-events: none; - - &.has-loaded { - opacity: 1; - pointer-events: auto; - } - } diff --git a/src/facets/data/process-tracks/index.inline.js b/src/facets/data/process-tracks/index.inline.js index 9fc71495..597b82df 100644 --- a/src/facets/data/process-tracks/index.inline.js +++ b/src/facets/data/process-tracks/index.inline.js @@ -6,7 +6,6 @@ import foundation from "~/common/foundation.js"; foundation.setup({ title: "Process Tracks | Diffuse" }); const main = /** @type {HTMLElement} */ (document.querySelector("main")); -main.classList.add("has-loaded"); const orchestrator = await foundation.orchestrator.processTracks({ disableWhenReady: true, @@ -76,3 +75,9 @@ effect(() => { /** @type {HTMLElement} */ (placeholder), ); }); + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/facets/data/v3-import/index.html b/src/facets/data/v3-import/index.html index dcd06b43..831f3c7d 100644 --- a/src/facets/data/v3-import/index.html +++ b/src/facets/data/v3-import/index.html @@ -40,15 +40,7 @@ } main { - opacity: 0; padding: var(--space-md); - pointer-events: none; - transition: opacity 750ms; - - &.has-loaded { - opacity: 1; - pointer-events: auto; - } } p { diff --git a/src/facets/data/v3-import/index.inline.js b/src/facets/data/v3-import/index.inline.js index e3b6ac4e..19f292f8 100644 --- a/src/facets/data/v3-import/index.inline.js +++ b/src/facets/data/v3-import/index.inline.js @@ -4,7 +4,6 @@ import foundation from "~/common/foundation.js"; foundation.setup({ title: "V3.x Import | Diffuse" }); const main = /** @type {HTMLElement} */ (document.querySelector("main")); -main.classList.add("has-loaded"); /** * @import {PlaylistItem, Track} from "~/definitions/types.d.ts" @@ -164,3 +163,9 @@ importPlaylistItemsBtn.onclick = async () => { showStatus(`Import failed: ${/** @type {Error} */ (err).message}`, "error"); } }; + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/facets/examples/generate-playlist/index.inline.js b/src/facets/examples/generate-playlist/index.inline.js index 78029378..59e895da 100644 --- a/src/facets/examples/generate-playlist/index.inline.js +++ b/src/facets/examples/generate-playlist/index.inline.js @@ -39,3 +39,9 @@ function generatePlaylist() { .onclick = () => { generatePlaylist(); }; + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/facets/examples/now-playing/index.inline.js b/src/facets/examples/now-playing/index.inline.js index 1625cac7..0e189d9c 100644 --- a/src/facets/examples/now-playing/index.inline.js +++ b/src/facets/examples/now-playing/index.inline.js @@ -35,3 +35,9 @@ effect(() => { .onclick = () => { queue.shift(); }; + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/facets/misc/scrobble/last.fm/index.html b/src/facets/misc/scrobble/last.fm/index.html index afd5a8bb..2d7c2900 100644 --- a/src/facets/misc/scrobble/last.fm/index.html +++ b/src/facets/misc/scrobble/last.fm/index.html @@ -11,16 +11,6 @@ margin: 0; } - main { - opacity: 0; - pointer-events: none; - transition: opacity 750ms; - - &.has-loaded { - opacity: 1; - pointer-events: auto; - } - } wa-card { width: min(360px, calc(100vw - 2rem)); @@ -104,8 +94,3 @@ - - diff --git a/src/facets/misc/scrobble/last.fm/index.inline.js b/src/facets/misc/scrobble/last.fm/index.inline.js index e469092a..38e7c9a1 100644 --- a/src/facets/misc/scrobble/last.fm/index.inline.js +++ b/src/facets/misc/scrobble/last.fm/index.inline.js @@ -164,3 +164,9 @@ resetCredsBtn.onclick = () => { apiKeyInput.value = ""; apiSecretInput.value = ""; }; + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/facets/misc/split-view/index.inline.js b/src/facets/misc/split-view/index.inline.js index 4273a825..f36b3154 100644 --- a/src/facets/misc/split-view/index.inline.js +++ b/src/facets/misc/split-view/index.inline.js @@ -448,3 +448,9 @@ async function saveSimplifiedCopy() { // ─── Init ───────────────────────────────────────────────────────────────────── render(); + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/facets/playback/auto-queue/index.html b/src/facets/playback/auto-queue/index.html index 2bb806b4..73a73da7 100644 --- a/src/facets/playback/auto-queue/index.html +++ b/src/facets/playback/auto-queue/index.html @@ -56,15 +56,7 @@ } main { - opacity: 0; padding: var(--space-md); - pointer-events: none; - transition: opacity 750ms; - - &.has-loaded { - opacity: 1; - pointer-events: auto; - } } label { diff --git a/src/facets/playback/auto-queue/index.inline.js b/src/facets/playback/auto-queue/index.inline.js index 737f7dc6..d07c34ae 100644 --- a/src/facets/playback/auto-queue/index.inline.js +++ b/src/facets/playback/auto-queue/index.inline.js @@ -7,11 +7,8 @@ const ACTIVE_CLASS = "button--active"; // Set doc title foundation.setup({ title: "Automatic Queue | Diffuse" }); -// Doc load -const main = /** @type {HTMLElement} */ (document.querySelector("main")); -main.classList.add("has-loaded"); - // Setup +const main = /** @type {HTMLElement} */ (document.querySelector("main")); await foundation.orchestrator.autoQueue(); const [repeatShuffle, scope, output] = await Promise.all([ @@ -135,3 +132,9 @@ sortDirectionBtn.onclick = () => { const dir = scope.sortDirection() ?? "desc"; scope.setSortDirection(dir === "asc" ? "desc" : "asc"); }; + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/l/index.vto b/src/l/index.vto index 05286b7e..e4f1ff33 100644 --- a/src/l/index.vto +++ b/src/l/index.vto @@ -9,10 +9,10 @@ scripts: - l/index.js --- -
-
-
- -
+
+
+
+ +
diff --git a/src/styles/loader.css b/src/styles/loader.css index 713526cd..623dfa66 100644 --- a/src/styles/loader.css +++ b/src/styles/loader.css @@ -10,6 +10,15 @@ body { color: var(--text-color); } +#container { + opacity: 0; + transition: opacity 750ms; + + &.has-loaded { + opacity: 1; + } +} + @scope (.diffuse) { :scope { color: var(--text-color); diff --git a/src/themes/blur/artwork-controller/facet/index.inline.js b/src/themes/blur/artwork-controller/facet/index.inline.js index 68c1e0d8..72985467 100644 --- a/src/themes/blur/artwork-controller/facet/index.inline.js +++ b/src/themes/blur/artwork-controller/facet/index.inline.js @@ -24,3 +24,9 @@ dac.setAttribute("favourites-orchestrator-selector", fav.selector); // Add to DOM (document.querySelector("#container") ?? document.body).append(dac); + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/themes/winamp/browser/facet/index.html b/src/themes/winamp/browser/facet/index.html index f32c27ef..69a65bc4 100644 --- a/src/themes/winamp/browser/facet/index.html +++ b/src/themes/winamp/browser/facet/index.html @@ -18,15 +18,6 @@ @import "./themes/winamp/facet.css"; @import "./vendor/98.css"; - .window { - opacity: 0; - pointer-events: none; - - &.has-loaded { - opacity: 1; - pointer-events: auto; - } - } diff --git a/src/themes/winamp/browser/facet/index.inline.js b/src/themes/winamp/browser/facet/index.inline.js index 13c47945..d68b1378 100644 --- a/src/themes/winamp/browser/facet/index.inline.js +++ b/src/themes/winamp/browser/facet/index.inline.js @@ -4,10 +4,6 @@ import BrowserElement from "~/themes/winamp/browser/element.js"; // Set doc title foundation.setup({ title: "Browser | Winamp | Diffuse" }); -// Doc loader -const window = /** @type {HTMLElement} */ (document.querySelector(".window")); -window.classList.add("has-loaded"); - const [out, que, scp, trc] = await Promise.all([ foundation.orchestrator.output(), foundation.engine.queue(), @@ -22,3 +18,9 @@ el.setAttribute("scope-engine-selector", scp.selector); el.setAttribute("tracks-selector", trc.selector); document.querySelector("#placeholder")?.replaceWith(el); + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); diff --git a/src/themes/winamp/facet/index.html b/src/themes/winamp/facet/index.html index 6f599a5b..96f25c2f 100644 --- a/src/themes/winamp/facet/index.html +++ b/src/themes/winamp/facet/index.html @@ -7,15 +7,6 @@ background-size: cover; }*/ - main { - opacity: 0; - pointer-events: none; - - &.has-loaded { - opacity: 1; - pointer-events: auto; - } - }
diff --git a/src/themes/winamp/facet/index.inline.js b/src/themes/winamp/facet/index.inline.js index e4aeac27..8337cce1 100644 --- a/src/themes/winamp/facet/index.inline.js +++ b/src/themes/winamp/facet/index.inline.js @@ -6,10 +6,6 @@ import WindowManager from "~/themes/winamp/window-manager/element.js"; // Set doc title foundation.setup({ title: "Winamp | Diffuse" }); -// Doc loader -const main = /** @type {HTMLElement} */ (document.querySelector("main")); -main.classList.add("has-loaded"); - /** * @import {OutputElement} from "~/components/output/types.d.ts" */ @@ -101,3 +97,9 @@ function windowManager() { if (w instanceof WindowManager) return w; return null; } + +//////////////////////////////////////////// +// 🚀 +//////////////////////////////////////////// + +foundation.ready(); -- knotmirror 0.0.1