Skip to content

Commit

Permalink
Merge pull request #80 from lovegaoshi/dev-noxplayer
Browse files Browse the repository at this point in the history
chore: lint
  • Loading branch information
lovegaoshi authored May 31, 2024
2 parents e3ad809 + 500d612 commit e2f448d
Show file tree
Hide file tree
Showing 27 changed files with 96 additions and 52 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ module.exports = {
['@components', './src/components'],
['@stores', './src/stores'],
['@hooks', './src/hooks'],
['@enums', './src/azusa-player-mobile/src/enums'],
['@APM', './src/azusa-player-mobile/src'],
['@enums', './azusa-player-mobile/src/enums'],
['@APM', './azusa-player-mobile/src'],
],
extensions: ['.ts', '.js', '.jsx', '.json', 'ts', 'tsx'],
},
Expand Down Expand Up @@ -88,5 +88,7 @@ module.exports = {
'react/jsx-props-no-spreading': 'off',
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error'],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': ['error'],
},
};
1 change: 1 addition & 0 deletions .github/workflows/build-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,6 @@ jobs:

- name: yarn ci
run: |
yarn compile
yarn ci:format
yarn ci:lint
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "azusa-player-mobile"]
path = src/azusa-player-mobile
path = azusa-player-mobile
url = https://github.com/lovegaoshi/azusa-player-mobile.git
branch = dev
branch = dev
1 change: 1 addition & 0 deletions azusa-player-mobile
Submodule azusa-player-mobile added at c9ff5b
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@
"@babel/preset-react": "^7.24.6",
"@babel/preset-typescript": "^7.24.6",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.13",
"@types/base-64": "^1.0.2",
"@types/chrome": "^0.0.268",
"@types/he": "^1.2.3",
"@types/js-base64": "^3.3.1",
"@types/md5": "^2.3.5",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
Expand Down
1 change: 0 additions & 1 deletion src/azusa-player-mobile
Submodule azusa-player-mobile deleted from 12d446
1 change: 0 additions & 1 deletion src/components/Playlist/Playlist.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-shadow */
import React from 'react';

