From ac201235a79864fcbc8717cd6185fdc0166594b8 Mon Sep 17 00:00:00 2001 From: Lechner Julian - FrauJulian Date: Sun, 27 Jul 2025 17:54:25 +0200 Subject: [PATCH] updated package.json; refactored code > imports/exports --- package-lock.json | 35 +++++++------ package.json | 62 +++++++++++++++++------- src/Models/VoiceAudioDataModel.d.ts | 4 +- src/Models/VoiceConnectionDataModel.d.ts | 4 +- src/Services/AudioManager.ts | 8 +-- src/Services/IAudioManager.ts | 7 ++- src/index.ts | 6 +-- tsconfig.json | 51 ++++++++++--------- tsup.config.ts | 8 +-- 9 files changed, 111 insertions(+), 74 deletions(-) diff --git a/package-lock.json b/package-lock.json index bd18833..11e87a0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,29 +1,36 @@ { "name": "discord-audio-stream", - "version": "0.6.8", + "version": "0.6.10", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "discord-audio-stream", - "version": "0.6.8", + "version": "0.6.10", "dependencies": { - "@discordjs/opus": "^0.10.0", "@discordjs/voice": "^0.18.0", "@noble/ciphers": "^1.3.0", "@stablelib/xchacha20poly1305": "^2.0.1", - "ffmpeg-static": "^5.2.0", - "libsodium-wrappers": "^0.7.15", - "opusscript": "^0.1.1", "sodium-native": "^5.0.6" }, "devDependencies": { "@types/ejs": "^3.1.5", - "@types/node": "^24.0.10", + "@types/node": "^24.1.0", "del-cli": "^6.0.0", - "npm-check-updates": "^18.0.1", + "npm-check-updates": "^18.0.2", "tsup": "^8.5.0", "typescript": "^5.8.3" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://ko-fi.com/FrauJulian" + }, + "peerDependencies": { + "ffmpeg-static": "^5.2.0", + "libsodium-wrappers": "^0.7.15", + "opusscript": "^0.1.1" } }, "node_modules/@derhuerst/http-basic": { @@ -1084,9 +1091,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "24.0.10", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.10.tgz", - "integrity": "sha512-ENHwaH+JIRTDIEEbDK6QSQntAYGtbvdDXnMXnZaZ6k13Du1dPMmprkEHIL7ok2Wl2aZevetwTAb5S+7yIF+enA==", + "version": "24.1.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.1.0.tgz", + "integrity": "sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w==", "license": "MIT", "dependencies": { "undici-types": "~7.8.0" @@ -2314,9 +2321,9 @@ } }, "node_modules/npm-check-updates": { - "version": "18.0.1", - "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-18.0.1.tgz", - "integrity": "sha512-MO7mLp/8nm6kZNLLyPgz4gHmr9tLoU+pWPLdXuGAx+oZydBHkHWN0ibTonsrfwC2WEQNIQxuZagYwB67JQpAuw==", + "version": "18.0.2", + "resolved": "https://registry.npmjs.org/npm-check-updates/-/npm-check-updates-18.0.2.tgz", + "integrity": "sha512-9uVFZUCg5oDOcbzdsrJ4BEvq2gikd23tXuF5mqpl4mxVl051lzB00Xmd7ZVjVWY3XNUF3BQKWlN/qmyD8/bwrA==", "dev": true, "license": "Apache-2.0", "bin": { diff --git a/package.json b/package.json index 84b932a..a6b98dd 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,25 @@ { "name": "discord-audio-stream", - "version": "0.6.8", + "version": "0.6.10", "description": "NodeJS library to make stream any audio on discord easier.", + "exports": { + ".": { + "require": { + "types": "./dist/index.d.ts", + "default": "./dist/index.js" + }, + "import": { + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" + } + } + }, "main": "./dist/index.js", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", + "files": [ + "dist" + ], "scripts": { "updateDependencies": "npx npm-check-updates --upgrade && npm install && echo SUCCEED UPDATE", "cleanSolution": "del-cli dist && echo SUCCEED CLEAN", @@ -14,35 +29,48 @@ }, "repository": "https://github.com/FrauJulian/Discord-Audio-Stream", "bugs": "https://github.com/FrauJulian/Discord-Audio-Stream/issues", + "funding": "https://ko-fi.com/FrauJulian", "keywords": [ - "discordjs-v14", - "stream", + "discordjs", + "discord.js", + "discord", "audio", - "music" + "voice", + "stream" + ], + "contributors": [ + { + "name": "Lechner Julian", + "nickname": "FrauJulian", + "email": "office@lechner-systems.at", + "website": "https://lechner-systems.at/" + } ], - "author": { - "name": "Lechner Julian", - "nickname": "FrauJulian", - "email": "contact@fraujulian.xyz", - "website": "https://fraujulian.xyz/" - }, - "private": false, "dependencies": { - "@discordjs/opus": "^0.10.0", "@discordjs/voice": "^0.18.0", "@noble/ciphers": "^1.3.0", "@stablelib/xchacha20poly1305": "^2.0.1", - "ffmpeg-static": "^5.2.0", - "libsodium-wrappers": "^0.7.15", - "opusscript": "^0.1.1", "sodium-native": "^5.0.6" }, "devDependencies": { "@types/ejs": "^3.1.5", - "@types/node": "^24.0.10", + "@types/node": "^24.1.0", "del-cli": "^6.0.0", - "npm-check-updates": "^18.0.1", + "npm-check-updates": "^18.0.2", "tsup": "^8.5.0", "typescript": "^5.8.3" + }, + "peerDependencies": { + "libsodium-wrappers": "^0.7.15", + "opusscript": "^0.1.1", + "ffmpeg-static": "^5.2.0" + }, + "engines": { + "node": ">=18" + }, + "private": false, + "publishConfig": { + "access": "public", + "provenance": true } } diff --git a/src/Models/VoiceAudioDataModel.d.ts b/src/Models/VoiceAudioDataModel.d.ts index 8f762c1..e6a4e02 100644 --- a/src/Models/VoiceAudioDataModel.d.ts +++ b/src/Models/VoiceAudioDataModel.d.ts @@ -1,4 +1,4 @@ -export interface VoiceAudioDataModel { +export default interface VoiceAudioDataModel { /** * The unique identifier for the audio resource. */ @@ -9,4 +9,4 @@ export interface VoiceAudioDataModel { * any is to be assumed to require(filepath) */ Resource: string | any; -} \ No newline at end of file +} diff --git a/src/Models/VoiceConnectionDataModel.d.ts b/src/Models/VoiceConnectionDataModel.d.ts index 4b3a614..523ec98 100644 --- a/src/Models/VoiceConnectionDataModel.d.ts +++ b/src/Models/VoiceConnectionDataModel.d.ts @@ -1,6 +1,6 @@ -import {DiscordGatewayAdapterCreator} from "@discordjs/voice"; +import type {DiscordGatewayAdapterCreator} from "@discordjs/voice"; -export interface VoiceConnectionDataModel { +export default interface VoiceConnectionDataModel { /** * The ID of the voice channel to connect to. */ diff --git a/src/Services/AudioManager.ts b/src/Services/AudioManager.ts index fea05cf..9ae6267 100644 --- a/src/Services/AudioManager.ts +++ b/src/Services/AudioManager.ts @@ -6,12 +6,12 @@ import { joinVoiceChannel, VoiceConnection } from "@discordjs/voice"; -import {IAudioManager} from "./IAudioManager"; -import {VoiceConnectionDataModel} from "../Models/VoiceConnectionDataModel"; -import {VoiceAudioDataModel} from "../Models/VoiceAudioDataModel"; +import type IAudioManager from "./IAudioManager"; +import type VoiceConnectionDataModel from "../Models/VoiceConnectionDataModel"; +import type VoiceAudioDataModel from "../Models/VoiceAudioDataModel"; import {join} from "node:path"; -export class AudioManager implements IAudioManager { +export default class AudioManager implements IAudioManager { public VoiceConnection: VoiceConnection | null = null; public AudioPlayer: AudioPlayer | null = null; public AudioResource: AudioResource | null = null; diff --git a/src/Services/IAudioManager.ts b/src/Services/IAudioManager.ts index f93c4ba..648e03e 100644 --- a/src/Services/IAudioManager.ts +++ b/src/Services/IAudioManager.ts @@ -1,8 +1,7 @@ -import {AudioPlayer, AudioResource, VoiceConnection} from "@discordjs/voice"; -import {VoiceAudioDataModel} from "../Models/VoiceAudioDataModel"; -import {VoiceConnectionDataModel} from "../Models/VoiceConnectionDataModel"; +import type VoiceConnectionDataModel from "../Models/VoiceConnectionDataModel"; +import type VoiceAudioDataModel from "../Models/VoiceAudioDataModel"; -export interface IAudioManager { +export default interface IAudioManager { OverrideOptions(connectionData?: VoiceConnectionDataModel | null, audioData?: VoiceAudioDataModel | null): void; CreateConnection(isRenew: boolean): void; diff --git a/src/index.ts b/src/index.ts index ea1b8c1..f08b6d3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,3 @@ -export {AudioManager} from "./Services/AudioManager"; -export type {VoiceConnectionDataModel} from "./Models/VoiceConnectionDataModel"; -export type {VoiceAudioDataModel} from "./Models/VoiceAudioDataModel"; +export { default as AudioManager } from './Services/AudioManager'; +export type { default as VoiceConnectionDataModel } from './Models/VoiceConnectionDataModel'; +export type { default as VoiceAudioDataModel } from './Models/VoiceAudioDataModel'; diff --git a/tsconfig.json b/tsconfig.json index 33392c1..89e67d6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,25 +1,28 @@ { - "compilerOptions": { - "strict": true, - "allowJs": false, - "noImplicitAny": true, - "esModuleInterop": true, - "strictNullChecks": true, - "target": "ES2022", - "moduleResolution": "Node", - "module": "CommonJS", - "declaration": true, - "isolatedModules": true, - "noEmit": true, - "outDir": "dist", - "types": [ - "node" - ], - "typeRoots": [ - "node_modules/@types" - ] - }, - - "include": ["src"], - "exclude": ["node_modules"] -} \ No newline at end of file + "compilerOptions": { + "strict": true, + "allowJs": false, + "noImplicitAny": true, + "esModuleInterop": true, + "strictNullChecks": true, + "target": "ES2022", + "moduleResolution": "Node", + "module": "CommonJS", + "declaration": true, + "isolatedModules": true, + "noEmit": true, + "outDir": "dist", + "types": [ + "node" + ], + "typeRoots": [ + "node_modules/@types" + ] + }, + "include": [ + "src" + ], + "exclude": [ + "node_modules" + ] +} diff --git a/tsup.config.ts b/tsup.config.ts index e5098e2..cbbe1bd 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,10 +1,10 @@ -import { defineConfig } from "tsup"; - +import {defineConfig} from "tsup"; + export default defineConfig({ - format: [ "cjs", "esm" ], + format: ["cjs", "esm"], entry: ["./src/index.ts"], dts: true, shims: true, skipNodeModulesBundle: true, clean: true, -}); \ No newline at end of file +});