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

3480
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -106,8 +106,8 @@
},
"dependencies": {
"@cliqz/adblocker-electron": "1.26.6",
"@ffmpeg/core": "0.12.2",
"@ffmpeg/ffmpeg": "0.12.5",
"@ffmpeg/core": "0.11.0",
"@ffmpeg/ffmpeg": "0.11.6",
"@foobar404/wave": "2.0.4",
"@xhayper/discord-rpc": "1.0.22",
"async-mutex": "0.4.0",
@ -115,7 +115,7 @@
"butterchurn": "2.6.7",
"butterchurn-presets": "2.4.7",
"custom-electron-prompt": "1.5.7",
"custom-electron-titlebar": "4.2.7",
"custom-electron-titlebar": "4.1.6",
"electron-better-web-request": "1.0.1",
"electron-debug": "3.2.0",
"electron-is": "3.0.0",
@ -130,7 +130,6 @@
"keyboardevents-areequal": "0.2.2",
"md5": "2.3.0",
"mpris-service": "2.1.2",
"node-fetch": "2.7.0",
"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",
@ -138,6 +137,7 @@
},
"overrides": {
"xml2js": "0.6.2",
"node-fetch": "2.7.0",
"@electron/universal": "1.4.1"
},
"devDependencies": {
@ -151,6 +151,7 @@
"eslint-plugin-import": "2.28.1",
"eslint-plugin-prettier": "5.0.0",
"node-gyp": "9.4.0",
"patch-package": "^8.0.0",
"playwright": "1.37.1"
},
"auto-changelog": {

View File

@ -2,7 +2,6 @@ const { promises } = require('node:fs'); // Used for caching
const path = require('node:path');
const { ElectronBlocker } = require('@cliqz/adblocker-electron');
const fetch = require('node-fetch');
const SOURCES = [
'https://raw.githubusercontent.com/kbinani/adblock-youtube-ads/master/signed.txt',

View File

@ -1,5 +1,5 @@
const { ipcRenderer } = require('electron');
const { Titlebar, TitlebarColor } = require('custom-electron-titlebar');
const { Titlebar, Color } = require('custom-electron-titlebar');
const config = require('../../config');
const { isEnabled } = require('../../config/plugins');
@ -12,9 +12,9 @@ module.exports = () => {
const visible = () => Boolean($('.cet-menubar').firstChild);
const bar = new Titlebar({
icon: 'https://cdn-icons-png.flaticon.com/512/5358/5358672.png',
backgroundColor: TitlebarColor.fromHex('#050505'),
itemBackgroundColor: TitlebarColor.fromHex('#1d1d1d'),
svgColor: TitlebarColor.WHITE,
backgroundColor: Color.fromHex('#050505'),
itemBackgroundColor: Color.fromHex('#1d1d1d'),
svgColor: Color.WHITE,
menu: config.get('options.hideMenu') ? null : undefined,
});
bar.updateTitle(' ');

View File

@ -1,5 +1,4 @@
const { shell } = require('electron');
const fetch = require('node-fetch');
const md5 = require('md5');
const { setOptions } = require('../../config/plugins');

View File

@ -3,7 +3,6 @@ const { join } = require('node:path');
const { ipcMain } = require('electron');
const is = require('electron-is');
const { convert } = require('html-to-text');
const fetch = require('node-fetch');
const { cleanupName } = require('../../providers/song-info');
const { injectCSS } = require('../utils');
@ -99,7 +98,7 @@ const getLyrics = async (url) => {
}
const html = await response.text();
const lyrics = convert(html, {
return convert(html, {
baseElements: {
selectors: ['[class^="Lyrics__Container"]', '.lyrics'],
},
@ -116,7 +115,6 @@ const getLyrics = async (url) => {
},
},
});
return lyrics;
};
module.exports.toggleRomanized = toggleRomanized;

View File

@ -1,5 +1,4 @@
const { ipcMain } = require('electron');
const fetch = require('node-fetch');
const is = require('electron-is');
const { sortSegments } = require('./segments');
@ -38,11 +37,9 @@ const fetchSegments = async (apiURL, categories) => {
}
const segments = await resp.json();
const sortedSegments = sortSegments(
return sortSegments(
segments.map((submission) => submission.segment),
);
return sortedSegments;
} catch (error) {
if (is.dev()) {
console.log('error on sponsorblock request:', error);

View File

@ -1,5 +1,4 @@
const { ipcMain } = require('electron');
const fetch = require('node-fetch');
const registerCallback = require('../../providers/song-info');
@ -24,7 +23,7 @@ const post = async (data) => {
'Access-Control-Allow-Headers': '*',
'Access-Control-Allow-Origin': '*',
};
const url = `http://localhost:${port}/`;
const url = `http://127.0.0.1:${port}/`;
fetch(url, {
method: 'POST',
headers,

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));
}