@students-dev/audify-js 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +92 -441
  2. package/dist/AudioEngine.js +232 -0
  3. package/dist/cjs/index.js +1478 -1746
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/constants/index.js +35 -0
  6. package/dist/engine/Filters.js +137 -0
  7. package/dist/engine/MockAudioContext.js +53 -0
  8. package/dist/engine/Player.js +209 -0
  9. package/dist/esm/index.js +1474 -1744
  10. package/dist/esm/index.js.map +1 -1
  11. package/dist/events/EventBus.js +61 -0
  12. package/dist/index.js +18 -0
  13. package/dist/interfaces/index.js +1 -0
  14. package/dist/plugins/Plugin.js +27 -0
  15. package/dist/plugins/PluginManager.js +106 -0
  16. package/dist/providers/LavalinkProvider.js +81 -0
  17. package/dist/providers/LocalProvider.js +70 -0
  18. package/dist/providers/ProviderRegistry.js +20 -0
  19. package/dist/providers/SpotifyProvider.js +59 -0
  20. package/dist/providers/YouTubeProvider.js +48 -0
  21. package/dist/queue/Queue.js +186 -0
  22. package/dist/queue/Track.js +54 -0
  23. package/dist/types/AudioEngine.d.ts +107 -0
  24. package/dist/types/constants/index.d.ts +39 -0
  25. package/dist/types/engine/Filters.d.ts +25 -24
  26. package/dist/types/engine/MockAudioContext.d.ts +43 -0
  27. package/dist/types/engine/Player.d.ts +25 -21
  28. package/dist/types/events/EventBus.d.ts +17 -15
  29. package/dist/types/index.d.ts +17 -15
  30. package/dist/types/interfaces/index.d.ts +31 -0
  31. package/dist/types/plugins/Plugin.d.ts +11 -43
  32. package/dist/types/plugins/PluginManager.d.ts +19 -19
  33. package/dist/types/providers/LavalinkProvider.d.ts +15 -46
  34. package/dist/types/providers/LocalProvider.d.ts +11 -22
  35. package/dist/types/providers/ProviderRegistry.d.ts +10 -0
  36. package/dist/types/providers/SpotifyProvider.d.ts +12 -52
  37. package/dist/types/providers/YouTubeProvider.d.ts +11 -28
  38. package/dist/types/queue/Queue.d.ts +28 -22
  39. package/dist/types/queue/Track.d.ts +18 -16
  40. package/dist/types/utils/Logger.d.ts +12 -16
  41. package/dist/types/utils/Metadata.d.ts +16 -15
  42. package/dist/types/utils/Probe.d.ts +7 -7
  43. package/dist/types/utils/Time.d.ts +9 -9
  44. package/dist/utils/Logger.js +59 -0
  45. package/dist/utils/Metadata.js +90 -0
  46. package/dist/utils/Probe.js +59 -0
  47. package/dist/utils/Time.js +54 -0
  48. package/package.json +14 -8
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Audio probing utilities
3
+ */
4
+ export class ProbeUtils {
5
+ /**
6
+ * Probe audio file/stream for basic info
7
+ * @param source - Audio source
8
+ * @returns Probe result
9
+ */
10
+ static async probe(source) {
11
+ // In a real implementation, this would use ffprobe or similar
12
+ // For now, return basic mock data
13
+ return {
14
+ duration: null, // seconds
15
+ format: null, // e.g., 'mp3', 'wav'
16
+ bitrate: null, // kbps
17
+ sampleRate: null, // Hz
18
+ channels: null // 1 or 2
19
+ };
20
+ }
21
+ /**
22
+ * Check if source is a valid audio URL
23
+ * @param url - URL to check
24
+ * @returns Is valid audio URL
25
+ */
26
+ static isValidAudioUrl(url) {
27
+ if (!url || typeof url !== 'string')
28
+ return false;
29
+ try {
30
+ const parsed = new URL(url);
31
+ const audioExtensions = ['.mp3', '.wav', '.ogg', '.flac', '.aac', '.m4a'];
32
+ const path = parsed.pathname.toLowerCase();
33
+ return audioExtensions.some(ext => path.endsWith(ext)) ||
34
+ url.includes('youtube.com') ||
35
+ url.includes('youtu.be') ||
36
+ url.includes('soundcloud.com');
37
+ }
38
+ catch {
39
+ return false;
40
+ }
41
+ }
42
+ /**
43
+ * Get audio format from URL or buffer
44
+ * @param source - Audio source
45
+ * @returns Audio format
46
+ */
47
+ static getFormat(source) {
48
+ if (typeof source === 'string') {
49
+ const extensions = ['mp3', 'wav', 'ogg', 'flac', 'aac', 'm4a'];
50
+ for (const ext of extensions) {
51
+ if (source.toLowerCase().includes(`.${ext}`)) {
52
+ return ext;
53
+ }
54
+ }
55
+ }
56
+ // For buffer, would need to check headers
57
+ return null;
58
+ }
59
+ }
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Time formatting utilities
3
+ */
4
+ export class TimeUtils {
5
+ /**
6
+ * Format seconds to MM:SS or HH:MM:SS
7
+ * @param seconds - Time in seconds
8
+ * @returns Formatted time string
9
+ */
10
+ static format(seconds) {
11
+ if (!Number.isFinite(seconds) || seconds < 0)
12
+ return '00:00';
13
+ const hours = Math.floor(seconds / 3600);
14
+ const minutes = Math.floor((seconds % 3600) / 60);
15
+ const secs = Math.floor(seconds % 60);
16
+ if (hours > 0) {
17
+ return `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
18
+ }
19
+ return `${minutes.toString().padStart(2, '0')}:${secs.toString().padStart(2, '0')}`;
20
+ }
21
+ /**
22
+ * Parse time string to seconds
23
+ * @param timeStr - Time string like "1:23" or "01:23:45"
24
+ * @returns Time in seconds
25
+ */
26
+ static parse(timeStr) {
27
+ if (!timeStr)
28
+ return 0;
29
+ const parts = timeStr.split(':').map(Number);
30
+ if (parts.length === 2) {
31
+ return parts[0] * 60 + parts[1];
32
+ }
33
+ else if (parts.length === 3) {
34
+ return parts[0] * 3600 + parts[1] * 60 + parts[2];
35
+ }
36
+ return 0;
37
+ }
38
+ /**
39
+ * Get current timestamp in milliseconds
40
+ * @returns Current time
41
+ */
42
+ static now() {
43
+ return Date.now();
44
+ }
45
+ /**
46
+ * Calculate duration between two timestamps
47
+ * @param start - Start time
48
+ * @param end - End time
49
+ * @returns Duration in milliseconds
50
+ */
51
+ static duration(start, end) {
52
+ return end - start;
53
+ }
54
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@students-dev/audify-js",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Modern modular audio engine with queue, filters, plugin API, and event-driven design.",
5
5
  "type": "module",
6
6
  "main": "dist/cjs/index.js",
@@ -42,17 +42,23 @@
42
42
  },
43
43
  "homepage": "https://github.com/students-dev/audify-js#readme",
44
44
  "dependencies": {
45
- "spotify-web-api-node": "^5.0.1",
46
- "lavalink-client": "^2.5.1"
45
+ "lavalink-client": "^2.5.1",
46
+ "spotify-web-api-node": "^5.0.1"
47
47
  },
48
48
  "devDependencies": {
49
- "@rollup/plugin-node-resolve": "^15.2.3",
50
49
  "@rollup/plugin-commonjs": "^25.0.7",
50
+ "@rollup/plugin-node-resolve": "^15.2.3",
51
+ "@rollup/plugin-typescript": "^12.3.0",
52
+ "@types/jest": "^30.0.0",
53
+ "@types/node": "^25.0.3",
54
+ "@types/spotify-web-api-node": "^5.0.11",
55
+ "eslint": "^8.56.0",
56
+ "jest": "^29.7.0",
51
57
  "rollup": "^4.9.6",
52
58
  "rollup-plugin-dts": "^6.1.0",
53
- "typescript": "^5.3.3",
54
- "jest": "^29.7.0",
55
- "eslint": "^8.56.0"
59
+ "ts-jest": "^29.4.6",
60
+ "tslib": "^2.8.1",
61
+ "typescript": "^5.3.3"
56
62
  },
57
63
  "engines": {
58
64
  "node": ">=14.0.0"
@@ -61,4 +67,4 @@
61
67
  "dist",
62
68
  "README.md"
63
69
  ]
64
- }
70
+ }