hls.js 1.5.5-0.canary.9982 → 1.5.5-0.canary.9984

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/hls.mjs CHANGED
@@ -370,78 +370,6 @@ let ErrorDetails = /*#__PURE__*/function (ErrorDetails) {
370
370
  return ErrorDetails;
371
371
  }({});
372
372
 
373
- class Logger {
374
- constructor(label, logger) {
375
- this.trace = void 0;
376
- this.debug = void 0;
377
- this.log = void 0;
378
- this.warn = void 0;
379
- this.info = void 0;
380
- this.error = void 0;
381
- const lb = `[${label}]:`;
382
- this.trace = noop;
383
- this.debug = logger.debug.bind(null, lb);
384
- this.log = logger.log.bind(null, lb);
385
- this.warn = logger.warn.bind(null, lb);
386
- this.info = logger.info.bind(null, lb);
387
- this.error = logger.error.bind(null, lb);
388
- }
389
- }
390
- const noop = function noop() {};
391
- const fakeLogger = {
392
- trace: noop,
393
- debug: noop,
394
- log: noop,
395
- warn: noop,
396
- info: noop,
397
- error: noop
398
- };
399
- function createLogger() {
400
- return _extends({}, fakeLogger);
401
- }
402
-
403
- // let lastCallTime;
404
- // function formatMsgWithTimeInfo(type, msg) {
405
- // const now = Date.now();
406
- // const diff = lastCallTime ? '+' + (now - lastCallTime) : '0';
407
- // lastCallTime = now;
408
- // msg = (new Date(now)).toISOString() + ' | [' + type + '] > ' + msg + ' ( ' + diff + ' ms )';
409
- // return msg;
410
- // }
411
-
412
- function consolePrintFn(type, id) {
413
- const func = self.console[type];
414
- return func ? func.bind(self.console, `${id ? '[' + id + '] ' : ''}[${type}] >`) : noop;
415
- }
416
- function getLoggerFn(key, debugConfig, id) {
417
- return debugConfig[key] ? debugConfig[key].bind(debugConfig) : consolePrintFn(key, id);
418
- }
419
- let exportedLogger = createLogger();
420
- function enableLogs(debugConfig, context, id) {
421
- // check that console is available
422
- const newLogger = createLogger();
423
- if (typeof console === 'object' && debugConfig === true || typeof debugConfig === 'object') {
424
- const keys = [
425
- // Remove out from list here to hard-disable a log-level
426
- // 'trace',
427
- 'debug', 'log', 'info', 'warn', 'error'];
428
- keys.forEach(key => {
429
- newLogger[key] = getLoggerFn(key, debugConfig, id);
430
- });
431
- // Some browsers don't allow to use bind on console object anyway
432
- // fallback to default if needed
433
- try {
434
- newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.5-0.canary.9982"}`);
435
- } catch (e) {
436
- /* log fn threw an exception. All logger methods are no-ops. */
437
- return createLogger();
438
- }
439
- }
440
- exportedLogger = newLogger;
441
- return newLogger;
442
- }
443
- const logger = exportedLogger;
444
-
445
373
  const DECIMAL_RESOLUTION_REGEX = /^(\d+)x(\d+)$/;
446
374
  const ATTR_LIST_REGEX = /(.+?)=(".*?"|.*?)(?:,|$)/g;
447
375
 
@@ -523,6 +451,79 @@ class AttrList {
523
451
  }
524
452
  }
525
453
 
