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.
- package/AI-Guide.md +607 -0
- package/README.md +513 -196
- package/dist/extensions/BaseExtension.d.ts +1 -0
- package/dist/extensions/BaseExtension.d.ts.map +1 -1
- package/dist/extensions/BaseExtension.js.map +1 -1
- package/dist/extensions/index.d.ts +38 -3
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +259 -41
- package/dist/extensions/index.js.map +1 -1
- package/dist/persistence/PersistenceManager.d.ts +61 -0
- package/dist/persistence/PersistenceManager.d.ts.map +1 -0
- package/dist/persistence/PersistenceManager.js +551 -0
- package/dist/persistence/PersistenceManager.js.map +1 -0
- package/dist/plugins/BasePlugin.js +1 -1
- package/dist/plugins/BasePlugin.js.map +1 -1
- package/dist/plugins/index.d.ts +19 -4
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +273 -146
- package/dist/plugins/index.js.map +1 -1
- package/dist/structures/FilterManager.js +3 -3
- package/dist/structures/FilterManager.js.map +1 -1
- package/dist/structures/Player.d.ts +64 -14
- package/dist/structures/Player.d.ts.map +1 -1
- package/dist/structures/Player.js +344 -91
- package/dist/structures/Player.js.map +1 -1
- package/dist/structures/PlayerManager.d.ts +125 -91
- package/dist/structures/PlayerManager.d.ts.map +1 -1
- package/dist/structures/PlayerManager.js +406 -111
- package/dist/structures/PlayerManager.js.map +1 -1
- package/dist/structures/Queue.d.ts +136 -31
- package/dist/structures/Queue.d.ts.map +1 -1
- package/dist/structures/Queue.js +265 -46
- package/dist/structures/Queue.js.map +1 -1
- package/dist/types/index.d.ts +39 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/persistence.d.ts +55 -0
- package/dist/types/persistence.d.ts.map +1 -0
- package/dist/types/persistence.js +3 -0
- package/dist/types/persistence.js.map +1 -0
- package/package.json +47 -46
- package/src/extensions/BaseExtension.ts +36 -35
- package/src/extensions/index.ts +473 -190
- package/src/index.ts +16 -16
- package/src/persistence/PersistenceManager.ts +572 -0
- package/src/plugins/BasePlugin.ts +27 -27
- package/src/plugins/index.ts +403 -236
- package/src/structures/FilterManager.ts +303 -303
- package/src/structures/Player.ts +1962 -1689
- package/src/structures/PlayerManager.ts +788 -416
- package/src/structures/Queue.ts +599 -354
- package/src/types/index.ts +406 -373
- package/src/types/persistence.ts +65 -0
- package/src/types/plugin.ts +1 -1
- package/src/utils/timeout.ts +10 -10
- 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
|
+
}
|
package/src/types/plugin.ts
CHANGED
|
@@ -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>;
|
package/src/utils/timeout.ts
CHANGED
|
@@ -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
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"
|
|
22
|
-
|
|
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
|
+
}
|