chore(deps): remove node-fetch, migration to node v18 fetch API

This commit is contained in:
JellyBrick
2023-08-29 21:15:22 +09:00
parent 92da06eb96
commit aacc2d261b
10 changed files with 1342 additions and 2178 deletions

View File

@ -1,8 +1,8 @@
const { Titlebar, TitlebarColor } = require('custom-electron-titlebar');
const { Titlebar, Color } = require('custom-electron-titlebar');
module.exports = () => {
new Titlebar({
backgroundColor: TitlebarColor.fromHex('#050505'),
backgroundColor: Color.fromHex('#050505'),
minimizable: false,
maximizable: false,
menu: null,

View File

@ -1,5 +1,4 @@
const { ipcMain, nativeImage } = require('electron');
const fetch = require('node-fetch');
const config = require('../config');
const { cache } = require('../providers/decorators');
@ -31,8 +30,8 @@ const getImage = cache(
*/
async (src) => {
const result = await fetch(src);
const buffer = await result.buffer();
const output = nativeImage.createFromBuffer(buffer);
const buffer = await result.arrayBuffer();
const output = nativeImage.createFromBuffer(Buffer.from(buffer));
if (output.isEmpty() && !src.endsWith('.jpg') && src.includes('.jpg')) { // Fix hidden webp files (https://github.com/th-ch/youtube-music/issues/315)
return getImage(src.slice(0, src.lastIndexOf('.jpg') + 4));
}