454
+ class Logger {
455
+ constructor(label, logger) {
456
+ this.trace = void 0;
457
+ this.debug = void 0;
458
+ this.log = void 0;
459
+ this.warn = void 0;
460
+ this.info = void 0;
461
+ this.error = void 0;
462
+ const lb = `[${label}]:`;
463
+ this.trace = noop;
464
+ this.debug = logger.debug.bind(null, lb);
465
+ this.log = logger.log.bind(null, lb);
466
+ this.warn = logger.warn.bind(null, lb);
467
+ this.info = logger.info.bind(null, lb);
468
+ this.error = logger.error.bind(null, lb);
469
+ }
470
+ }
471
+ const noop = function noop() {};
472
+ const fakeLogger = {
473
+ trace: noop,
474
+ debug: noop,
475
+ log: noop,
476
+ warn: noop,
477
+ info: noop,
478
+ error: noop
479
+ };
480
+ function createLogger() {
481
+ return _extends({}, fakeLogger);
482
+ }
483
+
484
+ // let lastCallTime;
485
+ // function formatMsgWithTimeInfo(type, msg) {
486
+ // const now = Date.now();
487
+ // const diff = lastCallTime ? '+' + (now - lastCallTime) : '0';
488
+ // lastCallTime = now;
489
+ // msg = (new Date(now)).toISOString() + ' | [' + type + '] > ' + msg + ' ( ' + diff + ' ms )';
490
+ // return msg;
491
+ // }
492
+
493
+ function consolePrintFn(type, id) {
494
+ const func = self.console[type];
495
+ return func ? func.bind(self.console, `${id ? '[' + id + '] ' : ''}[${type}] >`) : noop;
496
+ }
497
+ function getLoggerFn(key, debugConfig, id) {
498
+ return debugConfig[key] ? debugConfig[key].bind(debugConfig) : consolePrintFn(key, id);
499
+ }
500
+ const exportedLogger = createLogger();
501
+ function enableLogs(debugConfig, context, id) {
502
+ // check that console is available
503
+ const newLogger = createLogger();
504
+ if (typeof console === 'object' && debugConfig === true || typeof debugConfig === 'object') {
505
+ const keys = [
506
+ // Remove out from list here to hard-disable a log-level
507
+ // 'trace',
508
+ 'debug', 'log', 'info', 'warn', 'error'];
509
+ keys.forEach(key => {
510
+ newLogger[key] = getLoggerFn(key, debugConfig, id);
511
+ });
512
+ // Some browsers don't allow to use bind on console object anyway
513
+ // fallback to default if needed
514
+ try {
515
+ newLogger.log(`Debug logs enabled for "${context}" in hls.js version ${"1.5.5-0.canary.9984"}`);
516
+ } catch (e) {
517
+ /* log fn threw an exception. All logger methods are no-ops. */
518
+ return createLogger();
519
+ }
520
+ }
521
+ // global exported logger uses the log methods from last call to `enableLogs`
522
+ _extends(exportedLogger, newLogger);
523
+ return newLogger;
524
+ }
525
+ const logger = exportedLogger;
526
+
526
527
  // Avoid exporting const enum so that these values can be inlined
527
528
 
528
529
  function isDateRangeCueAttribute(attrName) {
@@ -3942,10 +3943,10 @@ class PlaylistLoader {
3942
3943
  const loaderContext = loader.context;
3943
3944
  if (loaderContext && loaderContext.url === context.url && loaderContext.level === context.level) {
3944
3945
  // same URL can't overlap
3945
- logger.trace('[playlist-loader]: playlist request ongoing');
3946
+ this.hls.logger.trace('[playlist-loader]: playlist request ongoing');
3946
3947
  return;
3947
3948
  }
3948
- logger.log(`[playlist-loader]: aborting previous loader for type: ${context.type}`);
3949
+ this.hls.logger.log(`[playlist-loader]: aborting previous loader for type: ${context.type}`);
3949
3950
  loader.abort();
3950
3951
  }
3951
3952
 
@@ -4055,7 +4056,7 @@ class PlaylistLoader {
4055
4056
  // alt audio rendition in which quality levels (main)
4056
4057
  // contains both audio+video. but with mixed audio track not signaled
4057
4058
  if (!embeddedAudioFound && levels[0].audioCodec && !levels[0].attrs.AUDIO) {
4058
- logger.log('[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one');
4059
+ this.hls.logger.log('[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one');
4059
4060
  audioTracks.unshift({
4060
4061
  type: 'main',
4061
4062
  name: 'main',
@@ -4154,7 +4155,7 @@ class PlaylistLoader {
4154
4155
  message += ` id: ${context.id} group-id: "${context.groupId}"`;
4155
4156
  }
4156
4157
  const error = new Error(message);
4157
- logger.warn(`[playlist-loader]: ${message}`);
4158
+ this.hls.logger.warn(`[playlist-loader]: ${message}`);
4158
4159
  let details = ErrorDetails.UNKNOWN;
4159
4160
  let fatal = false;
4160
4161
  const loader = this.getInternalLoader(context);
@@ -24586,7 +24587,7 @@ class CMCDController {
24586
24587
  su: !this.initialized
24587
24588
  });
24588
24589
  } catch (error) {
24589
- logger.warn('Could not generate manifest CMCD data.', error);
24590
+ this.hls.logger.warn('Could not generate manifest CMCD data.', error);
24590
24591
  }
24591
24592
  };
24592
24593
  /**
@@ -24614,7 +24615,7 @@ class CMCDController {
24614
24615
  }
24615
24616
  this.apply(context, data);
24616
24617
  } catch (error) {
24617
- logger.warn('Could not generate segment CMCD data.', error);
24618
+ this.hls.logger.warn('Could not generate segment CMCD data.', error);
24618
24619
  }
24619
24620
  };
24620
24621
  this.hls = hls;
@@ -28526,7 +28527,7 @@ class Hls {
28526
28527
  * Get the video-dev/hls.js package version.
28527
28528
  */
28528
28529
  static get version() {
28529
- return "1.5.5-0.canary.9982";
28530
+ return "1.5.5-0.canary.9984";
28530
28531
  }
28531
28532
 
28532
28533
  /**