chore: improve linting (#7244)

This commit is contained in:
Noel
2022-01-11 12:30:08 +01:00
committed by GitHub
parent ff3a8b8323
commit 16938da355
57 changed files with 527 additions and 440 deletions

View File

@@ -1,3 +1,9 @@
{ {
"eslint.workingDirectories": [{ "pattern": "./packages/*" }] "eslint.workingDirectories": [{ "pattern": "./packages/*" }],
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": false
}
} }

View File

@@ -39,14 +39,14 @@
}, },
"homepage": "https://discord.js.org", "homepage": "https://discord.js.org",
"devDependencies": { "devDependencies": {
"@commitlint/cli": "^16.0.1", "@commitlint/cli": "^16.0.2",
"@commitlint/config-angular": "^16.0.0", "@commitlint/config-angular": "^16.0.0",
"@favware/npm-deprecate": "^1.0.4", "@favware/npm-deprecate": "^1.0.4",
"conventional-changelog-cli": "^2.2.2", "conventional-changelog-cli": "^2.2.2",
"husky": "^7.0.4", "husky": "^7.0.4",
"lint-staged": "^12.1.7", "lint-staged": "^12.1.7",
"prettier": "^2.5.1", "prettier": "^2.5.1",
"turbo": "^1.0.24" "turbo": "1.0.24"
}, },
"engines": { "engines": {
"node": ">=16.9.0" "node": ">=16.9.0"
@@ -70,7 +70,9 @@
"dependsOn": [ "dependsOn": [
"^build" "^build"
], ],
"outputs": [] "outputs": [
"coverage/**"
]
}, },
"lint": { "lint": {
"dependsOn": [ "dependsOn": [

View File

@@ -8,9 +8,5 @@
"ignorePatterns": ["**/dist/*"], "ignorePatterns": ["**/dist/*"],
"env": { "env": {
"jest": true "jest": true
},
"rules": {
"no-redeclare": 0,
"@typescript-eslint/naming-convention": 0
} }
} }

View File

@@ -1,2 +1,8 @@
# Autogenerated # Autogenerated
CHANGELOG.md CHANGELOG.md
.turbo
dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/

View File

@@ -178,14 +178,14 @@ describe('Slash Commands', () => {
expect(() => expect(() =>
getBuilder().addStringOption( getBuilder().addStringOption(
// @ts-expect-error Checking if check works JS-side too // @ts-expect-error Checking if check works JS-side too
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
getStringOption().setAutocomplete(true).addChoice('Fancy Pants', 'fp_1'), getStringOption().setAutocomplete(true).addChoice('Fancy Pants', 'fp_1'),
), ),
).toThrowError(); ).toThrowError();
expect(() => expect(() =>
getBuilder().addStringOption( getBuilder().addStringOption(
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
getStringOption() getStringOption()
.setAutocomplete(true) .setAutocomplete(true)
// @ts-expect-error Checking if check works JS-side too // @ts-expect-error Checking if check works JS-side too
@@ -200,7 +200,7 @@ describe('Slash Commands', () => {
expect(() => expect(() =>
getBuilder().addStringOption( getBuilder().addStringOption(
// @ts-expect-error Checking if check works JS-side too // @ts-expect-error Checking if check works JS-side too
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
getStringOption().addChoice('Fancy Pants', 'fp_1').setAutocomplete(true), getStringOption().addChoice('Fancy Pants', 'fp_1').setAutocomplete(true),
), ),
).toThrowError(); ).toThrowError();
@@ -384,6 +384,7 @@ describe('Slash Commands', () => {
test('GIVEN builder with a subcommand that tries to add an invalid result THEN throw error', () => { test('GIVEN builder with a subcommand that tries to add an invalid result THEN throw error', () => {
expect(() => expect(() =>
// @ts-expect-error Checking if check works JS-side too // @ts-expect-error Checking if check works JS-side too
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
getNamedBuilder().addSubcommand(getSubcommand()).addInteger(getInteger()), getNamedBuilder().addSubcommand(getSubcommand()).addInteger(getInteger()),
).toThrowError(); ).toThrowError();
}); });

View File

@@ -5,9 +5,8 @@
"scripts": { "scripts": {
"build": "tsup", "build": "tsup",
"test": "jest --pass-with-no-tests", "test": "jest --pass-with-no-tests",
"lint": "eslint src --ext mjs,js,ts", "lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
"lint:fix": "eslint src --ext mjs,js,ts --fix", "format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
"format": "prettier --write .",
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs", "docs": "typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs",
"prepublishOnly": "yarn build && yarn lint && yarn test", "prepublishOnly": "yarn build && yarn lint && yarn test",
"changelog": "git cliff --prepend ./CHANGELOG.md -l -c ../../cliff.toml -r ../../ --include-path './*'" "changelog": "git cliff --prepend ./CHANGELOG.md -l -c ../../cliff.toml -r ../../ --include-path './*'"
@@ -61,16 +60,16 @@
"devDependencies": { "devDependencies": {
"@babel/core": "^7.16.5", "@babel/core": "^7.16.5",
"@babel/plugin-proposal-decorators": "^7.16.5", "@babel/plugin-proposal-decorators": "^7.16.5",
"@babel/preset-env": "^7.16.5", "@babel/preset-env": "^7.16.8",
"@babel/preset-typescript": "^7.16.5", "@babel/preset-typescript": "^7.16.5",
"@discordjs/ts-docgen": "^0.3.4", "@discordjs/ts-docgen": "^0.3.4",
"@types/jest": "^27.0.3", "@types/jest": "^27.0.3",
"@types/node": "^16.11.6", "@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "^5.9.0", "@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.0", "@typescript-eslint/parser": "^5.9.1",
"babel-plugin-transform-typescript-metadata": "^0.3.2", "babel-plugin-transform-typescript-metadata": "^0.3.2",
"eslint": "^8.5.0", "eslint": "^8.5.0",
"eslint-config-marine": "^9.1.0", "eslint-config-marine": "^9.3.2",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"jest": "^27.4.7", "jest": "^27.4.7",

View File

@@ -2,6 +2,28 @@ import { z } from 'zod';
import { ApplicationCommandType } from 'discord-api-types/v9'; import { ApplicationCommandType } from 'discord-api-types/v9';
import type { ContextMenuCommandType } from './ContextMenuCommandBuilder'; import type { ContextMenuCommandType } from './ContextMenuCommandBuilder';
const namePredicate = z
.string()
.min(1)
.max(32)
.regex(/^( *[\p{L}\p{N}_-]+ *)+$/u);
const typePredicate = z.union([z.literal(ApplicationCommandType.User), z.literal(ApplicationCommandType.Message)]);
const booleanPredicate = z.boolean();
export function validateDefaultPermission(value: unknown): asserts value is boolean {
booleanPredicate.parse(value);
}
export function validateName(name: unknown): asserts name is string {
namePredicate.parse(name);
}
export function validateType(type: unknown): asserts type is ContextMenuCommandType {
typePredicate.parse(type);
}
export function validateRequiredParameters(name: string, type: number) { export function validateRequiredParameters(name: string, type: number) {
// Assert name matches all conditions // Assert name matches all conditions
validateName(name); validateName(name);
@@ -9,25 +31,3 @@ export function validateRequiredParameters(name: string, type: number) {
// Assert type is valid // Assert type is valid
validateType(type); validateType(type);
} }
const namePredicate = z
.string()
.min(1)
.max(32)
.regex(/^( *[\p{L}\p{N}_-]+ *)+$/u);
export function validateName(name: unknown): asserts name is string {
namePredicate.parse(name);
}
const typePredicate = z.union([z.literal(ApplicationCommandType.User), z.literal(ApplicationCommandType.Message)]);
export function validateType(type: unknown): asserts type is ContextMenuCommandType {
typePredicate.parse(type);
}
const booleanPredicate = z.boolean();
export function validateDefaultPermission(value: unknown): asserts value is boolean {
booleanPredicate.parse(value);
}

View File

@@ -5,21 +5,6 @@ import type { ApplicationCommandOptionBase } from './mixins/ApplicationCommandOp
import type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder'; import type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder';
import type { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands'; import type { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands';
export function validateRequiredParameters(
name: string,
description: string,
options: ToAPIApplicationCommandOptions[],
) {
// Assert name matches all conditions
validateName(name);
// Assert description conditions
validateDescription(description);
// Assert options conditions
validateMaxOptionsLength(options);
}
const namePredicate = z const namePredicate = z
.string() .string()
.min(1) .min(1)
@@ -36,6 +21,27 @@ export function validateDescription(description: unknown): asserts description i
descriptionPredicate.parse(description); descriptionPredicate.parse(description);
} }
const maxArrayLengthPredicate = z.unknown().array().max(25);
export function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[] {
maxArrayLengthPredicate.parse(options);
}
export function validateRequiredParameters(
name: string,
description: string,
options: ToAPIApplicationCommandOptions[],
) {
// Assert name matches all conditions
validateName(name);
// Assert description conditions
validateDescription(description);
// Assert options conditions
validateMaxOptionsLength(options);
}
const booleanPredicate = z.boolean(); const booleanPredicate = z.boolean();
export function validateDefaultPermission(value: unknown): asserts value is boolean { export function validateDefaultPermission(value: unknown): asserts value is boolean {
@@ -46,12 +52,6 @@ export function validateRequired(required: unknown): asserts required is boolean
booleanPredicate.parse(required); booleanPredicate.parse(required);
} }
const maxArrayLengthPredicate = z.unknown().array().max(25);
export function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[] {
maxArrayLengthPredicate.parse(options);
}
export function validateMaxChoicesLength(choices: APIApplicationCommandOptionChoice[]) { export function validateMaxChoicesLength(choices: APIApplicationCommandOptionChoice[]) {
maxArrayLengthPredicate.parse(choices); maxArrayLengthPredicate.parse(choices);
} }

View File

@@ -133,5 +133,5 @@ export interface SlashCommandOptionsOnlyBuilder
Pick<SlashCommandBuilder, 'toJSON'> {} Pick<SlashCommandBuilder, 'toJSON'> {}
export interface ToAPIApplicationCommandOptions { export interface ToAPIApplicationCommandOptions {
toJSON(): APIApplicationCommandOption; toJSON: () => APIApplicationCommandOption;
} }

View File

@@ -48,8 +48,10 @@ export class SlashCommandSubcommandGroupBuilder implements ToAPIApplicationComma
validateMaxOptionsLength(options); validateMaxOptionsLength(options);
// Get the final result // Get the final result
// eslint-disable-next-line @typescript-eslint/no-use-before-define
const result = typeof input === 'function' ? input(new SlashCommandSubcommandBuilder()) : input; const result = typeof input === 'function' ? input(new SlashCommandSubcommandBuilder()) : input;
// eslint-disable-next-line @typescript-eslint/no-use-before-define
assertReturnOfBuilder(result, SlashCommandSubcommandBuilder); assertReturnOfBuilder(result, SlashCommandSubcommandBuilder);
// Push it // Push it

View File

@@ -8,9 +8,5 @@
"ignorePatterns": ["**/dist/*"], "ignorePatterns": ["**/dist/*"],
"env": { "env": {
"jest": true "jest": true
},
"rules": {
"no-redeclare": 0,
"@typescript-eslint/naming-convention": 0
} }
} }

View File

@@ -1,2 +1,8 @@
# Autogenerated # Autogenerated
CHANGELOG.md CHANGELOG.md
.turbo
dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/

View File

@@ -5,9 +5,8 @@
"scripts": { "scripts": {
"test": "jest --pass-with-no-tests", "test": "jest --pass-with-no-tests",
"build": "tsup", "build": "tsup",
"lint": "eslint src --ext mjs,js,ts", "lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
"lint:fix": "eslint src --ext mjs,js,ts --fix", "format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
"format": "prettier --write .",
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs", "docs": "typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs",
"prepublishOnly": "yarn build && yarn lint && yarn test", "prepublishOnly": "yarn build && yarn lint && yarn test",
"changelog": "git cliff --prepend ./CHANGELOG.md -l -c ../../cliff.toml -r ../../ --include-path './*'" "changelog": "git cliff --prepend ./CHANGELOG.md -l -c ../../cliff.toml -r ../../ --include-path './*'"
@@ -49,15 +48,15 @@
"homepage": "https://discord.js.org", "homepage": "https://discord.js.org",
"devDependencies": { "devDependencies": {
"@babel/core": "^7.16.5", "@babel/core": "^7.16.5",
"@babel/preset-env": "^7.16.5", "@babel/preset-env": "^7.16.8",
"@babel/preset-typescript": "^7.16.5", "@babel/preset-typescript": "^7.16.5",
"@discordjs/ts-docgen": "^0.3.4", "@discordjs/ts-docgen": "^0.3.4",
"@types/jest": "^27.0.3", "@types/jest": "^27.0.3",
"@types/node": "^16.11.6", "@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "^5.9.0", "@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.0", "@typescript-eslint/parser": "^5.9.1",
"eslint": "^8.5.0", "eslint": "^8.5.0",
"eslint-config-marine": "^9.1.0", "eslint-config-marine": "^9.3.2",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"jest": "^27.4.7", "jest": "^27.4.7",

View File

@@ -73,10 +73,12 @@ export class Collection<K, V> extends Map<K, V> {
public first(): V | undefined; public first(): V | undefined;
public first(amount: number): V[]; public first(amount: number): V[];
public first(amount?: number): V | V[] | undefined { public first(amount?: number): V | V[] | undefined {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
if (typeof amount === 'undefined') return this.values().next().value; if (typeof amount === 'undefined') return this.values().next().value;
if (amount < 0) return this.last(amount * -1); if (amount < 0) return this.last(amount * -1);
amount = Math.min(this.size, amount); amount = Math.min(this.size, amount);
const iter = this.values(); const iter = this.values();
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return Array.from({ length: amount }, (): V => iter.next().value); return Array.from({ length: amount }, (): V => iter.next().value);
} }
@@ -91,10 +93,12 @@ export class Collection<K, V> extends Map<K, V> {
public firstKey(): K | undefined; public firstKey(): K | undefined;
public firstKey(amount: number): K[]; public firstKey(amount: number): K[];
public firstKey(amount?: number): K | K[] | undefined { public firstKey(amount?: number): K | K[] | undefined {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
if (typeof amount === 'undefined') return this.keys().next().value; if (typeof amount === 'undefined') return this.keys().next().value;
if (amount < 0) return this.lastKey(amount * -1); if (amount < 0) return this.lastKey(amount * -1);
amount = Math.min(this.size, amount); amount = Math.min(this.size, amount);
const iter = this.keys(); const iter = this.keys();
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return Array.from({ length: amount }, (): K => iter.next().value); return Array.from({ length: amount }, (): K => iter.next().value);
} }
@@ -398,6 +402,7 @@ export class Collection<K, V> extends Map<K, V> {
if (typeof thisArg !== 'undefined') fn = fn.bind(thisArg); if (typeof thisArg !== 'undefined') fn = fn.bind(thisArg);
const iter = this.entries(); const iter = this.entries();
return Array.from({ length: this.size }, (): T => { return Array.from({ length: this.size }, (): T => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const [key, value] = iter.next().value; const [key, value] = iter.next().value;
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
return fn(value, key, this); return fn(value, key, this);

View File

@@ -1,2 +1,8 @@
# Autogenerated # Autogenerated
CHANGELOG.md CHANGELOG.md
.turbo
dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/

View File

@@ -3,12 +3,10 @@
"version": "14.0.0-dev", "version": "14.0.0-dev",
"description": "A powerful library for interacting with the Discord API", "description": "A powerful library for interacting with the Discord API",
"scripts": { "scripts": {
"test": "yarn docs:test && yarn lint:typings && yarn test:typescript", "test": "yarn docs:test && yarn test:typescript",
"test:typescript": "tsc --noEmit && tsd", "test:typescript": "tsc --noEmit && tsd",
"lint": "eslint ./src", "lint": "prettier --check . && eslint src && tslint typings/index.d.ts",
"lint:fix": "eslint ./src --fix", "format": "prettier --write . && eslint src --fix",
"lint:typings": "tslint ./typings/index.d.ts",
"format": "prettier --write .",
"docs": "docgen --source ./src --custom ./docs/index.yml --output ./docs/docs.json", "docs": "docgen --source ./src --custom ./docs/index.yml --output ./docs/docs.json",
"docs:test": "docgen --source ./src --custom ./docs/index.yml", "docs:test": "docgen --source ./src --custom ./docs/index.yml",
"prepublishOnly": "yarn lint && yarn test", "prepublishOnly": "yarn lint && yarn test",

View File

@@ -1,11 +1,11 @@
'use strict'; 'use strict';
const fetch = require('node-fetch');
const fs = require('node:fs'); const fs = require('node:fs');
const path = require('node:path'); const path = require('node:path');
const process = require('node:process'); const process = require('node:process');
const { setTimeout: sleep } = require('node:timers/promises'); const { setTimeout: sleep } = require('node:timers/promises');
const util = require('node:util'); const util = require('node:util');
const fetch = require('node-fetch');
const { owner, token } = require('./auth.js'); const { owner, token } = require('./auth.js');
const { Client, Intents, MessageAttachment, MessageEmbed } = require('../src'); const { Client, Intents, MessageAttachment, MessageEmbed } = require('../src');

View File

@@ -1,10 +1,10 @@
'use strict'; 'use strict';
const fetch = require('node-fetch');
const fs = require('node:fs'); const fs = require('node:fs');
const path = require('node:path'); const path = require('node:path');
const { setTimeout: sleep } = require('node:timers/promises'); const { setTimeout: sleep } = require('node:timers/promises');
const util = require('node:util'); const util = require('node:util');
const fetch = require('node-fetch');
const { owner, token, webhookChannel, webhookToken } = require('./auth.js'); const { owner, token, webhookChannel, webhookToken } = require('./auth.js');
const { Client, Intents, MessageAttachment, MessageEmbed, WebhookClient } = require('../src'); const { Client, Intents, MessageAttachment, MessageEmbed, WebhookClient } = require('../src');

View File

@@ -7,9 +7,5 @@
"ignorePatterns": ["**/dist/*"], "ignorePatterns": ["**/dist/*"],
"env": { "env": {
"jest": true "jest": true
},
"rules": {
"no-redeclare": 0,
"@typescript-eslint/naming-convention": 0
} }
} }

View File

@@ -1,2 +1,8 @@
# Autogenerated # Autogenerated
CHANGELOG.md CHANGELOG.md
.turbo
dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/

View File

@@ -41,6 +41,7 @@ nock(`${DefaultRestOptions.api}/v${DefaultRestOptions.version}`)
.post('/postFile') .post('/postFile')
.times(5) .times(5)
.reply(200, (_, body) => ({ .reply(200, (_, body) => ({
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
body: body body: body
.replace(/\r\n/g, '\n') .replace(/\r\n/g, '\n')
.replace(/-+\d+-*\n?/g, '') .replace(/-+\d+-*\n?/g, '')

View File

@@ -21,12 +21,31 @@ const sublimitIntervals = {
const sublimit = { body: { name: 'newname' } }; const sublimit = { body: { name: 'newname' } };
const noSublimit = { body: { bitrate: 40000 } }; const noSublimit = { body: { bitrate: 40000 } };
function startSublimitIntervals() {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!sublimitIntervals.reset) {
sublimitResetAfter = Date.now() + 250;
sublimitIntervals.reset = setInterval(() => {
sublimitRequests = 0;
sublimitResetAfter = Date.now() + 250;
}, 250);
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!sublimitIntervals.retry) {
retryAfter = Date.now() + 1000;
sublimitIntervals.retry = setInterval(() => {
sublimitHits = 0;
retryAfter = Date.now() + 1000;
}, 1000);
}
}
nock(`${DefaultRestOptions.api}/v${DefaultRestOptions.version}`) nock(`${DefaultRestOptions.api}/v${DefaultRestOptions.version}`)
.persist() .persist()
.replyDate() .replyDate()
.get('/standard') .get('/standard')
.times(3) .times(3)
.reply(function handler(): nock.ReplyFnResult { .reply((): nock.ReplyFnResult => {
const response = Date.now() >= resetAfter ? 204 : 429; const response = Date.now() >= resetAfter ? 204 : 429;
resetAfter = Date.now() + 250; resetAfter = Date.now() + 250;
if (response === 204) { if (response === 204) {
@@ -62,8 +81,8 @@ nock(`${DefaultRestOptions.api}/v${DefaultRestOptions.version}`)
]; ];
}) })
.get('/triggerGlobal') .get('/triggerGlobal')
.reply(function handler(): nock.ReplyFnResult { .reply(
return [ (): nock.ReplyFnResult => [
204, 204,
{ global: true }, { global: true },
{ {
@@ -71,12 +90,12 @@ nock(`${DefaultRestOptions.api}/v${DefaultRestOptions.version}`)
'retry-after': '1', 'retry-after': '1',
via: '1.1 google', via: '1.1 google',
}, },
]; ],
}) )
.get('/regularRequest') .get('/regularRequest')
.reply(204, { test: true }) .reply(204, { test: true })
.patch('/channels/:id', (body) => ['name', 'topic'].some((key) => Reflect.has(body as Record<string, unknown>, key))) .patch('/channels/:id', (body) => ['name', 'topic'].some((key) => Reflect.has(body as Record<string, unknown>, key)))
.reply(function handler(): nock.ReplyFnResult { .reply((): nock.ReplyFnResult => {
sublimitHits += 1; sublimitHits += 1;
sublimitRequests += 1; sublimitRequests += 1;
const response = 2 - sublimitHits >= 0 && 10 - sublimitRequests >= 0 ? 204 : 429; const response = 2 - sublimitHits >= 0 && 10 - sublimitRequests >= 0 ? 204 : 429;
@@ -113,7 +132,7 @@ nock(`${DefaultRestOptions.api}/v${DefaultRestOptions.version}`)
.patch('/channels/:id', (body) => .patch('/channels/:id', (body) =>
['name', 'topic'].every((key) => !Reflect.has(body as Record<string, unknown>, key)), ['name', 'topic'].every((key) => !Reflect.has(body as Record<string, unknown>, key)),
) )
.reply(function handler(): nock.ReplyFnResult { .reply((): nock.ReplyFnResult => {
sublimitRequests += 1; sublimitRequests += 1;
const response = 10 - sublimitRequests >= 0 ? 204 : 429; const response = 10 - sublimitRequests >= 0 ? 204 : 429;
startSublimitIntervals(); startSublimitIntervals();
@@ -148,7 +167,7 @@ nock(`${DefaultRestOptions.api}/v${DefaultRestOptions.version}`)
}) })
.get('/unexpected') .get('/unexpected')
.times(2) .times(2)
.reply(function handler(): nock.ReplyFnResult { .reply((): nock.ReplyFnResult => {
if (unexpected429) { if (unexpected429) {
unexpected429 = false; unexpected429 = false;
return [ return [
@@ -164,7 +183,7 @@ nock(`${DefaultRestOptions.api}/v${DefaultRestOptions.version}`)
}) })
.get('/unexpected-cf') .get('/unexpected-cf')
.times(2) .times(2)
.reply(function handler(): nock.ReplyFnResult { .reply((): nock.ReplyFnResult => {
if (unexpected429cf) { if (unexpected429cf) {
unexpected429cf = false; unexpected429cf = false;
return [ return [
@@ -179,7 +198,7 @@ nock(`${DefaultRestOptions.api}/v${DefaultRestOptions.version}`)
}) })
.get('/temp') .get('/temp')
.times(2) .times(2)
.reply(function handler(): nock.ReplyFnResult { .reply((): nock.ReplyFnResult => {
if (serverOutage) { if (serverOutage) {
serverOutage = false; serverOutage = false;
return [500]; return [500];
@@ -345,22 +364,3 @@ test('Reject on RateLimit', async () => {
test('malformedRequest', async () => { test('malformedRequest', async () => {
expect(await api.get('/malformedRequest')).toBe(null); expect(await api.get('/malformedRequest')).toBe(null);
}); });
function startSublimitIntervals() {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!sublimitIntervals.reset) {
sublimitResetAfter = Date.now() + 250;
sublimitIntervals.reset = setInterval(() => {
sublimitRequests = 0;
sublimitResetAfter = Date.now() + 250;
}, 250);
}
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (!sublimitIntervals.retry) {
retryAfter = Date.now() + 1000;
sublimitIntervals.retry = setInterval(() => {
sublimitHits = 0;
retryAfter = Date.now() + 1000;
}, 1000);
}
}

View File

@@ -5,9 +5,8 @@
"scripts": { "scripts": {
"build": "tsup && tsc --emitDeclarationOnly --incremental", "build": "tsup && tsc --emitDeclarationOnly --incremental",
"test": "jest --pass-with-no-tests --collect-coverage", "test": "jest --pass-with-no-tests --collect-coverage",
"lint": "eslint src __tests__ --ext mjs,js,ts", "lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
"lint:fix": "eslint src __tests__ --ext mjs,js,ts --fix", "format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
"format": "prettier --write .",
"prepublishOnly": "yarn build && yarn lint && yarn test", "prepublishOnly": "yarn build && yarn lint && yarn test",
"changelog": "git cliff --prepend ./CHANGELOG.md -l -c ../../cliff.toml -r ../../ --include-path './*'" "changelog": "git cliff --prepend ./CHANGELOG.md -l -c ../../cliff.toml -r ../../ --include-path './*'"
}, },
@@ -60,16 +59,16 @@
"devDependencies": { "devDependencies": {
"@babel/core": "^7.16.7", "@babel/core": "^7.16.7",
"@babel/plugin-proposal-decorators": "^7.16.7", "@babel/plugin-proposal-decorators": "^7.16.7",
"@babel/preset-env": "^7.16.7", "@babel/preset-env": "^7.16.8",
"@babel/preset-typescript": "^7.16.7", "@babel/preset-typescript": "^7.16.7",
"@types/jest": "^27.4.0", "@types/jest": "^27.4.0",
"@types/node-fetch": "^2.5.10", "@types/node-fetch": "^2.5.10",
"@typescript-eslint/eslint-plugin": "^5.9.0", "@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.0", "@typescript-eslint/parser": "^5.9.1",
"babel-plugin-const-enum": "^1.2.0", "babel-plugin-const-enum": "^1.2.0",
"babel-plugin-transform-typescript-metadata": "^0.3.2", "babel-plugin-transform-typescript-metadata": "^0.3.2",
"eslint": "^8.5.0", "eslint": "^8.5.0",
"eslint-config-marine": "^9.1.0", "eslint-config-marine": "^9.3.2",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"jest": "^27.4.7", "jest": "^27.4.7",

View File

@@ -171,20 +171,20 @@ export interface RestEvents {
} }
export interface REST { export interface REST {
on<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void): this; on: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) &
on<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void): this; (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
once<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void): this; once: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) &
once<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void): this; (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
emit<K extends keyof RestEvents>(event: K, ...args: RestEvents[K]): boolean; emit: (<K extends keyof RestEvents>(event: K, ...args: RestEvents[K]) => boolean) &
emit<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, ...args: any[]): boolean; (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, ...args: any[]) => boolean);
off<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void): this; off: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) &
off<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void): this; (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
removeAllListeners<K extends keyof RestEvents>(event?: K): this; removeAllListeners: (<K extends keyof RestEvents>(event?: K) => this) &
removeAllListeners<S extends string | symbol>(event?: Exclude<S, keyof RestEvents>): this; (<S extends string | symbol>(event?: Exclude<S, keyof RestEvents>) => this);
} }
export class REST extends EventEmitter { export class REST extends EventEmitter {

View File

@@ -126,20 +126,20 @@ export interface RouteData {
} }
export interface RequestManager { export interface RequestManager {
on<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void): this; on: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) &
on<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void): this; (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
once<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void): this; once: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) &
once<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void): this; (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
emit<K extends keyof RestEvents>(event: K, ...args: RestEvents[K]): boolean; emit: (<K extends keyof RestEvents>(event: K, ...args: RestEvents[K]) => boolean) &
emit<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, ...args: any[]): boolean; (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, ...args: any[]) => boolean);
off<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void): this; off: (<K extends keyof RestEvents>(event: K, listener: (...args: RestEvents[K]) => void) => this) &
off<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void): this; (<S extends string | symbol>(event: Exclude<S, keyof RestEvents>, listener: (...args: any[]) => void) => this);
removeAllListeners<K extends keyof RestEvents>(event?: K): this; removeAllListeners: (<K extends keyof RestEvents>(event?: K) => this) &
removeAllListeners<S extends string | symbol>(event?: Exclude<S, keyof RestEvents>): this; (<S extends string | symbol>(event?: Exclude<S, keyof RestEvents>) => this);
} }
/** /**

View File

@@ -2,10 +2,10 @@ import type { RequestInit } from 'node-fetch';
import type { InternalRequest, RouteData } from '../RequestManager'; import type { InternalRequest, RouteData } from '../RequestManager';
export interface IHandler { export interface IHandler {
queueRequest( queueRequest: (
routeId: RouteData, routeId: RouteData,
url: string, url: string,
options: RequestInit, options: RequestInit,
bodyData: Pick<InternalRequest, 'files' | 'body'>, bodyData: Pick<InternalRequest, 'files' | 'body'>,
): Promise<unknown>; ) => Promise<unknown>;
} }

View File

@@ -304,11 +304,12 @@ export class SequentialHandler {
try { try {
// node-fetch typings are a bit weird, so we have to cast to any to get the correct signature // node-fetch typings are a bit weird, so we have to cast to any to get the correct signature
// Type 'AbortSignal' is not assignable to type 'import("discord.js-modules/node_modules/@types/node-fetch/externals").AbortSignal' // Type 'AbortSignal' is not assignable to type 'import("discord.js-modules/node_modules/@types/node-fetch/externals").AbortSignal'
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
res = await fetch(url, { ...options, signal: controller.signal as any }); res = await fetch(url, { ...options, signal: controller.signal as any });
} catch (error: unknown) { } catch (error: unknown) {
// Retry the specified number of times for possible timed out requests // Retry the specified number of times for possible timed out requests
if (error instanceof Error && error.name === 'AbortError' && retries !== this.manager.options.retries) { if (error instanceof Error && error.name === 'AbortError' && retries !== this.manager.options.retries) {
return this.runRequest(routeId, url, options, bodyData, ++retries); return await this.runRequest(routeId, url, options, bodyData, ++retries);
} }
throw error; throw error;

View File

@@ -1,9 +1,9 @@
import { APIVersion } from 'discord-api-types/v9'; import { APIVersion } from 'discord-api-types/v9';
import type { RESTOptions } from '../REST'; import type { RESTOptions } from '../REST';
// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports, @typescript-eslint/no-unsafe-assignment
const Package = require('../../../package.json'); const Package = require('../../../package.json');
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions // eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unsafe-member-access
export const DefaultUserAgent = `DiscordBot (${Package.homepage}, ${Package.version})`; export const DefaultUserAgent = `DiscordBot (${Package.homepage}, ${Package.version})`;
export const DefaultRestOptions: Required<RESTOptions> = { export const DefaultRestOptions: Required<RESTOptions> = {

View File

@@ -8,9 +8,5 @@
"ignorePatterns": ["**/dist/*"], "ignorePatterns": ["**/dist/*"],
"env": { "env": {
"jest": true "jest": true
},
"rules": {
"no-redeclare": 0,
"@typescript-eslint/naming-convention": 0
} }
} }

View File

@@ -1,2 +1,8 @@
# Autogenerated # Autogenerated
CHANGELOG.md CHANGELOG.md
.turbo
dist/
docs/**/*
!docs/index.yml
!docs/README.md
coverage/

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/dot-notation */ /* eslint-disable @typescript-eslint/dot-notation */
import { GatewayOpcodes } from 'discord-api-types/v9'; import { GatewayOpcodes } from 'discord-api-types/v9';
import * as DataStore from '../src/DataStore'; import * as DataStore from '../src/DataStore';

View File

@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-argument */ /* eslint-disable @typescript-eslint/no-unsafe-argument */
/* eslint-disable @typescript-eslint/dot-notation */ /* eslint-disable @typescript-eslint/dot-notation */
import { import {

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { joinVoiceChannel } from '../src/joinVoiceChannel'; import { joinVoiceChannel } from '../src/joinVoiceChannel';
import * as VoiceConnection from '../src/VoiceConnection'; import * as VoiceConnection from '../src/VoiceConnection';

View File

@@ -5,9 +5,8 @@
"scripts": { "scripts": {
"build": "tsup && node scripts/postbuild.mjs", "build": "tsup && node scripts/postbuild.mjs",
"test": "jest --pass-with-no-tests --collect-coverage", "test": "jest --pass-with-no-tests --collect-coverage",
"lint": "eslint src --ext mjs,js,ts", "lint": "prettier --check . && eslint src __tests__ --ext mjs,js,ts",
"lint:fix": "eslint src --ext mjs,js,ts --fix", "format": "prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",
"format": "prettier --write .",
"docs": "typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs", "docs": "typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs",
"prepublishOnly": "yarn build && yarn lint && yarn test", "prepublishOnly": "yarn build && yarn lint && yarn test",
"changelog": "git cliff --prepend ./CHANGELOG.md -l -c ../../cliff.toml -r ../../ --include-path './*'" "changelog": "git cliff --prepend ./CHANGELOG.md -l -c ../../cliff.toml -r ../../ --include-path './*'"
@@ -59,15 +58,15 @@
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.16.0", "@babel/core": "^7.16.0",
"@babel/preset-env": "^7.16.0", "@babel/preset-env": "^7.16.8",
"@babel/preset-typescript": "^7.16.0", "@babel/preset-typescript": "^7.16.0",
"@discordjs/ts-docgen": "^0.3.2", "@discordjs/ts-docgen": "^0.3.2",
"@types/jest": "^27.0.2", "@types/jest": "^27.0.2",
"@types/node": "^16.11.7", "@types/node": "^16.11.7",
"@typescript-eslint/eslint-plugin": "^5.9.0", "@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.0", "@typescript-eslint/parser": "^5.9.1",
"eslint": "^8.2.0", "eslint": "^8.2.0",
"eslint-config-marine": "^9.0.6", "eslint-config-marine": "^9.3.2",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"jest": "^27.4.7", "jest": "^27.4.7",

View File

@@ -125,6 +125,7 @@ function audioCycleStep() {
// eslint-disable-next-line @typescript-eslint/dot-notation // eslint-disable-next-line @typescript-eslint/dot-notation
available.forEach((player) => player['_stepDispatch']()); available.forEach((player) => player['_stepDispatch']());
// eslint-disable-next-line @typescript-eslint/no-use-before-define
prepareNextAudioFrame(available); prepareNextAudioFrame(available);
} }

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/prefer-ts-expect-error */
import type { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v9'; import type { GatewayVoiceServerUpdateDispatchData, GatewayVoiceStateUpdateDispatchData } from 'discord-api-types/v9';
import type { CreateVoiceConnectionOptions } from '.'; import type { CreateVoiceConnectionOptions } from '.';
import type { AudioPlayer } from './audio/AudioPlayer'; import type { AudioPlayer } from './audio/AudioPlayer';
@@ -261,11 +262,11 @@ export class VoiceConnection extends TypedEmitter<VoiceConnectionEvents> {
*/ */
public set state(newState: VoiceConnectionState) { public set state(newState: VoiceConnectionState) {
const oldState = this._state; const oldState = this._state;
const oldNetworking: Networking | undefined = Reflect.get(oldState, 'networking'); const oldNetworking = Reflect.get(oldState, 'networking') as Networking | undefined;
const newNetworking: Networking | undefined = Reflect.get(newState, 'networking'); const newNetworking = Reflect.get(newState, 'networking') as Networking | undefined;
const oldSubscription: PlayerSubscription | undefined = Reflect.get(oldState, 'subscription'); const oldSubscription = Reflect.get(oldState, 'subscription') as PlayerSubscription | undefined;
const newSubscription: PlayerSubscription | undefined = Reflect.get(newState, 'subscription'); const newSubscription = Reflect.get(newState, 'subscription') as PlayerSubscription | undefined;
if (oldNetworking !== newNetworking) { if (oldNetworking !== newNetworking) {
if (oldNetworking) { if (oldNetworking) {
@@ -365,6 +366,7 @@ export class VoiceConnection extends TypedEmitter<VoiceConnectionEvents> {
newUdp?.on('message', this.receiver.onUdpMessage); newUdp?.on('message', this.receiver.onUdpMessage);
} }
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
this.receiver.connectionData = Reflect.get(newState, 'connectionData') ?? {}; this.receiver.connectionData = Reflect.get(newState, 'connectionData') ?? {};
} }

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/prefer-ts-expect-error */
import { addAudioPlayer, deleteAudioPlayer } from '../DataStore'; import { addAudioPlayer, deleteAudioPlayer } from '../DataStore';
import { Awaited, noop } from '../util/util'; import { Awaited, noop } from '../util/util';
import { VoiceConnection, VoiceConnectionStatus } from '../VoiceConnection'; import { VoiceConnection, VoiceConnectionStatus } from '../VoiceConnection';
@@ -163,6 +164,19 @@ export type AudioPlayerEvents = {
) => Awaited<void>; ) => Awaited<void>;
}; };
/**
* Stringifies an AudioPlayerState instance.
*
* @param state - The state to stringify
*/
function stringifyState(state: AudioPlayerState) {
return JSON.stringify({
...state,
resource: Reflect.has(state, 'resource'),
stepTimeout: Reflect.has(state, 'stepTimeout'),
});
}
/** /**
* Used to play audio resources (i.e. tracks, streams) to voice connections. * Used to play audio resources (i.e. tracks, streams) to voice connections.
* *
@@ -606,19 +620,6 @@ export class AudioPlayer extends TypedEmitter<AudioPlayerEvents> {
} }
} }
/**
* Stringifies an AudioPlayerState instance.
*
* @param state - The state to stringify
*/
function stringifyState(state: AudioPlayerState) {
return JSON.stringify({
...state,
resource: Reflect.has(state, 'resource'),
stepTimeout: Reflect.has(state, 'stepTimeout'),
});
}
/** /**
* Creates a new AudioPlayer to be used. * Creates a new AudioPlayer to be used.
*/ */

View File

@@ -151,7 +151,7 @@ export class AudioResource<T = unknown> {
this.silenceRemaining--; this.silenceRemaining--;
return SILENCE_FRAME; return SILENCE_FRAME;
} }
const packet: Buffer | null = this.playStream.read(); const packet = this.playStream.read() as Buffer | null;
if (packet) { if (packet) {
this.playbackDuration += 20; this.playbackDuration += 20;
} }

View File

@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/dot-notation */ /* eslint-disable @typescript-eslint/dot-notation */
import { AudioResource } from '../../audio/AudioResource'; import { AudioResource } from '../../audio/AudioResource';
import { createAudioPlayer, AudioPlayerStatus, AudioPlayer, SILENCE_FRAME } from '../AudioPlayer'; import { createAudioPlayer, AudioPlayerStatus, AudioPlayer, SILENCE_FRAME } from '../AudioPlayer';
@@ -372,7 +374,7 @@ test('play() throws when playing a resource that has already ended', async () =>
expect(resource.playStream.readableEnded).toBe(true); expect(resource.playStream.readableEnded).toBe(true);
player.stop(true); player.stop(true);
expect(player.state.status).toBe(AudioPlayerStatus.Idle); expect(player.state.status).toBe(AudioPlayerStatus.Idle);
expect(() => player.play(resource)).toThrow(); expect(() => player?.play(resource)).toThrow();
}); });
test('Propagates errors from streams', async () => { test('Propagates errors from streams', async () => {

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
import { opus, VolumeTransformer } from 'prism-media'; import { opus, VolumeTransformer } from 'prism-media';
import { PassThrough, Readable } from 'node:stream'; import { PassThrough, Readable } from 'node:stream';
import { SILENCE_FRAME } from '../AudioPlayer'; import { SILENCE_FRAME } from '../AudioPlayer';

View File

@@ -157,6 +157,41 @@ export interface NetworkingEvents {
close: (code: number) => Awaited<void>; close: (code: number) => Awaited<void>;
} }
/**
* Stringifies a NetworkingState.
*
* @param state - The state to stringify
*/
function stringifyState(state: NetworkingState) {
return JSON.stringify({
...state,
ws: Reflect.has(state, 'ws'),
udp: Reflect.has(state, 'udp'),
});
}
/**
* Chooses an encryption mode from a list of given options. Chooses the most preferred option.
*
* @param options - The available encryption options
*/
function chooseEncryptionMode(options: string[]): string {
const option = options.find((option) => SUPPORTED_ENCRYPTION_MODES.includes(option));
if (!option) {
throw new Error(`No compatible encryption modes. Available include: ${options.join(', ')}`);
}
return option;
}
/**
* Returns a random number that is in the range of n bits.
*
* @param n - The number of bits
*/
function randomNBit(n: number) {
return Math.floor(Math.random() * 2 ** n);
}
/** /**
* Manages the networking required to maintain a voice connection and dispatch audio packets * Manages the networking required to maintain a voice connection and dispatch audio packets
*/ */
@@ -348,12 +383,16 @@ export class Networking extends TypedEmitter<NetworkingEvents> {
* @param packet - The received packet * @param packet - The received packet
*/ */
private onWsPacket(packet: any) { private onWsPacket(packet: any) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (packet.op === VoiceOpcodes.Hello && this.state.code !== NetworkingStatusCode.Closed) { if (packet.op === VoiceOpcodes.Hello && this.state.code !== NetworkingStatusCode.Closed) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
this.state.ws.setHeartbeatInterval(packet.d.heartbeat_interval); this.state.ws.setHeartbeatInterval(packet.d.heartbeat_interval);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
} else if (packet.op === VoiceOpcodes.Ready && this.state.code === NetworkingStatusCode.Identifying) { } else if (packet.op === VoiceOpcodes.Ready && this.state.code === NetworkingStatusCode.Identifying) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
const { ip, port, ssrc, modes } = packet.d; const { ip, port, ssrc, modes } = packet.d;
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const udp = new VoiceUDPSocket({ ip, port }); const udp = new VoiceUDPSocket({ ip, port });
udp.on('error', this.onChildError); udp.on('error', this.onChildError);
udp.on('debug', this.onUdpDebug); udp.on('debug', this.onUdpDebug);
@@ -387,19 +426,23 @@ export class Networking extends TypedEmitter<NetworkingEvents> {
code: NetworkingStatusCode.UdpHandshaking, code: NetworkingStatusCode.UdpHandshaking,
udp, udp,
connectionData: { connectionData: {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
ssrc, ssrc,
}, },
}; };
} else if ( } else if (
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
packet.op === VoiceOpcodes.SessionDescription && packet.op === VoiceOpcodes.SessionDescription &&
this.state.code === NetworkingStatusCode.SelectingProtocol this.state.code === NetworkingStatusCode.SelectingProtocol
) { ) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
const { mode: encryptionMode, secret_key: secretKey } = packet.d; const { mode: encryptionMode, secret_key: secretKey } = packet.d;
this.state = { this.state = {
...this.state, ...this.state,
code: NetworkingStatusCode.Ready, code: NetworkingStatusCode.Ready,
connectionData: { connectionData: {
...this.state.connectionData, ...this.state.connectionData,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
encryptionMode, encryptionMode,
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
secretKey: new Uint8Array(secretKey), secretKey: new Uint8Array(secretKey),
@@ -411,6 +454,7 @@ export class Networking extends TypedEmitter<NetworkingEvents> {
packetsPlayed: 0, packetsPlayed: 0,
}, },
}; };
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
} else if (packet.op === VoiceOpcodes.Resumed && this.state.code === NetworkingStatusCode.Resuming) { } else if (packet.op === VoiceOpcodes.Resumed && this.state.code === NetworkingStatusCode.Resuming) {
this.state = { this.state = {
...this.state, ...this.state,
@@ -557,38 +601,3 @@ export class Networking extends TypedEmitter<NetworkingEvents> {
return [secretbox.methods.close(opusPacket, nonce, secretKey)]; return [secretbox.methods.close(opusPacket, nonce, secretKey)];
} }
} }
/**
* Returns a random number that is in the range of n bits.
*
* @param n - The number of bits
*/
function randomNBit(n: number) {
return Math.floor(Math.random() * 2 ** n);
}
/**
* Stringifies a NetworkingState.
*
* @param state - The state to stringify
*/
function stringifyState(state: NetworkingState) {
return JSON.stringify({
...state,
ws: Reflect.has(state, 'ws'),
udp: Reflect.has(state, 'udp'),
});
}
/**
* Chooses an encryption mode from a list of given options. Chooses the most preferred option.
*
* @param options - The available encryption options
*/
function chooseEncryptionMode(options: string[]): string {
const option = options.find((option) => SUPPORTED_ENCRYPTION_MODES.includes(option));
if (!option) {
throw new Error(`No compatible encryption modes. Available include: ${options.join(', ')}`);
}
return option;
}

View File

@@ -24,6 +24,25 @@ export interface VoiceUDPSocketEvents {
message: (message: Buffer) => Awaited<void>; message: (message: Buffer) => Awaited<void>;
} }
/**
* Parses the response from Discord to aid with local IP discovery.
*
* @param message - The received message
*/
export function parseLocalPacket(message: Buffer): SocketConfig {
const packet = Buffer.from(message);
const ip = packet.slice(8, packet.indexOf(0, 8)).toString('utf-8');
if (!isIPv4(ip)) {
throw new Error('Malformed IP address');
}
const port = packet.readUInt16BE(packet.length - 2);
return { ip, port };
}
/** /**
* The interval in milliseconds at which keep alive datagrams are sent. * The interval in milliseconds at which keep alive datagrams are sent.
*/ */
@@ -191,22 +210,3 @@ export class VoiceUDPSocket extends TypedEmitter<VoiceUDPSocketEvents> {
}); });
} }
} }
/**
* Parses the response from Discord to aid with local IP discovery.
*
* @param message - The received message
*/
export function parseLocalPacket(message: Buffer): SocketConfig {
const packet = Buffer.from(message);
const ip = packet.slice(8, packet.indexOf(0, 8)).toString('utf-8');
if (!isIPv4(ip)) {
throw new Error('Malformed IP address');
}
const port = packet.readUInt16BE(packet.length - 2);
return { ip, port };
}

View File

@@ -107,6 +107,7 @@ export class VoiceWebSocket extends TypedEmitter<VoiceWebSocketEvents> {
let packet: any; let packet: any;
try { try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
packet = JSON.parse(event.data); packet = JSON.parse(event.data);
} catch (error) { } catch (error) {
const e = error as Error; const e = error as Error;
@@ -114,6 +115,7 @@ export class VoiceWebSocket extends TypedEmitter<VoiceWebSocketEvents> {
return; return;
} }
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (packet.op === VoiceOpcodes.HeartbeatAck) { if (packet.op === VoiceOpcodes.HeartbeatAck) {
this.lastHeartbeatAck = Date.now(); this.lastHeartbeatAck = Date.now();
this.missedHeartbeats = 0; this.missedHeartbeats = 0;

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-empty-function */ /* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable @typescript-eslint/no-unused-vars */ /* eslint-disable @typescript-eslint/no-unused-vars */
import { createSocket as _createSocket } from 'node:dgram'; import { createSocket as _createSocket } from 'node:dgram';
@@ -21,7 +22,6 @@ class FakeSocket extends EventEmitter {
} }
// ip = 91.90.123.93, port = 54148 // ip = 91.90.123.93, port = 54148
// eslint-disable-next-line prettier/prettier
const VALID_RESPONSE = Buffer.from([ const VALID_RESPONSE = Buffer.from([
0x0, 0x2, 0x0, 0x46, 0x0, 0x4, 0xeb, 0x23, 0x39, 0x31, 0x2e, 0x39, 0x30, 0x2e, 0x31, 0x32, 0x33, 0x2e, 0x39, 0x33, 0x0, 0x2, 0x0, 0x46, 0x0, 0x4, 0xeb, 0x23, 0x39, 0x31, 0x2e, 0x39, 0x30, 0x2e, 0x31, 0x32, 0x33, 0x2e, 0x39, 0x33,
0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,

View File

@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { VoiceOpcodes } from 'discord-api-types/voice/v4'; import { VoiceOpcodes } from 'discord-api-types/voice/v4';
import EventEmitter, { once } from 'node:events'; import EventEmitter, { once } from 'node:events';
import WS from 'jest-websocket-mock'; import WS from 'jest-websocket-mock';

View File

@@ -63,23 +63,34 @@ export class VoiceReceiver {
* @internal * @internal
*/ */
public onWsPacket(packet: any) { public onWsPacket(packet: any) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (packet.op === VoiceOpcodes.ClientDisconnect && typeof packet.d?.user_id === 'string') { if (packet.op === VoiceOpcodes.ClientDisconnect && typeof packet.d?.user_id === 'string') {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
this.ssrcMap.delete(packet.d.user_id); this.ssrcMap.delete(packet.d.user_id);
} else if ( } else if (
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
packet.op === VoiceOpcodes.Speaking && packet.op === VoiceOpcodes.Speaking &&
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
typeof packet.d?.user_id === 'string' && typeof packet.d?.user_id === 'string' &&
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
typeof packet.d?.ssrc === 'number' typeof packet.d?.ssrc === 'number'
) { ) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
this.ssrcMap.update({ userId: packet.d.user_id, audioSSRC: packet.d.ssrc }); this.ssrcMap.update({ userId: packet.d.user_id, audioSSRC: packet.d.ssrc });
} else if ( } else if (
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
packet.op === VoiceOpcodes.ClientConnect && packet.op === VoiceOpcodes.ClientConnect &&
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
typeof packet.d?.user_id === 'string' && typeof packet.d?.user_id === 'string' &&
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
typeof packet.d?.audio_ssrc === 'number' typeof packet.d?.audio_ssrc === 'number'
) { ) {
this.ssrcMap.update({ this.ssrcMap.update({
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
userId: packet.d.user_id, userId: packet.d.user_id,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
audioSSRC: packet.d.audio_ssrc, audioSSRC: packet.d.audio_ssrc,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
videoSSRC: packet.d.video_ssrc === 0 ? undefined : packet.d.video_ssrc, videoSSRC: packet.d.video_ssrc === 0 ? undefined : packet.d.video_ssrc,
}); });
} }

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import EventEmitter, { once } from 'node:events'; import EventEmitter, { once } from 'node:events';
import { SSRCMap, VoiceUserData } from '../SSRCMap'; import { SSRCMap, VoiceUserData } from '../SSRCMap';

View File

@@ -1,3 +1,4 @@
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
/* eslint-disable @typescript-eslint/dot-notation */ /* eslint-disable @typescript-eslint/dot-notation */
import { VoiceReceiver } from '../VoiceReceiver'; import { VoiceReceiver } from '../VoiceReceiver';
import { VoiceConnection as _VoiceConnection, VoiceConnectionStatus } from '../../VoiceConnection'; import { VoiceConnection as _VoiceConnection, VoiceConnectionStatus } from '../../VoiceConnection';

View File

@@ -1,28 +1,37 @@
interface Methods { interface Methods {
open(buffer: Buffer, nonce: Buffer, secretKey: Uint8Array): Buffer | null; open: (buffer: Buffer, nonce: Buffer, secretKey: Uint8Array) => Buffer | null;
close(opusPacket: Buffer, nonce: Buffer, secretKey: Uint8Array): Buffer; close: (opusPacket: Buffer, nonce: Buffer, secretKey: Uint8Array) => Buffer;
random(bytes: number, nonce: Buffer): Buffer; random: (bytes: number, nonce: Buffer) => Buffer;
} }
const libs = { const libs = {
sodium: (sodium: any): Methods => ({ sodium: (sodium: any): Methods => ({
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
open: sodium.api.crypto_secretbox_open_easy, open: sodium.api.crypto_secretbox_open_easy,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
close: sodium.api.crypto_secretbox_easy, close: sodium.api.crypto_secretbox_easy,
random: (n: any, buffer?: Buffer) => { random: (n: any, buffer?: Buffer) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
if (!buffer) buffer = Buffer.allocUnsafe(n); if (!buffer) buffer = Buffer.allocUnsafe(n);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
sodium.api.randombytes_buf(buffer); sodium.api.randombytes_buf(buffer);
return buffer; return buffer;
}, },
}), }),
'libsodium-wrappers': (sodium: any): Methods => ({ 'libsodium-wrappers': (sodium: any): Methods => ({
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
open: sodium.crypto_secretbox_open_easy, open: sodium.crypto_secretbox_open_easy,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
close: sodium.crypto_secretbox_easy, close: sodium.crypto_secretbox_easy,
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
random: (n: any) => sodium.randombytes_buf(n), random: (n: any) => sodium.randombytes_buf(n),
}), }),
tweetnacl: (tweetnacl: any): Methods => ({ tweetnacl: (tweetnacl: any): Methods => ({
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
open: tweetnacl.secretbox.open, open: tweetnacl.secretbox.open,
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
close: tweetnacl.secretbox, close: tweetnacl.secretbox,
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
random: (n: any) => tweetnacl.randomBytes(n), random: (n: any) => tweetnacl.randomBytes(n),
}), }),
} as const; } as const;
@@ -46,6 +55,7 @@ void (async () => {
try { try {
// eslint-disable-next-line // eslint-disable-next-line
const lib = require(libName); const lib = require(libName);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (libName === 'libsodium-wrappers' && lib.ready) await lib.ready; if (libName === 'libsodium-wrappers' && lib.ready) await lib.ready;
Object.assign(methods, libs[libName](lib)); Object.assign(methods, libs[libName](lib));
break; break;

View File

@@ -1,3 +1,6 @@
/* eslint-disable @typescript-eslint/no-unsafe-call */
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import { demuxProbe } from '../demuxProbe'; import { demuxProbe } from '../demuxProbe';
import { opus as _opus } from 'prism-media'; import { opus as _opus } from 'prism-media';
import { Readable } from 'node:stream'; import { Readable } from 'node:stream';
@@ -9,6 +12,10 @@ jest.mock('prism-media');
const WebmDemuxer = _opus.WebmDemuxer as unknown as jest.Mock<_opus.WebmDemuxer>; const WebmDemuxer = _opus.WebmDemuxer as unknown as jest.Mock<_opus.WebmDemuxer>;
const OggDemuxer = _opus.OggDemuxer as unknown as jest.Mock<_opus.OggDemuxer>; const OggDemuxer = _opus.OggDemuxer as unknown as jest.Mock<_opus.OggDemuxer>;
function nextTick() {
return new Promise((resolve) => process.nextTick(resolve));
}
async function* gen(n: number) { async function* gen(n: number) {
for (let i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
yield Buffer.from([i]); yield Buffer.from([i]);
@@ -37,10 +44,6 @@ async function collectStream(stream: Readable): Promise<Buffer> {
return output; return output;
} }
function nextTick() {
return new Promise((resolve) => process.nextTick(resolve));
}
describe('demuxProbe', () => { describe('demuxProbe', () => {
const webmWrite: jest.Mock<(buffer: Buffer) => void> = jest.fn(); const webmWrite: jest.Mock<(buffer: Buffer) => void> = jest.fn();
const oggWrite: jest.Mock<(buffer: Buffer) => void> = jest.fn(); const oggWrite: jest.Mock<(buffer: Buffer) => void> = jest.fn();

View File

@@ -1,3 +1,5 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
import EventEmitter from 'node:events'; import EventEmitter from 'node:events';
import { VoiceConnection, VoiceConnectionStatus } from '../../VoiceConnection'; import { VoiceConnection, VoiceConnectionStatus } from '../../VoiceConnection';
import { entersState } from '../entersState'; import { entersState } from '../entersState';

View File

@@ -6,7 +6,8 @@
export function abortAfter(delay: number): [AbortController, AbortSignal] { export function abortAfter(delay: number): [AbortController, AbortSignal] {
const ac = new AbortController(); const ac = new AbortController();
const timeout = setTimeout(() => ac.abort(), delay); const timeout = setTimeout(() => ac.abort(), delay);
// @ts-ignore // @ts-expect-error
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
ac.signal.addEventListener('abort', () => clearTimeout(timeout)); ac.signal.addEventListener('abort', () => clearTimeout(timeout));
return [ac, ac.signal]; return [ac, ac.signal];
} }

View File

@@ -10,17 +10,17 @@ export interface DiscordGatewayAdapterLibraryMethods {
* *
* @param data - The inner data of the VOICE_SERVER_UPDATE payload * @param data - The inner data of the VOICE_SERVER_UPDATE payload
*/ */
onVoiceServerUpdate(data: GatewayVoiceServerUpdateDispatchData): void; onVoiceServerUpdate: (data: GatewayVoiceServerUpdateDispatchData) => void;
/** /**
* Call this when you receive a VOICE_STATE_UPDATE payload that is relevant to the adapter. * Call this when you receive a VOICE_STATE_UPDATE payload that is relevant to the adapter.
* *
* @param data - The inner data of the VOICE_STATE_UPDATE payload * @param data - The inner data of the VOICE_STATE_UPDATE payload
*/ */
onVoiceStateUpdate(data: GatewayVoiceStateUpdateDispatchData): void; onVoiceStateUpdate: (data: GatewayVoiceStateUpdateDispatchData) => void;
/** /**
* Call this when the adapter can no longer be used (e.g. due to a disconnect from the main gateway) * Call this when the adapter can no longer be used (e.g. due to a disconnect from the main gateway)
*/ */
destroy(): void; destroy: () => void;
} }
/** /**
@@ -34,12 +34,12 @@ export interface DiscordGatewayAdapterImplementerMethods {
* *
* @returns `false` if the payload definitely failed to send - in this case, the voice connection disconnects * @returns `false` if the payload definitely failed to send - in this case, the voice connection disconnects
*/ */
sendPayload(payload: any): boolean; sendPayload: (payload: any) => boolean;
/** /**
* This will be called by @discordjs/voice when the adapter can safely be destroyed as it will no * This will be called by @discordjs/voice when the adapter can safely be destroyed as it will no
* longer be used. * longer be used.
*/ */
destroy(): void; destroy: () => void;
} }
/** /**

View File

@@ -56,8 +56,11 @@ export function demuxProbe(
let resolved: StreamType | undefined = undefined; let resolved: StreamType | undefined = undefined;
const finish = (type: StreamType) => { const finish = (type: StreamType) => {
// eslint-disable-next-line @typescript-eslint/no-use-before-define
stream.off('data', onData); stream.off('data', onData);
// eslint-disable-next-line @typescript-eslint/no-use-before-define
stream.off('close', onClose); stream.off('close', onClose);
// eslint-disable-next-line @typescript-eslint/no-use-before-define
stream.off('end', onClose); stream.off('end', onClose);
stream.pause(); stream.pause();
resolved = type; resolved = type;

View File

@@ -3,6 +3,51 @@
import { resolve, dirname } from 'node:path'; import { resolve, dirname } from 'node:path';
import prism from 'prism-media'; import prism from 'prism-media';
/**
* Tries to find the package.json file for a given module.
*
* @param dir - The directory to look in
* @param packageName - The name of the package to look for
* @param depth - The maximum recursion depth
*/
function findPackageJSON(
dir: string,
packageName: string,
depth: number,
): { name: string; version: string } | undefined {
if (depth === 0) return undefined;
const attemptedPath = resolve(dir, './package.json');
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const pkg = require(attemptedPath);
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (pkg.name !== packageName) throw new Error('package.json does not match');
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return pkg;
} catch (err) {
return findPackageJSON(resolve(dir, '..'), packageName, depth - 1);
}
}
/**
* Tries to find the version of a dependency.
*
* @param name - The package to find the version of
*/
function version(name: string): string {
try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const pkg =
name === '@discordjs/voice'
? require('../../package.json')
: findPackageJSON(dirname(require.resolve(name)), name, 3);
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access
return pkg?.version ?? 'not found';
} catch (err) {
return 'not found';
}
}
/** /**
* Generates a report of the dependencies used by the \@discordjs/voice module. * Generates a report of the dependencies used by the \@discordjs/voice module.
* Useful for debugging. * Useful for debugging.
@@ -41,43 +86,3 @@ export function generateDependencyReport() {
return ['-'.repeat(50), ...report, '-'.repeat(50)].join('\n'); return ['-'.repeat(50), ...report, '-'.repeat(50)].join('\n');
} }
/**
* Tries to find the package.json file for a given module.
*
* @param dir - The directory to look in
* @param packageName - The name of the package to look for
* @param depth - The maximum recursion depth
*/
function findPackageJSON(
dir: string,
packageName: string,
depth: number,
): { name: string; version: string } | undefined {
if (depth === 0) return undefined;
const attemptedPath = resolve(dir, './package.json');
try {
const pkg = require(attemptedPath);
if (pkg.name !== packageName) throw new Error('package.json does not match');
return pkg;
} catch (err) {
return findPackageJSON(resolve(dir, '..'), packageName, depth - 1);
}
}
/**
* Tries to find the version of a dependency.
*
* @param name - The package to find the version of
*/
function version(name: string): string {
try {
const pkg =
name === '@discordjs/voice'
? require('../../package.json')
: findPackageJSON(dirname(require.resolve(name)), name, 3);
return pkg?.version ?? 'not found';
} catch (err) {
return 'not found';
}
}

View File

@@ -1,48 +1,4 @@
{ {
// Mapped from https://www.typescriptlang.org/tsconfig "extends": "../../tsconfig.json",
"compilerOptions": { "include": ["src/**/*.ts"]
// Type Checking
"allowUnreachableCode": false,
"allowUnusedLabels": false,
// if true: conflicts with discord-api-types
"exactOptionalPropertyTypes": false,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,
"useUnknownInCatchVariables": true,
// Modules
"module": "CommonJS",
"moduleResolution": "node",
"resolveJsonModule": true,
// Emit
"declaration": true,
"importHelpers": true,
"importsNotUsedAsValues": "error",
"inlineSources": true,
"newLine": "lf",
"noEmitHelpers": true,
"outDir": "dist",
"preserveConstEnums": true,
"removeComments": false,
"sourceMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
// Language and Environment
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["ESNext"],
"target": "ES2020",
"useDefineForClassFields": true,
// Completeness
"skipLibCheck": true
},
"include": ["src/**/*.ts"],
"exclude": ["src/**/__tests__"]
} }

261
yarn.lock
View File

@@ -14,6 +14,11 @@
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.16.4.tgz#081d6bbc336ec5c2435c6346b2ae1fb98b5ac68e" resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.16.4.tgz#081d6bbc336ec5c2435c6346b2ae1fb98b5ac68e"
integrity sha512-1o/jo7D+kC9ZjHX5v+EHrdjl3PhxMrLSOTGsOdHJ+KL8HCaEK6ehrVL2RS6oHDZp+L7xLirLrPmQtEng769J/Q== integrity sha512-1o/jo7D+kC9ZjHX5v+EHrdjl3PhxMrLSOTGsOdHJ+KL8HCaEK6ehrVL2RS6oHDZp+L7xLirLrPmQtEng769J/Q==
"@babel/compat-data@^7.16.8":
version "7.16.8"
resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.16.8.tgz#31560f9f29fdf1868de8cb55049538a1b9732a60"
integrity sha512-m7OkX0IdKLKPpBlJtF561YJal5y/jyI5fNfWbPxh2D/nbzzGI4qRyrD8xO2jB24u7l+5I2a43scCG2IrfjC50Q==
"@babel/core@^7.1.0", "@babel/core@^7.12.3", "@babel/core@^7.16.0", "@babel/core@^7.16.5", "@babel/core@^7.16.7", "@babel/core@^7.7.2", "@babel/core@^7.8.0": "@babel/core@^7.1.0", "@babel/core@^7.12.3", "@babel/core@^7.16.0", "@babel/core@^7.16.5", "@babel/core@^7.16.7", "@babel/core@^7.7.2", "@babel/core@^7.8.0":
version "7.16.7" version "7.16.7"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.16.7.tgz#db990f931f6d40cb9b87a0dc7d2adc749f1dcbcf" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.16.7.tgz#db990f931f6d40cb9b87a0dc7d2adc749f1dcbcf"
@@ -44,6 +49,15 @@
jsesc "^2.5.1" jsesc "^2.5.1"
source-map "^0.5.0" source-map "^0.5.0"
"@babel/generator@^7.16.8":
version "7.16.8"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.16.8.tgz#359d44d966b8cd059d543250ce79596f792f2ebe"
integrity sha512-1ojZwE9+lOXzcWdWmO6TbUzDfqLD39CmEhN8+2cX9XkDo5yW1OpgfejfliysR2AWLpMamTiOiAp/mtroaymhpw==
dependencies:
"@babel/types" "^7.16.8"
jsesc "^2.5.1"
source-map "^0.5.0"
"@babel/helper-annotate-as-pure@^7.16.7": "@babel/helper-annotate-as-pure@^7.16.7":
version "7.16.7" version "7.16.7"
resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.7.tgz#bb2339a7534a9c128e3102024c60760a3a7f3862" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.16.7.tgz#bb2339a7534a9c128e3102024c60760a3a7f3862"
@@ -181,14 +195,14 @@
resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.16.7.tgz#aa3a8ab4c3cceff8e65eb9e73d87dc4ff320b2f5" resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.16.7.tgz#aa3a8ab4c3cceff8e65eb9e73d87dc4ff320b2f5"
integrity sha512-Qg3Nk7ZxpgMrsox6HreY1ZNKdBq7K72tDSliA6dCl5f007jR4ne8iD5UzuNnCJH2xBf2BEEVGr+/OL6Gdp7RxA== integrity sha512-Qg3Nk7ZxpgMrsox6HreY1ZNKdBq7K72tDSliA6dCl5f007jR4ne8iD5UzuNnCJH2xBf2BEEVGr+/OL6Gdp7RxA==
"@babel/helper-remap-async-to-generator@^7.16.7": "@babel/helper-remap-async-to-generator@^7.16.8":
version "7.16.7" version "7.16.8"
resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.16.7.tgz#5ce2416990d55eb6e099128338848ae8ffa58a9a" resolved "https://registry.yarnpkg.com/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.16.8.tgz#29ffaade68a367e2ed09c90901986918d25e57e3"
integrity sha512-C3o117GnP/j/N2OWo+oepeWbFEKRfNaay+F1Eo5Mj3A1SRjyx+qaFhm23nlipub7Cjv2azdUUiDH+VlpdwUFRg== integrity sha512-fm0gH7Flb8H51LqJHy3HJ3wnE1+qtYR2A99K06ahwrawLdOFsCEWjZOrYricXJHoPSudNKxrMBUPEIPxiIIvBw==
dependencies: dependencies:
"@babel/helper-annotate-as-pure" "^7.16.7" "@babel/helper-annotate-as-pure" "^7.16.7"
"@babel/helper-wrap-function" "^7.16.7" "@babel/helper-wrap-function" "^7.16.8"
"@babel/types" "^7.16.7" "@babel/types" "^7.16.8"
"@babel/helper-replace-supers@^7.16.7": "@babel/helper-replace-supers@^7.16.7":
version "7.16.7" version "7.16.7"
@@ -232,15 +246,15 @@
resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.16.7.tgz#b203ce62ce5fe153899b617c08957de860de4d23" resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.16.7.tgz#b203ce62ce5fe153899b617c08957de860de4d23"
integrity sha512-TRtenOuRUVo9oIQGPC5G9DgK4743cdxvtOw0weQNpZXaS16SCBi5MNjZF8vba3ETURjZpTbVn7Vvcf2eAwFozQ== integrity sha512-TRtenOuRUVo9oIQGPC5G9DgK4743cdxvtOw0weQNpZXaS16SCBi5MNjZF8vba3ETURjZpTbVn7Vvcf2eAwFozQ==
"@babel/helper-wrap-function@^7.16.7": "@babel/helper-wrap-function@^7.16.8":
version "7.16.7" version "7.16.8"
resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.16.7.tgz#8ddf9eaa770ed43de4bc3687f3f3b0d6d5ecf014" resolved "https://registry.yarnpkg.com/@babel/helper-wrap-function/-/helper-wrap-function-7.16.8.tgz#58afda087c4cd235de92f7ceedebca2c41274200"
integrity sha512-7a9sABeVwcunnztZZ7WTgSw6jVYLzM1wua0Z4HIXm9S3/HC96WKQTkFgGEaj5W06SHHihPJ6Le6HzS5cGOQMNw== integrity sha512-8RpyRVIAW1RcDDGTA+GpPAwV22wXCfKOoM9bet6TLkGIFTkRQSkH1nMQ5Yet4MpoXe1ZwHPVtNasc2w0uZMqnw==
dependencies: dependencies:
"@babel/helper-function-name" "^7.16.7" "@babel/helper-function-name" "^7.16.7"
"@babel/template" "^7.16.7" "@babel/template" "^7.16.7"
"@babel/traverse" "^7.16.7" "@babel/traverse" "^7.16.8"
"@babel/types" "^7.16.7" "@babel/types" "^7.16.8"
"@babel/helpers@^7.16.7": "@babel/helpers@^7.16.7":
version "7.16.7" version "7.16.7"
@@ -265,6 +279,11 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.16.7.tgz#d372dda9c89fcec340a82630a9f533f2fe15877e" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.16.7.tgz#d372dda9c89fcec340a82630a9f533f2fe15877e"
integrity sha512-sR4eaSrnM7BV7QPzGfEX5paG/6wrZM3I0HDzfIAK06ESvo9oy3xBuVBxE3MbQaKNhvg8g/ixjMWo2CGpzpHsDA== integrity sha512-sR4eaSrnM7BV7QPzGfEX5paG/6wrZM3I0HDzfIAK06ESvo9oy3xBuVBxE3MbQaKNhvg8g/ixjMWo2CGpzpHsDA==
"@babel/parser@^7.16.8":
version "7.16.8"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.16.8.tgz#61c243a3875f7d0b0962b0543a33ece6ff2f1f17"
integrity sha512-i7jDUfrVBWc+7OKcBzEe5n7fbv3i2fWtxKzzCvOjnzSxMfWMigAhtfJ7qzZNGFNMsCCd67+uz553dYKWXPvCKw==
"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.16.7": "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@^7.16.7":
version "7.16.7" version "7.16.7"
resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.16.7.tgz#4eda6d6c2a0aa79c70fa7b6da67763dfe2141050" resolved "https://registry.yarnpkg.com/@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression/-/plugin-bugfix-safari-id-destructuring-collision-in-function-expression-7.16.7.tgz#4eda6d6c2a0aa79c70fa7b6da67763dfe2141050"
@@ -281,13 +300,13 @@
"@babel/helper-skip-transparent-expression-wrappers" "^7.16.0" "@babel/helper-skip-transparent-expression-wrappers" "^7.16.0"
"@babel/plugin-proposal-optional-chaining" "^7.16.7" "@babel/plugin-proposal-optional-chaining" "^7.16.7"
"@babel/plugin-proposal-async-generator-functions@^7.16.7": "@babel/plugin-proposal-async-generator-functions@^7.16.8":
version "7.16.7" version "7.16.8"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.16.7.tgz#739adc1212a9e4892de440cd7dfffb06172df78d" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.16.8.tgz#3bdd1ebbe620804ea9416706cd67d60787504bc8"
integrity sha512-TTXBT3A5c11eqRzaC6beO6rlFT3Mo9C2e8eB44tTr52ESXSK2CIc2fOp1ynpAwQA8HhBMho+WXhMHWlAe3xkpw== integrity sha512-71YHIvMuiuqWJQkebWJtdhQTfd4Q4mF76q2IX37uZPkG9+olBxsX+rH1vkhFto4UeJZ9dPY2s+mDvhDm1u2BGQ==
dependencies: dependencies:
"@babel/helper-plugin-utils" "^7.16.7" "@babel/helper-plugin-utils" "^7.16.7"
"@babel/helper-remap-async-to-generator" "^7.16.7" "@babel/helper-remap-async-to-generator" "^7.16.8"
"@babel/plugin-syntax-async-generators" "^7.8.4" "@babel/plugin-syntax-async-generators" "^7.8.4"
"@babel/plugin-proposal-class-properties@^7.16.7": "@babel/plugin-proposal-class-properties@^7.16.7":
@@ -551,14 +570,14 @@
dependencies: dependencies:
"@babel/helper-plugin-utils" "^7.16.7" "@babel/helper-plugin-utils" "^7.16.7"
"@babel/plugin-transform-async-to-generator@^7.16.7": "@babel/plugin-transform-async-to-generator@^7.16.8":
version "7.16.7" version "7.16.8"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.16.7.tgz#646e1262ac341b587ff5449844d4492dbb10ac4b" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.16.8.tgz#b83dff4b970cf41f1b819f8b49cc0cfbaa53a808"
integrity sha512-pFEfjnK4DfXCfAlA5I98BYdDJD8NltMzx19gt6DAmfE+2lXRfPUoa0/5SUjT4+TDE1W/rcxU/1lgN55vpAjjdg== integrity sha512-MtmUmTJQHCnyJVrScNzNlofQJ3dLFuobYn3mwOTKHnSCMtbNsqvF71GQmJfFjdrXSsAA7iysFmYWw4bXZ20hOg==
dependencies: dependencies:
"@babel/helper-module-imports" "^7.16.7" "@babel/helper-module-imports" "^7.16.7"
"@babel/helper-plugin-utils" "^7.16.7" "@babel/helper-plugin-utils" "^7.16.7"
"@babel/helper-remap-async-to-generator" "^7.16.7" "@babel/helper-remap-async-to-generator" "^7.16.8"
"@babel/plugin-transform-block-scoped-functions@^7.16.7": "@babel/plugin-transform-block-scoped-functions@^7.16.7":
version "7.16.7" version "7.16.7"
@@ -664,10 +683,10 @@
"@babel/helper-plugin-utils" "^7.16.7" "@babel/helper-plugin-utils" "^7.16.7"
babel-plugin-dynamic-import-node "^2.3.3" babel-plugin-dynamic-import-node "^2.3.3"
"@babel/plugin-transform-modules-commonjs@^7.16.7": "@babel/plugin-transform-modules-commonjs@^7.16.8":
version "7.16.7" version "7.16.8"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.16.7.tgz#fd119e6a433c527d368425b45df361e1e95d3c1a" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.16.8.tgz#cdee19aae887b16b9d331009aa9a219af7c86afe"
integrity sha512-h2RP2kE7He1ZWKyAlanMZrAbdv+Acw1pA8dQZhE025WJZE2z0xzFADAinXA9fxd5bn7JnM+SdOGcndGx1ARs9w== integrity sha512-oflKPvsLT2+uKQopesJt3ApiaIS2HW+hzHFcwRNtyDGieAeC/dIHZX8buJQ2J2X1rxGPy4eRcUijm3qcSPjYcA==
dependencies: dependencies:
"@babel/helper-module-transforms" "^7.16.7" "@babel/helper-module-transforms" "^7.16.7"
"@babel/helper-plugin-utils" "^7.16.7" "@babel/helper-plugin-utils" "^7.16.7"
@@ -693,10 +712,10 @@
"@babel/helper-module-transforms" "^7.16.7" "@babel/helper-module-transforms" "^7.16.7"
"@babel/helper-plugin-utils" "^7.16.7" "@babel/helper-plugin-utils" "^7.16.7"
"@babel/plugin-transform-named-capturing-groups-regex@^7.16.7": "@babel/plugin-transform-named-capturing-groups-regex@^7.16.8":
version "7.16.7" version "7.16.8"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.16.7.tgz#749d90d94e73cf62c60a0cc8d6b94d29305a81f2" resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.16.8.tgz#7f860e0e40d844a02c9dcf9d84965e7dfd666252"
integrity sha512-kFy35VwmwIQwCjwrAQhl3+c/kr292i4KdLPKp5lPH03Ltc51qnFlIADoyPxc/6Naz3ok3WdYKg+KK6AH+D4utg== integrity sha512-j3Jw+n5PvpmhRR+mrgIh04puSANCk/T/UA3m3P1MjJkhlK906+ApHhDIqBQDdOgL/r1UYpz4GNclTXxyZrYGSw==
dependencies: dependencies:
"@babel/helper-create-regexp-features-plugin" "^7.16.7" "@babel/helper-create-regexp-features-plugin" "^7.16.7"
@@ -803,18 +822,18 @@
"@babel/helper-create-regexp-features-plugin" "^7.16.7" "@babel/helper-create-regexp-features-plugin" "^7.16.7"
"@babel/helper-plugin-utils" "^7.16.7" "@babel/helper-plugin-utils" "^7.16.7"
"@babel/preset-env@^7.16.0", "@babel/preset-env@^7.16.5", "@babel/preset-env@^7.16.7": "@babel/preset-env@^7.16.8":
version "7.16.7" version "7.16.8"
resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.16.7.tgz#c491088856d0b3177822a2bf06cb74d76327aa56" resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.16.8.tgz#e682fa0bcd1cf49621d64a8956318ddfb9a05af9"
integrity sha512-urX3Cee4aOZbRWOSa3mKPk0aqDikfILuo+C7qq7HY0InylGNZ1fekq9jmlr3pLWwZHF4yD7heQooc2Pow2KMyQ== integrity sha512-9rNKgVCdwHb3z1IlbMyft6yIXIeP3xz6vWvGaLHrJThuEIqWfHb0DNBH9VuTgnDfdbUDhkmkvMZS/YMCtP7Elg==
dependencies: dependencies:
"@babel/compat-data" "^7.16.4" "@babel/compat-data" "^7.16.8"
"@babel/helper-compilation-targets" "^7.16.7" "@babel/helper-compilation-targets" "^7.16.7"
"@babel/helper-plugin-utils" "^7.16.7" "@babel/helper-plugin-utils" "^7.16.7"
"@babel/helper-validator-option" "^7.16.7" "@babel/helper-validator-option" "^7.16.7"
"@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression" "^7.16.7" "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression" "^7.16.7"
"@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining" "^7.16.7" "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining" "^7.16.7"
"@babel/plugin-proposal-async-generator-functions" "^7.16.7" "@babel/plugin-proposal-async-generator-functions" "^7.16.8"
"@babel/plugin-proposal-class-properties" "^7.16.7" "@babel/plugin-proposal-class-properties" "^7.16.7"
"@babel/plugin-proposal-class-static-block" "^7.16.7" "@babel/plugin-proposal-class-static-block" "^7.16.7"
"@babel/plugin-proposal-dynamic-import" "^7.16.7" "@babel/plugin-proposal-dynamic-import" "^7.16.7"
@@ -844,7 +863,7 @@
"@babel/plugin-syntax-private-property-in-object" "^7.14.5" "@babel/plugin-syntax-private-property-in-object" "^7.14.5"
"@babel/plugin-syntax-top-level-await" "^7.14.5" "@babel/plugin-syntax-top-level-await" "^7.14.5"
"@babel/plugin-transform-arrow-functions" "^7.16.7" "@babel/plugin-transform-arrow-functions" "^7.16.7"
"@babel/plugin-transform-async-to-generator" "^7.16.7" "@babel/plugin-transform-async-to-generator" "^7.16.8"
"@babel/plugin-transform-block-scoped-functions" "^7.16.7" "@babel/plugin-transform-block-scoped-functions" "^7.16.7"
"@babel/plugin-transform-block-scoping" "^7.16.7" "@babel/plugin-transform-block-scoping" "^7.16.7"
"@babel/plugin-transform-classes" "^7.16.7" "@babel/plugin-transform-classes" "^7.16.7"
@@ -858,10 +877,10 @@
"@babel/plugin-transform-literals" "^7.16.7" "@babel/plugin-transform-literals" "^7.16.7"
"@babel/plugin-transform-member-expression-literals" "^7.16.7" "@babel/plugin-transform-member-expression-literals" "^7.16.7"
"@babel/plugin-transform-modules-amd" "^7.16.7" "@babel/plugin-transform-modules-amd" "^7.16.7"
"@babel/plugin-transform-modules-commonjs" "^7.16.7" "@babel/plugin-transform-modules-commonjs" "^7.16.8"
"@babel/plugin-transform-modules-systemjs" "^7.16.7" "@babel/plugin-transform-modules-systemjs" "^7.16.7"
"@babel/plugin-transform-modules-umd" "^7.16.7" "@babel/plugin-transform-modules-umd" "^7.16.7"
"@babel/plugin-transform-named-capturing-groups-regex" "^7.16.7" "@babel/plugin-transform-named-capturing-groups-regex" "^7.16.8"
"@babel/plugin-transform-new-target" "^7.16.7" "@babel/plugin-transform-new-target" "^7.16.7"
"@babel/plugin-transform-object-super" "^7.16.7" "@babel/plugin-transform-object-super" "^7.16.7"
"@babel/plugin-transform-parameters" "^7.16.7" "@babel/plugin-transform-parameters" "^7.16.7"
@@ -876,11 +895,11 @@
"@babel/plugin-transform-unicode-escapes" "^7.16.7" "@babel/plugin-transform-unicode-escapes" "^7.16.7"
"@babel/plugin-transform-unicode-regex" "^7.16.7" "@babel/plugin-transform-unicode-regex" "^7.16.7"
"@babel/preset-modules" "^0.1.5" "@babel/preset-modules" "^0.1.5"
"@babel/types" "^7.16.7" "@babel/types" "^7.16.8"
babel-plugin-polyfill-corejs2 "^0.3.0" babel-plugin-polyfill-corejs2 "^0.3.0"
babel-plugin-polyfill-corejs3 "^0.4.0" babel-plugin-polyfill-corejs3 "^0.5.0"
babel-plugin-polyfill-regenerator "^0.3.0" babel-plugin-polyfill-regenerator "^0.3.0"
core-js-compat "^3.19.1" core-js-compat "^3.20.2"
semver "^6.3.0" semver "^6.3.0"
"@babel/preset-modules@^0.1.5": "@babel/preset-modules@^0.1.5":
@@ -935,6 +954,22 @@
debug "^4.1.0" debug "^4.1.0"
globals "^11.1.0" globals "^11.1.0"
"@babel/traverse@^7.16.8":
version "7.16.8"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.16.8.tgz#bab2f2b09a5fe8a8d9cad22cbfe3ba1d126fef9c"
integrity sha512-xe+H7JlvKsDQwXRsBhSnq1/+9c+LlQcCK3Tn/l5sbx02HYns/cn7ibp9+RV1sIUqu7hKg91NWsgHurO9dowITQ==
dependencies:
"@babel/code-frame" "^7.16.7"
"@babel/generator" "^7.16.8"
"@babel/helper-environment-visitor" "^7.16.7"
"@babel/helper-function-name" "^7.16.7"
"@babel/helper-hoist-variables" "^7.16.7"
"@babel/helper-split-export-declaration" "^7.16.7"
"@babel/parser" "^7.16.8"
"@babel/types" "^7.16.8"
debug "^4.1.0"
globals "^11.1.0"
"@babel/types@^7.0.0", "@babel/types@^7.16.0", "@babel/types@^7.16.7", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4": "@babel/types@^7.0.0", "@babel/types@^7.16.0", "@babel/types@^7.16.7", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4":
version "7.16.7" version "7.16.7"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.16.7.tgz#4ed19d51f840ed4bd5645be6ce40775fecf03159" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.16.7.tgz#4ed19d51f840ed4bd5645be6ce40775fecf03159"
@@ -943,15 +978,23 @@
"@babel/helper-validator-identifier" "^7.16.7" "@babel/helper-validator-identifier" "^7.16.7"
to-fast-properties "^2.0.0" to-fast-properties "^2.0.0"
"@babel/types@^7.16.8":
version "7.16.8"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.16.8.tgz#0ba5da91dd71e0a4e7781a30f22770831062e3c1"
integrity sha512-smN2DQc5s4M7fntyjGtyIPbRJv6wW4rU/94fmYJ7PKQuZkC0qGMHXJbg6sNGt12JmVr4k5YaptI/XtiLJBnmIg==
dependencies:
"@babel/helper-validator-identifier" "^7.16.7"
to-fast-properties "^2.0.0"
"@bcoe/v8-coverage@^0.2.3": "@bcoe/v8-coverage@^0.2.3":
version "0.2.3" version "0.2.3"
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
"@commitlint/cli@^16.0.1": "@commitlint/cli@^16.0.2":
version "16.0.1" version "16.0.2"
resolved "https://registry.yarnpkg.com/@commitlint/cli/-/cli-16.0.1.tgz#21905c898ebece7da42277209022b1bc80c4fb39" resolved "https://registry.yarnpkg.com/@commitlint/cli/-/cli-16.0.2.tgz#393b03793fc59b93e5f4dd7dd535a6cc5a7413ca"
integrity sha512-61gGRy65WiVDRsqP0dAR2fAgE3qrTBW3fgz9MySv32y5Ib3ZXXDDq6bGyQqi2dSaPuDYzNCRwwlC7mmQM73T/g== integrity sha512-Jt7iaBjoLGC5Nq4dHPTvTYnqPGkElFPBtTXTvBpTgatZApczyjI2plE0oG4GYWPp1suHIS/VdVDOMpPZjGVusg==
dependencies: dependencies:
"@commitlint/format" "^16.0.0" "@commitlint/format" "^16.0.0"
"@commitlint/lint" "^16.0.0" "@commitlint/lint" "^16.0.0"
@@ -1690,14 +1733,14 @@
dependencies: dependencies:
"@types/yargs-parser" "*" "@types/yargs-parser" "*"
"@typescript-eslint/eslint-plugin@^5.9.0": "@typescript-eslint/eslint-plugin@^5.9.1":
version "5.9.0" version "5.9.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.9.0.tgz#382182d5cb062f52aac54434cfc47c28898c8006" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.9.1.tgz#e5a86d7e1f9dc0b3df1e6d94feaf20dd838d066c"
integrity sha512-qT4lr2jysDQBQOPsCCvpPUZHjbABoTJW8V9ZzIYKHMfppJtpdtzszDYsldwhFxlhvrp7aCHeXD1Lb9M1zhwWwQ== integrity sha512-Xv9tkFlyD4MQGpJgTo6wqDqGvHIRmRgah/2Sjz1PUnJTawjHWIwBivUE9x0QtU2WVii9baYgavo/bHjrZJkqTw==
dependencies: dependencies:
"@typescript-eslint/experimental-utils" "5.9.0" "@typescript-eslint/experimental-utils" "5.9.1"
"@typescript-eslint/scope-manager" "5.9.0" "@typescript-eslint/scope-manager" "5.9.1"
"@typescript-eslint/type-utils" "5.9.0" "@typescript-eslint/type-utils" "5.9.1"
debug "^4.3.2" debug "^4.3.2"
functional-red-black-tree "^1.0.1" functional-red-black-tree "^1.0.1"
ignore "^5.1.8" ignore "^5.1.8"
@@ -1705,69 +1748,69 @@
semver "^7.3.5" semver "^7.3.5"
tsutils "^3.21.0" tsutils "^3.21.0"
"@typescript-eslint/experimental-utils@5.9.0": "@typescript-eslint/experimental-utils@5.9.1":
version "5.9.0" version "5.9.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-5.9.0.tgz#652762d37d6565ef07af285021b8347b6c79a827" resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-5.9.1.tgz#8c407c4dd5ffe522329df6e4c9c2b52206d5f7f1"
integrity sha512-ZnLVjBrf26dn7ElyaSKa6uDhqwvAi4jBBmHK1VxuFGPRAxhdi18ubQYSGA7SRiFiES3q9JiBOBHEBStOFkwD2g== integrity sha512-cb1Njyss0mLL9kLXgS/eEY53SZQ9sT519wpX3i+U457l2UXRDuo87hgKfgRazmu9/tQb0x2sr3Y0yrU+Zz0y+w==
dependencies: dependencies:
"@types/json-schema" "^7.0.9" "@types/json-schema" "^7.0.9"
"@typescript-eslint/scope-manager" "5.9.0" "@typescript-eslint/scope-manager" "5.9.1"
"@typescript-eslint/types" "5.9.0" "@typescript-eslint/types" "5.9.1"
"@typescript-eslint/typescript-estree" "5.9.0" "@typescript-eslint/typescript-estree" "5.9.1"
eslint-scope "^5.1.1" eslint-scope "^5.1.1"
eslint-utils "^3.0.0" eslint-utils "^3.0.0"
"@typescript-eslint/parser@^5.9.0": "@typescript-eslint/parser@^5.9.1":
version "5.9.0" version "5.9.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.9.0.tgz#fdbb08767a4caa6ca6ccfed5f9ffe9387f0c7d97" resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.9.1.tgz#b114011010a87e17b3265ca715e16c76a9834cef"
integrity sha512-/6pOPz8yAxEt4PLzgbFRDpZmHnXCeZgPDrh/1DaVKOjvn/UPMlWhbx/gA96xRi2JxY1kBl2AmwVbyROUqys5xQ== integrity sha512-PLYO0AmwD6s6n0ZQB5kqPgfvh73p0+VqopQQLuNfi7Lm0EpfKyDalchpVwkE+81k5HeiRrTV/9w1aNHzjD7C4g==
dependencies: dependencies:
"@typescript-eslint/scope-manager" "5.9.0" "@typescript-eslint/scope-manager" "5.9.1"
"@typescript-eslint/types" "5.9.0" "@typescript-eslint/types" "5.9.1"
"@typescript-eslint/typescript-estree" "5.9.0" "@typescript-eslint/typescript-estree" "5.9.1"
debug "^4.3.2" debug "^4.3.2"
"@typescript-eslint/scope-manager@5.9.0": "@typescript-eslint/scope-manager@5.9.1":
version "5.9.0" version "5.9.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.9.0.tgz#02dfef920290c1dcd7b1999455a3eaae7a1a3117" resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.9.1.tgz#6c27be89f1a9409f284d95dfa08ee3400166fe69"
integrity sha512-DKtdIL49Qxk2a8icF6whRk7uThuVz4A6TCXfjdJSwOsf+9ree7vgQWcx0KOyCdk0i9ETX666p4aMhrRhxhUkyg== integrity sha512-8BwvWkho3B/UOtzRyW07ffJXPaLSUKFBjpq8aqsRvu6HdEuzCY57+ffT7QoV4QXJXWSU1+7g3wE4AlgImmQ9pQ==
dependencies: dependencies:
"@typescript-eslint/types" "5.9.0" "@typescript-eslint/types" "5.9.1"
"@typescript-eslint/visitor-keys" "5.9.0" "@typescript-eslint/visitor-keys" "5.9.1"
"@typescript-eslint/type-utils@5.9.0": "@typescript-eslint/type-utils@5.9.1":
version "5.9.0" version "5.9.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.9.0.tgz#fd5963ead04bc9b7af9c3a8e534d8d39f1ce5f93" resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-5.9.1.tgz#c6832ffe655b9b1fec642d36db1a262d721193de"
integrity sha512-uVCb9dJXpBrK1071ri5aEW7ZHdDHAiqEjYznF3HSSvAJXyrkxGOw2Ejibz/q6BXdT8lea8CMI0CzKNFTNI6TEQ== integrity sha512-tRSpdBnPRssjlUh35rE9ug5HrUvaB9ntREy7gPXXKwmIx61TNN7+l5YKgi1hMKxo5NvqZCfYhA5FvyuJG6X6vg==
dependencies: dependencies:
"@typescript-eslint/experimental-utils" "5.9.0" "@typescript-eslint/experimental-utils" "5.9.1"
debug "^4.3.2" debug "^4.3.2"
tsutils "^3.21.0" tsutils "^3.21.0"
"@typescript-eslint/types@5.9.0": "@typescript-eslint/types@5.9.1":
version "5.9.0" version "5.9.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.9.0.tgz#e5619803e39d24a03b3369506df196355736e1a3" resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.9.1.tgz#1bef8f238a2fb32ebc6ff6d75020d9f47a1593c6"
integrity sha512-mWp6/b56Umo1rwyGCk8fPIzb9Migo8YOniBGPAQDNC6C52SeyNGN4gsVwQTAR+RS2L5xyajON4hOLwAGwPtUwg== integrity sha512-SsWegWudWpkZCwwYcKoDwuAjoZXnM1y2EbEerTHho19Hmm+bQ56QG4L4jrtCu0bI5STaRTvRTZmjprWlTw/5NQ==
"@typescript-eslint/typescript-estree@5.9.0": "@typescript-eslint/typescript-estree@5.9.1":
version "5.9.0" version "5.9.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.9.0.tgz#0e5c6f03f982931abbfbc3c1b9df5fbf92a3490f" resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.9.1.tgz#d5b996f49476495070d2b8dd354861cf33c005d6"
integrity sha512-kxo3xL2mB7XmiVZcECbaDwYCt3qFXz99tBSuVJR4L/sR7CJ+UNAPrYILILktGj1ppfZ/jNt/cWYbziJUlHl1Pw== integrity sha512-gL1sP6A/KG0HwrahVXI9fZyeVTxEYV//6PmcOn1tD0rw8VhUWYeZeuWHwwhnewnvEMcHjhnJLOBhA9rK4vmb8A==
dependencies: dependencies:
"@typescript-eslint/types" "5.9.0" "@typescript-eslint/types" "5.9.1"
"@typescript-eslint/visitor-keys" "5.9.0" "@typescript-eslint/visitor-keys" "5.9.1"
debug "^4.3.2" debug "^4.3.2"
globby "^11.0.4" globby "^11.0.4"
is-glob "^4.0.3" is-glob "^4.0.3"
semver "^7.3.5" semver "^7.3.5"
tsutils "^3.21.0" tsutils "^3.21.0"
"@typescript-eslint/visitor-keys@5.9.0": "@typescript-eslint/visitor-keys@5.9.1":
version "5.9.0" version "5.9.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.9.0.tgz#7585677732365e9d27f1878150fab3922784a1a6" resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.9.1.tgz#f52206f38128dd4f675cf28070a41596eee985b7"
integrity sha512-6zq0mb7LV0ThExKlecvpfepiB+XEtFv/bzx7/jKSgyXTFD7qjmSu1FoiS0x3OZaiS+UIXpH2vd9O89f02RCtgw== integrity sha512-Xh37pNz9e9ryW4TVdwiFzmr4hloty8cFj8GTWMXh3Z8swGwyQWeCcNgF0hm6t09iZd6eiZmIf4zHedQVP6TVtg==
dependencies: dependencies:
"@typescript-eslint/types" "5.9.0" "@typescript-eslint/types" "5.9.1"
eslint-visitor-keys "^3.0.0" eslint-visitor-keys "^3.0.0"
JSONStream@^1.0.4: JSONStream@^1.0.4:
@@ -2131,13 +2174,13 @@ babel-plugin-polyfill-corejs2@^0.3.0:
"@babel/helper-define-polyfill-provider" "^0.3.0" "@babel/helper-define-polyfill-provider" "^0.3.0"
semver "^6.1.1" semver "^6.1.1"
babel-plugin-polyfill-corejs3@^0.4.0: babel-plugin-polyfill-corejs3@^0.5.0:
version "0.4.0" version "0.5.0"
resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.4.0.tgz#0b571f4cf3d67f911512f5c04842a7b8e8263087" resolved "https://registry.yarnpkg.com/babel-plugin-polyfill-corejs3/-/babel-plugin-polyfill-corejs3-0.5.0.tgz#f81371be3fe499d39e074e272a1ef86533f3d268"
integrity sha512-YxFreYwUfglYKdLUGvIF2nJEsGwj+RhWSX/ije3D2vQPOXuyMLMtg/cCGMDpOA7Nd+MwlNdnGODbd2EwUZPlsw== integrity sha512-Hcrgnmkf+4JTj73GbK3bBhlVPiLL47owUAnoJIf69Hakl3q+KfodbDXiZWGMM7iqCZTxCG3Z2VRfPNYES4rXqQ==
dependencies: dependencies:
"@babel/helper-define-polyfill-provider" "^0.3.0" "@babel/helper-define-polyfill-provider" "^0.3.0"
core-js-compat "^3.18.0" core-js-compat "^3.20.0"
babel-plugin-polyfill-regenerator@^0.3.0: babel-plugin-polyfill-regenerator@^0.3.0:
version "0.3.0" version "0.3.0"
@@ -2867,7 +2910,7 @@ convert-source-map@^1.4.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0:
dependencies: dependencies:
safe-buffer "~5.1.1" safe-buffer "~5.1.1"
core-js-compat@^3.18.0, core-js-compat@^3.19.1: core-js-compat@^3.20.0, core-js-compat@^3.20.2:
version "3.20.2" version "3.20.2"
resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.20.2.tgz#d1ff6936c7330959b46b2e08b122a8b14e26140b" resolved "https://registry.yarnpkg.com/core-js-compat/-/core-js-compat-3.20.2.tgz#d1ff6936c7330959b46b2e08b122a8b14e26140b"
integrity sha512-qZEzVQ+5Qh6cROaTPFLNS4lkvQ6mBzE3R6A6EEpssj7Zr2egMHgsy4XapdifqJDGC9CBiNv7s+ejI96rLNQFdg== integrity sha512-qZEzVQ+5Qh6cROaTPFLNS4lkvQ6mBzE3R6A6EEpssj7Zr2egMHgsy4XapdifqJDGC9CBiNv7s+ejI96rLNQFdg==
@@ -3431,17 +3474,17 @@ escodegen@^2.0.0:
optionalDependencies: optionalDependencies:
source-map "~0.6.1" source-map "~0.6.1"
eslint-config-aqua@^9.0.2: eslint-config-aqua@^9.1.0:
version "9.0.2"
resolved "https://registry.yarnpkg.com/eslint-config-aqua/-/eslint-config-aqua-9.0.2.tgz#bc26093dd2292b0dfe9aa9ed6bac5247994d0a22"
integrity sha512-WqV4EYX3pXoL0TkUBH9VVHoWjR3eJ0ud1p5OmSfbRoyjDbUJURs78fpeU4H8t88pO8mFB4SHTZM95DJEwKG/MQ==
eslint-config-marine@^9.0.6, eslint-config-marine@^9.1.0:
version "9.1.0" version "9.1.0"
resolved "https://registry.yarnpkg.com/eslint-config-marine/-/eslint-config-marine-9.1.0.tgz#3d6f917c1de47f3d922fe19403e5fc712b5bbb68" resolved "https://registry.yarnpkg.com/eslint-config-aqua/-/eslint-config-aqua-9.1.0.tgz#c56241f4d7c4f4113508c558fc9864966bb1281a"
integrity sha512-27gCRgmWB1XL+DIa3+RX0qSVVk4UZP36fG72loDxkt71M4sl6TUE/w8NqsbF+G3S72jGY0fHIpXBVDMvTJIbDA== integrity sha512-l3ry74+qkpyy8JGkmoMZdgIeiQuxc/tjm5lzJQtrgE9a6VYzrQH2ZSkRw1q/zrDQH2v0PZc8PWvVITbApRuE0w==
eslint-config-marine@^9.3.2:
version "9.3.2"
resolved "https://registry.yarnpkg.com/eslint-config-marine/-/eslint-config-marine-9.3.2.tgz#225728b0033486fdc266ccafe192f0eefae43a55"
integrity sha512-MlddXjkZ1h/XqyN2/5nDqrwKGtD1lVVFvTRSNWCnjsJeyHA4GgUhNQoV14BMk5D5tx0AN1A0bTcAuPckOpFvjw==
dependencies: dependencies:
eslint-config-aqua "^9.0.2" eslint-config-aqua "^9.1.0"
eslint-config-prettier@^8.3.0: eslint-config-prettier@^8.3.0:
version "8.3.0" version "8.3.0"
@@ -7667,7 +7710,7 @@ turbo-windows-64@1.0.24:
resolved "https://registry.yarnpkg.com/turbo-windows-64/-/turbo-windows-64-1.0.24.tgz#5dd30b10110f2bb69caa479ddd72b4c471fb0dea" resolved "https://registry.yarnpkg.com/turbo-windows-64/-/turbo-windows-64-1.0.24.tgz#5dd30b10110f2bb69caa479ddd72b4c471fb0dea"
integrity sha512-YHAWha5XkW0Ate1HtwhzFD32kZFXtC8KB4ReEvHc9GM2inQob1ZinvktS0xi5MC5Sxl9+bObOWmsxeZPOgNCFA== integrity sha512-YHAWha5XkW0Ate1HtwhzFD32kZFXtC8KB4ReEvHc9GM2inQob1ZinvktS0xi5MC5Sxl9+bObOWmsxeZPOgNCFA==
turbo@^1.0.24: turbo@1.0.24:
version "1.0.24" version "1.0.24"
resolved "https://registry.yarnpkg.com/turbo/-/turbo-1.0.24.tgz#5efdeb44aab2f5e97b24a3e0ed4a159bfcd0a877" resolved "https://registry.yarnpkg.com/turbo/-/turbo-1.0.24.tgz#5efdeb44aab2f5e97b24a3e0ed4a159bfcd0a877"
integrity sha512-bfOr7iW48+chDl+yKiZ5FIWzXOF6xOIyrAGPaWI+I5CdD27IZCEGvqvTV/weaHvjLbV7otybHQ56XCybBlVjoA== integrity sha512-bfOr7iW48+chDl+yKiZ5FIWzXOF6xOIyrAGPaWI+I5CdD27IZCEGvqvTV/weaHvjLbV7otybHQ56XCybBlVjoA==