refactor(lib): move generic hooks, DnD engine, shortcut contract to lib

Continue M4 lib/ de-flattening with domain-agnostic infra:
- lib/hooks/: 9 pure generic hooks (useDebouncedValue, useIsMobile,
  useLongPressAction, useRangeSelection, useResizeClientHeight,
  useWindowVisibility, useSystemPrefersDark, useVirtualizerScrollMargin,
  useRemeasureGridVirtualizer) — all PURE (only react/zustand/tanstack deps).
- lib/dnd/DragDropContext.tsx: the generic mouse-event DnD engine (WebKitGTK
  HTML5-DnD workaround, ~24 importers, self-contained) — empties src/contexts/.
- lib/shortcuts/: shortcutActions + shortcutTypes (the action-id + binding
  contract; registry/dispatch/bindings stay app-level and import the contract,
  app->lib direction).

useWindowFullscreenState deliberately NOT moved — kept in hooks/ as app-shell
per the handoff iron-rule list (overrides its pure-helper appearance).

Pure move via deep @/lib/* specifiers. tsc 0, lint 0/0, full suite 319 files /
2353 tests green.
This commit is contained in:
Psychotoxical
2026-06-30 08:20:11 +02:00
parent 209dd61442
commit 7ad196711e
74 changed files with 78 additions and 78 deletions
@@ -8,7 +8,7 @@ import {
displayPlaylistName, isSmartPlaylistName, type PendingSmartPlaylist,
} from '@/features/playlist/utils/playlistsSmart';
import { formatHumanHoursMinutes } from '@/lib/format/formatHumanDuration';
import { useDragSource } from '@/contexts/DragDropContext';
import { useDragSource } from '@/lib/dnd/DragDropContext';
import { PlaylistCardMainCover, PlaylistSmartCoverCell } from '@/features/playlist/components/PlaylistCoverImages';
interface Props {
@@ -4,7 +4,7 @@ import { ChevronRight, Folder, Pencil, Trash2 } from 'lucide-react';
import type { SubsonicPlaylist } from '@/lib/api/subsonicTypes';
import { usePlaylistFolderStore } from '@/features/playlist/store/playlistFolderStore';
import type { PlaylistFolder } from '@/features/playlist/utils/playlistFolders';
import { useDragDrop } from '@/contexts/DragDropContext';
import { useDragDrop } from '@/lib/dnd/DragDropContext';
import { VirtualCardGrid } from '@/components/VirtualCardGrid';
interface Props {
@@ -4,7 +4,7 @@ import PlaylistRow, { type PlaylistRowCallbacks } from '@/features/playlist/comp
import { TracklistColumnPicker } from '@/components/albumTrackList/TracklistColumnPicker';
import { useTranslation } from 'react-i18next';
import { APP_MAIN_SCROLL_VIEWPORT_ID } from '@/constants/appScroll';
import { useElementClientHeightById } from '@/hooks/useResizeClientHeight';
import { useElementClientHeightById } from '@/lib/hooks/useResizeClientHeight';
import { useNavigate } from 'react-router-dom';
import {
ListPlus, Search, Trash2, X,
@@ -15,7 +15,7 @@ import type { Track } from '@/store/playerStoreTypes';
import { usePlayerStore } from '@/store/playerStore';
import { previewInputFromSong, usePreviewStore } from '@/store/previewStore';
import { useThemeStore } from '@/store/themeStore';
import { useDragDrop } from '@/contexts/DragDropContext';
import { useDragDrop } from '@/lib/dnd/DragDropContext';
import { useOrbitSongRowBehavior } from '@/features/orbit';
import { songToTrack } from '@/utils/playback/songToTrack';
import type { PlaylistSortKey, PlaylistSortDir } from '@/features/playlist/utils/playlistDisplayedSongs';
@@ -2,7 +2,7 @@ import React from 'react';
import type { SubsonicPlaylist } from '@/lib/api/subsonicTypes';
import { EMPTY_SERVER_FOLDERS, usePlaylistFolderStore } from '@/features/playlist/store/playlistFolderStore';
import { groupPlaylistsByFolder } from '@/features/playlist/utils/playlistFolders';
import { useDragDrop } from '@/contexts/DragDropContext';
import { useDragDrop } from '@/lib/dnd/DragDropContext';
import PlaylistFolderSection from '@/features/playlist/components/PlaylistFolderSection';
interface Props {
@@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import type { SubsonicSong } from '@/lib/api/subsonicTypes';
import { useDragDrop } from '@/contexts/DragDropContext';
import { useDragDrop } from '@/lib/dnd/DragDropContext';
import { runPlaylistReorderDrop } from '@/features/playlist/utils/runPlaylistReorderDrop';
export interface PlaylistDnDReorderDeps {
@@ -12,7 +12,7 @@ import { useAlbumOfflineState } from '@/features/album';
import { useAuthStore } from '@/store/authStore';
import { useDownloadModalStore } from '@/features/offline';
import { useZipDownloadStore } from '@/features/offline';
import { useDragDrop } from '@/contexts/DragDropContext';
import { useDragDrop } from '@/lib/dnd/DragDropContext';
import { useTranslation } from 'react-i18next';
import type { SpotifyCsvTrack } from '@/features/playlist/utils/spotifyCsvImport';
import { runPlaylistCsvImport } from '@/features/playlist/utils/runPlaylistCsvImport';
+1 -1
View File
@@ -8,7 +8,7 @@ import { usePlayerStore } from '@/store/playerStore';
import { usePlaylistStore } from '@/features/playlist/store/playlistStore';
import { useAuthStore } from '@/store/authStore';
import { useTranslation } from 'react-i18next';
import { useRangeSelection } from '@/hooks/useRangeSelection';
import { useRangeSelection } from '@/lib/hooks/useRangeSelection';
import {
defaultSmartFilters,