@xibosignage/xibo-layout-renderer 1.0.5 → 1.0.6

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.
@@ -71382,6 +71382,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
71382
71382
  currentLayoutId: null,
71383
71383
  currentLayout: undefined,
71384
71384
  nextLayout: undefined,
71385
+ emitter: {},
71385
71386
  bootstrap: function bootstrap() {},
71386
71387
  init: function init() {
71387
71388
  return Promise.resolve({});
@@ -71470,6 +71471,39 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
71470
71471
  options: options
71471
71472
  };
71472
71473
  var xlrObject = _objectSpread2({}, initialXlr);
71474
+ var emitter = createNanoEvents();
71475
+ xlrObject.emitter = emitter;
71476
+ xlrObject.emitter.on('layoutChange', /*#__PURE__*/function () {
71477
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(layoutId) {
71478
+ var _xlrObject$nextLayout, _targetLayout, _targetLayout2;
71479
+ var targetLayout;
71480
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
71481
+ while (1) switch (_context.prev = _context.next) {
71482
+ case 0:
71483
+ if (layoutId === ((_xlrObject$nextLayout = xlrObject.nextLayout) === null || _xlrObject$nextLayout === void 0 ? void 0 : _xlrObject$nextLayout.layoutId)) {
71484
+ targetLayout = {
71485
+ layout: xlrObject.nextLayout,
71486
+ pos: exports.ELayoutType.NEXT
71487
+ };
71488
+ }
71489
+ if (!((_targetLayout = targetLayout) !== null && _targetLayout !== void 0 && _targetLayout.layout && (_targetLayout2 = targetLayout) !== null && _targetLayout2 !== void 0 && _targetLayout2.pos)) {
71490
+ _context.next = 5;
71491
+ break;
71492
+ }
71493
+ _context.next = 4;
71494
+ return xlrObject.prepareLayoutXlf(xlrObject.nextLayout);
71495
+ case 4:
71496
+ xlrObject.nextLayout = _context.sent;
71497
+ case 5:
71498
+ case "end":
71499
+ return _context.stop();
71500
+ }
71501
+ }, _callee);
71502
+ }));
71503
+ return function (_x) {
71504
+ return _ref.apply(this, arguments);
71505
+ };
71506
+ }());
71473
71507
  xlrObject.bootstrap = function () {
71474
71508
  // Place to set configurations and initialize required props
71475
71509
  var self = this;
@@ -71511,11 +71545,11 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
71511
71545
  this.updateLayouts(inputLayouts);
71512
71546
  };
