audio-channel-queue 1.8.0 → 1.10.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 +197 -313
- package/dist/core.d.ts +59 -1
- package/dist/core.js +333 -41
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +37 -18
- package/dist/events.js +21 -14
- package/dist/index.d.ts +9 -8
- package/dist/index.js +23 -3
- package/dist/info.d.ts +17 -6
- package/dist/info.js +89 -17
- package/dist/pause.d.ts +24 -12
- package/dist/pause.js +93 -41
- package/dist/queue-manipulation.d.ts +104 -0
- package/dist/queue-manipulation.js +319 -0
- package/dist/types.d.ts +58 -11
- package/dist/types.js +18 -1
- package/dist/utils.d.ts +25 -0
- package/dist/utils.js +102 -13
- package/dist/volume.d.ts +14 -1
- package/dist/volume.js +201 -60
- package/package.json +18 -3
- package/src/core.ts +437 -81
- package/src/errors.ts +516 -480
- package/src/events.ts +36 -27
- package/src/index.ts +68 -43
- package/src/info.ts +129 -30
- package/src/pause.ts +169 -88
- package/src/queue-manipulation.ts +378 -0
- package/src/types.ts +63 -11
- package/src/utils.ts +117 -16
- package/src/volume.ts +250 -81
package/dist/errors.js
CHANGED
|
@@ -36,22 +36,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
38
|
exports.createProtectedAudioElement = exports.handleAudioError = exports.setupAudioErrorHandling = exports.categorizeError = exports.emitAudioError = exports.retryFailedAudio = exports.getErrorRecovery = exports.setErrorRecovery = exports.getRetryConfig = exports.setRetryConfig = exports.offAudioError = exports.onAudioError = void 0;
|
|
39
|
+
const types_1 = require("./types");
|
|
39
40
|
const info_1 = require("./info");
|
|
40
41
|
const utils_1 = require("./utils");
|
|
41
42
|
let globalRetryConfig = {
|
|
42
|
-
enabled: true,
|
|
43
|
-
maxRetries: 3,
|
|
44
43
|
baseDelay: 1000,
|
|
44
|
+
enabled: true,
|
|
45
45
|
exponentialBackoff: true,
|
|
46
|
-
|
|
47
|
-
skipOnFailure: false
|
|
46
|
+
maxRetries: 3,
|
|
47
|
+
skipOnFailure: false,
|
|
48
|
+
timeoutMs: 10000
|
|
48
49
|
};
|
|
49
50
|
let globalErrorRecovery = {
|
|
50
51
|
autoRetry: true,
|
|
51
|
-
|
|
52
|
+
fallbackToNextTrack: true,
|
|
52
53
|
logErrorsToAnalytics: false,
|
|
53
54
|
preserveQueueOnError: true,
|
|
54
|
-
|
|
55
|
+
showUserFeedback: false
|
|
55
56
|
};
|
|
56
57
|
const retryAttempts = new WeakMap();
|
|
57
58
|
const loadTimeouts = new WeakMap();
|
|
@@ -59,6 +60,7 @@ const loadTimeouts = new WeakMap();
|
|
|
59
60
|
* Subscribes to audio error events for a specific channel
|
|
60
61
|
* @param channelNumber - The channel number to listen to (defaults to 0)
|
|
61
62
|
* @param callback - Function to call when an audio error occurs
|
|
63
|
+
* @throws Error if the channel number exceeds the maximum allowed channels
|
|
62
64
|
* @example
|
|
63
65
|
* ```typescript
|
|
64
66
|
* onAudioError(0, (errorInfo) => {
|
|
@@ -68,7 +70,14 @@ const loadTimeouts = new WeakMap();
|
|
|
68
70
|
* ```
|
|
69
71
|
*/
|
|
70
72
|
const onAudioError = (channelNumber = 0, callback) => {
|
|
71
|
-
//
|
|
73
|
+
// Validate channel number limits BEFORE creating any channels
|
|
74
|
+
if (channelNumber < 0) {
|
|
75
|
+
throw new Error('Channel number must be non-negative');
|
|
76
|
+
}
|
|
77
|
+
if (channelNumber >= types_1.MAX_CHANNELS) {
|
|
78
|
+
throw new Error(`Channel number ${channelNumber} exceeds maximum allowed channels (${types_1.MAX_CHANNELS})`);
|
|
79
|
+
}
|
|
80
|
+
// Ensure channel exists (now safe because we validated the limit above)
|
|
72
81
|
while (info_1.audioChannels.length <= channelNumber) {
|
|
73
82
|
info_1.audioChannels.push({
|
|
74
83
|
audioCompleteCallbacks: new Set(),
|
|
@@ -191,11 +200,12 @@ exports.getErrorRecovery = getErrorRecovery;
|
|
|
191
200
|
* ```
|
|
192
201
|
*/
|
|
193
202
|
const retryFailedAudio = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (channelNumber = 0) {
|
|
203
|
+
var _a;
|
|
194
204
|
const channel = info_1.audioChannels[channelNumber];
|
|
195
205
|
if (!channel || channel.queue.length === 0)
|
|
196
206
|
return false;
|
|
197
207
|
const currentAudio = channel.queue[0];
|
|
198
|
-
const currentAttempts = retryAttempts.get(currentAudio)
|
|
208
|
+
const currentAttempts = (_a = retryAttempts.get(currentAudio)) !== null && _a !== void 0 ? _a : 0;
|
|
199
209
|
if (currentAttempts >= globalRetryConfig.maxRetries) {
|
|
200
210
|
return false;
|
|
201
211
|
}
|
|
@@ -208,6 +218,8 @@ const retryFailedAudio = (...args_1) => __awaiter(void 0, [...args_1], void 0, f
|
|
|
208
218
|
return true;
|
|
209
219
|
}
|
|
210
220
|
catch (error) {
|
|
221
|
+
// eslint-disable-next-line no-console
|
|
222
|
+
console.error(`Error in retryFailedAudio: ${error}`);
|
|
211
223
|
// Increment retry counter
|
|
212
224
|
retryAttempts.set(currentAudio, currentAttempts + 1);
|
|
213
225
|
return false;
|
|
@@ -227,13 +239,15 @@ const emitAudioError = (channelNumber, errorInfo, audioChannels) => {
|
|
|
227
239
|
return;
|
|
228
240
|
// Log to analytics if enabled
|
|
229
241
|
if (globalErrorRecovery.logErrorsToAnalytics) {
|
|
242
|
+
// eslint-disable-next-line no-console
|
|
230
243
|
console.warn('Audio Error Analytics:', errorInfo);
|
|
231
244
|
}
|
|
232
|
-
channel.audioErrorCallbacks.forEach(callback => {
|
|
245
|
+
channel.audioErrorCallbacks.forEach((callback) => {
|
|
233
246
|
try {
|
|
234
247
|
callback(errorInfo);
|
|
235
248
|
}
|
|
236
249
|
catch (error) {
|
|
250
|
+
// eslint-disable-next-line no-console
|
|
237
251
|
console.error('Error in audio error callback:', error);
|
|
238
252
|
}
|
|
239
253
|
});
|
|
@@ -252,7 +266,8 @@ const categorizeError = (error, audio) => {
|
|
|
252
266
|
return 'network';
|
|
253
267
|
}
|
|
254
268
|
// Check for unsupported format first (more specific than decode)
|
|
255
|
-
if (errorMessage.includes('not supported') ||
|
|
269
|
+
if (errorMessage.includes('not supported') ||
|
|
270
|
+
errorMessage.includes('unsupported') ||
|
|
256
271
|
errorMessage.includes('format not supported')) {
|
|
257
272
|
return 'unsupported';
|
|
258
273
|
}
|
|
@@ -312,7 +327,7 @@ const setupAudioErrorHandling = (audio, channelNumber, originalUrl, onError) =>
|
|
|
312
327
|
}
|
|
313
328
|
};
|
|
314
329
|
// Handle various error events
|
|
315
|
-
const handleError = (
|
|
330
|
+
const handleError = (_event) => {
|
|
316
331
|
var _a;
|
|
317
332
|
if (typeof setTimeout !== 'undefined') {
|
|
318
333
|
const timeoutId = loadTimeouts.get(audio);
|
|
@@ -363,25 +378,28 @@ exports.setupAudioErrorHandling = setupAudioErrorHandling;
|
|
|
363
378
|
* @internal
|
|
364
379
|
*/
|
|
365
380
|
const handleAudioError = (audio, channelNumber, originalUrl, error) => __awaiter(void 0, void 0, void 0, function* () {
|
|
381
|
+
var _a, _b;
|
|
366
382
|
const channel = info_1.audioChannels[channelNumber];
|
|
367
383
|
if (!channel)
|
|
368
384
|
return;
|
|
369
|
-
const currentAttempts = retryAttempts.get(audio)
|
|
370
|
-
const retryConfig = channel.retryConfig
|
|
385
|
+
const currentAttempts = (_a = retryAttempts.get(audio)) !== null && _a !== void 0 ? _a : 0;
|
|
386
|
+
const retryConfig = (_b = channel.retryConfig) !== null && _b !== void 0 ? _b : globalRetryConfig;
|
|
371
387
|
const errorInfo = {
|
|
372
388
|
channelNumber,
|
|
373
|
-
src: originalUrl,
|
|
374
|
-
fileName: (0, utils_1.extractFileName)(originalUrl),
|
|
375
389
|
error,
|
|
376
390
|
errorType: (0, exports.categorizeError)(error, audio),
|
|
377
|
-
|
|
391
|
+
fileName: (0, utils_1.extractFileName)(originalUrl),
|
|
392
|
+
remainingInQueue: channel.queue.length - 1,
|
|
378
393
|
retryAttempt: currentAttempts,
|
|
379
|
-
|
|
394
|
+
src: originalUrl,
|
|
395
|
+
timestamp: Date.now()
|
|
380
396
|
};
|
|
381
397
|
// Emit error event
|
|
382
398
|
(0, exports.emitAudioError)(channelNumber, errorInfo, info_1.audioChannels);
|
|
383
399
|
// Attempt retry if enabled and within limits
|
|
384
|
-
if (retryConfig.enabled &&
|
|
400
|
+
if (retryConfig.enabled &&
|
|
401
|
+
currentAttempts < retryConfig.maxRetries &&
|
|
402
|
+
globalErrorRecovery.autoRetry) {
|
|
385
403
|
const delay = retryConfig.exponentialBackoff
|
|
386
404
|
? retryConfig.baseDelay * Math.pow(2, currentAttempts)
|
|
387
405
|
: retryConfig.baseDelay;
|
|
@@ -412,6 +430,7 @@ const handleAudioError = (audio, channelNumber, originalUrl, error) => __awaiter
|
|
|
412
430
|
channel.queue.shift();
|
|
413
431
|
// Import and use playAudioQueue to continue with next track
|
|
414
432
|
const { playAudioQueue } = yield Promise.resolve().then(() => __importStar(require('./core')));
|
|
433
|
+
// eslint-disable-next-line no-console
|
|
415
434
|
playAudioQueue(channelNumber).catch(console.error);
|
|
416
435
|
}
|
|
417
436
|
else if (!globalErrorRecovery.preserveQueueOnError) {
|
package/dist/events.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.cleanupProgressTracking = exports.setupProgressTracking = exports.emitAudioResume = exports.emitAudioPause = exports.emitAudioComplete = exports.emitAudioStart = exports.emitQueueChange = void 0;
|
|
7
|
+
const types_1 = require("./types");
|
|
7
8
|
const utils_1 = require("./utils");
|
|
8
9
|
/**
|
|
9
10
|
* Emits a queue change event to all registered listeners for a specific channel
|
|
@@ -16,16 +17,17 @@ const utils_1 = require("./utils");
|
|
|
16
17
|
*/
|
|
17
18
|
const emitQueueChange = (channelNumber, audioChannels) => {
|
|
18
19
|
const channel = audioChannels[channelNumber];
|
|
19
|
-
if (!channel ||
|
|
20
|
+
if (!(channel === null || channel === void 0 ? void 0 : channel.queueChangeCallbacks))
|
|
20
21
|
return;
|
|
21
22
|
const snapshot = (0, utils_1.createQueueSnapshot)(channelNumber, audioChannels);
|
|
22
23
|
if (!snapshot)
|
|
23
24
|
return;
|
|
24
|
-
channel.queueChangeCallbacks.forEach(callback => {
|
|
25
|
+
channel.queueChangeCallbacks.forEach((callback) => {
|
|
25
26
|
try {
|
|
26
27
|
callback(snapshot);
|
|
27
28
|
}
|
|
28
29
|
catch (error) {
|
|
30
|
+
// eslint-disable-next-line no-console
|
|
29
31
|
console.error('Error in queue change callback:', error);
|
|
30
32
|
}
|
|
31
33
|
});
|
|
@@ -43,13 +45,14 @@ exports.emitQueueChange = emitQueueChange;
|
|
|
43
45
|
*/
|
|
44
46
|
const emitAudioStart = (channelNumber, audioInfo, audioChannels) => {
|
|
45
47
|
const channel = audioChannels[channelNumber];
|
|
46
|
-
if (!channel ||
|
|
48
|
+
if (!(channel === null || channel === void 0 ? void 0 : channel.audioStartCallbacks))
|
|
47
49
|
return;
|
|
48
|
-
channel.audioStartCallbacks.forEach(callback => {
|
|
50
|
+
channel.audioStartCallbacks.forEach((callback) => {
|
|
49
51
|
try {
|
|
50
52
|
callback(audioInfo);
|
|
51
53
|
}
|
|
52
54
|
catch (error) {
|
|
55
|
+
// eslint-disable-next-line no-console
|
|
53
56
|
console.error('Error in audio start callback:', error);
|
|
54
57
|
}
|
|
55
58
|
});
|
|
@@ -67,13 +70,14 @@ exports.emitAudioStart = emitAudioStart;
|
|
|
67
70
|
*/
|
|
68
71
|
const emitAudioComplete = (channelNumber, audioInfo, audioChannels) => {
|
|
69
72
|
const channel = audioChannels[channelNumber];
|
|
70
|
-
if (!channel ||
|
|
73
|
+
if (!(channel === null || channel === void 0 ? void 0 : channel.audioCompleteCallbacks))
|
|
71
74
|
return;
|
|
72
|
-
channel.audioCompleteCallbacks.forEach(callback => {
|
|
75
|
+
channel.audioCompleteCallbacks.forEach((callback) => {
|
|
73
76
|
try {
|
|
74
77
|
callback(audioInfo);
|
|
75
78
|
}
|
|
76
79
|
catch (error) {
|
|
80
|
+
// eslint-disable-next-line no-console
|
|
77
81
|
console.error('Error in audio complete callback:', error);
|
|
78
82
|
}
|
|
79
83
|
});
|
|
@@ -91,13 +95,14 @@ exports.emitAudioComplete = emitAudioComplete;
|
|
|
91
95
|
*/
|
|
92
96
|
const emitAudioPause = (channelNumber, audioInfo, audioChannels) => {
|
|
93
97
|
const channel = audioChannels[channelNumber];
|
|
94
|
-
if (!channel ||
|
|
98
|
+
if (!(channel === null || channel === void 0 ? void 0 : channel.audioPauseCallbacks))
|
|
95
99
|
return;
|
|
96
|
-
channel.audioPauseCallbacks.forEach(callback => {
|
|
100
|
+
channel.audioPauseCallbacks.forEach((callback) => {
|
|
97
101
|
try {
|
|
98
102
|
callback(channelNumber, audioInfo);
|
|
99
103
|
}
|
|
100
104
|
catch (error) {
|
|
105
|
+
// eslint-disable-next-line no-console
|
|
101
106
|
console.error('Error in audio pause callback:', error);
|
|
102
107
|
}
|
|
103
108
|
});
|
|
@@ -115,13 +120,14 @@ exports.emitAudioPause = emitAudioPause;
|
|
|
115
120
|
*/
|
|
116
121
|
const emitAudioResume = (channelNumber, audioInfo, audioChannels) => {
|
|
117
122
|
const channel = audioChannels[channelNumber];
|
|
118
|
-
if (!channel ||
|
|
123
|
+
if (!(channel === null || channel === void 0 ? void 0 : channel.audioResumeCallbacks))
|
|
119
124
|
return;
|
|
120
|
-
channel.audioResumeCallbacks.forEach(callback => {
|
|
125
|
+
channel.audioResumeCallbacks.forEach((callback) => {
|
|
121
126
|
try {
|
|
122
127
|
callback(channelNumber, audioInfo);
|
|
123
128
|
}
|
|
124
129
|
catch (error) {
|
|
130
|
+
// eslint-disable-next-line no-console
|
|
125
131
|
console.error('Error in audio resume callback:', error);
|
|
126
132
|
}
|
|
127
133
|
});
|
|
@@ -151,10 +157,10 @@ const setupProgressTracking = (audio, channelNumber, audioChannels) => {
|
|
|
151
157
|
if (progressListeners.has(audio))
|
|
152
158
|
return;
|
|
153
159
|
const updateProgress = () => {
|
|
154
|
-
var _a, _b;
|
|
160
|
+
var _a, _b, _c, _d;
|
|
155
161
|
// Get callbacks for this specific audio element AND the channel-wide callbacks
|
|
156
|
-
const audioCallbacks = ((_a = channel.progressCallbacks) === null || _a === void 0 ? void 0 : _a.get(audio))
|
|
157
|
-
const channelCallbacks = ((
|
|
162
|
+
const audioCallbacks = (_b = (_a = channel.progressCallbacks) === null || _a === void 0 ? void 0 : _a.get(audio)) !== null && _b !== void 0 ? _b : new Set();
|
|
163
|
+
const channelCallbacks = (_d = (_c = channel.progressCallbacks) === null || _c === void 0 ? void 0 : _c.get(types_1.GLOBAL_PROGRESS_KEY)) !== null && _d !== void 0 ? _d : new Set();
|
|
158
164
|
// Combine both sets of callbacks
|
|
159
165
|
const allCallbacks = new Set([...audioCallbacks, ...channelCallbacks]);
|
|
160
166
|
if (allCallbacks.size === 0)
|
|
@@ -166,6 +172,7 @@ const setupProgressTracking = (audio, channelNumber, audioChannels) => {
|
|
|
166
172
|
callback(info);
|
|
167
173
|
}
|
|
168
174
|
catch (error) {
|
|
175
|
+
// eslint-disable-next-line no-console
|
|
169
176
|
console.error('Error in progress callback:', error);
|
|
170
177
|
}
|
|
171
178
|
});
|
|
@@ -193,7 +200,7 @@ exports.setupProgressTracking = setupProgressTracking;
|
|
|
193
200
|
*/
|
|
194
201
|
const cleanupProgressTracking = (audio, channelNumber, audioChannels) => {
|
|
195
202
|
const channel = audioChannels[channelNumber];
|
|
196
|
-
if (!channel ||
|
|
203
|
+
if (!(channel === null || channel === void 0 ? void 0 : channel.progressCallbacks))
|
|
197
204
|
return;
|
|
198
205
|
// Remove event listeners
|
|
199
206
|
const updateProgress = progressListeners.get(audio);
|
package/dist/index.d.ts
CHANGED
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
* Exports all public functions and types for audio queue management, pause/resume controls,
|
|
4
4
|
* volume management with ducking, progress tracking, and comprehensive event system
|
|
5
5
|
*/
|
|
6
|
-
export { queueAudio, queueAudioPriority, stopCurrentAudioInChannel, stopAllAudioInChannel, stopAllAudio, playAudioQueue } from './core';
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
10
|
-
export {
|
|
6
|
+
export { queueAudio, queueAudioPriority, stopCurrentAudioInChannel, stopAllAudioInChannel, stopAllAudio, playAudioQueue, destroyChannel, destroyAllChannels, setQueueConfig, getQueueConfig, setChannelQueueLimit } from './core';
|
|
7
|
+
export { clearQueueAfterCurrent, getQueueItemInfo, getQueueLength, removeQueuedItem, reorderQueue, swapQueueItems } from './queue-manipulation';
|
|
8
|
+
export { getErrorRecovery, getRetryConfig, offAudioError, onAudioError, retryFailedAudio, setErrorRecovery, setRetryConfig } from './errors';
|
|
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';
|
|
11
12
|
export { audioChannels } from './info';
|
|
12
|
-
export { cleanWebpackFilename, createQueueSnapshot, extractFileName, getAudioInfoFromElement } from './utils';
|
|
13
|
-
export type { AudioCompleteCallback, AudioCompleteInfo, AudioErrorCallback, AudioErrorInfo, AudioInfo, AudioPauseCallback, AudioQueueOptions, AudioResumeCallback, AudioStartCallback, AudioStartInfo, ChannelFadeState, ErrorRecoveryOptions, ExtendedAudioQueueChannel, FadeConfig, ProgressCallback, QueueChangeCallback, QueueItem, QueueSnapshot, RetryConfig, VolumeConfig } from './types';
|
|
14
|
-
export { EasingType, FadeType } from './types';
|
|
13
|
+
export { cleanWebpackFilename, createQueueSnapshot, extractFileName, getAudioInfoFromElement, sanitizeForDisplay, validateAudioUrl } from './utils';
|
|
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';
|
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.
|
|
9
|
-
exports.FadeType = exports.EasingType = exports.getAudioInfoFromElement = exports.extractFileName = exports.createQueueSnapshot = exports.cleanWebpackFilename = void 0;
|
|
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;
|
|
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; } });
|
|
@@ -15,6 +15,19 @@ Object.defineProperty(exports, "stopCurrentAudioInChannel", { enumerable: true,
|
|
|
15
15
|
Object.defineProperty(exports, "stopAllAudioInChannel", { enumerable: true, get: function () { return core_1.stopAllAudioInChannel; } });
|
|
16
16
|
Object.defineProperty(exports, "stopAllAudio", { enumerable: true, get: function () { return core_1.stopAllAudio; } });
|
|
17
17
|
Object.defineProperty(exports, "playAudioQueue", { enumerable: true, get: function () { return core_1.playAudioQueue; } });
|
|
18
|
+
Object.defineProperty(exports, "destroyChannel", { enumerable: true, get: function () { return core_1.destroyChannel; } });
|
|
19
|
+
Object.defineProperty(exports, "destroyAllChannels", { enumerable: true, get: function () { return core_1.destroyAllChannels; } });
|
|
20
|
+
Object.defineProperty(exports, "setQueueConfig", { enumerable: true, get: function () { return core_1.setQueueConfig; } });
|
|
21
|
+
Object.defineProperty(exports, "getQueueConfig", { enumerable: true, get: function () { return core_1.getQueueConfig; } });
|
|
22
|
+
Object.defineProperty(exports, "setChannelQueueLimit", { enumerable: true, get: function () { return core_1.setChannelQueueLimit; } });
|
|
23
|
+
// Queue manipulation functions
|
|
24
|
+
var queue_manipulation_1 = require("./queue-manipulation");
|
|
25
|
+
Object.defineProperty(exports, "clearQueueAfterCurrent", { enumerable: true, get: function () { return queue_manipulation_1.clearQueueAfterCurrent; } });
|
|
26
|
+
Object.defineProperty(exports, "getQueueItemInfo", { enumerable: true, get: function () { return queue_manipulation_1.getQueueItemInfo; } });
|
|
27
|
+
Object.defineProperty(exports, "getQueueLength", { enumerable: true, get: function () { return queue_manipulation_1.getQueueLength; } });
|
|
28
|
+
Object.defineProperty(exports, "removeQueuedItem", { enumerable: true, get: function () { return queue_manipulation_1.removeQueuedItem; } });
|
|
29
|
+
Object.defineProperty(exports, "reorderQueue", { enumerable: true, get: function () { return queue_manipulation_1.reorderQueue; } });
|
|
30
|
+
Object.defineProperty(exports, "swapQueueItems", { enumerable: true, get: function () { return queue_manipulation_1.swapQueueItems; } });
|
|
18
31
|
// Error handling and recovery functions
|
|
19
32
|
var errors_1 = require("./errors");
|
|
20
33
|
Object.defineProperty(exports, "getErrorRecovery", { enumerable: true, get: function () { return errors_1.getErrorRecovery; } });
|
|
@@ -51,6 +64,8 @@ Object.defineProperty(exports, "setAllChannelsVolume", { enumerable: true, get:
|
|
|
51
64
|
Object.defineProperty(exports, "setChannelVolume", { enumerable: true, get: function () { return volume_1.setChannelVolume; } });
|
|
52
65
|
Object.defineProperty(exports, "setVolumeDucking", { enumerable: true, get: function () { return volume_1.setVolumeDucking; } });
|
|
53
66
|
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; } });
|
|
54
69
|
// Audio information and progress tracking functions
|
|
55
70
|
var info_1 = require("./info");
|
|
56
71
|
Object.defineProperty(exports, "getAllChannelsInfo", { enumerable: true, get: function () { return info_1.getAllChannelsInfo; } });
|
|
@@ -75,7 +90,12 @@ Object.defineProperty(exports, "cleanWebpackFilename", { enumerable: true, get:
|
|
|
75
90
|
Object.defineProperty(exports, "createQueueSnapshot", { enumerable: true, get: function () { return utils_1.createQueueSnapshot; } });
|
|
76
91
|
Object.defineProperty(exports, "extractFileName", { enumerable: true, get: function () { return utils_1.extractFileName; } });
|
|
77
92
|
Object.defineProperty(exports, "getAudioInfoFromElement", { enumerable: true, get: function () { return utils_1.getAudioInfoFromElement; } });
|
|
78
|
-
|
|
93
|
+
Object.defineProperty(exports, "sanitizeForDisplay", { enumerable: true, get: function () { return utils_1.sanitizeForDisplay; } });
|
|
94
|
+
Object.defineProperty(exports, "validateAudioUrl", { enumerable: true, get: function () { return utils_1.validateAudioUrl; } });
|
|
95
|
+
// Enums and constants
|
|
79
96
|
var types_1 = require("./types");
|
|
80
97
|
Object.defineProperty(exports, "EasingType", { enumerable: true, get: function () { return types_1.EasingType; } });
|
|
81
98
|
Object.defineProperty(exports, "FadeType", { enumerable: true, get: function () { return types_1.FadeType; } });
|
|
99
|
+
Object.defineProperty(exports, "MAX_CHANNELS", { enumerable: true, get: function () { return types_1.MAX_CHANNELS; } });
|
|
100
|
+
Object.defineProperty(exports, "TimerType", { enumerable: true, get: function () { return types_1.TimerType; } });
|
|
101
|
+
Object.defineProperty(exports, "GLOBAL_PROGRESS_KEY", { enumerable: true, get: function () { return types_1.GLOBAL_PROGRESS_KEY; } });
|
package/dist/info.d.ts
CHANGED
|
@@ -5,6 +5,9 @@ import { AudioInfo, QueueSnapshot, ProgressCallback, QueueChangeCallback, AudioS
|
|
|
5
5
|
/**
|
|
6
6
|
* Global array to store audio channels with their queues and callback management
|
|
7
7
|
* Each channel maintains its own audio queue and event callback sets
|
|
8
|
+
*
|
|
9
|
+
* Note: While you can inspect this array for debugging, direct modification is discouraged.
|
|
10
|
+
* Use the provided API functions for safe channel management.
|
|
8
11
|
*/
|
|
9
12
|
export declare const audioChannels: ExtendedAudioQueueChannel[];
|
|
10
13
|
/**
|
|
@@ -37,22 +40,24 @@ export declare const getCurrentAudioInfo: (channelNumber?: number) => AudioInfo
|
|
|
37
40
|
export declare const getAllChannelsInfo: () => (AudioInfo | null)[];
|
|
38
41
|
/**
|
|
39
42
|
* Gets a complete snapshot of the queue state for a specific channel
|
|
40
|
-
* @param channelNumber - The channel number
|
|
43
|
+
* @param channelNumber - The channel number (defaults to 0)
|
|
41
44
|
* @returns QueueSnapshot object or null if channel doesn't exist
|
|
42
45
|
* @example
|
|
43
46
|
* ```typescript
|
|
44
|
-
* const snapshot = getQueueSnapshot(
|
|
47
|
+
* const snapshot = getQueueSnapshot();
|
|
45
48
|
* if (snapshot) {
|
|
46
49
|
* console.log(`Queue has ${snapshot.totalItems} items`);
|
|
47
50
|
* console.log(`Currently playing: ${snapshot.items[0]?.fileName}`);
|
|
48
51
|
* }
|
|
52
|
+
* const channelSnapshot = getQueueSnapshot(2);
|
|
49
53
|
* ```
|
|
50
54
|
*/
|
|
51
|
-
export declare const getQueueSnapshot: (channelNumber
|
|
55
|
+
export declare const getQueueSnapshot: (channelNumber?: number) => QueueSnapshot | null;
|
|
52
56
|
/**
|
|
53
57
|
* Subscribes to real-time progress updates for a specific channel
|
|
54
58
|
* @param channelNumber - The channel number
|
|
55
59
|
* @param callback - Function to call with audio info updates
|
|
60
|
+
* @throws Error if the channel number exceeds the maximum allowed channels
|
|
56
61
|
* @example
|
|
57
62
|
* ```typescript
|
|
58
63
|
* onAudioProgress(0, (info) => {
|
|
@@ -64,17 +69,19 @@ export declare const getQueueSnapshot: (channelNumber: number) => QueueSnapshot
|
|
|
64
69
|
export declare const onAudioProgress: (channelNumber: number, callback: ProgressCallback) => void;
|
|
65
70
|
/**
|
|
66
71
|
* Removes progress listeners for a specific channel
|
|
67
|
-
* @param channelNumber - The channel number
|
|
72
|
+
* @param channelNumber - The channel number (defaults to 0)
|
|
68
73
|
* @example
|
|
69
74
|
* ```typescript
|
|
70
|
-
* offAudioProgress(
|
|
75
|
+
* offAudioProgress();
|
|
76
|
+
* offAudioProgress(1); // Stop receiving progress updates for channel 1
|
|
71
77
|
* ```
|
|
72
78
|
*/
|
|
73
|
-
export declare
|
|
79
|
+
export declare function offAudioProgress(channelNumber?: number): void;
|
|
74
80
|
/**
|
|
75
81
|
* Subscribes to queue change events for a specific channel
|
|
76
82
|
* @param channelNumber - The channel number to monitor
|
|
77
83
|
* @param callback - Function to call when queue changes
|
|
84
|
+
* @throws Error if the channel number exceeds the maximum allowed channels
|
|
78
85
|
* @example
|
|
79
86
|
* ```typescript
|
|
80
87
|
* onQueueChange(0, (snapshot) => {
|
|
@@ -97,6 +104,7 @@ export declare const offQueueChange: (channelNumber: number) => void;
|
|
|
97
104
|
* Subscribes to audio start events for a specific channel
|
|
98
105
|
* @param channelNumber - The channel number to monitor
|
|
99
106
|
* @param callback - Function to call when audio starts playing
|
|
107
|
+
* @throws Error if the channel number exceeds the maximum allowed channels
|
|
100
108
|
* @example
|
|
101
109
|
* ```typescript
|
|
102
110
|
* onAudioStart(0, (info) => {
|
|
@@ -110,6 +118,7 @@ export declare const onAudioStart: (channelNumber: number, callback: AudioStartC
|
|
|
110
118
|
* Subscribes to audio complete events for a specific channel
|
|
111
119
|
* @param channelNumber - The channel number to monitor
|
|
112
120
|
* @param callback - Function to call when audio completes
|
|
121
|
+
* @throws Error if the channel number exceeds the maximum allowed channels
|
|
113
122
|
* @example
|
|
114
123
|
* ```typescript
|
|
115
124
|
* onAudioComplete(0, (info) => {
|
|
@@ -125,6 +134,7 @@ export declare const onAudioComplete: (channelNumber: number, callback: AudioCom
|
|
|
125
134
|
* Subscribes to audio pause events for a specific channel
|
|
126
135
|
* @param channelNumber - The channel number to monitor
|
|
127
136
|
* @param callback - Function to call when audio is paused
|
|
137
|
+
* @throws Error if the channel number exceeds the maximum allowed channels
|
|
128
138
|
* @example
|
|
129
139
|
* ```typescript
|
|
130
140
|
* onAudioPause(0, (channelNumber, info) => {
|
|
@@ -138,6 +148,7 @@ export declare const onAudioPause: (channelNumber: number, callback: AudioPauseC
|
|
|
138
148
|
* Subscribes to audio resume events for a specific channel
|
|
139
149
|
* @param channelNumber - The channel number to monitor
|
|
140
150
|
* @param callback - Function to call when audio is resumed
|
|
151
|
+
* @throws Error if the channel number exceeds the maximum allowed channels
|
|
141
152
|
* @example
|
|
142
153
|
* ```typescript
|
|
143
154
|
* onAudioResume(0, (channelNumber, info) => {
|