Compare commits

...
7 Commits
Author SHA1 Message Date
HorizonCode 51f5fa3e46 fix(themes): enforce strict semver versions
Require SemVer 2.0.0 when saving, validating, or publishing a theme, and validate again at the workshop upload boundary. This rejects partial versions, v-prefixed versions, leading-zero components, and arbitrary strings while preserving valid prerelease and build metadata.
2026-11-04 00:00:07 +01:00
HorizonCode 07cbfa39a6 fix(themes): require a newer version for each publish
Compare the proposed version with the version currently published in the workshop before opening the publish dialog and again before upload. Reject invalid semver, duplicate versions, and downgrades, while tracking the just-submitted version in-session so pending updates cannot be published twice.
2026-11-03 23:54:02 +01:00
HorizonCode 11aefee7ed feat(themes): persist publisher id in theme manifests
Publishing now stamps the signed-in EZPPFarm user ID into theme.json and saves it before packaging, so installed theme cards can resolve avatars by stable user ID. Older manifests keep the author-name fallback.
2026-11-03 23:45:00 +01:00
HorizonCode 5eea428802 fix(themes): show author avatars on installed theme cards
Installed theme cards rendered only an initial because their manifests store the author name, not an avatar URL. Use the EZPPFarm avatar endpoint with the author name and keep the initial as the image-load fallback, matching the community workshop presentation.
2026-11-03 23:39:25 +01:00
HorizonCode 760bd9a283 refactor(themes): align installed cards with the workshop layout
Installed theme cards now use the same visual hierarchy as workshop cards: status and API badges at the top, version on the preview, an author strip over the artwork, a compact title and description, and a footer with status plus compact actions. This removes the oversized primary button and duplicate version/author rows.
2026-11-03 23:13:44 +01:00
HorizonCode 47c022642f feat(themes): polish installed cards and add workshop theme details
Installed themes now use a 16:9 preview with stable card spacing and a single overflow menu for edit, restore, update, report and uninstall actions. Community theme previews and titles open a large detail dialog with a full-size preview, metadata, tags, review status and the relevant install action.
2026-11-03 23:08:35 +01:00
HorizonCode 5613c3be25 fix(workshop): make moderation and install flows production ready
Replace the remaining native prompt and confirm calls with an in-app action dialog, including focus handling and inline errors. Guard likes and concurrent moderation loads, surface stale-data errors, paginate the review queue, and keep load-more state local to each list. Allow the packaged app to reach the workshop host for API calls and previews.
2026-11-03 22:55:18 +01:00
7 changed files with 1494 additions and 385 deletions

No files matched your search

