Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…o v7
  • Loading branch information
twlite committed Jul 4, 2024
2 parents 7831a24 + 4d2a7c0 commit f776993
Show file tree
Hide file tree
Showing 25 changed files with 255 additions and 517 deletions.
4 changes: 4 additions & 0 deletions apps/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,9 @@
"homepage": "https://github.com/Androz2091/discord-player#readme",
"dependencies": {
"mintlify": "^4.0.160"
},
"devDependencies": {
"tsup": "^8.1.0",
"typescript": "^5.5.2"
}
}
17 changes: 4 additions & 13 deletions packages/discord-player/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,14 @@
"@discord-player/equalizer": "workspace:^",
"@discord-player/ffmpeg": "workspace:^",
"@discord-player/node": "workspace:^",
"@discord-player/utils": "workspace:^",
"@web-scrobbler/metadata-filter": "^3.1.0",
"discord-voip": "^0.1.3",
"ip": "^2.0.1",
"libsodium-wrappers": "^0.7.13",
"ws": "^8.17.0"
"@discord-player/utils": "workspace:^"
},
"devDependencies": {
"@discord-player/tsconfig": "workspace:^",
"@types/ip": "^1.1.0",
"@types/node": "^18.6.3",
"@types/ws": "^8.5.3",
"discord-api-types": "^0.37.0",
"discord.js": "^14.1.2",
"opusscript": "^0.0.8",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"discord-api-types": "^0.37.91",
"tsup": "^8.1.0",
"typescript": "^5.5.2",
"vitest": "^0.34.6"
},
"typedoc": {
Expand Down
4 changes: 3 additions & 1 deletion packages/discord-player/src/utils/DependencyReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type MaybeNull<T> = T | null;
export interface DependenciesReport {
core: {
'discord-player': string;
'discord-voip': string;
};
libopus: {
mediaplex: MaybeNull<string>;
Expand Down Expand Up @@ -108,7 +109,8 @@ export const DependencyReport = {

return {
core: {
'discord-player': DependencyReport.version('discord-player') as string
'discord-player': DependencyReport.version('discord-player') as string,
'discord-voip': DependencyReport.version('discord-voip') as string
},
libopus: {
mediaplex: DependencyReport.version('mediaplex'),
Expand Down
2 changes: 1 addition & 1 deletion packages/discord-player/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "@discord-player/tsconfig/base.json",
"include": ["src/**/*", "../discord-voip"]
"include": ["src/**/*"]
}
21 changes: 21 additions & 0 deletions packages/discord-voip/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Androz2091

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
5 changes: 4 additions & 1 deletion packages/discord-voip/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
"dependencies": {
"@discord-player/ffmpeg": "workspace:^",
"@discord-player/opus": "workspace:^",
"@discord-player/utils": "workspace:^"
"@discord-player/utils": "workspace:^",
"@types/ws": "^8.5.10",
"tsup": "^8.1.0",
"typescript": "^5.5.2"
}
}
15 changes: 15 additions & 0 deletions packages/discord-voip/scripts/esm-shim.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* eslint-disable */
const { writeFileSync } = require('fs');

const mod = require(`${__dirname}/../dist/index.js`);

const entries = Object.keys(mod);
const exportsMeta = entries.map((m) => `\t${m}`).join(',\n');

const content = [
`import DiscordPlayer from './index.js';\n`,
`const {\n${exportsMeta}\n} = DiscordPlayer;\n`,
`export {\n${exportsMeta}\n};`
];

writeFileSync(`${__dirname}/../dist/index.mjs`, content.join('\n'));
21 changes: 11 additions & 10 deletions packages/discord-voip/src/audio/AudioResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@

import type { Buffer } from 'node:buffer';
import { pipeline, type Readable } from 'node:stream';
import prism from 'prism-media';
import { noop } from '../util/util';
import { SILENCE_FRAME, type AudioPlayer } from './AudioPlayer';
import { findPipeline, StreamType, TransformerType, type Edge } from './TransformerGraph';
import { OggDemuxer, OpusDecoder, OpusEncoder, WebmDemuxer } from '@discord-player/opus';
import { VolumeTransformer } from '@discord-player/equalizer';

/**
* Options that are set when creating a new audio resource.
Expand Down Expand Up @@ -66,13 +67,13 @@ export class AudioResource<Metadata = unknown> {
* If the resource was created with inline volume transformation enabled, then this will be a
* prism-media VolumeTransformer. You can use this to alter the volume of the stream.
*/
public readonly volume?: prism.VolumeTransformer;
public readonly volume?: VolumeTransformer;

/**
* If using an Opus encoder to create this audio resource, then this will be a prism-media opus.Encoder.
* You can use this to control settings such as bitrate, FEC, PLP.
*/
public readonly encoder?: prism.opus.Encoder;
public readonly encoder?: OpusEncoder;

/**
* The audio player that the resource is subscribed to, if any.
Expand Down Expand Up @@ -106,9 +107,9 @@ export class AudioResource<Metadata = unknown> {
this.silencePaddingFrames = silencePaddingFrames;

for (const stream of streams) {
if (stream instanceof prism.VolumeTransformer) {
if (stream instanceof VolumeTransformer) {
this.volume = stream;
} else if (stream instanceof prism.opus.Encoder) {
} else if (stream instanceof OpusEncoder) {
this.encoder = stream;
}
}
Expand Down Expand Up @@ -183,15 +184,15 @@ export function inferStreamType(stream: Readable): {
hasVolume: boolean;
streamType: StreamType;
} {
if (stream instanceof prism.opus.Encoder) {
if (stream instanceof OpusEncoder) {
return { streamType: StreamType.Opus, hasVolume: false };
} else if (stream instanceof prism.opus.Decoder) {
} else if (stream instanceof OpusDecoder) {
return { streamType: StreamType.Raw, hasVolume: false };
} else if (stream instanceof prism.VolumeTransformer) {
} else if (stream instanceof VolumeTransformer) {
return { streamType: StreamType.Raw, hasVolume: true };
} else if (stream instanceof prism.opus.OggDemuxer) {
} else if (stream instanceof OggDemuxer) {
return { streamType: StreamType.Opus, hasVolume: false };
} else if (stream instanceof prism.opus.WebmDemuxer) {
} else if (stream instanceof WebmDemuxer) {
return { streamType: StreamType.Opus, hasVolume: false };
}

Expand Down
2 changes: 1 addition & 1 deletion packages/discord-voip/src/audio/TransformerGraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ function findPath(from: Node, constraints: (path: Edge[]) => boolean, goal = get
* @param step - The first step of the path
*/
function constructPipeline(step: Step) {
const edges = [];
const edges: Edge[] = [];
let current: Step | undefined = step;
while (current?.edge) {
edges.push(current.edge);
Expand Down
128 changes: 0 additions & 128 deletions packages/discord-voip/src/util/demuxProbe.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/discord-voip/src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@

export * from './entersState';
export * from './adapter';
export * from './demuxProbe';
4 changes: 4 additions & 0 deletions packages/discord-voip/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "@discord-player/tsconfig/base.json",
"include": ["src/**/*"]
}
7 changes: 7 additions & 0 deletions packages/discord-voip/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from '../../tsup.config';
import { esbuildPluginVersionInjector } from 'esbuild-plugin-version-injector';

export default defineConfig({
esbuildPlugins: [esbuildPluginVersionInjector()],
format: ['cjs']
});
5 changes: 5 additions & 0 deletions packages/discord-voip/typedoc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"entryPoints": ["src/index.ts"],
"excludePrivate": true,
"excludeExternals": true
}
4 changes: 2 additions & 2 deletions packages/equalizer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
},
"devDependencies": {
"@discord-player/tsconfig": "workspace:^",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"tsup": "^8.1.0",
"typescript": "^5.5.2",
"vitest": "^0.34.6"
},
"typedoc": {
Expand Down
4 changes: 2 additions & 2 deletions packages/ffmpeg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
"devDependencies": {
"@discord-player/tsconfig": "workspace:^",
"@types/node": "^20.3.1",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"tsup": "^8.1.0",
"typescript": "^5.5.2",
"vitest": "^0.34.6"
}
}
3 changes: 2 additions & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
},
"devDependencies": {
"@discord-player/tsconfig": "workspace:^",
"tsup": "^8.1.0"
"tsup": "^8.1.0",
"typescript": "^5.5.2"
}
}
Loading

0 comments on commit f776993

Please sign in to comment.