ziplayer 0.3.10 → 0.3.12-dev.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/dist/extensions/index.d.ts +1 -0
- package/dist/extensions/index.d.ts.map +1 -1
- package/dist/extensions/index.js +9 -1
- package/dist/extensions/index.js.map +1 -1
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +106 -61
- package/dist/plugins/index.js.map +1 -1
- package/dist/structures/FilterManager.d.ts +1 -0
- package/dist/structures/FilterManager.d.ts.map +1 -1
- package/dist/structures/FilterManager.js +76 -10
- package/dist/structures/FilterManager.js.map +1 -1
- package/dist/structures/Player.d.ts +1 -1
- package/dist/structures/Player.d.ts.map +1 -1
- package/dist/structures/Player.js +45 -20
- package/dist/structures/Player.js.map +1 -1
- package/dist/structures/PlayerManager.d.ts +12 -7
- package/dist/structures/PlayerManager.d.ts.map +1 -1
- package/dist/structures/PlayerManager.js +113 -79
- package/dist/structures/PlayerManager.js.map +1 -1
- package/dist/structures/PreloadManager.d.ts.map +1 -1
- package/dist/structures/PreloadManager.js +11 -8
- package/dist/structures/PreloadManager.js.map +1 -1
- package/dist/structures/Queue.js +2 -2
- package/dist/structures/Queue.js.map +1 -1
- package/dist/types/index.d.ts +4 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utils/timeout.d.ts.map +1 -1
- package/dist/utils/timeout.js +8 -1
- package/dist/utils/timeout.js.map +1 -1
- package/package.json +1 -1
- package/src/extensions/index.ts +9 -1
- package/src/plugins/index.ts +1027 -975
- package/src/structures/FilterManager.ts +88 -12
- package/src/structures/Player.ts +58 -28
- package/src/structures/PlayerManager.ts +125 -84
- package/src/structures/PreloadManager.ts +12 -8
- package/src/structures/Queue.ts +2 -2
- package/src/types/index.ts +5 -2
- package/src/utils/timeout.ts +8 -1
|
@@ -24,6 +24,7 @@ export class PreloadManager {
|
|
|
24
24
|
resource: null,
|
|
25
25
|
track: null,
|
|
26
26
|
streamId: null,
|
|
27
|
+
processedStreamId: null,
|
|
27
28
|
abortController: null,
|
|
28
29
|
isValid: false,
|
|
29
30
|
isLoading: false,
|
|
@@ -239,17 +240,20 @@ export class PreloadManager {
|
|
|
239
240
|
this.debugLog(`[Preload] Track changed after stream fetch`);
|
|
240
241
|
throw new Error("PRELOAD_CANCELLED");
|
|
241
242
|
}
|
|
242
|
-
if (!streamInfo?.stream) {
|
|
243
|
+
if (!streamInfo?.stream && !streamInfo?.url) {
|
|
243
244
|
throw new Error(`No stream available`);
|
|
244
245
|
}
|
|
245
246
|
|
|
246
|
-
const streamId =
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
247
|
+
const streamId =
|
|
248
|
+
streamInfo.stream ?
|
|
249
|
+
this.streamManager.registerStream(streamInfo.stream, track, {
|
|
250
|
+
source: track.source || "preload",
|
|
251
|
+
isPreload: true,
|
|
252
|
+
priority: 5,
|
|
253
|
+
})
|
|
254
|
+
: null;
|
|
251
255
|
|
|
252
|
-
const resource = createAudioResource(streamInfo.stream
|
|
256
|
+
const resource = createAudioResource(streamInfo.stream || streamInfo.url!, {
|
|
253
257
|
inlineVolume: true,
|
|
254
258
|
metadata: { ...track, preloaded: true },
|
|
255
259
|
});
|
|
@@ -277,7 +281,7 @@ export class PreloadManager {
|
|
|
277
281
|
signal.removeEventListener("abort", handler);
|
|
278
282
|
reject(new Error("PRELOAD_CANCELLED"));
|
|
279
283
|
};
|
|
280
|
-
signal.addEventListener("abort", handler);
|
|
284
|
+
signal.addEventListener("abort", handler, { once: true });
|
|
281
285
|
});
|
|
282
286
|
|
|
283
287
|
const existingStream = this.streamManager.getStreamByTrack(track.id || track.title);
|
package/src/structures/Queue.ts
CHANGED
|
@@ -231,9 +231,9 @@ export class Queue {
|
|
|
231
231
|
this.current = this.tracks.shift() || null;
|
|
232
232
|
}
|
|
233
233
|
|
|
234
|
-
// Skip bypassed track loop but no other track exists →
|
|
234
|
+
// Skip bypassed track loop but no other track exists → trigger queue end
|
|
235
235
|
if (!this.current && this._loop === "track" && ignoreLoop && this.history.length > 0) {
|
|
236
|
-
|
|
236
|
+
return null;
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
return this.current;
|
package/src/types/index.ts
CHANGED
|
@@ -124,8 +124,9 @@ export interface SearchScore {
|
|
|
124
124
|
* };
|
|
125
125
|
*/
|
|
126
126
|
export interface StreamInfo {
|
|
127
|
-
stream
|
|
128
|
-
|
|
127
|
+
stream?: Readable;
|
|
128
|
+
url?: string;
|
|
129
|
+
type: "webm/opus" | "ogg/opus" | "arbitrary" | "url" | string;
|
|
129
130
|
metadata?: Record<string, any>;
|
|
130
131
|
position?: number;
|
|
131
132
|
recreate?: (position: number) => Promise<Readable>;
|
|
@@ -419,6 +420,7 @@ export interface SaveOptions {
|
|
|
419
420
|
/** Seek position in milliseconds to start saving from */
|
|
420
421
|
seek?: number;
|
|
421
422
|
}
|
|
423
|
+
|
|
422
424
|
export interface PlayerSession {
|
|
423
425
|
guildId: string;
|
|
424
426
|
queue: Track[];
|
|
@@ -470,6 +472,7 @@ export interface StreamSlot {
|
|
|
470
472
|
resource: AudioResource | null;
|
|
471
473
|
track: Track | null;
|
|
472
474
|
streamId: string | null;
|
|
475
|
+
processedStreamId: string | null;
|
|
473
476
|
abortController: AbortController | null;
|
|
474
477
|
isValid: boolean;
|
|
475
478
|
isLoading: boolean;
|
package/src/utils/timeout.ts
CHANGED
|
@@ -6,5 +6,12 @@
|
|
|
6
6
|
* @returns Promise that rejects if timeout is reached
|
|
7
7
|
*/
|
|
8
8
|
export function withTimeout<T>(promise: Promise<T>, timeoutMs: number, message: string): Promise<T> {
|
|
9
|
-
|
|
9
|
+
let timeoutId: NodeJS.Timeout;
|
|
10
|
+
const timeoutPromise = new Promise<never>((_, reject) => {
|
|
11
|
+
timeoutId = setTimeout(() => reject(new Error(message)), timeoutMs);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
return Promise.race([promise, timeoutPromise]).finally(() => {
|
|
15
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
16
|
+
});
|
|
10
17
|
}
|