import { useNoxSetting } from '@APM/stores/useApp';
Expand Down
1 change: 0 additions & 1 deletion src/components/Playlist/PlaylistHeader/PlaylistHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-shadow */
import React from 'react';
import Box from '@mui/material/Box';
import Grid from '@mui/material/Grid';
Expand Down
1 change: 0 additions & 1 deletion src/components/Playlist/SongList/SongInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-shadow */
import React from 'react';
import { styled } from '@mui/material/styles';
import TableCell, { tableCellClasses } from '@mui/material/TableCell';
Expand Down
1 change: 0 additions & 1 deletion src/components/Playlist/SongList/SongList.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-shadow */
import React from 'react';
import { createTheme, ThemeProvider } from '@mui/material/styles';
import Table from '@mui/material/Table';
Expand Down
1 change: 0 additions & 1 deletion src/components/Playlist/SongList/SongListTableActions.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable no-shadow */
import React from 'react';
import { useTheme } from '@mui/material/styles';
import PropTypes from 'prop-types';
Expand Down
2 changes: 2 additions & 0 deletions src/components/menus/DummyMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/* eslint-disable */
// @ts-nocheck
// HACK: the menu type checks are just a giant mess
import React from 'react';
import { Menu, Item, useContextMenu } from 'react-contexify';
import TerminalIcon from '@mui/icons-material/Terminal';
Expand Down
1 change: 1 addition & 0 deletions src/components/menus/PlaylistMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable */
// @ts-nocheck
import React from 'react';
import { Menu, Item, useContextMenu } from 'react-contexify';
import YoutubeSearchedForIcon from '@mui/icons-material/YoutubeSearchedFor';
Expand Down
1 change: 0 additions & 1 deletion src/components/setting/enums.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// eslint-disable-next-line no-shadow
enum SETTING_TAB {
GENERAL = '1',
TOOLBOX = '2',
Expand Down
7 changes: 5 additions & 2 deletions src/hooks/usePlayback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ import useApp from '@stores/useApp';
import { parseSongList } from '@objects/Playlist';
import renderExtendsContent from '@components/App/ExtendContent';
import { Source } from '@enums/MediaFetch';
import { DEFAULT_NULL_URL } from '@objects/Song';
import { MUSICFREE } from '@utils/mediafetch/musicfree';
import r128gain from '../utils/ffmpeg/r128util';
import {
checkBiliVideoPlayed,
initBiliHeartbeat,
} from '../utils/Bilibili/BiliOperate';
import { saveLastPlayDuration } from '../utils/ChromeStorage';
import { DEFAULT_NULL_URL } from '@objects/Song';

const SkipR128Source: (Source | undefined | MUSICFREE)[] = [Source.biliLive];

export default () => {
const playerSetting = useNoxSetting((state) => state.playerSetting);
Expand Down Expand Up @@ -49,7 +52,7 @@ export default () => {
) => {
if (
!playerSettingStore.getState().playerSetting.r128gain ||
[Source.biliLive].includes(song.source)
SkipR128Source.includes(song.source)
) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions src/stores/playingList.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const setPlayingList = () => {};
export const setPlayingIndex = () => {};
export const setPlayingList: (v: NoxMedia.Song[]) => void = () => {};
export const setPlayingIndex: (v: number, i: string) => void = () => {};
export default {};
2 changes: 1 addition & 1 deletion src/styles/skins/APMSkins.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import AzusaTheme from '@APM/components/styles/AzusaTheme';
import AzusaTheme from '@APM/components/styles/AzusaThemeRaw';
import NoxTheme from '@APM/components/styles/NoxTheme';
// eslint-disable-next-line import/extensions
import steriaJson from '@APM/components/styles/steria.json';
Expand Down
7 changes: 6 additions & 1 deletion src/utils/Bilibili/bilifavOperate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@ export const addToBiliFavlist = async (
);
};

export const syncFavlist = async (favlist: NoxMedia.Playlist) => {
export const syncFavlist = async (
favlist: NoxMedia.Playlist,
p?: NoxUtils.ProgressEmitter,
) => {
p?.(100);
const user = await getBiliUser();
if (!user.mid) return false;
const favid = await getOrInsertBiliFavlist(
Expand All @@ -113,5 +117,6 @@ export const syncFavlist = async (favlist: NoxMedia.Playlist) => {
favid,
uniqBVIDs.filter((val) => val.startsWith('BV')),
);
p?.(0);
return true;
};
5 changes: 3 additions & 2 deletions src/utils/ChromeStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import { dummyPlaylist } from '@APM/objects/Playlist';
import { DefaultSetting, NPOverwriteSetting } from '@objects/Storage';
// eslint-disable-next-line import/extensions
import rejson from '@APM/utils/rejson.json';
import { MUSICFREE } from './mediafetch/musicfree';

export const SongListSuffix = '-songList';

export const getMusicFreePlugin = (): string[] => [];
export const getMusicFreePlugin = (): MUSICFREE[] => [];

export const saveDefaultSearch = (val: SearchOptions) =>
export const saveDefaultSearch = (val: SearchOptions | MUSICFREE) =>
saveItem(StorageKeys.DEFAULT_SEARCH, val);

const removeItem = (key: string) => chrome.storage.local.remove(key);
Expand Down
5 changes: 4 additions & 1 deletion src/utils/StyleStorage.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export const savePlayerStyle = async () => ({});
export const savePlayerStyle: (
v: NoxTheme.Style,
save?: boolean,
) => Promise<void> = async () => undefined;

export default {};
10 changes: 1 addition & 9 deletions src/utils/mediafetch/bilisearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,12 @@ const fetchBiliSearchList = async (
return [];
};

interface regexFetchProps {
url: string;
progressEmitter: () => void;
useBiliTag: boolean;
fastSearch?: boolean;
cookiedSearch?: boolean;
}

const regexFetch = async ({
url,
progressEmitter = () => undefined,
fastSearch = true,
cookiedSearch = false,
}: regexFetchProps): Promise<NoxNetwork.NoxRegexFetch> => ({
}: NoxNetwork.BiliSearchFetchProps): Promise<NoxNetwork.NoxRegexFetch> => ({
songList: await fetchBiliSearchList(
url,
progressEmitter,
Expand Down
3 changes: 2 additions & 1 deletion src/utils/mediafetch/local.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export default {
regexSearchMatch: /NOT_IMPLEMETED_ERROR/,
regexFetch: () => undefined,
regexFetch: async () => ({ songList: [] }),
regexResolveURLMatch: /NOT_IMPLEMENTED_ERROR/,
resolveURL: async () => 'NOT_IMPLEMENTED_ERROR',
refreshSong: () => undefined,
resolveArtwork: async () => 'NOT_IMPLEMENTED_ERROR',
resolveURLPrefetch: async (song: NoxMedia.Song) => ({ url: song.bvid }),
};
14 changes: 11 additions & 3 deletions src/utils/mediafetch/musicfree.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
export default {};

export const MUSICFREE = {
aggregated: 'disabled-in-noxplayer',
export enum MUSICFREE {
aggregated = 'aggregated',
}

export const searcher: {
[MUSICFREE.aggregated]: (v: string, i: MUSICFREE[]) => Promise<[]>;
} = {
[MUSICFREE.aggregated]: async () => [],
};

export const searcher = [];
export const resolver: {
[k: string]: (v: NoxMedia.Song) => Promise<{ url: string }>;
} = {};
4 changes: 2 additions & 2 deletions src/utils/mediafetch/ytbvideo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { biliApiLimiter } from '@APM/utils/mediafetch/throttle';
import SongTS from '@objects/Song';
import { Source } from '@enums/MediaFetch';

const CIDPREFIX = `${Source.ytbvideo}-`;
export const CIDPREFIX = `${Source.ytbvideo}-`;

const resolveURL = async (song: NoxMedia.Song) => {
const extractedVideoInfo = await get_song(song.bvid);
Expand Down Expand Up @@ -39,7 +39,7 @@ const regexFetch = async ({
return { songList: audioInfo || [] };
};

const fetchAudioInfo = (
export const fetchAudioInfo = (
bvid: string,
progressEmitter: () => void = () => undefined,
) =>
Expand Down
18 changes: 5 additions & 13 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"@styles/*": ["./src/styles/*"],
"@objects/*": ["./src/objects/*"],
"@background/*": ["./src/background/*"],
"@enums/*": ["./src/azusa-player-mobile/src/enums/*"],
"@APM/*": ["./src/azusa-player-mobile/src/*"]
"@enums/*": ["./azusa-player-mobile/src/enums/*"],
"@APM/*": ["./azusa-player-mobile/src/*"]
},
"target": "esnext",
"module": "esnext",
Expand All @@ -24,7 +24,7 @@
// "declaration": true,
"sourceMap": true,
"outDir": "./build",
"rootDir": "./src",
"rootDir": ".",
"removeComments": true,
"noEmit": true,
"isolatedModules": true,
Expand All @@ -49,14 +49,6 @@
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true
},
"include": ["src"],
"exclude": [
"node_modules",
"build",
"public",
"src/azusa-player-mobile/__tests__",
"src/azusa-player-mobile/MusicFreePlugins",
"src/azusa-player-mobile/docs",
"src/azusa-player-mobile/src/**/*.tsx"
]
"include": ["src", "azusa-player-mobile/src/types"],
"exclude": ["node_modules", "build", "public"]
}
11 changes: 7 additions & 4 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ module.exports = (env) => {
},
},
exclude: /node_modules/,
include: [path.resolve(__dirname, 'src')],
include: [
path.resolve(__dirname, 'src'),
path.resolve(__dirname, 'azusa-player-mobile'),
],
},
{
test: /\.(s[ac]|c)ss$/i,
Expand Down Expand Up @@ -237,12 +240,12 @@ module.exports = (env) => {
'@objects': path.resolve(__dirname, 'src/objects'),
'@background': path.resolve(__dirname, 'src/background'),
'@stores': path.resolve(__dirname, 'src/stores'),
'@enums': path.resolve(__dirname, 'src/azusa-player-mobile/src/enums'),
'@enums': path.resolve(__dirname, 'azusa-player-mobile/src/enums'),
'@mfsdk': path.resolve(
__dirname,
'src/azusa-player-mobile/MusicFreePlugins/dist',
'azusa-player-mobile/MusicFreePlugins/dist',
),
'@APM': path.resolve(__dirname, 'src/azusa-player-mobile/src'),
'@APM': path.resolve(__dirname, 'azusa-player-mobile/src'),
},
extensions: ['.tsx', '.ts', '.js', '.jsx', 'svg', 'png'],
fallback: {
Expand Down
33 changes: 33 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2584,6 +2584,13 @@ __metadata:
languageName: node
linkType: hard

"@types/base-64@npm:^1.0.2":
version: 1.0.2
resolution: "@types/base-64@npm:1.0.2"
checksum: 10c0/3ad69002bd9ca4e79c010f6d9a4c9d09967687153fa6bb98e9459c731219609a4ac76920451565784e9d98cbe3567429eb60bd1561918c3a6ea2436d894346af
languageName: node
linkType: hard

"@types/body-parser@npm:*":
version: 1.19.5
resolution: "@types/body-parser@npm:1.19.5"
Expand Down Expand Up @@ -2716,6 +2723,13 @@ __metadata:
languageName: node
linkType: hard

"@types/he@npm:^1.2.3":
version: 1.2.3
resolution: "@types/he@npm:1.2.3"
checksum: 10c0/562e4ec00e31e3d464e79e6da4b8a5c21999d38ceca6a8facaa96e89c2d646f410bb58bb81f48a7472aeb4655ce40d27b7d77e5a4fa5a2d9caa0f3037caab5b7
languageName: node
linkType: hard

"@types/hoist-non-react-statics@npm:^3.3.1":
version: 3.3.5
resolution: "@types/hoist-non-react-statics@npm:3.3.5"
Expand Down Expand Up @@ -2749,6 +2763,15 @@ __metadata:
languageName: node
linkType: hard

"@types/js-base64@npm:^3.3.1":
version: 3.3.1
resolution: "@types/js-base64@npm:3.3.1"
dependencies:
js-base64: "npm:*"
checksum: 10c0/677ada5339cd48fed160552dd599350a94e4ba3698dc749f23d5301dec852742203173bf0c86556bde0f17bb7321e508d8f6289c7a0ea9eded36c15037047719
languageName: node
linkType: hard

"@types/json-schema@npm:*, @types/json-schema@npm:^7.0.8, @types/json-schema@npm:^7.0.9":
version: 7.0.15
resolution: "@types/json-schema@npm:7.0.15"
Expand Down Expand Up @@ -7805,6 +7828,13 @@ __metadata:
languageName: node
linkType: hard

"js-base64@npm:*":
version: 3.7.7
resolution: "js-base64@npm:3.7.7"
checksum: 10c0/3c905a7e78b601e4751b5e710edd0d6d045ce2d23eb84c9df03515371e1b291edc72808dc91e081cb9855aef6758292a2407006f4608ec3705373dd8baf2f80f
languageName: node
linkType: hard

"js-base64@npm:^2.4.9":
version: 2.6.4
resolution: "js-base64@npm:2.6.4"
Expand Down Expand Up @@ -8972,7 +9002,10 @@ __metadata:
"@mui/material": "npm:^5.15.19"
"@mui/styles": "npm:^5.15.19"
"@pmmmwh/react-refresh-webpack-plugin": "npm:^0.5.13"
"@types/base-64": "npm:^1.0.2"
"@types/chrome": "npm:^0.0.268"
"@types/he": "npm:^1.2.3"
"@types/js-base64": "npm:^3.3.1"
"@types/md5": "npm:^2.3.5"
"@types/react": "npm:^18.3.3"
"@types/react-dom": "npm:^18.3.0"
Expand Down

0 comments on commit e2f448d

Please sign in to comment.