ziplayer 0.2.6 → 0.2.7-dev.1

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 (57) hide show
  1. package/AI-Guide.md +607 -0
  2. package/README.md +513 -196
  3. package/dist/extensions/BaseExtension.d.ts +1 -0
  4. package/dist/extensions/BaseExtension.d.ts.map +1 -1
  5. package/dist/extensions/BaseExtension.js.map +1 -1
  6. package/dist/extensions/index.d.ts +38 -3
  7. package/dist/extensions/index.d.ts.map +1 -1
  8. package/dist/extensions/index.js +259 -41
  9. package/dist/extensions/index.js.map +1 -1
  10. package/dist/persistence/PersistenceManager.d.ts +61 -0
  11. package/dist/persistence/PersistenceManager.d.ts.map +1 -0
  12. package/dist/persistence/PersistenceManager.js +551 -0
  13. package/dist/persistence/PersistenceManager.js.map +1 -0
  14. package/dist/plugins/BasePlugin.js +1 -1
  15. package/dist/plugins/BasePlugin.js.map +1 -1
  16. package/dist/plugins/index.d.ts +19 -4
  17. package/dist/plugins/index.d.ts.map +1 -1
  18. package/dist/plugins/index.js +273 -146
  19. package/dist/plugins/index.js.map +1 -1
  20. package/dist/structures/FilterManager.js +3 -3
  21. package/dist/structures/FilterManager.js.map +1 -1
  22. package/dist/structures/Player.d.ts +64 -14
  23. package/dist/structures/Player.d.ts.map +1 -1
  24. package/dist/structures/Player.js +344 -91
  25. package/dist/structures/Player.js.map +1 -1
  26. package/dist/structures/PlayerManager.d.ts +125 -91
  27. package/dist/structures/PlayerManager.d.ts.map +1 -1
  28. package/dist/structures/PlayerManager.js +406 -111
  29. package/dist/structures/PlayerManager.js.map +1 -1
  30. package/dist/structures/Queue.d.ts +136 -31
  31. package/dist/structures/Queue.d.ts.map +1 -1
  32. package/dist/structures/Queue.js +265 -46
  33. package/dist/structures/Queue.js.map +1 -1
  34. package/dist/types/index.d.ts +39 -6
  35. package/dist/types/index.d.ts.map +1 -1
  36. package/dist/types/index.js +1 -0
  37. package/dist/types/index.js.map +1 -1
  38. package/dist/types/persistence.d.ts +55 -0
  39. package/dist/types/persistence.d.ts.map +1 -0
  40. package/dist/types/persistence.js +3 -0
  41. package/dist/types/persistence.js.map +1 -0
  42. package/package.json +47 -46
  43. package/src/extensions/BaseExtension.ts +36 -35
  44. package/src/extensions/index.ts +473 -190
  45. package/src/index.ts +16 -16
  46. package/src/persistence/PersistenceManager.ts +572 -0
  47. package/src/plugins/BasePlugin.ts +27 -27
  48. package/src/plugins/index.ts +403 -236
  49. package/src/structures/FilterManager.ts +303 -303
  50. package/src/structures/Player.ts +1962 -1689
  51. package/src/structures/PlayerManager.ts +788 -416
  52. package/src/structures/Queue.ts +599 -354
  53. package/src/types/index.ts +406 -373
  54. package/src/types/persistence.ts +65 -0
  55. package/src/types/plugin.ts +1 -1
  56. package/src/utils/timeout.ts +10 -10
  57. package/tsconfig.json +22 -23