71513
71547
  xlrObject.updateLayouts = /*#__PURE__*/function () {
71514
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(inputLayouts) {
71548
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(inputLayouts) {
71515
71549
  var _this2 = this;
71516
71550
  var xlr, _this$currentLayout, _this$nextLayout, currLayoutIndex, nxtLayoutIndex, tempOldNxtLayout, newNxtLayoutIndex, tempNxtLayout, hasOldNxtLayout, oldNxtLayoutIndex, _this$nextLayout2, tempNewNxtLayout;
71517
- return _regeneratorRuntime().wrap(function _callee$(_context) {
71518
- while (1) switch (_context.prev = _context.next) {
71551
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
71552
+ while (1) switch (_context2.prev = _context2.next) {
71519
71553
  case 0:
71520
71554
  /**
71521
71555
  * @TODO
@@ -71538,19 +71572,19 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
71538
71572
  var _this2$currentLayout;
71539
71573
  return inputLayout.layoutId === ((_this2$currentLayout = _this2.currentLayout) === null || _this2$currentLayout === void 0 ? void 0 : _this2$currentLayout.layoutId);
71540
71574
  }).length === 0)) {
71541
- _context.next = 11;
71575
+ _context2.next = 11;
71542
71576
  break;
71543
71577
  }
71544
71578
  // Unset currentLayout, nextLayout and layouts
71545
71579
  this.layouts = [];
71546
71580
  this.currentLayout = undefined;
71547
71581
  this.nextLayout = undefined;
71548
- _context.next = 7;
71582
+ _context2.next = 7;
71549
71583
  return this.prepareLayouts();
71550
71584
  case 7:
71551
- xlr = _context.sent;
71585
+ xlr = _context2.sent;
71552
71586
  this.playSchedules(xlr);
71553
- _context.next = 40;
71587
+ _context2.next = 40;
71554
71588
  break;
71555
71589
  case 11:
71556
71590
  /** Case 2: When currentLayout is in inputLayouts, then continue playing
@@ -71565,18 +71599,18 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
71565
71599
  tempOldNxtLayout = this.layouts[nxtLayoutIndex];
71566
71600
  newNxtLayoutIndex = currLayoutIndex + 1;
71567
71601
  if (!(nxtLayoutIndex !== newNxtLayoutIndex)) {
71568
- _context.next = 33;
71602
+ _context2.next = 33;
71569
71603
  break;
71570
71604
  }
71571
71605
  // Delete old nextLayout
71572
71606
  delete this.layouts[nxtLayoutIndex];
71573
71607
  if (!Boolean(this.layouts[newNxtLayoutIndex])) {
71574
- _context.next = 22;
71608
+ _context2.next = 22;
71575
71609
  break;
71576
71610
  }
71577
71611
  this.nextLayout = this.layouts[newNxtLayoutIndex];
71578
71612
  this.layouts[newNxtLayoutIndex] = this.nextLayout;
71579
- _context.next = 31;
71613
+ _context2.next = 31;
71580
71614
  break;
71581
71615
  case 22:
71582
71616
  // Check if newNxtLayoutIndex is still within inputLayouts
@@ -71585,14 +71619,14 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
71585
71619
  newNxtLayoutIndex = 0;
71586
71620
  }
71587
71621
  if (!Boolean(inputLayouts[newNxtLayoutIndex])) {
71588
- _context.next = 29;
71622
+ _context2.next = 29;
71589
71623
  break;
71590
71624
  }
71591
71625
  tempNxtLayout = _objectSpread2(_objectSpread2({}, initialLayout), inputLayouts[newNxtLayoutIndex]);
71592
- _context.next = 27;
71626
+ _context2.next = 27;
71593
71627
  return this.prepareLayoutXlf(tempNxtLayout);
71594
71628
  case 27:
71595
- this.nextLayout = _context.sent;
71629
+ this.nextLayout = _context2.sent;
71596
71630
  this.layouts[newNxtLayoutIndex] = this.nextLayout;
71597
71631
  case 29:
71598
71632
  // Move old nextLayout to its index
@@ -71604,18 +71638,18 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
71604
71638
  this.layouts[oldNxtLayoutIndex] = tempOldNxtLayout;
71605
71639
  }
71606
71640
  case 31:
71607
- _context.next = 40;
71641
+ _context2.next = 40;
71608
71642
  break;
71609
71643
  case 33:
71610
71644
  if (!(inputLayouts[nxtLayoutIndex].layoutId !== ((_this$nextLayout2 = this.nextLayout) === null || _this$nextLayout2 === void 0 ? void 0 : _this$nextLayout2.layoutId))) {
71611
- _context.next = 39;
71645
+ _context2.next = 39;
71612
71646
  break;
71613
71647
  }
71614
71648
  tempNewNxtLayout = _objectSpread2(_objectSpread2({}, initialLayout), inputLayouts[nxtLayoutIndex]);
71615
- _context.next = 37;
71649
+ _context2.next = 37;
71616
71650
  return this.prepareLayoutXlf(tempNewNxtLayout);
71617
71651
  case 37:
71618
- this.nextLayout = _context.sent;
71652
+ this.nextLayout = _context2.sent;
71619
71653
  this.layouts[nxtLayoutIndex] = this.nextLayout;
71620
71654
  case 39:
71621
71655
  // Remove old nextLayout if it's not in inputLayouts
@@ -71628,19 +71662,19 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
71628
71662
  }
71629
71663
  case 40:
71630
71664
  case "end":
71631
- return _context.stop();
71665
+ return _context2.stop();
71632
71666
  }
71633
- }, _callee, this);
71667
+ }, _callee2, this);
71634
71668
  }));
71635
- return function (_x) {
71636
- return _ref.apply(this, arguments);
71669
+ return function (_x2) {
71670
+ return _ref2.apply(this, arguments);
71637
71671
  };
71638
71672
  }();
71639
- xlrObject.prepareLayouts = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
71673
+ xlrObject.prepareLayouts = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
71640
71674
  var _xlrLayouts$current;
71641
71675
  var self, xlrLayouts, layoutsXlf, layouts;
71642
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
71643
- while (1) switch (_context2.prev = _context2.next) {
71676
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
71677
+ while (1) switch (_context3.prev = _context3.next) {
71644
71678
  case 0:
71645
71679
  self = this; // Get layouts
71646
71680
  xlrLayouts = getLayout({
@@ -71659,13 +71693,13 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
71659
71693
  return [].concat(_toConsumableArray(coll), [self.prepareLayoutXlf(item)]);
71660
71694
  }, []);
71661
71695
  };
71662
- _context2.next = 7;
71696
+ _context3.next = 7;
71663
71697
  return Promise.all(layoutsXlf());
71664
71698
  case 7:
71665
- layouts = _context2.sent;
71699
+ layouts = _context3.sent;
71666
71700
  console.debug('prepareLayouts::layouts', layouts);
71667
71701
  console.debug('prepareLayouts::xlr>layouts', self.layouts);
71668
- return _context2.abrupt("return", new Promise(function (resolve) {
71702
+ return _context3.abrupt("return", new Promise(function (resolve) {
71669
71703
  layouts.map(function (layoutItem) {
71670
71704
  if (!Boolean(self.layouts[layoutItem.index])) {
71671
71705
  self.layouts[layoutItem.index] = layoutItem;
@@ -71684,16 +71718,16 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
71684
71718
  }));
71685
71719
  case 11:
71686
71720
  case "end":
71687
- return _context2.stop();
71721
+ return _context3.stop();
71688
71722
  }
71689
- }, _callee2, this);
71723
+ }, _callee3, this);
71690
71724
  }));
71691
71725
  xlrObject.prepareLayoutXlf = /*#__PURE__*/function () {
71692
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(inputLayout) {
71726
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(inputLayout) {
71693
71727
  var _this3 = this;
71694
71728
  var self, newOptions, layoutXlf, layoutXlfNode, parser;
71695
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
71696
- while (1) switch (_context3.prev = _context3.next) {
71729
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
71730
+ while (1) switch (_context4.prev = _context4.next) {
71697
71731
  case 0:
71698
71732
  self = this; // Compose layout props first
71699
71733
  newOptions = Object.assign({}, platform);
@@ -71704,21 +71738,21 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
71704
71738
  newOptions.xlfUrl = inputLayout.path;
71705
71739
  }
71706
71740
  if (!(inputLayout && inputLayout.layoutNode === null)) {
71707
- _context3.next = 12;
71741
+ _context4.next = 12;
71708
71742
  break;
71709
71743
  }
71710
- _context3.next = 7;
71744
+ _context4.next = 7;
71711
71745
  return getXlf(newOptions);
71712
71746
  case 7:
71713
- layoutXlf = _context3.sent;
71747
+ layoutXlf = _context4.sent;
71714
71748
  parser = new window.DOMParser();
71715
71749
  layoutXlfNode = parser.parseFromString(layoutXlf, 'text/xml');
71716
- _context3.next = 13;
71750
+ _context4.next = 13;
71717
71751
  break;
71718
71752
  case 12:
71719
71753
  layoutXlfNode = inputLayout && inputLayout.layoutNode;
71720
71754
  case 13:
71721
- return _context3.abrupt("return", new Promise(function (resolve) {
71755
+ return _context4.abrupt("return", new Promise(function (resolve) {
71722
71756
  var xlrLayoutObj = initialLayout;
71723
71757
  xlrLayoutObj.id = Number(inputLayout.layoutId);
71724
71758
  xlrLayoutObj.layoutId = Number(inputLayout.layoutId);
@@ -71728,12 +71762,12 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
71728
71762
  }));
71729
71763
  case 14:
71730
71764
  case "end":
71731
- return _context3.stop();
71765
+ return _context4.stop();
71732
71766
  }
71733
- }, _callee3, this);
71767
+ }, _callee4, this);
71734
71768
  }));
71735
- return function (_x2) {
71736
- return _ref3.apply(this, arguments);
71769
+ return function (_x3) {
71770
+ return _ref4.apply(this, arguments);
71737
71771
  };
71738
71772
  }();
71739
71773
  xlrObject.bootstrap();