livekit-client 2.5.6 → 2.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. package/dist/livekit-client.e2ee.worker.js +1 -1
  2. package/dist/livekit-client.e2ee.worker.js.map +1 -1
  3. package/dist/livekit-client.e2ee.worker.mjs +624 -603
  4. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  5. package/dist/livekit-client.esm.mjs +2123 -1948
  6. package/dist/livekit-client.esm.mjs.map +1 -1
  7. package/dist/livekit-client.umd.js +1 -1
  8. package/dist/livekit-client.umd.js.map +1 -1
  9. package/dist/src/e2ee/worker/FrameCryptor.d.ts +2 -2
  10. package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
  11. package/dist/src/index.d.ts +2 -2
  12. package/dist/src/index.d.ts.map +1 -1
  13. package/dist/src/room/Room.d.ts +2 -1
  14. package/dist/src/room/Room.d.ts.map +1 -1
  15. package/dist/src/room/events.d.ts +2 -2
  16. package/dist/src/room/participant/Participant.d.ts +1 -1
  17. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  18. package/dist/src/room/track/Track.d.ts +1 -1
  19. package/dist/src/room/track/Track.d.ts.map +1 -1
  20. package/dist/src/room/utils.d.ts +1 -1
  21. package/dist/src/room/utils.d.ts.map +1 -1
  22. package/dist/src/test/mocks.d.ts +1 -1
  23. package/dist/src/test/mocks.d.ts.map +1 -1
  24. package/dist/ts4.2/src/e2ee/worker/FrameCryptor.d.ts +2 -2
  25. package/dist/ts4.2/src/index.d.ts +2 -2
  26. package/dist/ts4.2/src/room/Room.d.ts +2 -1
  27. package/dist/ts4.2/src/room/events.d.ts +2 -2
  28. package/dist/ts4.2/src/room/participant/Participant.d.ts +1 -1
  29. package/dist/ts4.2/src/room/track/Track.d.ts +1 -1
  30. package/dist/ts4.2/src/room/utils.d.ts +1 -1
  31. package/dist/ts4.2/src/test/mocks.d.ts +1 -1
  32. package/package.json +10 -11
  33. package/src/e2ee/worker/FrameCryptor.test.ts +249 -2
  34. package/src/e2ee/worker/FrameCryptor.ts +3 -3
  35. package/src/e2ee/worker/ParticipantKeyHandler.test.ts +122 -0
  36. package/src/e2ee/worker/ParticipantKeyHandler.ts +1 -1
  37. package/src/e2ee/worker/e2ee.worker.ts +1 -1
  38. package/src/index.ts +2 -0
  39. package/src/room/Room.ts +16 -10
  40. package/src/room/events.ts +2 -2
  41. package/src/room/participant/Participant.ts +3 -2
  42. package/src/room/track/Track.ts +1 -1
  43. package/src/room/track/utils.ts +1 -1
  44. package/src/room/utils.ts +1 -1
  45. package/src/test/mocks.ts +1 -1
@@ -30,9 +30,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
30
30
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
31
31
  };
32
32
 
33
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
34
-
35
- var loglevel = {exports: {}};
33
+ var loglevel$1 = {exports: {}};
36
34
 
37
35
  /*
38
36
  * loglevel - https://github.com/pimterry/loglevel
@@ -40,315 +38,323 @@ var loglevel = {exports: {}};
40
38
  * Copyright (c) 2013 Tim Perry
41
39
  * Licensed under the MIT license.
42
40
  */
