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.
Files changed (40) hide show
  1. package/dist/extensions/index.d.ts +1 -0
  2. package/dist/extensions/index.d.ts.map +1 -1
  3. package/dist/extensions/index.js +9 -1
  4. package/dist/extensions/index.js.map +1 -1
  5. package/dist/plugins/index.d.ts.map +1 -1
  6. package/dist/plugins/index.js +106 -61
  7. package/dist/plugins/index.js.map +1 -1
  8. package/dist/structures/FilterManager.d.ts +1 -0
  9. package/dist/structures/FilterManager.d.ts.map +1 -1
  10. package/dist/structures/FilterManager.js +76 -10
  11. package/dist/structures/FilterManager.js.map +1 -1
  12. package/dist/structures/Player.d.ts +1 -1
  13. package/dist/structures/Player.d.ts.map +1 -1
  14. package/dist/structures/Player.js +45 -20
  15. package/dist/structures/Player.js.map +1 -1
  16. package/dist/structures/PlayerManager.d.ts +12 -7
  17. package/dist/structures/PlayerManager.d.ts.map +1 -1
  18. package/dist/structures/PlayerManager.js +113 -79
  19. package/dist/structures/PlayerManager.js.map +1 -1
  20. package/dist/structures/PreloadManager.d.ts.map +1 -1
  21. package/dist/structures/PreloadManager.js +11 -8
  22. package/dist/structures/PreloadManager.js.map +1 -1
  23. package/dist/structures/Queue.js +2 -2
  24. package/dist/structures/Queue.js.map +1 -1
  25. package/dist/types/index.d.ts +4 -2
  26. package/dist/types/index.d.ts.map +1 -1
  27. package/dist/types/index.js.map +1 -1
  28. package/dist/utils/timeout.d.ts.map +1 -1
  29. package/dist/utils/timeout.js +8 -1
  30. package/dist/utils/timeout.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/extensions/index.ts +9 -1
  33. package/src/plugins/index.ts +1027 -975
  34. package/src/structures/FilterManager.ts +88 -12
  35. package/src/structures/Player.ts +58 -28
  36. package/src/structures/PlayerManager.ts +125 -84
  37. package/src/structures/PreloadManager.ts +12 -8
  38. package/src/structures/Queue.ts +2 -2
  39. package/src/types/index.ts +5 -2
  40. 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 = this.streamManager.registerStream(streamInfo.stream, track, {
247
- source: track.source || "preload",
248
- isPreload: true,
249
- priority: 5,
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);
@@ -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 → restore current from history
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
- this.current = this.history.pop() || null;
236
+ return null;
237
237
  }
238
238
 
239
239
  return this.current;
@@ -124,8 +124,9 @@ export interface SearchScore {
124
124
  * };
125
125
  */
126
126
  export interface StreamInfo {
127
- stream: Readable;
128
- type: "webm/opus" | "ogg/opus" | "arbitrary" | string;
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;
@@ -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
- return Promise.race([promise, new Promise<never>((_, reject) => setTimeout(() => reject(new Error(message)), timeoutMs))]);
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
  }