+2 -2
View File
@@ -32,8 +32,8 @@
"script-src": "'self' 'unsafe-inline' 'unsafe-eval' asset: http://asset.localhost https://asset.localhost http://127.0.0.1:* https://analytics.ez-pp.farm", "script-src": "'self' 'unsafe-inline' 'unsafe-eval' asset: http://asset.localhost https://asset.localhost http://127.0.0.1:* https://analytics.ez-pp.farm",
"worker-src": ["'self'", "blob:"], "worker-src": ["'self'", "blob:"],
"style-src": "'self' 'unsafe-inline' asset: http://asset.localhost https://asset.localhost http://127.0.0.1:*", "style-src": "'self' 'unsafe-inline' asset: http://asset.localhost https://asset.localhost http://127.0.0.1:*",
"img-src": "'self' asset: http://asset.localhost https://asset.localhost blob: data: http://127.0.0.1:* https://assets.ppy.sh https://a.ez-pp.farm https://git.ez-pp.farm https://osu.direct", "img-src": "'self' asset: http://asset.localhost https://asset.localhost blob: data: http://127.0.0.1:* https://assets.ppy.sh https://a.ez-pp.farm https://git.ez-pp.farm https://osu.direct https://themes.ez-pp.farm",
"connect-src": "'self' ipc: http://ipc.localhost asset: http://asset.localhost https://asset.localhost http://127.0.0.1:* https://ez-pp.farm https://api.ez-pp.farm https://c.ez-pp.farm https://analytics.ez-pp.farm https://git.ez-pp.farm https://osu.direct https://osu.ppy.sh https://api.fontsource.org https://cdn.jsdelivr.net", "connect-src": "'self' ipc: http://ipc.localhost asset: http://asset.localhost https://asset.localhost http://127.0.0.1:* https://ez-pp.farm https://api.ez-pp.farm https://c.ez-pp.farm https://analytics.ez-pp.farm https://git.ez-pp.farm https://osu.direct https://osu.ppy.sh https://api.fontsource.org https://cdn.jsdelivr.net https://themes.ez-pp.farm",
"media-src": "'self' asset: http://asset.localhost https://asset.localhost http://127.0.0.1:* blob:", "media-src": "'self' asset: http://asset.localhost https://asset.localhost http://127.0.0.1:* blob:",
"font-src": [ "font-src": [
"'self'", "'self'",
+9 -1
View File
@@ -1,4 +1,5 @@
import { config } from './config'; import { config } from './config';
import { normalizeThemeVersion } from './themeV2';
import { import {
reloadThemes, reloadThemes,
themesDirectory, themesDirectory,
@@ -727,6 +728,13 @@ export async function publishThemeToWorkshop(options: {
throw new Error('You must be logged in to EZPPFarm to publish themes.'); throw new Error('You must be logged in to EZPPFarm to publish themes.');
} }
const version = normalizeThemeVersion(options.version ?? '1.0.0');
if (!version) {
throw new Error(
'Theme version must use semantic versioning, for example 1.2.3 or 1.2.3-beta.1.'
);
}
onProgress('Packaging theme archive...', 5); onProgress('Packaging theme archive...', 5);
const baseThemesDir = await themesDirectory(); const baseThemesDir = await themesDirectory();
@@ -771,7 +779,7 @@ export async function publishThemeToWorkshop(options: {
themeId: options.workshopId || options.themeId, themeId: options.workshopId || options.themeId,
name: options.name, name: options.name,
description: options.description || '', description: options.description || '',
version: options.version || '1.0.0', version,
apiVersion: options.apiVersion || '2.0.0', apiVersion: options.apiVersion || '2.0.0',
totalSize, totalSize,
totalChunks, totalChunks,
File diff suppressed because it is too large. Load diff
+118 -13
View File
@@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import Logo from '$assets/logo.png'; import Logo from '$assets/logo.png';
import { publishThemeToWorkshop } from '$lib/communityThemes'; import { fetchCommunityThemeDetails, publishThemeToWorkshop } from '$lib/communityThemes';
import FontPreview from '$lib/components/theme/FontPreview.svelte'; import FontPreview from '$lib/components/theme/FontPreview.svelte';
import ThemeBehaviorInspector from '$lib/components/theme/ThemeBehaviorInspector.svelte'; import ThemeBehaviorInspector from '$lib/components/theme/ThemeBehaviorInspector.svelte';
import ThemeElementInspector from '$lib/components/theme/ThemeElementInspector.svelte'; import ThemeElementInspector from '$lib/components/theme/ThemeElementInspector.svelte';
@@ -75,6 +75,7 @@
normalizeChrome, normalizeChrome,
normalizeThemeTags, normalizeThemeTags,
normalizeThemeV2, normalizeThemeV2,
normalizeThemeVersion,
themeAssetName, themeAssetName,
themeHasLaunchButton, themeHasLaunchButton,
type ThemeV2Asset, type ThemeV2Asset,
@@ -173,6 +174,7 @@
import { getCurrentWindow } from '@tauri-apps/api/window'; import { getCurrentWindow } from '@tauri-apps/api/window';
import { open, save as saveDialog } from '@tauri-apps/plugin-dialog'; import { open, save as saveDialog } from '@tauri-apps/plugin-dialog';
import * as fs from '@tauri-apps/plugin-fs'; import * as fs from '@tauri-apps/plugin-fs';
import semver from 'semver';
import { sileo } from 'sileo'; import { sileo } from 'sileo';
import { onMount, tick } from 'svelte'; import { onMount, tick } from 'svelte';
import { SvelteMap, SvelteSet } from 'svelte/reactivity'; import { SvelteMap, SvelteSet } from 'svelte/reactivity';
@@ -287,6 +289,7 @@
let panStart = { x: 0, y: 0, panX: 0, panY: 0 }; let panStart = { x: 0, y: 0, panX: 0, panY: 0 };
const canvasScale = $derived(canvasFitScale * canvasZoom); const canvasScale = $derived(canvasFitScale * canvasZoom);
let statusMessage = $state('Ready'); let statusMessage = $state('Ready');
let lastPublishedVersion = $state<string | undefined>(undefined);
let renamingId = $state<string | undefined>(undefined); let renamingId = $state<string | undefined>(undefined);
let draggingLayer = $state<LayerDragItem | undefined>(undefined); let draggingLayer = $state<LayerDragItem | undefined>(undefined);
let dropTarget = $state<LayerDropTarget | undefined>(undefined); let dropTarget = $state<LayerDropTarget | undefined>(undefined);
@@ -1803,6 +1806,7 @@
async function loadContext() { async function loadContext() {
loading = true; loading = true;
lastPublishedVersion = undefined;
try { try {
const context = await invoke<ThemeEditorContext>('theme_editor_context'); const context = await invoke<ThemeEditorContext>('theme_editor_context');
const parsed = context.themeJson const parsed = context.themeJson
@@ -2920,6 +2924,12 @@
notifyError('Add an author name so people know who made the theme.'); notifyError('Add an author name so people know who made the theme.');
return false; return false;
} }
const version = normalizeThemeVersion(definition.version);
if (!version) {
notifyError('The version must use semantic versioning, for example 1.2.3 or 1.2.3-beta.1.');
return false;
}
if (definition.version !== version) definition.version = version;
const folderName = savedFolder ?? toSafeName(definition.name); const folderName = savedFolder ?? toSafeName(definition.name);
if (!folderName.replace(/_/g, '')) { if (!folderName.replace(/_/g, '')) {
notifyError('The theme name needs at least one letter or number.'); notifyError('The theme name needs at least one letter or number.');
@@ -3016,8 +3026,10 @@
if (!definition.name.trim()) error('The theme needs a name.'); if (!definition.name.trim()) error('The theme needs a name.');
if (!definition.author.trim()) error('The theme needs an author.'); if (!definition.author.trim()) error('The theme needs an author.');
if (!/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/.test(definition.version.trim())) { if (!normalizeThemeVersion(definition.version)) {
warning('The version should use semantic versioning, for example 1.0.0.'); error(
'The version must use semantic versioning, for example 1.0.0 or 1.0.0-beta.1, with no "v" prefix.'
);
} }
if (!themeHasLaunchButton(definition)) { if (!themeHasLaunchButton(definition)) {
error( error(
@@ -3340,10 +3352,68 @@
let publishStatusMessage = $state(''); let publishStatusMessage = $state('');
let publishProgress = $state(0); let publishProgress = $state(0);
async function checkPublishVersion(): Promise<
{ ok: true; version: string } | { ok: false; error: string }
> {
const proposed = normalizeThemeVersion(definition.version);
if (!proposed) {
return {
ok: false,
error: 'Use a semantic version such as 1.2.3 in the Theme tab before publishing.',
};
}
let publishedVersion = lastPublishedVersion;
const workshopId = definition.workshopId?.trim();
if (workshopId) {
let remoteVersion: string;
try {
remoteVersion = (await fetchCommunityThemeDetails(workshopId)).version?.trim() ?? '';
} catch (error) {
console.warn('[Workshop] Could not verify the published theme version:', error);
return {
ok: false,
error:
'Could not verify the current workshop version. Check your connection and try again.',
};
}
const validRemote = normalizeThemeVersion(remoteVersion);
if (!validRemote) {
return {
ok: false,
error:
'The current workshop version could not be read. Contact a workshop administrator.',
};
}
if (!publishedVersion || semver.gt(validRemote, publishedVersion)) {
publishedVersion = validRemote;
}
}
if (publishedVersion) {
if (semver.eq(proposed, publishedVersion)) {
return {
ok: false,
error: `Version ${proposed} has already been published. Increase the version before publishing again.`,
};
}
if (!semver.gt(proposed, publishedVersion)) {
return {
ok: false,
error: `Version ${proposed} must be higher than the last published version ${publishedVersion}.`,
};
}
}
return { ok: true, version: proposed };
}
async function openPublishDialog() { async function openPublishDialog() {
if (exporting || saving || publishing) return; if (exporting || saving || publishing) return;
if (!$currentUser) { const user = $currentUser;
if (!user) {
sileo.error({ sileo.error({
title: 'Authentication Required', title: 'Authentication Required',
description: description:
@@ -3361,8 +3431,23 @@
return; return;
} }
if (dirty) { const versionCheck = await checkPublishVersion();
await saveTheme({ notify: false }); if (!versionCheck.ok) {
sileo.error({
title: 'Version not publishable',
description: versionCheck.error,
});
return;
}
const versionChanged = definition.version !== versionCheck.version;
if (versionChanged) definition.version = versionCheck.version;
const authorIdChanged = definition.authorId !== user.id;
if (authorIdChanged) definition.authorId = user.id;
if (dirty || authorIdChanged || versionChanged) {
const saved = await saveTheme({ notify: false });
if (!saved) return;
} }
publishThemeId = definition.workshopId ?? ''; publishThemeId = definition.workshopId ?? '';
@@ -3399,17 +3484,34 @@
async function handlePublishToWorkshop() { async function handlePublishToWorkshop() {
if (publishing) return; if (publishing) return;
if (!savedFolder) {
await saveTheme({ notify: false });
if (!savedFolder) return;
}
const firstPublish = !definition.workshopId; const firstPublish = !definition.workshopId;
publishing = true; publishing = true;
publishProgress = 5; publishProgress = 5;
publishStatusMessage = 'Packaging theme archive...'; publishStatusMessage = 'Checking version...';
try { try {
const versionCheck = await checkPublishVersion();
if (!versionCheck.ok) {
sileo.error({
title: 'Version not publishable',
description: versionCheck.error,
});
return;
}
if (definition.version !== versionCheck.version) {
definition.version = versionCheck.version;
const saved = await saveTheme({ notify: false });
if (!saved) return;
}
if (!savedFolder) {
const saved = await saveTheme({ notify: false });
if (!saved || !savedFolder) return;
}
publishStatusMessage = 'Packaging theme archive...';
const baseThemesDir = await themesDirectory(); const baseThemesDir = await themesDirectory();
const themeFolder = await path.join(baseThemesDir, savedFolder); const themeFolder = await path.join(baseThemesDir, savedFolder);
const themeId = savedFolder || toSafeName(definition.name); const themeId = savedFolder || toSafeName(definition.name);
@@ -3420,7 +3522,7 @@
workshopId: definition.workshopId, workshopId: definition.workshopId,
name: definition.name, name: definition.name,
description: definition.description || '', description: definition.description || '',
version: definition.version || '1.0.0', version: versionCheck.version,
apiVersion: definition.apiVersion || '2.0.0', apiVersion: definition.apiVersion || '2.0.0',
tags: definition.tags ?? [], tags: definition.tags ?? [],
allowForking: definition.allowForking !== false, allowForking: definition.allowForking !== false,
@@ -3430,6 +3532,8 @@
}, },
}); });
lastPublishedVersion = versionCheck.version;
if (result.themeId) { if (result.themeId) {
// Persist the server-assigned ID so the next publish updates this // Persist the server-assigned ID so the next publish updates this
// workshop record instead of creating another one. // workshop record instead of creating another one.
@@ -6983,7 +7087,8 @@
</div> </div>
</div> </div>
<p class="text-[10px] leading-relaxed text-muted-foreground/70"> <p class="text-[10px] leading-relaxed text-muted-foreground/70">
These details come from the Theme tab. Change them there before publishing. These details come from the Theme tab. Published versions cannot be reused, so increase
the version before every update.
</p> </p>
</div> </div>
+18
View File
@@ -646,6 +646,8 @@ export type ThemeV2Definition = {
version: string; version: string;
apiVersion: '2.0'; apiVersion: '2.0';
author: string; author: string;
/** EZPPFarm user ID of the publisher, written when the theme is published. */
authorId?: number;
description?: string; description?: string;
/** Workshop discovery tags for this theme. */ /** Workshop discovery tags for this theme. */
tags?: string[]; tags?: string[];
@@ -746,6 +748,16 @@ export const normalizeThemeTags = (raw: unknown): string[] => {
return tags; return tags;
}; };
const THEME_VERSION_PATTERN =
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?$/;
/** Accept only strict SemVer 2.0.0, preserving prerelease and build metadata. */
export const normalizeThemeVersion = (raw: unknown): string | undefined => {
if (typeof raw !== 'string') return undefined;
const version = raw.trim();
return version.length > 0 && THEME_VERSION_PATTERN.test(version) ? version : undefined;
};
const WORKSHOP_ID_PATTERN = /^[a-z0-9][a-z0-9_-]{0,63}$/; const WORKSHOP_ID_PATTERN = /^[a-z0-9][a-z0-9_-]{0,63}$/;
/** Keep a server-assigned workshop ID while preserving legacy slug IDs. */ /** Keep a server-assigned workshop ID while preserving legacy slug IDs. */
@@ -755,6 +767,11 @@ const normalizeWorkshopId = (raw: unknown): string | undefined => {
return WORKSHOP_ID_PATTERN.test(id) ? id : undefined; return WORKSHOP_ID_PATTERN.test(id) ? id : undefined;
}; };
const normalizeAuthorId = (raw: unknown): number | undefined => {
if (typeof raw !== 'number' || !Number.isSafeInteger(raw) || raw <= 0) return undefined;
return raw;
};
const clampInteger = (value: unknown, fallback: number, min: number, max: number) => const clampInteger = (value: unknown, fallback: number, min: number, max: number) =>
Math.round(clamp(value, fallback, min, max)); Math.round(clamp(value, fallback, min, max));
@@ -1913,6 +1930,7 @@ export const normalizeThemeV2 = (raw: Partial<ThemeV2Definition>): ThemeV2Defini
version: text(raw.version, '1.0.0'), version: text(raw.version, '1.0.0'),
apiVersion: '2.0', apiVersion: '2.0',
author: text(raw.author, 'Unknown'), author: text(raw.author, 'Unknown'),
authorId: normalizeAuthorId(raw.authorId),
description: text(raw.description), description: text(raw.description),
tags: normalizeThemeTags(raw.tags), tags: normalizeThemeTags(raw.tags),
workshopId: normalizeWorkshopId(raw.workshopId), workshopId: normalizeWorkshopId(raw.workshopId),
+10
View File
@@ -16,6 +16,8 @@ export type Theme = {
version: string; version: string;
apiVersion: string; apiVersion: string;
author: string; author: string;
/** EZPPFarm user ID stored in the manifest when the theme is published. */
authorId?: number;
description: string; description: string;
nsfw: boolean; nsfw: boolean;
scriptUrl: string; scriptUrl: string;
@@ -44,6 +46,7 @@ export type ThemeInfo = {
apiVersion?: string; apiVersion?: string;
workshopId?: string; workshopId?: string;
author?: string; author?: string;
authorId?: number;
description?: string; description?: string;
nsfw?: boolean; nsfw?: boolean;
entry?: string; entry?: string;
@@ -173,6 +176,12 @@ const themeFromFolder = async (
version: parsed.version ?? '1.0.0', version: parsed.version ?? '1.0.0',
apiVersion, apiVersion,
author: parsed.author ?? 'Unknown', author: parsed.author ?? 'Unknown',
authorId:
typeof parsed.authorId === 'number' &&
Number.isSafeInteger(parsed.authorId) &&
parsed.authorId > 0
? parsed.authorId
: undefined,
description: parsed.description ?? '', description: parsed.description ?? '',
nsfw: parsed.nsfw === true, nsfw: parsed.nsfw === true,
scriptUrl, scriptUrl,
@@ -523,6 +532,7 @@ export const reloadThemes = async () => {
preview: theme.preview, preview: theme.preview,
version: theme.version, version: theme.version,
author: theme.author, author: theme.author,
authorId: theme.authorId,
apiVersion: theme.apiVersion, apiVersion: theme.apiVersion,
description: theme.description, description: theme.description,
nsfw: theme.nsfw, nsfw: theme.nsfw,
+266 -171
View File
@@ -163,6 +163,7 @@
ChevronLeft, ChevronLeft,
ChevronRight, ChevronRight,
Clock, Clock,
Ellipsis,
ExternalLink, ExternalLink,
Flag, Flag,
Globe, Globe,
@@ -421,6 +422,14 @@
return ownedWorkshopThemeNames.includes(theme.name.trim().toLowerCase()); return ownedWorkshopThemeNames.includes(theme.name.trim().toLowerCase());
}; };
const themeAuthorAvatarUrl = (theme: Theme) => {
if (theme.authorId && theme.authorId > 0) {
return `https://a.ez-pp.farm/${theme.authorId}`;
}
const author = theme.author.trim();
return author ? `https://a.ez-pp.farm/${encodeURIComponent(author)}` : undefined;
};
onMount(() => { onMount(() => {
let loadedUserId: number | undefined; let loadedUserId: number | undefined;
return currentUser.subscribe((user) => { return currentUser.subscribe((user) => {
@@ -505,6 +514,29 @@
await config.value<string>('theme').set(theme.name); await config.value<string>('theme').set(theme.name);
}; };
const uninstallInstalledTheme = async (theme: Theme) => {
try {
const deleteResult = await deleteTheme(theme);
if (deleteResult) {
sileo.success({
title: 'Theme uninstalled',
description: `"${theme.name}" was removed from your library.`,
});
} else {
sileo.error({
title: 'Could not uninstall theme',
description: 'The theme files could not be removed.',
});
}
} catch (err) {
console.error(err);
sileo.error({
title: 'Could not uninstall theme',
description: err instanceof Error ? err.message : String(err),
});
}
};
const updateInstalledTheme = async (theme: Theme) => { const updateInstalledTheme = async (theme: Theme) => {
const wasActive = $active_custom_theme?.folder_name === theme.folder_name; const wasActive = $active_custom_theme?.folder_name === theme.folder_name;
const updateResult = await downloadTheme(theme, true); const updateResult = await downloadTheme(theme, true);
@@ -3911,6 +3943,28 @@
{#each filteredThemes as theme, index (theme.folder_name)} {#each filteredThemes as theme, index (theme.folder_name)}
{@const isActive = {@const isActive =
$active_custom_theme?.folder_name === theme.folder_name} $active_custom_theme?.folder_name === theme.folder_name}
{@const canEditTheme =
theme.status === 'installed' && Boolean(theme.definition)}
{@const canRestoreTheme =
theme.status === 'installed' && (theme.backups?.length ?? 0) > 0}
{@const canUpdateTheme =
theme.status === 'installed' && theme.updateAvailable}
{@const canReportTheme =
Boolean($currentUser && ownedWorkshopLoaded) &&
!isOwnInstalledTheme(theme) &&
theme.status === 'installed' &&
theme.name !== 'Default' &&
theme.folder_name !== 'default'}
{@const canUninstallTheme =
(theme.status === 'installed' || theme.status === 'deleting') &&
!isActive &&
theme.name !== 'Default'}
{@const hasThemeMenu =
canEditTheme ||
canRestoreTheme ||
canUpdateTheme ||
canReportTheme ||
canUninstallTheme}
<div <div
class="group flex flex-col overflow-hidden rounded-xl border bg-theme-900/30 {isActive class="group flex flex-col overflow-hidden rounded-xl border bg-theme-900/30 {isActive
? 'border-primary/60 ring-1 ring-primary/15' ? 'border-primary/60 ring-1 ring-primary/15'
@@ -3925,7 +3979,7 @@
}} }}
> >
<div <div
class="relative h-36 w-full shrink-0 overflow-hidden bg-theme-950/60" class="relative aspect-video w-full shrink-0 overflow-hidden bg-theme-950/60"
> >
<div <div
class="h-full w-full {$reduceAnimations class="h-full w-full {$reduceAnimations
@@ -3966,17 +4020,37 @@
<div <div
class="pointer-events-none absolute inset-0 bg-gradient-to-t from-theme-950/75 via-transparent to-transparent" class="pointer-events-none absolute inset-0 bg-gradient-to-t from-theme-950/75 via-transparent to-transparent"
></div> ></div>
{#if isActive} <div
<Badge class="absolute top-1.5 left-1.5 text-[9px]">In use</Badge> class="absolute top-1.5 left-1.5 flex max-w-[calc(100%-4.5rem)] flex-wrap items-center gap-1"
{/if} >
{#if theme.name !== 'Default' && theme.folder_name !== 'default' && theme.apiVersion} {#if isActive}
<Badge <Badge class="text-[9px]">In use</Badge>
variant="secondary" {/if}
class="absolute top-1.5 right-1.5 bg-black/50 px-1.5 py-0 text-[9px] backdrop-blur-sm" {#if theme.name !== 'Default' && theme.folder_name !== 'default' && theme.apiVersion}
<Badge
variant="secondary"
class="bg-black/50 px-1.5 py-0 text-[9px] backdrop-blur-sm"
>
API {theme.apiVersion.startsWith('2') ? '2.0' : '1.0'}
</Badge>
{/if}
</div>
<div class="absolute top-1.5 right-1.5 flex items-center gap-1">
{#if theme.nsfw}
<Badge
variant="destructive"
class="px-1.5 py-0 text-[9px]"
title="Adult content"
>
18+
</Badge>
{/if}
<span
class="rounded-md bg-black/60 px-1.5 py-0.5 text-[9px] font-medium text-white/90 backdrop-blur-sm"
> >
API {theme.apiVersion.startsWith('2') ? '2.0' : '1.0'} v{theme.version}
</Badge> </span>
{/if} </div>
{#if theme.nsfw && !revealedNsfw.includes(theme.name)} {#if theme.nsfw && !revealedNsfw.includes(theme.name)}
<button <button
type="button" type="button"
@@ -3992,192 +4066,213 @@
{:else if theme.nsfw} {:else if theme.nsfw}
<button <button
type="button" type="button"
class="absolute bottom-1.5 left-1.5 z-10 flex items-center gap-1 rounded-full bg-black/60 px-1.5 py-0.5 text-[8px] font-medium text-white/80 backdrop-blur-sm hover:bg-black/75 hover:text-white" class="absolute right-1.5 bottom-10 z-10 flex items-center gap-1 rounded-full bg-black/60 px-1.5 py-0.5 text-[8px] font-medium text-white/80 backdrop-blur-sm hover:bg-black/75 hover:text-white"
onclick={() => toggleNsfwPreview(theme.name)} onclick={() => toggleNsfwPreview(theme.name)}
> >
<ThemeIcon name="eye-off" set={iconSet} class="size-3" /> <ThemeIcon name="eye-off" set={iconSet} class="size-3" />
Hide preview Hide preview
</button> </button>
{/if} {/if}
{#if theme.nsfw} <div
<Badge class="absolute right-2 bottom-2 left-2 flex items-center justify-between gap-2"
variant="destructive" >
class="absolute right-1.5 bottom-1.5 px-1.5 py-0 text-[9px]" <div class="flex min-w-0 items-center gap-1.5">
title="Adult content" <Avatar.Root
> class="size-5 shrink-0 border border-white/20 bg-theme-800"
18+
</Badge>
{/if}
</div>
<div class="flex flex-1 flex-col gap-1.5 p-2.5">
<div class="flex items-start justify-between gap-1.5">
<div class="min-w-0">
<span
class="block truncate text-[13px] leading-tight font-semibold"
> >
{theme.name} <Avatar.Image
</span> src={themeAuthorAvatarUrl(theme)}
alt={theme.author || 'Unknown author'}
class="object-cover"
/>
<Avatar.Fallback
class="text-[9px] font-bold text-white/80 uppercase"
>
{theme.author.trim().charAt(0) || '?'}
</Avatar.Fallback>
</Avatar.Root>
<span <span
class="mt-0.5 block truncate text-[10px] text-muted-foreground" class="truncate text-[11px] font-semibold text-white/95 drop-shadow-sm"
> >
by {theme.author} {theme.author || 'Unknown author'}
</span> </span>
</div> </div>
<span <span
class="shrink-0 rounded-full bg-theme-800/50 px-1.5 py-0.5 text-[9px] whitespace-nowrap tabular-nums text-muted-foreground" class="shrink-0 text-[9px] {theme.updateAvailable
? 'text-primary'
: 'text-muted-foreground/90'}"
> >
{#if theme.updateAvailable && theme.availableVersion} {theme.updateAvailable ? 'Update available' : 'Installed'}
v{theme.version} <span class="text-primary">→</span>
v{theme.availableVersion}
{:else}
v{theme.version}
{/if}
</span> </span>
</div> </div>
</div>
<div class="flex flex-1 flex-col gap-2 p-3">
<h3 class="truncate text-[13px] font-bold text-theme-50">
{theme.name}
</h3>
{#if theme.description} {#if theme.description}
<p <p
class="line-clamp-2 text-[10px] leading-snug text-muted-foreground" class="line-clamp-2 text-[10px] leading-relaxed text-muted-foreground"
> >
{theme.description} {theme.description}
</p> </p>
{/if} {/if}
<div class="mt-auto flex items-center gap-1 pt-0.5"> <div
<Button class="mt-auto flex items-center justify-between gap-2 border-t border-theme-800/40 pt-2.5"
class="relative h-8 min-w-0 flex-1 overflow-hidden px-2 text-xs {theme.status === >
'downloading' || theme.status === 'extracting' <span class="min-w-0 truncate text-[9px] text-muted-foreground">
? 'disabled:bg-primary disabled:opacity-100' {#if theme.updateAvailable && theme.availableVersion}
: ''}" <span class="text-primary"
size="sm" >v{theme.availableVersion} available</span
aria-busy={theme.status === 'downloading' || >
theme.status === 'extracting'} {:else if isActive}
disabled={isActive || Active theme
theme.status === 'downloading' || {:else}
theme.status === 'extracting' || Installed
theme.status === 'deleting'}
onclick={() => requestThemeApply(theme)}
>
{#if theme.status === 'downloading' || theme.status === 'extracting'}
<span
class="absolute inset-y-0 left-0 bg-white/20 transition-[width] duration-300 ease-out"
style={`width: ${Math.min(100, Math.max(0, theme.progress * 100))}%`}
></span>
{#if !$reduceAnimations}
<span
class="theme-download-shimmer absolute inset-y-0 left-0 w-1/2 bg-gradient-to-r from-transparent via-white/25 to-transparent"
></span>
{/if}
{/if} {/if}
<span </span>
class="relative z-10 flex items-center justify-center gap-2" <div class="flex shrink-0 items-center gap-1">
<Button
class="relative h-7 min-w-0 max-w-44 overflow-hidden px-2.5 text-xs {theme.status ===
'downloading' || theme.status === 'extracting'
? 'disabled:bg-primary disabled:opacity-100'
: ''}"
size="sm"
aria-busy={theme.status === 'downloading' ||
theme.status === 'extracting'}
disabled={isActive ||
theme.status === 'downloading' ||
theme.status === 'extracting' ||
theme.status === 'deleting'}
onclick={() => requestThemeApply(theme)}
> >
{#if theme.status === 'extracting'} {#if theme.status === 'downloading' || theme.status === 'extracting'}
<ThemeIcon <span
name="loader" class="absolute inset-y-0 left-0 bg-white/20 transition-[width] duration-300 ease-out"
set={iconSet} style={`width: ${Math.min(100, Math.max(0, theme.progress * 100))}%`}
class="size-4 animate-spin" ></span>
/> {#if !$reduceAnimations}
<span
class="theme-download-shimmer absolute inset-y-0 left-0 w-1/2 bg-gradient-to-r from-transparent via-white/25 to-transparent"
></span>
{/if}
{/if} {/if}
<TextMorph <span
text={themeButtonLabel( class="relative z-10 flex items-center justify-center gap-2"
theme, >
$active_custom_theme?.folder_name {#if theme.status === 'extracting'}
)} <ThemeIcon
duration={260} name="loader"
ease="cubic-bezier(0.19, 1, 0.22, 1)" set={iconSet}
disabled={$reduceAnimations} class="size-4 animate-spin"
class="whitespace-nowrap" />
/> {/if}
</span> <TextMorph
</Button> text={themeButtonLabel(
{#if theme.status === 'installed' && theme.definition} theme,
<Button $active_custom_theme?.folder_name
variant="secondary" )}
size="icon" duration={260}
class="size-7 shrink-0" ease="cubic-bezier(0.19, 1, 0.22, 1)"
title="Edit theme" disabled={$reduceAnimations}
onclick={() => openThemeEditor(theme)} class="whitespace-nowrap"
>
<ThemeIcon name="edit" set={iconSet} class="size-3.5" />
</Button>
{/if}
{#if theme.status === 'installed' && (theme.backups?.length ?? 0) > 0}
<Button
variant="secondary"
size="icon"
class="size-7 shrink-0"
title="Restore previous version ({new Date(
theme.backups![0].createdAt
).toLocaleDateString()})"
onclick={() => requestThemeRestore(theme, theme.backups![0])}
>
<ThemeIcon name="history" set={iconSet} class="size-3.5" />
</Button>
{/if}
{#if theme.status === 'installed' && theme.updateAvailable}
<Button
variant="secondary"
size="icon"
class="size-7 shrink-0"
title={`Update theme${theme.availableVersion ? ` to v${theme.availableVersion}` : ''}`}
onclick={() => updateInstalledTheme(theme)}
>
<ThemeIcon name="download" set={iconSet} class="size-3.5" />
</Button>
{/if}
{#if (theme.status === 'installed' || theme.status === 'deleting') && !isActive && theme.name !== 'Default'}
<Button
variant="destructive"
size="icon"
class="size-7 shrink-0"
title="Uninstall theme"
disabled={theme.status !== 'installed'}
onclick={async () => {
try {
const deleteResult = await deleteTheme(theme);
if (deleteResult) {
sileo.success({
title: 'Yaay!',
description: 'Theme uninstalled successfully!',
});
} else {
sileo.error({
title: 'Uhhm..',
description: 'Failed to uninstall theme.',
});
}
} catch (err) {
console.log(err);
sileo.error({
title: 'Uhhm..',
description: 'Failed to uninstall theme.',
});
}
}}
>
{#if theme.status === 'deleting'}
<ThemeIcon
name="loader"
set={iconSet}
class="size-3.5 animate-spin"
/> />
{:else} </span>
<ThemeIcon name="trash" set={iconSet} class="size-3.5" />
{/if}
</Button> </Button>
{/if} {#if hasThemeMenu}
{#if $currentUser && ownedWorkshopLoaded && !isOwnInstalledTheme(theme) && theme.status === 'installed' && theme.name !== 'Default' && theme.folder_name !== 'default'} <DropdownMenu.Root>
<Button <DropdownMenu.Trigger>
variant="secondary" {#snippet child({ props })}
size="icon" <Button
class="size-7 shrink-0 text-muted-foreground hover:bg-amber-500/15 hover:text-amber-300" {...props}
title="Report theme" variant="secondary"
aria-label={`Report ${theme.name}`} size="icon"
disabled={installedReportLoading} class="size-7 shrink-0 text-muted-foreground hover:text-white"
onclick={() => void openInstalledReport(theme)} title="More theme actions"
> aria-label={`More actions for ${theme.name}`}
<Flag class="size-3.5" /> >
</Button> <Ellipsis class="size-3.5" />
{/if} </Button>
{/snippet}
</DropdownMenu.Trigger>
<DropdownMenu.Content
align="end"
class="w-48 border-theme-700 bg-theme-950 text-theme-50"
>
{#if canEditTheme}
<DropdownMenu.Item
class="gap-2 text-[11px]"
onclick={() => openThemeEditor(theme)}
>
<ThemeIcon name="edit" set={iconSet} class="size-3.5" />
Edit theme
</DropdownMenu.Item>
{/if}
{#if canRestoreTheme}
<DropdownMenu.Item
class="gap-2 text-[11px]"
onclick={() =>
requestThemeRestore(theme, theme.backups![0])}
>
<ThemeIcon
name="history"
set={iconSet}
class="size-3.5"
/>
Restore previous version
</DropdownMenu.Item>
{/if}
{#if canUpdateTheme}
<DropdownMenu.Item
class="gap-2 text-[11px]"
onclick={() => updateInstalledTheme(theme)}
>
<ThemeIcon
name="download"
set={iconSet}
class="size-3.5"
/>
Update theme
</DropdownMenu.Item>
{/if}
{#if canReportTheme}
<DropdownMenu.Item
class="gap-2 text-[11px]"
disabled={installedReportLoading}
onclick={() => void openInstalledReport(theme)}
>
<Flag class="size-3.5" />
Report theme
</DropdownMenu.Item>
{/if}
{#if canUninstallTheme}
<DropdownMenu.Separator class="my-1 bg-theme-800" />
<DropdownMenu.Item
class="gap-2 text-[11px] text-red-300 data-[highlighted]:bg-red-500/15 data-[highlighted]:text-red-200"
disabled={theme.status !== 'installed'}
onclick={() => void uninstallInstalledTheme(theme)}
>
{#if theme.status === 'deleting'}
<ThemeIcon
name="loader"
set={iconSet}
class="size-3.5 animate-spin"
/>
Uninstalling...
{:else}
<ThemeIcon
name="trash"
set={iconSet}
class="size-3.5"
/>
Uninstall theme
{/if}
</DropdownMenu.Item>
{/if}
</DropdownMenu.Content>
</DropdownMenu.Root>
{/if}
</div>
</div> </div>
</div> </div>
</div> </div>