@xibosignage/xibo-layout-renderer 1.0.18 → 1.0.19

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.
@@ -668,7 +668,8 @@ var XiboLayoutRenderer = (function (exports) {
668
668
  xlr: {},
669
669
  finishAllRegions: function finishAllRegions() {
670
670
  return Promise.resolve([]);
671
- }
671
+ },
672
+ inLoop: true
672
673
  };
673
674
 
674
675
  function nextId(options) {
@@ -74144,7 +74145,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74144
74145
  });
74145
74146
  emitter.on('end', /*#__PURE__*/function () {
74146
74147
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(layout) {
74147
- var $layout;
74148
+ var $layout, _$layout$parentElemen;
74148
74149
  return _regeneratorRuntime().wrap(function _callee$(_context) {
74149
74150
  while (1) switch (_context.prev = _context.next) {
74150
74151
  case 0:
@@ -74156,7 +74157,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74156
74157
  $layout: $layout
74157
74158
  });
74158
74159
  if ($layout !== null) {
74159
- $layout.remove();
74160
+ (_$layout$parentElemen = $layout.parentElement) === null || _$layout$parentElemen === void 0 || _$layout$parentElemen.removeChild($layout);
74160
74161
  }
74161
74162
  // Check if stats are enabled for the layout
74162
74163
  if (layout.enableStat) {
@@ -74167,7 +74168,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74167
74168
  type: 'layout'
74168
74169
  });
74169
74170
  }
74170
- if (xlr.config.platform !== 'CMS') {
74171
+ if (xlr.config.platform !== 'CMS' && layout.inLoop) {
74171
74172
  // Transition next layout to current layout and prepare next layout if exist
74172
74173
  xlr.prepareLayouts().then(function (parent) {
74173
74174
  xlr.playSchedules(parent);
@@ -74326,43 +74327,46 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74326
74327
  self.end();
74327
74328
  }
74328
74329
  };
74329
- layoutObject.regionEnded = function () {
74330
- var self = layoutObject;
74331
- self.allEnded = true;
74332
- for (var i = 0; i < self.regions.length; i++) {
74333
- if (!self.regions[i].ended) {
74334
- self.allEnded = false;
74335
- }
74336
- }
74337
- if (self.allEnded) {
74338
- self.stopAllMedia().then( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
74339
- var $end, $preview;
74340
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
74341
- while (1) switch (_context2.prev = _context2.next) {
74342
- case 0:
74343
- console.debug('starting to end layout . . .');
74344
- if (xlr.config.platform === 'CMS') {
74345
- $end = document.getElementById('play_ended');
74346
- $preview = document.getElementById('screen_container');
74347
- if ($preview) {
74348
- while ($preview.firstChild) {
74349
- $preview.removeChild($preview.firstChild);
74350
- }
74351
- $preview.style.display = 'none';
74352
- }
74353
- if ($end) {
74354
- $end.style.display = 'block';
74355
- }
74330
+ layoutObject.regionEnded = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
74331
+ var self, i, $end, $preview;
74332
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
74333
+ while (1) switch (_context2.prev = _context2.next) {
74334
+ case 0:
74335
+ self = layoutObject;
74336
+ self.allEnded = true;
74337
+ for (i = 0; i < self.regions.length; i++) {
74338
+ if (!self.regions[i].ended) {
74339
+ self.allEnded = false;
74340
+ }
74341
+ }
74342
+ if (!self.allEnded) {
74343
+ _context2.next = 9;
74344
+ break;
74345
+ }
74346
+ _context2.next = 6;
74347
+ return self.stopAllMedia();
74348
+ case 6:
74349
+ console.debug('starting to end layout . . .');
74350
+ if (xlr.config.platform === 'CMS') {
74351
+ $end = document.getElementById('play_ended');
74352
+ $preview = document.getElementById('screen_container');
74353
+ if ($preview) {
74354
+ while ($preview.firstChild) {
74355
+ $preview.removeChild($preview.firstChild);
74356
74356
  }
74357
- self.emitter.emit('end', self);
74358
- case 3:
74359
- case "end":
74360
- return _context2.stop();
74357
+ $preview.style.display = 'none';
74358
+ }
74359
+ if ($end) {
74360
+ $end.style.display = 'block';
74361
+ }
74361
74362
  }
74362
- }, _callee2);
74363
- })));
74364
- }
74365
- };
74363
+ self.emitter.emit('end', self);
74364
+ case 9:
74365
+ case "end":
74366
+ return _context2.stop();
74367
+ }
74368
+ }, _callee2);
74369
+ }));
74366
74370
  layoutObject.end = function () {
74367
74371
  console.debug('Executing Layout::end and Calling Region::end ', layoutObject);
74368
74372
  /* Ask the layout to gracefully stop running now */
@@ -74612,7 +74616,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74612
74616
  xlrObject.updateLayouts = /*#__PURE__*/function () {
74613
74617
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(inputLayouts) {
74614
74618
  var _this2 = this;
74615
- var xlr, _this$currentLayout, _this$nextLayout, currLayoutIndex, nxtLayoutIndex, tempOldNxtLayout, newNxtLayoutIndex, tempNxtLayout, hasOldNxtLayout, oldNxtLayoutIndex, _this$nextLayout2, tempNewNxtLayout;
74619
+ var _this$currentLayout, xlr, _this$currentLayout2, _this$nextLayout, currLayoutIndex, nxtLayoutIndex, tempOldNxtLayout, newNxtLayoutIndex, tempNxtLayout, hasOldNxtLayout, oldNxtLayoutIndex, _this$nextLayout2, tempNewNxtLayout;
74616
74620
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
74617
74621
  while (1) switch (_context2.prev = _context2.next) {
74618
74622
  case 0:
@@ -74634,39 +74638,49 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74634
74638
  * Case 0: When inputLayouts length = 0
74635
74639
  */
74636
74640
  if (!(inputLayouts.length === 0)) {
74637
- _context2.next = 9;
74641
+ _context2.next = 10;
74638
74642
  break;
74639
74643
  }
74640
74644
  this.layouts = [];
74645
+ if (this.currentLayout) {
74646
+ this.currentLayout.inLoop = false;
74647
+ }
74641
74648
  this.currentLayout = undefined;
74642
74649
  this.nextLayout = undefined;
74643
74650
  this.currentLayoutIndex = 0;
74644
74651
  this.prepareLayouts().then(function (xlr) {
74645
74652
  _this2.playSchedules(xlr);
74646
74653
  });
74647
- _context2.next = 49;
74654
+ _context2.next = 65;
74648
74655
  break;
74649
- case 9:
74656
+ case 10:
74650
74657
  if (!(inputLayouts.filter(function (inputLayout) {
74651
74658
  var _this2$currentLayout;
74652
74659
  return inputLayout.layoutId === ((_this2$currentLayout = _this2.currentLayout) === null || _this2$currentLayout === void 0 ? void 0 : _this2$currentLayout.layoutId);
74653
74660
  }).length === 0)) {
74654
- _context2.next = 20;
74661
+ _context2.next = 24;
74655
74662
  break;
74656
74663
  }
74657
74664
  // Unset currentLayout, nextLayout and layouts
74658
74665
  this.layouts = [];
74666
+ if (this.currentLayout) {
74667
+ this.currentLayout.inLoop = false;
74668
+ }
74669
+ // Clean up currentLayout
74670
+ _context2.next = 15;
74671
+ return (_this$currentLayout = this.currentLayout) === null || _this$currentLayout === void 0 ? void 0 : _this$currentLayout.finishAllRegions();
74672
+ case 15:
74659
74673
  this.currentLayout = undefined;
74660
74674
  this.nextLayout = undefined;
74661
74675
  this.currentLayoutIndex = 0;
74662
- _context2.next = 16;
74676
+ _context2.next = 20;
74663
74677
  return this.prepareLayouts();
74664
- case 16:
74678
+ case 20:
74665
74679
  xlr = _context2.sent;
74666
74680
  this.playSchedules(xlr);
74667
- _context2.next = 49;
74681
+ _context2.next = 65;
74668
74682
  break;
74669
- case 20:
74683
+ case 24:
74670
74684
  /** Case 2: When currentLayout is in inputLayouts, then continue playing
74671
74685
  * Also check for nextLayout if in inputLayouts and same sequence, then don't change and continue playing.
74672
74686
  * If not in inputLayouts, then replace and prepare nextLayout.
@@ -74674,73 +74688,92 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74674
74688
  // 2.1 We don't have to do anything for currentLayout
74675
74689
  // 2.2 Check for nextLayout
74676
74690
  // Get nextLayout index
74677
- currLayoutIndex = getIndexByLayoutId(inputLayouts, (_this$currentLayout = this.currentLayout) === null || _this$currentLayout === void 0 ? void 0 : _this$currentLayout.layoutId).index;
74691
+ currLayoutIndex = getIndexByLayoutId(inputLayouts, (_this$currentLayout2 = this.currentLayout) === null || _this$currentLayout2 === void 0 ? void 0 : _this$currentLayout2.layoutId).index;
74678
74692
  nxtLayoutIndex = getIndexByLayoutId(inputLayouts, (_this$nextLayout = this.nextLayout) === null || _this$nextLayout === void 0 ? void 0 : _this$nextLayout.layoutId).index;
74679
74693
  tempOldNxtLayout = this.layouts[nxtLayoutIndex];
74680
74694
  newNxtLayoutIndex = currLayoutIndex + 1;
74681
74695
  if (!(nxtLayoutIndex !== newNxtLayoutIndex)) {
74682
- _context2.next = 42;
74696
+ _context2.next = 54;
74683
74697
  break;
74684
74698
  }
74685
74699
  // Delete old nextLayout
74686
74700
  delete this.layouts[nxtLayoutIndex];
74687
74701
  if (!Boolean(this.layouts[newNxtLayoutIndex])) {
74688
- _context2.next = 31;
74702
+ _context2.next = 35;
74689
74703
  break;
74690
74704
  }
74691
74705
  this.nextLayout = this.layouts[newNxtLayoutIndex];
74692
74706
  this.layouts[newNxtLayoutIndex] = this.nextLayout;
74693
- _context2.next = 40;
74707
+ _context2.next = 52;
74694
74708
  break;
74695
- case 31:
74709
+ case 35:
74696
74710
  // Check if newNxtLayoutIndex is still within inputLayouts
74697
74711
  if (newNxtLayoutIndex + 1 > inputLayouts.length) {
74698
74712
  // Goes back to first layout in the sequence
74699
74713
  newNxtLayoutIndex = 0;
74700
74714
  }
74701
74715
  if (!Boolean(inputLayouts[newNxtLayoutIndex])) {
74702
- _context2.next = 38;
74716
+ _context2.next = 42;
74703
74717
  break;
74704
74718
  }
74705
74719
  tempNxtLayout = _objectSpread2(_objectSpread2({}, initialLayout), inputLayouts[newNxtLayoutIndex]);
74706
- _context2.next = 36;
74720
+ _context2.next = 40;
74707
74721
  return this.prepareLayoutXlf(tempNxtLayout);
74708
- case 36:
74722
+ case 40:
74709
74723
  this.nextLayout = _context2.sent;
74710
74724
  this.layouts[newNxtLayoutIndex] = this.nextLayout;
74711
- case 38:
74725
+ case 42:
74712
74726
  // Move old nextLayout to its index
74713
74727
  hasOldNxtLayout = inputLayouts.filter(function (_layout) {
74714
74728
  return _layout.layoutId === (tempOldNxtLayout === null || tempOldNxtLayout === void 0 ? void 0 : tempOldNxtLayout.layoutId);
74715
74729
  });
74716
- if (hasOldNxtLayout.length === 1) {
74717
- oldNxtLayoutIndex = getIndexByLayoutId(inputLayouts, hasOldNxtLayout[0].layoutId).index;
74718
- this.layouts[oldNxtLayoutIndex] = tempOldNxtLayout;
74730
+ if (!(hasOldNxtLayout.length === 1)) {
74731
+ _context2.next = 48;
74732
+ break;
74719
74733
  }
74720
- case 40:
74721
- _context2.next = 49;
74734
+ oldNxtLayoutIndex = getIndexByLayoutId(inputLayouts, hasOldNxtLayout[0].layoutId).index;
74735
+ this.layouts[oldNxtLayoutIndex] = tempOldNxtLayout;
74736
+ _context2.next = 52;
74722
74737
  break;
74723
- case 42:
74738
+ case 48:
74739
+ if (!tempOldNxtLayout) {
74740
+ _context2.next = 52;
74741
+ break;
74742
+ }
74743
+ _context2.next = 51;
74744
+ return tempOldNxtLayout.finishAllRegions();
74745
+ case 51:
74746
+ delete this.layouts[tempOldNxtLayout.index];
74747
+ case 52:
74748
+ _context2.next = 65;
74749
+ break;
74750
+ case 54:
74724
74751
  if (!(inputLayouts[nxtLayoutIndex].layoutId !== ((_this$nextLayout2 = this.nextLayout) === null || _this$nextLayout2 === void 0 ? void 0 : _this$nextLayout2.layoutId))) {
74725
- _context2.next = 48;
74752
+ _context2.next = 60;
74726
74753
  break;
74727
74754
  }
74728
74755
  tempNewNxtLayout = _objectSpread2(_objectSpread2({}, initialLayout), inputLayouts[nxtLayoutIndex]);
74729
- _context2.next = 46;
74756
+ _context2.next = 58;
74730
74757
  return this.prepareLayoutXlf(tempNewNxtLayout);
74731
- case 46:
74758
+ case 58:
74732
74759
  this.nextLayout = _context2.sent;
74733
74760
  this.layouts[nxtLayoutIndex] = this.nextLayout;
74734
- case 48:
74735
- // Remove old nextLayout if it's not in inputLayouts
74736
- if (tempOldNxtLayout !== null && tempOldNxtLayout !== void 0 && tempOldNxtLayout.index && Boolean(this.layouts[tempOldNxtLayout === null || tempOldNxtLayout === void 0 ? void 0 : tempOldNxtLayout.index])) {
74737
- if (inputLayouts.filter(function (_layout) {
74738
- return _layout.layoutId === (tempOldNxtLayout === null || tempOldNxtLayout === void 0 ? void 0 : tempOldNxtLayout.layoutId);
74739
- }).length === 0) {
74740
- delete this.layouts[tempOldNxtLayout === null || tempOldNxtLayout === void 0 ? void 0 : tempOldNxtLayout.index];
74741
- }
74761
+ case 60:
74762
+ if (!(tempOldNxtLayout !== null && tempOldNxtLayout !== void 0 && tempOldNxtLayout.index && Boolean(this.layouts[tempOldNxtLayout === null || tempOldNxtLayout === void 0 ? void 0 : tempOldNxtLayout.index]))) {
74763
+ _context2.next = 65;
74764
+ break;
74765
+ }
74766
+ if (!(inputLayouts.filter(function (_layout) {
74767
+ return _layout.layoutId === (tempOldNxtLayout === null || tempOldNxtLayout === void 0 ? void 0 : tempOldNxtLayout.layoutId);
74768
+ }).length === 0)) {
74769
+ _context2.next = 65;
74770
+ break;
74742
74771
  }
74743
- case 49:
74772
+ _context2.next = 64;
74773
+ return tempOldNxtLayout.finishAllRegions();
74774
+ case 64:
74775
+ delete this.layouts[tempOldNxtLayout === null || tempOldNxtLayout === void 0 ? void 0 : tempOldNxtLayout.index];
74776
+ case 65:
74744
74777
  case "end":
74745
74778
  return _context2.stop();
74746
74779
  }
@@ -74851,7 +74884,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74851
74884
  }();
74852
74885
  xlrObject.gotoPrevLayout = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5() {
74853
74886
  var _this4 = this;
74854
- var _currentLayoutIndex, _assumedPrevIndex, _this$currentLayout2;
74887
+ var _currentLayoutIndex, _assumedPrevIndex, _this$currentLayout3;
74855
74888
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
74856
74889
  while (1) switch (_context5.prev = _context5.next) {
74857
74890
  case 0:
@@ -74873,7 +74906,7 @@ ${segmentInfoString(segmentInfo)}`); // If there's an init segment associated wi
74873
74906
  break;
74874
74907
  }
74875
74908
  _context5.next = 8;
74876
- return (_this$currentLayout2 = this.currentLayout) === null || _this$currentLayout2 === void 0 ? void 0 : _this$currentLayout2.finishAllRegions();
74909
+ return (_this$currentLayout3 = this.currentLayout) === null || _this$currentLayout3 === void 0 ? void 0 : _this$currentLayout3.finishAllRegions();
74877
74910
  case 8:
74878
74911
  // and set the previous layout as current layout
74879
74912
  this.currentLayoutIndex = _assumedPrevIndex;