Merges Renovate's kit 3 (PR #149) and adapter-static 4 (PR #148) bumps, plus the migration they need. The mechanical part is `sv migrate sveltekit-3`, run one task at a time and reviewed: - svelte.config.js is gone. Its options move into sveltekit() in vite.config.ts, exported as kitOptions so vitest.config.ts runs the same kit setup, including the $test-utils alias the tests import. - $lib becomes #lib through package.json "imports". There is no src/lib/index, so only the "#lib/*" entry is kept. - tsconfig extends $app/tsconfig. - Peer floors raised to kit 3's requirements: svelte ^5.57.1, vite ^8.0.12, svelte-check ^4.7.5. By hand, from the codemod's list of non-automated tasks: - goto's replaceState option is now replace; keepFocus becomes reset: false. For the search typeahead, reset: false also stops the scroll-to-top, which is wanted while typing. - The test setup mocks drop pushState/replaceState and $app/paths base/assets, which kit 3 removed, and mock refreshAll in place of invalidateAll. - The other flagged files only read page.url or goto internal routes, so they needed no change. TypeScript goes to ^6, not the ^7 Renovate offers: kit 3 declares typescript ^6 as a peer and svelte-check 4.7 accepts ^5 || ^6. Move to 7 once both accept it. With Tailwind 4 and kit 3 in, `npm audit` on the whole tree reports 0, so the web lane now audits every dependency rather than only what ships to browsers. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
150 lines
5.2 KiB
Svelte
150 lines
5.2 KiB
Svelte
<script lang="ts">
|
||
import { GripVertical, X } from 'lucide-svelte';
|
||
import { draggable, type DragEventData } from '@neodrag/svelte';
|
||
import LikeButton from './LikeButton.svelte';
|
||
import TrackMenu from './TrackMenu.svelte';
|
||
import type { PlaylistTrack } from '#lib/api/types.js';
|
||
import { playlistTrackToRef } from '#lib/playlists/playlistTrackToRef.js';
|
||
import { player } from '#lib/player/store.svelte.js';
|
||
import { offsetToDelta } from './queue-row-math';
|
||
|
||
let {
|
||
row,
|
||
isOwner,
|
||
onRemove,
|
||
onPlay,
|
||
onMove
|
||
}: {
|
||
row: PlaylistTrack;
|
||
isOwner: boolean;
|
||
onRemove: (position: number) => void;
|
||
onPlay: (position: number) => void;
|
||
onMove?: (fromPos: number, toPos: number) => void;
|
||
} = $props();
|
||
|
||
// Two different ways a row can be dead, with the same behaviour and
|
||
// deliberately different copy. A removed track is gone for good; a
|
||
// missing file is a track we still have — history, likes and all —
|
||
// whose bytes aren't on disk right now (#2527). Telling the user
|
||
// "file missing" invites them to fix it; a strikethrough would say
|
||
// "deleted", which is a lie about a file that may well come back.
|
||
const isMissingFile = $derived(row.unavailable);
|
||
const isRemoved = $derived(row.track_id === null);
|
||
const isUnavailable = $derived(isRemoved || isMissingFile);
|
||
|
||
// Reconstruct a minimal TrackRef for the kebab menu when the
|
||
// upstream track still exists. When unavailable, the menu is hidden.
|
||
const liveTrack = $derived(playlistTrackToRef(row));
|
||
|
||
let measuredRowHeight = 56; // sensible default; replaced on dragStart
|
||
|
||
function handleDragStart(data: DragEventData) {
|
||
const rect = data.rootNode.getBoundingClientRect();
|
||
if (rect.height > 0) measuredRowHeight = rect.height;
|
||
}
|
||
|
||
function handleDragEnd(data: DragEventData) {
|
||
const delta = offsetToDelta(data.offsetY, measuredRowHeight);
|
||
if (delta === 0) return;
|
||
onMove?.(row.position, row.position + delta);
|
||
}
|
||
|
||
function handleHandleKeydown(e: KeyboardEvent) {
|
||
if (e.key === 'ArrowUp') {
|
||
e.preventDefault();
|
||
onMove?.(row.position, row.position - 1);
|
||
} else if (e.key === 'ArrowDown') {
|
||
e.preventDefault();
|
||
onMove?.(row.position, row.position + 1);
|
||
} else if (e.key === ' ' || e.key === 'Enter') {
|
||
// Reorder activates via arrow keys, not Space/Enter. Prevent
|
||
// default so Space doesn't scroll the list and Enter doesn't
|
||
// fire the button's no-op click.
|
||
e.preventDefault();
|
||
}
|
||
}
|
||
|
||
function format(sec: number): string {
|
||
const m = Math.floor(sec / 60);
|
||
const s = sec % 60;
|
||
return `${m}:${s.toString().padStart(2, '0')}`;
|
||
}
|
||
|
||
// Drag is gated on owner+available. When neither, the action runs but
|
||
// the dragEnd handler skips by returning before onMove fires; visually
|
||
// the user never sees the row move.
|
||
const canDrag = $derived(isOwner && !isUnavailable);
|
||
|
||
// "Now playing" highlight: matches QueueTrackRow's treatment so the
|
||
// user can see which row is current without reading the player bar.
|
||
// Unavailable rows (trackId === null) never match.
|
||
const isCurrent = $derived(
|
||
!isUnavailable && player.current?.id === row.track_id,
|
||
);
|
||
</script>
|
||
|
||
<div
|
||
role="listitem"
|
||
class="flex items-center gap-3 px-3 py-2 text-sm transition-colors hover:bg-surface-hover
|
||
{isUnavailable ? 'text-text-muted' : 'text-text-primary'}
|
||
{isCurrent ? 'border-l-2 border-l-accent bg-surface-hover' : ''}"
|
||
use:draggable={{
|
||
axis: 'y',
|
||
bounds: 'parent',
|
||
disabled: !canDrag,
|
||
onDragStart: handleDragStart,
|
||
onDragEnd: handleDragEnd
|
||
}}
|
||
>
|
||
{#if isOwner}
|
||
<button
|
||
type="button"
|
||
disabled={!canDrag}
|
||
aria-label="Reorder track (drag or use arrow keys)"
|
||
aria-keyshortcuts="ArrowUp ArrowDown"
|
||
onkeydown={handleHandleKeydown}
|
||
class="shrink-0 cursor-grab text-text-muted hover:text-text-primary
|
||
active:cursor-grabbing focus-visible:outline-solid focus-visible:outline-2
|
||
focus-visible:outline-accent disabled:cursor-not-allowed disabled:opacity-50"
|
||
>
|
||
<GripVertical size={14} strokeWidth={1} />
|
||
</button>
|
||
{/if}
|
||
|
||
<button
|
||
type="button"
|
||
class="min-w-0 flex-1 text-left"
|
||
onclick={() => !isUnavailable && onPlay(row.position)}
|
||
disabled={isUnavailable}
|
||
title={isMissingFile
|
||
? 'This track’s file is missing from the library, so it can’t be played. It stays in the playlist, and returns automatically if the file comes back.'
|
||
: undefined}
|
||
>
|
||
<div class="truncate {isRemoved ? 'line-through' : ''}">{row.title}</div>
|
||
<div class="truncate text-xs text-text-muted">
|
||
{row.artist_name} · {row.album_title}
|
||
{#if isMissingFile}
|
||
<span class="text-action-destructive"> · File missing</span>
|
||
{/if}
|
||
</div>
|
||
</button>
|
||
|
||
<span class="shrink-0 text-xs text-text-muted">{format(row.duration_sec)}</span>
|
||
|
||
{#if !isUnavailable && liveTrack}
|
||
<LikeButton entityType="track" entityId={liveTrack.id} />
|
||
<TrackMenu track={liveTrack} />
|
||
{/if}
|
||
|
||
{#if isOwner}
|
||
<button
|
||
type="button"
|
||
onclick={() => onRemove(row.position)}
|
||
aria-label={`Remove ${row.title} from playlist`}
|
||
class="shrink-0 rounded p-1 text-text-muted hover:bg-surface hover:text-action-destructive"
|
||
>
|
||
<X size={14} strokeWidth={1} />
|
||
</button>
|
||
{/if}
|
||
</div>
|