Skip to content

Commit

Permalink
format, fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Tnixc committed Nov 19, 2024
1 parent 7ff01cc commit 5d95057
Show file tree
Hide file tree
Showing 38 changed files with 78 additions and 76 deletions.
2 changes: 1 addition & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { electronApp, is, optimizer } from "@electron-toolkit/utils";
import { Router } from "@main/lib/route-pass/Router";
import createMenu from "@main/lib/window/menu";
import trackBounds, { getBounds, wasMaximized } from "@main/lib/window/resizer";
import { main } from "@main/main";
import { electronApp, is, optimizer } from "@electron-toolkit/utils";
import { app, BrowserWindow, dialog } from "electron";
import { join } from "path";

Expand Down
4 changes: 2 additions & 2 deletions src/main/lib/osu-file-parser/OsuFile.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AudioSource, ImageSource, Optional, Result, Song } from "@shared/types/common.types";
import { access, readFile, stat } from "@main/lib/fs-promises";
import { SongBuilder } from "@main/lib/song/SongBuilder";
import { none, some } from "@shared/lib/rust-types/Optional";
import { fail, ok } from "@shared/lib/rust-types/Result";
import { SongBuilder } from "@main/lib/song/SongBuilder";
import { AudioSource, ImageSource, Optional, Result, Song } from "@shared/types/common.types";
import { getAudioDurationInSeconds } from "get-audio-duration";
import fs from "graceful-fs";
import path from "path";
Expand Down
4 changes: 2 additions & 2 deletions src/main/lib/osu-file-parser/OsuParser.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AudioSource, ImageSource, ResourceID, Result, Song } from "@shared/types/common.types";
import { OsuFile } from "./OsuFile";
import { access } from "@main/lib/fs-promises";
import { fail, ok } from "@shared/lib/rust-types/Result";
import { assertNever } from "@shared/lib/tungsten/assertNever";
import { OsuFile } from "./OsuFile";
import { AudioSource, ImageSource, ResourceID, Result, Song } from "@shared/types/common.types";
import fs from "graceful-fs";
import os from "os";
import path from "path/posix";
Expand Down
2 changes: 1 addition & 1 deletion src/main/lib/osu-file-parser/WatchFile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Result } from "@shared/types/common.types";
import { fail, ok } from "@shared/lib/rust-types/Result";
import { Result } from "@shared/types/common.types";
import fs from "fs";
import path from "path";

Expand Down
6 changes: 3 additions & 3 deletions src/main/lib/route-pass/Router.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { APIFunction, Packet } from "@shared/types/common.types";
import { ListenAPI, RequestAPI } from "@shared/types/router.types";
import { cratePacket } from "./Packet";
import { assertNever } from "@shared/lib/tungsten/assertNever";
import { TokenNamespace } from "@shared/lib/tungsten/token";
import { cratePacket } from "./Packet";
import type { APIFunction, Packet } from "@shared/types/common.types";
import { ListenAPI, RequestAPI } from "@shared/types/router.types";
import { BrowserWindow, ipcMain } from "electron";

