audio-channel-queue 1.10.0 → 1.12.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/README.md CHANGED
@@ -75,8 +75,8 @@ Install this package by running either of these commands (typescript packages ar
75
75
  ```typescript
76
76
  // Add an audio file to the queue and start playing it automatically.
77
77
  queueAudio(audioUrl, channelNumber?, options?);
78
- queueAudio('hello.mp3'); // Add to default channel 0
79
- queueAudio('laser.mp3', 1, { loop: true, volume: 0.8 }); // Add to channel 1 with options
78
+ await queueAudio('hello.mp3'); // Add to default channel 0
79
+ await queueAudio('laser.mp3', 1, { loop: true, volume: 0.8 }); // Add to channel 1 with options
80
80
  ```
81
81
 
82
82
 
@@ -84,8 +84,8 @@ queueAudio('laser.mp3', 1, { loop: true, volume: 0.8 }); // Add to channel 1 wit
84
84
  ```typescript
85
85
  // Add a file to the front of the queue (plays after current audio finishes).
86
86
  queueAudioPriority(audioUrl, channelNumber?, options?);
87
- queueAudioPriority('urgent.mp3'); // Add to front of default channel 0
88
- queueAudioPriority('announcement.mp3', 1, { volume: 1.0 }); // Add to front of channel 1
87
+ await queueAudioPriority('urgent.mp3'); // Add to front of default channel 0
88
+ await queueAudioPriority('announcement.mp3', 1, { volume: 1.0 }); // Add to front of channel 1
89
89
  ```
90
90
 
91
91
 
@@ -93,8 +93,8 @@ queueAudioPriority('announcement.mp3', 1, { volume: 1.0 }); // Add to front of c
93
93
  ```typescript
94
94
  // Stop the current audio and automatically start playing the next one in queue.
95
95
  stopCurrentAudioInChannel(channelNumber?);
96
- stopCurrentAudioInChannel(); // Stop current audio in default channel (0)
97
- stopCurrentAudioInChannel(2); // Stop current audio in channel 2
96
+ await stopCurrentAudioInChannel(); // Stop current audio in default channel (0)
97
+ await stopCurrentAudioInChannel(2); // Stop current audio in channel 2
98
98
  ```
99
99
 
100
100
 
@@ -102,14 +102,14 @@ stopCurrentAudioInChannel(2); // Stop current audio in channel 2
102
102
  ```typescript
103
103
  // Stop all audio in a channel and remove all enqueued files.
104
104
  stopAllAudioInChannel(channelNumber?);
105
- stopAllAudioInChannel(); // Stop and clear all audio in default channel (0)
106
- stopAllAudioInChannel(1); // Stop and clear all audio in channel 1
105
+ await stopAllAudioInChannel(); // Stop and clear all audio in default channel (0)
106
+ await stopAllAudioInChannel(1); // Stop and clear all audio in channel 1
107
107
  ```
108
108
 
109
109
  ### Stop All Audio
110
110
  ```typescript
111
111
  // Stop all audio in all channels and remove all enqueued files.
112
- stopAllAudio();
112
+ await stopAllAudio();
113
113
  ```
114
114
 
115
115
  ## 🔄 Advanced Queue Manipulation:
@@ -118,32 +118,32 @@ stopAllAudio();
118
118
  ```typescript
119
119
  // Remove a specific item from the queue by its position (cannot remove currently playing item at index 0).
120
120
  removeQueuedItem(queuedSlotNumber, channelNumber?);
121
- const result = removeQueuedItem(2); // Remove item at index 2 from default channel (0)
122
- const result = removeQueuedItem(1, 1); // Remove item at index 1 from channel 1
121
+ const result = await removeQueuedItem(2); // Remove item at index 2 from default channel (0)
122
+ const result = await removeQueuedItem(1, 1); // Remove item at index 1 from channel 1
123
123
  ```
124
124
 
125
125
  ### Reorder Queue Items
126
126
  ```typescript
127
127
  // Move a queue item from one position to another (cannot move currently playing item at index 0).
128
128
  reorderQueue(currentQueuedSlotNumber, newQueuedSlotNumber, channelNumber?);
129
- const result = reorderQueue(3, 1); // Move item from index 3 to index 1 in default channel (0)
130
- const result = reorderQueue(2, 4, 1); // Move item from index 2 to index 4 in channel 1
129
+ const result = await reorderQueue(3, 1); // Move item from index 3 to index 1 in default channel (0)
130
+ const result = await reorderQueue(2, 4, 1); // Move item from index 2 to index 4 in channel 1
131
131
  ```
132
132
 
133
133
  ### Clear Queue After Current
134
134
  ```typescript
135
135
  // Remove all items from the queue except the currently playing audio.
136
136
  clearQueueAfterCurrent(channelNumber?);
137
- const result = clearQueueAfterCurrent(); // Clear queue after current in default channel (0)
138
- const result = clearQueueAfterCurrent(2); // Clear queue after current in channel 2
137
+ const result = await clearQueueAfterCurrent(); // Clear queue after current in default channel (0)
138
+ const result = await clearQueueAfterCurrent(2); // Clear queue after current in channel 2
139
139
  ```
140
140
 
141
141
  ### Swap Queue Items
142
142
  ```typescript
143
143
  // Swap the positions of two items in the queue (cannot involve currently playing item at index 0).
144
144
  swapQueueItems(firstQueuedSlotNumber, secondQueuedSlotNumber, channelNumber?);
145
- const result = swapQueueItems(1, 3); // Swap items at index 1 and 3 in default channel (0)
146
- const result = swapQueueItems(2, 4, 1); // Swap items at index 2 and 4 in channel 1
145
+ const result = await swapQueueItems(1, 3); // Swap items at index 1 and 3 in default channel (0)
146
+ const result = await swapQueueItems(2, 4, 1); // Swap items at index 2 and 4 in channel 1
147
147
  ```
148
148
 
149
149
  ### Get Queue Item Info
@@ -177,8 +177,8 @@ interface QueueManipulationResult {
177
177
  ```typescript
178
178
  // Set the volume for a specific channel (0-1 range).
179
179
  setChannelVolume(channelNumber, volume);
180
- setChannelVolume(0, 0.5); // Set channel 0 to 50% volume
181
- setChannelVolume(1, 0.8); // Set channel 1 to 80% volume
180
+ await setChannelVolume(0, 0.5); // Set channel 0 to 50% volume
181
+ await setChannelVolume(1, 0.8); // Set channel 1 to 80% volume
182
182
  ```
183
183
 
184
184
  ### Get Channel Volume
@@ -193,8 +193,8 @@ console.log(`Channel volume: ${(getChannelVolume(2) * 100).toFixed(0)}%`); // Ge
193
193
  ```typescript
194
194
  // Set the same volume level for all channels.
195
195
  setAllChannelsVolume(volume);
196
- setAllChannelsVolume(0.6); // Set all channels to 60% volume
197
- setAllChannelsVolume(0.0); // Mute all channels
196
+ await setAllChannelsVolume(0.6); // Set all channels to 60% volume
197
+ await setAllChannelsVolume(0.0); // Mute all channels
198
198
  ```
199
199
 
200
200
  ### Volume Ducking (Background Audio Reduction)
@@ -356,30 +356,65 @@ onQueueChange(channelNumber, callback);
356
356
  onQueueChange(0, (snapshot) => updateQueueDisplay(snapshot)); // Update UI on queue changes
357
357
  ```
358
358
 
359
+ ```typescript
360
+ // Unsubscribe from queue change events (removes ALL queue change callbacks for the channel)
361
+ offQueueChange(channelNumber?);
362
+ offQueueChange(); // Stop receiving all queue change notifications for default channel (0)
363
+ offQueueChange(1); // Stop receiving all queue change notifications for channel 1
364
+ ```
365
+
359
366
  ```typescript
360
367
  // Subscribe to audio start events.
361
368
  onAudioStart(channelNumber, callback);
362
369
  onAudioStart(0, (info) => console.log(`Started: ${info.fileName}`)); // Log audio starts
363
370
  ```
364
371
 
372
+ ```typescript
373
+ // Unsubscribe from audio start events (removes ALL start callbacks for the channel)
374
+ offAudioStart(channelNumber?);
375
+ offAudioStart(); // Stop receiving all start notifications for default channel (0)
376
+ offAudioStart(1); // Stop receiving all start notifications for channel 1
377
+ ```
378
+
365
379
  ```typescript
366
380
  // Subscribe to audio completion events.
367
381
  onAudioComplete(channelNumber, callback);
368
382
  onAudioComplete(0, (info) => logPlayHistory(info)); // Track completed audio
369
383
  ```
370
384
 
385
+ ```typescript
386
+ // Unsubscribe from audio completion events (removes ALL complete callbacks for the channel)
387
+ offAudioComplete(channelNumber?);
388
+ offAudioComplete(); // Stop receiving all completion notifications for default channel (0)
389
+ offAudioComplete(1); // Stop receiving all completion notifications for channel 1
390
+ ```
391
+
371
392
  ```typescript
372
393
  // Subscribe to audio pause events.
373
394
  onAudioPause(channelNumber, callback);
374
395
  onAudioPause(0, (info) => showPauseIcon(info)); // Show pause state in UI
375
396
  ```
376
397
 
398
+ ```typescript
399
+ // Unsubscribe from audio pause events (removes ALL pause callbacks for the channel)
400
+ offAudioPause(channelNumber?);
401
+ offAudioPause(); // Stop receiving all pause notifications for default channel (0)
402
+ offAudioPause(1); // Stop receiving all pause notifications for channel 1
403
+ ```
404
+
377
405
  ```typescript
378
406
  // Subscribe to audio resume events.
379
407
  onAudioResume(channelNumber, callback);
380
408
  onAudioResume(0, (info) => showPlayIcon(info)); // Show play state in UI
381
409
  ```
382
410
 
411
+ ```typescript
412
+ // Unsubscribe from audio resume events (removes ALL resume callbacks for the channel)
413
+ offAudioResume(channelNumber?);
414
+ offAudioResume(); // Stop receiving all resume notifications for default channel (0)
415
+ offAudioResume(1); // Stop receiving all resume notifications for channel 1
416
+ ```
417
+
383
418
  ### TypeScript Support
384
419
  If you cannot import audio files into your app, you may need a `custom.d.ts` file in the root directory. An example of one is shown here:
385
420
 
package/dist/core.d.ts CHANGED
@@ -73,10 +73,10 @@ export declare const queueAudioPriority: (audioUrl: string, channelNumber?: numb
73
73
  /**
74
74
  * Plays the audio queue for a specific channel
75
75
  * @param channelNumber - The channel number to play
76
- * @returns Promise that resolves when the current audio finishes playing
76
+ * @returns Promise that resolves when the audio starts playing (setup complete)
77
77
  * @example
78
78
  * ```typescript
79
- * await playAudioQueue(0); // Play queue for channel 0
79
+ * await playAudioQueue(0); // Start playing queue for channel 0
80
80
  * ```
81
81
  */
82
82
  export declare const playAudioQueue: (channelNumber: number) => Promise<void>;
package/dist/core.js CHANGED
@@ -260,9 +260,9 @@ const queueAudio = (audioUrl_1, ...args_1) => __awaiter(void 0, [audioUrl_1, ...
260
260
  channel.maxQueueSize = options.maxQueueSize;
261
261
  }
262
262
  }
263
- // Handle priority option (same as addToFront for backward compatibility)
264
- const shouldAddToFront = (options === null || options === void 0 ? void 0 : options.addToFront) || (options === null || options === void 0 ? void 0 : options.priority);
265
- // Add to queue based on priority/addToFront option
263
+ // Handle addToFront option
264
+ const shouldAddToFront = options === null || options === void 0 ? void 0 : options.addToFront;
265
+ // Add to queue based on addToFront option
266
266
  if (shouldAddToFront && channel.queue.length > 0) {
267
267
  // Insert after currently playing track (at index 1)
268
268
  channel.queue.splice(1, 0, audio);
@@ -279,12 +279,8 @@ const queueAudio = (audioUrl_1, ...args_1) => __awaiter(void 0, [audioUrl_1, ...
279
279
  (0, events_1.emitQueueChange)(channelNumber, info_1.audioChannels);
280
280
  // Start playing if this is the first item and channel isn't paused
281
281
  if (channel.queue.length === 1 && !channel.isPaused) {
282
- // Use setTimeout to ensure the queue change event is emitted first
283
- setTimeout(() => {
284
- (0, exports.playAudioQueue)(channelNumber).catch((error) => {
285
- (0, errors_1.handleAudioError)(audio, channelNumber, validatedUrl, error);
286
- });
287
- }, 0);
282
+ // Await the audio setup to complete before resolving queueAudio
283
+ yield (0, exports.playAudioQueue)(channelNumber);
288
284
  }
289
285
  });
290
286
  exports.queueAudio = queueAudio;
@@ -309,10 +305,10 @@ exports.queueAudioPriority = queueAudioPriority;
309
305
  /**
310
306
  * Plays the audio queue for a specific channel
311
307
  * @param channelNumber - The channel number to play
312
- * @returns Promise that resolves when the current audio finishes playing
308
+ * @returns Promise that resolves when the audio starts playing (setup complete)
313
309
  * @example
314
310
  * ```typescript
315
- * await playAudioQueue(0); // Play queue for channel 0
311
+ * await playAudioQueue(0); // Start playing queue for channel 0
316
312
  * ```
317
313
  */
318
314
  const playAudioQueue = (channelNumber) => __awaiter(void 0, void 0, void 0, function* () {
@@ -331,6 +327,7 @@ const playAudioQueue = (channelNumber) => __awaiter(void 0, void 0, void 0, func
331
327
  let hasStarted = false;
332
328
  let metadataLoaded = false;
333
329
  let playStarted = false;
330
+ let setupComplete = false;
334
331
  // Check if we should fire onAudioStart (both conditions met)
335
332
  const tryFireAudioStart = () => {
336
333
  if (!hasStarted && metadataLoaded && playStarted) {
@@ -341,6 +338,11 @@ const playAudioQueue = (channelNumber) => __awaiter(void 0, void 0, void 0, func
341
338
  fileName: (0, utils_1.extractFileName)(currentAudio.src),
342
339
  src: currentAudio.src
343
340
  }, info_1.audioChannels);
341
+ // Resolve setup promise when audio start event is fired
342
+ if (!setupComplete) {
343
+ setupComplete = true;
344
+ resolve();
345
+ }
344
346
  }
345
347
  };
346
348
  // Event handler for when metadata loads (duration becomes available)
@@ -371,7 +373,6 @@ const playAudioQueue = (channelNumber) => __awaiter(void 0, void 0, void 0, func
371
373
  catch (error) {
372
374
  yield (0, errors_1.handleAudioError)(currentAudio, channelNumber, currentAudio.src, error);
373
375
  }
374
- resolve();
375
376
  }
376
377
  else {
377
378
  // For non-looping audio, remove from queue and play next
@@ -384,7 +385,6 @@ const playAudioQueue = (channelNumber) => __awaiter(void 0, void 0, void 0, func
384
385
  (0, events_1.emitQueueChange)(channelNumber, info_1.audioChannels);
385
386
  // Play next audio immediately if there's more in queue
386
387
  yield (0, exports.playAudioQueue)(channelNumber);
387
- resolve();
388
388
  }
389
389
  });
390
390
  // Add event listeners
@@ -398,7 +398,10 @@ const playAudioQueue = (channelNumber) => __awaiter(void 0, void 0, void 0, func
398
398
  // Enhanced play with error handling
399
399
  currentAudio.play().catch((error) => __awaiter(void 0, void 0, void 0, function* () {
400
400
  yield (0, errors_1.handleAudioError)(currentAudio, channelNumber, currentAudio.src, error);
401
- resolve(); // Resolve to prevent hanging
401
+ if (!setupComplete) {
402
+ setupComplete = true;
403
+ resolve(); // Resolve gracefully instead of rejecting
404
+ }
402
405
  }));
403
406
  });
404
407
  });
package/dist/errors.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @fileoverview Error handling, retry logic, and recovery mechanisms for the audio-channel-queue package
3
3
  */
4
- import { AudioErrorInfo, AudioErrorCallback, RetryConfig, ErrorRecoveryOptions, ExtendedAudioQueueChannel } from './types';
4
+ import { AudioErrorInfo, AudioErrorCallback, AudioErrorType, RetryConfig, ErrorRecoveryOptions, ExtendedAudioQueueChannel } from './types';
5
5
  /**
6
6
  * Subscribes to audio error events for a specific channel
7
7
  * @param channelNumber - The channel number to listen to (defaults to 0)
@@ -61,10 +61,10 @@ export declare const getRetryConfig: () => RetryConfig;
61
61
  * ```typescript
62
62
  * setErrorRecovery({
63
63
  * autoRetry: true,
64
- * showUserFeedback: true,
64
+ * fallbackToNextTrack: true,
65
65
  * logErrorsToAnalytics: true,
66
66
  * preserveQueueOnError: true,
67
- * fallbackToNextTrack: true
67
+ * showUserFeedback: true
68
68
  * });
69
69
  * ```
70
70
  */
@@ -109,7 +109,7 @@ export declare const emitAudioError: (channelNumber: number, errorInfo: AudioErr
109
109
  * @returns The categorized error type
110
110
  * @internal
111
111
  */
112
- export declare const categorizeError: (error: Error, audio: HTMLAudioElement) => AudioErrorInfo["errorType"];
112
+ export declare const categorizeError: (error: Error, audio: HTMLAudioElement) => AudioErrorType;
113
113
  /**
114
114
  * Sets up comprehensive error handling for an audio element
115
115
  * @param audio - The audio element to set up error handling for
package/dist/errors.js CHANGED
@@ -43,6 +43,7 @@ let globalRetryConfig = {
43
43
  baseDelay: 1000,
44
44
  enabled: true,
45
45
  exponentialBackoff: true,
46
+ fallbackUrls: [],
46
47
  maxRetries: 3,
47
48
  skipOnFailure: false,
48
49
  timeoutMs: 10000
@@ -161,10 +162,10 @@ exports.getRetryConfig = getRetryConfig;
161
162
  * ```typescript
162
163
  * setErrorRecovery({
163
164
  * autoRetry: true,
164
- * showUserFeedback: true,
165
+ * fallbackToNextTrack: true,
165
166
  * logErrorsToAnalytics: true,
166
167
  * preserveQueueOnError: true,
167
- * fallbackToNextTrack: true
168
+ * showUserFeedback: true
168
169
  * });
169
170
  * ```
170
171
  */
@@ -263,34 +264,34 @@ exports.emitAudioError = emitAudioError;
263
264
  const categorizeError = (error, audio) => {
264
265
  const errorMessage = error.message.toLowerCase();
265
266
  if (errorMessage.includes('network') || errorMessage.includes('fetch')) {
266
- return 'network';
267
+ return types_1.AudioErrorType.Network;
267
268
  }
268
269
  // Check for unsupported format first (more specific than decode)
269
270
  if (errorMessage.includes('not supported') ||
270
271
  errorMessage.includes('unsupported') ||
271
272
  errorMessage.includes('format not supported')) {
272
- return 'unsupported';
273
+ return types_1.AudioErrorType.Unsupported;
273
274
  }
274
275
  if (errorMessage.includes('decode') || errorMessage.includes('format')) {
275
- return 'decode';
276
+ return types_1.AudioErrorType.Decode;
276
277
  }
277
278
  if (errorMessage.includes('permission') || errorMessage.includes('blocked')) {
278
- return 'permission';
279
+ return types_1.AudioErrorType.Permission;
279
280
  }
280
281
  if (errorMessage.includes('abort')) {
281
- return 'abort';
282
+ return types_1.AudioErrorType.Abort;
282
283
  }
283
284
  if (errorMessage.includes('timeout')) {
284
- return 'timeout';
285
+ return types_1.AudioErrorType.Timeout;
285
286
  }
286
287
  // Check audio element network state for more context
287
288
  if (audio.networkState === HTMLMediaElement.NETWORK_NO_SOURCE) {
288
- return 'network';
289
+ return types_1.AudioErrorType.Network;
289
290
  }
290
291
  if (audio.networkState === HTMLMediaElement.NETWORK_LOADING) {
291
- return 'timeout';
292
+ return types_1.AudioErrorType.Timeout;
292
293
  }
293
- return 'unknown';
294
+ return types_1.AudioErrorType.Unknown;
294
295
  };
295
296
  exports.categorizeError = categorizeError;
296
297
  /**
package/dist/index.d.ts CHANGED
@@ -7,9 +7,9 @@ export { queueAudio, queueAudioPriority, stopCurrentAudioInChannel, stopAllAudio
7
7
  export { clearQueueAfterCurrent, getQueueItemInfo, getQueueLength, removeQueuedItem, reorderQueue, swapQueueItems } from './queue-manipulation';
8
8
  export { getErrorRecovery, getRetryConfig, offAudioError, onAudioError, retryFailedAudio, setErrorRecovery, setRetryConfig } from './errors';
9
9
  export { getAllChannelsPauseState, isChannelPaused, pauseAllChannels, pauseAllWithFade, pauseChannel, pauseWithFade, resumeAllChannels, resumeAllWithFade, resumeChannel, resumeWithFade, togglePauseAllChannels, togglePauseAllWithFade, togglePauseChannel, togglePauseWithFade } from './pause';
10
- export { clearVolumeDucking, fadeVolume, getAllChannelsVolume, getChannelVolume, getFadeConfig, setAllChannelsVolume, setChannelVolume, setVolumeDucking, transitionVolume, cancelVolumeTransition, cancelAllVolumeTransitions } from './volume';
11
- export { getAllChannelsInfo, getCurrentAudioInfo, getQueueSnapshot, offAudioPause, offAudioProgress, offAudioResume, offQueueChange, onAudioComplete, onAudioPause, onAudioProgress, onAudioResume, onAudioStart, onQueueChange } from './info';
10
+ export { cancelAllVolumeTransitions, cancelVolumeTransition, clearVolumeDucking, getAllChannelsVolume, getChannelVolume, getFadeConfig, setAllChannelsVolume, setChannelVolume, setVolumeDucking, transitionVolume } from './volume';
11
+ export { getAllChannelsInfo, getCurrentAudioInfo, getQueueSnapshot, offAudioComplete, offAudioPause, offAudioProgress, offAudioResume, offAudioStart, offQueueChange, onAudioComplete, onAudioPause, onAudioProgress, onAudioResume, onAudioStart, onQueueChange } from './info';
12
12
  export { audioChannels } from './info';
13
13
  export { cleanWebpackFilename, createQueueSnapshot, extractFileName, getAudioInfoFromElement, sanitizeForDisplay, validateAudioUrl } from './utils';
14
14
  export type { AudioCompleteCallback, AudioCompleteInfo, AudioErrorCallback, AudioErrorInfo, AudioInfo, AudioPauseCallback, AudioQueueOptions, AudioResumeCallback, AudioStartCallback, AudioStartInfo, ChannelFadeState, ErrorRecoveryOptions, ExtendedAudioQueueChannel, FadeConfig, ProgressCallback, QueueChangeCallback, QueueItem, QueueManipulationResult, QueueSnapshot, RetryConfig, VolumeConfig, QueueConfig } from './types';
15
- export { EasingType, FadeType, MAX_CHANNELS, TimerType, GLOBAL_PROGRESS_KEY } from './types';
15
+ export { AudioErrorType, EasingType, FadeType, MAX_CHANNELS, TimerType, GLOBAL_PROGRESS_KEY } from './types';
package/dist/index.js CHANGED
@@ -5,8 +5,8 @@
5
5
  * volume management with ducking, progress tracking, and comprehensive event system
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.getAllChannelsInfo = exports.cancelAllVolumeTransitions = exports.cancelVolumeTransition = exports.transitionVolume = exports.setVolumeDucking = exports.setChannelVolume = exports.setAllChannelsVolume = exports.getFadeConfig = exports.getChannelVolume = exports.getAllChannelsVolume = exports.fadeVolume = exports.clearVolumeDucking = exports.togglePauseWithFade = exports.togglePauseChannel = exports.togglePauseAllWithFade = exports.togglePauseAllChannels = exports.resumeWithFade = exports.resumeChannel = exports.resumeAllWithFade = exports.resumeAllChannels = exports.pauseWithFade = exports.pauseChannel = exports.pauseAllWithFade = exports.pauseAllChannels = exports.isChannelPaused = exports.getAllChannelsPauseState = exports.setRetryConfig = exports.setErrorRecovery = exports.retryFailedAudio = exports.onAudioError = exports.offAudioError = exports.getRetryConfig = exports.getErrorRecovery = exports.swapQueueItems = exports.reorderQueue = exports.removeQueuedItem = exports.getQueueLength = exports.getQueueItemInfo = exports.clearQueueAfterCurrent = exports.setChannelQueueLimit = exports.getQueueConfig = exports.setQueueConfig = exports.destroyAllChannels = exports.destroyChannel = exports.playAudioQueue = exports.stopAllAudio = exports.stopAllAudioInChannel = exports.stopCurrentAudioInChannel = exports.queueAudioPriority = exports.queueAudio = void 0;
9
- exports.GLOBAL_PROGRESS_KEY = exports.TimerType = exports.MAX_CHANNELS = exports.FadeType = exports.EasingType = exports.validateAudioUrl = exports.sanitizeForDisplay = exports.getAudioInfoFromElement = exports.extractFileName = exports.createQueueSnapshot = exports.cleanWebpackFilename = exports.audioChannels = exports.onQueueChange = exports.onAudioStart = exports.onAudioResume = exports.onAudioProgress = exports.onAudioPause = exports.onAudioComplete = exports.offQueueChange = exports.offAudioResume = exports.offAudioProgress = exports.offAudioPause = exports.getQueueSnapshot = exports.getCurrentAudioInfo = void 0;
8
+ exports.getCurrentAudioInfo = exports.getAllChannelsInfo = exports.transitionVolume = exports.setVolumeDucking = exports.setChannelVolume = exports.setAllChannelsVolume = exports.getFadeConfig = exports.getChannelVolume = exports.getAllChannelsVolume = exports.clearVolumeDucking = exports.cancelVolumeTransition = exports.cancelAllVolumeTransitions = exports.togglePauseWithFade = exports.togglePauseChannel = exports.togglePauseAllWithFade = exports.togglePauseAllChannels = exports.resumeWithFade = exports.resumeChannel = exports.resumeAllWithFade = exports.resumeAllChannels = exports.pauseWithFade = exports.pauseChannel = exports.pauseAllWithFade = exports.pauseAllChannels = exports.isChannelPaused = exports.getAllChannelsPauseState = exports.setRetryConfig = exports.setErrorRecovery = exports.retryFailedAudio = exports.onAudioError = exports.offAudioError = exports.getRetryConfig = exports.getErrorRecovery = exports.swapQueueItems = exports.reorderQueue = exports.removeQueuedItem = exports.getQueueLength = exports.getQueueItemInfo = exports.clearQueueAfterCurrent = exports.setChannelQueueLimit = exports.getQueueConfig = exports.setQueueConfig = exports.destroyAllChannels = exports.destroyChannel = exports.playAudioQueue = exports.stopAllAudio = exports.stopAllAudioInChannel = exports.stopCurrentAudioInChannel = exports.queueAudioPriority = exports.queueAudio = void 0;
9
+ exports.GLOBAL_PROGRESS_KEY = exports.TimerType = exports.MAX_CHANNELS = exports.FadeType = exports.EasingType = exports.AudioErrorType = exports.validateAudioUrl = exports.sanitizeForDisplay = exports.getAudioInfoFromElement = exports.extractFileName = exports.createQueueSnapshot = exports.cleanWebpackFilename = exports.audioChannels = exports.onQueueChange = exports.onAudioStart = exports.onAudioResume = exports.onAudioProgress = exports.onAudioPause = exports.onAudioComplete = exports.offQueueChange = exports.offAudioStart = exports.offAudioResume = exports.offAudioProgress = exports.offAudioPause = exports.offAudioComplete = exports.getQueueSnapshot = void 0;
10
10
  // Core queue management functions
11
11
  var core_1 = require("./core");
12
12
  Object.defineProperty(exports, "queueAudio", { enumerable: true, get: function () { return core_1.queueAudio; } });
@@ -55,8 +55,9 @@ Object.defineProperty(exports, "togglePauseChannel", { enumerable: true, get: fu
55
55
  Object.defineProperty(exports, "togglePauseWithFade", { enumerable: true, get: function () { return pause_1.togglePauseWithFade; } });
56
56
  // Volume control and ducking functions
57
57
  var volume_1 = require("./volume");
58
+ Object.defineProperty(exports, "cancelAllVolumeTransitions", { enumerable: true, get: function () { return volume_1.cancelAllVolumeTransitions; } });
59
+ Object.defineProperty(exports, "cancelVolumeTransition", { enumerable: true, get: function () { return volume_1.cancelVolumeTransition; } });
58
60
  Object.defineProperty(exports, "clearVolumeDucking", { enumerable: true, get: function () { return volume_1.clearVolumeDucking; } });
59
- Object.defineProperty(exports, "fadeVolume", { enumerable: true, get: function () { return volume_1.fadeVolume; } });
60
61
  Object.defineProperty(exports, "getAllChannelsVolume", { enumerable: true, get: function () { return volume_1.getAllChannelsVolume; } });
61
62
  Object.defineProperty(exports, "getChannelVolume", { enumerable: true, get: function () { return volume_1.getChannelVolume; } });
62
63
  Object.defineProperty(exports, "getFadeConfig", { enumerable: true, get: function () { return volume_1.getFadeConfig; } });
@@ -64,16 +65,16 @@ Object.defineProperty(exports, "setAllChannelsVolume", { enumerable: true, get:
64
65
  Object.defineProperty(exports, "setChannelVolume", { enumerable: true, get: function () { return volume_1.setChannelVolume; } });
65
66
  Object.defineProperty(exports, "setVolumeDucking", { enumerable: true, get: function () { return volume_1.setVolumeDucking; } });
66
67
  Object.defineProperty(exports, "transitionVolume", { enumerable: true, get: function () { return volume_1.transitionVolume; } });
67
- Object.defineProperty(exports, "cancelVolumeTransition", { enumerable: true, get: function () { return volume_1.cancelVolumeTransition; } });
68
- Object.defineProperty(exports, "cancelAllVolumeTransitions", { enumerable: true, get: function () { return volume_1.cancelAllVolumeTransitions; } });
69
68
  // Audio information and progress tracking functions
70
69
  var info_1 = require("./info");
71
70
  Object.defineProperty(exports, "getAllChannelsInfo", { enumerable: true, get: function () { return info_1.getAllChannelsInfo; } });
72
71
  Object.defineProperty(exports, "getCurrentAudioInfo", { enumerable: true, get: function () { return info_1.getCurrentAudioInfo; } });
73
72
  Object.defineProperty(exports, "getQueueSnapshot", { enumerable: true, get: function () { return info_1.getQueueSnapshot; } });
73
+ Object.defineProperty(exports, "offAudioComplete", { enumerable: true, get: function () { return info_1.offAudioComplete; } });
74
74
  Object.defineProperty(exports, "offAudioPause", { enumerable: true, get: function () { return info_1.offAudioPause; } });
75
75
  Object.defineProperty(exports, "offAudioProgress", { enumerable: true, get: function () { return info_1.offAudioProgress; } });
76
76
  Object.defineProperty(exports, "offAudioResume", { enumerable: true, get: function () { return info_1.offAudioResume; } });
77
+ Object.defineProperty(exports, "offAudioStart", { enumerable: true, get: function () { return info_1.offAudioStart; } });
77
78
  Object.defineProperty(exports, "offQueueChange", { enumerable: true, get: function () { return info_1.offQueueChange; } });
78
79
  Object.defineProperty(exports, "onAudioComplete", { enumerable: true, get: function () { return info_1.onAudioComplete; } });
79
80
  Object.defineProperty(exports, "onAudioPause", { enumerable: true, get: function () { return info_1.onAudioPause; } });
@@ -94,6 +95,7 @@ Object.defineProperty(exports, "sanitizeForDisplay", { enumerable: true, get: fu
94
95
  Object.defineProperty(exports, "validateAudioUrl", { enumerable: true, get: function () { return utils_1.validateAudioUrl; } });
95
96
  // Enums and constants
96
97
  var types_1 = require("./types");
98
+ Object.defineProperty(exports, "AudioErrorType", { enumerable: true, get: function () { return types_1.AudioErrorType; } });
97
99
  Object.defineProperty(exports, "EasingType", { enumerable: true, get: function () { return types_1.EasingType; } });
98
100
  Object.defineProperty(exports, "FadeType", { enumerable: true, get: function () { return types_1.FadeType; } });
99
101
  Object.defineProperty(exports, "MAX_CHANNELS", { enumerable: true, get: function () { return types_1.MAX_CHANNELS; } });
package/dist/info.d.ts CHANGED
@@ -2,6 +2,29 @@
2
2
  * @fileoverview Audio information and progress tracking functions for the audio-channel-queue package
3
3
  */
4
4
  import { AudioInfo, QueueSnapshot, ProgressCallback, QueueChangeCallback, AudioStartCallback, AudioCompleteCallback, AudioPauseCallback, AudioResumeCallback, ExtendedAudioQueueChannel } from './types';
5
+ /**
6
+ * Gets the current list of whitelisted channel properties
7
+ * This is automatically derived from the ExtendedAudioQueueChannel interface
8
+ * @returns Array of whitelisted property names
9
+ * @internal
10
+ */
11
+ export declare const getWhitelistedChannelProperties: () => string[];
12
+ /**
13
+ * Returns the list of non-whitelisted properties found on a specific channel
14
+ * These are properties that will trigger warnings when modified directly
15
+ * @param channelNumber - The channel number to inspect (defaults to 0)
16
+ * @returns Array of property names that are not in the whitelist, or empty array if channel doesn't exist
17
+ * @example
18
+ * ```typescript
19
+ * // Add some custom property to a channel
20
+ * (audioChannels[0] as any).customProperty = 'test';
21
+ *
22
+ * const nonWhitelisted = getNonWhitelistedChannelProperties(0);
23
+ * console.log(nonWhitelisted); // ['customProperty']
24
+ * ```
25
+ * @internal
26
+ */
27
+ export declare const getNonWhitelistedChannelProperties: (channelNumber?: number) => string[];
5
28
  /**
6
29
  * Global array to store audio channels with their queues and callback management
7
30
  * Each channel maintains its own audio queue and event callback sets
@@ -93,13 +116,14 @@ export declare function offAudioProgress(channelNumber?: number): void;
93
116
  export declare const onQueueChange: (channelNumber: number, callback: QueueChangeCallback) => void;
94
117
  /**
95
118
  * Removes queue change listeners for a specific channel
96
- * @param channelNumber - The channel number
119
+ * @param channelNumber - The channel number (defaults to 0)
97
120
  * @example
98
121
  * ```typescript
99
- * offQueueChange(0); // Stop receiving queue change notifications for channel 0
122
+ * offQueueChange(); // Stop receiving queue change notifications for default channel (0)
123
+ * offQueueChange(1); // Stop receiving queue change notifications for channel 1
100
124
  * ```
101
125
  */
102
- export declare const offQueueChange: (channelNumber: number) => void;
126
+ export declare const offQueueChange: (channelNumber?: number) => void;
103
127
  /**
104
128
  * Subscribes to audio start events for a specific channel
105
129
  * @param channelNumber - The channel number to monitor
@@ -160,19 +184,41 @@ export declare const onAudioPause: (channelNumber: number, callback: AudioPauseC
160
184
  export declare const onAudioResume: (channelNumber: number, callback: AudioResumeCallback) => void;
161
185
  /**
162
186
  * Removes pause event listeners for a specific channel
163
- * @param channelNumber - The channel number
187
+ * @param channelNumber - The channel number (defaults to 0)
164
188
  * @example
165
189
  * ```typescript
166
- * offAudioPause(0); // Stop receiving pause notifications for channel 0
190
+ * offAudioPause(); // Stop receiving pause notifications for default channel (0)
191
+ * offAudioPause(1); // Stop receiving pause notifications for channel 1
167
192
  * ```
168
193
  */
169
- export declare const offAudioPause: (channelNumber: number) => void;
194
+ export declare const offAudioPause: (channelNumber?: number) => void;
170
195
  /**
171
196
  * Removes resume event listeners for a specific channel
172
- * @param channelNumber - The channel number
197
+ * @param channelNumber - The channel number (defaults to 0)
198
+ * @example
199
+ * ```typescript
200
+ * offAudioResume(); // Stop receiving resume notifications for default channel (0)
201
+ * offAudioResume(1); // Stop receiving resume notifications for channel 1
202
+ * ```
203
+ */
204
+ export declare const offAudioResume: (channelNumber?: number) => void;
205
+ /**
206
+ * Removes audio start event listeners for a specific channel
207
+ * @param channelNumber - The channel number (defaults to 0)
208
+ * @example
209
+ * ```typescript
210
+ * offAudioStart(); // Stop receiving start notifications for default channel (0)
211
+ * offAudioStart(1); // Stop receiving start notifications for channel 1
212
+ * ```
213
+ */
214
+ export declare const offAudioStart: (channelNumber?: number) => void;
215
+ /**
216
+ * Removes audio complete event listeners for a specific channel
217
+ * @param channelNumber - The channel number (defaults to 0)
173
218
  * @example
174
219
  * ```typescript
175
- * offAudioResume(0); // Stop receiving resume notifications for channel 0
220
+ * offAudioComplete(); // Stop receiving completion notifications for default channel (0)
221
+ * offAudioComplete(1); // Stop receiving completion notifications for channel 1
176
222
  * ```
177
223
  */
178
- export declare const offAudioResume: (channelNumber: number) => void;
224
+ export declare const offAudioComplete: (channelNumber?: number) => void;