43
- (function (module) {
44
- (function (root, definition) {
45
-
46
- if (module.exports) {
47
- module.exports = definition();
48
- } else {
49
- root.log = definition();
50
- }
51
- })(commonjsGlobal, function () {
41
+ var loglevel = loglevel$1.exports;
42
+ var hasRequiredLoglevel;
43
+ function requireLoglevel() {
44
+ if (hasRequiredLoglevel) return loglevel$1.exports;
45
+ hasRequiredLoglevel = 1;
46
+ (function (module) {
47
+ (function (root, definition) {
52
48
 
53
- // Slightly dubious tricks to cut down minimized file size
54
- var noop = function () {};
55
- var undefinedType = "undefined";
56
- var isIE = typeof window !== undefinedType && typeof window.navigator !== undefinedType && /Trident\/|MSIE /.test(window.navigator.userAgent);
57
- var logMethods = ["trace", "debug", "info", "warn", "error"];
58
- var _loggersByName = {};
59
- var defaultLogger = null;
60
-
61
- // Cross-browser bind equivalent that works at least back to IE6
62
- function bindMethod(obj, methodName) {
63
- var method = obj[methodName];
64
- if (typeof method.bind === 'function') {
65
- return method.bind(obj);
49
+ if (module.exports) {
50
+ module.exports = definition();
66
51
  } else {
67
- try {
68
- return Function.prototype.bind.call(method, obj);
69
- } catch (e) {
70
- // Missing bind shim or IE8 + Modernizr, fallback to wrapping
71
- return function () {
72
- return Function.prototype.apply.apply(method, [obj, arguments]);
73
- };
74
- }
52
+ root.log = definition();
75
53
  }
76
- }
54
+ })(loglevel, function () {
77
55
 
78
- // Trace() doesn't print the message in IE, so for that case we need to wrap it
79
- function traceForIE() {
80
- if (console.log) {
81
- if (console.log.apply) {
82
- console.log.apply(console, arguments);
56
+ // Slightly dubious tricks to cut down minimized file size
57
+ var noop = function () {};
58
+ var undefinedType = "undefined";
59
+ var isIE = typeof window !== undefinedType && typeof window.navigator !== undefinedType && /Trident\/|MSIE /.test(window.navigator.userAgent);
60
+ var logMethods = ["trace", "debug", "info", "warn", "error"];
61
+ var _loggersByName = {};
62
+ var defaultLogger = null;
63
+
64
+ // Cross-browser bind equivalent that works at least back to IE6
65
+ function bindMethod(obj, methodName) {
66
+ var method = obj[methodName];
67
+ if (typeof method.bind === 'function') {
68
+ return method.bind(obj);
83
69
  } else {
84
- // In old IE, native console methods themselves don't have apply().
85
- Function.prototype.apply.apply(console.log, [console, arguments]);
70
+ try {
71
+ return Function.prototype.bind.call(method, obj);
72
+ } catch (e) {
73
+ // Missing bind shim or IE8 + Modernizr, fallback to wrapping
74
+ return function () {
75
+ return Function.prototype.apply.apply(method, [obj, arguments]);
76
+ };
77
+ }
86
78
  }
87
79
  }
88
- if (console.trace) console.trace();
89
- }
90
80
 
91
- // Build the best logging method possible for this env
92
- // Wherever possible we want to bind, not wrap, to preserve stack traces
93
- function realMethod(methodName) {
94
- if (methodName === 'debug') {
95
- methodName = 'log';
96
- }
97
- if (typeof console === undefinedType) {
98
- return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives
99
- } else if (methodName === 'trace' && isIE) {
100
- return traceForIE;
101
- } else if (console[methodName] !== undefined) {
102
- return bindMethod(console, methodName);
103
- } else if (console.log !== undefined) {
104
- return bindMethod(console, 'log');
105
- } else {
106
- return noop;
81
+ // Trace() doesn't print the message in IE, so for that case we need to wrap it
82
+ function traceForIE() {
83
+ if (console.log) {
84
+ if (console.log.apply) {
85
+ console.log.apply(console, arguments);
86
+ } else {
87
+ // In old IE, native console methods themselves don't have apply().
88
+ Function.prototype.apply.apply(console.log, [console, arguments]);
89
+ }
90
+ }
91
+ if (console.trace) console.trace();
107
92
  }
108
- }
109
-
110
- // These private functions always need `this` to be set properly
111
-
112
- function replaceLoggingMethods() {
113
- /*jshint validthis:true */
114
- var level = this.getLevel();
115
93
 
116
- // Replace the actual methods.
117
- for (var i = 0; i < logMethods.length; i++) {
118
- var methodName = logMethods[i];
119
- this[methodName] = i < level ? noop : this.methodFactory(methodName, level, this.name);
94
+ // Build the best logging method possible for this env
95
+ // Wherever possible we want to bind, not wrap, to preserve stack traces
96
+ function realMethod(methodName) {
97
+ if (methodName === 'debug') {
98
+ methodName = 'log';
99
+ }
100
+ if (typeof console === undefinedType) {
101
+ return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives
102
+ } else if (methodName === 'trace' && isIE) {
103
+ return traceForIE;
104
+ } else if (console[methodName] !== undefined) {
105
+ return bindMethod(console, methodName);
106
+ } else if (console.log !== undefined) {
107
+ return bindMethod(console, 'log');
108
+ } else {
109
+ return noop;
110
+ }
120
111
  }
121
112
 
122
- // Define log.log as an alias for log.debug
123
- this.log = this.debug;
113
+ // These private functions always need `this` to be set properly
124
114
 
125
- // Return any important warnings.
126
- if (typeof console === undefinedType && level < this.levels.SILENT) {
127
- return "No console available for logging";
128
- }
129
- }
115
+ function replaceLoggingMethods() {
116
+ /*jshint validthis:true */
117
+ var level = this.getLevel();
130
118
 
131
- // In old IE versions, the console isn't present until you first open it.
132
- // We build realMethod() replacements here that regenerate logging methods
133
- function enableLoggingWhenConsoleArrives(methodName) {
134
- return function () {
135
- if (typeof console !== undefinedType) {
136
- replaceLoggingMethods.call(this);
137
- this[methodName].apply(this, arguments);
119
+ // Replace the actual methods.
120
+ for (var i = 0; i < logMethods.length; i++) {
121
+ var methodName = logMethods[i];
122
+ this[methodName] = i < level ? noop : this.methodFactory(methodName, level, this.name);
138
123
  }
139
- };
140
- }
141
124
 
142
- // By default, we use closely bound real methods wherever possible, and
143
- // otherwise we wait for a console to appear, and then try again.
144
- function defaultMethodFactory(methodName, _level, _loggerName) {
145
- /*jshint validthis:true */
146
- return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
147
- }
148
- function Logger(name, factory) {
149
- // Private instance variables.
150
- var self = this;
151
- /**
152
- * The level inherited from a parent logger (or a global default). We
153
- * cache this here rather than delegating to the parent so that it stays
154
- * in sync with the actual logging methods that we have installed (the
155
- * parent could change levels but we might not have rebuilt the loggers
156
- * in this child yet).
157
- * @type {number}
158
- */
159
- var inheritedLevel;
160
- /**
161
- * The default level for this logger, if any. If set, this overrides
162
- * `inheritedLevel`.
163
- * @type {number|null}
164
- */
165
- var defaultLevel;
166
- /**
167
- * A user-specific level for this logger. If set, this overrides
168
- * `defaultLevel`.
169
- * @type {number|null}
170
- */
171
- var userLevel;
172
- var storageKey = "loglevel";
173
- if (typeof name === "string") {
174
- storageKey += ":" + name;
175
- } else if (typeof name === "symbol") {
176
- storageKey = undefined;
125
+ // Define log.log as an alias for log.debug
126
+ this.log = this.debug;
127
+
128
+ // Return any important warnings.
129
+ if (typeof console === undefinedType && level < this.levels.SILENT) {
130
+ return "No console available for logging";
131
+ }
177
132
  }
178
- function persistLevelIfPossible(levelNum) {
179
- var levelName = (logMethods[levelNum] || 'silent').toUpperCase();
180
- if (typeof window === undefinedType || !storageKey) return;
181
133
 
182
- // Use localStorage if available
183
- try {
184
- window.localStorage[storageKey] = levelName;
185
- return;
186
- } catch (ignore) {}
134
+ // In old IE versions, the console isn't present until you first open it.
135
+ // We build realMethod() replacements here that regenerate logging methods
136
+ function enableLoggingWhenConsoleArrives(methodName) {
137
+ return function () {
138
+ if (typeof console !== undefinedType) {
139
+ replaceLoggingMethods.call(this);
140
+ this[methodName].apply(this, arguments);
141
+ }
142
+ };
143
+ }
187
144
 
188
- // Use session cookie as fallback
189
- try {
190
- window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
191
- } catch (ignore) {}
145
+ // By default, we use closely bound real methods wherever possible, and
146
+ // otherwise we wait for a console to appear, and then try again.
147
+ function defaultMethodFactory(methodName, _level, _loggerName) {
148
+ /*jshint validthis:true */
149
+ return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
192
150
  }
193
- function getPersistedLevel() {
194
- var storedLevel;
195
- if (typeof window === undefinedType || !storageKey) return;
196
- try {
197
- storedLevel = window.localStorage[storageKey];
198
- } catch (ignore) {}
151
+ function Logger(name, factory) {
152
+ // Private instance variables.
153
+ var self = this;
154
+ /**
155
+ * The level inherited from a parent logger (or a global default). We
156
+ * cache this here rather than delegating to the parent so that it stays
157
+ * in sync with the actual logging methods that we have installed (the
158
+ * parent could change levels but we might not have rebuilt the loggers
159
+ * in this child yet).
160
+ * @type {number}
161
+ */
162
+ var inheritedLevel;
163
+ /**
164
+ * The default level for this logger, if any. If set, this overrides
165
+ * `inheritedLevel`.
166
+ * @type {number|null}
167
+ */
168
+ var defaultLevel;
169
+ /**
170
+ * A user-specific level for this logger. If set, this overrides
171
+ * `defaultLevel`.
172
+ * @type {number|null}
173
+ */
174
+ var userLevel;
175
+ var storageKey = "loglevel";
176
+ if (typeof name === "string") {
177
+ storageKey += ":" + name;
178
+ } else if (typeof name === "symbol") {
179
+ storageKey = undefined;
180
+ }
181
+ function persistLevelIfPossible(levelNum) {
182
+ var levelName = (logMethods[levelNum] || 'silent').toUpperCase();
183
+ if (typeof window === undefinedType || !storageKey) return;
199
184
 
200
- // Fallback to cookies if local storage gives us nothing
201
- if (typeof storedLevel === undefinedType) {
185
+ // Use localStorage if available
202
186
  try {
203
- var cookie = window.document.cookie;
204
- var cookieName = encodeURIComponent(storageKey);
205
- var location = cookie.indexOf(cookieName + "=");
206
- if (location !== -1) {
207
- storedLevel = /^([^;]+)/.exec(cookie.slice(location + cookieName.length + 1))[1];
208
- }
187
+ window.localStorage[storageKey] = levelName;
188
+ return;
189
+ } catch (ignore) {}
190
+
191
+ // Use session cookie as fallback
192
+ try {
193
+ window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
209
194
  } catch (ignore) {}
210
195
  }
196
+ function getPersistedLevel() {
197
+ var storedLevel;
198
+ if (typeof window === undefinedType || !storageKey) return;
199
+ try {
200
+ storedLevel = window.localStorage[storageKey];
201
+ } catch (ignore) {}
202
+
203
+ // Fallback to cookies if local storage gives us nothing
204
+ if (typeof storedLevel === undefinedType) {
205
+ try {
206
+ var cookie = window.document.cookie;
207
+ var cookieName = encodeURIComponent(storageKey);
208
+ var location = cookie.indexOf(cookieName + "=");
209
+ if (location !== -1) {
210
+ storedLevel = /^([^;]+)/.exec(cookie.slice(location + cookieName.length + 1))[1];
211
+ }
212
+ } catch (ignore) {}
213
+ }
211
214
 
212
- // If the stored level is not valid, treat it as if nothing was stored.
213
- if (self.levels[storedLevel] === undefined) {
214
- storedLevel = undefined;
215
+ // If the stored level is not valid, treat it as if nothing was stored.
216
+ if (self.levels[storedLevel] === undefined) {
217
+ storedLevel = undefined;
218
+ }
219
+ return storedLevel;
215
220
  }
216
- return storedLevel;
217
- }
218
- function clearPersistedLevel() {
219
- if (typeof window === undefinedType || !storageKey) return;
221
+ function clearPersistedLevel() {
222
+ if (typeof window === undefinedType || !storageKey) return;
220
223
 
221
- // Use localStorage if available
222
- try {
223
- window.localStorage.removeItem(storageKey);
224
- } catch (ignore) {}
224
+ // Use localStorage if available
225
+ try {
226
+ window.localStorage.removeItem(storageKey);
227
+ } catch (ignore) {}
225
228
 
226
- // Use session cookie as fallback
227
- try {
228
- window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
229
- } catch (ignore) {}
230
- }
231
- function normalizeLevel(input) {
232
- var level = input;
233
- if (typeof level === "string" && self.levels[level.toUpperCase()] !== undefined) {
234
- level = self.levels[level.toUpperCase()];
229
+ // Use session cookie as fallback
230
+ try {
231
+ window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
232
+ } catch (ignore) {}
235
233
  }
236
- if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) {
237
- return level;
238
- } else {
239
- throw new TypeError("log.setLevel() called with invalid level: " + input);
234
+ function normalizeLevel(input) {
235
+ var level = input;
236
+ if (typeof level === "string" && self.levels[level.toUpperCase()] !== undefined) {
237
+ level = self.levels[level.toUpperCase()];
238
+ }
239
+ if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) {
240
+ return level;
241
+ } else {
242
+ throw new TypeError("log.setLevel() called with invalid level: " + input);
243
+ }
244
+ }
245
+
246
+ /*
247
+ *
248
+ * Public logger API - see https://github.com/pimterry/loglevel for details
249
+ *
250
+ */
251
+
252
+ self.name = name;
253
+ self.levels = {
254
+ "TRACE": 0,
255
+ "DEBUG": 1,
256
+ "INFO": 2,
257
+ "WARN": 3,
258
+ "ERROR": 4,
259
+ "SILENT": 5
260
+ };
261
+ self.methodFactory = factory || defaultMethodFactory;
262
+ self.getLevel = function () {
263
+ if (userLevel != null) {
264
+ return userLevel;
265
+ } else if (defaultLevel != null) {
266
+ return defaultLevel;
267
+ } else {
268
+ return inheritedLevel;
269
+ }
270
+ };
271
+ self.setLevel = function (level, persist) {
272
+ userLevel = normalizeLevel(level);
273
+ if (persist !== false) {
274
+ // defaults to true
275
+ persistLevelIfPossible(userLevel);
276
+ }
277
+
278
+ // NOTE: in v2, this should call rebuild(), which updates children.
279
+ return replaceLoggingMethods.call(self);
280
+ };
281
+ self.setDefaultLevel = function (level) {
282
+ defaultLevel = normalizeLevel(level);
283
+ if (!getPersistedLevel()) {
284
+ self.setLevel(level, false);
285
+ }
286
+ };
287
+ self.resetLevel = function () {
288
+ userLevel = null;
289
+ clearPersistedLevel();
290
+ replaceLoggingMethods.call(self);
291
+ };
292
+ self.enableAll = function (persist) {
293
+ self.setLevel(self.levels.TRACE, persist);
294
+ };
295
+ self.disableAll = function (persist) {
296
+ self.setLevel(self.levels.SILENT, persist);
297
+ };
298
+ self.rebuild = function () {
299
+ if (defaultLogger !== self) {
300
+ inheritedLevel = normalizeLevel(defaultLogger.getLevel());
301
+ }
302
+ replaceLoggingMethods.call(self);
303
+ if (defaultLogger === self) {
304
+ for (var childName in _loggersByName) {
305
+ _loggersByName[childName].rebuild();
306
+ }
307
+ }
308
+ };
309
+
310
+ // Initialize all the internal levels.
311
+ inheritedLevel = normalizeLevel(defaultLogger ? defaultLogger.getLevel() : "WARN");
312
+ var initialLevel = getPersistedLevel();
313
+ if (initialLevel != null) {
314
+ userLevel = normalizeLevel(initialLevel);
240
315
  }
316
+ replaceLoggingMethods.call(self);
241
317
  }
242
318
 
243
319
  /*
244
320
  *
245
- * Public logger API - see https://github.com/pimterry/loglevel for details
321
+ * Top-level API
246
322
  *
247
323
  */
248
324
 
249
- self.name = name;
250
- self.levels = {
251
- "TRACE": 0,
252
- "DEBUG": 1,
253
- "INFO": 2,
254
- "WARN": 3,
255
- "ERROR": 4,
256
- "SILENT": 5
257
- };
258
- self.methodFactory = factory || defaultMethodFactory;
259
- self.getLevel = function () {
260
- if (userLevel != null) {
261
- return userLevel;
262
- } else if (defaultLevel != null) {
263
- return defaultLevel;
264
- } else {
265
- return inheritedLevel;
325
+ defaultLogger = new Logger();
326
+ defaultLogger.getLogger = function getLogger(name) {
327
+ if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
328
+ throw new TypeError("You must supply a name when creating a logger.");
266
329
  }
267
- };
268
- self.setLevel = function (level, persist) {
269
- userLevel = normalizeLevel(level);
270
- if (persist !== false) {
271
- // defaults to true
272
- persistLevelIfPossible(userLevel);
330
+ var logger = _loggersByName[name];
331
+ if (!logger) {
332
+ logger = _loggersByName[name] = new Logger(name, defaultLogger.methodFactory);
273
333
  }
274
-
275
- // NOTE: in v2, this should call rebuild(), which updates children.
276
- return replaceLoggingMethods.call(self);
334
+ return logger;
277
335
  };
278
- self.setDefaultLevel = function (level) {
279
- defaultLevel = normalizeLevel(level);
280
- if (!getPersistedLevel()) {
281
- self.setLevel(level, false);
336
+
337
+ // Grab the current global log variable in case of overwrite
338
+ var _log = typeof window !== undefinedType ? window.log : undefined;
339
+ defaultLogger.noConflict = function () {
340
+ if (typeof window !== undefinedType && window.log === defaultLogger) {
341
+ window.log = _log;
282
342
  }
343
+ return defaultLogger;
283
344
  };
284
- self.resetLevel = function () {
285
- userLevel = null;
286
- clearPersistedLevel();
287
- replaceLoggingMethods.call(self);
288
- };
289
- self.enableAll = function (persist) {
290
- self.setLevel(self.levels.TRACE, persist);
345
+ defaultLogger.getLoggers = function getLoggers() {
346
+ return _loggersByName;
291
347
  };
292
- self.disableAll = function (persist) {
293
- self.setLevel(self.levels.SILENT, persist);
294
- };
295
- self.rebuild = function () {
296
- if (defaultLogger !== self) {
297
- inheritedLevel = normalizeLevel(defaultLogger.getLevel());
298
- }
299
- replaceLoggingMethods.call(self);
300
- if (defaultLogger === self) {
301
- for (var childName in _loggersByName) {
302
- _loggersByName[childName].rebuild();
303
- }
304
- }
305
- };
306
-
307
- // Initialize all the internal levels.
308
- inheritedLevel = normalizeLevel(defaultLogger ? defaultLogger.getLevel() : "WARN");
309
- var initialLevel = getPersistedLevel();
310
- if (initialLevel != null) {
311
- userLevel = normalizeLevel(initialLevel);
312
- }
313
- replaceLoggingMethods.call(self);
314
- }
315
-
316
- /*
317
- *
318
- * Top-level API
319
- *
320
- */
321
348
 
322
- defaultLogger = new Logger();
323
- defaultLogger.getLogger = function getLogger(name) {
324
- if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
325
- throw new TypeError("You must supply a name when creating a logger.");
326
- }
327
- var logger = _loggersByName[name];
328
- if (!logger) {
329
- logger = _loggersByName[name] = new Logger(name, defaultLogger.methodFactory);
330
- }
331
- return logger;
332
- };
333
-
334
- // Grab the current global log variable in case of overwrite
335
- var _log = typeof window !== undefinedType ? window.log : undefined;
336
- defaultLogger.noConflict = function () {
337
- if (typeof window !== undefinedType && window.log === defaultLogger) {
338
- window.log = _log;
339
- }
349
+ // ES6 default export, for compatibility
350
+ defaultLogger['default'] = defaultLogger;
340
351
  return defaultLogger;
341
- };
342
- defaultLogger.getLoggers = function getLoggers() {
343
- return _loggersByName;
344
- };
352
+ });
353
+ })(loglevel$1);
354
+ return loglevel$1.exports;
355
+ }
345
356
 
346
- // ES6 default export, for compatibility
347
- defaultLogger['default'] = defaultLogger;
348
- return defaultLogger;
349
- });
350
- })(loglevel);
351
- var loglevelExports = loglevel.exports;
357
+ var loglevelExports = requireLoglevel();
352
358
 
353
359
  var LogLevel;
354
360
  (function (LogLevel) {
@@ -4008,383 +4014,390 @@ var AudioPresets;
4008
4014
 
4009
4015
  var events = {exports: {}};
4010
4016
 
4011
- var R = typeof Reflect === 'object' ? Reflect : null;
4012
- var ReflectApply = R && typeof R.apply === 'function' ? R.apply : function ReflectApply(target, receiver, args) {
4013
- return Function.prototype.apply.call(target, receiver, args);
4014
- };
4015
- var ReflectOwnKeys;
4016
- if (R && typeof R.ownKeys === 'function') {
4017
- ReflectOwnKeys = R.ownKeys;
4018
- } else if (Object.getOwnPropertySymbols) {
4019
- ReflectOwnKeys = function ReflectOwnKeys(target) {
4020
- return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));
4021
- };
4022
- } else {
4023
- ReflectOwnKeys = function ReflectOwnKeys(target) {
4024
- return Object.getOwnPropertyNames(target);
4017
+ var hasRequiredEvents;
4018
+ function requireEvents() {
4019
+ if (hasRequiredEvents) return events.exports;
4020
+ hasRequiredEvents = 1;
4021
+ var R = typeof Reflect === 'object' ? Reflect : null;
4022
+ var ReflectApply = R && typeof R.apply === 'function' ? R.apply : function ReflectApply(target, receiver, args) {
4023
+ return Function.prototype.apply.call(target, receiver, args);
4025
4024
  };
4026
- }
4027
- function ProcessEmitWarning(warning) {
4028
- if (console && console.warn) console.warn(warning);
4029
- }
4030
- var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
4031
- return value !== value;
4032
- };
4033
- function EventEmitter() {
4034
- EventEmitter.init.call(this);
4035
- }
4036
- events.exports = EventEmitter;
4037
- events.exports.once = once;
4038
-
4039
- // Backwards-compat with node 0.10.x
4040
- EventEmitter.EventEmitter = EventEmitter;
4041
- EventEmitter.prototype._events = undefined;
4042
- EventEmitter.prototype._eventsCount = 0;
4043
- EventEmitter.prototype._maxListeners = undefined;
4044
-
4045
- // By default EventEmitters will print a warning if more than 10 listeners are
4046
- // added to it. This is a useful default which helps finding memory leaks.
4047
- var defaultMaxListeners = 10;
4048
- function checkListener(listener) {
4049
- if (typeof listener !== 'function') {
4050
- throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
4025
+ var ReflectOwnKeys;
4026
+ if (R && typeof R.ownKeys === 'function') {
4027
+ ReflectOwnKeys = R.ownKeys;
4028
+ } else if (Object.getOwnPropertySymbols) {
4029
+ ReflectOwnKeys = function ReflectOwnKeys(target) {
4030
+ return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));
4031
+ };
4032
+ } else {
4033
+ ReflectOwnKeys = function ReflectOwnKeys(target) {
4034
+ return Object.getOwnPropertyNames(target);
4035
+ };
4051
4036
  }
4052
- }
4053
- Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
4054
- enumerable: true,
4055
- get: function () {
4056
- return defaultMaxListeners;
4057
- },
4058
- set: function (arg) {
4059
- if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
4060
- throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
4061
- }
4062
- defaultMaxListeners = arg;
4037
+ function ProcessEmitWarning(warning) {
4038
+ if (console && console.warn) console.warn(warning);
4063
4039
  }
4064
- });
4065
- EventEmitter.init = function () {
4066
- if (this._events === undefined || this._events === Object.getPrototypeOf(this)._events) {
4067
- this._events = Object.create(null);
4068
- this._eventsCount = 0;
4040
+ var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
4041
+ return value !== value;
4042
+ };
4043
+ function EventEmitter() {
4044
+ EventEmitter.init.call(this);
4069
4045
  }
4070
- this._maxListeners = this._maxListeners || undefined;
4071
- };
4046
+ events.exports = EventEmitter;
4047
+ events.exports.once = once;
4072
4048
 
4073
- // Obviously not all Emitters should be limited to 10. This function allows
4074
- // that to be increased. Set to zero for unlimited.
4075
- EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
4076
- if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
4077
- throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
4078
- }
4079
- this._maxListeners = n;
4080
- return this;
4081
- };
4082
- function _getMaxListeners(that) {
4083
- if (that._maxListeners === undefined) return EventEmitter.defaultMaxListeners;
4084
- return that._maxListeners;
4085
- }
4086
- EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
4087
- return _getMaxListeners(this);
4088
- };
4089
- EventEmitter.prototype.emit = function emit(type) {
4090
- var args = [];
4091
- for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
4092
- var doError = type === 'error';
4093
- var events = this._events;
4094
- if (events !== undefined) doError = doError && events.error === undefined;else if (!doError) return false;
4049
+ // Backwards-compat with node 0.10.x
4050
+ EventEmitter.EventEmitter = EventEmitter;
4051
+ EventEmitter.prototype._events = undefined;
4052
+ EventEmitter.prototype._eventsCount = 0;
4053
+ EventEmitter.prototype._maxListeners = undefined;
4095
4054
 
4096
- // If there is no 'error' event listener then throw.
4097
- if (doError) {
4098
- var er;
4099
- if (args.length > 0) er = args[0];
4100
- if (er instanceof Error) {
4101
- // Note: The comments on the `throw` lines are intentional, they show
4102
- // up in Node's output if this results in an unhandled exception.
4103
- throw er; // Unhandled 'error' event
4055
+ // By default EventEmitters will print a warning if more than 10 listeners are
4056
+ // added to it. This is a useful default which helps finding memory leaks.
4057
+ var defaultMaxListeners = 10;
4058
+ function checkListener(listener) {
4059
+ if (typeof listener !== 'function') {
4060
+ throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
4104
4061
  }
4105
- // At least give some kind of context to the user
4106
- var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
4107
- err.context = er;
4108
- throw err; // Unhandled 'error' event
4109
- }
4110
- var handler = events[type];
4111
- if (handler === undefined) return false;
4112
- if (typeof handler === 'function') {
4113
- ReflectApply(handler, this, args);
4114
- } else {
4115
- var len = handler.length;
4116
- var listeners = arrayClone(handler, len);
4117
- for (var i = 0; i < len; ++i) ReflectApply(listeners[i], this, args);
4118
4062
  }
4119
- return true;
4120
- };
4121
- function _addListener(target, type, listener, prepend) {
4122
- var m;
4123
- var events;
4124
- var existing;
4125
- checkListener(listener);
4126
- events = target._events;
4127
- if (events === undefined) {
4128
- events = target._events = Object.create(null);
4129
- target._eventsCount = 0;
4130
- } else {
4131
- // To avoid recursion in the case that type === "newListener"! Before
4132
- // adding it to the listeners, first emit "newListener".
4133
- if (events.newListener !== undefined) {
4134
- target.emit('newListener', type, listener.listener ? listener.listener : listener);
4063
+ Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
4064
+ enumerable: true,
4065
+ get: function () {
4066
+ return defaultMaxListeners;
4067
+ },
4068
+ set: function (arg) {
4069
+ if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
4070
+ throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
4071
+ }
4072
+ defaultMaxListeners = arg;
4073
+ }
4074
+ });
4075
+ EventEmitter.init = function () {
4076
+ if (this._events === undefined || this._events === Object.getPrototypeOf(this)._events) {
4077
+ this._events = Object.create(null);
4078
+ this._eventsCount = 0;
4079
+ }
4080
+ this._maxListeners = this._maxListeners || undefined;
4081
+ };
4135
4082
 
4136
- // Re-assign `events` because a newListener handler could have caused the
4137
- // this._events to be assigned to a new object
4138
- events = target._events;
4083
+ // Obviously not all Emitters should be limited to 10. This function allows
4084
+ // that to be increased. Set to zero for unlimited.
4085
+ EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
4086
+ if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {
4087
+ throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + n + '.');
4139
4088
  }
4140
- existing = events[type];
4089
+ this._maxListeners = n;
4090
+ return this;
4091
+ };
4092
+ function _getMaxListeners(that) {
4093
+ if (that._maxListeners === undefined) return EventEmitter.defaultMaxListeners;
4094
+ return that._maxListeners;
4141
4095
  }
4142
- if (existing === undefined) {
4143
- // Optimize the case of one listener. Don't need the extra array object.
4144
- existing = events[type] = listener;
4145
- ++target._eventsCount;
4146
- } else {
4147
- if (typeof existing === 'function') {
4148
- // Adding the second element, need to change to array.
4149
- existing = events[type] = prepend ? [listener, existing] : [existing, listener];
4150
- // If we've already got an array, just append.
4151
- } else if (prepend) {
4152
- existing.unshift(listener);
4096
+ EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
4097
+ return _getMaxListeners(this);
4098
+ };
4099
+ EventEmitter.prototype.emit = function emit(type) {
4100
+ var args = [];
4101
+ for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);
4102
+ var doError = type === 'error';
4103
+ var events = this._events;
4104
+ if (events !== undefined) doError = doError && events.error === undefined;else if (!doError) return false;
4105
+
4106
+ // If there is no 'error' event listener then throw.
4107
+ if (doError) {
4108
+ var er;
4109
+ if (args.length > 0) er = args[0];
4110
+ if (er instanceof Error) {
4111
+ // Note: The comments on the `throw` lines are intentional, they show
4112
+ // up in Node's output if this results in an unhandled exception.
4113
+ throw er; // Unhandled 'error' event
4114
+ }
4115
+ // At least give some kind of context to the user
4116
+ var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));
4117
+ err.context = er;
4118
+ throw err; // Unhandled 'error' event
4119
+ }
4120
+ var handler = events[type];
4121
+ if (handler === undefined) return false;
4122
+ if (typeof handler === 'function') {
4123
+ ReflectApply(handler, this, args);
4153
4124
  } else {
4154
- existing.push(listener);
4125
+ var len = handler.length;
4126
+ var listeners = arrayClone(handler, len);
4127
+ for (var i = 0; i < len; ++i) ReflectApply(listeners[i], this, args);
4155
4128
  }
4129
+ return true;
4130
+ };
4131
+ function _addListener(target, type, listener, prepend) {
4132
+ var m;
4133
+ var events;
4134
+ var existing;
4135
+ checkListener(listener);
4136
+ events = target._events;
4137
+ if (events === undefined) {
4138
+ events = target._events = Object.create(null);
4139
+ target._eventsCount = 0;
4140
+ } else {
4141
+ // To avoid recursion in the case that type === "newListener"! Before
4142
+ // adding it to the listeners, first emit "newListener".
4143
+ if (events.newListener !== undefined) {
4144
+ target.emit('newListener', type, listener.listener ? listener.listener : listener);
4156
4145
 
4157
- // Check for listener leak
4158
- m = _getMaxListeners(target);
4159
- if (m > 0 && existing.length > m && !existing.warned) {
4160
- existing.warned = true;
4161
- // No error code for this since it is a Warning
4162
- // eslint-disable-next-line no-restricted-syntax
4163
- var w = new Error('Possible EventEmitter memory leak detected. ' + existing.length + ' ' + String(type) + ' listeners ' + 'added. Use emitter.setMaxListeners() to ' + 'increase limit');
4164
- w.name = 'MaxListenersExceededWarning';
4165
- w.emitter = target;
4166
- w.type = type;
4167
- w.count = existing.length;
4168
- ProcessEmitWarning(w);
4146
+ // Re-assign `events` because a newListener handler could have caused the
4147
+ // this._events to be assigned to a new object
4148
+ events = target._events;
4149
+ }
4150
+ existing = events[type];
4169
4151
  }
4152
+ if (existing === undefined) {
4153
+ // Optimize the case of one listener. Don't need the extra array object.
4154
+ existing = events[type] = listener;
4155
+ ++target._eventsCount;
4156
+ } else {
4157
+ if (typeof existing === 'function') {
4158
+ // Adding the second element, need to change to array.
4159
+ existing = events[type] = prepend ? [listener, existing] : [existing, listener];
4160
+ // If we've already got an array, just append.
4161
+ } else if (prepend) {
4162
+ existing.unshift(listener);
4163
+ } else {
4164
+ existing.push(listener);
4165
+ }
4166
+
4167
+ // Check for listener leak
4168
+ m = _getMaxListeners(target);
4169
+ if (m > 0 && existing.length > m && !existing.warned) {
4170
+ existing.warned = true;
4171
+ // No error code for this since it is a Warning
4172
+ // eslint-disable-next-line no-restricted-syntax
4173
+ var w = new Error('Possible EventEmitter memory leak detected. ' + existing.length + ' ' + String(type) + ' listeners ' + 'added. Use emitter.setMaxListeners() to ' + 'increase limit');
4174
+ w.name = 'MaxListenersExceededWarning';
4175
+ w.emitter = target;
4176
+ w.type = type;
4177
+ w.count = existing.length;
4178
+ ProcessEmitWarning(w);
4179
+ }
4180
+ }
4181
+ return target;
4170
4182
  }
4171
- return target;
4172
- }
4173
- EventEmitter.prototype.addListener = function addListener(type, listener) {
4174
- return _addListener(this, type, listener, false);
4175
- };
4176
- EventEmitter.prototype.on = EventEmitter.prototype.addListener;
4177
- EventEmitter.prototype.prependListener = function prependListener(type, listener) {
4178
- return _addListener(this, type, listener, true);
4179
- };
4180
- function onceWrapper() {
4181
- if (!this.fired) {
4182
- this.target.removeListener(this.type, this.wrapFn);
4183
- this.fired = true;
4184
- if (arguments.length === 0) return this.listener.call(this.target);
4185
- return this.listener.apply(this.target, arguments);
4183
+ EventEmitter.prototype.addListener = function addListener(type, listener) {
4184
+ return _addListener(this, type, listener, false);
4185
+ };
4186
+ EventEmitter.prototype.on = EventEmitter.prototype.addListener;
4187
+ EventEmitter.prototype.prependListener = function prependListener(type, listener) {
4188
+ return _addListener(this, type, listener, true);
4189
+ };
4190
+ function onceWrapper() {
4191
+ if (!this.fired) {
4192
+ this.target.removeListener(this.type, this.wrapFn);
4193
+ this.fired = true;
4194
+ if (arguments.length === 0) return this.listener.call(this.target);
4195
+ return this.listener.apply(this.target, arguments);
4196
+ }
4186
4197
  }
4187
- }
4188
- function _onceWrap(target, type, listener) {
4189
- var state = {
4190
- fired: false,
4191
- wrapFn: undefined,
4192
- target: target,
4193
- type: type,
4194
- listener: listener
4198
+ function _onceWrap(target, type, listener) {
4199
+ var state = {
4200
+ fired: false,
4201
+ wrapFn: undefined,
4202
+ target: target,
4203
+ type: type,
4204
+ listener: listener
4205
+ };
4206
+ var wrapped = onceWrapper.bind(state);
4207
+ wrapped.listener = listener;
4208
+ state.wrapFn = wrapped;
4209
+ return wrapped;
4210
+ }
4211
+ EventEmitter.prototype.once = function once(type, listener) {
4212
+ checkListener(listener);
4213
+ this.on(type, _onceWrap(this, type, listener));
4214
+ return this;
4215
+ };
4216
+ EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {
4217
+ checkListener(listener);
4218
+ this.prependListener(type, _onceWrap(this, type, listener));
4219
+ return this;
4195
4220
  };
4196
- var wrapped = onceWrapper.bind(state);
4197
- wrapped.listener = listener;
4198
- state.wrapFn = wrapped;
4199
- return wrapped;
4200
- }
4201
- EventEmitter.prototype.once = function once(type, listener) {
4202
- checkListener(listener);
4203
- this.on(type, _onceWrap(this, type, listener));
4204
- return this;
4205
- };
4206
- EventEmitter.prototype.prependOnceListener = function prependOnceListener(type, listener) {
4207
- checkListener(listener);
4208
- this.prependListener(type, _onceWrap(this, type, listener));
4209
- return this;
4210
- };
4211
4221
 
4212
- // Emits a 'removeListener' event if and only if the listener was removed.
4213
- EventEmitter.prototype.removeListener = function removeListener(type, listener) {
4214
- var list, events, position, i, originalListener;
4215
- checkListener(listener);
4216
- events = this._events;
4217
- if (events === undefined) return this;
4218
- list = events[type];
4219
- if (list === undefined) return this;
4220
- if (list === listener || list.listener === listener) {
4221
- if (--this._eventsCount === 0) this._events = Object.create(null);else {
4222
- delete events[type];
4223
- if (events.removeListener) this.emit('removeListener', type, list.listener || listener);
4224
- }
4225
- } else if (typeof list !== 'function') {
4226
- position = -1;
4227
- for (i = list.length - 1; i >= 0; i--) {
4228
- if (list[i] === listener || list[i].listener === listener) {
4229
- originalListener = list[i].listener;
4230
- position = i;
4231
- break;
4222
+ // Emits a 'removeListener' event if and only if the listener was removed.
4223
+ EventEmitter.prototype.removeListener = function removeListener(type, listener) {
4224
+ var list, events, position, i, originalListener;
4225
+ checkListener(listener);
4226
+ events = this._events;
4227
+ if (events === undefined) return this;
4228
+ list = events[type];
4229
+ if (list === undefined) return this;
4230
+ if (list === listener || list.listener === listener) {
4231
+ if (--this._eventsCount === 0) this._events = Object.create(null);else {
4232
+ delete events[type];
4233
+ if (events.removeListener) this.emit('removeListener', type, list.listener || listener);
4232
4234
  }
4235
+ } else if (typeof list !== 'function') {
4236
+ position = -1;
4237
+ for (i = list.length - 1; i >= 0; i--) {
4238
+ if (list[i] === listener || list[i].listener === listener) {
4239
+ originalListener = list[i].listener;
4240
+ position = i;
4241
+ break;
4242
+ }
4243
+ }
4244
+ if (position < 0) return this;
4245
+ if (position === 0) list.shift();else {
4246
+ spliceOne(list, position);
4247
+ }
4248
+ if (list.length === 1) events[type] = list[0];
4249
+ if (events.removeListener !== undefined) this.emit('removeListener', type, originalListener || listener);
4233
4250
  }
4234
- if (position < 0) return this;
4235
- if (position === 0) list.shift();else {
4236
- spliceOne(list, position);
4251
+ return this;
4252
+ };
4253
+ EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
4254
+ EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
4255
+ var listeners, events, i;
4256
+ events = this._events;
4257
+ if (events === undefined) return this;
4258
+
4259
+ // not listening for removeListener, no need to emit
4260
+ if (events.removeListener === undefined) {
4261
+ if (arguments.length === 0) {
4262
+ this._events = Object.create(null);
4263
+ this._eventsCount = 0;
4264
+ } else if (events[type] !== undefined) {
4265
+ if (--this._eventsCount === 0) this._events = Object.create(null);else delete events[type];
4266
+ }
4267
+ return this;
4237
4268
  }
4238
- if (list.length === 1) events[type] = list[0];
4239
- if (events.removeListener !== undefined) this.emit('removeListener', type, originalListener || listener);
4240
- }
4241
- return this;
4242
- };
4243
- EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
4244
- EventEmitter.prototype.removeAllListeners = function removeAllListeners(type) {
4245
- var listeners, events, i;
4246
- events = this._events;
4247
- if (events === undefined) return this;
4248
4269
 
4249
- // not listening for removeListener, no need to emit
4250
- if (events.removeListener === undefined) {
4270
+ // emit removeListener for all listeners on all events
4251
4271
  if (arguments.length === 0) {
4272
+ var keys = Object.keys(events);
4273
+ var key;
4274
+ for (i = 0; i < keys.length; ++i) {
4275
+ key = keys[i];
4276
+ if (key === 'removeListener') continue;
4277
+ this.removeAllListeners(key);
4278
+ }
4279
+ this.removeAllListeners('removeListener');
4252
4280
  this._events = Object.create(null);
4253
4281
  this._eventsCount = 0;
4254
- } else if (events[type] !== undefined) {
4255
- if (--this._eventsCount === 0) this._events = Object.create(null);else delete events[type];
4282
+ return this;
4256
4283
  }
4257
- return this;
4258
- }
4259
-
4260
- // emit removeListener for all listeners on all events
4261
- if (arguments.length === 0) {
4262
- var keys = Object.keys(events);
4263
- var key;
4264
- for (i = 0; i < keys.length; ++i) {
4265
- key = keys[i];
4266
- if (key === 'removeListener') continue;
4267
- this.removeAllListeners(key);
4284
+ listeners = events[type];
4285
+ if (typeof listeners === 'function') {
4286
+ this.removeListener(type, listeners);
4287
+ } else if (listeners !== undefined) {
4288
+ // LIFO order
4289
+ for (i = listeners.length - 1; i >= 0; i--) {
4290
+ this.removeListener(type, listeners[i]);
4291
+ }
4268
4292
  }
4269
- this.removeAllListeners('removeListener');
4270
- this._events = Object.create(null);
4271
- this._eventsCount = 0;
4272
4293
  return this;
4294
+ };
4295
+ function _listeners(target, type, unwrap) {
4296
+ var events = target._events;
4297
+ if (events === undefined) return [];
4298
+ var evlistener = events[type];
4299
+ if (evlistener === undefined) return [];
4300
+ if (typeof evlistener === 'function') return unwrap ? [evlistener.listener || evlistener] : [evlistener];
4301
+ return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
4273
4302
  }
4274
- listeners = events[type];
4275
- if (typeof listeners === 'function') {
4276
- this.removeListener(type, listeners);
4277
- } else if (listeners !== undefined) {
4278
- // LIFO order
4279
- for (i = listeners.length - 1; i >= 0; i--) {
4280
- this.removeListener(type, listeners[i]);
4303
+ EventEmitter.prototype.listeners = function listeners(type) {
4304
+ return _listeners(this, type, true);
4305
+ };
4306
+ EventEmitter.prototype.rawListeners = function rawListeners(type) {
4307
+ return _listeners(this, type, false);
4308
+ };
4309
+ EventEmitter.listenerCount = function (emitter, type) {
4310
+ if (typeof emitter.listenerCount === 'function') {
4311
+ return emitter.listenerCount(type);
4312
+ } else {
4313
+ return listenerCount.call(emitter, type);
4281
4314
  }
4282
- }
4283
- return this;
4284
- };
4285
- function _listeners(target, type, unwrap) {
4286
- var events = target._events;
4287
- if (events === undefined) return [];
4288
- var evlistener = events[type];
4289
- if (evlistener === undefined) return [];
4290
- if (typeof evlistener === 'function') return unwrap ? [evlistener.listener || evlistener] : [evlistener];
4291
- return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
4292
- }
4293
- EventEmitter.prototype.listeners = function listeners(type) {
4294
- return _listeners(this, type, true);
4295
- };
4296
- EventEmitter.prototype.rawListeners = function rawListeners(type) {
4297
- return _listeners(this, type, false);
4298
- };
4299
- EventEmitter.listenerCount = function (emitter, type) {
4300
- if (typeof emitter.listenerCount === 'function') {
4301
- return emitter.listenerCount(type);
4302
- } else {
4303
- return listenerCount.call(emitter, type);
4304
- }
4305
- };
4306
- EventEmitter.prototype.listenerCount = listenerCount;
4307
- function listenerCount(type) {
4308
- var events = this._events;
4309
- if (events !== undefined) {
4310
- var evlistener = events[type];
4311
- if (typeof evlistener === 'function') {
4312
- return 1;
4313
- } else if (evlistener !== undefined) {
4314
- return evlistener.length;
4315
+ };
4316
+ EventEmitter.prototype.listenerCount = listenerCount;
4317
+ function listenerCount(type) {
4318
+ var events = this._events;
4319
+ if (events !== undefined) {
4320
+ var evlistener = events[type];
4321
+ if (typeof evlistener === 'function') {
4322
+ return 1;
4323
+ } else if (evlistener !== undefined) {
4324
+ return evlistener.length;
4325
+ }
4315
4326
  }
4327
+ return 0;
4316
4328
  }
4317
- return 0;
4318
- }
4319
- EventEmitter.prototype.eventNames = function eventNames() {
4320
- return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
4321
- };
4322
- function arrayClone(arr, n) {
4323
- var copy = new Array(n);
4324
- for (var i = 0; i < n; ++i) copy[i] = arr[i];
4325
- return copy;
4326
- }
4327
- function spliceOne(list, index) {
4328
- for (; index + 1 < list.length; index++) list[index] = list[index + 1];
4329
- list.pop();
4330
- }
4331
- function unwrapListeners(arr) {
4332
- var ret = new Array(arr.length);
4333
- for (var i = 0; i < ret.length; ++i) {
4334
- ret[i] = arr[i].listener || arr[i];
4335
- }
4336
- return ret;
4337
- }
4338
- function once(emitter, name) {
4339
- return new Promise(function (resolve, reject) {
4340
- function errorListener(err) {
4341
- emitter.removeListener(name, resolver);
4342
- reject(err);
4329
+ EventEmitter.prototype.eventNames = function eventNames() {
4330
+ return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];
4331
+ };
4332
+ function arrayClone(arr, n) {
4333
+ var copy = new Array(n);
4334
+ for (var i = 0; i < n; ++i) copy[i] = arr[i];
4335
+ return copy;
4336
+ }
4337
+ function spliceOne(list, index) {
4338
+ for (; index + 1 < list.length; index++) list[index] = list[index + 1];
4339
+ list.pop();
4340
+ }
4341
+ function unwrapListeners(arr) {
4342
+ var ret = new Array(arr.length);
4343
+ for (var i = 0; i < ret.length; ++i) {
4344
+ ret[i] = arr[i].listener || arr[i];
4343
4345
  }
4344
- function resolver() {
4345
- if (typeof emitter.removeListener === 'function') {
4346
- emitter.removeListener('error', errorListener);
4346
+ return ret;
4347
+ }
4348
+ function once(emitter, name) {
4349
+ return new Promise(function (resolve, reject) {
4350
+ function errorListener(err) {
4351
+ emitter.removeListener(name, resolver);
4352
+ reject(err);
4347
4353
  }
4348
- resolve([].slice.call(arguments));
4349
- }
4350
- eventTargetAgnosticAddListener(emitter, name, resolver, {
4351
- once: true
4352
- });
4353
- if (name !== 'error') {
4354
- addErrorHandlerIfEventEmitter(emitter, errorListener, {
4354
+ function resolver() {
4355
+ if (typeof emitter.removeListener === 'function') {
4356
+ emitter.removeListener('error', errorListener);
4357
+ }
4358
+ resolve([].slice.call(arguments));
4359
+ }
4360
+ eventTargetAgnosticAddListener(emitter, name, resolver, {
4355
4361
  once: true
4356
4362
  });
4357
- }
4358
- });
4359
- }
4360
- function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
4361
- if (typeof emitter.on === 'function') {
4362
- eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
4363
+ if (name !== 'error') {
4364
+ addErrorHandlerIfEventEmitter(emitter, errorListener, {
4365
+ once: true
4366
+ });
4367
+ }
4368
+ });
4363
4369
  }
4364
- }
4365
- function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
4366
- if (typeof emitter.on === 'function') {
4367
- if (flags.once) {
4368
- emitter.once(name, listener);
4369
- } else {
4370
- emitter.on(name, listener);
4370
+ function addErrorHandlerIfEventEmitter(emitter, handler, flags) {
4371
+ if (typeof emitter.on === 'function') {
4372
+ eventTargetAgnosticAddListener(emitter, 'error', handler, flags);
4371
4373
  }
4372
- } else if (typeof emitter.addEventListener === 'function') {
4373
- // EventTarget does not have `error` event semantics like Node
4374
- // EventEmitters, we do not listen for `error` events here.
4375
- emitter.addEventListener(name, function wrapListener(arg) {
4376
- // IE does not have builtin `{ once: true }` support so we
4377
- // have to do it manually.
4374
+ }
4375
+ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
4376
+ if (typeof emitter.on === 'function') {
4378
4377
  if (flags.once) {
4379
- emitter.removeEventListener(name, wrapListener);
4378
+ emitter.once(name, listener);
4379
+ } else {
4380
+ emitter.on(name, listener);
4380
4381
  }
4381
- listener(arg);
4382
- });
4383
- } else {
4384
- throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
4382
+ } else if (typeof emitter.addEventListener === 'function') {
4383
+ // EventTarget does not have `error` event semantics like Node
4384
+ // EventEmitters, we do not listen for `error` events here.
4385
+ emitter.addEventListener(name, function wrapListener(arg) {
4386
+ // IE does not have builtin `{ once: true }` support so we
4387
+ // have to do it manually.
4388
+ if (flags.once) {
4389
+ emitter.removeEventListener(name, wrapListener);
4390
+ }
4391
+ listener(arg);
4392
+ });
4393
+ } else {
4394
+ throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof emitter);
4395
+ }
4385
4396
  }
4397
+ return events.exports;
4386
4398
  }
4387
- var eventsExports = events.exports;
4399
+
4400
+ var eventsExports = requireEvents();
4388
4401
 
4389
4402
  /**
4390
4403
  * Events are the primary way LiveKit notifies your application of changes.
@@ -4648,7 +4661,7 @@ var RoomEvent;
4648
4661
  */
4649
4662
  RoomEvent["MediaDevicesError"] = "mediaDevicesError";
4650
4663
  /**
4651
- * A participant's permission has changed. Currently only fired on LocalParticipant.
4664
+ * A participant's permission has changed.
4652
4665
  * args: (prevPermissions: [[ParticipantPermission]], participant: [[Participant]])
4653
4666
  */
4654
4667
  RoomEvent["ParticipantPermissionsChanged"] = "participantPermissionsChanged";
@@ -4829,7 +4842,7 @@ var ParticipantEvent;
4829
4842
  /** @internal */
4830
4843
  ParticipantEvent["AudioStreamAcquired"] = "audioStreamAcquired";
4831
4844
  /**
4832
- * A participant's permission has changed. Currently only fired on LocalParticipant.
4845
+ * A participant's permission has changed.
4833
4846
  * args: (prevPermissions: [[ParticipantPermission]])
4834
4847
  */
4835
4848
  ParticipantEvent["ParticipantPermissionsChanged"] = "participantPermissionsChanged";
@@ -5477,6 +5490,14 @@ class LivekitError extends Error {
5477
5490
  this.code = code;
5478
5491
  }
5479
5492
  }
5493
+ var ConnectionErrorReason;
5494
+ (function (ConnectionErrorReason) {
5495
+ ConnectionErrorReason[ConnectionErrorReason["NotAllowed"] = 0] = "NotAllowed";
5496
+ ConnectionErrorReason[ConnectionErrorReason["ServerUnreachable"] = 1] = "ServerUnreachable";
5497
+ ConnectionErrorReason[ConnectionErrorReason["InternalError"] = 2] = "InternalError";
5498
+ ConnectionErrorReason[ConnectionErrorReason["Cancelled"] = 3] = "Cancelled";
5499
+ ConnectionErrorReason[ConnectionErrorReason["LeaveRequest"] = 4] = "LeaveRequest";
5500
+ })(ConnectionErrorReason || (ConnectionErrorReason = {}));
5480
5501
  var MediaDeviceFailure;
5481
5502
  (function (MediaDeviceFailure) {
5482
5503
  // user rejected permissions
@@ -6242,7 +6263,7 @@ class ParticipantKeyHandler extends eventsExports.EventEmitter {
6242
6263
  this.decryptionFailureCount = 0;
6243
6264
  this._hasValidKey = true;
6244
6265
  this.currentKeyIndex = 0;
6245
- if (keyProviderOptions.keyringSize < 1 || keyProviderOptions.keyringSize > 255) {
6266
+ if (keyProviderOptions.keyringSize < 1 || keyProviderOptions.keyringSize > 256) {
6246
6267
  throw new TypeError('Keyring size needs to be between 1 and 256');
6247
6268
  }
6248
6269
  this.cryptoKeyRing = new Array(keyProviderOptions.keyringSize).fill(undefined);