type Pending = {
Expand Down
2 changes: 1 addition & 1 deletion src/main/lib/search-parser/SearchParser.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { closestLevenDist } from "./levenshteinDistance";
import {
SearchPropertyValidation,
SearchConfig,
Expand All @@ -6,7 +7,6 @@ import {
ValidationSuggestion,
SearchQuerySuggestion,
} from "@shared/types/search-parser.types";
import { closestLevenDist } from "./levenshteinDistance";

type ComparisonExtractionTrue = {
isPresent: true;
Expand Down
2 changes: 1 addition & 1 deletion src/main/lib/search-parser/validators.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { closestLevenDist } from "./levenshteinDistance";
import {
SearchPropertyValidation,
SearchPropertyValidator,
} from "@shared/types/search-parser.types";
import { closestLevenDist } from "./levenshteinDistance";

export const equalsSymbols = ["=", "==", "!="];
export const greaterThanSymbols = [">", ">="];
Expand Down
2 changes: 1 addition & 1 deletion src/main/lib/song/filter.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { assertNever } from "@shared/lib/tungsten/assertNever";
import {
OsuSearchAbleProperties,
SongIndex,
SongsQueryPayload,
Tag,
} from "@shared/types/common.types";
import { assertNever } from "@shared/lib/tungsten/assertNever";

export function filter(indexes: SongIndex[], query: SongsQueryPayload): SongIndex[] {
if (query.searchQuery === undefined) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/lib/song/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Song, SongIndex } from "@shared/types/common.types";
import { averageBPM, msToBPM } from "./average-bpm";
import { Song, SongIndex } from "@shared/types/common.types";

function createSongIndex(id: string, song: Song): SongIndex {
return {
Expand Down
2 changes: 1 addition & 1 deletion src/main/lib/song/indexMapper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Song, SongIndex } from "@shared/types/common.types";
import { Storage } from "@main/lib/storage/Storage";
import { Song, SongIndex } from "@shared/types/common.types";

export function* indexMapper(indexes: SongIndex[]): Generator<Song> {
for (let i = 0; i < indexes.length; i++) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/lib/song/order.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Order, Result, Song } from "@shared/types/common.types";
import { ok } from "@shared/lib/rust-types/Result";
import { averageBPM, msToBPM } from "./average-bpm";
import { ok } from "@shared/lib/rust-types/Result";
import { Order, Result, Song } from "@shared/types/common.types";

export default function order(ordering: Order): Result<(a: Song, b: Song) => number, string> {
const { option, direction } = ordering;
Expand Down
2 changes: 1 addition & 1 deletion src/main/lib/storage/Storage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BlobMap, TableMap } from "@shared/types/common.types";
import { Table } from "./Table";
import { BlobMap, TableMap } from "@shared/types/common.types";
import { app } from "electron";
import fs from "fs";
import path from "path";
Expand Down
2 changes: 1 addition & 1 deletion src/main/lib/storage/Table.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Optional } from "@shared/types/common.types";
import { none, some } from "@shared/lib/rust-types/Optional";
import { Optional } from "@shared/types/common.types";
import fs from "fs";

export class Table<S> {
Expand Down
2 changes: 1 addition & 1 deletion src/main/lib/window/resizer.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { orDefault } from "@shared/lib/rust-types/Optional";
import { Storage } from "@main/lib/storage/Storage";
import { orDefault } from "@shared/lib/rust-types/Optional";
import { BrowserWindow } from "electron";

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/main.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { DirParseResult, OsuParser } from "@main/lib/osu-file-parser/OsuParser";
import { Router } from "@main/lib/route-pass/Router";
import { orDefault } from "@shared/lib/rust-types/Optional";
import { collectTagsAndIndexSongs } from "@main/lib/song";
import { Storage } from "@main/lib/storage/Storage";
import { throttle } from "@main/lib/throttle";
import { dirSubmit } from "@main/router/dir-router";
import { showError } from "@main/router/error-router";
import "@main/router/import";
import { orDefault } from "@shared/lib/rust-types/Optional";
import { BrowserWindow } from "electron";

export let mainWindow: BrowserWindow;
Expand Down
2 changes: 1 addition & 1 deletion src/main/router/local-volume-router.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AudioSource, ResourceID } from "@shared/types/common.types";
import { delay } from "@main/lib/delay-backend";
import { Router } from "@main/lib/route-pass/Router";
import { Storage } from "@main/lib/storage/Storage";
import { AudioSource, ResourceID } from "@shared/types/common.types";

const [writeAudioSource] = delay((audioID: ResourceID, audioSource: AudioSource) => {
Storage.getTable("audio").write(audioID, audioSource);
Expand Down
20 changes: 10 additions & 10 deletions src/main/router/queue-router.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
import { Router } from "@main/lib/route-pass/Router";
import { filter } from "@main/lib/song/filter";
import { indexMapper } from "@main/lib/song/indexMapper";
import order from "@main/lib/song/order";
import { Storage } from "@main/lib/storage/Storage";
import { mainWindow } from "@main/main";
import { none, some } from "@shared/lib/rust-types/Optional";
import { fail, ok } from "@shared/lib/rust-types/Result";
import { shuffle } from "@shared/lib/tungsten/collections";
import errorIgnored from "@shared/lib/tungsten/errorIgnored";
import {
Optional,
QueueCreatePayload,
Expand All @@ -6,16 +16,6 @@ import {
Song,
SongIndex,
} from "@shared/types/common.types";
import { Router } from "@main/lib/route-pass/Router";
import { none, some } from "@shared/lib/rust-types/Optional";
import { fail, ok } from "@shared/lib/rust-types/Result";
import { filter } from "@main/lib/song/filter";
import { indexMapper } from "@main/lib/song/indexMapper";
import order from "@main/lib/song/order";
import { Storage } from "@main/lib/storage/Storage";
import { shuffle } from "@shared/lib/tungsten/collections";
import errorIgnored from "@shared/lib/tungsten/errorIgnored";
import { mainWindow } from "@main/main";

let queue: Song[];

Expand Down
2 changes: 1 addition & 1 deletion src/main/router/resource-router.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Router } from "@main/lib/route-pass/Router";
import { Storage } from "@main/lib/storage/Storage";
import { none, some } from "@shared/lib/rust-types/Optional";
import { fail, ok } from "@shared/lib/rust-types/Result";
import { Storage } from "@main/lib/storage/Storage";
import path from "path";
import sharp from "sharp";
import { pathToFileURL } from "url";
Expand Down
2 changes: 1 addition & 1 deletion src/main/router/songs-pool-router.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Router } from "@main/lib/route-pass/Router";
import { none, some } from "@shared/lib/rust-types/Optional";
import { filter } from "@main/lib/song/filter";
import { indexMapper } from "@main/lib/song/indexMapper";
import order from "@main/lib/song/order";
import { Storage } from "@main/lib/storage/Storage";
import { none, some } from "@shared/lib/rust-types/Optional";

Router.respond("query::songsPool::init", (_evt, payload) => {
const indexes = Storage.getTable("system").get("indexes");
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Scenes } from "@shared/types/common.types";
import NoticeContainer from "./components/notice/NoticeContainer";
import Popover from "./components/popover/Popover";
import "@renderer/keyboard-registers/initialize";
import { fetchOs, os, setOs } from "./lib/os";
import { TokenNamespace } from "@shared/lib/tungsten/token";
import { sidebarWidth } from "./scenes/main-scene/main.utils";
import "@renderer/keyboard-registers/initialize";
import ErrorScene from "@renderer/scenes/ErrorScene";
import NoScene from "@renderer/scenes/NoScene";
import DirSelectScene from "@renderer/scenes/dir-select-scene/DirSelectScene";
import LoadingScene from "@renderer/scenes/loading-scene/LoadingScene";
import MainScene from "@renderer/scenes/main-scene/MainScene";
import { sidebarWidth } from "./scenes/main-scene/main.utils";
import { TokenNamespace } from "@shared/lib/tungsten/token";
import { Scenes } from "@shared/types/common.types";
import type { JSX } from "solid-js";
import { createMemo, createSignal, Match, onCleanup, onMount, Show, Switch } from "solid-js";

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/InfiniteScroller.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Impulse from "@renderer/lib/Impulse";
import { OmitPropsWithoutReturnType, Optional } from "@shared/types/common.types";
import { RequestAPI } from "@shared/types/router.types";
import Impulse from "@renderer/lib/Impulse";
import {
Component,
createSignal,
Expand Down
7 changes: 4 additions & 3 deletions src/renderer/src/components/notice/NoticeContainer.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Result } from "@shared/types/common.types";
import Notice, { IconNoticeType } from "./Notice";
import { fail, ok } from "@shared/lib/rust-types/Result";
import { TokenNamespace } from "@shared/lib/tungsten/token";
import Notice, { IconNoticeType } from "./Notice";
import { Result } from "@shared/types/common.types";
import { NoticeTypeIconMap } from "@shared/types/common.types";
import { For, createSignal } from "solid-js";
import { createStore } from "solid-js/store";
import { NoticeTypeIconMap } from "@shared/types/common.types";

const [notices, setNotices] = createStore<IconNoticeType[]>([]);
const namespace = new TokenNamespace();
const [isPaused, setIsPaused] = createSignal(false);
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/settings/Settings.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { cn } from "@renderer/lib/css.utils";
import Select from "@renderer/components/select/Select";
import { changeAudioDevice } from "@renderer/components/song/song.utils";
import { cn } from "@renderer/lib/css.utils";
import { GlobeIcon, LucideIcon, Volume2Icon } from "lucide-solid";
import { Component, createEffect, createSignal, For, JSX, onMount } from "solid-js";

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/components/song/color-extractor.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Song } from "@shared/types/common.types";
import { extractColors } from "extract-colors";
import { lighten, darken, getContrast, parseToHsl, hslToColorString } from "polished";
import { Accessor, createSignal } from "solid-js";
import { Song } from "@shared/types/common.types";

const MIN_CONTRAST_RATIO = 4.5;
const MIN_VIBRANCY_THRESHOLD = 0.3;
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/src/components/song/song-detail/SongControls.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { isSongUndefined } from "@renderer/lib/song";
import Popover from "@renderer/components/popover/Popover";
import {
isPlaying,
next,
Expand All @@ -13,7 +11,9 @@ import {
handleMuteSong,
} from "../song.utils";
import Button from "@renderer/components/button/Button";
import Popover from "@renderer/components/popover/Popover";
import Slider from "@renderer/components/slider/Slider";
import { isSongUndefined } from "@renderer/lib/song";
import {
CirclePlusIcon,
GaugeIcon,
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/src/components/song/song-detail/SongDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import formatTime from "@renderer/lib/time-formatter";
import SongImage from "@renderer/components/song/SongImage";
import { useColorExtractor } from "@renderer/components/song/color-extractor";
import SongControls from "./SongControls";
import Slider from "@renderer/components/slider/Slider";
import SongImage from "@renderer/components/song/SongImage";
import { useColorExtractor } from "@renderer/components/song/color-extractor";
import {
seek,
duration,
Expand All @@ -11,6 +10,7 @@ import {
handleSeekStart,
handleSeekEnd,
} from "@renderer/components/song/song.utils";
import formatTime from "@renderer/lib/time-formatter";
import { Component, createMemo } from "solid-js";
import { Show } from "solid-js";

Expand Down
6 changes: 3 additions & 3 deletions src/renderer/src/components/song/song-item/SongItem.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ResourceID, Song } from "@shared/types/common.types";
import draggable from "@renderer/lib/draggable/draggable";
import Popover from "@renderer/components/popover/Popover";
import SongHint from "@renderer/components/song/SongHint";
import SongImage from "@renderer/components/song/SongImage";
import { useColorExtractor } from "@renderer/components/song/color-extractor";
import { song as selectedSong } from "@renderer/components/song/song.utils";
import Popover from "@renderer/components/popover/Popover";
import draggable from "@renderer/lib/draggable/draggable";
import { ResourceID, Song } from "@shared/types/common.types";
import { EllipsisVerticalIcon } from "lucide-solid";
import { transparentize } from "polished";
import { Component, createSignal, JSXElement, onMount, createMemo, Show } from "solid-js";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Optional, Order, Tag } from "@shared/types/common.types";
import { setSongsSearch } from "@renderer/components/song/song-list/song-list.utils";
import SongListSearchOrderBy from "./SongListSearchOrderBy";
import { SongListSearchTags } from "./SongListSearchTags";
import Button from "@renderer/components/button/Button";
import { Input } from "@renderer/components/input/Input";
import { setSongsSearch } from "@renderer/components/song/song-list/song-list.utils";
import { Optional, Order, Tag } from "@shared/types/common.types";
import { SearchQueryError } from "@shared/types/search-parser.types";
import { FilterIcon, SearchIcon, FilterXIcon } from "lucide-solid";
import { Accessor, Component, createSignal, Match, Setter, Signal, Switch } from "solid-js";
import { SearchQueryError } from "@shared/types/search-parser.types";

export type SearchProps = {
tags: Signal<Tag[]>;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import FilterOption from "./FilterOption";
import SelectableList from "@renderer/components/selectable-list/SelectableList";
import { OrderDirection, OrderOptions, Order } from "@shared/types/common.types";
import { SortAsc, SortDesc } from "lucide-solid";
import { Component, createMemo, createSignal, For, Match, Setter, Switch } from "solid-js";
import { OrderDirection, OrderOptions, Order } from "@shared/types/common.types";

type OrderOption = {
text: string;
Expand Down
13 changes: 7 additions & 6 deletions src/renderer/src/components/song/song-list/SongList.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { Optional, Order, ResourceID, SongsQueryPayload, Tag } from "@shared/types/common.types";
import { songsSearch } from "./song-list.utils";
import { namespace } from "@renderer/App";
import Impulse from "@renderer/lib/Impulse";
import { none, some } from "@shared/lib/rust-types/Optional";
import InfiniteScroller from "@renderer/components/InfiniteScroller";
import DropdownList from "@renderer/components/dropdown-list/DropdownList";
import SongItem from "@renderer/components/song/song-item/SongItem";
import SongListSearch from "@renderer/components/song/song-list-search/SongListSearch";
import { songsSearch } from "./song-list.utils";
import DropdownList from "@renderer/components/dropdown-list/DropdownList";
import Impulse from "@renderer/lib/Impulse";
import { none, some } from "@shared/lib/rust-types/Optional";
import { Optional, Order, ResourceID, SongsQueryPayload, Tag } from "@shared/types/common.types";
import { Song } from "@shared/types/common.types";
import { SearchQueryError } from "@shared/types/search-parser.types";
import { ListPlus, ListStartIcon } from "lucide-solid";
import { Component, createEffect, createSignal, onCleanup, onMount } from "solid-js";
import { SearchQueryError } from "@shared/types/search-parser.types";

export type SongViewProps = {
isAllSongs?: boolean;
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/src/components/song/song-queue/SongQueue.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Song } from "@shared/types/common.types";
import { namespace } from "@renderer/App";
import Impulse from "@renderer/lib/Impulse";
import scrollIfNeeded from "@shared/lib/tungsten/scroll-if-needed";
import InfiniteScroller from "@renderer/components/InfiniteScroller";
import SongItem from "@renderer/components/song/song-item/SongItem";
import DropdownList from "@renderer/components/dropdown-list/DropdownList";
import SongItem from "@renderer/components/song/song-item/SongItem";
import Impulse from "@renderer/lib/Impulse";
import scrollIfNeeded from "@shared/lib/tungsten/scroll-if-needed";
import { Song } from "@shared/types/common.types";
import { ListPlusIcon, DeleteIcon } from "lucide-solid";
import { Component, createSignal, onCleanup, onMount } from "solid-js";

Expand Down
6 changes: 3 additions & 3 deletions src/renderer/src/components/song/song.utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import DEFAULT_SONG_BG_SMALL from "@renderer/assets/osu-default-background-small.jpg";
import { delay } from "@renderer/lib/delay";
import { none, some } from "@shared/lib/rust-types/Optional";
import { isSongUndefined, msToBPM } from "@renderer/lib/song";
import { createEffect, createSignal } from "solid-js";
import { none, some } from "@shared/lib/rust-types/Optional";
import { AudioSource, Optional, Song } from "@shared/types/common.types";
import DEFAULT_SONG_BG_SMALL from "@renderer/assets/osu-default-background-small.jpg";
import { createEffect, createSignal } from "solid-js";

/** Range from 0 to 1. */
export type ZeroToOne = number;
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/src/keyboard-registers/c-play-pause.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Keyboard } from "@renderer/lib/Keyboard";
import { togglePlay } from "@renderer/components/song/song.utils";
import { Keyboard } from "@renderer/lib/Keyboard";

Keyboard.register({
key: "c",
Expand Down
Loading

0 comments on commit 5d95057

Please sign in to comment.