Skip to content

Commit

Permalink
Bump deps
Browse files Browse the repository at this point in the history
  • Loading branch information
PapiOphidian committed Jul 7, 2024
1 parent 0f1d933 commit 504b0a2
Show file tree
Hide file tree
Showing 23 changed files with 1,893 additions and 976 deletions.
Binary file modified .yarn/install-state.gz
Binary file not shown.
541 changes: 541 additions & 0 deletions .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ enableGlobalCache: true

nodeLinker: node-modules

plugins:
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
spec: "@yarnpkg/plugin-interactive-tools"

yarnPath: .yarn/releases/yarn-3.3.0.cjs
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
"start": "node --enable-source-maps --optimize_for_size ./packages/server/dist/index.js"
},
"devDependencies": {
"@types/node": "^18.15.11",
"@typescript-eslint/eslint-plugin": "^5.57.0",
"@typescript-eslint/parser": "^5.57.0",
"eslint": "^8.36.0",
"turbo": "^1.8.8",
"typescript": "^5.0.2"
"@types/node": "^20.14.10",
"@typescript-eslint/eslint-plugin": "^7.15.0",
"@typescript-eslint/parser": "^7.15.0",
"eslint": "^9.6.0",
"turbo": "^2.0.6",
"typescript": "^5.5.3"
},
"packageManager": "yarn@3.3.0"
}
4 changes: 2 additions & 2 deletions packages/addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
],
"license": "MIT",
"devDependencies": {
"@napi-rs/cli": "^2.15.2"
"@napi-rs/cli": "^2.18.4"
},
"engines": {
"node": ">= 18"
},
"scripts": {
"artifacts": "napi artifacts",
"build": "napi build --platform --release",
"build-old": "napi build --platform --release",
"build:debug": "napi build --platform",
"version": "napi version"
},
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {}
8 changes: 4 additions & 4 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"types": "index.d.ts",
"scripts": {
"lint": "eslint . --ext js,ts",
"lint": "eslint .",
"build": "node prebuild.js && tsc -p ./server-tsconfig.json",
"postinstall": "npm run build"
},
Expand All @@ -21,9 +21,9 @@
"author": "PapiOphidian",
"license": "MIT",
"dependencies": {
"@discordjs/voice": "^0.16.0",
"lavalink-types": "^2.0.2",
"uWebSockets.js": "uNetworking/uWebSockets.js#v20.20.0"
"@discordjs/voice": "^0.17.0",
"lavalink-types": "^2.1.1",
"uWebSockets.js": "https://github.com/uNetworking/uWebSockets.js.git#commit=f40213ec0a97d0d8721d9d32d92d6eb6ddcd22e7"
},
"bugs": {
"url": "https://github.com/AmandaDiscord/Volcano/issues"
Expand Down
3 changes: 3 additions & 0 deletions packages/server/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
"ignores": ["dist"]
}
28 changes: 14 additions & 14 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"create-release": "node ./scripts/release.js",
"auth-gen": "node ./scripts/auth-gen.js",
"dep-report": "node ./scripts/generateDependencyReport.js",
"lint": "eslint . --ext .ts"
"lint": "eslint . -c eslint.config.js"
},
"engines": {
"node": ">=18.0.0",
Expand All @@ -33,25 +33,25 @@
"license": "MIT",
"dependencies": {
"@discordjs/opus": "0.9.0",
"@discordjs/voice": "^0.16.0",
"@discordjs/voice": "^0.17.0",
"@lavalink/encoding": "^0.1.2",
"backtracker": "3.3.2",
"ffmpeg-static": "^5.1.0",
"html-entities": "^2.3.3",
"libsodium-wrappers": "0.7.11",
"backtracker": "^4.0.0",
"ffmpeg-static": "^5.2.0",
"html-entities": "^2.5.2",
"libsodium-wrappers": "0.7.13",
"m3u8stream": "^0.8.6",
"music-metadata": "^8.1.4",
"node-html-parser": "^6.1.5",
"play-dl": "^1.9.6",
"music-metadata": "^8.3.0",
"node-html-parser": "^6.1.13",
"play-dl": "^1.9.7",
"twitch-m3u8": "github:AmandaDiscord/twitch-m3u8#ba927b26fb3c5cb118d75c20f990c5cce8a1ae7a",
"uWebSockets.js": "uNetworking/uWebSockets.js#v20.20.0",
"uWebSockets.js": "https://github.com/uNetworking/uWebSockets.js.git#commit=f40213ec0a97d0d8721d9d32d92d6eb6ddcd22e7",
"volcano-sdk": "2.0.0-rc.2",
"yaml": "^2.2.1",
"ytmusic-api": "^4.1.0"
"yaml": "^2.4.5",
"ytmusic-api": "^5.2.2"
},
"devDependencies": {
"lavalink-types": "2.0.2",
"tsup": "^6.7.0"
"lavalink-types": "2.1.1",
"tsup": "^8.1.0"
},
"files": [
"./dist",
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const defaultOptions = {
}
},
server: {
port: Number(process.env.PORT || 2333),
port: Number(process.env.PORT ?? 2333),
address: "0.0.0.0"
},
lavalink: {
Expand Down
29 changes: 13 additions & 16 deletions packages/server/src/loaders/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ app.get(`/v${lavalinkMajor}/loadtracks`, async (res, req) => {
const payload = JSON.stringify(result.result);
res.writeStatus("200 OK");
Util.assignHeadersToResponse(res, Constants.baseHTTPResponseHeaders);
return res.end(payload, true);
return void res.end(payload, true);
}
});

Expand All @@ -92,7 +92,7 @@ app.get(`/v${lavalinkMajor}/decodetrack`, (res, req) => {
const payload = JSON.stringify(data);
res.writeStatus("200 OK");
Util.assignHeadersToResponse(res, Constants.baseHTTPResponseHeaders);
return res.end(payload, true);
return void res.end(payload, true);
});


Expand All @@ -110,7 +110,7 @@ app.post(`/v${lavalinkMajor}/decodetracks`, async (res, req) => {
const payload = JSON.stringify(data);
res.writeStatus("200 OK");
Util.assignHeadersToResponse(res, Constants.baseHTTPResponseHeaders);
return res.end(payload, true);
return void res.end(payload, true);
});


Expand Down Expand Up @@ -158,7 +158,7 @@ app.get(`/v${lavalinkMajor}/info`, async (res, req) => {
const payload = JSON.stringify(data);
res.writeStatus("200 OK");
Util.assignHeadersToResponse(res, Constants.baseHTTPResponseHeaders);
return res.end(payload, true);
return void res.end(payload, true);
});


Expand All @@ -173,7 +173,7 @@ app.get(`/v${lavalinkMajor}/stats`, async (res, req) => {
const payload = JSON.stringify(data);
res.writeStatus("200 OK");
Util.assignHeadersToResponse(res, Constants.baseHTTPResponseHeaders);
return res.end(payload, true);
return void res.end(payload, true);
});


Expand All @@ -185,7 +185,7 @@ app.get("/version", (res, req) => {
res.writeStatus("200 OK")
.writeHeader("Content-Type", "text/plain")
.writeHeader("Lavalink-Api-Version", lavalinkMajor);
return res.end(payload, true);
return void res.end(payload, true);
});


Expand Down Expand Up @@ -236,7 +236,7 @@ app.get(`/v${lavalinkMajor}/sessions/:sessionID/players`, async (res, req) => {
const payload = JSON.stringify(data);
res.writeStatus("200 OK");
Util.assignHeadersToResponse(res, Constants.baseHTTPResponseHeaders);
return res.end(payload, true);
return void res.end(payload, true);
});


Expand Down Expand Up @@ -288,7 +288,7 @@ app.get(`/v${lavalinkMajor}/sessions/:sessionID/players/:guildID`, async (res, r
const payload = JSON.stringify(data);
res.writeStatus("200 OK");
Util.assignHeadersToResponse(res, Constants.baseHTTPResponseHeaders);
return res.end(payload, true);
return void res.end(payload, true);
});
app.patch(`/v${lavalinkMajor}/sessions/:sessionID/players/:guildID`, async (res, req) => {
if (!Util.authenticate(req, res)) return;
Expand Down Expand Up @@ -329,7 +329,7 @@ app.patch(`/v${lavalinkMajor}/sessions/:sessionID/players/:guildID`, async (res,
const stringified = JSON.stringify(payload);
res.writeStatus("200 OK");
Util.assignHeadersToResponse(res, Constants.baseHTTPResponseHeaders);
return res.end(stringified, true);
return void res.end(stringified, true);
});
app.del(`/v${lavalinkMajor}/sessions/:sessionID/players/:guildID`, async (res, req) => {
if (!Util.authenticate(req, res)) return;
Expand Down Expand Up @@ -371,7 +371,7 @@ app.patch(`/v${lavalinkMajor}/sessions/:sessionID`, async (res, req) => {
const stringified = JSON.stringify(payload);
res.writeStatus("200 OK");
Util.assignHeadersToResponse(res, Constants.baseHTTPResponseHeaders);
return res.end(stringified, true);
return void res.end(stringified, true);
});


Expand All @@ -383,7 +383,7 @@ async function doTrackLoad(id?: string | null, logRequest = true): Promise<{ sym
if (!id || typeof id !== "string") return { error: new Error("Invalid or no identifier query string provided."), result: payload };

const identifier = entities.decode(id);
const match = identifier.match(IDRegex);
const match = IDRegex.exec(identifier);
if (!match) {
if (logRequest) console.log(`Got request to load for identifier "${identifier}"`);
return { error: new Error("Identifier did not match regex"), result: payload }; // Should theoretically never happen, but TypeScript doesn't know this
Expand Down Expand Up @@ -420,11 +420,8 @@ async function doTrackLoad(id?: string | null, logRequest = true): Promise<{ sym
function assignResults(result: Awaited<ReturnType<NonNullable<import("volcano-sdk").Plugin["infoHandler"]>>>, source: string, payload: import("lavalink-types").TrackLoadingResult) {
if (result.source) source = result.source;
payload.tracks = result.entries.map(t => ({
encoded: encoding.encode(Object.assign({ flags: 1, version: 2, source: source, position: BigInt(0), probeInfo: t["probeInfo"] }, t, { length: BigInt(t.length) })),
info: Object.assign({ position: 0 }, (() => {
delete t["probeInfo"];
return Object.assign({}, t, { isSeekable: !t.isStream, sourceName: source }) as typeof t & { isSeekable: boolean; sourceName: string; };
})())
encoded: encoding.encode({ flags: 1, version: 2, source: source, position: BigInt(0), probeInfo: t["probeInfo"], ...t, length: BigInt(t.length) }),
info: { position: 0, ...(() => { delete t["probeInfo"]; return { ...t, isSeekable: !t.isStream, sourceName: source } })() }
}));
if (result.plData) payload.playlistInfo = result.plData;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/server/src/loaders/stdin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function install(url: string) {
const onError = er => {
child.removeListener("exit", onExit);
clearTimeout(timer);
rej(er);
rej(er as Error);
child.kill();
};
child.once("exit", onExit);
Expand Down
6 changes: 3 additions & 3 deletions packages/server/src/sources/BandcampSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class BandcampSource extends Plugin {
const html = await fetch(info.uri!, { redirect: "follow", headers: this.utils.Constants.baseHTTPRequestHeaders }).then(d => d.text());
const parser = htmlParse.default(html);
const head = parser.getElementsByTagName("head")[0];
const stream = head.toString().match(streamRegex);
const stream = streamRegex.exec(head.toString());
if (!stream) throw new Error("There was no stream URL for that track");
const response = await this.utils.connect(entities.decode(stream[1].replace("&quot;", "")), { headers: this.utils.Constants.baseHTTPRequestHeaders });

Expand All @@ -47,7 +47,7 @@ class BandcampSource extends Plugin {
private static parse(html: string) {
const parser = htmlParse.default(html);
const head = parser.getElementsByTagName("head")[0];
const script = head.querySelector("script[type=\"application/ld+json\"]")?.innerHTML || "{}";
const script = head.querySelector("script[type=\"application/ld+json\"]")?.innerHTML ?? "{}";
const data = JSON.parse(script);
if (!data.name) throw new Error("No information about that track was given");
return data;
Expand All @@ -65,7 +65,7 @@ class BandcampSource extends Plugin {
}

private static getDurationFromString(duration: string) {
const match = duration?.match(durationRegex);
const match = durationRegex.exec(duration);
if (!match) return 0;
const hours = Number(match[1]);
const minutes = Number(match[2]);
Expand Down
10 changes: 5 additions & 5 deletions packages/server/src/sources/HTTPSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class HTTPSource extends Plugin {
resource = followed.url;
const data = followed.data;

const mimeMatch = data.headers["content-type"]?.match(mimeRegex);
const mimeMatch = mimeRegex.exec(data.headers["content-type"]);
if (!mimeMatch || (mimeMatch[1] === "application" && !supportedApplicationTypes.includes(mimeMatch[2])) || (mimeMatch[1] === "audio" && unsupportedAudioTypes.includes(mimeMatch[2]))) {
data.end();
data.destroy();
for (const plugin of lavalinkPlugins) {
const result = await plugin.postHTTPProcessUnknown?.(resource, data.headers);
if (result && result.entries.length) {
if (result?.entries.length) {
if (!result.source && plugin.source) result.source = plugin.source;
return result;
}
Expand Down Expand Up @@ -92,11 +92,11 @@ class HTTPSource extends Plugin {
return {
entries: [
{
title: parsed.common.title || "Unknown title",
author: parsed.common.artist || "Unknown author",
title: parsed.common.title ?? "Unknown title",
author: parsed.common.artist ?? "Unknown author",
identifier: resource,
uri: resource,
length: Math.round((parsed.format.duration || 0) * 1000),
length: Math.round((parsed.format.duration ?? 0) * 1000),
isStream: chunked,
probeInfo: {
raw: probe,
Expand Down
6 changes: 3 additions & 3 deletions packages/server/src/sources/LocalSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class LocalSource extends Plugin {
{
identifier: resource,
uri: resource,
author: meta.common.artist || "Unknown author",
length: Math.round((meta.format.duration || 0) * 1000),
title: meta.common.title || "Unknown title",
author: meta.common.artist ?? "Unknown author",
length: Math.round((meta.format.duration ?? 0) * 1000),
title: meta.common.title ?? "Unknown title",
isStream: false,
probeInfo: {
raw: fileEnding,
Expand Down
18 changes: 9 additions & 9 deletions packages/server/src/sources/TwitchSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@ class TwitchSource extends Plugin {
}

public async infoHandler(resource: string) {
const vod = resource.match(vodRegex);
const vod = vodRegex.exec(resource);
if (vod) {
const data = await twitch.getVod(vod[1]) as Array<import("twitch-m3u8").Stream>;
if (!data.length) throw new Error("There were no stream URLs available for that vod");
const audioOnly = data.find(d => d.quality === "Audio only");
const chosen = audioOnly ? audioOnly : data[0];
const chosen = audioOnly ?? data[0];
const streamerName = chosen.url.split("_").slice(1, audioOnly ? -3 : -2).join("_");
const res = await fetch(resource, { redirect: "follow", headers: this.utils.Constants.baseHTTPRequestHeaders }).then(r => r.text());
const parser = htmlParse.default(res);
const head = parser.getElementsByTagName("head")[0];
const title = entities.decode(head.querySelector("meta[property=\"og:title\"]")?.getAttribute("content")?.split("-").slice(0, -1).join("-").trim() || `Twitch Stream of ${streamerName}`);
const duration = +(head.querySelector("meta[property=\"og:video:duration\"]")?.getAttribute("content") || 0) * 1000;
const title = entities.decode(head.querySelector("meta[property=\"og:title\"]")?.getAttribute("content")?.split("-").slice(0, -1).join("-").trim() ?? `Twitch Stream of ${streamerName}`);
const duration = +(head.querySelector("meta[property=\"og:video:duration\"]")?.getAttribute("content") ?? 0) * 1000;
return {
entries: [
{
Expand All @@ -43,15 +43,15 @@ class TwitchSource extends Plugin {
};
}

const user = resource.match(channelRegex);
const user = channelRegex.exec(resource);
if (!user) throw new Error("The provided link was not to a user or a vod");
const data = await twitch.getStream(user[1]);
if (!data.length) throw new Error("There were no stream URLs available for that stream");
const uri = `https://www.twitch.tv/${user[1]}`;
const res = await fetch(uri, { redirect: "follow", headers: this.utils.Constants.baseHTTPRequestHeaders }).then(r => r.text());
const parser = htmlParse.default(res);
const head = parser.getElementsByTagName("head")[0];
const title = entities.decode(head.querySelector("meta[property=\"og:description\"]")?.getAttribute("content") || `Twitch Stream of ${user[1]}`);
const title = entities.decode(head.querySelector("meta[property=\"og:description\"]")?.getAttribute("content") ?? `Twitch Stream of ${user[1]}`);
return {
entries: [
{
Expand All @@ -67,12 +67,12 @@ class TwitchSource extends Plugin {
}

public async streamHandler(info: import("@lavalink/encoding").TrackInfo) {
const vod = info.uri!.match(vodRegex);
const user = info.uri!.match(channelRegex);
const vod = vodRegex.exec(info.uri!);
const user = channelRegex.exec(info.uri!);
const streams = await twitch[vod ? "getVod" : "getStream"](vod ? vod[1] : user![1]) as Array<import("twitch-m3u8").Stream>;
if (!streams.length) throw new Error("There were no available streams for playback");
const audioOnly = streams.find(d => d.quality === "Audio only");
const chosen = audioOnly ? audioOnly : streams[0];
const chosen = audioOnly ?? streams[0];
return { stream: m3u8(chosen.url) };
}
}
Expand Down
Loading

0 comments on commit 504b0a2

Please sign in to comment.