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