Skip to content
This repository has been archived by the owner on Aug 12, 2024. It is now read-only.

Commit

Permalink
feat: migration to TypeScript part 3
Browse files Browse the repository at this point in the history
Co-authored-by: Su-Yong <[email protected]>
  • Loading branch information
JellyBrick and Su-Yong committed Sep 3, 2023
1 parent 03c1ab0 commit 278618b
Show file tree
Hide file tree
Showing 25 changed files with 676 additions and 382 deletions.
42 changes: 41 additions & 1 deletion config/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,39 @@ export interface WindowSizeConfig {
height: number;
}

export interface DefaultConfig {
'window-size': {
width: number;
height: number;
}
'window-maximized': boolean;
'window-position': {
x: number;
y: number;
}
url: string;
options: {
tray: boolean;
appVisible: boolean;
autoUpdates: boolean;
alwaysOnTop: boolean;
hideMenu: boolean;
hideMenuWarned: boolean;
startAtLogin: boolean;
disableHardwareAcceleration: boolean;
removeUpgradeButton: boolean;
restartOnConfigChanges: boolean;
trayClickPlayPause: boolean;
autoResetAppCache: boolean;
resumeOnStart: boolean;
likeButtons: string;
proxy: string;
startingPage: string;
overrideUserAgent: boolean;
themes: string[];
}
}

const defaultConfig = {
'window-size': {
width: 1100,
Expand Down Expand Up @@ -54,15 +87,22 @@ const defaultConfig = {
'downloader': {
enabled: false,
ffmpegArgs: [], // E.g. ["-b:a", "192k"] for an audio bitrate of 192kb/s
downloadFolder: undefined, // Custom download folder (absolute path)
downloadFolder: undefined as string | undefined, // Custom download folder (absolute path)
preset: 'mp3',
skipExisting: false,
playlistMaxItems: undefined as number | undefined,
},
'last-fm': {
enabled: false,
token: undefined as string | undefined, // Token used for authentication
session_key: undefined as string | undefined, // Session key used for scrobbling
api_root: 'http://ws.audioscrobbler.com/2.0/',
api_key: '04d76faaac8726e60988e14c105d421a', // Api key registered by @semvis123
secret: 'a5d2a36fdf64819290f6982481eaffa2',
},
'lyric-genius': {
romanizedLyrics: false,
},
'discord': {
enabled: false,
autoReconnect: true, // If enabled, will try to reconnect to discord every 5 seconds after disconnecting or failing to connect
Expand Down
47 changes: 45 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
"lint": "xo",
"changelog": "auto-changelog",
"plugins": "npm run plugin:adblocker && npm run plugin:bypass-age-restrictions",
"plugin:adblocker": "del-cli plugins/adblocker/ad-blocker-engine.bin && node plugins/adblocker/blocker.ts",
"plugin:adblocker": "del-cli plugins/adblocker/ad-blocker-engine.bin && tsc plugins/adblocker/blocker.ts && node dist/plugins/adblocker/blocker.js",
"plugin:bypass-age-restrictions": "del-cli node_modules/simple-youtube-age-restriction-bypass/package.json && npm run generate:package simple-youtube-age-restriction-bypass",
"release:linux": "npm run clean && electron-builder --linux -p always -c.snap.publish=github",
"release:mac": "npm run clean && electron-builder --mac -p always",
Expand Down Expand Up @@ -135,6 +135,7 @@
"keyboardevents-areequal": "0.2.2",
"md5": "2.3.0",
"mpris-service": "2.1.2",
"node-id3": "0.2.6",
"simple-youtube-age-restriction-bypass": "git+https://github.com/zerodytrash/Simple-YouTube-Age-Restriction-Bypass.git#v2.5.9",
"vudio": "2.1.1",
"youtubei.js": "6.1.0",
Expand All @@ -149,7 +150,10 @@
"devDependencies": {
"@playwright/test": "1.37.1",
"@total-typescript/ts-reset": "0.5.1",
"@types/electron-localshortcut": "^3.1.0",
"@types/howler": "^2.2.8",
"@types/html-to-text": "^9.0.1",
"@types/md5": "^2.3.2",
"@types/youtube-player": "^5.5.7",
"@typescript-eslint/eslint-plugin": "6.5.0",
"auto-changelog": "2.4.0",
Expand Down
4 changes: 2 additions & 2 deletions plugins/discord/back.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export default (
largeImageKey: songInfo.imageSrc ?? '',
largeImageText: songInfo.album ?? '',
buttons: options.listenAlong ? [
{ label: 'Listen Along', url: songInfo.url },
{ label: 'Listen Along', url: songInfo.url ?? '' },
] : undefined,
};

Expand All @@ -176,7 +176,7 @@ export default (
}
} else if (!options.hideDurationLeft) {
// Add the start and end time of the song
const songStartTime = Date.now() - (songInfo.elapsedSeconds * 1000);
const songStartTime = Date.now() - ((songInfo.elapsedSeconds ?? 0) * 1000);
activityInfo.startTimestamp = songStartTime;
activityInfo.endTimestamp
= songStartTime + (songInfo.songDuration * 1000);
Expand Down
Loading

0 comments on commit 278618b

Please sign in to comment.