ziplayer 0.2.7-dev.3 → 0.3.0
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 +624 -607
- package/README.md +526 -524
- package/dist/plugins/index.d.ts +62 -12
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +497 -57
- package/dist/plugins/index.js.map +1 -1
- package/dist/structures/PersistenceManager.d.ts +96 -0
- package/dist/structures/PersistenceManager.d.ts.map +1 -0
- package/dist/structures/PersistenceManager.js +1008 -0
- package/dist/structures/PersistenceManager.js.map +1 -0
- package/dist/structures/Player.d.ts +109 -18
- package/dist/structures/Player.d.ts.map +1 -1
- package/dist/structures/Player.js +902 -182
- package/dist/structures/Player.js.map +1 -1
- package/dist/structures/PlayerManager.d.ts +1 -22
- package/dist/structures/PlayerManager.d.ts.map +1 -1
- package/dist/structures/PlayerManager.js +1 -73
- package/dist/structures/PlayerManager.js.map +1 -1
- package/dist/structures/StreamManager.d.ts +137 -0
- package/dist/structures/StreamManager.d.ts.map +1 -0
- package/dist/structures/StreamManager.js +420 -0
- package/dist/structures/StreamManager.js.map +1 -0
- package/dist/types/index.d.ts +149 -16
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/persistence.d.ts +3 -2
- package/dist/types/persistence.d.ts.map +1 -1
- package/package.json +47 -47
- package/src/extensions/BaseExtension.ts +36 -36
- package/src/extensions/index.ts +473 -473
- package/src/index.ts +16 -16
- package/src/plugins/BasePlugin.ts +27 -27
- package/src/plugins/index.ts +950 -403
- package/src/structures/FilterManager.ts +303 -303
- package/src/structures/Player.ts +2797 -1970
- package/src/structures/PlayerManager.ts +725 -822
- package/src/structures/Queue.ts +599 -599
- package/src/structures/StreamManager.ts +524 -0
- package/src/types/extension.ts +129 -129
- package/src/types/fillter.ts +264 -264
- package/src/types/index.ts +548 -415
- package/src/types/plugin.ts +59 -59
- package/src/utils/timeout.ts +10 -10
- package/tsconfig.json +22 -22
- package/src/persistence/PersistenceManager.ts +0 -1077
- package/src/types/persistence.ts +0 -85
package/src/types/plugin.ts
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
import type { SearchResult, StreamInfo, Track } from ".";
|
|
2
|
-
/**
|
|
3
|
-
* Plugin interface
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* const plugin: SourcePlugin = {
|
|
7
|
-
* name: "YouTube",
|
|
8
|
-
* version: "1.0.0"
|
|
9
|
-
* priority: 0, // Optional, default is 0. Lower priority plugins are tried first in getStream fallback.
|
|
10
|
-
* };
|
|
11
|
-
*/
|
|
12
|
-
export interface SourcePlugin {
|
|
13
|
-
name: string;
|
|
14
|
-
version: string;
|
|
15
|
-
priority?: number; // Higher = run first, default is 0. Lower priority plugins are tried first in getStream fallback.
|
|
16
|
-
canHandle(query: string): boolean;
|
|
17
|
-
search(query: string, requestedBy: string): Promise<SearchResult>;
|
|
18
|
-
getStream(track: Track): Promise<StreamInfo>;
|
|
19
|
-
getRelatedTracks?(track: Track, opts?: { limit?: number; offset?: number }): Promise<Track[]>;
|
|
20
|
-
validate?(url: string): boolean;
|
|
21
|
-
extractPlaylist?(url: string, requestedBy: string): Promise<Track[]>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Constructor for a SourcePlugin
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* const plugin = new YouTubePlugin();
|
|
29
|
-
* console.log(`Plugin: ${plugin.name}`);
|
|
30
|
-
*/
|
|
31
|
-
export type SourcePluginCtor<T extends SourcePlugin = SourcePlugin> = new (...args: any[]) => T;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* SourcePlugin or SourcePluginCtor
|
|
35
|
-
*
|
|
36
|
-
* @example
|
|
37
|
-
* const plugin = new YouTubePlugin();
|
|
38
|
-
* console.log(`Plugin: ${plugin.name}`);
|
|
39
|
-
*/
|
|
40
|
-
export type SourcePluginLike = SourcePlugin | SourcePluginCtor;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Configuration options for creating a PlayerManager instance.
|
|
44
|
-
*
|
|
45
|
-
* @example
|
|
46
|
-
* const managerOptions: PlayerManagerOptions = {
|
|
47
|
-
* plugins: [
|
|
48
|
-
* new YouTubePlugin(),
|
|
49
|
-
* new SoundCloudPlugin(),
|
|
50
|
-
* new SpotifyPlugin(),
|
|
51
|
-
* new TTSPlugin({ defaultLang: "en" })
|
|
52
|
-
* ],
|
|
53
|
-
* extensions: [
|
|
54
|
-
* new voiceExt(null, { lang: "en-US" }),
|
|
55
|
-
* new lavalinkExt(null, { nodes: [...] })
|
|
56
|
-
* ],
|
|
57
|
-
* extractorTimeout: 10000
|
|
58
|
-
* };
|
|
59
|
-
*/
|
|
1
|
+
import type { SearchResult, StreamInfo, Track } from ".";
|
|
2
|
+
/**
|
|
3
|
+
* Plugin interface
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* const plugin: SourcePlugin = {
|
|
7
|
+
* name: "YouTube",
|
|
8
|
+
* version: "1.0.0"
|
|
9
|
+
* priority: 0, // Optional, default is 0. Lower priority plugins are tried first in getStream fallback.
|
|
10
|
+
* };
|
|
11
|
+
*/
|
|
12
|
+
export interface SourcePlugin {
|
|
13
|
+
name: string;
|
|
14
|
+
version: string;
|
|
15
|
+
priority?: number; // Higher = run first, default is 0. Lower priority plugins are tried first in getStream fallback.
|
|
16
|
+
canHandle(query: string): boolean;
|
|
17
|
+
search(query: string, requestedBy: string): Promise<SearchResult>;
|
|
18
|
+
getStream(track: Track): Promise<StreamInfo>;
|
|
19
|
+
getRelatedTracks?(track: Track, opts?: { limit?: number; offset?: number }): Promise<Track[]>;
|
|
20
|
+
validate?(url: string): boolean;
|
|
21
|
+
extractPlaylist?(url: string, requestedBy: string): Promise<Track[]>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Constructor for a SourcePlugin
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* const plugin = new YouTubePlugin();
|
|
29
|
+
* console.log(`Plugin: ${plugin.name}`);
|
|
30
|
+
*/
|
|
31
|
+
export type SourcePluginCtor<T extends SourcePlugin = SourcePlugin> = new (...args: any[]) => T;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* SourcePlugin or SourcePluginCtor
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* const plugin = new YouTubePlugin();
|
|
38
|
+
* console.log(`Plugin: ${plugin.name}`);
|
|
39
|
+
*/
|
|
40
|
+
export type SourcePluginLike = SourcePlugin | SourcePluginCtor;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Configuration options for creating a PlayerManager instance.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* const managerOptions: PlayerManagerOptions = {
|
|
47
|
+
* plugins: [
|
|
48
|
+
* new YouTubePlugin(),
|
|
49
|
+
* new SoundCloudPlugin(),
|
|
50
|
+
* new SpotifyPlugin(),
|
|
51
|
+
* new TTSPlugin({ defaultLang: "en" })
|
|
52
|
+
* ],
|
|
53
|
+
* extensions: [
|
|
54
|
+
* new voiceExt(null, { lang: "en-US" }),
|
|
55
|
+
* new lavalinkExt(null, { nodes: [...] })
|
|
56
|
+
* ],
|
|
57
|
+
* extractorTimeout: 10000
|
|
58
|
+
* };
|
|
59
|
+
*/
|
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,22 +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
|
-
"allowSyntheticDefaultImports": true,
|
|
16
|
-
"experimentalDecorators": true,
|
|
17
|
-
"emitDecoratorMetadata": true,
|
|
18
|
-
"resolveJsonModule": true
|
|
19
|
-
},
|
|
20
|
-
"include": ["src/**/*"],
|
|
21
|
-
"exclude": ["node_modules", "dist", "examples"]
|
|
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
|
+
"allowSyntheticDefaultImports": true,
|
|
16
|
+
"experimentalDecorators": true,
|
|
17
|
+
"emitDecoratorMetadata": true,
|
|
18
|
+
"resolveJsonModule": true
|
|
19
|
+
},
|
|
20
|
+
"include": ["src/**/*"],
|
|
21
|
+
"exclude": ["node_modules", "dist", "examples"]
|
|
22
|
+
}
|