@@ -0,0 +1,65 @@
1
+ import type { Track, LoopMode, PlayerOptions } from ".";
2
+
3
+ export interface SerializedTrack {
4
+ id: string;
5
+ title: string;
6
+ url: string;
7
+ source: string;
8
+ duration: number;
9
+ thumbnail?: string;
10
+ author?: string;
11
+ requestedBy?: string;
12
+ isLive?: boolean;
13
+ artwork?: string;
14
+ [key: string]: any; // For additional metadata
15
+ }
16
+
17
+ export interface SerializedQueue {
18
+ tracks: SerializedTrack[];
19
+ current: SerializedTrack | null;
20
+ history: SerializedTrack[];
21
+ loopMode: LoopMode;
22
+ autoPlay: boolean;
23
+ position?: number; // Current playback position in ms
24
+ }
25
+
26
+ export interface SerializedPlayer {
27
+ guildId: string;
28
+ queue: SerializedQueue;
29
+ volume: number;
30
+ isPlaying: boolean;
31
+ isPaused: boolean;
32
+ options: PlayerOptions;
33
+ filters?: string[];
34
+ lastUpdate: number;
35
+ version: string; // For backward compatibility
36
+ }
37
+
38
+ export interface PersistenceOptions {
39
+ enabled: boolean;
40
+ provider?: "file" | "redis" | "database";
41
+ saveInterval?: number; // Auto-save interval (ms)
42
+ autoLoad?: boolean; // Auto-load on start
43
+ maxBackups?: number; // Number of backups to keep
44
+ compress?: boolean; // Compress saved data
45
+
46
+ // File provider options
47
+ filePath?: string;
48
+
49
+ // Redis provider options
50
+ redisUrl?: string;
51
+ redisPrefix?: string;
52
+
53
+ // Database options (for custom provider)
54
+ save?: (data: Map<string, SerializedPlayer>) => Promise<void>;
55
+ load?: () => Promise<Map<string, SerializedPlayer>>;
56
+ delete?: (guildId: string) => Promise<void>;
57
+ list?: () => Promise<string[]>;
58
+ }
59
+
60
+ export interface PersistenceProvider {
61
+ save(key: string, data: any, compress?: boolean): Promise<void>;
62
+ load(key: string): Promise<any>;
63
+ delete(key: string): Promise<void>;
64
+ list(): Promise<string[]>;
65
+ }
@@ -12,7 +12,7 @@ import type { SearchResult, StreamInfo, Track } from ".";
12
12
  export interface SourcePlugin {
13
13
  name: string;
14
14
  version: string;
15
- priority?: number;
15
+ priority?: number; // Higher = run first, default is 0. Lower priority plugins are tried first in getStream fallback.
16
16
  canHandle(query: string): boolean;
17
17
  search(query: string, requestedBy: string): Promise<SearchResult>;
18
18
  getStream(track: Track): Promise<StreamInfo>;
@@ -1,10 +1,10 @@
1
- /**
2
- * Utility function to add timeout to a promise
3
- * @param promise The promise to add timeout to
4
- * @param timeoutMs Timeout in milliseconds
5
- * @param message Error message when timeout occurs
6
- * @returns Promise that rejects if timeout is reached
7
- */
8
- export function withTimeout<T>(promise: Promise<T>, timeoutMs: number, message: string): Promise<T> {
9
- return Promise.race([promise, new Promise<never>((_, reject) => setTimeout(() => reject(new Error(message)), timeoutMs))]);
10
- }
1
+ /**
2
+ * Utility function to add timeout to a promise
3
+ * @param promise The promise to add timeout to
4
+ * @param timeoutMs Timeout in milliseconds
5
+ * @param message Error message when timeout occurs
6
+ * @returns Promise that rejects if timeout is reached
7
+ */
8
+ export function withTimeout<T>(promise: Promise<T>, timeoutMs: number, message: string): Promise<T> {
9
+ return Promise.race([promise, new Promise<never>((_, reject) => setTimeout(() => reject(new Error(message)), timeoutMs))]);
10
+ }
package/tsconfig.json CHANGED
@@ -1,23 +1,22 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2021",
4
- "module": "commonjs",
5
- "lib": ["ES2021"],
6
- "outDir": "./dist",
7
- "rootDir": "./src",
8
- "strict": true,
9
- "esModuleInterop": true,
10
- "skipLibCheck": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "declaration": true,
13
- "declarationMap": true,
14
- "sourceMap": true,
15
- "moduleResolution": "node",
16
- "allowSyntheticDefaultImports": true,
17
- "experimentalDecorators": true,
18
- "emitDecoratorMetadata": true,
19
- "resolveJsonModule": true
20
- },
21
- "include": ["src/**/*"],
22
- "exclude": ["node_modules", "dist", "examples"]
23
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2021",
4
+ "module": "commonjs",
5
+ "lib": ["ES2021"],
6
+ "outDir": "./dist",
7
+ "rootDir": "./src",
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "skipLibCheck": true,
11
+ "forceConsistentCasingInFileNames": true,
12
+ "declaration": true,
13
+ "declarationMap": true,
14
+ "sourceMap": true,
15
+ "allowSyntheticDefaultImports": true,
16
+ "experimentalDecorators": true,
17
+ "emitDecoratorMetadata": true,
18
+ "resolveJsonModule": true
19
+ },
20
+ "include": ["src/**/*"],
21
+ "exclude": ["node_modules", "dist", "examples"]
22
+ }